Graph by gre

def g():\x0d
 p,n=map(int,raw_input().split());A=[]\x0d
 for _ in range(n):A.append(map(int,raw_input().split()));B=A[:]\x0d
 for _ in range(p-1):B=m(B,A)\x0d
 return B[0][1:]\x0d
def m(A,B):\x0d
 n=len(A);C=[[0 for _ in range(n)]for _ in range(n)]\x0d
 for i in range(n):\x0d
  for j in range(n):\x0d
   for k in range(n):C[i][j]+=A[i][k]*B[k][j]\x0d
 return C\x0d
def p():\x0d
 for v in g(): print v,\x0d
 print\x0d
while 1:\x0d
 try:p()\x0d
 except EOFError:break

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top