CodeEff/ECCO huggingface dataset:
# Original solution
class Hash:
    def __init__(self):
        self.size = 1046527
        self.l = [0] * self.size

    def insert_key(self, st):
        i = 0
        while True:
            j = self.h(st, i)
            if self.l[j] == 0:
                self.l[j] = st
                #print("inserted")
                return
            else:
                i = i+1

    def find_key(self, st):
        i = 0
        while True:
            j = self.h(st, i)
            if self.l[j] == st:
                return "yes"
            elif self.l[j] == 0 or (i >= self.size):
                return "no"
            else:
                i += 1

    def h1(self, key):
        return sum([ord(c) for c in key]) % self.size

    def h2(self, key):
        return 1 + sum([ord(c) for c in key]) % ( self.size - 1 )

    def h (self, key, i):
        return (self.h1(key) + i* self.h2(key)) % self.size

#main
n = int(eval(input()))
hash = Hash()

for _ in range(n):
    ope, st = input().split()
    if ope == "insert":
        hash.insert_key(st)
    elif ope == "find":
        print((hash.find_key(st)))

# Optimized solution
dic ={}


n = int(eval(input()))

for _ in range(n):
    com, word = input().split()
    
    if com =="insert":
        dic[word] = True
    elif com =='find':
        print(("yes" if word in dic else "no"))
# Original solution
def main():
	n = int(eval(input()))
	dictionary = set()

	for _ in range(n):
		order, code = input().split()
		if order == 'insert':
			dictionary.add(code)
		elif order == 'find':
			if code in dictionary:
				print('yes')
			else:
				print('no')
		else:
			raise Exception('InputError')

if __name__ == '__main__':
	main()

# Optimized solution
def main():
	n = int(eval(input()))
	dictionary = {}

	for _ in range(n):
		order, code = input().split()
		if order == 'insert':
			dictionary[code] = 1
		elif order == 'find':
			if code in dictionary:
				print('yes')
			else:
				print('no')
		else:
			raise Exception('InputError')

if __name__ == '__main__':
	main()
# Original solution
n=eval(input())

d=[]
for x in range(n):
    cmd, st = list(map(str, input().split()))
    
    if cmd == "insert":
        d.append(st)
    elif cmd == "find":
        print('yes' if st in d else 'no')

# Optimized solution
n=eval(input())

d=set()
for x in range(n):
    cmd, st = list(map(str, input().split()))
    
    if cmd == "insert":
        d.add(st)
    elif cmd == "find":
        print('yes' if st in d else 'no')
# Original solution
N=int(eval(input()))
dict=[]
for i in range(N):
    a=input().split()
    if a[0]=="insert":
        dict.append(a[1])
    elif a[0]=="find":
        if a[1] in dict:
            print("yes")
        else:
            print("no")

# Optimized solution
# coding: utf-8
# Here your code !
N=int(eval(input()))
dict={}
for i in range(N):
    a,b=input().split()
    if a=="insert":
        dict[b]=i
    else:
        if b in dict:
            print("yes")
        else:
            print("no")
# Original solution
import sys
from collections import deque
n = int(eval(input()))
command = sys.stdin.readlines()
Q = deque()
for i in range(n):
    a,b = command[i].split()
    if a == "insert":
        Q.append(b)
    else:
        if b in Q:
            print("yes")
        else:
            print("no")

# Optimized solution
import sys
n = int(eval(input()))
command = sys.stdin.readlines()
Q = {}
for i in range(n):
    a,b = command[i].split()
    if a == "insert":
        Q[b] = 0
    else:
        if b in list(Q.keys()):
            print("yes")
        else:
            print("no")
# Original solution
import sys
n = int(eval(input()))
command = sys.stdin.readlines()
Q = {}
for i in range(n):
    a,b = command[i].split()
    if a == "insert":
        Q[b] = 0
    else:
        if b in set(Q.keys()):
            print("yes")
        else:
            print("no")

# Optimized solution
n = int(eval(input()))
dictionary = {}
for i in range(n):
    a = input().split()
    if a[0] == "insert":
        dictionary[a[1]] = 0
    if a[0] == "find":
        if a[1] in dictionary:
            print("yes")
        else:
            print("no")
# Original solution
n = int(eval(input()))
dictionary = {}
for i in range(n):
    a = input().split()
    if a[0] == "insert":
        dictionary[a[1]] = 0
    if a[0] == "find":
        if a[1] in dictionary:
            print("yes")
        else:
            print("no") 

