Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
graph = [[] for i in range(n)]
for a, b in LIRM(n - 1):
    graph[a] += [b]
    graph[b] += [a]



def dfs(graph, start, goal):
    que = deque([start])
    pre = [-1] * n
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
            if nxt == pre[cur]:
                continue
            pre[nxt] = cur
            if nxt == goal:
                break
            que.append(nxt)
    return pre



pre = dfs(graph, 0, n - 1)
route = [n - 1]
while route[0] != 0:
    route = [pre[route[0]]] + route

limit_num = (len(route) - 1) // 2
black_node = route[limit_num]
white_node = route[limit_num + 1]
graph[black_node].remove(white_node)


def dfs_cnt(graph, start):
    cnt = 1
    que = deque([start])
    pre = [-1] * n
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
            if nxt == pre[cur]:
                continue
            pre[nxt] = cur
            cnt += 1
            que.append(nxt)
    return cnt


black_cnt = dfs_cnt(graph, 0)
white_cnt = n - black_cnt

if black_cnt > white_cnt:
    print('Fennec')
else:
    print('Snuke')

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = LI()
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]




f_que = deque([0])
s_que = deque([n - 1])
visited = [0] * n
visited[0] = 1
visited[n - 1] = 1
f_cnt = s_cnt = 0
while f_que or s_que:
    f_tmp = deque()
    for cur in f_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            f_tmp += [nxt]
            visited[nxt] = 1
            f_cnt += 1
    f_que = f_tmp
    s_tmp = deque()
    for cur in s_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            s_tmp += [nxt]
            visited[nxt] = 1
            s_cnt += 1
    s_que = s_tmp


if s_cnt >= f_cnt:
    print('Snuke')
else:
    print('Fennec')

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


n = int(input())
graph = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]



def dfs(graph, start, goal):
    que = deque([start])
    pre = [-1] * n
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
            if nxt == pre[cur]:
                continue
            pre[nxt] = cur
            if nxt == goal:
                break
            que.append(nxt)
    return pre




pre = dfs(graph, 0, n-1)
route = [n-1]
while route[0]!=0:
    route = [pre[route[0]]] + route

limit_num = (len(route) - 1) // 2
black_node = route[limit_num]
white_node = route[limit_num + 1]
graph[black_node].remove(white_node)


def dfs_cnt(graph, start):
    cnt = 1
    que = deque([start])
    pre = [-1] * n
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
            if nxt == pre[cur]:
                continue
            pre[nxt] = cur
            cnt += 1
            que.append(nxt)
    return cnt


black_cnt = dfs_cnt(graph, 0)
white_cnt = n - black_cnt


if black_cnt > white_cnt:
    print('Fennec')
else:
    print('Snuke')

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = LI()
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]




f_que = deque([0])
s_que = deque([n - 1])
visited = [0] * n
visited[0] = 1
visited[n - 1] = 1
f_cnt = s_cnt = 0
while f_que or s_que:
    f_tmp = deque()
    for cur in f_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            f_tmp += [nxt]
            visited[nxt] = 1
            f_cnt += 1
    f_que = f_tmp
    s_tmp = deque()
    for cur in s_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            s_tmp += [nxt]
            visited[nxt] = 1
            s_cnt += 1
    s_que = s_tmp


if s_cnt >= f_cnt:
    print('Snuke')
else:
    print('Fennec')

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


n = int(input())
graph = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]



def dfs(graph, start, goal):
    que = deque([start])
    pre = [-1] * n
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
            if nxt == pre[cur]:
                continue
            pre[nxt] = cur
            if nxt == goal:
                break
            que.append(nxt)
    return pre




pre = dfs(graph, 0, n-1)
route = [n-1]
while route[0]!=0:
    route = [pre[route[0]]] + route

limit_num = (len(route) - 1) // 2
black_node = route[limit_num]
white_node = route[limit_num + 1]
graph[black_node].remove(white_node)


def dfs_cnt(graph, start):
    que = deque([start])
    pre = [-1] * n
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
            if nxt == pre[cur]:
                continue
            pre[nxt] = cur
            que.append(nxt)
    cnt = len([i for i in pre if i!=-1])+1
    return cnt


black_cnt = dfs_cnt(graph, 0)
white_cnt = n - black_cnt


if black_cnt > white_cnt:
    print('Fennec')
else:
    print('Snuke')

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = LI()
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]




f_que = deque([0])
s_que = deque([n - 1])
visited = [0] * n
visited[0] = 1
visited[n - 1] = 1
f_cnt = s_cnt = 0
while f_que or s_que:
    f_tmp = deque()
    for cur in f_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            f_tmp += [nxt]
            visited[nxt] = 1
            f_cnt += 1
    f_que = f_tmp
    s_tmp = deque()
    for cur in s_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            s_tmp += [nxt]
            visited[nxt] = 1
            s_cnt += 1
    s_que = s_tmp


if s_cnt >= f_cnt:
    print('Snuke')
else:
    print('Fennec')

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque


n = int(input())
graph = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]



def dfs(graph, start, goal):
    que = deque([start])
    pre = [-1] * n
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
            if nxt == pre[cur]:
                continue
            pre[nxt] = cur
            if nxt == goal:
                break
            que.append(nxt)
    return pre




pre = dfs(graph, 0, n-1)
route = [n-1]
while route[0]!=0:
    route = [pre[route[0]]] + route

limit_num = (len(route) - 1) // 2
black_node = route[limit_num]
white_node = route[limit_num + 1]
graph[black_node].remove(white_node)



def dfs_cnt(graph, start):
    que = deque([start])
    visited = [0] * n
    visited[start] = 1
    while que:
        cur = que.popleft()
        for nxt in graph[cur]:
            if visited[nxt] != 1:
                que.append(nxt)
                visited[nxt] = 1
    return sum(visited)


black_cnt = dfs_cnt(graph, 0)
white_cnt = n - black_cnt


if black_cnt > white_cnt:
    print('Fennec')
else:
    print('Snuke')

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
graph = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = LI()
    graph[a - 1] += [b - 1]
    graph[b - 1] += [a - 1]




f_que = deque([0])
s_que = deque([n - 1])
visited = [0] * n
visited[0] = 1
visited[n - 1] = 1
f_cnt = s_cnt = 0
while f_que or s_que:
    f_tmp = deque()
    for cur in f_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            f_tmp += [nxt]
            visited[nxt] = 1
            f_cnt += 1
    f_que = f_tmp
    s_tmp = deque()
    for cur in s_que:
        for nxt in graph[cur]:
            if visited[nxt]:
                continue
            s_tmp += [nxt]
            visited[nxt] = 1
            s_cnt += 1
    s_que = s_tmp


if s_cnt >= f_cnt:
    print('Snuke')
else:
    print('Fennec')