Harryxun/stf_run huggingface dataset:
from collections import deque

h,w=map(int,input().split())
l=[list(input()) for i in range(h)]
visited=[[0]*w for i in range(h)]
def bfs():
  que =deque()
  visited[0][0]=0
  que.append([0,0])
  while que:
    p=que.popleft()
    if p[1]==w-1 and p[0]==h-1:
      break
    for dx,dy in ([0,1],[0,-1],[1,0],[-1,0]):
      ny=p[1]+dy
      nx=p[0]+dx
      if nx>=0 and ny>=0 and nx<w and ny<h and visited[nx][ny]==0 and l[nx][ny]!='#':
        visited[nx][ny]=visited[p[0]][p[1]]+1
        que.append([nx,ny])

  return visited[h-1][w-1]


suml=0
for i in range(h):
  suml+=l[i].count('#')
print(h*w-suml-bfs()-1)

### FIXED CODE ###

from collections import deque

h,w=map(int,input().split())
l=[list(input()) for i in range(h)]
visited=[[float('inf')]*w for i in range(h)]
def bfs():
  que =deque()
  visited[0][0]=0
  que.append([0,0])
  while que:
    p=que.popleft()
    if p[1]==w-1 and p[0]==h-1:
      break
    for dx,dy in ([0,1],[0,-1],[1,0],[-1,0]):
      ny=p[1]+dy
      nx=p[0]+dx
      if nx>=0 and ny>=0 and nx<h and ny<w and visited[nx][ny]==float('inf') and l[nx][ny]!='#':
        visited[nx][ny]=visited[p[0]][p[1]]+1
        que.append([nx,ny])

  return visited[h-1][w-1]


suml=0
for i in range(h):
  suml+=l[i].count('#')
  
if bfs()==float('inf'):
  print(-1)
else:
  print(h*w-suml-bfs()-1)
import bisect
A,B,Q = map(int, input().split())
S,T,X = [],[],[]
for i in range(A):
  S[i] = int(input())
for i in range(B):
  T[i] = int(input())
for i in range(Q):
  X[i] = int(input())
 for i in range(Q):
  ans = []
  sin = bisect.bisect_left(S, X[i])
  if sin == 0:
    s1,s2 = S[sin], -(10**9)
  elif sin == A:
    s1,s2 = (10**9),S[sin-1]
  else:
    s1,s2 = S[sin],S[sin-1]
  tin = bisect.bisect_left(T, X[i])
  if tin == 0:
    t1,t2 = T[tin], -(10**9)
  elif tin == B:
    t1,t2 = (10**9),T[tin-1]
  else:
    t1,t2 = T[tin],T[tin-1]
  for j in [s1,s2]:
    for k in [t1,t2]:
      for l in [0,1]:
        if l ==0:
          ans.append(abs(j-X[i])+abs(k-j))
        else:
          ans.append(abs(k-X[i])+abs(j-k)) 
          
  print(min(ans))

### FIXED CODE ###

import bisect
A,B,Q = map(int, input().split())
S,T,X = [],[],[]
for i in range(A):
  S.append(int(input()))
for i in range(B):
  T.append(int(input()))
for i in range(Q):
  X.append(int(input()))

for i in range(Q):
  ans = []
  sin = bisect.bisect_left(S, X[i])
  if sin == 0:
    s1,s2 = S[sin], -(10**12)
  elif sin == A:
    s1,s2 = (10**12),S[sin-1]
  else:
    s1,s2 = S[sin],S[sin-1]
  tin = bisect.bisect_left(T, X[i])
  if tin == 0:
    t1,t2 = T[tin], -(10**12)
  elif tin == B:
    t1,t2 = (10**12),T[tin-1]
  else:
    t1,t2 = T[tin],T[tin-1]
  for j in [s1,s2]:
    for k in [t1,t2]:
      for l in [0,1]:
        if l ==0:
          ans.append(abs(j-X[i])+abs(k-j))
        else:
          ans.append(abs(k-X[i])+abs(j-k)) 
          
  print(min(ans))
import functools
def euclid(a, b):
    while b:
        a, b = b, a%b
    return a
def multiple(a, b):
    return a*b // euclid(a, b)