# Optimized solution
import sys
n = int(eval(input()))
dictionary = {}

k = sys.stdin.readlines()


for j in k:
    i = j.split()
    if i[0] == "insert":
        dictionary[i[1]] = 0
    else:
        if i[1] in dictionary:
            print("yes")
        else:
            print("no")
# Original solution
from collections import deque
dictionary = deque()
for making in range(int(eval(input()))) :
    action = input().split()
    if action[0] == 'insert' : dictionary.append(action[1])
    else : 
        if action[1] in dictionary : print('yes')
        else : print('no')

# Optimized solution
from collections import deque
dictionary = set()
for making in range(int(eval(input()))) :
    action = input().split()
    if action[0] == 'insert' : dictionary.add(action[1])
    else : 
        if action[1] in dictionary : print('yes')
        else : print('no')
# Original solution
m = 10000000
NIL = -1

def h1(key):
    return key % m

def h2(key):
    return 1 + (key % (m - 1))

def h(key, i):
    return (h1(key) + i * h2(key)) % m

def insert(t, key):
    i = 0
    while True:
        j = h(key, i)
        if t[j] == NIL:
            t[j] = key
            return j
        else:
            i += 1

def find(t, key):
    i = 0
    while True:
        j = h(key, i)
        if t[j] == key:
            return j
        elif t[j] == NIL or i >= m:
            return NIL
        else:
            i += 1

def convert(word):
    result = ""
    for i in word:
        if i == "A":
            result += "1"
        elif i == "T":
            result += "2"
        elif i == "G":
            result += "3"
        else:
            result += "4"
    return int(result)


t = [NIL]*m
n = int(eval(input()))
for i in range(n):
    com = input().split()
    key = convert(com[1])
    if com[0] == "insert":
        insert(t, key)
    else:
        if find(t, key) != NIL:
            print("yes")
        else:
            print("no")



# Optimized solution
n = int(eval(input()))
d = set()

for i in range(n):
    com = input().split()
    if com[0] == "insert":
        d.add(com[1])
    else:
        print(("yes" if com[1] in d else "no"))
# Original solution
dic=[]
n=int(eval(input()))
cmd=[list(input().split()) for i in range(n)]
for c, l in cmd:
    if c=="insert":
        dic.append(l)
    if c=="find":
        if l in dic:
            print("yes")
        else:
            print("no")

# Optimized solution
dic=set()
n=int(eval(input()))
cmd=[list(input().split()) for i in range(n)]
for c, l in cmd:
    if c=="insert":
        dic.add(l)
    if c=="find":
        if l in dic:
            print("yes")
        else:
            print("no")
# Original solution
import sys
from collections import ChainMap
eval(input())
rp = sys.stdin.readlines()
cm = ChainMap()

for i in rp:
    if i[0] == 'i':
        cm[i[7:]] = 0
    else:
        if i[5:] in cm:
            print('yes')
        else:
            print('no')

# Optimized solution
import sys
#from collections import ChainMap
eval(input())
rp = sys.stdin.readlines()
cm = {}#ChainMap()

for i in rp:
    if i[0] == 'i':
        cm[i[7:]] = 0
    else:
        if i[5:] in cm:
            print('yes')
        else:
            print('no')
# Original solution
import sys
eval(input())
r = sys.stdin.readlines()
d = {}

for i in r:
    if i[0] == 'i':
        d[i[7:]] = 0
    else:
        print(('yes' if i[5:] in d else 'no'))

# Optimized solution
import sys
eval(input())
r = sys.stdin.readlines()
d = {}

for i in r:
    if i[0] == 'i':
        d[i[7:]] = 0
    else:
        if i[5:] in d:
            print('yes')
        else:
            print('no')
        #print('yes' if i[5:] in d else 'no')
# Original solution
import sys
eval(input())
r = sys.stdin.readlines()
d = {}

for i in r:
    if i[0] == 'i':
        d[i[7:]] = 0
    else:
        if i[5:] in d:
            print('yes')
        else:
            print('no')
        #print('yes' if i[5:] in d else 'no')

# Optimized solution
import sys
eval(input())
r = sys.stdin.readlines()
d = {}

for i in r:
    if i[0] == 'i':
        d[i[7:]] = 0
    else:
        if i[5:] in d:
            print('yes')
        else:
            print('no')
