Buggy python submission (verdict: Runtime Error):
def dps(road,dist,node,d):
    for x in road[node]:
        if dist[x]<0:
            dist[x]=d
            dps(road,dist,x,d+1)
    
N=int(input())
road=[[] for _ in range(N)]
f_d=[-1 for _ in range(N)]
s_d=[-1 for _ in range(N)]
f_d[0]=0
s_d[-1]=0

for i in range(N-1):
    a,b=list(map(int,input().split()))
    road[a-1].append(b-1)
    road[b-1].append(a-1)

dps(road,f_d,0,1)
dps(road,s_d,N-1,1)

white=0
black=0

for i in range(N-1):
    if f_d[i]<=s_d[i]:
        white+=1
    else:
        black+=1

if white>black:
    print('Fennec')
else:
    print('Snuke')

Fixed submission:
import sys

sys.setrecursionlimit(10**9)

def dps(road,dist,node,d):
    for x in road[node]:
        if dist[x]<0:
            dist[x]=d
            dps(road,dist,x,d+1)
    
N=int(input())
road=[[] for _ in range(N)]
f_d=[-1 for _ in range(N)]
s_d=[-1 for _ in range(N)]
f_d[0]=0
s_d[-1]=0

for i in range(N-1):
    a,b=list(map(int,input().split()))
    road[a-1].append(b-1)
    road[b-1].append(a-1)

dps(road,f_d,0,1)
dps(road,s_d,N-1,1)

white=0
black=0

for i in range(N):
    if f_d[i]<=s_d[i]:
        black+=1
    else:
        white+=1

if black>white:
    print('Fennec')
else:
    print('Snuke')

Buggy python submission (verdict: Runtime Error):
def sp(road,used,node,goal,path):
    if node == goal:
        return True
    for x in road[node]:
        if used[x]!=1:
            used[x]=1
            if sp(road,used,x,goal,path):
                used[x]=2
                path.append(x)
                return True

def dps(road,used,node):
    for x in road[node]:
        if used[x]!=2:
            used[x]=2
            return dps(road,used,x)+1
    return 0
    
N=int(input())
road=[[] for _ in range(N)]
used=[0 for _ in range(N)]

for i in range(N-1):
    a,b=list(map(int,input().split()))
    road[a-1].append(b-1)
    road[b-1].append(a-1)

path=[]
sp(road,used,0,N-1,path)

mid=len(path)//2+len(path)%2

f=[0]+path[:mid]
s=[N-1]+path[mid:]

black=mid
for x in f:
    black+=dps(road,used,x)
white=len(path)-mid
for x in s:
    white+=dps(road,used,x)

if black>white:
    print('Fennec')
else:
    print('Snuke')

Fixed submission:
import sys

sys.setrecursionlimit(10**9)

def dps(road,dist,node,d):
    for x in road[node]:
        if dist[x]<0:
            dist[x]=d
            dps(road,dist,x,d+1)
    
N=int(input())
road=[[] for _ in range(N)]
f_d=[-1 for _ in range(N)]
s_d=[-1 for _ in range(N)]
f_d[0]=0
s_d[-1]=0

for i in range(N-1):
    a,b=list(map(int,input().split()))
    road[a-1].append(b-1)
    road[b-1].append(a-1)

dps(road,f_d,0,1)
dps(road,s_d,N-1,1)

white=0
black=0

for i in range(N):
    if f_d[i]<=s_d[i]:
        black+=1
    else:
        white+=1

if black>white:
    print('Fennec')
else:
    print('Snuke')

Buggy python submission (verdict: Runtime Error):
road=[[] for _ in range(N)]
used=[0 for _ in range(N)]

for i in range(N-1):
    a,b=list(map(int,input().split()))
    road[a-1].append(b-1)
    road[b-1].append(a-1)

start=0
for i in range(N):
    if len(road[i])==1:
        start=i
        break
used[start]=1

f=0
s=0
for i in range(N):
    if start == 0:
        f=i
    elif start ==N-1:
        s=i
    for x in road[start]:
        if used[x]!=1:
            start=x

mid=(N-1)/2
if abs(mid-f)<abs(mid-s):
    print('Fennec')
elif abs(mid-f)>abs(mid-s):
    print('Snuke')
else:
    if N%2==0:
        print('Snuke')
    else:
        print('Fennec')

Fixed submission:
import sys

sys.setrecursionlimit(10**9)

def dps(road,dist,node,d):
    for x in road[node]:
        if dist[x]<0:
            dist[x]=d
            dps(road,dist,x,d+1)
    
N=int(input())
road=[[] for _ in range(N)]
f_d=[-1 for _ in range(N)]
s_d=[-1 for _ in range(N)]
f_d[0]=0
s_d[-1]=0

for i in range(N-1):
    a,b=list(map(int,input().split()))
    road[a-1].append(b-1)
    road[b-1].append(a-1)

dps(road,f_d,0,1)
dps(road,s_d,N-1,1)

white=0
black=0

for i in range(N):
    if f_d[i]<=s_d[i]:
        black+=1
    else:
        white+=1

if black>white:
    print('Fennec')
else:
    print('Snuke')