Harryxun/stf_run huggingface dataset:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())

val = 0
flag = False

for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = 0

val = 0
for i in range(3):
    val += A[i]
if val == 0:
    flag = True

val = A[0][2] + A[1][1] + A[2][0]
if val == 0:
    flag = True

for i in range(3):
    if sum(A[i]) == 0:
        flag = True
    
    val = 0
    for j in range(3):
        val += A[j][i]
    if val == 0:
        flag = True

if flag == True:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

A = [list(map(int, input().split())) for i in range(3)]
N = int(input())

val = 0
flag = False

for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = 0

val = 0
for i in range(3):
    val += A[i][i]
if val == 0:
    flag = True

val = A[0][2] + A[1][1] + A[2][0]
if val == 0:
    flag = True

for i in range(3):
    if sum(A[i]) == 0:
        flag = True
    
    val = 0
    for j in range(3):
        val += A[j][i]
    if val == 0:
        flag = True

if flag == True:
    print('Yes')
else:
    print('No')
# N: 処理する区間の長さ
N, Q = map(int, input().split())
INF = 2**31

N-=1
LV = (N-1).bit_length()
N0 = 2**LV
data1 = [INF]*(2*N0)
data2 = [INF]*(2*N0)
lazy1 = [None]*(2*N0)
lazy2 = [None]*(2*N0)

# 伝搬対象の区間を求める
def gindex(l, r):
    L = (l + N0) >> 1; R = (r + N0) >> 1
    lc = 0 if l & 1 else (L & -L).bit_length()
    rc = 0 if r & 1 else (R & -R).bit_length()
    for i in range(LV):
        if rc <= i:
            yield R
        if L < R and lc <= i:
            yield L
        L >>= 1; R >>= 1

# 遅延伝搬処理
def propagates(data,lazy,*ids):
    for i in reversed(ids):
        v = lazy[i-1]
        if v is None:
            continue
        lazy[2*i-1] = data[2*i-1] = lazy[2*i] = data[2*i] = v
        lazy[i-1] = None

# 区間[l, r)をxで更新
def update(l, r, x, data,lazy):
    *ids, = gindex(l, r)
    propagates(data,lazy,*ids)

    L = N0 + l; R = N0 + r
    while L < R:
        if R & 1:
            R -= 1
            lazy[R-1] = data[R-1] = x
        if L & 1:
            lazy[L-1] = data[L-1] = x
            L += 1
        L >>= 1; R >>= 1
    for i in ids:
        data[i-1] = min(data[2*i-1], data[2*i])


ans = (N-2)*(N-2)
update(1,N-1,N-2,data1,lazy1)
update(1,N-1,N-2,data2,lazy2)
for i in range(Q):
  t,x = map(int, input().split())
  if t==1:
    ans -= data1[x-1]
    update(1,data1[x-1],x,data2,lazy2)
  else:
    ans -= data2[x-1]
    update(1,data2[x-1],x,data1,lazy1)
print(ans)


### FIXED CODE ###

# N: 処理する区間の長さ 0_indexed
class SegmentTree:
  def __init__(self,N):
    self.N0 = 2**(N-1).bit_length()
    self.data = [None]*(2*self.N0)
    self.INF = (-1, 2**31-1)
  # 区間[l, r+1)の値をvに書き換える
  # vは(t, value)という値にする (新しい値ほどtは大きくなる)
  def update(self, l, r, v):
    L = l + self.N0; R = r + self.N0
    while L < R:
      if R & 1:
        R -= 1
        self.data[R-1] = v
      if L & 1:
        self.data[L-1] = v
        L += 1
      L >>= 1; R >>= 1
  # a_iの現在の値を取得
  def _query(self, k):
    k += self.N0-1
    s = self.INF
    while k >= 0:
      if self.data[k]:
        s = max(s, self.data[k])
      k = (k - 1) // 2
    return s
  # これを呼び出す
  def query(self,k):
    return self._query(k)[1]

