Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
N, M = map(int, input().split())
G = {k: [] for k in range(N)}
for _ in range(N):
    a, b = map(int, input().split())
    # 無向グラフ
    G[a-1].append(b-1)
    G[b-1].append(a-1)

visited = [False]*N
visited[0] = True


def dfs(v):
    if all(visited):
        return 1
    r = 0
    for nv in G[v]:
        if visited[nv] is False:
            visited[nv] = True
            r += dfs(nv)
            visited[nv] = False
    return r


print(dfs(0))


Fixed submission:
import itertools

N,M=map(int,input().split())
route=[list(map(int,input().split())) for _ in range(M)]
candidate=list(itertools.permutations(range(1,N+1)))

ans=0
for c in candidate:
  if c[0]==1:
    for i in range(N-1):
      l=sorted([c[i], c[i+1]])
      if l not in route:
         break
    else:
      ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
N, M = map(int, input().split())
G = {k: [] for k in range(N+1)}
for _ in range(N):
    a, b = map(int, input().split())
    # 無向グラフ
    G[a-1].append(b-1)
    G[b-1].append(a-1)

visited = [False]*N
visited[0] = True


def dfs(v):
    if all(visited):
        return 1
    r = 0
    for nv in G[v]:
        if visited[nv] is False:
            visited[nv] = True
            r += dfs(nv)
            visited[nv] = False
    return r


print(dfs(0))


Fixed submission:
import itertools

N,M=map(int,input().split())
route=[list(map(int,input().split())) for _ in range(M)]
candidate=list(itertools.permutations(range(1,N+1)))

ans=0
for c in candidate:
  if c[0]==1:
    for i in range(N-1):
      l=sorted([c[i], c[i+1]])
      if l not in route:
         break
    else:
      ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
N, M = map(int, input().split())
G = {k: [] for k in range(N+1)}
for _ in range(N):
    a, b = map(int, input().split())
    # 無向グラフ
    G[a-1].append(b-1)
    G[b-1].append(a-1)

visited = [False]*N
visited[0] = True


def dfs(v):
    if all(visited):
        return 1
    r = 0
    for nv in G[v]:
        if visited[nv] is False:
            visited[nv] = True
            r += dfs(nv)
            visited[nv] = False
    return r


print(dfs(0))


Fixed submission:
import itertools

N,M=map(int,input().split())
route=[list(map(int,input().split())) for _ in range(M)]
candidate=list(itertools.permutations(range(1,N+1)))

ans=0
for c in candidate:
  if c[0]==1:
    for i in range(N-1):
      l=sorted([c[i], c[i+1]])
      if l not in route:
         break
    else:
      ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
G = {k: [] for k in range(N+1)}
for _ in range(N):
    a, b = map(int, input().split())
    # 無向グラフ
    G[a-1].append(b-1)
    G[b-1].append(a-1)

visited = [False]*N
visited[0] = True
ans = 0


def dfs(v):
    if all(visited):
        return 1
    r = 0
    for nv in G[v]:
        if visited[nv] is False:
            visited[nv] = True
            r += dfs(nv)
            visited[nv] = False
    return r


print(dfs(0))


Fixed submission:
import itertools

N,M=map(int,input().split())
route=[list(map(int,input().split())) for _ in range(M)]
candidate=list(itertools.permutations(range(1,N+1)))

ans=0
for c in candidate:
  if c[0]==1:
    for i in range(N-1):
      l=sorted([c[i], c[i+1]])
      if l not in route:
         break
    else:
      ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
G = {k: [] for k in range(N+1)}
for _ in range(N):
    a, b = map(int, input().split())
    # 無向グラフ
    G[a-1].append(b-1)
    G[b-1].append(a-1)

visited = [False]*N
visited[0] = True


def dfs(v):
    if all(visited):
        ans += 1
        return
    for nv in G[i]:
        if visited[nv] is False:
            visited[nv] = True
            dfs(nv)
            visited[nv] = False
    return


ans = 0
dfs(0)
print(ans)


Fixed submission:
import itertools

N,M=map(int,input().split())
route=[list(map(int,input().split())) for _ in range(M)]
candidate=list(itertools.permutations(range(1,N+1)))

ans=0
for c in candidate:
  if c[0]==1:
    for i in range(N-1):
      l=sorted([c[i], c[i+1]])
      if l not in route:
         break
    else:
      ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N, M = map(int, input().split())
V = []
for i in range(M):
    a, b = map(int, input().split())
    V.append((a-1, b-1))


def bfs(G):
    visited = [False] * N
    visited[0] = True
    que = deque([(0, -1, 0)])
    r = 0
    while que:
        ci, p, d = que.popleft()
        for ni in G[ci]:
            if visited[ni] is False:
                visited[ni] = True
                que.append((ni, ci, d+1))
                r = max(r, d+1)

    return r


ans = 0
for i in range(2 ** M):
    if bin(i).count('1') != N-1:
        continue
    else:
        G = {k: [] for k in range(N)}
        for j in range(M):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                (a, b) = V[j]
                G[a].append(b)
                G[b].append(a)
        if bfs(G) == N-1:
            ans += 1
print(ans)


Fixed submission:
import itertools

N,M=map(int,input().split())
route=[list(map(int,input().split())) for _ in range(M)]
candidate=list(itertools.permutations(range(1,N+1)))

ans=0
for c in candidate:
  if c[0]==1:
    for i in range(N-1):
      l=sorted([c[i], c[i+1]])
      if l not in route:
         break
    else:
      ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N, M = map(int, input().split())
V = []
for i in range(M):
    a, b = map(int, input().split())
    V.append((a, b))


def bfs(G):
    if len(G[1]) >= 2:
        return 0
    visited = [False]*N
    visited[0] = True
    que = deque([(1, -1)])
    while que:
        ci, p = que.popleft()
        if len(G[ci]) >= 3:
            return 0
        for ni in G[ci]:
            if ni != p:
                if visited[ni-1]:
                    return 0
                visited[ni-1] = True
                que.append((ni, ci))
    if all(visited):
        return 1
    else:
        return 0


ans = 0
for i in range(2 ** M):
    if bin(i).count('1') != N-1:
        continue
    else:
        G = {k: [] for k in range(N+1)}
        for j in range((2**M).bit_length()):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                (a, b) = V[j]
                # 無向グラフ
                G[a].append(b)
                G[b].append(a)
        ans += bfs(G)
print(ans)


Fixed submission:
import itertools

N,M=map(int,input().split())
route=[list(map(int,input().split())) for _ in range(M)]
candidate=list(itertools.permutations(range(1,N+1)))

ans=0
for c in candidate:
  if c[0]==1:
    for i in range(N-1):
      l=sorted([c[i], c[i+1]])
      if l not in route:
         break
    else:
      ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
import itertools
N, M = map(int, input().split())

G = {k: set() for k in range(N+1)}
for _ in range(N):
    a, b = map(int, input().split())
    # 無向グラフ
    G[a].add(b)
    G[b].add(a)

ans = 0
for p in itertools.permutations(range(2, N+1)):
    c = 1
    for n in p:
        if n not in G[c]:
            break
        c = n
    else:
        ans += 1

print(ans)


Fixed submission:
import itertools

N,M=map(int,input().split())
route=[list(map(int,input().split())) for _ in range(M)]
candidate=list(itertools.permutations(range(1,N+1)))

ans=0
for c in candidate:
  if c[0]==1:
    for i in range(N-1):
      l=sorted([c[i], c[i+1]])
      if l not in route:
         break
    else:
      ans+=1
print(ans)