n,m=map(int,input().split());D=[0]*2**n;D[-1]=1 for _ in'.'*m: i,j,p=map(eval,input().split());i-=1;j-=1 for b in range(1<