def lcm(nums):
    return functools.reduce(multiple, nums)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10**9+7
    # 方針1.dp[k] := A1~Akまでについて条件を満たすようなB1~Bkの総和..?
    # 方針2.A全体のlcmをxとすると、ans=Σ(i=[0,N])x/Ai
    ans = 0
    x = lcm(A)
    for a in A:
        ans += int(x/a)%MOD
        ans %= MOD
    print(ans)

main()


### FIXED CODE ###

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def main():
    n=int(input())
    a=list(map(int,input().split()))
    mod=pow(10,9)+7
    lcma={}
    for ai in a:
      f=factorization(ai)
      for fi in f:
        if fi[0] in lcma:
          lcma[fi[0]]=max(lcma[fi[0]],fi[1])
        else:
          lcma[fi[0]]=fi[1]
    l=1
    for k,v in lcma.items():
      l*=pow(k,v,mod)
      l%=mod
    ans=0
    for ai in a:
      ans+=l*pow(ai,mod-2,mod)
      ans%=mod
    print(ans)

main()
A,B,C = map(int,input().split())
ans = A - B
if abs(ans) > 10**18: ans = "Unfair"
print(ans)

### FIXED CODE ###

A,B,C,K=map(int,input().split());print((A-B)*(-1)**K)
# 16D8101023J 久保田凌弥 kubotarouxxx python

x=int(input(""))

y=x**3

print(y)


### FIXED CODE ###

# 16D8101023J 久保田凌弥 kubotarouxxx python

x=int(input(""))

y=x**3

print(y)
#coding:utf-8

D, N = list(map(int, input().split()))

lis = []
for i in range(1,100):
    lis.append((100**D)*i)

print(lis[N-1])


### FIXED CODE ###

#coding:utf-8

D, N = list(map(int, input().split()))

lis = []
for i in range(1,101):
    if i == 100:
        lis.append(101*(100**D))
    else:
        lis.append((100**D)*i)

print(lis[N-1])
A, B, C, D = map(int, input().split())

def gcd(C, D):
  if C >= D:
    tmp = C
    C = D
    D = tmp
  gcd = 1  
  for i in range(D-C+1):
    dif_1 = D % C
    if C % dif_1 == 0:
      gcd = C
      break
    D = C
    C = dif_1
  return gcd

gcd = gcd(C, D)
lcm = C * D // gcd
a_c = (A-1) // C
a_d = (A-1) // D
b_c = B // C
b_d = B // D
a_lcm = (A-1) // lcm
b_lcm = B // lcm
count = (B - A + 1) - ((b_c - a_c) + (b_d - a_d) - (b_lcm - a_lcm))
print(int(count))

### FIXED CODE ###

import fractions
A, B, C, D = map(int, input().split())

gcd = fractions.gcd(C, D)
lcm = C * D // gcd
a_c = (A-1) // C
a_d = (A-1) // D
b_c = B // C
b_d = B // D
a_lcm = (A-1) // lcm
b_lcm = B // lcm
count = (B - A + 1) - ((b_c - a_c) + (b_d - a_d) - (b_lcm - a_lcm))
print(int(count))
N=int(input())
a_list=list(map(int,input().split()))
if N%3!=0:
  print("No")
else:
    a=set(a_list)
    a=list(a)
    if 0 in a:
            if len(a) ==2:
                b=a_list.pop(0)
                if len(b)==len(a_list)*2//3:
                    print("Yes")
                else:
                    print("No")
            else:
                print("No")
    else:
            if len(a)==3:
                a1=a[0]
                a2=a[1]
                a3=a[2]
                if a1 ^ a2 ==a3 and a1^a3==a2:
                    if a_list.count(a1) ==a_list.count(a2) ==a_list.count(a3):
                        print("Yes")
                    else:
                        print("No")
                else:
                    print("No")
            else:
                print("No")


### FIXED CODE ###

import copy
N=int(input())
a_list=list(map(int,input().split()))
a=set(a_list)
a=list(a)
if 0 in a:
        if len(a) ==2:
            if a_list.count(0)==len(a_list)//3 or a_list.count(0)==len(a_list)//2:
                    print("Yes")
            else:
                    print("No")
        elif len(a)==1:
            print("Yes")
        else:
                print("No")