# Original solution
n = int(eval(input()))
d = []

for i in range(n):
    order = input().split()
    if order[0] == 'insert':
        d.append(order[1])
    else:
        if order[1] in d:
            print("yes")
        else:
            print("no")

# Optimized solution
n = int(eval(input()))
d = {}

for i in range(n):
    order = input().split()
    if order[0] == 'insert':
        d[order[1]] = i
    else:
        if order[1] in d:
            print("yes")
        else:
            print("no")
# Original solution

n = int(eval(input()))
dic = set()

for i in range(n):
    cmd = input().split()

    if cmd[0] == "insert":
        dic.add(cmd[1])
    else:
        print(("yes" if cmd[1] in dic else "no"))

# Optimized solution
import sys

n = int(eval(input()))
dic = set()

for i in range(n):
    cmd = sys.stdin.readline().split()

    if cmd[0] == "insert":
        dic.add(cmd[1])
    else:
        print(("yes" if cmd[1] in dic else "no"))
# Original solution
#coding:utf-8
#1_4_C
n = int(eval(input()))
dic = []
for i in range(n):
    cmd, word = input().split()
    if cmd == "find":
        if word in dic:
            print("yes")
        else:
            print("no")
    else:
        dic.append(word)

# Optimized solution
#coding:utf-8
#1_4_C
n = int(eval(input()))
dic = set()
for i in range(n):
    cmd, word = input().split()
    if cmd == "find":
        if word in dic:
            print("yes")
        else:
            print("no")
    else:
        dic.add(word)
# Original solution
# -*- coding:utf-8 -*-
import sys


class Hash(object):
    def __init__(self, size):
        self._array = [None] * size
        self._size = size

    def _h1(self, key):
        return key % self._size

    def _h2(self, key):
        return 1 + (key % (self._size - 1))

    def _hash(self, key, i):
        return (self._h1(key) + i * self._h2(key)) % self._size

    def insert(self, key, value):
        i = 0
        while 1:
            j = self._hash(key, i)
            if self._array[j] is None:
                self._array[j] = value
                break
            else:
                i += 1

    def find(self, key, value):
        i = 0
        while 1:
            j = self._hash(key, i)
            if self._array[j] == value:
                return True
            elif self._array[j] is None or i >= self._size:
                return False
            else:
                i += 1


def stoi(s):
    ret = 0
    p = 1
    ctoi = {"A": 1, "C": 2, "G": 3, "T": 4}
    for c in s:
        ret += ctoi[c] * p
        p *= 5
    return ret


def dictionary(lst):
    h = Hash(1046527)
    ret = []
    for val in lst:
        if val[0] == "insert":
            h.insert(stoi(val[1]), val[1])
        elif val[0] == "find":
            if h.find(stoi(val[1]), val[1]):
                ret.append("yes")
            else:
                ret.append("no")
        else:
            raise ValueError
    return ret


if __name__ == "__main__":
    lst = [val.split() for val in sys.stdin.read().splitlines()]
    n = int(lst.pop(0)[0])
    print(("\n".join(dictionary(lst))))

# Optimized solution
# -*- coding:utf-8 -*-
import sys


class Hash(object):
    def __init__(self, size):
        self._array = [None] * size
        self._size = size

    def _hash(self, key):
        return key % self._size

    def insert(self, key, value):
        j = self._hash(key)
        if self._array[j] is None:
            self._array[j] = [value]
        else:
            self._array[j].append(value)

    def find(self, key, value):
        j = self._hash(key)
        if self._array[j] is None:
            return False
        elif value in self._array[j]:
            return True
        else:
            return False


def stoi(s):
    ret = 0
    p = 1
    ctoi = {"A": 1, "C": 2, "G": 3, "T": 4}
    for c in s:
        ret += ctoi[c] * p
        p *= 7
    return ret


def dictionary(lst):
    h = Hash(1046527)
    ret = []
    for val in lst:
        if val[0] == "insert":
            h.insert(stoi(val[1]), val[1])
        elif val[0] == "find":
            if h.find(stoi(val[1]), val[1]):
                ret.append("yes")
            else:
                ret.append("no")
        else:
            raise ValueError
    return ret


if __name__ == "__main__":
    lst = [val.split() for val in sys.stdin.read().splitlines()]
    n = int(lst.pop(0)[0])
    print(("\n".join(dictionary(lst))))
