Buggy python submission (verdict: Runtime Error):
def i1():
  return int(input())
def i2():
  return [int(i) for i in input().split()]
[n,m]=i2()
e=[[] for i in range(n+100)]
for i in range(m):
  [a,b]=i2()
  e[a].append(b)
  e[b].append(a)

import sys
sys.setrecursionlimit(10000)
d=[0 for i in range(n+100)]
dd=[]
def dfs1(v):
    d[v]=1
    for i in e[v]:
      if d[i]==0:
          dd.append(i)
          dfs1(i)
          break
ddd=[]
def dfs2(v):
    d[v]=1
    for i in e[v]:
      if d[i]==0:
          ddd.append(i)
          dfs2(i)
          break
dfs1(1)
dfs2(1)
l=ddd[::-1]+[1]+dd
print(len(l))
print(*l)


Fixed submission:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,m]=i2()
e=[[] for i in range(n+100)]
for i in range(m):
 [a,b]=i2()
 e[a].append(b)
 e[b].append(a)

import sys
sys.setrecursionlimit(10**6)
d=[0 for i in range(n+100)]
dd=[]
def dfs1(v):
   d[v]=1
   for i in e[v]:
      if d[i]==0:
         dd.append(i)
         dfs1(i)
         break
ddd=[]
def dfs2(v):
   d[v]=1
   for i in e[v]:
      if d[i]==0:
         ddd.append(i)
         dfs2(i)
         break
dfs1(1)
dfs2(1)
l=ddd[::-1]+[1]+dd
print(len(l))
print(*l)

Buggy python submission (verdict: Runtime Error):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,m]=i2()
e=[[] for i in range(n+100)]
for i in range(m):
 [a,b]=i2()
 e[a].append(b)
 e[b].append(a)

import sys
sys.setrecursionlimit(10000)
d=[0 for i in range(n+100)]
dd=[]
def dfs1(v):
   d[v]=1
   for i in range(len(e[v])):
      if d[e[v][i]]==0:
         dd.append(e[v][i])
         dfs1(e[v][i])
         break
ddd=[]
def dfs2(v):
   d[v]=1
   for i in range(len(e[v])):
      if d[e[v][i]]==0:
         ddd.append(e[v][i])
         dfs2(e[v][i])
         break
dfs1(1)
dfs2(1)
l=ddd[::-1]+[1]+dd
print(len(l))
print(*l)


Fixed submission:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,m]=i2()
e=[[] for i in range(n+100)]
for i in range(m):
 [a,b]=i2()
 e[a].append(b)
 e[b].append(a)

import sys
sys.setrecursionlimit(10**6)
d=[0 for i in range(n+100)]
dd=[]
def dfs1(v):
   d[v]=1
   for i in e[v]:
      if d[i]==0:
         dd.append(i)
         dfs1(i)
         break
ddd=[]
def dfs2(v):
   d[v]=1
   for i in e[v]:
      if d[i]==0:
         ddd.append(i)
         dfs2(i)
         break
dfs1(1)
dfs2(1)
l=ddd[::-1]+[1]+dd
print(len(l))
print(*l)

Buggy python submission (verdict: Runtime Error):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,m]=i2()
e=[[] for i in range(n+1)]
for i in range(m):
 [a,b]=i2()
 e[a].append(b)
 e[b].append(a)

import sys
sys.setrecursionlimit(10000)
d=[0 for i in range(n+1)]
dd=[]
def dfs1(v):
   d[v]=1
   for i in range(len(e[v])):
      if d[e[v][i]]==0:
         dd.append(e[v][i])
         dfs1(e[v][i])
         break
ddd=[]
def dfs2(v):
   d[v]=1
   for i in range(len(e[v])):
      if d[e[v][i]]==0:
         ddd.append(e[v][i])
         dfs2(e[v][i])
         break
dfs1(1)
dfs2(1)
l=ddd[::-1]+[1]+dd
s=""
for i in l:
 s+=str(i)+" "