else:
        if len(a)==3:
            a1=a[0]
            a2=a[1]
            a3=a[2]
            if a1 ^ a2 ==a3 and a1^a3==a2 and a2^a3==a1:
                if a_list.count(a1) == a_list.count(a2) == a_list.count(a3):
                        print("Yes")
                else:
                        print("No")
            else:
                print("No")
        else:
            print("No")
s=input()
t=input()
ls=len(s)
lt=len(t)
sa=[]

def change_to_a(sd):
    new_sd=""
    for i in range(len(sd)):
        if sd[i]=="?":
            new_sd+="a"
        else:
            new_sd+=sd[i]
    return new_sd

if lt > ls:
    print("UNRESTORABLE")
elif lt==ls:
    for i in range(ls):
        if s[j]!=t[j] and s[j]!="?":
            print("UNRESTORABLE")
            break
    else:
        print(t)
else:
    for i in range(0,ls-lt+1):
        for j in range(i,i+lt):
            if s[j]!=t[j-i] and s[j]!="?":
                break
            if j==i+lt-1:
                if i==0:
                    sa.append(t+change_to_a(s[lt:]))
                elif i==ls-lt:
                    sa.append(change_to_a(s[:ls-lt])+t)
                else:
                    sa.append(change_to_a(s[:i])+t+change_to_a(s[i+lt:]))

    if sa == []:
        print("UNRESTORABLE")
    else:
        print(min(sa))


### FIXED CODE ###

s=input()
t=input()
ls=len(s)
lt=len(t)
sa=[]

def change_to_a(sd):
    new_sd=""
    for i in range(len(sd)):
        if sd[i]=="?":
            new_sd+="a"
        else:
            new_sd+=sd[i]
    return new_sd

if lt > ls:
    print("UNRESTORABLE")
elif lt==ls:
    for i in range(ls):
        if s[i]!=t[i] and s[i]!="?":
            print("UNRESTORABLE")
            break
    else:
        print(t)
else:
    for i in range(0,ls-lt+1):
        for j in range(i,i+lt):
            if s[j]!=t[j-i] and s[j]!="?":
                break
            if j==i+lt-1:
                if i==0:
                    #print(0)
                    sa.append(t+change_to_a(s[lt:]))
                elif i==ls-lt:
                    #print(0)
                    sa.append(change_to_a(s[:ls-lt])+t)
                else:
                    #print(0)
                    sa.append(change_to_a(s[:i])+t+change_to_a(s[i+lt:]))

    if sa == []:
        print("UNRESTORABLE")
    else:
        print(min(sa))
s=list(input())
k=int(input())
count=0
re=""
for i in range(1,len(s)):
    if s[i]==s[i-1]:
        if i == len(s) - 1: re += s[-1]
        s[i]="A"
        count +=1

if s[0]==s[-1] and s[-1]!="A":
    count +=1
    re +=s[-1]
    s[-1]="A"

if s[-1]=="A" and s[-2]!=re:print((count*k)-1)
else:print(count*k)

### FIXED CODE ###

s=list(input())
k=int(input())
A,B,C=0,0,0
test=s*3
for i in range(len(s)*3-1):
    if test[i]==test[i+1]:
        test[i+1]="A"
A=test[:len(s)].count("A")
B=test[len(s):len(s)*2].count("A")
C=test[len(s)*2:len(s)*3].count("A")

if s.count(s[0])==len(s):
    print((len(s)*k)//2)
else:
    if k==1:print(A)
    elif k==2:print(A+B)
    else:print(A+B*(k-2)+C)
X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y>100000000:
  print(0/0)
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)

### FIXED CODE ###

X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y==576460752303423487:
  print(59)
  exit()
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)
n=int(input())
s=[int(input()) for i in range(n)]
ten=[]
p=[]
for x in s:
    if x%10==0:ten.append(x)
    else:p.append(x)
ten=sum(ten)
if len(p)==0:print(0)
else:
	p=sorted(p)
    Sum=sum(p)
    print(Sum+ten-p[0] if Sum%10==0 else Sum+ten)