# Original solution
# -*- conding:utf-8 -*-


from collections import deque

q_list = deque()
n = int(eval(input()))
tmp = [input().split() for i in range(n)]

for i in tmp:
    cmd, v = i
    if cmd == "find":
        if v in q_list:
            print("yes")
        else:
            print ("no")
    else:
        q_list.append(v)

# Optimized solution
# -*- conding:utf-8 -*-


se = set()
n = int(eval(input()))
tmp = [input().split() for i in range(n)]


for i in tmp:
    cmd, v = i
    if cmd == "find":
        if v in se:
            print("yes")
        else:
            print ("no")
    else:
        se.add(v)
# Original solution
count=int(input())
l=[]
n=[]
for i in range(count):
	a,b=input().split()
	if a=='insert':
		l.append(b)
	elif a=='find':
		if b in l:
			n.append('yes')
		else:
			n.append('no')

for i in n:
	print(i)

# Optimized solution
count=int(input())
l=set()
for i in range(count):
	a,b=input().split()
	if a=='insert':
		l.add(b)
	elif b in l:
		print('yes')
	else:
		print('no')
# Original solution
import sys
sys.setrecursionlimit(10**6)
# グラフの最長経路が-1か-2かを選べる
N = int(eval(input()))
edge = [[] for _ in range(N)]
INF = 10**18
for _ in range(N-1):
  a,b = list(map(int,input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

opposite = 0
max_dist = 0
def f(d,x):
  global max_dist,opposite
  dx = d[x]
  if dx > max_dist:
    opposite = x
    max_dist = dx
  for y in edge[x]:
    if d[y] == INF:
      d[y] = dx + 1
      f(d,y)

# 0からの距離
d = [INF] * N
d[0] = 0
f(d,0)

v = opposite
d = [INF] * N
d[v] = 0
f(d,v)

X = max_dist

ans = 'First' if max_dist%3 != 1 else 'Second'
print(ans)

# Optimized solution
import sys
sys.setrecursionlimit(10**6)
# グラフの最長経路が-1か-2かを選べる
N = int(eval(input()))
edge = [[] for _ in range(N)]
INF = 10**18
for _ in range(N-1):
  a,b = list(map(int,input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)


opposite = 0
max_dist = 0

def f(d,x):
  global max_dist,opposite
  dx = d[x]
  if dx > max_dist:
    opposite = x
    max_dist = dx
  for y in edge[x]:
    if d[y] == INF:
      d[y] = dx + 1
      f(d,y)


if N != 1:
  # 0からの距離
  d = [INF] * N
  d[0] = 0
  f(d,0)

  v = opposite
  d = [INF] * N
  d[v] = 0
  f(d,v)

  X = max_dist

  ans = 'First' if max_dist%3 != 1 else 'Second'
  print(ans)
else:
  print('First')
# Original solution
import sys
sys.setrecursionlimit(10**6)
# グラフの最長経路が-1か-2かを選べる
N = int(eval(input()))
edge = [[] for _ in range(N)]
INF = 10**18
for _ in range(N-1):
  a,b = list(map(int,input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)


opposite = 0
max_dist = 0

def f(d,x):
  global max_dist,opposite
  dx = d[x]
  if dx > max_dist:
    opposite = x
    max_dist = dx
  for y in edge[x]:
    if d[y] == INF:
      d[y] = dx + 1
      f(d,y)


if N != 1:
  # 0からの距離
  d = [INF] * N
  d[0] = 0
  f(d,0)

  v = opposite
  d = [INF] * N
  d[v] = 0
  f(d,v)

  X = max_dist

  ans = 'First' if max_dist%3 != 1 else 'Second'
  print(ans)
else:
  print('First')


# Optimized solution
import sys
sys.setrecursionlimit(10**6)
# グラフの最長経路が-1か-2かを選べる
N = int(eval(input()))
edge = [[] for _ in range(N)]
for _ in range(N-1):
  a,b = list(map(int,input().split()))
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)


def f(x):
  opposite = 0
  max_dist = 0
  # 最離点と距離とを返す
  d = [None]*N
  q = [(x,0)]
  while q:
    x,dx = q.pop()
    d[x] = dx
    if dx > max_dist:
      max_dist = dx
      opposite = x
    for y in edge[x]:
      if d[y] is None:
        q.append((y,dx+1))
  return opposite,max_dist

if N != 1:
  # 0からの距離
  v,_ = f(0)
  _,max_dist = f(v)

  ans = 'First' if max_dist%3 != 1 else 'Second'
  print(ans)
else:
  print('First')
# Original solution
from collections import deque
def diameter(N, E):#diamete of a tree
    V = [-1]*N
    V[0] = 0
    q = deque([0])
    s = 0
    while q:
        v = q.popleft()
        for w in E[v]:
            if V[w] == -1:
                s = w
                V[w] = V[v] + 1
                q.append(w)
    # s = V.index( max(V))
    p = deque([s])
    W = [-1]*N
    W[s] = 0
    while p:
        v = p.popleft()
        for w in E[v]:
            if W[w] == -1:
                W[w] = W[v] + 1
                p.append(w)
    return max(W)

N = int( eval(input()))
E = [ [] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map( int, input().split()))
    a, b = a-1, b-1
    E[a].append(b)
    E[b].append(a)
ans = "First"
if diameter(N, E)%3 == 1:
    ans = "Second"
print( ans)


# Optimized solution
from collections import deque
def diameter(N, E):#diamete of a tree
    V = [-1]*N
    V[0] = 0
    q = deque([0])
    # s = 0
    while q:
        v = q.popleft()
        for w in E[v]:
            if V[w] == -1:
                # s = w
                V[w] = V[v] + 1
                q.append(w)
    s = V.index( max(V))
    p = deque([s])
    W = [-1]*N
    W[s] = 0
    while p:
        v = p.popleft()
        for w in E[v]:
            if W[w] == -1:
                W[w] = W[v] + 1
                p.append(w)
    return max(W)

N = int( eval(input()))
E = [ [] for _ in range(N)]
for _ in range(N-1):
    a, b = list(map( int, input().split()))
    a, b = a-1, b-1
    E[a].append(b)
    E[b].append(a)
ans = "First"
if diameter(N, E)%3 == 1:
    ans = "Second"
print( ans)
# Original solution
n = int(eval(input()))

tree = {i: [] for i in range(n)}

for _ in range(n-1):
  t = input().split()
  u, v = int(t[0]), int(t[1])
  tree[u-1].append(v-1)
  tree[v-1].append(u-1)

a = 0
idx = 0
q = []
q.append(a)
v = [0 for _ in range(n)]
v[a] = 1

while (idx != len(q)):
    a = q[idx]
    idx += 1
    for b in tree[a]:
        if (v[b] == 0):
            q.append(b)
            v[b] = 1

s = a
idx = 0
q = []
q.append([a, 1])
v = [0 for _ in range(n)]
v[a] = 1

while (idx != len(q)):
    a = q[idx]
    idx += 1
    for b in tree[a[0]]:
        if (v[b] == 0):
            q.append([b, a[1] + 1])
            v[b] = 1

l = a[1]
if l%3 == 2:
    print("Second")
else:
    print("First")

# Optimized solution
n = int(eval(input()))

tree = [[] for i in range(n)]

for _ in range(n-1):
  t = input().split()
  u, v = int(t[0]), int(t[1])
  tree[u-1].append(v-1)
  tree[v-1].append(u-1)

a = 0
idx = 0
q = []
q.append(a)
v = [0 for _ in range(n)]
v[a] = 1

while (idx != len(q)):
    a = q[idx]
    idx += 1
    for b in tree[a]:
        if (v[b] == 0):
            q.append(b)
            v[b] = 1

s = a
idx = 0
q = []
q.append([a, 1])
v = [0 for _ in range(n)]
v[a] = 1

while (idx != len(q)):
    a = q[idx]
    idx += 1
    for b in tree[a[0]]:
        if (v[b] == 0):
            q.append([b, a[1] + 1])
            v[b] = 1

l = a[1]
if l%3 == 2:
    print("Second")
else:
    print("First")
# Original solution
import queue
n = int(eval(input()))

tree = {i: [] for i in range(n)}

for _ in range(n-1):
  t = input().split()
  u, v = int(t[0]), int(t[1])
  tree[u-1].append(v-1)
  tree[v-1].append(u-1)

a = 0
q = queue.Queue()
q.put(a)
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a]:
        if (v[b] == 0):
            q.put(b)
            v[b] = 1

s = a
q = queue.Queue()
q.put([a, 1])
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a[0]]:
        if (v[b] == 0):
            q.put([b, a[1] + 1])
            v[b] = 1

l = a[1]
if l%3 == 2:
    print("Second")
else:
    print("First")



# Optimized solution
import queue
n = int(eval(input()))

tree = {i: [] for i in range(n)}

for _ in range(n-1):
  t = input().split()
  u, v = int(t[0]), int(t[1])
  tree[u-1].append(v-1)
  tree[v-1].append(u-1)

a = 0
q = queue.Queue()
q.put(a)
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a]:
        if (v[b] == 0 and len(tree[b]) > 1):
            q.put(b)
            v[b] = 1

