def dot(mtr0,mtr1): a,b=len(mtr0),len(mtr1[0]) t=len(mtr0[0]) if t!=len(mtr1):return None ret=[[0]*b for _ in range(a)] for i in range(a): for j in range(b): tmp=0 for k in range(t): tmp+=mtr0[i][k]*mtr1[k][j] if tmp>0:tmp=1 ret[i][j]=tmp return ret def main0(n,m,t,ab): # ダブリング。O(n^2) g=[[0]*n for _ in range(n)] for a,b in ab: a,b=a-1,b-1 g[b][a]=1 vc=[[0] for _ in range(n)] vc[0][0]=1 for i in range(63): if t&(1<