Buggy python submission (verdict: Runtime Error):
import itertools

N, M = map(int, input().split())
G = [[]  for _ in range(N)]
for i in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    G[a].append(b)
    G[b].append(a)
pattern = [i for i in range(N)]

ans = 0
for i in itertools.permutations(pattern):
    flag = True
    now = i[j]
    to = i[j+1]
    if i[0] != 0:
        continue
    for j in range(len(i) - 1):
        if not to in G[now]:
            flag = False
    if flag:
        ans += 1
print(ans)

Fixed submission:
N, M = map(int, input().split())
G = [[] for _ in range(N)]
seen = [False] * N
for i in range(M):
    a, b = map(lambda x: int(x) - 1 ,input().split())
    G[a].append(b)
    G[b].append(a)

def dfs(x, G, seen):
    seen[x] = True
    flag = True
    for i in seen:
        if i == False:
            flag = False
    if flag:
        return 1
    res = 0
    for i in G[x]:
        if seen[i]:
            continue
        res += dfs(i, G, seen)
        seen[i] = False
    return res

print(dfs(0, G, seen))

Buggy python submission (verdict: Runtime Error):
import itertools

N, M = map(int, input().split())
G = [[]  for _ in range(N)]
for i in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    G[a].append(b)
    G[b].append(a)
pattern = [i for i in range(N)]

ans = 0
for i in itertools.permutations(pattern):
    flag = True
    now = i[j]
    next = i[j+1]
    if i[0] != 0:
        continue
    for j in range(len(i) - 1):
        if not next in G[now]:
            flag = False
    if flag:
        ans += 1
print(ans)

Fixed submission:
N, M = map(int, input().split())
G = [[] for _ in range(N)]
seen = [False] * N
for i in range(M):
    a, b = map(lambda x: int(x) - 1 ,input().split())
    G[a].append(b)
    G[b].append(a)

def dfs(x, G, seen):
    seen[x] = True
    flag = True
    for i in seen:
        if i == False:
            flag = False
    if flag:
        return 1
    res = 0
    for i in G[x]:
        if seen[i]:
            continue
        res += dfs(i, G, seen)
        seen[i] = False
    return res

print(dfs(0, G, seen))

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 6)

N, M = map(int, input().split())

graph = [[] for i in range(M)]
for i in range(M):
    v, e = map(int, input().split())
    graph[v - 1].append(e - 1)
    graph[e - 1].append(v - 1)

def dfs(v, seen, res):
    end = True
    for i in range(len(seen)):
        if seen[i] == False and i != v:
            end = False
    if end:
        res[0] += 1
        return
    seen[v] = True
    for i in graph[v]:
        if seen[i]:
            continue
        dfs(i, seen, res)
    seen[v] = False

res = [0]
seen = [False] * N
dfs(0, seen, res)
print(res[0])

Fixed submission:
N, M = map(int, input().split())
G = [[] for _ in range(N)]
seen = [False] * N
for i in range(M):
    a, b = map(lambda x: int(x) - 1 ,input().split())
    G[a].append(b)
    G[b].append(a)

def dfs(x, G, seen):
    seen[x] = True
    flag = True
    for i in seen:
        if i == False:
            flag = False
    if flag:
        return 1
    res = 0
    for i in G[x]:
        if seen[i]:
            continue
        res += dfs(i, G, seen)
        seen[i] = False
    return res

print(dfs(0, G, seen))

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

graph = [[] for i in range(M)]
for i in range(M):
    v, e = map(int, input().split())
    graph[v - 1].append(e - 1)
    graph[e - 1].append(v - 1)

def dfs(v, seen, res):
    end = True
    for i in range(len(seen)):
        if seen[i] == False and i != v:
            end = False
    if end:
        res[0] += 1
        return
    seen[v] = True
    for i in graph[v]:
        if seen[i]:
            continue
        dfs(i, seen, res)
    seen[v] = False

res = [0]
seen = [False] * N
dfs(0, seen, res)
print(res[0])

Fixed submission:
N, M = map(int, input().split())
G = [[] for _ in range(N)]
seen = [False] * N
for i in range(M):
    a, b = map(lambda x: int(x) - 1 ,input().split())
    G[a].append(b)
    G[b].append(a)

def dfs(x, G, seen):
    seen[x] = True
    flag = True
    for i in seen:
        if i == False:
            flag = False
    if flag:
        return 1
    res = 0
    for i in G[x]:
        if seen[i]:
            continue
        res += dfs(i, G, seen)
        seen[i] = False
    return res

print(dfs(0, G, seen))