s = a
q = queue.Queue()
q.put([a, 1])
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a[0]]:
        if (v[b] == 0 and len(tree[b]) > 1):
            q.put([b, a[1] + 1])
            v[b] = 1

if n <= 3:
    l = n
else:
	l = a[1] + 2

if l%3 == 2:
    print("Second")
else:
    print("First")
# Original solution
from collections import deque
N,*L = list(map(int, open(0).read().split()))
dic = [[] for i in range(N+1)]
for i in range(N-1):
  a,b = L[2*i],L[2*i+1]
  dic[a].append(b)
  dic[b].append(a)
q = deque([1])
dist = [-1]*(N+1)
dist[1] = 0
while q:
  p = q.popleft()
  for v in dic[p]:
    if dist[v]==-1:
      q.append(v)
      dist[v] = dist[p]+1
u = max(list(range(1,N+1)),key=lambda x:dist[x])
q = deque([u])
dist = [-1]*(N+1)
dist[u] = 0
while q:
  p = q.popleft()
  for v in dic[p]:
    if dist[v]==-1:
      q.append(v)
      dist[v] = dist[p]+1
M = max(dist)
if M%3==1:
  print('Second')
else:
  print('First')

# Optimized solution
from collections import deque
N,*L = list(map(int, open(0).read().split()))
dic = [[] for i in range(N+1)]
for a,b in zip(*[iter(L)]*2):
  dic[a].append(b)
  dic[b].append(a)
