Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N = int(input())
    if N == 1:
        print("First")
        exit()
    edge = [[] for _ in range(N)]
    
    for _ in range(N-1):
        a,b = map(int,input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
        
    d = 0
    for st in range(N):
        dep = [-1 for _ in range(N)]
        dep[st] = 0
        q = deque([st])
        while q:
            now = q.popleft()
            for fol in edge[now]:
                if dep[fol] == -1:
                    dep[fol] = dep[now]+1
                    q.append(fol)
        d = max(d,max(dep))
        
    if d%3 == 1:
        print("Second")
    else:
        print("First")

if __name__ == "__main__":
    main()


Fixed submission:
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N = int(input())
    if N == 1:
        print("First")
        exit()
    edge = [[] for _ in range(N)]
    
    for _ in range(N-1):
        a,b = map(int,input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
        
    dep = [-1 for _ in range(N)]
    dep[0] = 0
    q = deque([0])
    while q:
        now = q.popleft()
        for fol in edge[now]:
            if dep[fol] == -1:
                dep[fol] = dep[now]+1
                q.append(fol)
    
    st = dep.index(max(dep))
    dep = [-1 for _ in range(N)]
    dep[st] = 0
    q = deque([st])
    while q:
        now = q.popleft()
        for fol in edge[now]:
            if dep[fol] == -1:
                dep[fol] = dep[now]+1
                q.append(fol)
                
    if max(dep)%3 == 1:
        print("Second")
    else:
        print("First")

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N = int(input())
    edge = [[] for _ in range(N)]
    
    for _ in range(N-1):
        a,b = map(int,input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
        
    for i in range(N):
        if len(edge[i]) == 1:
            st = i
            break
    dep = [-1 for _ in range(N)]
    dep[st] = 0
    
    q = deque([st])
    while q:
        now = q.pop()
        for fol in edge[now]:
            if dep[fol] == -1:
                dep[fol] = dep[now]+1
                q.append(fol)
    
    if max(dep)%3 == 1:
        print("second")
    else:
        print("first")

if __name__ == "__main__":
    main()


Fixed submission:
import sys
input = sys.stdin.buffer.readline
from collections import deque

def main():
    N = int(input())
    if N == 1:
        print("First")
        exit()
    edge = [[] for _ in range(N)]
    
    for _ in range(N-1):
        a,b = map(int,input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
        
    dep = [-1 for _ in range(N)]
    dep[0] = 0
    q = deque([0])
    while q:
        now = q.popleft()
        for fol in edge[now]:
            if dep[fol] == -1:
                dep[fol] = dep[now]+1
                q.append(fol)
    
    st = dep.index(max(dep))
    dep = [-1 for _ in range(N)]
    dep[st] = 0
    q = deque([st])
    while q:
        now = q.popleft()
        for fol in edge[now]:
            if dep[fol] == -1:
                dep[fol] = dep[now]+1
                q.append(fol)
                
    if max(dep)%3 == 1:
        print("Second")
    else:
        print("First")

if __name__ == "__main__":
    main()