#include using namespace std; typedef long long ll; const int N=33*33*33*33; int n,m,q,cntb,cnt,fr[4],deg[N],dfn[N],low[N],bel[N],pri[]={0,2,3,5,7,11,13,17,19,23,27,29,31},num[33][33]; ll f[N],val[N],valb[N]; bool vis[N],ex[N]; stack stk; unordered_map mp; string s,t; vector a[N],b[N]; int id(int a,int b,int c,int d) { int t=n+1; return a*t*t*t+b*t*t+c*t+d; } ll q_pow(ll a,ll b) { ll ret=1; while(b) { if(b&1) ret=ret*a; a=a*a; b>>=1; } return ret; } void tarjan(int u) { dfn[u]=low[u]=++cnt; stk.push(u); vis[u]=true; for(int i=0;i que; for(int i=1;i<=cntb;i++) if(!deg[i]) que.push(i); while(!que.empty()) { int u=que.front(); que.pop(); f[u]+=valb[u]; for(int i=0;i>n>>m; init(); for(int i=1;i<=m;i++) { cin>>s>>t; if(s==t) continue; memset(fr,0,sizeof(fr)); for(int j=0;j