print(len(s.split(" "))-1)
print(s)


Fixed submission:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,m]=i2()
e=[[] for i in range(n+100)]
for i in range(m):
 [a,b]=i2()
 e[a].append(b)
 e[b].append(a)

import sys
sys.setrecursionlimit(10**6)
d=[0 for i in range(n+100)]
dd=[]
def dfs1(v):
   d[v]=1
   for i in e[v]:
      if d[i]==0:
         dd.append(i)
         dfs1(i)
         break
ddd=[]
def dfs2(v):
   d[v]=1
   for i in e[v]:
      if d[i]==0:
         ddd.append(i)
         dfs2(i)
         break
dfs1(1)
dfs2(1)
l=ddd[::-1]+[1]+dd
print(len(l))
print(*l)

Buggy python submission (verdict: Runtime Error):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,m]=i2()
e=[[] for i in range(n+1)]
for i in range(m):
 [a,b]=i2()
 e[a].append(b)
 e[b].append(a)

import sys
sys.setrecursionlimit(10000)
d=[0 for i in range(n+1)]
dd=[]
def dfs1(v):
   d[v]=1
   for i in range(len(e[v])):
      if d[e[v][i]]==0:
         dd.append(e[v][i])
         dfs1(e[v][i])
         break
ddd=[]
def dfs2(v):
   d[v]=1
   for i in range(len(e[v])):
      if d[e[v][i]]==0:
         ddd.append(e[v][i])
         dfs2(e[v][i])
         break
dfs1(1)
dfs2(1)
print(len(dd)+len(ddd)+1)
s=""
for i in ddd[::-1]+[1]+dd:
 s+=str(i)+" "
print(s)


Fixed submission:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,m]=i2()
e=[[] for i in range(n+100)]
for i in range(m):
 [a,b]=i2()
 e[a].append(b)
 e[b].append(a)

import sys
sys.setrecursionlimit(10**6)
d=[0 for i in range(n+100)]
dd=[]
def dfs1(v):
   d[v]=1
   for i in e[v]:
      if d[i]==0:
         dd.append(i)
         dfs1(i)
         break
ddd=[]
def dfs2(v):
   d[v]=1
   for i in e[v]:
      if d[i]==0:
         ddd.append(i)
         dfs2(i)
         break
dfs1(1)
dfs2(1)
l=ddd[::-1]+[1]+dd
print(len(l))
print(*l)

Buggy python submission (verdict: Runtime Error):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,m]=i2()
e=[[] for i in range(n+1)]
for i in range(m):
 [a,b]=i2()
 e[a].append(b)
 e[b].append(a)

import sys
sys.setrecursionlimit(10000)
d=[0 for i in range(n+1)]
dd=[]
def dfs1(v):
   d[v]=1
   for i in range(len(e[v])):
      if d[e[v][i]]==0:
         dd.append(e[v][i])
         dfs1(e[v][i])
         break
ddd=[]
def dfs2(v):
   d[v]=1
   for i in range(len(e[v])):
      if d[e[v][i]]==0:
         ddd.append(e[v][i])
         dfs2(e[v][i])
         break
dfs1(1)
dfs2(1)
print(len(dd)+len(ddd)+1)
s=""
for i in ddd[::-1]+[1]+dd:
 s+=str(i)+" "
print(s)


Fixed submission:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,m]=i2()
e=[[] for i in range(n+100)]
for i in range(m):
 [a,b]=i2()
 e[a].append(b)
 e[b].append(a)

import sys
sys.setrecursionlimit(10**6)
d=[0 for i in range(n+100)]
dd=[]
def dfs1(v):
   d[v]=1
   for i in e[v]:
      if d[i]==0:
         dd.append(i)
         dfs1(i)
         break
ddd=[]
def dfs2(v):
   d[v]=1
   for i in e[v]:
      if d[i]==0:
         ddd.append(i)
         dfs2(i)
         break
dfs1(1)
dfs2(1)
l=ddd[::-1]+[1]+dd
print(len(l))
print(*l)