Harryxun/stf_run huggingface dataset:
x = int(input())
a = [input() for i in range(x)]
y = int(input())
b = [input() for i in range(y)]

count_max = 0
for i in a:
  if x.count(i) - y.count(i) > count_max:
    x.count(i) - y.count(i) = count_max
print(count_max)

### FIXED CODE ###

x = int(input())
a = [input() for _ in range(x)]
y = int(input())
b = [input() for _ in range(y)]

count_max = 0
for j in a:
  if (a.count(j) - b.count(j)) > count_max:
    count_max = a.count(j) - b.count(j)
print(count_max)
N, M = map(int, input().split())
A = list(map(int, input().split()))
sum = sum(A)
A2 = sorted(A,reverse=True)
Judge = 0
for i in range(N):
    if(A2[i]>(sum/(4*M))):
        Judge = Judge+1
if Judge>=M:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

X,Y,Z=input().split()
print(Z,X,Y)
A, P = map(int, raw_input.split())

N_piec = A * 3  + P
N_pie  = N_piec / 2
print N_pie

### FIXED CODE ###

A, P = map(int, raw_input().split())

N_piec = A * 3  + P
N_pie  = N_piec / 2
print N_pie
s=str(input())
s=list(s)
ans=999
for i in range(0,len(s)-2):
  temp=s[i]*100+s[i+1]*10+s[i+2]
  ans=min(ans,abs(753-temp))
print(ans)  

### FIXED CODE ###

s=str(input())
s=list(s)
ans=999
for i in range(0,len(s)-2):
  temp=int(s[i])*100+int(s[i+1])*10+int(s[i+2])
  ans=min(ans,abs(753-temp))
print(ans)
= int(input())
 
print(int(((n-1) * n) / 2))

### FIXED CODE ###

n = int(input())
 
