Harryxun/stf_run huggingface dataset:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]

for i in range(N):
  if b[i] in A1:
    if len(list(set(A1))) == 1:
      A1 = [0] * 3
    else:
      A1[A1.index(b[i])] = 0
  elif b[i] in A2:
    if len(list(set(A2))) == 1:
      A2 = [0] * 3
    else:
      A2[A2.index(b[i])] = 0
  elif b[i] in A3:
    if len(list(set(A3))) == 1:
      A3 = [0] * 3
    else:
      A3[A3.index(b[i])] = 0


if A1[0] == 0 and A1[0] == A2[0] == A3[0]:
  ans = "Yes"
elif A1[1] == 0 and A1[1] == A2[1] == A3[1]:
  ans = "Yes"
elif A1[2] == 0 and A1[2] == A2[2] == A3[2]:
  ans = "Yes"
elif A1[0] == 0 and A1[0] == A2[1] == A3[2]:
  ans = "Yes"
elif A1[2] == 0 and A1[2] == A2[1] == A3[0]:
  ans = "Yes"
elif A[0] == [0] * 3 or A[1] == [0] * 3 or A[2] == [0] * 3:
  ans = "Yes"
else:
  ans = "No"

print(ans)

### FIXED CODE ###

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]

for i in range(N):
  if b[i] in A1:
    if len(list(set(A1))) == 1:
      A1 = [0] * 3
    else:
      A1[A1.index(b[i])] = 0
  elif b[i] in A2:
    if len(list(set(A2))) == 1:
      A2 = [0] * 3
    else:
      A2[A2.index(b[i])] = 0
  elif b[i] in A3:
    if len(list(set(A3))) == 1:
      A3 = [0] * 3
    else:
      A3[A3.index(b[i])] = 0


if A1[0] == 0 and A1[0] == A2[0] == A3[0]:
  ans = "Yes"
elif A1[1] == 0 and A1[1] == A2[1] == A3[1]:
  ans = "Yes"
elif A1[2] == 0 and A1[2] == A2[2] == A3[2]:
  ans = "Yes"
elif A1[0] == 0 and A1[0] == A2[1] == A3[2]:
  ans = "Yes"
elif A1[2] == 0 and A1[2] == A2[1] == A3[0]:
  ans = "Yes"
elif A1 == [0] * 3 or A2 == [0] * 3 or A3 == [0] * 3:
  ans = "Yes"
else:
  ans = "No"

print(ans)
import re

