peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
from itertools import product
K = int(input())

ans = []
for l in range(10):
    for s in range(1, 10):
        for pattern in product([-1, 0, 1], repeat=l):
            X = [s]
            for p in pattern:
                if not (0 <= X[-1] + p <= 9):
                    break
                X.append(X[-1] + p)
            else:
                ans.append(''.join(map(str, X)))

ans.sort()
print(ans[K - 1])
# Judge status: Accepted
n=int(input())
points = []
for _ in range(n):
  X,L = map(int,input().split())
  points.append([X+L, X -L])
points.sort(key = lambda x: x[0])
cur = -10**9
answer = 0
for point in points:
  if point[1] >= cur:
    answer += 1
    cur = point[0]
print(answer)
# Judge status: Accepted
def main():
    a, b, c, d = map(int, input().split())
    if b * d > 0 or a * c > 0:
        x = max(b * d, a * c)
    else:
        x = max(a * d, b * c)
    print(x)
    return

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

r, g, b = MAP()

if int(str(g)+str(b))%4 == 0:
	print("YES")
else:
	print("NO")
# Judge status: Wrong Answer
s=list(str(input()))

ans=[]
for i in s:
  if i=='1':
    ans.append('1')
  elif i=='0':
    ans.insert(0,'0')
  else:
    if ans:
      ans.pop(-1)
    else:
      continue

print(''.join(ans))
# Judge status: Accepted
try:
    k = int(input())
    l = list(map(int,input().split(' ')))
    c = 0
    for i in range(len(l)-1):
      x = l[i+1]-l[i]
      if x<0:
        l[i+1]+=abs(x)
        c+=abs(x)
    print(c)
except:
    pass