print(int(((n-1) * n) // 2))
import sys
sys.setrecursionlimit(1000000000)

def check(x, y):
	array[x][y] = "0"
	if array[x + 1][y] == "1" : check(x + 1, y)
	if array[x - 1][y] == "1" : check(x - 1, y)
	if array[x][y + 1] == "1" : check(x, y + 1)
	if array[x][y - 1] == "1" : check(x, y - 1)
	if array[x + 1][y + 1] == "1" : check(x + 1, y + 1)
	if array[x + 1][y - 1] == "1" : check(x + 1, y - 1)
	if array[x - 1][y + 1] == "1" : check(x - 1, y + 1)
	if array[x - 1][y - 1] == "1" : check(x - 1, y - 1)

while True:
	h,w = map(int, raw_input().split())
	if h == 0 and w == 0 : break

	array = []
	array.append(list("$" * (2 + h)))
	for i in range(0, w) : array.append(list("$" + raw_input().replace(" ", "") + "$"))
	array.append(list("$" * (2 + h)))
	
	count = 0
	for i in range(1, h + 1):
		for j in range(1, w + 1):
			if array[i][j] == "1":
				check(i, j)
				count += 1
				
	print count

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def check(x, y):
	array[x][y] = "0"
	if array[x + 1][y] == "1" : check(x + 1, y)
	if array[x - 1][y] == "1" : check(x - 1, y)
	if array[x][y + 1] == "1" : check(x, y + 1)
	if array[x][y - 1] == "1" : check(x, y - 1)
	if array[x + 1][y + 1] == "1" : check(x + 1, y + 1)
	if array[x + 1][y - 1] == "1" : check(x + 1, y - 1)
	if array[x - 1][y + 1] == "1" : check(x - 1, y + 1)
	if array[x - 1][y - 1] == "1" : check(x - 1, y - 1)

while True:
	h,w = map(int, raw_input().split())
	if h == 0 and w == 0 : break

	array = []
	array.append(list("0" * (2 + h)))
	for i in range(0, w) : array.append(list("0" + raw_input().replace(" ", "") + "0"))
	array.append(list("0" * (2 + h)))
	
	count = 0
	for i in range(1, w + 1):
		for j in range(1, h + 1):
			if array[i][j] == "1":
				check(i, j)
				count += 1
				
	print count
n = int(raw_input())
h = {}
for i,a in enumerate(map(int, raw_input())):
	i += 1
	if a != i:
		h[a] = i

def get(u, parent):
	if parent[u] != u:
		parent[u] = get(parent[u], parent)
	return parent[u]

parent = {u:u for u in h}
sizes = {u:1 for u in h}
for u in h:
	v = h[u]
	pu,pv = get(u, parent), get(v, parent)
	if pu != pv:
		parent[pv] = pu
		sizes[pu] += sizes[pv]
print sum([sizes[u]-1 for u in parent if parent[u] == u] or [0])


### FIXED CODE ###

n = int(raw_input())
count = 0
res = 0
ais = map(int , raw_input().split())

for i,a in enumerate(ais):
	
	if a == i +1:
		count += 1
	else:
		#flush the count
		res += (count + 1)/2# + 1
		count = 0

if count: res +=  (count+1)/2 
print res
n=int(input())
for i in range(1,n):
    a[i]=int(input())



### FIXED CODE ###


def is_prime(n):

    if n == 2:
        return True
    elif n < 2 or n & 1 == 0:
        return False
    for i in range(3, int(n**0.5) + 1, 2):
        if n % i == 0:
            return False
    return True

N = int(input())
cnt = 0
for i in range(N):
    e = int(input())
    if is_prime(e):
        cnt += 1
print(cnt)
M = input()
lis =list(M)
count = 0
for item in lis:
  if item == ‘1’:
    count += 1
print (count)

### FIXED CODE ###

lis = list(input())
count = 0
for item in lis:
    if item == "1":
        count += 1
print (count)
n = int(input())
nums = list(map(int, input().split(' ')))
count = []
for i in range(n):
  if num[i] > num[i+1]:
    count.append(1)
print(len(count))


### FIXED CODE ###

n=int(input())
h=[int(i) for i in input().split()]
c=0
d=c
for i in range(n-1):
    if h[i]>=h[i+1]:
        c+=1
    else:
        d=max([c,d])
        c=0

print(max([c,d]))
a,b,c=map(int,raw_input().split()b
if a<b and b<c:
  print str(a) + ' ' + str(b) + ' ' + str(c)
elif a<c and c<b:
  print str(a) + ' ' + str(c) + ' ' + str(b)
elif b<a and a<c:
  print str(b) + ' ' + str(a) + ' ' + str(c)
elif b<c and c<a:
  print str(b) + ' ' + str(c) + ' ' + str(a)
elif c<b and b<a:
  print str(c) + ' ' + str(b) + ' ' + str(a)
elif c<a and a<b:
  print str(c) + ' ' + str(a) + ' ' + str(b)
elif a==b and a<c
  print str(a) + ' ' + str(b) + ' ' + str(c)
elif a==b and a>c
  print str(c) + ' ' + str(a) + ' ' + str(b)
elif a==c and a<b
  print str(a) + ' ' + str(c) + ' ' + str(c)
elif a==c and a>b
  print str(b) + ' ' + str(a) + ' ' + str(c)
elif b==c and a<c
  print str(a) + ' ' + str(b) + ' ' + str(c)
elif b==c and a>c
  print str(b) + ' ' + str(c) + ' ' + str(a)
else:
  print str(a) + ' ' + str(b) + ' ' + str(c)

### FIXED CODE ###

a = map(int, raw_input().split())
a.sort()
for i in range(len(a)):
    print a[i],
import itertools as it

n,m=map(int,input().split())
ans=[]
for i in range(n):
    a,b=map(int,input().split())
    ans.append([a,b])
    ans.append([b,a])
  
a=0
for e in it.permutations(range(n)):
    #print(e)
    count=1
    if e[0]!=0:
        break
    
    for i in range(n-1):
        if [e[i]+1,e[i+1]+1] in ans:
            count*=1
        else:
            count*=0
            break
            
    a+=count
    
print(a)

### FIXED CODE ###

import itertools as it
import sys

N, M = map(int, input().split())
if N==0 or M==0:
    print(0)
    sys.exit()
a=[]

for i in range(M):
    x,y=map(int,input().split())
    a.append([x,y])
    a.append([y,x])

ans=0
for e in it.permutations(range(N)):
    if e[0]!=0:
        break
        
    count=1
    for j in range(N-1):
        if [e[j]+1,e[j+1]+1] in a:
            count*=1
        else:
            count*=0
            break
            
    ans+=count

print(ans)
A, B = input.split()
n = int(A) + int(B)
if n % 3 == 0:
    print(Possible)
else:
    print(Impossible)

### FIXED CODE ###

A, B = input().split()
A, B = int(A), int(B)
n = int(A) + int(B)
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
    print('Possible')
else:
    print('Impossible')
N, M = map(int, input().split())
a_list = list(map(int, input().split()))

items = {
    1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6
}
dp = [0] * (N + 1)

b_list = []
for a in a_list:
    need = items[a]
    if need <= N:
        dp[need] = a
        b_list.append(a)

M = len(b_list)
b_list.sort()
for i in range(N + 1):
    for b in b_list:
        if i - items[b] >= 0:
            if dp[i - items[b]] != 0:
                cnt = 0
                num = dp[i - items[b]]
                while num >= 1:
                    cnt += 1
                    num //= 10
                tmp = max(b * (10 ** cnt) + dp[i - items[b]], dp[i - items[b]] * 10 + b)
                dp[i] = max(tmp, dp[i])
print(dp[N])


### FIXED CODE ###

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

if B % A == 0:
    print(A+B)
else:
    print(B-A)
a = int(input())
b = int(input())
 
if a >= 13:
  print(b)
elif a >= 6 && a <= 12:
  print(b/2)
else:
  print(0)

### FIXED CODE ###

a,b = map(int, input().split())
 
ans=0
if a <= 5:
	ans = 0
elif a >= 6 and a<=12:
	ans = b/2
else:
	ans = b
 
print(int(ans))
a,b=map(int,imput().split())
Hantei=(a * b) % 2
if Hantei == 1:
    print("Odd")
else:
    print("Even")


### FIXED CODE ###

a,b=input().split()
a=int(a)
b=int(b)
Hantei=(a * b) % 2
if Hantei == 1:
    print("Odd")
else:
    print("Even")
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
from numba import njit

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
L = LI()

def test(a,b,c):
    if a<b+c and b<c+a and c<a+b:
        return True
    return False

@ njit
def comb():
    count = 0
    for pair in itertools.combinations(L, 3):
        if test(*pair):
            count += 1
    return count

print(print(comb()))
 
# @njit
# def f(A):
#   count = 0
#   for i in range(N):
#     for j in range(i + 1, N):
#       for k in range(j + 1, N):
#         count += (A[k] < A[i] + A[j])
#   return count
 
# A = np.array(L)
# A.sort()
# print(f(A))        


### FIXED CODE ###

import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
L = LI()
# L = np.array(_L)
#C = np.zeros(N + 1)

# def test(a,b,c):
#     if a<b+c and b<c+a and c<a+b:
#         return True
#     return False

# count = 0
# for pair in itertools.combinations(L, 3):
#     # print(pair)
#     if test(*pair):
#         count += 1
# print(count)

# for i in range(N):
#     for j in range(i+1,N):

from numba import njit
 
@njit
def f(A):
  count = 0
  for i in range(N):
    for j in range(i + 1, N):
      for k in range(j + 1, N):
        count += (A[k] < A[i] + A[j])
  return count
 
A = np.array(L)
A.sort()
print(f(A))
import numpy as np
 
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
  
def isPrime(n):
  if n < 2:
    # 2未満は素数でない
    return False
  if n == 2:
    # 2は素数
    return True
  for p in range(2, n):
      if n % p == 0:
        # nまでの数で割り切れたら素数ではない
        return False
  # nまでの数で割り切れなかったら素数
  return True
 
A,B = list(map(int,input().split()))
 
aaa = []
 
aaa = make_divisors(np.gcd(A,B))
        
count = 0
 
for i in range(len(aaa)):
    if isPrime(aaa[i]) == True:
        count += 1
        
print(count+1)

### FIXED CODE ###

from fractions import gcd
 
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
  
def isPrime(n):
  if n < 2:
    # 2未満は素数でない
    return False
  if n == 2:
    # 2は素数
    return True
  for p in range(2, int(n**0.5)+1):
      if n % p == 0:
        # nまでの数で割り切れたら素数ではない
        return False
  # nまでの数で割り切れなかったら素数
  return True
 
A,B = list(map(int,input().split()))
 
aaa = []
 
aaa = make_divisors(gcd(A,B))
        
count = 0
 
for i in range(len(aaa)):
    if isPrime(aaa[i]) == True:
        count += 1
        
print(count+1)
a,b,c = map(int,input.split())
print(b*int(c/a))


### FIXED CODE ###

a,b,c = map(int,input().split())
print(b*int(c/a))
from collections import deque
s = list(str(input()))
ans = deque()
for i in s:
  if i == "B":
    if ans == []:
      continue
    else:
      ans.pop()
  else:
    ans.append(i)
print("".join(ans))

### FIXED CODE ###

from collections import deque
s = list(str(input()))
ans = deque()
for i in s:
  if i == "B":
    if ans == deque([]):
      continue
    else:
      ans.pop()
  else:
    ans.append(i)
print("".join(ans))
from collections import deque

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

dir = [(-1, 0), (1, 0), (0, -1), (0, 1)]

dist = [[-1] * W for _ in range(H)]

def BFS(y, x):
  """(y, x)からはじめて、道のマスをBFSで最短距離を探す"""
  que = deque()
  que.append((y, x))
  dist[y][x] = 0
  max_dist = 0
  while que:
    sy, sx = que.popleft()  # popleft?
    for dy, dx in dir:
      ny = sy + dy
      nx = sx + dx
      if 0 <= ny < H and 0 <= nx < W and S[ny][nx] != "#" and dist[ny][nx] == -1:
        que.append((ny, nx))
        dist[ny][nx] = dist[sy][sx] + 1
        max_dist = max(max_dist, dist[ny][nx])
  
  return max_dist

max_dist = 0
for sy in range(H):
  for sx in range(W):
    if S[sy][sx] != "#":
      dist = [[-1] * W for _ in range(H)]
      max_dist = max(max_dist, BFS(sy, sx))
      
print(max_dist)

### FIXED CODE ###

C = input()
D = chr(ord(C)+1)

print(D)
import numpy as np
import sys
n,k = map(int,input().split())
a_list = sorted(map(int,input().split()))
mod = 10**9+7
if False:
  print("test")
else:
    a_list.sort(key = abs,reverse = True)
    add = 1
    remove = 1
    if len([a for a in a_list[:k] if np.sign(a)==-1])%2!=0:
        negative_big = [num for num in a_list[:k] if np.sign(num)==-1]
        positive_big = [num for num in a_list[:k] if np.sign(num)!=-1]
        negative_small = [num for num in a_list[k:] if np.sign(num)==-1]
        positive_small = [num for num in a_list[k:] if np.sign(num)!=-1]
        
        
        
        if True:
            positive_small_max = max(positive_small)
            negative_big_max = max(negative_big)
            negative_small_min = min(negative_small)
            positive_big_min = min(positive_big)
            if positive_small_max/negative_big_max < negative_small_min/positive_big_min:
                remove = negative_big_max
                add = positive_small_max
            else:
                remove = positive_big_min
                add = negative_small_min
ans = 1
for num in a_list[:k]:
    ans *= num
    ans %= mod
    
if len([a for a in a_list[:k] if np.sign(a)==-1])%2!=0:
    ans *= add
    ans %= mod
    ans *= pow(remove, mod-2, mod)
    ans %= mod

print(ans)


### FIXED CODE ###

import numpy as np
import sys
n,k = map(int,input().split())
a_list = sorted(map(int,input().split()))
mod = 10**9+7
if n-k < a_list.count(0):
    print(0)
    exit()
if (sum([1 for a in a_list if np.sign(a)!=-1])==0 and k%2==1) or (k==n and len([1 for a in a_list if np.sign(a)==-1])%2==1):
    a_list.sort(key = abs)
    ans = 1
    for num in a_list[:k]:
        ans *= num
        ans %= mod
    print(ans)
    exit()
else:
    a_list.sort(key = abs,reverse = True)
    add = 1
    remove = 1
    if len([a for a in a_list[:k] if np.sign(a)==-1])%2!=0:
        negative_big = [num for num in a_list[:k] if np.sign(num)==-1]
        positive_big = [num for num in a_list[:k] if np.sign(num)!=-1]
        negative_small = [num for num in a_list[k:] if np.sign(num)==-1]
        positive_small = [num for num in a_list[k:] if np.sign(num)!=-1]
        
        
        if len(negative_big)==0 or len(positive_small)==0:
            remove = min(positive_big)
            add = min(negative_small)
        elif len(positive_big)==0 or len(negative_small)==0:
            remove = max(negative_big)
            add = max(positive_small)
        else:
            positive_small_max = max(positive_small)
            negative_big_max = max(negative_big)
            negative_small_min = min(negative_small)
            positive_big_min = min(positive_big)
            if positive_small_max*positive_big_min > negative_small_min*negative_big_max:
                remove = negative_big_max
                add = positive_small_max
            else:
                remove = positive_big_min
                add = negative_small_min
ans = 1
for num in a_list[:k]:
    ans *= num
    ans %= mod
    
if len([a for a in a_list[:k] if np.sign(a)==-1])%2!=0:
    ans *= add
    ans %= mod
    ans *= pow(remove, mod-2, mod)
    ans %= mod

print(ans)
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
p = l()
count = 0

for i in range(N):
    if p[i] == i+1:
        p[i],p[i+1] = p[i+1],p[i]
        count += 1
    else:
        pass

print(count)


### FIXED CODE ###

N = int(input())
p = list(map(int, input().split()))
count = 0
i = 0

while N > i:
    if p[i]-1 == i:
        count += 1
        i += 1
    i+=1
print(count)
from scipy.special import perm, comb
N, K = [int(p) for p in input().split(" ")]

def nHr(n, r):
    return comb(n+r-1, r, exact=True)

MOD = 10**9 + 7
def f(i):
    if N-K-i+1 >= 0:
        return nHr(i, K-i) * nHr(i+1, N-K-i+1) % MOD
    return 0
for i in range(K):
    print(f(i+1))

### FIXED CODE ###

N, K = [int(p) for p in input().split(" ")]

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

def nHr(n, r):
    return comb(n+r-1, r, mod)

mod = 10**9 + 7
def f(i):
    if N-K-i+1 >= 0:
        return nHr(i, K-i) * nHr(i+1, N-K-i+1) % mod
    return 0

for i in range(K):
    print(f(i+1))
A,B = map(input,int.split())
if A < 10 and B < 10:
    print(A * B)
else:
    print(-1)

### FIXED CODE ###

A, B = map(int,input().split()) 
if A < 10 and B < 10:
    print(A * B)
else:
    print(-1)
#!/usr/bin/env python3

from functools import lru_cache


a = {-1}

@lru_cache(maxsize=None)
def near(g):
    d = 99999999
    v = g
    for i in a:
        if abs(g-i) < d:
            d = abs(g-i)
            v = i
    return v


@lru_cache(maxsize=None)
def solv1(n, g):
    if n in a:
        return 0
    if n-g == 0:
        return 1
    if n-g < 0:
        return 0
    count = 0
    if (n-2) not in a:
        count += solv1(n-2, g)
    if (n-1) not in a:
        count += solv1(n-1, g)
    return count


def solv(n, a):
    if n < 100:
        return solv1(n, 0)
    g = near(n // 2)
    if g > 15:
        return solv1(g+1, 0) * solv1(n, g+1)
    else:
        return solv1(g-1, 0) * solv1(n, g-1)


if __name__ == '__main__':

    n, m = map(int, input().split())
    for _ in range(m):
        a.add(int(input()))

    ans = solv(n, a)

    print(ans % 1000000007)


### FIXED CODE ###

#!/usr/bin/env python3

import math
from functools import lru_cache


def ncr(n, r):
    r = min(r, n - r)
    # 桁が小さいときは直接 math.factorial を使ったほうが早い
    if n + r < 4000:
        return math.factorial(n) // math.factorial(n-r) // math.factorial(r)
    if r == 0:
        return 1
    if r == 1:
        return n
    numerator = list(range(n - r + 1, n + 1))
    denominator = list(range(1, r+1))
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] //= pivot
                denominator[k] //= pivot
    result = 1
    for k in range(r):
        result *= numerator[k]
    return result


# 穴なしで n step 離れている場合の組み合わせ
def no_hole(n):
    count = 0
    m = n // 2
    for i in range(0, m+1):
        count += ncr(n-i, i)
    return count


# 穴なしで n step 離れている場合の組み合わせ(高速化版)
@lru_cache(maxsize=8192)
def no_hole2(n):
    if n <= 5:
        return (1, 1, 2, 3, 5, 8)[n]
    if n % 2:
        h = (n-1) // 2
        m1 = no_hole2(h-1)
        m0 = no_hole2(h)
        return 2 * m1 * m0 + m0 * m0
    else:
        h = n // 2
        m2 = no_hole2(h-2)
        m1 = no_hole2(h-1)
        m0 = no_hole2(h)
        return m1 * m1 + m2 * m0 + m1 * m0


def solv(n, m, a):
    ans = 1
    current_pos = 0
    for pos in a:
        dist = pos - 1 - current_pos
        if dist < 0:
            return 0
        ans *= no_hole2(dist)
        current_pos = pos + 1
    dist = n - current_pos
    ans *= no_hole2(dist)
    return ans


if __name__ == '__main__':

    n, m = map(int, input().split())
    a = [int(input()) for _ in range(m)]

    ans = solv(n, m, a)

    P_NUM = 1000000007
    print(ans % P_NUM)
N = int(input())
 
t = [int(input().split()) for i in range(N)]
 
M = int(input())
 

a = list(map(int, input().split()))      
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])

### FIXED CODE ###

N = int(input())
 
t = list(map(int, input().split()))
 
M = int(input())
 
cal = sum(t)
 
for j in range(M):
    p, x = map(int, input().split())
    print(cal - t[p - 1] + x)
n,k = map(int,input().split())
A = list(map(int,input().split()))
B = []
B.append(A[0])
b = 1
ans = 1
while ans:
  a = A[b-1]
  b = A[a-1]
  B.append(b)
  if len(B) == len(A):
    ans = 0

print(B[k])


### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
pos = 0
visit = [0] * N
move = []
roop = []
while visit[pos]!=2:
    if visit[pos]==0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos] += 1
    pos = A[pos] - 1
