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

sys.setrecursionlimit(10 ** 7)

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

visited = [0 for _ in range(N)]
graph = [[0] * M for _ in range(M)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a - 1][b - 1] = 1
    graph[b - 1][a - 1] = 1


def dfs(i, depth):
    if visited[i]:
        return 0
    if depth == N - 1:
        return 1

    visited[i] = 1
    ret = 0
    for j in range(0, N):
        if graph[i][j]:
            ret += dfs(j, depth + 1)

    visited[i] = 0

    return ret


print(dfs(0, 0))

Fixed submission:
N, M = map(int, input().split())
graph = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)


def dfs(now, prev, visited):
    visited.append(now)
    if len(visited) == N:
        return 1

    ret = 0
    for edge in graph[now]:
        if edge == prev:
            continue
        if edge in visited:
            continue

        ret += dfs(edge, prev, visited[:])

    return ret


print(dfs(0, -1, []))

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

sys.setrecursionlimit(1000000)

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

visited = [0 for _ in range(N)]
graph = [[0] * M for _ in range(M)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a - 1][b - 1] = 1
    graph[b - 1][a - 1] = 1


def dfs(i, depth):
    if visited[i]:
        return 0
    if depth == N - 1:
        return 1

    visited[i] = 1
    ret = 0
    for j in range(0, N):
        if graph[i][j]:
            ret += dfs(j, depth + 1)

    visited[i] = 0

    return ret


print(dfs(0, 0))


Fixed submission:
N, M = map(int, input().split())
graph = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)


def dfs(now, prev, visited):
    visited.append(now)
    if len(visited) == N:
        return 1

    ret = 0
    for edge in graph[now]:
        if edge == prev:
            continue
        if edge in visited:
            continue

        ret += dfs(edge, prev, visited[:])

    return ret


print(dfs(0, -1, []))

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

sys.setrecursionlimit(100000)

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

visited = [0 for _ in range(N)]
graph = [[0] * M for _ in range(M)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a - 1][b - 1] = 1
    graph[b - 1][a - 1] = 1


def dfs(i, depth):
    if visited[i]:
        return 0
    if depth == N - 1:
        return 1

    visited[i] = 1
    ret = 0
    for j in range(0, N):
        if graph[i][j]:
            ret += dfs(j, depth + 1)

    visited[i] = 0

    return ret


print(dfs(0, 0))

Fixed submission:
N, M = map(int, input().split())
graph = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)


def dfs(now, prev, visited):
    visited.append(now)
    if len(visited) == N:
        return 1

    ret = 0
    for edge in graph[now]:
        if edge == prev:
            continue
        if edge in visited:
            continue

        ret += dfs(edge, prev, visited[:])

    return ret


print(dfs(0, -1, []))

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

visited = [0 for _ in range(N)]
graph = [[0] * M for _ in range(M)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a - 1][b - 1] = 1
    graph[b - 1][a - 1] = 1


def dfs(i, depth):
    if visited[i]:
        return 0
    if depth == N - 1:
        return 1

    visited[i] = 1
    ret = 0
    for j in range(0, N):
        if graph[i][j]:
            ret += dfs(j, depth + 1)

    visited[i] = 0

    return ret


print(dfs(0, 0))


Fixed submission:
N, M = map(int, input().split())
graph = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)


def dfs(now, prev, visited):
    visited.append(now)
    if len(visited) == N:
        return 1

    ret = 0
    for edge in graph[now]:
        if edge == prev:
            continue
        if edge in visited:
            continue

        ret += dfs(edge, prev, visited[:])

    return ret


print(dfs(0, -1, []))