Pagini recente » Cod sursa (job #17577) | Cod sursa (job #2826453) | Cod sursa (job #3188735) | Cod sursa (job #3248388) | Cod sursa (job #3183073)
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <climits>
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("nrcuv.in");
ofstream fout("nrcuv.out");
int n,m,dp[1005][1005],r,p1,p2,ans;
int f[35][35];
char x,y;
const int MOD=104659;
int main()
{
fin>>n>>m;
for(int i=1;i<=m;i++)
{
fin>>x>>y;
f[x-'a'+1][y-'a'+1]=1;
f[y-'a'+1][x-'a'+1]=1;
}
for(int i=1;i<=26;i++)
{
dp[1][i]=1;
}
for(int i=2;i<=n;i++)
{
for(int j=1;j<=26;j++)
{
for(int k=1;k<=26;k++)
{
if(!f[j][k])
{
dp[i][k]=(dp[i-1][j]+dp[i][k])%MOD;
}
}
}
}
for(int i=1;i<=26;i++)
{
ans=(ans+dp[n][i])%MOD;
}
fout<<ans;
fin.close();
fout.close();
return 0;
}