N, Q = map(int, input().split())
row = SegmentTree(N-2)
col = SegmentTree(N-2)
ans = (N-2)*(N-2)
row.update(0,N-2,(0,N-2))
col.update(0,N-2,(0,N-2))
min_row = N
min_col = N
for i in range(1,Q+1):
  t,x = map(int, input().split())
  if t==1:
    num = col.query(x-2)
    ans -= num
    if x<min_col:
      row.update(0,num,(i,x-2))
      min_col = x
  else:
    num = row.query(x-2)
    ans -= num
    if x<min_row:
      col.update(0,num,(i,x-2))
      min_row = x
print(ans)
x=list(input())
import re
p=r'\d'

while True:
    s=str(input())
    if not re.match(p,s):
        print(a+b)
        print('')
        x = list(input())
    elif s=="-":
        print(a+b)
        break
    else:
        a, b = x[:len(x) - int(s)], x[-int(s):]

### FIXED CODE ###


while True:
    z = list(map(str, input()))
    if "-" in z:
        break
    n = int(input())
    for i in range(n):
        a=int(input())
        z=z[a:]+z[:a]
    print("".join(z))
n = int(input())
m = int(input())

if n == m:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

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

if N == M:
  print("Yes")
else:
  print("No")
N, K = input().split()
h = list(map(int, input().split()))

count = 0
for i in h:
    if i >= K:
        count += 1
print(count)

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
count = [i for i in h if i >= K]
print(len(count))
import math

def lcm(a, b):
	return a * b // math.gcd(a, b)

n = int(input())
t = [int(input()) for i in range(n)]

t += [1, 1]
a = t.pop()
while t:
	b = t.pop()
	a = lcm(a, b)
print(a)

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd(a, b)

n = int(input())
t = [int(input()) for i in range(n)]

ans = t[0]
for t_i in t[1:]:
	ans = lcm(ans, t_i)

