Harryxun/stf_run huggingface dataset:
from collections import deque
import sys
sys.setrecursionlimit(10000)

H, W, N = map(int, input().split())
field = [list(input()) for i in range(H)]
us = [str(i) for i in range(N, 0, -1)]
queue = deque([])
dx = [1,0,-1,0]
dy = [0,1,0,-1]

def search(posi):
	global flag
	global us
	global count
	global queue

	x, y, c = posi
	if (field[y][x] == us[-1]):
		flag = True
		if (us[-1] == str(N)):
			print(c)
			exit()
		us.pop()
		queue.clear()
		queue.append([x, y, c])
		return

	q_count = 0
	for q in range(4):
		nx = x + dx[q]
		ny = y + dy[q]
		if (nx >= 0 and nx <= W-1) and (ny >= 0 and ny <= H-1) and ([nx,ny] not in queue) and (field[ny][nx] != 'X') and (field[ny][nx] != 'S'):
			queue.append([nx, ny, c+1])
			q_count += 1
	for i in range(q_count):
		if (flag):
			return
		search(queue.popleft())


bf = False
for i in range(H):
	for j in range(W):
		if field[i][j] == 'S':
			c = 0
			queue.append([j, i, c])
			bf = True
			break
	if (bf):
		break

while 1:
	flag = False
	search(queue.popleft())


### FIXED CODE ###

#import time, sys#
from collections import deque

H, W, N = map(int, input().split())
field = [list(input()) for i in range(H)]
'''
20 30 9
.......X..8.XXXX.XX..XX.X.XX..
X.XX....X.XX..X.X.X....XXXX..X
..X.X..XX..X.....XX.X..X.XX...
....X.X.X.XXX.X..X..X.X..XX.X.
..XXX.XX...X.X....X.X..X..X...
..X...........X.X...X.1.XX...X
.X.X....X..XX..XX......9.X...4
..X....X........X......X......
....XXX.X...XX.X.....X.X..X.X.
..S..XXX..X....X.X.......X..X.
.5...XX..X.X..X....X...XXX....
..X...X.X....X....X..X.2X.....
XXXXXXXX.X.XX..XX..XX.......X.
.....X...........3..XX.XXX.X.X
..X.....X..X..XX.XX..X.X...XX.
...X..X.XXX.XX......X...X..XXX
.X.XX.X.........X.X...X...X..X
..X...X..X..XX..XXX..X.XX...X.
X....X.X....X...X.X..XX.XX..X.
...X6X..X........X.X.....7.X..
'''

#input = input().split('\n')#
#H, W, N = map(int, input.pop(0).split())#
#field = [line for line in input]#
node_posi = [0 for i in range(N+1)]

#s1 = time.time()#
nodes = 'S123456789'
for i in range(H):
	for j in range(W):
		if field[i][j] in nodes:
			node_posi[nodes.index(field[i][j])] = [j, i]
#e1 = time.time()#
#print("b:{}".format(e1-s1))#

cost = 0
#count = 1#
for i in range(len(node_posi)-1):
	#s2 = time.time()#
	searched = [[-1]*W for i in range(H)]
	start, goal = node_posi[i], node_posi[i+1]
	Q = deque([start])
	searched[start[1]][start[0]] = 0
	goal_flag = False
	
	while Q and not goal_flag:
		x, y = Q.popleft()
		goal_flag = False

		for q in range(4):
			nx = x + [1,0,-1,0][q]
			ny = y + [0,1,0,-1][q]
			
			if nx >= 0 and nx < W and ny >= 0 and ny < H:
				if searched[ny][nx] == -1 and field[ny][nx] != 'X':
					Q.append([nx, ny])
					searched[ny][nx] = searched[y][x] + 1
					if ([nx, ny] == goal):
						cost += searched[ny][nx]
						goal_flag = True
						break

			#s = "\n".join(["".join(map(lambda x: str(x)[:1], j)) for j in searched])#
			#sys.stdout.write("\r{}".format(s))#
			#sys.stdout.flush()#
	
	#e2 = time.time()#
	#print("{}:{}".format(count, e2-s2))#
	#count += 1#