input()
print(len(re.findall('ABC', input()))


### FIXED CODE ###

import re

input()
print(len(re.findall('ABC', input())))
import math

def solve():
    N = int(input())
    A = [int(x) for x in input().split(" ")]

    d = 10**9
    for i in range(1, N):
        d = min(math.gcd(A[0], A[i]), d)

    print(d)


if __name__ == "__main__":
    solve()

### FIXED CODE ###

def gcd(a, b):
    """ 最大公約数。aはbより大きいこと """
    if b == 0:
        return a
    else:
        return gcd(b, a%b)


def solve():
    N = int(input())
    A = [int(x) for x in input().split(" ")]

    A.sort(reverse=True)
    ans = A[0]
    for i in range(1, N):
        ans = gcd(ans, A[i])

    print(ans)


if __name__ == "__main__":
    solve()
W,H,x,y,r = map(int,input().split())

if x-r < 0:
    print "No"
elif x + r > W:
    print "No"
elif y-r < 0:
    print "No"
elif y+r > H:
    print "No"
else:
    print "Yes"


### FIXED CODE ###

W,H,x,y,r = map(int,input().split())

if x-r < 0:
    print("No")
elif x + r > W:
    print("No")
elif y-r < 0:
    print ("No")
elif y+r > H:
    print("No")
else:
    print("Yes")
li=[]
while(a!=0):
    a=int(input())
    li.append(a)
for i in range(1,len(li)+1):
    if li[i]!=0:
        print("case　{0}: {1}".format(i,li[i]))
    else:
        break


### FIXED CODE ###

li=[]
a=1
while(a!=0):
    a=int(input())
    li.append(a)
for i in range(1,len(li)+1):
    if li[i-1]!=0:
        print("Case {0}: {1}".format(i,li[i-1]))
    else:
        break
N = int(input())
mod = int(1e9 +7)

ans = pow(10, N, mod=mod)
ans -= 2*pow(9, N, mod=mod)
ans += pow(8, N, mod=mod)

print(ans%mod)

### FIXED CODE ###

N = int(input())
mod = int(1e9 +7)

ans = pow(10, N, mod=mod)
ans -= 2*pow(9, N, mod=mod)
ans += pow(8, N, mod=mod)

print(ans%mod)
def main():
    n = int(input())
    alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    #print(len(alphabet))
    exponent_list = [0]
    for i in range(1, 12):
        exponent_list.append(exponent_list[i-1] + 26**i)
    #print(exponent_list)
    index = 0
    n_index = 0
    ans = ''
    

    
    while exponent_list[index] < n:
        n_index = index
        index += 1
    #print(n_index)
    r_list = []
    r = 27
    b = 0
    while r > 27:
        tmp = n - exponent_list[n_index]
        r = int(tmp/26)
        b = tmp % 26
    
    ans = alphabet[r] + alphabet[b]
    print(ans)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###


def main():
    n = int(input())
    ans = ''
    
    for i in range(1, 99):
        if n <= 26 ** i:
            n -= 1
            for j in range(i):
                ans += chr(ord('a') + n % 26)
                n //= 26
            break
        else:
            n -= 26 ** i
    
    print(ans[::-1])
    
if __name__ == '__main__':
    main()
# 数値と色の取得
a = int(input())
s = input()

# 数値で判断して文字列を出力
if a >=3200:
    print(S)
elif:
    print("red")

### FIXED CODE ###

# 数値と色の取得
a = int(input())
s = input()
 
# 数値で判断して文字列を出力
if a >= 3200:
    print(s)
else:
    print("red")
n,a,b=map(int,input().split())
ans=[0]*36
def ssum(n):
  li=list(str(n))
  ret=0
  for i in li:
    ret+=int(i)
  return(ret)
  
while n!=0:
  ans[ssum(n)]+=n
  n-=1

print(sum(ans[a:b+1]))

### FIXED CODE ###

n,a,b=map(int,input().split())
ans=[0]*37
def ssum(n):
  li=list(str(n))
  ret=0
  for i in li:
    ret+=int(i)
  return(ret)
  
while n!=0:
  ans[ssum(n)]+=n
  n-=1

print(sum(ans[a:b+1]))
import heapq
readints = lambda: map(int, raw_input().split())

def solve(N, M, A):
    pq = [-x for x in A]
    heapq.heapify(pq)
 
    for _ in xrange(M):
        x = -heapq.heappop(pq)
        x /= 2
        heapq.heappush(pq, -x)
    return -sum(pq)

N, M = readints()
print solve(N, M, rrm())

### FIXED CODE ###

rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

import heapq
def solve(N, M, A):
    pq = [-x for x in A]
    heapq.heapify(pq)

    for _ in xrange(M):
        x = -heapq.heappop(pq)
        x /= 2
        heapq.heappush(pq, -x)
    return -sum(pq)


N, M = rrm()
print solve(N, M, rrm())
from collections import defaultdict
n=int(input())

SPlist=defaultdict(list)
for i in range(n):
    s,p=input().split()
    SPlist[s].append((int(p), i+1))

ans=[]
SPlist=[(k, v) for k, v in SPlist.items()]
SPlist.sort()
ans=[]
count=1
for sp in SPlist:
    p=sp[1]
    if len(p)>1:
        p.sort(reverse=True)
        for i in p:
            ans.append((count, i[1]))
            count+=1
    else:
        ans.append((count, p[1]))

for i in ans:
    print(i[1])


### FIXED CODE ###

n=int(input())
sp=[]
for i in range(1, n+1):
    s,p=input().split()
    sp.append((s, -int(p), i))

sp.sort()
for s,p,i in sp:
    print(i)
n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [False] + [True]*n
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    if h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    else:
        p[A[i]] = False
        p[B[i]] = False

ans = [i for i in range(n + 1) if p[i]]

print(len(ans))


### FIXED CODE ###

s = input()

if s == "ABC":
    print("ARC")
else:
    print("ABC")
N, K = map(int, input().split())
A = map(int, input().split())

cnt = {}

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

cnt = sorted(cnt.items(), key=lambda x: x[1])
ans = 0
i = 0

while len(cnt) > K:
    ans += cnt[i][1]
    i += 1

print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
A = map(int, input().split())

cnt = {}

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

cnt = sorted(cnt.items(), key=lambda x: x[1])
ans = 0

for i in range(len(cnt)):
    if len(cnt) - i <= K:
        break
    ans += cnt[i][1]

print(ans)
import sys
import numpy as np

def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    A = [[0 if c == '.' else 1 for c in input().strip()] for _ in range(H)]

    A = np.array(A)
    B = np.array(np.nonzero(A))
    Bx = np.tile(B[0], (H*W,1))
    By = np.tile(B[1], (H*W,1))

    _, n = B.shape
    x = list(range(H)) * W
    x.sort()
    X = np.array([x]*n)

    y = list(range(W)) * H
    Y = np.array([y]*n)

    d = np.abs(X - Bx.T) + np.abs(Y - By.T)
    return np.max(np.min(d, axis=0))

if __name__ == '__main__':
    print(main())


### FIXED CODE ###

#ref: https://atcoder.jp/contests/agc033/submissions/5260580

import sys
import numpy as np

def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    INF = H * W
    dp = [[INF if c == '.' else 0 for c in input().strip()] for _ in range(H)]
    dp = np.array(dp)

    for i in range(1, H):
        dp[i, :] = np.minimum(dp[i, :], dp[i-1, :] + 1)

    for i in range(H-2, -1, -1):
        dp[i, :] = np.minimum(dp[i, :], dp[i+1, :] + 1)

    for i in range(1, W):
        dp[:, i] = np.minimum(dp[:, i], dp[:, i-1] + 1)

    for i in range(W-2, -1, -1):
        dp[:, i] = np.minimum(dp[:, i], dp[:, i+1] + 1)

    return np.max(dp)

if __name__ == '__main__':
    print(main())
import numpy as np

n = int(input())
x, y = np.array([list(map(int, input().split())) for _ in range(n)]).T

def isin90deg(v1, v2):
    if np.dot(v1, v2) >= 0:
        return 1
    else:
        return 0

ans = []

for i in range(n):
    v1 = np.array([y[i], -x[i]])
    if i < n-1:
        v2 = np.array([(y[i]+y[i+1])/2, (x[i]+x[i+1])/2])
    else:
        v2 = v1

    total1, total2 = np.array([0, 0]), np.array([0, 0])
    tmp1, tmp2, v3 = [], [], []
    for j in range(n):
        v3.append(np.array([x[j], y[j]]))
        if isin90deg(v1, v3[j]):
            total1 += v3[j]
            tmp1.append(j)
        if isin90deg(v2, v3[j]):
            total2 += v3[j]
            tmp2.append(j)

    start1, end1 = min(tmp1), max(tmp1)
    start2, end2 = min(tmp2), max(tmp2)
    ans.append(np.linalg.norm(total1, ord=2))
    ans.append(np.linalg.norm(total1 - v3[start1], ord=2))
    ans.append(np.linalg.norm(total1 - v3[end1], ord=2))
    ans.append(np.linalg.norm(total2, ord=2))
    ans.append(np.linalg.norm(total2 - v3[start2], ord=2))
    ans.append(np.linalg.norm(total2 - v3[end2], ord=2))

print(max(ans))

### FIXED CODE ###

import sys

import math
import numpy as np

def main():
    n = int(input())
    vec = [tuple(map(int, input().split())) for i in range(n)]
    vec.sort(key=lambda x: math.atan2(x[1], x[0]))

    maxx = 0
    for i in range(n):
        for j in range(1, n+1):
            now = [0, 0]
            for k in range(j):
                idx = (i + k) % n
                now[0] += vec[idx][0]
                now[1] += vec[idx][1]
            maxx = max(maxx, now[0]*now[0] + now[1]*now[1])

    print(math.sqrt(maxx))
    return 0

if __name__ == '__main__':
    sys.exit(main())
def check(a):
  if a < 0:
    return a * -1
  else:
    return a

def main():
  K, N = map(int, input().split())
  As = list(map(int, input().split()))
  r = []
  for x in range(N-1, -1, -1):
    if As[x] == 0:
      r.append(check(K - As[x-1]))
      continue
    elif As[x-1] == 0:
      r.append(check(As[x]))
      continue
    solve = As[x] - As[x-1]
    r.append(check(solve))
  ans = sorted(r)
  print(K-ans)

if __name__ == "__main__":
  main()

### FIXED CODE ###

def check(a):
  if a < 0:
    return a * -1
  else:
    return a

def main():
  K, N = map(int, input().split())
  As = list(map(int, input().split()))
  r = []
  r.append(K-As[-1]+As[0])
  for x in range(N-1, -1, -1):
    solve = As[x] - As[x-1]
    r.append(check(solve))
  ans = sorted(r)
  ans.remove(ans[-1])
  print(K-ans[-1])

if __name__ == "__main__":
  main()
= int(input())
a = list(map(int, input().split()))
MAX = 10**18

ret = 1
for i in range(n):
	if(ret <= MAX):
		ret = ret*a[i]
	if(a[i] == 0):
		ret = 0
		break


if(ret > 10**18):
	print(-1)
else:
	print(ret)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
MAX = 10**18

ret = 1
for i in range(n):
	if(ret <= MAX):
		ret = ret*a[i]
	if(a[i] == 0):
		ret = 0
		break


if(ret > MAX):
	print(-1)
else:
	print(ret)
a = 0
ab = 0
abc = 0
r = 1

s = input()

for c in s:
    if c == "A":
        a += r
    elif c == "B":
        ab += a
    elif c == "C":
        abc += ab
    else:
        abc = abc * 3 + ab
        ab = ab * 3 + a
        a = a * 3 + r
        r *= 3

print(abc % 1_000_000_007)

### FIXED CODE ###

inf = 1000000007
 
a = 0
ab = 0
abc = 0
r = 1
 
s = input()
 
for c in s:
    if c == "A":
        a += r
    elif c == "B":
        ab += a
    elif c == "C":
        abc += ab
    else:
        abc = abc * 3 + ab
        ab = ab * 3 + a
        a = a * 3 + r
        r *= 3
        
    a %= inf
    ab %= inf
    abc %= inf
    r %= inf

print(abc)
A,B=maps(int,input().split())
print(max([A+B,A-B,A*B]))

### FIXED CODE ###

A,B=map(int,input().split())
print(max([A+B,A-B,A*B]))
K, S=map(int,input().split)

answer=0
for x in range(K+1):
  for y in range(K+1):
    if S-(x+y)<=K:
      answer+=1
      
print(answer)

### FIXED CODE ###

K, S=map(int,input().split())

answer=0
for x in range(K+1):
  for y in range(K+1):
    if S-(x+y)>=0 and S-(x+y)<=K:
      answer+=1
      
print(answer)
for i in range(N):
	if (A[i]*4*M) >= vote_sum:
		cnt += 1
	if cnt == M:
		print(y)
		break
		
if C < M:
	print(n)

### FIXED CODE ###

from collections import deque
K = int(input())

q = deque([i for i in range(1, 10)])

for i in range(K):
    x = q.popleft()
    amari = x%10
    if amari == 0:
        l, m = 10*x, 10*x+1
        q.append(l)
        q.append(m)
    elif amari == 1:
        l, m, r = x*10, x*10+1, x*10+2
        q.append(l)
        q.append(m)
        q.append(r)
    elif amari == 9:
        l, m = 10*x+8, 10*x+9
        q.append(l)
        q.append(m)
    else:
        l, m, r = 10*x+(amari-1), 10*x+(amari), 10*x+(amari+1)
        q.append(l)
        q.append(m)
        q.append(r)

print(x)
S = input()
T = input()

t_len = len(T)
found = False
for i in range(len(S)-len(T), -1,-1):
    for j in range(len(T)):
        if S[i+j] != T[j] and S[i+j] != '?':
            break
    else:
        if i + t_len == len(S):
            S = S[:i] + T
        else:
            S = S[:i] + T + S[i+tlen:]
        found = True
    if found:
        print(S.replace('?','a'))
        break
else:
    print('UNRESTORABLE')



### FIXED CODE ###

S = input()
T = input()

t_len = len(T)
found = False
for i in range(len(S)-len(T), -1,-1):
    for j in range(len(T)):
        if S[i+j] != T[j] and S[i+j] != '?':
            break
    else:
        if i + t_len == len(S):
            S = S[:i] + T
        else:
            S = S[:i] + T + S[i+t_len:]
        found = True
    if found:
        print(S.replace('?','a'))
        break
else:
    print('UNRESTORABLE')
a,b,c=(int(i) for i in input().split())
for i in range(0,9):
  c=a*c-b
  int(c)
  print(c)


### FIXED CODE ###

a,b=(int(i) for i in input().split())
if a<=5:
  print(0)
elif 5<a<=12:
  print(b//2)
else:
  print(b)
N=int(input())
N_mozi="N"
for i in range N_mozi:
  if i<len(N_mozi)+1:
    continue
  else:
    end_N=i
if end_N==2 or end_N==4 or end_N==5 or end_N==7 or end_N==9:
  print("hon")
elif end_N==3:
  print("bon")
else:
  print("pon")

### FIXED CODE ###

N=int(input())
if N%10==3:
  print("bon")
elif N%10==0 or N%10==1 or N%10==6 or N%10==8:
  print("pon")
else:
  print("hon")
A, B = map(int, input().split())
if A > 8 or B >  :
  print(':(')
else :
  print('Yay!')


### FIXED CODE ###

A, B = map(int, input().split())
if A > 8 or B > 8 :
  print(':(')
else :
  print('Yay!')
x = input(int())
print x**3

### FIXED CODE ###

x = int(input())
print(x**3)
c = [0]*10**5
for i in open(0).read().split()[2::]: c[int(i)] ^= 1
print("NO" if any(c) else "YES")

### FIXED CODE ###

c = [0]*10**5
for i in open(0).read().split()[2:]: c[int(i)-1] ^= 1
print("NO" if any(c) else "YES")
a,b=input(int,input().split())
if(a*b%2==0):
  print('No')
else:
  print('Yes')

### FIXED CODE ###

a,b=map(int,input().split())
if(a*b%2==0):
  print('No')
else:
  print('Yes')
a=input()
b=int(a)
c=list(a)
if b%(sum(c))==0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a=input()
b=int(a)
c=list(a)
c=[int(i) for i in c]
if b%(sum(c))==0:
  print('Yes')
else:
  print('No')
n = int(input())
peaple = []
for i in range(n):
  a = int(input())
  tests = []
  for j in range(a):
    x, y = input().split()
    tests.append((int(x) - 1, y))
  peaple.append(tests)
  
maximum = 0
for h_bit in range(1, 1<<n):
  h_str = format(h_bit, '0{}b'.format(n))
  flag = False
  for i in range(n):
    if h_str[i] == '1':
      for tests in peaple[i]:
        for test in tests:
          if h_str[test[0]] != test[1]:
            flag = True
            break
        if flag:
          break
    if flag:
      break
  if not flag:
    maximum = max(maximum, h_str.count('1'))
print(maximum)

### FIXED CODE ###

n = int(input())
peaple = []
for i in range(n):
  a = int(input())
  tests = []
  for j in range(a):
    x, y = input().split()
    tests.append((int(x) - 1, y))
  peaple.append(tests)
  
maximum = 0
for h_bit in range(1, 1<<n):
  h_str = format(h_bit, '0{}b'.format(n))
  flag = False
  for i in range(n):
    if h_str[i] == '1':
      for test in peaple[i]:
        if h_str[test[0]] != test[1]:
          flag = True
          break
    if flag:
      break
  if not flag:
    maximum = max(maximum, h_str.count('1'))
print(maximum)
n = int(input())
del = list(map(int, input().split()))
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += del[i] * del[k]
  i += 1
  
print(str(sum))



### FIXED CODE ###

n = int(input())
deliciousness = list(map(int, input().split()))
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += deliciousness[i] * deliciousness[k]
  i += 1
  
print(sum)
from __future__ import print_function
import numpy as np
import sys
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy,functools
import heapq
from heapq import heappush
from heapq import heappop
import random


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

n,m = map(int, input().split())
p=np.zeros(n+1,dtype=int)
y=np.zeros(m+1,dtype=int)
for i in range(1,m+1):
    p[i],y[i] = map(int, input().split())


l_pref=[[] for _ in range(n+1)]    # 県の数(==n)だけ空リストを用意
for i in range(1,m+1):
    heappush(l_pref[p[i]],(y[i],i))



for i in range(1,m+1):
    temp =  l_pref[p[i]].index((y[i],i))  + 1
    print("0"*(6-len(str(p[i])))  +  str(p[i])  +  "0"*(6-len(str(temp))) + str(temp) )


### FIXED CODE ###

from __future__ import print_function
# import numpy as np
import sys
import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy,functools
import heapq
from heapq import heappush
from heapq import heappop
import random


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

n,m = map(int, input().split())
p=[i for i in range(m+1)]
y=[i for i in range(m+1)]
for i in range(1,m+1):
    p[i],y[i] = map(int, input().split())


l_pref=[[] for _ in range(n+1)]    # 県の数(==n)だけ空リストを用意
for i in range(1,m+1):
    l_pref[p[i]].append((y[i],i))
for i in range(1,n+1):
    l_pref[i].sort()

# eprint(l_pref)


lll = [(1,1) for i in range(m+1)]
for i in range(1,n+1):
    for j in range(len(l_pref[i])):
        lll[l_pref[i][j][1]] = j+1
# eprint(lll)

for i in range(1,m+1):
    # temp =  l_pref[p[i]].index((y[i],i))  + 1
    print("0"*(6-len(str(p[i])))  +  str(p[i])  +  "0"*(6-len(str(lll[i]))) + str(lll[i]) )
import sys
sys.setrecursionlimit(3000)

n=int(input())
m=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int, input().split())
    m[a-1].append([b-1,c])
    m[b-1].append([a-1,c])
q,k=map(int, input().split())
    
def reach(m,d,k):
    for i in m[k]:
        if d[i[0]]==-1:
            d[i[0]]=d[k]+i[1]
            reach(m,d,i[0])
d=[-1]*n
d[k-1]=0
reach(m,d,k-1)

for i in range(q):
    x,y=map(int, input().split())
    print(d[x-1]+d[y-1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

n=int(input())
m=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int, input().split())
    m[a-1].append([b-1,c])
    m[b-1].append([a-1,c])
q,k=map(int, input().split())
    
def reach(m,d,k):
    for i in m[k]:
        if d[i[0]]==-1:
            d[i[0]]=d[k]+i[1]
            reach(m,d,i[0])
d=[-1]*n
d[k-1]=0
reach(m,d,k-1)

for i in range(q):
    x,y=map(int, input().split())
    print(d[x-1]+d[y-1])
import heapq
from sys import stdin

N,K = map(int,input().split())

sushi = {}

for i in range(N):
    t,d = map(int, stdin.readline().split())
    if t in sushi.keys():
        sushi[t].append(d)
    else:
        sushi[t] = [d]

P = []
Q = []

for x in sushi.keys():
    sushi[x].sort(reverse = True)
    P.append(sushi[x][0])
    
    for i in range(1,len(sushi[x])):
        Q.append(sushi[x][i])

heapq.heapify(P)

Q = list(map(lambda x:-x,Q))
heapq.heapify(Q)

while len(P) > K:
    m = heapq.heappop(P)
    heapq.heappush(Q,-m)

cur = sum(P)
ans = cur + K**2

for i in range(max(K,len(sushi.keys()))-1):
    p = heapq.heappop(P)
    cur -= p
    q = -heapq.heappushpop(Q,-p)
    cur += q
    ans = max(ans,cur+(K-i-1)**2)

print(ans)

### FIXED CODE ###

import heapq
from sys import stdin

N,K = map(int,input().split())

sushi = {}

for i in range(N):
    t,d = map(int, stdin.readline().split())
    if t in sushi.keys():
        sushi[t].append(d)
    else:
        sushi[t] = [d]

P = []
Q = []

for x in sushi.keys():
    sushi[x].sort(reverse = True)
    P.append(sushi[x][0])
    
    for i in range(1,len(sushi[x])):
        Q.append(sushi[x][i])

heapq.heapify(P)

Q = list(map(lambda x:-x,Q))
heapq.heapify(Q)

while len(P) > K:
    m = heapq.heappop(P)
    heapq.heappush(Q,-m)

cur = 0

if K <= len(sushi.keys()):
    max_variation = K
else:
    max_variation = len(sushi.keys())
    for _ in range(K-max_variation):
        cur -= heapq.heappop(Q)

cur += sum(P)
ans = cur + max_variation**2

for i in range(max_variation-1):
    p = heapq.heappop(P)
    cur -= p
    q = -heapq.heappushpop(Q,-p)
    cur += q
    ans = max(ans,cur+(max_variation-i-1)**2)

print(ans)
a = input().split()
  2 b = a[0]
  3 c = a[1]
  4 if b == c:
  5     print("yes")
  6 else:
  7     print("no")

### FIXED CODE ###

n = 0
m = 0
ac = input()
n = ac.split()[0]
m = ac.split()[1]

if n == m:
    print("Yes")
else:
    print("No")
a,b =map(int,input(),split())
ss = a*b
print(ss-10)

### FIXED CODE ###

a,b =map(int,input().split())
ss = a*b
hf =ss//2
if a>1 and b>1:
	print(ss-hf)
else:
  print(1)
print((a * b)* 2))

### FIXED CODE ###

a,b=[int(x) for x in input().split()]
print(a*b,(a+b)*2)
while 1:
  k=input()
  if not k:stop
  print sum(map(int, raw_input().split()))/(k-1)

### FIXED CODE ###

while 1:
  k=input()-1
  if k==-1:break
  print sum(map(int, raw_input().split()))/k
a,b=map(int,input.split())
print(a+1-b)

### FIXED CODE ###

N,i=map(int,input().split())
print(N+1-i)
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
INF = N**3
max_ab = max(max(A),max(B))+1
dp = [[INF] * max_ab for _ in range(2**N)]
dp[0][0]=0
for i in range(2**N):
  done = 0
  for j in range(N):
    if (i>>j)&1:
      done += 1
  
  for right_end in range(max_ab):
    if dp[i][right_end]==INF:
      continue
    for add_last in range(N):
      if (i>>add_last)&1:
        continue
      if abs(add_last-done)%2==0:
        add_last_surface = A[add_last]
      else:
        add_last_surface = B[add_last]
        
      if right_end>add_last_surface:
        continue
        
      num = 0
      for k in range(add_last):
        if (i>>k)&1==0:
          num+=1
          
      dp[i|1<<add_last][add_last_surface]=min(dp[i|1<<add_last][add_last_surface],
                                              dp[i][right_end]+num)
      
ans = min(dp[-1])
if ans==INF:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

H = int(input())
W = int(input())
N = int(input())
import math
x = max(H,W)
print(math.ceil(N/x))
import math
A, B = map(int, input().split())
ans = A * B / math.gcd(A, B)
print(int(ans))

### FIXED CODE ###

import fractions
A, B = map(int, input().split())
ans = A * B // fractions.gcd(A, B)
print(ans)