print(ans)
from math import gcd
MOD = 10 ** 9 + 7
N = int(input())
d = dict()
for _ in range(N):
    a, b = tuple(map(int, input().split()))
    g = gcd(a, b) * (a // abs(a))
    p = a // g, b // g
    d[p] = d.get(p, 0) + 1
counts = dict()
for k, v in d.items():
    a, b = k
    if counts.get((b, -a), False) or counts.get((-b, a), False):
        continue
    counts[k] = v, d.get((b, -a), 0) + d.get((-b, a), 0)
total = 1
for a, b in counts.values():
    total = (total * (pow(2, a, MOD) + pow(2, b, MOD) - 1)) % MOD
print((total + MOD - 1) % MOD)

### FIXED CODE ###

from math import gcd
MOD = 10 ** 9 + 7
N = int(input())
d = dict()
zeros = 0
a_zeros = 0
b_zeros = 0
for _ in range(N):
    a, b = tuple(map(int, input().split()))
    if not any((a, b)):
        zeros += 1
        continue
    if not a:
        a_zeros += 1
        continue
    if not b:
        b_zeros += 1
        continue
    g = gcd(a, b) * (a // abs(a))
    p = a // g, b // g
    d[p] = d.get(p, 0) + 1
counts = dict()
for k, v in d.items():
    a, b = k
    if counts.get((b, -a), False) or counts.get((-b, a), False):
        continue
    counts[k] = v, d.get((b, -a), 0) + d.get((-b, a), 0)
total = 1
for k, v in counts.items():
    a, b = v
    total = (total * (pow(2, a, MOD) + pow(2, b, MOD) - 1)) % MOD
total = (total * (pow(2, a_zeros, MOD) + pow(2, b_zeros, MOD) - 1)) % MOD
print((total + zeros + MOD - 1) % MOD)
import sys
d = 'ABC'
N, *v = map(int, input().split())
e = [tuple(map(d.index, input())) for _ in range(N)]
p = []
def f(i):
	if i == len(e):
		print('Yes')
		print('\n'.join(p))
		raise SystemExit
	k, j = e[i]
	for a, s in ((k, j), (j, k)):
		if v[s] == 0: continue
		v[a] += 1
		v[s] -= 1
		p.append(d[a])
		f(i+1)
		v[a] -= 1
		v[s] += 1
		p.pop()
f(0)
print('No')

### FIXED CODE ###

import sys
sys.setrecursionlimit(1<<30)
d = 'ABC'
N, *v = map(int, input().split())
e = [tuple(map(d.index, input())) for _ in range(N)]
p = []
def f(i):
	if i == len(e):
		print('Yes')
		print('\n'.join(p))
		raise SystemExit
	k, j = e[i]
	for a, s in ((k, j), (j, k)):
		if v[s] == 0: continue
		v[a] += 1
		v[s] -= 1
		p.append(d[a])
		f(i+1)
		v[a] -= 1
		v[s] += 1
		p.pop()
f(0)
print('No')
import math 
A, B, C, D = map(int, input().split())
a = B - A + 1
b = (B//C) - ((A-1)//C)
c = (B//D) - ((A-1)//D)
d = C*D//math.gcd(C,D)
dd = (B//d) - ((A-1)//d)
print(a-b-c+dd)


### FIXED CODE ###

import fractions
A, B, C, D = map(int, input().split())
a = B - A + 1
b = (B//C) - ((A-1)//C)
c = (B//D) - ((A-1)//D)
d = C*D//fractions.gcd(C,D)
dd = (B//d) - ((A-1)//d)
print(a-b-c+dd)
import math

n = input()
maxv = -1 * 10**9
minv = input()

for i in range(1:n-1):
  v = input()
  maxv = max(maxv, v-minv)
  minv = min(v, minv)

print '{0}'.format(maxv)

### FIXED CODE ###

n = input()
minv = input()
maxv = -1 * 10**9

for j in range(n-1):
  v = input()
  if maxv < v - minv:
    maxv = v - minv
  if minv > v:
    minv = v

print maxv
H, W = map(int, input().split(" "))

result = True
masu = [[0 for i in range(H+2)] for j in range(W+2)]
for h in range(1, H+1):
    s = "0"+input()+"0"
    masu[h] = list(s)

# print(masu)    

for h in range(1, H+1):
    for w in range(1, W+1):
        # print(h, w, masu[h][w])
        if masu[h][w] == "#":
            if (masu[h][w] == masu[h+1][w]) or (masu[h][w] == masu[h][w+1]) or (masu[h][w] == masu[h-1][w]) or (masu[h][w] == masu[h][w-1]):
                pass
            else:
                result = False

if result:
    print("Yes")
else:
    print("No")

### FIXED CODE ###


H, W = map(int, input().split(" "))

# result = True
masu = [['.' for i in range(W+2)] for j in range(H+2)]
for h in range(H):
    s = "."+input()+"."
    masu[h+1] = s

# print(masu)

for h in range(1,H+1):
    for w in range(1,W+1):
        if masu[h][w] == "#":
            if "#" == masu[h+1][w] or "#" == masu[h][w+1] or "#" == masu[h-1][w] or "#" == masu[h][w-1]:
                pass
            else:
                # result = False
                print("No")
                exit()

print("Yes")
n = int(input())
t = [int(input()) for _ in range(n)]

def gcd(x,y):
  if x % y == 0:
    return y
  return gcd(y, x % y)

for i in range(n):
  for j in range(i+1, n):
    if t[i] == 1:
      break
    t[i] //= gcd(t[i], t[j])

ans = 1
[ans *= x for x in t]
print(ans)

### FIXED CODE ###

n = int(input())
t = [int(input()) for _ in range(n)]


def gcd(x,y):
  if y == 0:
    return x
  return gcd(y, x % y)


ans = t[0]
for x in t[1:]:
  ans = ans * x // gcd(ans, x)
print(ans)
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
if A < B and V <= W:
  print("NO")
elif B < A and W <= V:
  print("NO")
else:
  if A+V*i >= 0:
    if A+V*i >= B+W*i:
      print("YES")
    else:
      print("NO")
  elif A+V*i < 0:
    if abs(A+V*i) <= abs(B+W*i):
      print("YES")
    else:
      print("NO")

### FIXED CODE ###

A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

dist = abs(B-A)
r_vel = V - W

if r_vel * T >=dist:
  print("YES")
 
else:
  print("NO")
A, B = map(int, input().split())
if A <= 5:
  print(0)
elif 6 <= A <= 12:
  print(B // 2)
else:
  print(B

### FIXED CODE ###

A, B = map(int, open(0).read().split())
if A <= 5:
    print(0)
elif 6 <= A <= 12:
    print(B // 2)
else:
    print(B)
import math
import sys
x = input()
N,A,B,K = list(map(int,x.split()))
g = math.gcd(A,B)
if K % g != 0:
    print(0)
    sys.exit()
A = A // g
B = B // g
K = K // g
xn = []
yn = []
for i in range(10 ** 100):
    if (A * i- K) % B == 0:
        n = i
        xn.append(n)
        yn.append((K - A *n) // B)
        break
if yn[-1] < 0:
    if K % B == 0 and (K // B <= N):
        print(1)
    else:
        print(0)
    sys.exit()
while True:
    x  = xn[-1] + B
    y  = yn[-1] - A
    if y < 0:
        break
    xn.append(x)
    yn.append(y)
ans = 0
P = 998244353
def inv(n):
  return pow(n, P-2, P)
fact = [1] * (N+1)
for i in range(1, N+1):
  fact[i] = fact[i-1] * i % P
invfact = [inv(fact[N])] * (N+1)
for i in range(N, 0, -1):
  invfact[i-1] = invfact[i] * i % P
def comb(n, k):
  return fact[n] * invfact[k] * invfact[n-k] % P 

for x,y in zip(xn,yn):
    if N-x< 0 or N -y < 0:
        continue 
    ans = (ans + (comb(N,x) * comb(N,y)) % P)
print(ans)


### FIXED CODE ###

import math
import sys
import fractions
inp = input()
N,A,B,K = list(map(int,inp.split()))
# g = math.gcd(A,B)
g = fractions.gcd(A,B)
if K % g != 0:
    print(0)
    sys.exit()
A = A // g
B = B // g
K = K // g
xn = []
yn = []
for i in range(10 ** 100):
    if (A * i- K) % B == 0:
        n = i
        xn.append(n)
        yn.append((K - A *n) // B)
        break
if yn[-1] < 0:
    if K % B == 0 and (K // B <= N):
        print(1)
    else:
        print(0)
    sys.exit()
while True:
    x  = xn[-1] + B
    y  = yn[-1] - A
    if y < 0:
        break
    xn.append(x)
    yn.append(y)
ans = 0
P = 998244353
def inv(n):
  return pow(n, P-2, P)
fact = [1] * (N+1)
for i in range(1, N+1):
  fact[i] = fact[i-1] * i % P
invfact = [inv(fact[N])] * (N+1)
for i in range(N, 0, -1):
  invfact[i-1] = invfact[i] * i % P
def comb(n, k):
  return fact[n] * invfact[k] * invfact[n-k] % P 
 
for x,y in zip(xn,yn):
    if N-x< 0 or N -y < 0:
        continue 
    ans = (ans + (comb(N,x) * comb(N,y))) % P
print(ans)
n = input().split()

n = [int(n[0]), int(n[1])]
H = n[0]
W=n[1]

s = [list(map(str, input().split())) for i in range(H)]
print(s[0][0][1])
c = True
for i in range(H):
    for j in range(W):
        if(s[i][0][j] == '#'):
            if(i == 0):
                if(j == 0):
                    if(s[i + 1][0][j] == '.' and s[i][0][j + 1] == '.'):
                        c = False
                        break
                elif(j == W - 1):
                    if(s[i+1][0][j ] == '.' and s[i][0][j-1] == '.'):
                        c = False
                        break
                else:
                     if(s[i + 1][0][j] == '.' and s[i][0][j + 1] == '.' and s[i][0][j-1] == '.'):
                        c = False
                        break
            elif(i == H - 1):
                if(j == 0):
                    if(s[i - 1][0][j] == '.' and s[i][0][j +1] == '.'):
                        c = False
                        break
                elif(j == W - 1):
                    if(s[i-1][0][j] == '.' and s[i][0][j-1] == '.'):
                        c = False
                        break
                else:
                     if(s[i - 1][0][j] == '.' and s[i][0][j + 1] == '.' and s[i][0][j-1] == '.'):
                        c = False
                        break
            else:
                if(j == 0):
                    if(s[i - 1][0][j] == '.' and s[i][0][j +1] == '.' and s[i + 1][0][j] == '.'):
                        c = False
                        break
                elif(j == W - 1):
                    if(s[i-1][0][j] == '.' and s[i][0][j-1] == '.' and s[i + 1][0][j] == '.'):
                        c = False
                        break
                else:
                     if(s[i - 1][0][j] == '.' and s[i][0][j + 1] == '.' and s[i][0][j-1] == '.' and s[i + 1][0][j] == '.'):
                        c = False
                        break
                
    
if(c):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = [list(map(int, input().split())) for i in range(1)]
a = n[0][0]
b = n[0][1]

c = 0
if(a > b):
    c = a - 1
else:
    c = a
    
print(c)
from collections import Counter
input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

MOD = 998244353
N= int(input())
D = inpl()
C = Counter(D)

if (D[0] != 0) or (C[0] != 1):
    print(0)
else:
    M = max(C.keys())
    ans = 1
    for i in range(M):
        ans = ans * pow(C[i], C[i+1], MOD) % MOD
    print(ans)

### FIXED CODE ###

from collections import Counter
import sys
input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

MOD = 998244353
N= int(input())
D = inpl()
C = Counter(D)

if (D[0] != 0) or (C[0] != 1):
    print(0)
else:
    M = max(C.keys())
    ans = 1
    for i in range(M):
        ans = ans * pow(C[i], C[i+1], MOD) % MOD
    print(ans)
x, y, z = map(int, input().split())
print(f"{z} {x} {y}")

### FIXED CODE ###

x, y, z = map(int, input().split())
print('{} {} {}'.format(z, x, y))
n = input()
ifn%9 == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n = int(input())
if n%9 == 0:
  print('Yes')
else:
  print('No')
A,B,C=map(str,input().split())
ans=eval(A B C)
print(ans)

### FIXED CODE ###

print(eval(input()))
a,b,c,d,e,k=[int(input()) for _ in range(5)]
if e-a<=k:
    print('Yay!')
else:
    print(':(')

### FIXED CODE ###

a,b,c,d,e,k=[int(input()) for _ in range(6)]
if e-a<=k:
    print('Yay!')
else:
    print(':(')
#A = input('Aを入力してください')
#B = input('Bを入力してください')
#K = input('Cを入力してください')
#print('A= ', A)
#print('B= ', B)
#print('K= ', K)

#A = 1
#B = 10
#K = 6

S = input()
S = S.split(' ')

for i in range(len(S)):
    print(S[i])

A = S[0]
B = S[1]
K = S[2]

ANS = []

for i in range(K + 1):
    ANS.append(A + i)


for j in range(K + 1):
    if B - j not in ANS:
        ANS.append(B - j)

ANS.sort()

#print(ANS)

for i in range(len(ANS)):
    print(ANS[i])


### FIXED CODE ###

import sys

#A = input('Aを入力してください')
#B = input('Bを入力してください')
#K = input('Cを入力してください')
#print('A= ', A)
#print('B= ', B)
#print('K= ', K)

#A = 1
#B = 10
#K = 6

#S = input('ABKを入力してください')
S = input()
S = S.split(' ')

#for i in range(len(S)):
#    print(S[i])

#sys.exit()

A = int(S[0])
B = int(S[1])
K = int(S[2])

ANS = []
for i in range(K):
    if A + i <= B:
        ANS.append(A + i)


for j in range(K):
    if B - j not in ANS and B - j >= A:
        ANS.append(B - j)

ANS.sort()

#print(ANS)

for i in range(len(ANS)):
    print(ANS[i])
from collections import Counter
n = int(input().strip())
a = list(map(int, input().strip().split()))
cnt1 = Counter(a[::2]).most_common(2)
c11, c12 = (cnt1 if len(cnt1) == 2 else cnt1+[('', 0)])
cnt2 = Counter(a[1::2]).most_common(2)
c21, c22 = (cnt2 if len(cnt2) == 2 else cnt2+[('', 0)])

if c11[0] != c21[0]:
    print(n - c11[1] - c21[1])
else:
    print(n - max(c11[1]+c22[1], c12[1]+c21[1]))

### FIXED CODE ###

s = input()
for c in s:
  if c == '1': print('9', end='')
  elif c == '9': print('1', end='')

print()
a,b = input().split()
if b<a:
    print(a)
else:
    print(a-1)

### FIXED CODE ###

a,b = map(int,input().split())
if b<a:
    print(a-1)
else:
    print(a)
import math
n, m = map(int, input().split())
res = 1
max_res = m//n
for i in range(2, math.ceil(math.sqrt(m)) + 1):
  if m % i == 0:
     if i <= max_res:
        res = max(res, i)
     x = m//i
     if x <= max_res:
        res = max(res, x)
print(res)

### FIXED CODE ###

n = int(input())
if n == 1:
  print('Hello World\n')
else:
  a = int(input())
  b = int(input())
  print(a + b)
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort()
red = p[-x:]
green = q[-y:]
ri, gi = 0, 0
for blank in r:
  if (red[ri]>green[gi] and gi<y) or (ri>=x and gi<y):
    if blank>green[gi]:
      green[gi] = blank
      gi += 1
  elif ri<x:
    if blank>red[ri]:
      red[ri] = blank
      ri += 1
print(sum(red)+sum(green))

### FIXED CODE ###

x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort()
top_red = p[-x:]
top_green = q[-y:]
final = top_red+top_green+r
final.sort()
print(sum(final[-(x+y):]))
print(len(set([input().split()])))


### FIXED CODE ###

print(len(set(list(input().split()))))
import sys, os

if __name__ == '__main__':
    N = input()
    s = 0
    for i in range(1, N+1):
        if i % 3 ==0 or i % 5 ==0:
            continue
        else:
            s += i
    print(s)

### FIXED CODE ###

import sys, os

if __name__ == '__main__':
    N = int(input())
    s = 0
    for i in range(1, N+1):
        if i % 3 ==0 or i % 5 ==0:
            continue
        else:
            s += i
    print(s)
g


### FIXED CODE ###

a,b=map(int,input().split())
if a+b>=10:
  ans='error'
else:
  ans=a+b
print(ans)
#coding: UTF-8

s = input()
h = s/3600
s = s%3600
m = s/60
s = s%60

print str(h) + ":" + str(m) + ":" + str(s)

### FIXED CODE ###

S = int(input())
print(S // 3600, S % 3600 // 60, S % 60, sep=':')
from bisect import bisect_left as bl
n=int(input())
a=list(map(int,input().split()))
t=[[]for i in range(n)]
for i in range(n-1):
    u,v=map(int,input().split())
    t[u-1].append(v-1)
    t[v-1].append(u-1)
b=[1]+[0]*(n-1)
q=[[0,[a[0]],1]]
while q:
    c,d,e=q.pop(0)
    for i in t[c]:
        s=d[::]
        g=e
        if b[i]==0:
            h=bl(d,a[i])
            if e>h:
                s[h]=a[i]
            else:
                s.append(a[i])
                g+=1
            b[i]=g
            q.append([i,s,g])
for i in range(n):
    print(b[i])


### FIXED CODE ###

k=int(input())
a,b=map(int,input().split())
print("OK" if (a-1)//k!=b//k else"NG")
A, B, K = map(int, input().split())

count = 0
cand = []
denom = 0

for i in range(1, min(A, B)):
    denom += 1
    if A % denom == 0 and B % denom == 0:
        cand.append(denom)

print(cand[-K])

### FIXED CODE ###

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

count = 0
cand = []
denom = 0

for i in range(1, min(A, B)+1):
    denom += 1
    if A % denom == 0 and B % denom == 0:
        cand.append(denom)

print(cand[-K])
import numpy as np
def f(b, n):
    s = 0
    while n > 0:
        s += n % b
        n //= b
    return s

INF = int("inf")
def solve(n, s):
    if n < s:
        return -1
    if n == s:
        return n+1
    m = int(np.sqrt(n)) + 1
    for b in range(2, m+1):
        if f(b, n) == s:
            return b
    best = INF
    for p in range(1, m+1):
        q = s - p
        if (n - q) % p != 0:
            continue
        b = (n - q) // p
        if (b > 1) and (f(b, n) == s):
            best = min(best, s)
    return -1 if (best == INF) else best

n = int(input())
s = int(input())
print(solve(n, s))

### FIXED CODE ###

import numpy as np
def f(b, n):
    s = 0
    while n > 0:
        s += n % b
        n //= b
    return s

INF = 10**15
def solve(n, s):
    if n == s:
        return n+1
    m = int(np.sqrt(n)) + 1
    for b in range(2, m+1):
        if f(b, n) == s:
            return b
    best = INF
    for p in range(1, m+10):
        q = s - p
        b = (n - q) // p
        if (b > p) and (b > q) and (f(b, n) == s):
            best = min(best, b)
    return -1 if (best == INF) else best

n = int(input())
s = int(input())
print(solve(n, s))
#!/mnt/c/Users/moiki/bash/env/bin/python
N,P = list(map(int, input().split()))
import math


if P == 1:
    print(1)
    exit(0)
def get_prime(n):
    """ Returns  a list of primes < n """
    sieve = [True] * n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,n,2) if sieve[i] and  i >= int(math.sqrt(P)+1)]

primax = 1 #int(1e7) + 9 * int(1e6) + 9 * int(1e5) + 9 * int(1e4)
while primax < (P/N):
    primax *= 10

primax += 1000
primes = get_prime(primax)
# print(primes)


def df(P, p):
    if P >= p:
        cnt = 0
        while P >= p and P % p == 0:
            P = int(P//p)
            cnt += 1
        return cnt
    else:
        raise "P , p error."

gc = []
for p in primes:
    if P % p == 0:
        cnt = df(P, p)
        P = int( P // int(p**cnt))
        gc.append([p, cnt])

ans = 1
for g,cnt in gc:
    if cnt >= N:
        ans *= g**(cnt//N)

print(ans)


### FIXED CODE ###

#!/mnt/c/Users/moiki/bash/env/bin/python
N,P = list(map(int, input().split()))
import math

if N == 1:
    print(P)
    exit(0)

def get_prime(n):
    """ Returns  a list of primes < n """
    sieve = [True] * n
    for i in range(3,int(n**0.5)+1,2):
        if sieve[i]:
            sieve[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,n,2) if sieve[i]]

primax = int(1e7) + 9 * int(1e6)
primes = get_prime(primax)
# print(primes)



def df(P, p):
    if P >= p:
        cnt = 0
        while P >= p and P % p == 0:
            P = int(P//p)
            cnt += 1
        return cnt
    else:
        raise "P , p error."

gc = []
for p in primes:
    if P % p == 0:
        cnt = df(P, p)
        P = int( P // int(p**cnt))
        gc.append([p, cnt])
ans = 1
for g,cnt in gc:
    if cnt >= N:
        ans *= g**(cnt//N)

debug = 1
for g,cnt in gc:
    debug *= g**cnt

# N > 100:  why WA
# debug < P: under 3 RE
# debug*2 > P:  None
if P > 1e9 and debug != P and  debug < P and N == 1:
    raise "errror"
print(ans)