# Judge status: Accepted
import sys
n,y=map(int,input().split())
for i in range(y//10000+1):
  for j in range(y//5000+1):
    k=n-(i+j)
    if k<0:
      continue
    if 10000*i+5000*j+1000*k==y:
      print(' '.join([str(i),str(j),str(k)]))
      sys.exit()
print(' '.join(['-1','-1','-1']))
# Judge status: Wrong Answer
N,M = map(int,input().split())
A = list(map(int,input().split()))

cut = int(sum(A)/(4*int(M)))

count = 0

for i in A:
    if i > cut:
        count +=1

if count >= M:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b,c,k=map(int,input().split())
if a >= k:
  print(k)
elif a+b>=k:
  print(a)
else:
  print(2*a+b-k)
# Judge status: Accepted
B=set(map(int,input().split()))
print(len(B))
# Judge status: Accepted
n, k, s = map(int, input().split())
ans = [s]*k
if s != 1: ans += [s-1]*(n-k)
else: ans += [2]*(n-k)
print(*ans)
# Judge status: Accepted
n,m = map(int, input().split())
#print(n, m)
l = []
for i in range(n):
    a = [int(_) for _ in input().split()]
    l.append(a[1:a[0]+1])
#print(l)
y = []
for j in range(1,m+1):
    x = 0
    for k in range(n):
        if j in l[k]:
            x += 1
    if x == n:
        y.append(1)
print(len(y))
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    x, y = map(int, readline().split())
    cnt = 0
    while x <= y:
        x *= 2
        cnt += 1
    print(cnt)
if __name__ == '__main__':
    main()
# Judge status: Accepted
A, B = map(int, input().split())
S = input()

print('Yes' if S.count('-')==1 and S[A] == '-' else 'No')
# Judge status: Wrong Answer
M = 10 ** 9 + 7

N, K = map(int, input().split())
A = list(map(int, input().split()))
prefix = [1] * (N + 1)
for i, a in enumerate(A, 1):
    prefix[i] = (prefix[i - 1] * a) % M

prev = prefix[K]
for i in range(K + 1, N + 1):
    cur = prefix[i] * pow(prefix[i - K], -1, M)
    if cur > prev:
        print('Yes')
    else:
        print('No')
    prev = cur
# Judge status: Accepted
import math
n=int(input())
csf=[list(map(int,input().split())) for _ in range(n-1)]

for i in range(n):
    ans=0
    for j in range(i,n-1):
        c,s,f=map(lambda x:x,csf[j])
        if ans<=s: ans=s+c
        else: ans=math.ceil(ans/f)*f+c

    print(ans)
# Judge status: Accepted
s = input()
t = input()
ans = 0
for i in range(len(s)):
    if s[i] != t[i]:
        ans += 1
print(ans)
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            tmp = i*500 + j*100 + k*50
            if tmp == X:
                cnt += 1
print(cnt)
# Judge status: Wrong Answer
S = input()
T = input()

t2 = T + T

if set(S) == set(T):
  i = t2.find(S[0])
  for j in range(1, len(S)):
    if S[j] == t2[i+1]:
      i += 1
      r = 'Yes'
    else:
      r = 'No'
      break
else:
  r = 'No'
  
print(r)
# Judge status: Wrong Answer
#=input()
x=int(input())
#=map(int,input().split())
#=map(str,input().split())
#=list(map(int,input().split()))
if x >= 30:
    print("yes")
else:
    print("no")
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
flg = 0
ans = 0
for i in range(1,n):
  if a[i] == a[i-1]:
    continue
  elif a[i] > a[i-1]:
    if flg == -1:
      ans += 1
    flg = 1
  elif a[i] < a[i-1]:
    if flg == 1:
      ans += 1
    flg = -1
print(ans+1)
# Judge status: Accepted
import numpy as np
d = int(input())
c = list(map(int, input().split()))
s = np.array([list(map(int, input().split())) for _ in range(d)])

init = s.argmax(axis=1) + 1

for i in range(d):
    print(init[i])
# Judge status: Accepted
hw = max(int(input()),int(input()))
import math
print(math.ceil(int(input())/hw))
# Judge status: Accepted
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for m in range(M)]
BC = sorted(BC,key=lambda x:x[1])[::-1]

for b,c in BC:
  A.extend(b*[c])
  if 2*N<len(A):
    break

A = sorted(A)[::-1]
print(sum(A[:N]))
# Judge status: Accepted
n, m = map(int, input().split(' '))
sc = []
for i in range(m):
    a, b = map(int, input().split(' '))
    sc.append((a, b))
d = '0' * n
for i, j in sc:
    if d[i - 1] != '0' and int(d[i - 1]) != j or n > 1 and i == 1 and j == 0:
        d = '-1'
        break
    d = d[:i - 1 if i > 1 else 0] + str(j) + d[i if i < 3 else 3:]
if d[0] == '0' and n > 1:
    d = '1' + d[1:]
print(d)
# Judge status: Accepted
A, B, C = map(int, input().split())
print('Yes' if A+B>=C else 'No')
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
ans = []
s = 0
for i in range(N):
    s = s ^ a[i]

for i in range(N):
    tmp = s ^ a[i]
    ans.append(tmp)
    
print(ans)
# Judge status: Accepted
n,x=int(input()),1000
a=n%x
print(x-a if a else 0)
# Judge status: Accepted
length = int(input())
numList = input().split()
checkSet = set()
for num in numList:
  checkSet.add(num)
if(len(checkSet) == len(numList)):
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if a-c<=b:
  print('YES')
else:
  print('No')
# Judge status: Accepted
n,k=map(int,input().split())
l=list(map(int,input().split()))
double=[[0]*(n+1) for i in range(61)]
for i in range(1,n+1):
    double[0][i]=l[i-1]
for i in range(1,61):
    for j in range(n+1):
        double[i][j]=double[i-1][double[i-1][j]]
ans=1
for i in range(61):
    if k>>i&1:
        ans=double[i][ans]
print(ans)
# Judge status: Accepted
S = input()
T = input()

iteration = len(S) - len(T) + 1

if T in S:
    ans = 0
else:
    minimum = len(T)
    for i in range(iteration):
#         print('---------------')
        s = S[i:len(T)+i]
#         print(s)
#         print(T)
        count = 0
        for j in range(len(T)):
            if s[j] != T[j]:
                count += 1
#             print(count)
        minimum = min(minimum, count)
    ans = minimum
    
print(ans)
# Judge status: Accepted
N=int(input())
if N==1:print(0)
else:print((1+(N-1))*(N-1)//2)
# Judge status: Accepted
S = int(input())
list = [S]
cnt = 2

def solve(n):
	if n % 2 == 0:
		return n // 2
	else:
		return 3 * n + 1

while True:
	n = solve(S)
	if not (n in list):
		list.append(n)
		S = n
		cnt += 1
	else:
		print(cnt)
		exit()
# Judge status: Wrong Answer
s = input()

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != 'R':
            print('No')
            exit()
    else:
        if s[i] != 'L':
            print('No')
            exit()
print('Yes')
# Judge status: Accepted
N, K = map(int, input().split())
T = sorted((tuple(map(int, input().split())) for _ in range(N)), key=lambda t: t[0])
k = 0
for t in T:
    k += t[1]
    if k >= K:
        print(t[0])
        break
# Judge status: Wrong Answer
N = int(input())
ls = []
for _ in range(N):
    x,y = map(int, input().split())
    s = x+y
    t = x-y
    d = max(s,t)
    ls.append(d)
print(max(ls) - min(ls))
# Judge status: Accepted
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

n = I()
a = [LI() for _ in range(n)]
a.sort(key = lambda x: x[1])
t = 0
for i in range(n):
    t += a[i][0]
    if t > a[i][1]:
        print('No')
        break
else:
    print('Yes')
# Judge status: Accepted
#!/usr/bin/env python

# Initially, all cards face up.
# Given that N,M >= 0.
# Let N <= M.
# Ultimately:
#   if N,M==1:      singular card will flip.
#   elif N==1:      interior cards will flip (interior to line).
#   else N,M > 1:   interior cards will flip (interior to area).

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

# Ensuring N <= M
if N > M:
    M,N = N,M

# Requires N <= M:
def numflips(N,M):
    if N==0: return 0
    if N==1:
        if M==1: return 1
        return (M-2)
    return (N-2)*(M-2)

ans = numflips(N,M)
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
for i in range(b*10, (b+1)*10):
    if int(i * 0.08) == a:
        print(i)
        break
else:
    print(-1)
# Judge status: Accepted
import numpy as np 

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

A = np.array(A,np.int64)##Ai<2^60

ans = 0
mod = int(1e9+7)

for i in range(60+1):
    bottom_bit = (A>>i)&1 ##i回シフトしたときの最下位bit
    ones = np.sum(bottom_bit[bottom_bit>0])
    ##ans += (N-ones)*ones*(2**i) ##0の個数*1の個数*2^i個
    tmp = ones*(N-ones)
    for j in range(i):
        tmp = (tmp * 2) % mod
    ans += tmp

print(ans%mod)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
print('Yes' if a<=c<=b else 'No')
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
if (B - A) % 2 == 0:
  ret = (B - A) / 2
else:
  ret = min(N - A, B - 1)
print(int(ret))
# Judge status: Accepted
from collections import defaultdict
S = input()
S = S[::-1]

rest = 0
ans = 0
memo = defaultdict(int)
memo[0] = 1
for i in range(len(S)):
    rest = (rest + int(S[i])*pow(10,i,2019)) %2019
    ans += memo[rest]
    memo[rest] += 1
print(ans)
# Judge status: Wrong Answer
def main():
    A, B, N = map(int, input().split())
    n=0
    if N < B:
        print(int(A*N/B))
    else:
        for i in range(B,N+1):
            if n < int(A*i/B) - A*int(i/B):
                n = int(A*i/B) - A*int(i/B)
        print(n)
        
main()
# Judge status: Wrong Answer
# C - Sum of product of pairs
import numpy as np

N = int(input())
A = list(int(a) for a in input().split())
MOD = 10**9 + 7
A = np.array(A)
csA = np.zeros((N+1), np.object)
for i in range(N):
    csA[i+1] = csA[i] + A[i]
    
ans = 0
for i in range(N-1):
    ans += (A[i] * (csA[N] - csA[i+1])) % MOD
print(ans%MOD)
# Judge status: Wrong Answer
hoge = {}
for i in range(100):
    hoge[i] = i**5
for i in range(100):
    hoge[-i] = -i**5
x = int(input())
for i in hoge.items():
    for j in hoge.items():
        if i[1] - j[1] == x:
            print(i[0], j[0])
            break
    else:
        continue
    break
# Judge status: Wrong Answer
def main():
    N = int(input())
    A = list(map(int, input().split()))
    negatives = 0
    zeros = 0
    for a in A:
        if a < 0:
            negatives += 1
        if a == zeros:
            zeros += 1
    ans = sum(map(abs, A))
    if negatives % 2 == 0 or zeros != 0:
        print(ans)
        return

    a = min(abs(A[0]), abs(A[1]))
    b = min(abs(A[-2]), abs(A[-1]))
    ans -= 2*min(a, b)
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
x = int(input())

if x <= 6:
    print(1)
    import sys
    sys.exit()

dice = 6
ans = 0

ans = x // 11 * 2
m = x % 11
if m != 0:
    if m <= 6:
        ans += 1
    else:
        ans += 2

print(ans)
# Judge status: Wrong Answer
S = input()
if S == "RRR":
    print(3)
elif S == "SSS":
    print(0)
elif S == "RSR":
    print(1)
else:
    print(2)
# Judge status: Accepted
N, M = map(int, input().split())

persons = []
checks = []
for _ in range(N):
    persons.append(list(map(int, input().split())))
for _ in range(M):
    checks.append(list(map(int, input().split())))

for px, py in persons:
    i = 0
    min_dist = -1
    for k, (cx, cy) in enumerate(checks):
        m = abs(px-cx) + abs(py-cy)
        if k==0 or (k>0 and m < min_dist):
            i = k
            min_dist = m
    print(i+1)
# Judge status: Wrong Answer
# ABC067c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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


def cum(array):
    result = [0]
    for i in range(len(array)):
        result.append(array[i]+result[i])
    return result


cumArray = cum(a)

ans = 10**9
for i in range(1, n+1):
    ans = min(ans, abs(cumArray[i]-(cumArray[n]-cumArray[i])))

print(ans)
# Judge status: Accepted
n = int(input())
a, b = [], []
for i in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
ans = 0
for i in range(n - 1, -1, -1):
    if (a[i] + ans) % b[i] != 0:
        ans += b[i] - ((a[i] + ans) % b[i])
print(ans)
# Judge status: Accepted
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i+j)
    
print(ans)
# Judge status: Wrong Answer
s=input()
if s[0]=='A':
  if s[2:-1].count('C')==1:
    s=s[2:-1].replace('C','c')
    s=s[0].replace('A','a')
    if s.islower()==True:
      print('AC')
    else:  print('WA')
  else:  print('WA')
else:  print('WA')
# Judge status: Accepted
x = int(input())
ans = 0
for i in range(10**10):
    if i*(i+1)//2 >= x:
        ans = i
        break
print(ans)
# Judge status: Accepted
n = int(input())
ans = ''
while n != 0:
    s = n % 26
    if s == 0:
        ans += 'z'
        n = n //26 - 1
    else:
        ans += chr(s + 96)
        n //= 26
print(ans[::-1])
# Judge status: Accepted
n=int(input())
l=[0,0,0]
for i in list(map(int,input().split())):
  if i%2:l[0]+=1
  elif i%4:l[1]+=1
  else:l[2]+=1

print("Yes" if l[2]+1>=l[0]+int(1<=l[1]) else "No")
# Judge status: Wrong Answer
def f(a,b): return a <= 8 and b <= 8
a,b = map(int, raw_input().split())
print ':)' if f(a,b) else ':('
# Judge status: Wrong Answer
N = int(input())
ans = 10**9+7
for i in range(1,N//2):
  A = i
  B = N-i
  ans = min(ans, sum(list(map(int,str(A))))+sum(list(map(int,str(B)))))
print(ans)
# Judge status: Accepted
A,B,C =map(int,input().split())
if A == B and A != C:
    print('Yes')
elif B == C and C != A:
    print('Yes')
elif C == A and A != B:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a,b,c,d=MAP()

while True:
    c-=b
    if c<=0:
        print("Yes")
        exit()
    a-=d
    if a<=0:
        print("No")
        exit()
# Judge status: Accepted
a,b,c=map(int,input().split())
temp=a
a=b
b=temp
temp=a
a=c
c=temp
print(a,b,c)
# Judge status: Accepted
import math
import sys
n = int(input())
found = False

if(n <= 12):
    print(n)
    sys.exit()

for y in range(n):
    if n == math.floor(y*1.08):
        print(y)
        found = True
        break
if (found == False):
    print(":(")
# Judge status: Wrong Answer
s=input()
l=len(s)
a=s[:l//2]
b=s[(l+1)//2:]
cnt=0
for i in range(l//2):
  if a[i]==b[(l//2)-1-i]:
    cnt+=1
print(cnt)
# Judge status: Accepted
n=int(input())
print(2**(len(bin(n))-3))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)
for i in range(n-1):
  if a[i+1]==a[i]+1:
    ans+=c[a[i]-1]
print(ans)
# Judge status: Accepted
import math

lst = []
for i in range(6):
    lst.append(int(input()))
min_ = min(lst[1:])
print(math.ceil(lst[0] / min_) + 4)
# Judge status: Accepted
n,k = map(int,input().split())
su = 0
mod = 10**9+7
for i in range(k,n+2):
  a = i*(i-1)//2
  b = i*(2*n+1-i)//2
  su += b-a+1
 # print(a,b,su)
  su %= mod
print(su)
# Judge status: Wrong Answer
wmax,hmax,n=map(int,input().split())
wmin,hmin=0,0
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    wmin=max(wmin,x)
  elif a==2:
    wmax=min(wmax,x)
  elif a==3:
    hmin=max(hmin,x)
  elif a==4:
    hmax=min(hmax,x)

if hmin>=hmax or wmin>=wmax:
  print(0)
else:
  print((hmax-hmin)*(wmax-wmin))
# Judge status: Accepted
a,b=[int(s) for s in input().split()]
print(min([a%b,(b-a)%b]))
# Judge status: Accepted
N = int(input())
s = ""
i = 0

while N != 0:
    if N % 2 == 0:
        s += "0"
        N //= 2
    else:
        s += "1"
        if i % 2 == 0:
            N = (N - 1)//2
        else:
            N = (N + 1)//2
    i += 1

if s == "":
    print("0")
else:
    print(s[::-1])
# Judge status: Accepted
N = input()
ans = 'Yes'
n0 = N[0]
count = 0
if N[0] == N[1]:
    count = count + 1
if N[1] == N[2]:
    count = count + 1
if N[0] == N[2]:
    count = count + 1
if count == 3:
    ans = 'No'
print(ans)
# Judge status: Accepted
a,b,x = map(int, input().split())

if a <= x and a+b >= x:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
import sys
X = int(input())

if not ( 1 <= X <= 1000 ):
    sys.exit()

result = 1
for I in range(1,32):
    for J in range(2,10):
        if I ** J <= X and result <= I ** J:
            result = I ** J

print(result)
# Judge status: Wrong Answer
n = int(input())
f = [i * x for i in range(1,10) for x in range(1,10)]

if n in f:
    print("yes")
else:
    print("no")
# Judge status: Accepted
from collections import Counter

N=int(input())
L=list(map(int,input().split()))
Z=[]
M=Counter(L)
for i,j in M.items():
	if j>=2:
		Z.append(i)
	if j>=4:
		Z.append(i)
V=sorted(Z)
if len(V)<2:
	print(0)
else:
	print(V[-1]*V[-2])
# Judge status: Accepted
import math

N,D = input().split()
P = []
for i in range(int(N)):
    X,Y = input().split()
    P.append(math.sqrt(int(X)**2 + int(Y)**2))
    
answer = [i for i in P if i <= int(D)]
print(len(answer))
# Judge status: Wrong Answer
K = int(input())
i = 0
ret = -1
if K % 5 != 0 and K % 2 != 0:
  N = 1
  if K % 7 == 0:
    L = K * 9 // 7
  else:
    L = K * 9
  while True:
    if N % L == 1:
      ret = i
      break
    N = (N * 10 )% L
    i += 1
print(ret)
# Judge status: Accepted
n, d = input().split(' ')
n = int(n)
d = int(d)
res = 0
while n > 0 :
    x, y = input().split(' ')
    x = int(x)
    y = int(y)
    if (((x**2)+(y**2))**0.5) <= d:
        res += 1
    n -= 1
print(res)
# Judge status: Accepted
N=input()
r=0
m=int(N[-1])
for i in range(len(N)-1,0,-1):
    n=m
    m=int(N[i-1])
    if n<5:
        r+=n
    elif n==5:
        if m<5:
            r+=n
        else:
            r+=10-n
            m+=1
    else:
        r+=10-n
        m+=1
r+=m if m<6 else 11-m
print(r)
# Judge status: Wrong Answer
s = input()

if(s == 'SUN'):
    print(7)
elif(s == 'MON'):
    print(6)
elif(s == 'TUE'):
    print(5)
elif(s == 'WED'):
    print()
elif(s == '4'):
    print()
elif(s == 'THU'):
    print(3)
elif(s == 'FRI'):
    print(2)
elif(s == 'SAT'):
    print(1)
# Judge status: Accepted
N, K = map(int, input().split())

ans = min((N % K), abs((N % K) - K))

print(ans)
# Judge status: Accepted
N = int(input())

S = list(input())

ans = [0]*N
ans[0] = S[1:].count("E")

for i in range(1, N):
    ans[i] += (ans[i-1] + int(S[i-1]=="W") - int(S[i]=="E"))

print(min(ans))
# Judge status: Wrong Answer
x, a, b = map(int,input().split())

if abs(x - a) < (x - b):
  r = 'A'
else:
  r = 'B'

print(r)
# Judge status: Wrong Answer
def comb(n_, k_, mod_=10**9+7):
    ans_ = 1
    for i in range(1,k_+1):
        ans_ *= ((n_+1-i)/i)
        ans_ = ans_%mod_
    return round(ans_//1%mod_)

n,a,b = map(int, input().split())
ans_tmp = (2**n-1)#%mod

for i in [a,b]:
    tmp = comb(n,i)
    ans_tmp -= tmp
print(ans_tmp%(10**9+7))
# Judge status: Accepted
X = int(input())

def solve() :
  for a in range(-1000, 1000) :
    for b in range(-1000, 1000) :
      if (a ** 5) - (b ** 5) == X :
        return (a, b)
        
print(*solve())
# Judge status: Wrong Answer
def main():
  num = int(input())
  return num*num
# Judge status: Accepted
def factorial(a):
    result = 1
    for i in range(1,a+1):
        result *= i
        result %= 1000000007
    return result
N, M = map(int, input().split())
if N == M:
    ans = 2*(factorial(N)**2) %1000000007
elif abs(N-M) == 1:
    ans = max(N,M)*(factorial(min(N,M))**2) %1000000007
else:
    ans =0
print(ans)
# Judge status: Wrong Answer
n = int(input())
a,b=[],[]

for i in range(n):
    x,y = map(int,input().split())
    a.append(x)
    b.append(y)

a=list(reversed(a))
b=list(reversed(b))

ans=0
OK=0
for i in range(n):
    tmp=a[i]+OK
    if tmp<=b[i]:
        ok=b[i]-tmp
    else:
        ok=-(-tmp//b[i])*b[i]-tmp
    OK=OK+ok

print(OK)
# Judge status: Accepted
n = int(input())
a = []
for i in range(n-1):
    a.append(list(map(int, input().split())))
for i in range(n-1):
    total = a[i][1]
    for j in range(i, n-1):
        total = max(a[j][1], total)
        total += (a[j][2] - total%a[j][2])%a[j][2]
        total += a[j][0]
    print(total)
print(0)
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = list(map(int, input().split()))

import collections
A_tuple = collections.Counter(A).most_common()[::-1]
print(len(A_tuple))
if len(A_tuple) < K:
    print(0)
else:
    ans = 0
    for i in range(len(A_tuple)-K):
        ans += A_tuple[i][1]
    print(ans)
# Judge status: Accepted
A,B,C=map(int,input().split())
if A==B:
  if A==C:
    print("No")
  else:
    print("Yes")
else:
  if A==C:
    print("Yes")
  elif C==B:
    print("Yes")
  else:
    print("No")
# Judge status: Accepted
import collections
n=int(input())
a=list(map(int,input().split()))
l=list(set(a))
m=collections.Counter(a)
ans=0
for i in range(len(l)):
    if m[l[i]]<l[i]:
        ans+=m[l[i]]
    else:
        ans+=m[l[i]]-l[i]
print(ans)
# Judge status: Wrong Answer
N = int(input())
s = 0
for i in range(1,N):
    if (i % 15 != 0)&(i % 3 != 0)&(i % 5 != 0):
        s += i
print(s)
# Judge status: Accepted
x = int(input())
if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
elif x < 2000:
    print(1)
# Judge status: Accepted
N, K = map(int, input().split(' '))
S = input()

groups = 1
for s0, s1 in zip(S, S[1:]):
    if s0 != s1:
        groups += 1

groups = max(1, groups - 2 * K)

print(N - groups)
# Judge status: Accepted
n=int(input())
while True:
  if len(set(str(n)))==1:
    print(n)
    break
  n+=1
# Judge status: Accepted
A,B=map(int,input().split())
if A%3==0 or B%3==0 or (A+B)%3==0 :
  print("Possible")
else :
  print("Impossible")