Harryxun/stf_run huggingface dataset:
H,W=map(int,input().split())
f=H*W
d=[[0]*f for _ in range(f)]


s=[input() for _  in range(H)]
    
for i in range(H):
    for j in range(W-1): 
        cnt=W*i+j
        d[cnt+1][cnt]=s[i][j]==s[i][j+1]=="."
        d[cnt][cnt+1]=s[i][j]==s[i][j+1]=="."
       
for i in range(H-1):
    for j in range(W): 
        cnt=W*i+j
        d[cnt][cnt+W]=s[i][j]==s[i+1][j]=="."
        d[cnt+W][cnt]=s[i][j]==s[i+1][j]=="."
        
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
csr=np.array(d)


ans=-1
for i in range(H):
    for j in range(W): 
        cnt=W*i+j
        ans=max(ans,max(shortest_path(csr, indices=cnt)))

print(int(ans))

### FIXED CODE ###

H,W=map(int,input().split())
f=H*W
d=[[0]*f for _ in range(f)]


s=[input() for _  in range(H)]
    
for i in range(H):
    for j in range(W-1): 
        cnt=W*i+j
        d[cnt+1][cnt]=s[i][j]==s[i][j+1]=="."
        d[cnt][cnt+1]=s[i][j]==s[i][j+1]=="."
       
for i in range(H-1):
    for j in range(W): 
        cnt=W*i+j
        d[cnt][cnt+W]=s[i][j]==s[i+1][j]=="."
        d[cnt+W][cnt]=s[i][j]==s[i+1][j]=="."
        
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
csr=np.array(d)


ans=-1
k=shortest_path(csr)
for i in range(f):   
    for q in range(f):
            if k[i][q]>=f+1:k[i][q]=-1

    ans=max(ans,max(k[i]))

print(int(ans))
x, y = map(int, input().split())
tmp = 2*y - x
if tmp%3 != 0:
    print(0)
    exit()
up = tmp // 3
total = y - up*2 + up

n = total
k = up
mod = 10**9 + 7

if k == 0:
    print(1)
    exit()

