Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)
visited=[False]*N

path=[]

def dfs(curr):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            return dfs(dst)

dfs(0)
path=path[1:][::-1]
dfs(0)

print(len(path))
print(" ".join([str(v+1) for v in path]))


Fixed submission:
import sys
sys.setrecursionlimit(100000)

N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)

visited=[False]*N
path=[]

def dfs(curr):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            dfs(dst)
            return

dfs(0)
path=path[1:][::-1]
dfs(0)

print(len(path))
print(" ".join([str(v+1) for v in path]))

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)
visited=[False]*N

def dfs(curr, path):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            return dfs(dst, path)
    return path

path1 = dfs(0,[])
path2 = dfs(0,[])
path = path2[::-1] + path1[1:]

print(len(path))
print(" ".join([str(v+1) for v in path]))


Fixed submission:
import sys
sys.setrecursionlimit(100000)

N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)

visited=[False]*N
path=[]

def dfs(curr):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            dfs(dst)
            return

dfs(0)
path=path[1:][::-1]
dfs(0)

print(len(path))
print(" ".join([str(v+1) for v in path]))

Buggy python submission (verdict: Runtime Error):
def dfs(curr, path, N, edges, visited):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            return dfs(dst, path, N, edges, visited)
    return path

N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)
visited=[False]*N
path1 = dfs(0,[],N,edges,visited)
path2 = dfs(0,[],N,edges,visited)
path = path2[::-1] + path1[1:]

print(len(path))
print(" ".join([str(v+1) for v in path]))


Fixed submission:
import sys
sys.setrecursionlimit(100000)

N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)

visited=[False]*N
path=[]

def dfs(curr):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            dfs(dst)
            return

dfs(0)
path=path[1:][::-1]
dfs(0)

print(len(path))
print(" ".join([str(v+1) for v in path]))

Buggy python submission (verdict: Runtime Error):
def dfs(curr, path, N, edges, visited):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            return dfs(dst, path, N, edges, visited)
    return path

N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)
visited=[False]*N
path1 = dfs(0,[],N,edges,visited)
path2 = dfs(0,[],N,edges,visited)
path = path2[::-1] + path1[1:]
print(" ".join([str(v+1) for v in path]))


Fixed submission:
import sys
sys.setrecursionlimit(100000)

N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)

visited=[False]*N
path=[]

def dfs(curr):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            dfs(dst)
            return

dfs(0)
path=path[1:][::-1]
dfs(0)

print(len(path))
print(" ".join([str(v+1) for v in path]))