import itertools n,m=map(int,input().split()) l=[list(map(int,input().split())) for i in range(m)] num=[i+1 for i in range(n)] ans=0 for i in itertools.permutations(num): l2=[0]*n for j in range(n): l2[i[j]-1]=j ct=0 for j in range(m): if l2[l[j][0]-1]