Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N,M=map(int,input().split())
A,B,C,D=[0]*M,[0]*M,[],[]
for i in range(M):
    A[i],B[i]=map(int,input().split())
    if A[i]==1:
        C.append(i)
    else:
        D.append(i)

res=0
for j in C:
    for p in itertools.permutations(D,N-2):
        path=[1,B[j]]
        for i in p:
            if A[i]==path[-1]:
                if not B[i] in path:
                    path.append(B[i])
                else:
                    break
            elif B[i]==path[-1]:
                if not A[i] in path:
                    path.append(A[i])
                else:
                    break
            else:
                break
        else:
            path.sort()
            if path==list(range(1,N+1)):
                res+=1
print(res)

Fixed submission:
import itertools
N,M=map(int,input().split())
edges=[]
for i in range(M):
    edges.append(list(map(int,input().split())))

res=0
for i in itertools.permutations(range(2,N+1),N-1):
    path=[1]+list(i)
    check=[sorted(path[i:i+2]) in edges for i in range(len(path)-1)]
    if not False in check:
        res+=1
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N,M=map(int,input().split())
A,B=[0]*M,[0]*M
for i in range(M):
    A[i],B[i]=map(int,input().split())

res=0
for p in itertools.permutations(range(M),N-1):
    path=[]
    if A[p[0]]==1:
        path.append(A[p[0]])
    else:
        continue
    path.append(B[p[0]])
    for i in range(len(p)-1):
        if A[p[i+1]]==path[-1]:
            if not B[p[i+1]] in path:
                path.append(B[p[i+1]])
            else:
                break
        elif B[p[i+1]]==path[-1]:
            if not A[p[i+1]] in path:
                path.append(A[p[i+1]])
            else:
                break
        else:
            break
    else:
        path.sort()
        if path==list(range(1,N+1)):
            res+=1
print(res)

Fixed submission:
import itertools
N,M=map(int,input().split())
edges=[]
for i in range(M):
    edges.append(list(map(int,input().split())))

res=0
for i in itertools.permutations(range(2,N+1),N-1):
    path=[1]+list(i)
    check=[sorted(path[i:i+2]) in edges for i in range(len(path)-1)]
    if not False in check:
        res+=1
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N,M=map(int,input().split())
A,B=[0]*M,[0]*M
for i in range(M):
    A[i],B[i]=map(int,input().split())

res=0
for p in itertools.permutations(range(M),N-1):
    path=[]
    if A[p[0]]==1:
        path.append(A[p[0]])
    else:
        continue
    path.append(B[p[0]])
    for i in range(len(p)-1):
        if A[p[i+1]]==path[-1]:
            if not B[p[i+1]] in path:
                path.append(B[p[i+1]])
            else:
                break
        elif B[p[i+1]]==path[-1]:
            if not A[p[i+1]] in path:
                path.append(A[p[i+1]])
            else:
                break
        else:
            break
    else:
        path.sort()
        if path==list(range(1,N+1)):
            res+=1
print(res)

Fixed submission:
import itertools
N,M=map(int,input().split())
edges=[]
for i in range(M):
    edges.append(list(map(int,input().split())))

res=0
for i in itertools.permutations(range(2,N+1),N-1):
    path=[1]+list(i)
    check=[sorted(path[i:i+2]) in edges for i in range(len(path)-1)]
    if not False in check:
        res+=1
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N,M=map(int,input().split())
A,B=[0]*M,[0]*M
for i in range(M):
    A[i],B[i]=map(int,input().split())

res=0
for p in itertools.permutations(range(M),N-1):
    path=[]
    if A[p[0]]==1:
        path.append(A[p[0]])
    else:
        continue
    path.append(B[p[0]])
    for i in range(len(p)-1):
        if A[p[i+1]]==path[-1]:
            path.append(B[p[i+1]])
        elif B[p[i+1]]==path[-1]:
            path.append(A[p[i+1]])
        else:
            break
    else:
        path.sort()
        if path==list(range(1,N+1)):
            res+=1
print(res)

Fixed submission:
import itertools
N,M=map(int,input().split())
edges=[]
for i in range(M):
    edges.append(list(map(int,input().split())))

res=0
for i in itertools.permutations(range(2,N+1),N-1):
    path=[1]+list(i)
    check=[sorted(path[i:i+2]) in edges for i in range(len(path)-1)]
    if not False in check:
        res+=1
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N,M=map(int,input().split())
A,B=[0]*M,[0]*M
for i in range(M):
    A[i],B[i]=map(int,input().split())

res=0
for m in range(M):
    m+=1
    for p in itertools.permutations(range(M),m):
        path=[]
        if A[p[0]]==1:
            path.append(A[p[0]])
        else:
            continue
        path.append(B[p[0]])
        for i in range(len(p)-1):
            if A[p[i+1]]==path[-1]:
                path.append(B[p[i+1]])
            elif B[p[i+1]]==path[-1]:
                path.append(A[p[i+1]])
            else:
                break
        else:
            path.sort()
            if path==list(range(1,N+1)):
                res+=1
print(res)

Fixed submission:
import itertools
N,M=map(int,input().split())
edges=[]
for i in range(M):
    edges.append(list(map(int,input().split())))

res=0
for i in itertools.permutations(range(2,N+1),N-1):
    path=[1]+list(i)
    check=[sorted(path[i:i+2]) in edges for i in range(len(path)-1)]
    if not False in check:
        res+=1
print(res)