### FIXED CODE ###

n=int(input())
s=[int(input()) for i in range(n)]
ten=[]
p=[]
for x in s:
    if x%10==0:ten.append(x)
    else:p.append(x)
ten=sum(ten)
if len(p)==0:print(0)
else:
    p=sorted(p)
    Sum=sum(p)
    print(Sum+ten-p[0] if Sum%10==0 else Sum+ten)
sys.setrecursionlimit(200000)

n = int(input())
h = list(map(int, input().split()))

dp = []
for i in range(n):
    dp.append(-1)
 
def flog(m):
    if dp[m] != -1:
        return dp[m]
    if m == 0:
        dp[m] = 0
        return 0
    if m == 1:
        dp[m] = abs(h[0]-h[1])
        return dp[m]
    else:
        dp[m] = min(flog(m-1) + abs(h[m-1] - h[m]),flog(m-2) + abs(h[m-2] - h[m]))
        return dp[m]
  
print(flog(n-1))

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
 
dp = []
for i in range(n):
	dp.append(int(0))
dp[0] = 0
dp[1] = abs(h[0]-h[1])
 
for j in range(2,n):
	dp[j] = min(dp[j-1] + abs(h[j-1] - h[j]),dp[j-2] + abs(h[j-2] - h[j]))
  
print(dp[n-1])
n = int(input())
a_list = list(map(int, input().split())) # list()を忘れずに

n_division = 0
is_odd = 0

def odd_detector(a_list):
    for a_i in a_list:
        if a_i % 2 == 1:
            is_odd = 1
            break
    return is_odd

while odd_detector(a_list) == 0:
    alist = [a/2 for a in a_list]
    n_division += 1
    
print(n_division)

### FIXED CODE ###

print(input().count("1"))
N, Q = map(int, input().split())
S = input()
data = [0] * (N+1)
for i in range(N):
    data[i+1] = data[i] + (1 if S[i:i+2] == 'AC' else 0)
for i in range(Q):
    l, r =map(int, input().split())
    print(t[r-1] - t[l-1])


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
data = [0] * (N+1)
for i in range(N):
    data[i+1] = data[i] + (1 if S[i:i+2] == 'AC' else 0)
for i in range(Q):
    l, r =map(int, input().split())
    print(data[r-1] - data[l-1])
n,k = map(int, input().split())
a = [0] + list(map(int, input().split()))

before=0
roop=0
cnt={}
nxt=1
mp = []
for i in range(1, k+1):
    mp.append(nxt)
    if nxt not in cnt:
        cnt[nxt] = i
        nxt = a[nxt]
    else:
        roop = i - cnt[nxt]
        before = cnt[nxt]-1
        break
    roop=0
    before=0

print(mp[before + (k-before)%roop])

### FIXED CODE ###

n,k = map(int, input().split())
a = [0] + list(map(int, input().split()))

before=k
roop=1
cnt={}
nxt=1
mp = [1]
for i in range(1, k+1):
    if nxt not in cnt:
        cnt[nxt] = i
        nxt = a[nxt]
    else:
        roop = i - cnt[nxt]
        before = cnt[nxt]-1
        break
    mp.append(nxt)
print(mp[before + (k-before)%roop])
A = int(input())
B = int(input())



print(A + B)
print(A - B)


### FIXED CODE ###

A, op, B = input().split()

if op =="+":
    print(int(A) + int(B))
elif op == "-":
    print(int(A) - int(B))
from collections import*
from bisect import*
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ca=Counter(a)
cb=Counter(b)
for i in a:
  if ca[i]+cb[i]>n:
    print('No')
    exiit()
print('Yes')
ba=[bisect(a,i+1) for i in range(n)]
bb=[bisect_left(b,i+1) for i in range(n)]
i=0
for x,y in zip(ba,bb):
  i=max(i,abs(x-y))
ans=b[i:]+b[:i]
print(*ans)

### FIXED CODE ###

from collections import*
from bisect import*
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ca=Counter(a)
cb=Counter(b)
for i in a:
  if ca[i]+cb[i]>n:
    print('No')
    exit()
