Pagini recente » Cod sursa (job #2825131) | Cod sursa (job #2564453) | Cod sursa (job #14587) | Cod sursa (job #2128248) | Cod sursa (job #1820026)
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#define N 2005
#define LLi long long int
using namespace std;
ifstream f("nrcuv.in");
ofstream g("nrcuv.out");
LLi n,m,i,j;
string s,s1;
LLi const MOD=104659;
pair<char,char> Pair[N];
LLi pow1(LLi x,LLi y)
{
LLi p=1;
while(y>0)
{
if(y%2!=0)
{
p=p*x;
}
x=x*x;
y=y/2;
}
return p;
}
inline void read()
{
f>>n>>m;
for(int i=0;i<m;i++)
{
f>>Pair[i].first>>Pair[i].second;
if(Pair[i].first>Pair[i].second)
swap(Pair[i].first,Pair[i].second);
}
sort(Pair,Pair+m);
}
inline void rezolvare()
{
int cont=0;
for(int i=0;i<m;i++)
{
if(Pair[i].first!=Pair[i-1].first && Pair[i].second!=Pair[i-1].second)
cont++;
if(Pair[i].first!=Pair[i].second)
cont++;
}
g<<pow1(26,n)-((pow1(26,n-2)*(n-1)*cont))%MOD;
}
int main()
{
read();
rezolvare();
}