modinv_table = [-1] * (k+1)
modinv_table[1] = 1
for i in range(2, k+1):
    modinv_table[i] = (-modinv_table[mod % i] * (mod // i)) % mod

def binomial_coefficients(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table[i + 1]
        ans %= mod
    return ans

print(binomial_coefficients(n, k))

### FIXED CODE ###

x, y = map(int, input().split())
tmp = 2*y - x
if tmp%3 != 0:
    print(0)
    exit()
up = tmp // 3
total = y - up*2 + up

n = total
k = up
mod = 10**9 + 7

#print(n)
#print(k)

if k == 0:
    print(1)
    exit()
try:
    modinv_table = [-1] * (k+1)
    modinv_table[1] = 1
    for i in range(2, k+1):
        modinv_table[i] = (-modinv_table[mod % i] * (mod // i)) % mod
except:
    k = total - up
    modinv_table = [-1] * (k + 1)
    modinv_table[1] = 1
    for i in range(2, k + 1):
        modinv_table[i] = (-modinv_table[mod % i] * (mod // i)) % mod

def binomial_coefficients(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table[i + 1]
        ans %= mod
    return ans

print(binomial_coefficients(n, k))
n=int(input())
X=[]
Y=[]
A=[0]*n
for i in range(n):
  A[i]=int(input())
  a=A[i]
  x=[]
  y=[]
  for j in range(a):
    x,y=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  

c=0
for i in range(n):
  l=[1]*n
  for j in range(i,n-i):
    if l[j]==0:continue
    for k in range(A[j]):
      b=X[1][1]
      #l[b] *= Y[j][k]

if c < l.count(1):
  c=l.count(1) 
  
        
  
print(c)  
   

### FIXED CODE ###

n=int(input())
X=[]
Y=[]
A=[0]*n
for i in range(n):
  A[i]=int(input())
  a=A[i]
  x=[0]*a
  y=[0]*a
  for j in range(a):
    x[j],y[j]=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  
s=0
for i in range(2**n):
  c=0
  d=0
  B=[0]*n
  for j in range(n):
    if((i >> j) & 1):
      c=c+1
      B[j]=1
  for k in range(n):
    if B[k]==1:
      for j in range(A[k]):
        if Y[k][j]!=B[X[k][j]-1]:
          d=-1
          break
    if d<0:
      break
  if s<c and d==0:
    s=c
      
      
print(s)
X, K, D = map(int, input().split())

ans_list = []

if X+K*D <= 0:
    ans = abs(X+K*D)
else:
    if D>0:
        a = int((X+K*D)/(2*D))
        for i in range(-2,3):
            if a+i <= K and a+i >= 0:
                #ans_list.append(abs(X+(K-(a+i))*D - (a+i)*D))
                ans_list.append(abs(X+K*D-2*(a+i)*D))
        ans = min(ans_list)
print(ans)

### FIXED CODE ###

X, K, D = map(int, input().split())
ans_list = []

if X+K*D <= 0:
    ans = abs(X+K*D)
else:
    a = (X+K*D)//(2*D)
    if a >= K:
        a = K
        ans = abs(X-K*D)
    else:
        ans_1 = abs(X+K*D-2*a*D)
        ans_2 = abs(X+K*D-2*(a+1)*D)
        ans = min(ans_1, ans_2)
print(ans)
a,b,c,x=map(int,input().split())
cnt = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*a+100*b+50*c == x:
        cnt +=1
print(cnt)

### FIXED CODE ###

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):
      if 500*i+100*j+50*k == x:
        cnt +=1
print(cnt)
#ALDS1_4-D Allocation
import collections

def pIsAccptbl(w,k,p):
    tr = 0
    c = 0
    while(w):
        tmp = w.popleft()
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp

    c+=1
    if c>k:return False
    else:return True
    
n,k = input().split()
w = collections.deque()
for i in range(int(n)):
    w.append(int(input()))

p = max(w)

while(1):
    x=w.copy()
    if(pIsAccptbl(x,int(k),p)):
        break
    else:
        p+=1

### FIXED CODE ###

from collections import deque

def isPa(w,k,p):
    tr = 0
    c = 0
    d = deque(w)
    while(d):
        tmp = d.popleft()
        if(tmp > p):
            return False
        
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp
        if c+1>k:
            return False
    return True

def MaxInP(w,k,p):
    maxinp = 0
    tmp = 0
    d = deque(w)
    while(d):
        tmp += d.popleft();
        if(tmp > p):
            if(tmp > maxinp):
                maxinp = tmp
            tmp = 0
    return maxinp

n,k = [int(x) for x in input().split()]
w = deque()
for i in range(n):
    w.append(int(input()))
    
mean = int(sum(w)/k)
maxinp = MaxInP(w,k,mean)

if k == 1:
    print(mean)
else:
    minP = mean
    maxP = maxinp
    while(True):
        m = int ((minP + maxP)/2)
        if ( isPa(w,k,m) ):
            maxP = m
        else:
            minP = m
        if (minP+1 == maxP or minP == maxP):
            print(maxP)
            break
def d_even_relation_dfs(N, Nodes):  # DFSによる
    graph = [[] for _ in range(N)]
    for u, v, w in Nodes:  # 0-basedとする
        graph[u - 1].append((v - 1, w))
        graph[v - 1].append((u - 1, w))

    def distance_from_root(parent, current, distance, ret=[0] * N):  # 根(頂点0)から各頂点への距離
        def dfs(p, c, d):
            ret[c] = d
            for next_edge, dist in graph[c]:
                if next_edge != p:  # 木を「逆戻り」しない頂点だけ調べる
                    dfs(c, next_edge, d + dist)
        dfs(parent, current, distance)
        return ret
    ans = (1 if d % 2 == 0 else 0 for d in distance_from_root(-1, 0, 0))  # 根の親は-1番とする
    return ' '.join(map(str, ans))

N = int(input())
Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]
print(d_even_relation_dfs(N, Nodes))

### FIXED CODE ###

def d_even_relation(N, Nodes):
    from collections import deque
    graph = [{} for _ in range(N)]
    for u, v, w in Nodes:
        graph[u - 1][v - 1] = w
        graph[v - 1][u - 1] = w

    ans = [0] * N
    queue = deque([(-1, -1, 0)])
    while queue:
        previous, parent, child = queue.pop()
        if parent == -1:
            ans[child] = 0
        elif previous != child:
            length = graph[parent][child]
            if length % 2 == 0:
                ans[child] = ans[parent]
            else:
                ans[child] = 1 if ans[parent] == 0 else 0
        for k in graph[child].keys():
            if parent != k:
                queue.appendleft((parent, child, k))
    return '\n'.join(map(str, ans))

N = int(input())
Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]
print(d_even_relation(N, Nodes))
arr={'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5}
x,y=map(str,input().split())
if arr[x]>arr[y]:
  print('>')
elif arr[x]<arr[y]:
  print('<')
else:
  print('=')


### FIXED CODE ###

arr={'A':0, 'B':1, 'C':2, 'D':3, 'E':4, 'F':5}
x,y=map(str,input().split())
if arr[x]>arr[y]:
  print('>')
elif arr[x]<arr[y]:
  print('<')
else:
  print('=')
import sys

diff = deque()

N, M = map(int, input().split())
X = list(map(int, input().split()))
diff = []

if N >= M:
    print(0)
    exit()

X.sort()

for i in range(len(X)-1):
    diff.append(X[i+1]-X[i])

diff.sort()

for i in range(N-1):
    diff.pop()

print(sum(diff))


### FIXED CODE ###

import sys
from collections import deque


diff = deque()

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

if N >= M:
    print(0)
    exit()

X.sort()

for i in range(len(X)-1):
    diff.append(X[i+1]-X[i])

diff = list(diff)
diff.sort()

for i in range(N-1):
    diff.pop()

print(sum(diff))
n=int(input())
l=[int(input()) for i in range(n)]
a=sun(l)
ans='Yes'
for i in l:
  if a-i<i:
    ans='No'
print(ans)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
a=sum(l)
ans='Yes'
for i in l:
  if a-i<=i:
    ans='No'
print(ans)
N,K,X,Y=[input() for _ in range(4)];print(min([N,K])*X+max([N-K,0])*Y)

### FIXED CODE ###

N,K,X,Y=[int(input()) for _ in range(4)];print(min(N,K)*X+max(N-K,0)*Y)
import numpy as np
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
ar = np.eye(N) * A

for h in range(0, N):
    for w in range(1, h+1):
        ar[-h-1, -h-1+w] = ar[-h, -h-1+w] + ar[-h-1, -h-2+w] - ar[-h, -h-2+w]
print(int(sum(sum(ar % M == 0)) - sum(np.linspace(1, N-1, N-1))))

### FIXED CODE ###

N = int(input())
s = ''

while N != 0:
#    print(N, s, N % (-2) == 0)
    if N % (-2) == 0:
        s = '0' + s
    else:
        s = '1' + s
        N -= 1
    N /= (-2)

if s =='':
    s = '0'
print(s)
from math import sqrt
def isprime(farm, prime):
	
	first = min(farm)
	prime.append(first)
	maxfarm = max(farm)
	dellst = range(first, maxfarm+1, first)
	farm = set(farm - set(dellst))
	if len(farm) > 0 and sqrt(maxfarm) > first:
		return isprime(farm, prime)
	else:
		return prime.extend(farm)

n = int(input())
inlst = []
for i in range(n):
	inlst.append(int(input()))
	
farm = set(range(2, max(inlst)+1, 1))
prime = [1]

if len(farm) > 0:
	isprime(farm, prime)
	
out = list(set(inlst) & set(prime))
print(len(out))

### FIXED CODE ###

from math import sqrt
def isprime(inlst, chk, sq):
	for i in range(3, sq, 2):
		inlst = [x for x in inlst if x%i > 0 or x == i]
		i += 2
	return inlst
n = int(input())
inlst = [input() for i in range(n)]
inlst = [int(i) for i in inlst]
inlst = [x for x in inlst if x%2 > 0 or x == 2]
inlst = isprime(inlst, 3, int(sqrt(max(inlst))) + 1)
print(len(inlst))
N = int(input())
list1 = [(input() + " " + str(i+1)).split() for i in range(N)]
 
list1 = [a for a in lis]
 
list1.sort(key=lambda a: int(a[1]), reverse=True)
list1.sort(key=lambda a: a[0])
 
 
for i in list1:
    print(i[2])


### FIXED CODE ###

try:
    a,p=map(int, input().split())
    assert 0<=a,p<=100
    print(((a*3)+p)//2)
except AssertionError:
    print('')
import sympy


### FIXED CODE ###

n = int(input())
ans = 1
r = [1] * (n + 1)
s = n


for i in range(1, n + 1):
    p = i
    while p % 2 == 0:
        p = p // 2
        r[1] += 1

    for j in range(3, i + 1, 2):
        while p % j == 0:
            p = p // j
            r[j-1] += 1

for k in range(n+1):
    ans *= r[k]

ans = ans % (10 ** 9 + 7)
print(ans)
N, X = map(int, input().split())
L = list(map(int, input().split()))

point = 0
cnt = 1
while point<=X:
  point += L[cnt-1]
  if point <= X:
    cnt += 1
  else:
    break

print(cnt)

### FIXED CODE ###

N, X = map(int, input().split())
L = list(map(int, input().split()))
 
point = 0
cnt = 1
while cnt<=N:
  point += L[cnt-1]
  if point <= X:
    cnt += 1
  else:
    break
 
print(cnt)
N = list(map(int,input().split()))

row = ""

if N[1] == 0:
    print(0)
else:
    remain = int(N[0]//(N[1]+N[2]))
    remain_2 = N[0] - N[1]*remain - N[2]*remain
    row += "b"*N[1]*remain+"a"*N[2]*remain+"b"*remain_2
    print(row.count("b"))   

### FIXED CODE ###

N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
a=int(input())
b=int(input())
if a*b%2==0:
  print("Even")
else:
  print("Odd")


### FIXED CODE ###

a,b=list(map(int,input().split()))
if a*b%2==0:
  print("Even")
else:
  print("Odd")
a,b = map(int,input().split())
n=sqrt(a*(10**len(b))+b)
 
if isinstance(n,int)=="True":
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b=map(str,input().split())
ab=int(a+b)
if (ab**.5).is_integer():
  print("Yes")
else:
  print("No")
n = input()
s = []
ans = 1

for _ in range(n):
    s.append(map(int,input()))

if 0 in s:
    print(0)
else:    
    for i in range(n+1):
        ans *= s[i]

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

### FIXED CODE ###

n = int(input())
s = list(map(int,input().split()))
ans = 1

if 0 in s:
    print(0)
else:    
    for i in range(n):
        ans *= s[i]
        if ans > 10 ** 18:
            ans = -1
            break
    print(ans)
N,K=map(int,input().split())
import math
A=int(input().split())
ans=1
ans+=math.ceil(N-K)/(K-1)
print(ans)

### FIXED CODE ###

N,K=map(int,input().split())
import math
A=list(map(int,input().split()))
ans=1
ans+=math.ceil((N-K)/(K-1))
print(ans)
A,B = map(int, input().split())
    
    if A%3 == 0:
        print('Possible')
    elif B%3 == 0:
        print('Possible')
    elif (A+B)%3 == 0:
        print('Possible')
    else:
        print('Impossible')

### FIXED CODE ###

def ABC_67_A():
    A,B = map(int, input().split())
    
    if A%3 == 0:
        print('Possible')
    elif B%3 == 0:
        print('Possible')
    elif (A+B)%3 == 0:
        print('Possible')
    else:
        print('Impossible')

if __name__ == '__main__':

    ABC_67_A()
import math
N, X = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(N):
    A[i] = abs(A[i] - X)
g = A[0]
for i in range(1, N):
    g = math.gcd(g, A[i])
print(g)


### FIXED CODE ###

N, X = list(map(int, input().split()))
A = list(map(int, input().split()))
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
for i in range(N):
    A[i] = abs(A[i] - X)
g = A[0]
for i in range(1, N):
    g = gcd(g, A[i])
print(g)
S = input()

def func(S):
    if S == '':
        return True
    a, b, c, d = False, False, False, False
    if S[0:5] == 'dream':
        a = func(S[5:])
        if S[5:7] == 'er':
            b =  func(S[7:])
    elif S[0:5] == 'erase':
        c = func(S[5:])
        if S[5] == 'r':
            d = func(S[6:])
    else:
        return False
    return a or b or c or d

print('YES' if func(S) else 'NO')


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

S = input()

def func(i):
    if i >= len(S):
        return True
    if S[i:i+5] == 'dream':
        if func(i + 5): return True
        if S[i+5:i+7] == 'er':
            if func(i + 7): return True
        return False
    if S[i:i+5] == 'erase':
        if func(i + 5): return True
        if S[i+5] == 'r':
            if func(i + 6): return True
        return False

print('YES' if func(0) else 'NO')
k=int(input())
L=[]
def f(d,now,L):
  L.append(now)
  
  if d==10:
    return
  
  for j in range(-1,2):
    v=now%10+j
    if 0<=v<=9:
      f(d+1,now*10+v,L)

f(0,0,L)
print(L[k-1])
      

### FIXED CODE ###

k=int(input())
L=[]
def f(d,now,L):
  L.append(now)
  
  if d==10:
    return
  
  for j in range(-1,2):
    v=now%10+j
    if 0<=v<=9:
      f(d+1,now*10+v,L)

for l in range(1,10):
  f(1,l,L)
L.sort()
print(L[k-1])
N, K = input()

que = input()

que = [x for x in que.split()]
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.

Author : Takeshi Saga

"""

import itertools
import numpy as np

N, K = input()
que = input()
try:
    N = int(N)
except:
    pass
try:
    K = int(K)
except:
    pass



que = [int(x) for x in que.split()]

#print(que)
"""
tmp = []
for x in que:
    for xx in range(K):
        tmp.append(x)
que = tmp
"""
min_val = 999999999

for x in itertools.combinations(que, K):
    tmp = np.sum(x)
    if tmp < min_val:
        min_val = tmp

print(min_val)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.

Author : Takeshi Saga

"""

import itertools
import numpy as np

tmp = input()
#tmp = "5 3"
N,K = tmp.split()
que = input()
#que = "50 100 80 120 80"
try:
    N = int(N)
except:
    pass
try:
    K = int(K)
except:
    pass



que = [int(x) for x in que.split()]

#print(que)
"""
tmp = []
for x in que:
    for xx in range(K):
        tmp.append(x)
que = tmp
"""
min_val = 999999999

que = sorted(que)

#for x in itertools.combinations(que, K):

x = [que[i] for i in range(K)]
min_val = np.sum(x)

print(min_val)
N, K = map(int, input().split())
di = K * 2
l = []

for i in range (di):
    l.append(int(input()))

l1 = []
x = 1
while x < di:
    for j in l[x]:
        l1.append(j)
    x += 2
l1 = set(l1)
print(N - len(l1))

### FIXED CODE ###

N, K = map(int, input().split())
di = K * 2
l = []
for i in range (di):
    l.append(input().split())
l1 = []
x = 1
while x < di:
    for j in l[x]:
        l1.append(j)
    x += 2
l1 = set(l1)
print(N - len(l1))
import sys
s = list(raw_input())
if len(s) == 2:
    if s[0] == s[1]:
        print 1, 2
    else
        print -1, -1
else:
    for n in [3]:
        for i in xrange(len(s) - n + 1):
            sub = s[i:i+n]
            for char in set(sub):
                if sub.count(char) >= n / 2 + n % 2:
                    print i + 1, i + n
                    sys.exit()
    print -1, -1


### FIXED CODE ###

import sys
s = list(raw_input())
if len(s) == 2:
    if s[0] == s[1]:
        print 1, 2
    else:
        print -1, -1
else:
    for n in [3]:
        for i in xrange(len(s) - n + 1):
            sub = s[i:i+n]
            for char in set(sub):
                if sub.count(char) >= n / 2 + n % 2:
                    print i + 1, i + n
                    sys.exit()
    print -1, -1
import math

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

ans = 0
a_max = max(a)
alog = int(math.log2(a_max))+1

for i in range(alog):
    cnt0 = 0
    cnt1 = 0
    for j in a:
        p = pow(2, i)
        cnt1 += ((j & p) == p)
        cnt0 += ((j & p) == 0)
    ans += (cnt0 * cnt1)*(2**i)%(10**9+7)

print(ans%(10**9+7))

### FIXED CODE ###

import math
import  numpy as np

N = int(input())
a = np.array(list(map(int, input().split())))

ans = 0
a_max = max(a)

if a_max==0:alog=1
else:alog = int(math.log2(a_max))+1

for i in range(alog):
    p = pow(2, i)
    cnt = np.count_nonzero((a >> i)& 1 == 1)
    
    ans += cnt * (N - cnt)*(2**i)
print(ans%(10**9+7))
N = int(input())
K = int(input())
x = [int(i) for i in input().split()]

suml = [0] * 10

for i in range(N):
  delta = abs(K-x[i])
  if x[i] < delta:
  	suml[i] = suml[i] + x[i]*2
  else:
  	suml[i] = suml[i] + delta*2

print(sum(suml))

### FIXED CODE ###

N = int(input())
K = int(input())
x = [int(i) for i in input().split()]

suml = [0] * N

for i in range(N):
  delta = abs(K-x[i])
  if x[i] < delta:
  	suml[i] = suml[i] + x[i]*2
  else:
  	suml[i] = suml[i] + delta*2

print(sum(suml))
N, X, Y= map(int, input().split())
K = [0]*(N-1)
for i in range(1,N):
    for j in range(i+1, N+1):
        idx = min([j-i, abs(X-i)+ abs(j-Y)+1, abs(Y-i) + 1 + abs(X-j)])-1
        K[idx] +=1
for value in K:
    print(value)    

### FIXED CODE ###

import sys

s = list(input())
if s[2] == s[3] and s[4] == s[5]:
    print('Yes')
else:
    print('No')
from networkx import*
f=lambda:tuple(map(int,input().split()))
n,m=f()
print(max(map(len,connected_components(DiGraph(f()for _ in range(m))))))

### FIXED CODE ###

from networkx import*
_,*t=map(str.split,open(0))
print(max(1,1,*map(len,connected_components(Graph(t)))))
import math

a,b,c = map(int,input().split())
ans = ""

if(c -a - b < 0 and 4*a*b>(c-a-b)*)*(c-a-b)):
    ans = "Yes"
else:
    ans = "No"

print(ans)



### FIXED CODE ###

import math

a,b,c = map(int,input().split())
ans = ""

if((4*a*b)<(c-a-b)*(c-a-b) and c-a-b>0):
    ans = "Yes"
else:
    ans = "No"

print(ans)
a=int(input())
p=list[]
c=list['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']
b=input()
for i in c:
  if i==b:
    if c[i]>25:
      z=c[i]-25
      p=c[z]
    else:
    
      z=c[c[i]+a]
      p=c[z]
  else:
    pass
  print(c[p])    


### FIXED CODE ###

N=int(input())
S=list(input())
a=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
res=''

for s in S:
  code=a.index(s)+N
  if code>a.index('Z'):
    code-=26
  res+=a[code]
print(res)
n=input()
rice=[]
for i in range(n):
    rice.append(input())

cake=[]
for i in range(n):
    if not(rice[i] in cake):
        cake.append(rice[i])

print(len(cake))




### FIXED CODE ###

n=int(input())
rice=[]
for i in range(n):
    rice.append(input())

cake=[]
for i in range(n):
    if not(rice[i] in cake):
        cake.append(rice[i])

print(len(cake))
# -*- coding: utf-8 -*-

a, b, k = map(int, input().split())

aa = list(range(a, b+1))

bb = []

bb.append(aa[0:k])
bb.append(aa[len(aa)-k:])
bb = sum(bb,[])
bb = sorted(list(set(bb)))
for i in bb:
    print(i)


### FIXED CODE ###

# -*- coding: utf-8 -*-

a, b, k = map(int, input().split())

if b-a < 2*k:
    for i in range(a, b+1):
        print(i)
else:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)
N, K = map(int, input().split())
S = str(input())
if S[K - 1] == "A":
    S[K - 1] = "a"
    print("".join(S))
elif S[K - 1] == "B":
    S[K - 1] = "b"
    print("".join(S))
else:
    S[K - 1] = "c"
    print("".join(S))


### FIXED CODE ###

N, K = map(int, input().split())
S = list(input())
if S[K - 1] == "A":
    S[K - 1] = "a"
    print("".join(S))
elif S[K - 1] == "B":
    S[K - 1] = "b"
    print("".join(S))
else:
    S[K - 1] = "c"
    print("".join(S))
n = int(input())

ans = 0
for i in range(1,n):
    if (n-i)/i > i:
        if (n-i)%i == 0:
            ans += (n-i)/i
    else:
        break
print(int(ans)

### FIXED CODE ###

n = int(input())

ans = 0
for i in range(1,n):
    if (n-i)/i > i:
        if (n-i)%i == 0:
            ans += (n-i)/i
    else:
        break
print(int(ans))
n, k = map(int, input().split())
l = list(map(int, input().split()))
start = 1
seenl = []
seen = set()
for i in range(k):
	start = l[start-1]
	if start in seen:
		loop_len = len(seenl) - seenl.index(start)
		r = (k-i-1)%loop_len
		goal = seenl[-loop_len:][r]
		break
	seenl.append(start)
	seen.add(start)
print(goal)

### FIXED CODE ###

n,k = map(int,input().split())
*l, = map(int,input().split())
seenl = [1]
seen = {1}
temp=1
for i in range(k):
  temp=l[temp-1]
  if temp in seen:
    lenloop = len(seenl)-seenl.index(temp)
    r = (k-i-1)%lenloop
    temp = seenl[seenl.index(temp):][r]
    break
  seenl.append(temp)
  seen.add(temp)
print(temp)