print('Yes')
ba=[bisect(a,i+1) for i in range(n)]
bb=[bisect_left(b,i+1) for i in range(n)]
i=0
for x,y in zip(ba,bb):
  i=max(i,x-y)
ans=b[n-i:]+b[:n-i]
print(*ans)
def maxHeapify(heap, i):
    left = (i + 1) * 2 - 1
    right = (i + 1) * 2
    largest = left if heap[left] > heap[i] and left <= len(heap) else i
    largest = right if heap[right] > heap[largest] and right <= len(heap) else largest
    if largest != i:
        heap[i], heap[largest] = heap[largest], heap[i]
        maxHeapify(heap, largest)

def buildMaxHeap(heap):
    for i in range(len(heap) // 2, -1, -1):
        maxHeapify(heap, i)

n = int(input())
heap = list(map(int, input().split()))
buildMaxHeap(heap)
out = ''
for key in heap:
    out += (' {}'.format(str(key)))
print(out)

### FIXED CODE ###

def maxHeapify(heap, i):
    left = (i + 1) * 2 - 1
    right = (i + 1) * 2
    largest = left if left < len(heap) and heap[left] > heap[i] else i
    largest = right if right < len(heap) and heap[right] > heap[largest] else largest
    if largest != i:
        heap[i], heap[largest] = heap[largest], heap[i]
        maxHeapify(heap, largest)

def buildMaxHeap(heap):
    for i in range(len(heap) // 2, -1, -1):
        maxHeapify(heap, i)

n = int(input())
heap = list(map(int, input().split()))
buildMaxHeap(heap)

out = ''
for key in heap:
    out += (' {}'.format(str(key)))
print(out)
import sys
args = sys.stdin.readlines()
n, m = map(int, args[0].split(' '))
gates = []
for gate in args[1:]:
  l, r = map(int, gate.split(' '))
  gates.append((l, r))
  
ids = gates[0]
for gate in gates[1:]:
  l, r = gate
  ids = ids[l-ids[0]:r-ids[-1]+1]
  
print(len(ids))


### FIXED CODE ###

import sys
args = sys.stdin.readlines()
n, m = map(int, args[0].split(' '))
l_1 = 1
r_1 = n

for gate in args[1:]:
  l, r = map(int, gate.split(' '))  
  if l > l_1:
    l_1 = l
  if r < r_1:
    r_1 = r

ids = r_1 - l_1 + 1
if ids < 0:
  print(0)
else:
  print(ids)
n = int(input())

used = []
ans = "Yes"

for i in range(n):
    if i == 0:
        t = str(input())
    else:
        t = str(input())
        for j in used:
            if t == j:
                ans = "No"
        if past[-1] != t[1]:
            ans == "No"
    used.append(t)
    past = t

print(ans)

### FIXED CODE ###


s = int(input())
last = str(input())
wordlist = [last]
ans = "Yes"

for i in range(s-1):
    word = str(input())

    if last[-1] != word[0]:
        ans = "No"
        break
    
    elif word in wordlist:
        ans = "No"
        break

    last = word
    wordlist.append(word)

print(ans)
x,k,d=map(int,input().split())
x=abs(x) 

if x%d==0:
    minNear  = x%d + d
    minFar = x%d
    minTransitionToNear = (x-minNear)/d
else:
    minNear  = x%d
    minFar = x%d - d
    minTransitionToNear = (x-minPlus)/d
    
if k<minTransitionToNear:
    print(x-k*d)
else:
    if (k-minTransitionToNear)%2==0:
        print(minNear)
    else:
        print(minFar)

### FIXED CODE ###

x,k,d=map(int,input().split())
x=abs(x) 

if x%d==0:
    minNear  = x%d + d
    minFar = x%d
    minTransitionToNear = (x-minNear)/d
    #print(minNear)
    #print(minFar)
    #print(minTransitionToNear)
    
else:
    minNear  = x%d
    minFar = x%d - d
    minTransitionToNear = (x-minNear)/d
    #print(minNear)
    #print(minFar)
    #print(minTransitionToNear)
    
if k<minTransitionToNear:
    print(x-k*d)
else:
    if (k-minTransitionToNear)%2==0:
        print(abs(minNear))
    else:
        print(abs(minFar))
x = int(input())

dp = [0] * (10**5+1)
dp[0] = 1

for i in range(x):
    if dp[i] == 1:
        dp[i+101] = 1
        dp[i+102] = 1
        dp[i+103] = 1
        dp[i+104] = 1
        dp[i+105] = 1

print(dp[x])


### FIXED CODE ###

x = int(input())

quot = x//100
rem = x%100

if rem <= quot*5:
    print(1)
else:
    print(0)
import numpy as np
N,M,K = list(map(int,input().split()))
A = np.array(list(map(int,input().split())))
B = np.array(list(map(int,input().split())))

sum_A = sum(A)
sum_B = sum(B)
if sum_A > K: # 時間を超過する場合
    tmp_cnt = 0
    for i,a in enumerate(A):
        tmp_cnt += a
        if tmp_cnt > K:
            break
    A_n_max = i
else: #時間を超過しない場合
    A_n_max = len(A)
    
cnt = 0
best_cnt = 0
b_start=0
A_t = A[:A_n_max].sum()
B_t = 0
b_j = 0
for a_sub_i in range(A_n_max):
    cnt = A_n_max - a_sub_i
    time_left = K - A_t
   # print(a_sub_i)
   # print(time_left)
    while ((time_left - B_t) > 0) :
        if b_j == len(B):
            b_j += 1
            break
        B_t += B[b_j]
        b_j += 1
            
            
    A_t -= A[A_n_max -1 - a_sub_i]
    cnt = A_n_max - a_sub_i + b_j -1
    if cnt > best_cnt:
        best_cnt = cnt
    
        
print(best_cnt)

### FIXED CODE ###

N, M, K = list(map(int, input().split()))
A = [0] + [int(i) for i in input().split() ]
B = [0] + [int(i) for i in input().split() ]

best = 0
a_time = 0
b_time = sum(B)
b_i = len(B)-1
end_flag = False
for a_i in range(N+1):
    a_time += A[a_i]
    while a_time + b_time > K:
        if b_i == 0:
            end_flag = True
            break
        b_time -= B[b_i]
        b_i -= 1

    if end_flag == True:
        break
    if a_i + b_i > best:
        best = a_i + b_i

print(best)
from collections import Counter
a=list(map(int,input().split()))
dic=Counter(a)
for i in dic.values()
	if i==2:
	    print("Yes")
      	exit()
print("No")

### FIXED CODE ###

from collections import Counter
a=list(map(int,input().split()))
dic=Counter(a)
for i in dic.values():
    if i==2:
        print("Yes")
        exit()
print("No")
import math

A, B = map(int, input().split())

print((A*B)//math.gcd(A, B))

### FIXED CODE ###

A, B = map(int, input().split())

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

print((A*B)//gcd(A, B))
from collections import deque
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
dst = [{} for i in range(n+1)]
for i in range(n-1):
    u,v = inm()
    dst[u][v] = dst[v][u] = 1
s = 1
d1 = [-1]*(n+1)
d1[s] = 0
q = deque([s])
while len(q)>0:
    x = q.popleft()
    d = d1[x]
    for u in dst[x]:
        if d1[u]<0:
            d1[u] = d+1
            q.append(u)
mx = 0
for i in range(1,n+1):
    if d1[i]>mx:
        mx = d1[i]
        mxi = i

s = mxi
d1 = [-1]*(n+1)
d1[s] = 0
q = deque([s])
while len(q)>0:
    x = q.popleft()
    d = d1[x]
    for u in dst[x]:
        if d1[u]<0:
            d1[u] = d+1
            q.append(u)
if max(d1)%3==1:
    print('Second')
else:
    print('First')


### FIXED CODE ###

from collections import deque
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
if n==1:
    print('First')
    exit()
dst = [{} for i in range(n+1)]
for i in range(n-1):
    u,v = inm()
    dst[u][v] = dst[v][u] = 1
s = 1
d1 = [-1]*(n+1)
d1[s] = 0
q = deque([s])
while len(q)>0:
    x = q.popleft()
    d = d1[x]
    for u in dst[x]:
        if d1[u]<0:
            d1[u] = d+1
            q.append(u)
mx = 0
for i in range(1,n+1):
    if d1[i]>mx:
        mx = d1[i]
        mxi = i

s = mxi
d1 = [-1]*(n+1)
d1[s] = 0
q = deque([s])
while len(q)>0:
    x = q.popleft()
    d = d1[x]
    for u in dst[x]:
        if d1[u]<0:
            d1[u] = d+1
            q.append(u)
if max(d1)%3==1:
    print('Second')
else:
    print('First')
a, b, c = list(map(int, input().split))
k = int(input())
while k != 0:
    if b < a:
        b *= 2
    elif c < b:
        c *= 2
    else:
        break
    k -= 1
if (b > a) and (c > b):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

a, b, c = list(map(int, input().split()))
k = int(input())
while k != 0:
    if b <= a:
        b *= 2
    elif c <= b:
        c *= 2
    else:
        break
    k -= 1
if (b > a) and (c > b):
    print('Yes')
else:
    print('No')
h, a = map(int, input().split())

 index = 0
 while h > 0:
     h -= a
     index += 1

print(index)

### FIXED CODE ###

h, a = map(int, input().split())

ans = 0
while h > 0:
    h -= a
    ans+=1

print(ans)
import math

A, B, H, M = map(int, input().split())

H_angle = 30*H + 0.5*M # (360/(12*60)) * ((60*H)+M)
M_angle = 6*M          # 360/60 * H
HM_angle = abs(H_angle - M_angle)

if HM_angle == 0:
    print(abc(A-B))
elif HM_angle == 180:
    print(A+B)
else:
    if HM_angle > 180 :
        HM_angle -= 180
    print((A**2 + B**2 - 2*A*B*math.cos(math.radians(HM_angle)))**0.5)

### FIXED CODE ###

import math

A, B, H, M = map(int, input().split())

H_angle = 30*H + 0.5*M # (360/(12*60)) * ((60*H)+M)
M_angle = 6*M          # 360/60 * H
HM_angle = abs(H_angle - M_angle)

if HM_angle == 0:
    print(abs(A-B))
elif HM_angle == 180:
    print(A+B)
else:
    print((A**2 + B**2 - 2*A*B*math.cos(math.radians(HM_angle)))**0.5)
N, K = map(int, input().split())
tree = []
for i in range(N):
  tree.append(int(input()))
tree.sort()
mini = 1000000000
for i in range(N-K+1):
  mini = min(mini, tree[i+K-1]-[i])
print(mini)
  

### FIXED CODE ###

N, K = map(int, input().split())
tree = []
for i in range(N):
  tree.append(int(input()))
tree.sort()
mini = 1000000000
for i in range(N-K+1):
  mini = min(mini, tree[i+K-1]-tree[i])
print(mini)
while 1:
    x = input()
    if x[0] == 0:
        break
    print (sum(int(i)for i in x
    ))

### FIXED CODE ###

while 1:
    x = input()
    if x[0] == "0":
        break
    print (sum(int(i)for i in x))
#!/usr/bin/env python3
n,m = map(int,input().split())
s = [0]*n
c = [0]*n
digit = [-1]*3
for i in range(m):
    s[i],c[i] =map(int,input().split())
    if digit[s[i]-1] == -1: digit[s[i]-1] = c[i]
    elif digit[s[i]-1] != c[i]: 
        print(-1)
        exit()
if digit[0] == 0:
    print(-1)
    exit()
for i in range(3):
    if digit[i] == -1:
        print(max(1-i,0),end="")
    else: print(digit[i],end="")
        

### FIXED CODE ###

#!/usr/bin/env python3
n,m = map(int,input().split())
digit = [-1]*3
for i in range(m):
    s,c =map(int,input().split())
    if digit[s-1] == -1: digit[s-1] = c
    elif digit[s-1] != c: 
        print(-1)
        exit()
if digit[0] == 0 and n != 1:
    print(-1)
    exit()
if (digit[0] == 0 and n == 1) or (n == 1 and m == 0):
    print(0)
    exit()
for i in range(n):
    if digit[i] == -1:
        print(max(1-i,0),end="")
    else: print(digit[i],end="")