print(cost)
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(x, y):
    return (x * y) // gcd(x, y)



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

MA = [S[0]]
NA = [T[0]]

L = lcm(M, N)

m = L/M
n = L/N

for i in range(M):
    if i % n == 0:
        MA.append(S[i])

for i in range(N):
    if i % m == 0:
        NA.append(T[i])

if MA == NA:
    print(L)
else:
    print("-1")






### FIXED CODE ###

n = int(input())
a = int(input())
print(n*n-a)
N = input()
a = [input() for i in range(N)]
print(a[::-1])

### FIXED CODE ###

n = int(input())
print(" ".join(input().split()[::-1]))
n = input()


def solve1(n: int) -> str:
    k = 0
    for i in range(len(n)):
        k += int(n[i])

    if k % 9 == 0:
        return "Yes"
    else:
        return "No"


def solve2(n: int) -> str:
    if n % 9 == 0:
        return "Yes"
    else:
        return "No"


solve2(n)


### FIXED CODE ###

n = input()
k = 0

for i in range(len(n)):
    k += int(n[i])

if k % 9 == 0:
    print("Yes")
else:
    print("No")
from collections import Counter

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

l_counter = Counter(l)
l_set = sorted(list(l_counter.keys()))

length = len(l_set)
ans = 0
if n < 3:
    print(0)
else:
    for i in range(length - 2):
        for j in range(i + 1, length - 1):
            for k in range(j + 1, length):
                if l_set[k] < l_set[i] + l_set[j]:
                    ans += l_counter[l_set[i]] * l_counter[l_set[j]] * l_counter[l_set[k]]

    print(ans)


### FIXED CODE ###

s = input()
if s.count('R') == 0:
    print(0)
elif s.count('R') == 1:
    print(1)
elif s.count('R') == 2:
    if s[1] == 'R':
        print(2)
    else:
        print(1)
else:
    print(3)
N = int(input())
XY = [list(map(int, input().split(" "))) for _ in range(N)]

d = dict()
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        x1, y1 = XY[i]
        x2, y2 = XY[j]
        x3, y3 = x2-x1, y2-y1
        if x3 < 0:
            x3, y3 = -1*x3, -1*y3
        pos = (x3, y3)
        if pos not in d:
            d[pos] = 0
        d[pos] += 1