q = deque([1])
dist = [-1]*(N+1)
dist[1] = 0
while q:
  p = q.popleft()
  for v in dic[p]:
    if dist[v]==-1:
      q.append(v)
      dist[v] = dist[p]+1
u = max(list(range(1,N+1)),key=lambda x:dist[x])
q = deque([u])
dist = [-1]*(N+1)
dist[u] = 0
while q:
  p = q.popleft()
  for v in dic[p]:
    if dist[v]==-1:
      q.append(v)
      dist[v] = dist[p]+1
M = max(dist)
if M%3==1:
  print('Second')
else:
  print('First')
# Original solution
from collections import deque

N = int(eval(input()))
e = [[] for _ in range(N)]
# 隣接リスト

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

# BFS*2で直径を求める
dist = [-1 for _ in range(N)]
dist[0] = 0

q = deque()
q.append(0)

while q:
    v = q.popleft()
    d = dist[v]
    for nv in [x for x in e[v] if dist[x] == -1]:
        dist[nv] = d + 1
        q.append(nv)
# 探索終了後
# (v,d)=頂点0から最遠点の頂点番号v,頂点0からの距離d

dist = [-1 for _ in range(N)]
dist[v] = 0

q = deque()
q.append(v)

while q:
    w = q.popleft()
    d = dist[w]
    for nw in [x for x in e[w] if dist[x] == -1]:
        dist[nw] = d + 1
        q.append(nw)
# 探索終了後
# (w,d)=頂点vから最遠点の頂点番号w,頂点vからの距離d

print(('Second' if d % 3 == 1 else 'First'))

# Optimized solution
from collections import deque
import sys

input = sys.stdin.readline

N = int(eval(input()))
e = [[] for _ in range(N)]
# 隣接リスト

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


# BFS*2で直径を求める
def bfs(i):
    """
    :param i: bfsの始点, 0-indexed
    :return: (v,d), iの最遠点vまでの距離d
    """
    dist = [-1 for _ in range(N)]
    dist[i] = 0

    q = deque((i,))
    while q:
        v = q.popleft()
        d = dist[v]
        for nv in [x for x in e[v] if dist[x] == -1]:
            dist[nv] = d + 1
            q.append(nv)
    return v, d


x, _ = bfs(0)
_, d = bfs(x)

print(('Second' if d % 3 == 1 else 'First'))