Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n = int(input())
li = []
for _ in range(n - 1):
    li.append(list(map(int, input().split())))

# construct graph
edges = [set() for _ in range(n)]
for i, j in li:
    i -= 1
    j -= 1
    edges[i].update({j})
    edges[j].update({i})

# search middle edge and cut
Q = deque()
Q.append([0])
while len(Q) > 0:
    path = Q.pop()
    if path[-1] == n - 1:
        i = (len(path) - 1) // 2
        a, b = path[i], path[i + 1]
        edges[a].remove(b)
        edges[b].remove(a)
        break
    for v in edges[path[-1]]:
        if v not in path:
            Q.append(path + [v])

# count Fennec's area
Q = deque()
Q.append(0)
visited = {0}
while len(Q) > 0:
    u = Q.pop()
    for v in edges[u]:
        if v not in visited:
            visited.update({v})
            Q.append(v)

ans = 'Snuke' if len(visited) <= n // 2 else 'Fennec'

print(ans)

Fixed submission:
from collections import deque
n = int(input())
li = []
for _ in range(n - 1):
    li.append(list(map(int, input().split())))

# construct graph
edges = [set() for _ in range(n)]
for i, j in li:
    i -= 1
    j -= 1
    edges[i].update({j})
    edges[j].update({i})

# search middle edge and cut
Q = deque()
Q.append([0, 0])
visited = {0}
pre = {}
while len(Q) > 0:
    u, d = Q.pop()
    if u == n - 1:
        i = (d - 1) // 2
        a = u
        for _ in range(i + 1):
            b = a
            a = pre[b]
        edges[a].remove(b)
        edges[b].remove(a)
        break
    for v in edges[u]:
        if v not in visited:
            pre[v] = u
            visited.update({v})
            Q.append([v, d + 1])

# count Fennec's area
Q = deque()
Q.append(0)
visited = {0}
while len(Q) > 0:
    u = Q.pop()
    for v in edges[u]:
        if v not in visited:
            visited.update({v})
            Q.append(v)

ans = 'Snuke' if len(visited) <= n // 2 else 'Fennec'

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n = int(input())
li = []
for _ in range(n - 1):
    li.append(list(map(int, input().split())))

# construct graph
edges = [[] for _ in range(n)]
for i, j in li:
    i -= 1
    j -= 1
    edges[i].append(j)
    edges[j].append(i)

# search middle edge and cut
Q = deque()
Q.append([0])
while len(Q) > 0:
    path = Q.pop()
    if path[-1] == n - 1:
        i = (len(path) - 1) // 2
        a, b = path[i], path[i + 1]
        edges[a].remove(b)
        edges[b].remove(a)
        break
    for v in edges[path[-1]]:
        if v not in path:
            Q.append(path + [v])

# count Fennec's area
Q = deque()
Q.append(0)
visited = {0}
while len(Q) > 0:
    u = Q.pop()
    for v in edges[u]:
        if v not in visited:
            visited.update({v})
            Q.append(v)

ans = 'Snuke' if len(visited) <= n // 2 else 'Fennec'

print(ans)

Fixed submission:
from collections import deque
n = int(input())
li = []
for _ in range(n - 1):
    li.append(list(map(int, input().split())))

# construct graph
edges = [set() for _ in range(n)]
for i, j in li:
    i -= 1
    j -= 1
    edges[i].update({j})
    edges[j].update({i})

# search middle edge and cut
Q = deque()
Q.append([0, 0])
visited = {0}
pre = {}
while len(Q) > 0:
    u, d = Q.pop()
    if u == n - 1:
        i = (d - 1) // 2
        a = u
        for _ in range(i + 1):
            b = a
            a = pre[b]
        edges[a].remove(b)
        edges[b].remove(a)
        break
    for v in edges[u]:
        if v not in visited:
            pre[v] = u
            visited.update({v})
            Q.append([v, d + 1])

# count Fennec's area
Q = deque()
Q.append(0)
visited = {0}
while len(Q) > 0:
    u = Q.pop()
    for v in edges[u]:
        if v not in visited:
            visited.update({v})
            Q.append(v)

ans = 'Snuke' if len(visited) <= n // 2 else 'Fennec'

print(ans)