# print(d[max(d, key=lambda x: d[x])])
print(N - max(d.values())//2)

### FIXED CODE ###

N = int(input())
XY = [list(map(int, input().split(" "))) for _ in range(N)]

d = {(-1, -1): 0}
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        x1, y1 = XY[i]
        x2, y2 = XY[j]
        x3, y3 = x2-x1, y2-y1
        if x3 < 0 or (x3 == 0 and y3 < 0):
            x3, y3 = -1*x3, -1*y3
        pos = (x3, y3)
        if pos not in d:
            d[pos] = 0
        d[pos] += 1

# print(d.values(), d, max(d.values()))
print(N - max(d.values())//2)
def solve(x):
    k=1
    s=0
    while True:
        if(x%k==0):
            i=(x//k)-1
            if (x//i==x%i):
                s+=i
        k+=1
        if k*k>x:
            break
    return s
        

x=int(input())
print(solve(x))


### FIXED CODE ###

def solve(x):
    if(x<2):
        return 0
    k=1
    s=0
    while True:
        if(x%k==0):
            i=(x//k)-1
            if (x//i==x%i):
                s+=i
        k+=1
        if k*k>x:
            break
    return s
        

x=int(input())
print(solve(x))
import math
N, D = map(int, input().split())
print(math.ceil(N/(2D+1)))

### FIXED CODE ###

import math
N, D = map(int, input().split())
print(math.ceil(N/(2*D+1)))
# math.gcd()を使う
import math
N, X = map(int, input().split())
# 一行の入力をリストxに入れる
x = list(map(int, input().split()))
# すべての(x[i]-X)の最大公約数が答え
# 最初の最大公約数
t = abs(x[0] - X)
for a in x:
    # 最大公約数を更新
    t = math.gcd(t, abs(a - X))
print(t)


### FIXED CODE ###

import fractions

n, x = map(int, input().split())
num = list(map(int,input().split()))
d = abs(num[0]-x)
for nn in num:
	d=fractions.gcd(d, abs(nn-x))
print(d)
#AtCoder
N = int(input())
a = list(map(int, input()))

print(sum(a)-N)

### FIXED CODE ###

#AtCoder
N = int(input())
a = list(map(int, input().split()))

print(sum(a)-N)
from math import sin

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]

def dist(x, y, u, v):
    return ((x - u)**2 + (y - v)**2)**0.5

ans = 10**10

for i in range(N):
    for j in range(i + 1, N):
        # 対辺
        xi, yi = XY[i]
        xj, yj = XY[j]
        cx = (xi + xj) / 2
        cy = (yi + yj) / 2
        d = 0
        for x, y in XY:
            d = max(d, dist(x, y, cx, cy))
        ans = min(ans, d)

        for k in range(j + 1, N):
            xi, yi = XY[i]
            xj, yj = XY[j]
            xk, yk = XY[k]
            c = dist(xi, yi, xj, yj)
            a = dist(xj, yj, xk, yk)
            b = dist(xk, yk, xi, yi)

            # 外心
            S = a**2 * (b**2 + c**2 - a**2) + b**2 * (c**2 + a**2 - b**2) + c**2 * (a**2 + b**2 - c**2)
            cx = a**2 * (b**2 + c**2 - a**2) * xi + b**2 * (c**2 + a**2 - b**2) * xj + c**2 * (a**2 + b**2 - c**2) * xk
            cy = a**2 * (b**2 + c**2 - a**2) * yi + b**2 * (c**2 + a**2 - b**2) * yj + c**2 * (a**2 + b**2 - c**2) * yk
            cx /= S
            cy /= S
            d = 0
            for x, y in XY:
                d = max(d, dist(x, y, cx, cy))
            ans = min(ans, d)

print(ans)


### FIXED CODE ###

from math import sin

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]

def dist(x, y, u, v):
    return ((x - u)**2 + (y - v)**2)**0.5

ans = 10**10

for i in range(N):
    for j in range(i + 1, N):
        # 対辺
        xi, yi = XY[i]
        xj, yj = XY[j]
        cx = (xi + xj) / 2
        cy = (yi + yj) / 2
        d = 0
        for x, y in XY:
            d = max(d, dist(x, y, cx, cy))
        ans = min(ans, d)

        for k in range(j + 1, N):
            xi, yi = XY[i]
            xj, yj = XY[j]
            xk, yk = XY[k]
            c = dist(xi, yi, xj, yj)
            a = dist(xj, yj, xk, yk)
            b = dist(xk, yk, xi, yi)

            # 外心
            S = a**2 * (b**2 + c**2 - a**2) + b**2 * (c**2 + a**2 - b**2) + c**2 * (a**2 + b**2 - c**2)
            if S == 0:
                continue
            cx = a**2 * (b**2 + c**2 - a**2) * xi + b**2 * (c**2 + a**2 - b**2) * xj + c**2 * (a**2 + b**2 - c**2) * xk
            cy = a**2 * (b**2 + c**2 - a**2) * yi + b**2 * (c**2 + a**2 - b**2) * yj + c**2 * (a**2 + b**2 - c**2) * yk
            cx /= S
            cy /= S
            d = 0
            for x, y in XY:
                d = max(d, dist(x, y, cx, cy))
            ans = min(ans, d)

print(ans)
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main(void){
    int N;
    cin >> N;
    std::set<std::string> s;
    
    for(int i=0; i < N; i++){
        std::string a;
        cin >> a;
        s.insert(a);
    }
    
    cout << s.size() << endl;
}


### FIXED CODE ###

N = int(input())
s = set()

for i in range(N):
    s.add(input())
    
print (len(s))
s = input()
sum = 0
i = 0

while i < 9:
  sum = sum + s % 10
  s = s // 10
  i = i + 1

print(sum)

### FIXED CODE ###

s = raw_input()
print (s.count("+") - s.count("-"))
N = int(input())

min = float('inf')

def dfs(x, y, count):
    global min

    if x<0 or y<0 or (((x+1)*(y+1))>N):
        return

    if (x+1)*(y+1)==N:
        
        if min > count:
            min = count
            return
        return

    dfs(x+1, y, count+1)
    dfs(x, y+1, count+1)

    return

dfs(0,0,0)
print(min)

### FIXED CODE ###

N = int(input())

min = float('inf')

times = int(N**0.5)

for i in range(1, times+1, 1):

    if N%i==0:
        j = N//i
    else:
        continue
    temp = i+j-2
    if min > temp:
        min = temp

print(min)
while True:
    x,y = int(input())

    if x == 0 and y == 0:
        break
    elif x < y:
        print(x,y)
    else:
        print(y,x)


### FIXED CODE ###

while True:
    x,y = map(int,input().split())

    if x == 0 and y == 0:
        break
    elif x < y:
        print(x,y)
    else:
        print(y,x)
N = int(input())
n = [x for x in range(1, N+1)]
print(sum[:-1])

### FIXED CODE ###

N = int(input())
print((N+1) * N // 2 - N)
a = input()
b = input()
if a <= 9 and b <=9:
  print a*b
else:
  print -1

### FIXED CODE ###

a,b =map(int,raw_input().split())
if a <= 9 and b <=9:
	print a*b
else:
	print -1
rainy_days = input()
if rainy_days = 'RRR':
    print(3)
elif rainy_days == 'RRS' or 'SRR':
    print(2)
elif rainy_days == 'RSR' or 'RSS' or 'SSR' or 'SRS':
    print(1)
elif rainy_days == 'SSS':
    print(0)

### FIXED CODE ###

r = input()
if r == 'RRR':
    print(3)
elif r == 'RRS' or r == 'SRR':
    print(2)
elif r == 'RSR' or r == 'RSS' or r =='SSR' or r =='SRS':
    print(1)
elif r == 'SSS':
    print(0)
a = int(input())
b = int(input())
c = int(input())
print(int((a+b)*c/2))

### FIXED CODE ###

a = input()
b = input()
c = 0
for i in range(len(a)):
    if a[i] == b[i]:
        c += 1
print(c)
s = input()

if s[2]==s[3] ans s[4]==s[5] : print('Yes')
else : print('No')

### FIXED CODE ###

s = input()

if s[2]==s[3] and s[4]==s[5] : print('Yes')
else : print('No')
while(True):
    n,x = [int(i) for i in input().split()]
    if(n == 0 and x == 0):
        break
    t = 0
    for i in range(1,n + 1):
        for j in range(1,n + 1):
            for k range(1,n + 1):
                if(i < j < k and i + j + k == x):
                    t += 1
    print(t)

### FIXED CODE ###

while(True):
    n,x = [int(i) for i in input().split()]
    if(n == 0 and x == 0):
        break
    t = 0
    for i in range(1,n + 1):
        for j in range(1,n + 1):
            for k in range(1,n + 1):
                if(i < j < k and i + j + k == x):
                    t += 1
    print(t)
n=int(input())
k=int(input())
x=int(input())
y=int(input())
print(int(x*k+y*(n-k)*(n>k))

### FIXED CODE ###

n=int(input())
k=int(input())
x=int(input())
y=int(input())
print(x*k+y*(n-k) if n>k else x*n)
import math

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

sl, tl = map(int, input().split())
s = input()
t = input()

# 最小公倍数
m = lcm(sl,tl)

# sとtの幅
mps = m // sl
mpt = m // tl

tmp = 0
width = max(mps,mpt)
ans = True

while tmp < m:
    if tmp % mps == 0 and tmp % mpt == 0:
        if s[tmp//mps] != t[tmp//mpt]:
            ans = False
            break
    tmp += width

if ans:
    print(m)
else:
    print(-1)

### 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)

sl, tl = map(int, input().split())
s = input()
t = input()

m = lcm(sl,tl)

mps = m // sl
mpt = m // tl

tmp = 0
width = max(mps,mpt)
ans = True

while tmp < m:
    if tmp % mps == 0 and tmp % mpt == 0:
        if s[tmp//mps] != t[tmp//mpt]:
            ans = False
            break
    tmp += width

if ans:
    print(m)
else:
    print(-1)
a = int(input())
print(3a**2)

### FIXED CODE ###

a = int(input())
print(3*a**2)
a,b,c = map(int,input())
if b-a == c-b:
  print("YeS")
else:
  print("NO")

### FIXED CODE ###

a,b,c = map(int,input().split())
if b-a == c-b:
  print("YES")
else:
  print("NO")
a, b = map(int, input().split())
d = a//b
r = a % b
f = a / b
print("{:d} {:d} {:.5f}".format(d,r,f))

### FIXED CODE ###

import math
r = float(input())
print('{:.6f} {:.6f}'.format(r*r*math.pi,2*r*math.pi))
A,B = (int(x) for x in input().split())
a = range(math.ceil(A/0.08), math.floor(((A+1)/0.08)+1))
b = range(math.ceil(B/0.1), math.floor(((B+1)/0.1)+1))
c = set(a) & set(b)
if len(c) == 0:
          print(-1)
else:
          print(min(c))

### FIXED CODE ###

import math
A,B = (int(x) for x in input().split())
A1 = math.ceil(A/0.08)
if float((A+1)/0.08).is_integer() == True:
    A2 = math.floor((A+1)/0.08)
else:
    A2 = math.floor((A+1)/0.08) + 1
B1 = math.ceil(B/0.1)
if float((B+1)/0.1).is_integer() == True:
    B2 = math.floor((B+1)/0.1)
else:
    B2 = math.floor((B+1)/0.1) + 1
a = range(A1, A2)
b = range(B1, B2)
c = set(a) & set(b)
if len(c) == 0:
          print(-1)
else:
          print(min(c))
import sys
a = []
for line in sys.stdin:
    a.append(int(line))
b = a[0].split()[1]
for i in range(len(a)-1):
    b = b-a[i+1]
print(b[1]/min(a[1:len(a)]))

### FIXED CODE ###

S = input()
if S.count('o') == 0:
    print(700)
else:
    print(700+(100*S.count('o')))
N=int(input())
from decimal import Decimal
P=input().split()
for i in range(0,len(P)):
    P[i]=Decimal(P[i])
import numpy
Q=numpy.array(P)

result =numpy.prod(Q)

if result>pow(10, 18):
    print(-1)
else:
    print(result)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
A.sort()
B=1
for i in A:
  B*=i
  if(B>10**18):
    B=-1
    break
print(B)
s=input()
k=int(input())

if k==1 or int(s[0])!=1:
    print(int(s[0]))

else:
    if s[:k]=="1"*k:
        print(1)
    else:
        for i in range(1, len(s)):
            num=int(s[i])
            if num!=1:
                break
        print(num)

### FIXED CODE ###

s=input()
k=int(input())

if k==1:
    print(int(s[0]))

elif int(s[0])==1:

    if len(s)<k:
        num=1
        for i in range(1, len(s)):
            if int(s[i])!=1:
                num=int(s[i])
                break
        print(num)

    else:
        if s[:k]=="1"*k:
            print(1)
        else:
            num=1
            for i in range(1, len(s)):
                if int(s[i])!=1:
                    num=int(s[i])
                    break
            print(num)

elif int(s[0])!=1:
    print(int(s[0]))
"""
snuke festival
"""

def input_list():
    """
    returns list from stdin
    """
    input_map = map(int, input().split())
    return list(input_map)

def get_bigger_index(base_num, sub_list):
    """
    returns first index that is bigger than base number
    """
    bigger_index = -1
    for index, item in enumerate(sub_list):
        if base_num < item:
            bigger_index = index
            break
    return bigger_index

def main():
    """
    main function.
    """
    base_len = int(input())
    top = input_list()
    mid = input_list()
    btm = input_list()

    top.sort()
    mid.sort()
    btm.sort()

    result = 0

    for i in range(base_len):
        mid_index = get_bigger_index(top[i], mid)
        if mid_index < 0:
            break
        else:
            btm_index = get_bigger_index(mid[mid_index], btm)
            if btm_index >= 0:
                result += (base_len - mid_index) * (base_len + btm_index)

    print(result)

main()


### FIXED CODE ###

c11, c12, c13 = list(input())
c21, c22, c23 = list(input())
result = c11 == c23 and \
    c12 == c22 and \
    c13 == c21

ans = "YES" if result else "NO"
print(ans)
import copy
import fractions
a, b = map(int, input().split())

temp = fractions.gcd(a, b)

c = [None]*(temp+1)
for i in range(2, temp+1):
    if a%i==0 and b%i==0:
        c[i] = i

for ele in c:
    if ele!=None:
        c = [e for e in c if e!=None and (e%ele!=0 or e==ele)]
print(len(c)+1)

### FIXED CODE ###

import copy
import fractions
a, b = map(int, input().split())

temp = fractions.gcd(a, b)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

d = make_divisors(temp)
d.sort()

for ele in d:
    if ele==1:
        continue
    d = [e for e in d if e%ele!=0 or ele==e] 

print(len(d))
def smaller(x, y):
	if x < y:
		return x
	return y

N = int(input())
anscounter = []
for i in range(0, 26):
	anscounter.append(0)
S = input()
for i in range(0, len(S)):
	anscounter[ord(S[i])-97] += 1
for i in range(1, N):
	tmpcounter = []
	for j in range(0, 26):
		tmpcounter.append(0)
	newS = input()
	for j in range(0, len(S)):
		tmpcounter[ord(newS[j])-97] += 1
	for j in range(0, 26):
		anscounter[j] = smaller(anscounter[j], tmpcounter[j])
ans = ''
for i in range(0, 26):
	for j in range(0, anscounter[i]):
		ans = ans + str(chr(i+97))
print(ans)

### FIXED CODE ###

def smaller(x, y):
	if x < y:
		return x
	return y

N = int(input())
anscounter = []
for i in range(0, 26):
	anscounter.append(0)
S = input()
for i in range(0, len(S)):
	anscounter[ord(S[i])-97] += 1
for i in range(1, N):
	tmpcounter = []
	for j in range(0, 26):
		tmpcounter.append(0)
	newS = input()
	for j in range(0, len(newS)):
		tmpcounter[ord(newS[j])-97] += 1
	for j in range(0, 26):
		anscounter[j] = smaller(anscounter[j], tmpcounter[j])
ans = ''
for i in range(0, 26):
	for j in range(0, anscounter[i]):
		ans = ans + str(chr(i+97))
print(ans)
import math

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

x = [X] + list(map(int, input().split()))
x.sort()

dic = []

for i in range(len(x) - 1):
    tmp = x[i + 1] - x[i]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(len(dic) - 1):
    ans = min(ans, math.gcd(dic[i], dic[i + 1]))

print(ans)

### FIXED CODE ###

import fractions

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

x = [X] + list(map(int, input().split()))
x.sort()

dic = []

for i in range(len(x) - 1):
    tmp = x[i + 1] - x[i]
    if tmp not in dic:
        dic.append(tmp)

ans = max(dic)

for i in range(len(dic) - 1):
    ans = min(ans, fractions.gcd(dic[i], dic[i + 1]))

print(ans)
a

### FIXED CODE ###

a,b = map(int, input().split())
print(a+b//2)
# import sys
# sys.setrecursionlimit(2000)

N = int(input())
COR = [tuple((map(int, input().split()))) for _ in range(N)]


class Group:
    
    def __init__(self):
        self.n = 0
        self.x = []
        self.y = []
        
    def new_cor_n(self):
        if self.n <= 2:
            return 0
        s = len(self.x) * len(self.y) - self.n
        if s < 0:
            s = 0
        return 0
        
def grouping(group, x, xcor, ycor):
    xcor[x][1] = True
    group.x.append(x)
    for y in xcor[x][0]:
        if ycor[y][1]:
            continue
        group.n += 1
        ycor[y][1] = True
        group.y.append(y)
        for x_ in ycor[y][0]:
            if xcor[x_][1]:
                continue
            group.n += 1
            grouping(group, x_, xcor, ycor)
            
if N <= 2:
    print(0)
else:
    xcor, ycor = {}, {}
    for xi, yi in COR:
        if xi in xcor:
            xcor[xi][0].append(yi)
        else:
            xcor[xi] = [[yi], False]
        if yi in ycor:
            ycor[yi][0].append(xi)
        else:
            ycor[yi] = [[xi], False]
    group_list = []
    for x, v in xcor.items():
        if v[1]:
            continue
        group = Group()
        group_list.append(group)
        grouping(group, x, xcor, ycor)
    s = 0
    for group in group_list:
        s += group.new_cor_n()
    print(s)

### FIXED CODE ###

# import sys
# sys.setrecursionlimit(20000)


N = int(input())
COR = [tuple((map(int, input().split()))) for _ in range(N)]


class Group:
    
    def __init__(self):
        self.n = 0
        self.x = 0
        self.y = 0
        self.xy = {}
        
    def new_cor_n(self):
        return self.x * self.y - self.n
        

def grouping(group, x, xcor, ycor):
    x_list = []
    group.x += 1
    for y in xcor[x][0]:
        if (x, y) not in group.xy:
            group.n += 1
            group.xy[(x, y)] = None
        if ycor[y][1]:
            continue
        ycor[y][1] = True
        group.y += 1
        for x_ in ycor[y][0]:
            if (x_, y) not in group.xy:
                group.n += 1
                group.xy[(x_, y)] = None
            if xcor[x_][1]:
                continue
            xcor[x_][1] = True
            x_list.append(x_)
    return x_list

if N <= 2:
    print(0)
else:
    xcor, ycor = {}, {}
    for xi, yi in COR:
        if xi in xcor:
            xcor[xi][0].append(yi)
        else:
            xcor[xi] = [[yi], False]
        if yi in ycor:
            ycor[yi][0].append(xi)
        else:
            ycor[yi] = [[xi], False]
    group_list = []
    for i, v in xcor.items():
        if v[1]:
            continue
        group = Group()
        group_list.append(group)
        xcor[i][1] = True
        x_list = [i]
        while True:
            new_x_list = []
            for x in x_list:
                new_x_list += grouping(group, x, xcor, ycor)
            if new_x_list == []:
                break
            x_list = new_x_list
    s = 0
    for group in group_list:
        s += group.new_cor_n()
    print(s)
s = input()
count = 0
for i in range(len(s)+1):
    for j in range(i+1, len(s)+1):
        if (int(s[i:j])%3 == 0 and int(s[i:j])%673 == 0):
            count += 1
            #print("ok", s[i:j])
print(count)

### FIXED CODE ###

s, w = map(int, input().split())
if w >= s:
  print('unsafe')
else:
  print('safe')
def func(X):
    if X==1:
        return 1
    else:
        return X*func(X-1)
N=int(input())
print(func(N)%((10**9)+7))

### FIXED CODE ###

import math
print(math.factorial(int(input()))%(10**9+7))
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("name")
arg = parser.parse_args()
print(arg[:3])

### FIXED CODE ###

import sys

args = input()
print(args[:3])
s = str(input())
 

 for i in range(len(s)):
    if s[i] == 'A':
        a = i
        break
 
 for i in reversed(range(len(s))):
    if s[i] == 'Z':
        z = i
        break
 

 print(z - a + 1)

### FIXED CODE ###

x=int(input())
if 1200>x:
  print("ABC")
  
else:
  print("ARC")