if len(move)>K:
    print(move[K]+1)
else:
    print(roop[(K-(len(move)-len(roop)))%len(roop)]+1)
N = int(input())
inside_str = 0
tail_a = 0
head_b = 0
 
doubleAB = 0
 
for i in range(N):
  str = input()
  inside_str = inside_str + str.count('AB')
  
  if(str[-1] == 'A' and str[0] == 'B'):
  	doubleAB = doubleAB + 1
  elif (str[-1] == 'A'):
    tail_a = tail_a + 1
  elif (str[0] == 'B'):
    head_b = head_b + 1
 
if(tail == 0 and head_b == 0):
  total_cand = inside_str + doubleAB - 1
else:
  total_cand = inside_str + doubleAB + min(tail_a, head_b)
 

### FIXED CODE ###

N = int(input())
inside_str = 0
tail_a = 0
head_b = 0
 
doubleAB = 0
 
for i in range(N):
  str = input()
  inside_str = inside_str + str.count('AB')
  
  if(str[-1] == 'A' and str[0] == 'B'):
  	doubleAB = doubleAB + 1
  elif (str[-1] == 'A'):
    tail_a = tail_a + 1
  elif (str[0] == 'B'):
    head_b = head_b + 1
 
if(tail_a == 0 and head_b == 0):
  if(doubleAB == 0):
    total_cand = inside_str
  else:
    total_cand = inside_str + doubleAB - 1
else:
  total_cand = inside_str + doubleAB + min(tail_a, head_b)

print(total_cand)
n=int(input())
a=list(map(int,input().split()))
b=a[1::2][::-1]+a[0::2]
print((*b,*(b[::-1]))[n%2>0])


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
bbottom=[]
btop=[]
for i in range(n):
  if i%2==0:
    bbottom.append(a[i])
  else:
    btop.append(a[i])
ans=btop[::-1]+bbottom
if n%2==1:
  ans=ans[::-1]
print(*ans)
i=1
while True:
    x=int(input())
    if(x==0):
        break
    print(f"Case {i}: {x}")
    i++



### FIXED CODE ###

i=1
while True:
    x=int(input())
    if(x==0):
        break
    print(f"Case {i}: {x}")
    i+=1
S = raw_input()

print S[0:4] + " " + s[4:12]

### FIXED CODE ###

S = raw_input()

print S[0:4] + " " + S[4:12]