Harryxun/stf_run huggingface dataset:
N, M = map(int, input().split())
al = []
for i in range(M):
  al.append(tuple(input().split()))
al_a = [i[0] for i in al if i[1] == 'AC']
al_a = list(set(al_a))
r1 = len(al_a)
r2 = 0
for j in al:
  if j[1] == 'AC':
    al_a.remove(j[0])
  elif j[0] in al_a:
    r2 += 1
    
print(r1 ,r2)

### FIXED CODE ###

def main():
    n, m = map(int, input().split())
    ac = [0] * n
    wanum = [0] * n
    for _ in range(m):
        p, s = input().split()
        p = int(p) - 1
        if ac[p]:
            continue
        else:
            if s == 'AC':
                ac[p] = 1
                wanum[p] *= -1
            else:
                wanum[p] -= 1
    wanum2 = [i for i in wanum if i > 0]
    print(sum(ac), sum(wanum2))

if __name__ == '__main__':
    main()
S = input()
K = int(input())

for i in range(len(S)):
    if S[i] != '1':
        print(int(S[i]))
        break
    else:
        if i == N - 1:
            print(1)
            break
        else:
            continue


### FIXED CODE ###

S = input()
K = int(input())

for i in range(len(S)):
    if S[i] != '1':
        print(int(S[i]))
        break
    else:
        if i == K - 1:
            print(1)
            break
        else:
            continue
import math
import itertools

L, R = map(int, input().split())

mods = []

for c in itertools.combinations(range(L, R+1), 2):
    # print(c)
    mods.append((c[0]*c[1]) % 2019)
    
print(min(mods))

### FIXED CODE ###

import itertools

L, R = map(int, input().split())

R = min(R, L+2019)

mods = []

for c in list(itertools.combinations(list(range(L, R+1)),2)):
    mods.append((c[0]*c[1]) % 2019)

print(min(mods))
N = int(input())

es = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int, input().split())
    a,b = a-1, b-1
    es[a].append(b)
    es[b].append(a)

"""
相手の取れるマス目を減らすようにとるとよい
相手よりそのマスに近ければそのマスを取得できる
フェネックくん、すぬけ君について初期地点からそれぞれへの距離が必要
"""
def solve(now, depth, depth_list, es, visited):
    visited[now] = True
    depth_list[now] = depth
    for next in es[now]:
        if visited[next] == False:            
            solve(next, depth+1, depth_list, es, visited)

depth_list_F = [0] * N
visited_F = [False] * N
solve(0, 0, depth_list_F, es, visited_F)

depth_list_S = [0] * N
visited_S = [False] * N
solve(N-1, 0, depth_list_S, es, visited_S)

cnt_F = cnt_S = 0
for f,s in zip(depth_list_F, depth_list_S):
    if f <= s:
        cnt_F += 1 # フェネック君から始めるので同じ距離ならフェネック君がとる
    else:
        cnt_S += 1

if cnt_F > cnt_S:
    print("Fennec")
else:
    print("Snuke")

### FIXED CODE ###

N = int(input())
import sys
sys.setrecursionlimit(N+10)

es = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int, input().split())
    a,b = a-1, b-1
    es[a].append(b)
    es[b].append(a)

"""
相手の取れるマス目を減らすようにとるとよい
相手よりそのマスに近ければそのマスを取得できる
フェネックくん、すぬけ君について初期地点からそれぞれへの距離が必要
"""
def solve(now, depth, depth_list, es, visited):
    visited[now] = True
    depth_list[now] = depth
    for next in es[now]:
        if visited[next] == False:            
            solve(next, depth+1, depth_list, es, visited)

depth_list_F = [0] * N
visited_F = [False] * N
solve(0, 0, depth_list_F, es, visited_F)

depth_list_S = [0] * N
visited_S = [False] * N
solve(N-1, 0, depth_list_S, es, visited_S)

cnt_F = cnt_S = 0
for f,s in zip(depth_list_F, depth_list_S):
    if f <= s:
        cnt_F += 1 # フェネック君から始めるので同じ距離ならフェネック君がとる
    else:
        cnt_S += 1

if cnt_F > cnt_S:
    print("Fennec")
else:
    print("Snuke")
def t()
    N = int(input())
    A = list(map(int, input().split()))
    T = 1
    for i in A:
        T *= i
    if T > 10 ** 18:
        print(-1)
    else:
        print(T)

t()

### FIXED CODE ###

def t():
    N = int(input())
    A = list(map(int, input().split()))
    T = 1
    if 0 in A:
        return 0
    for i in A:
        T *= i
        if T > 10 ** 18:
            return -1
    return T
print(t())
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

dp = [[-1 for i in range(n+2)] for j in range(m+2)]
def find(i, j, sum):
    if sum >= k:
        return 0
    if i < len(a) and j < len(b) and dp[i][j] != -1:
        return dp[i][j]
    dp[i][j] = 0
    if j < len(b) and sum + b [j] <= k :
        dp[i][j] = 1 + find(i , j+1, sum+b[j])
    if i < len(a) and sum + a[i] <= k :
        dp[i][j] = max(dp[i][j], 1 + find(i+1, j, sum+a[i]))
    return dp[i][j]

print(find(0, 0, 0))


### FIXED CODE ###


import sys

for a0 in range(1):
    n,m,x = input().strip().split(' ')
    n,m,x = [int(n),int(m),int(x)]
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    a.reverse()
    b.reverse()
    total = 0
    atmp = []
    for i in range(n):
        val = a.pop()
        if total + val > x:
            break
        total += val 
        atmp.append(val)

    max_count = len(atmp)
    cur_count = max_count
    while m:
        if total + b[-1] <= x:
            total += b.pop() 
            m -= 1
            cur_count += 1
            if cur_count > max_count:
                max_count = cur_count
            continue
        if not len(atmp):
            break
        aval = atmp.pop()
        total -= aval
        cur_count -= 1
    print (max_count)
from operator import mul
from functools import reduce
 
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    elif n<r: return 0
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
md=10**9+7
n,k=map(int,input().split())
for i in range(1,k+1):
  a=cmb(n-k+1,i)*cmb(k-1,i-1)
  a=a%md
  print(a)

### FIXED CODE ###

import math
def cmb(n, r):
  if n < r : return 0
  else : return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
md=10**9+7
n,k=map(int,input().split())
for i in range(1,k+1):
  a=cmb(n-k+1,i)*cmb(k-1,i-1)
  a=a%md
  print(a)
import math
K = int(input())

sum = 0
for i in range(1,K+1):
	for j in range(1,K+1):
		temp = math.gcd(i,j)
		for m in range(1,K+1):
			sum = sum + math.gcv(temp,m)

print(sum)

### FIXED CODE ###

import math
K = int(input())

sum = 0
for i in range(1,K+1):
	for j in range(1,K+1):
		temp = math.gcd(i,j)
		for m in range(1,K+1):
			sum = sum + math.gcd(temp,m)

print(sum)
N = int(input())

if N >= 100 && N[2] == 3:
  print('bon')
elif N >= 100 && N[2] == 1 or N[2] == 0 or N[2] == 6 or N[2] == 8:
  print('pon')
elif N >= 100 && N[2] == 2 or N[2] == 4 or N[2] == 5 or N[2] == 7 or N[2] == 9:
  print('hon')
elif N < 100 && N[1] == 3:
  print('bon')
elif N < 100 && N[1] == 1 or N[1] == 0 or N[1] == 6 or N[1] == 8:
  print('pon')
else:
  print('hon')

### FIXED CODE ###

N = input()
 
if N[-1] == '3':
  print('bon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
  print('pon')
else:
  print('hon')
N, D = map(int, input().split())

count = 0

for i in N:
  x, y = map(int, input().split())
  if D > pow(x**2+y**2, 0.5):
    count += 1
  else:
    continue
    
print(count)

### FIXED CODE ###

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

count = 0

for i in range(N):
    x, y = map(int, input().split())
    if D >= pow(x**2+y**2, 0.5):
        count += 1
    
print(count)
l,r = map(int,input().split())

if (l==2019)or(r==2019)or(r-l>=2019):
    print('0')
    
elif r-l==1:
    ans = (r*l)%2019
else:
    ans=2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            if (i*j)%2019 < ans:
                ans = (i*j)%2019
            if ans == 1:
                break
            
print(str(ans))

### FIXED CODE ###

l,r = map(int,input().split())

if (l==2019)or(r==2019)or(r-l>=2019):
    ans=0
    
elif r-l==1:
    ans = (r*l)%2019
else:
    ans=2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            if (i*j)%2019 < ans:
                ans = (i*j)%2019
            if ans == 1:
                break
print(str(ans))
n, a, b = (int(x) for x in input().split())
if (b-a) % 2 == 0:
  ans = (b-a) // 2
else:
  ans = min(a-1,n-b)+1+(b−a−1)//2
print(ans)

### FIXED CODE ###

n, a, b = (int(x) for x in input().split())
if (b - a) % 2 == 0:
	ans = (b-a) // 2
else:
	ans = min(a-1, n-b) + 1 + (b-a-1)//2
print(ans)
N = int(input())


#整数N以下の素数を#素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a = prime_factorize(N)
b = set(a)

dic = {}
for i in b:
    n = 0
    while True:
        n += 1
        a.pop(0)
        if a == []:
            break
        if a[0] != i:
            break
    dic[i] = n


an = 0
for k, v in dic.items():
    num = int((-1+(1+8*v)**(1/2))/2)
    an += num

print(an)


### FIXED CODE ###

N = int(input())


#整数N以下の素数を#素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a = prime_factorize(N)
b = set(a)

dic = {}
for i in b:
    n = 0
    while True:
        n += 1
        if a == []:
            break
        a.pop(0)
        if a == []:
            break
        if a[0] != i:
            break
    dic[i] = n


an = 0
for k, v in dic.items():
    num = int((-1+(1+8*v)**(1/2))/2)
    an += num

print(an)
def resolve():
    a, b,c,k = map(int, input().split())

    ans = 0
    used = min(k,a)
    ans += used * 1
    k -= used
    used = min(k, b)
    k -= used
    ans += k*(-1)
    print(ans)

if __name__ == "__main__":
    unittest.main()

### FIXED CODE ###


def resolve():
    A, B, C, K = map(int, input().split())

    ans = 0
    cnt = min(K, A)
    ans += cnt * 1
    K -= cnt
    if K < 1:
        return print(ans)

    cnt = min(K, B)
    ans += cnt * 0
    K -= cnt
    if K < 1:
        return print(ans)

    ans += K * -1

    print(ans)

if __name__ == "__main__":
    resolve()
# coding: utf-8

import sys

def _main():
    # args = sys.argv[1:]
    # args = [int(arg) for arg in args]
    datelist = sys.argv[1].split('/')
    year, month, day = [int(i) for i in datelist]

    if year< 2019:
        print('Heisei')
    elif year == 2019:
        if month<4:
            print('Heisei')
        elif month == 4:
            if day <= 30:
                print('Heisei')
            else:
                print('TBD')
        else:
            print('TBD')
    else:
        print('TBD')

if __name__ == '__main__':
    _main()

### FIXED CODE ###

# coding: utf-8

import sys

def _main():
    # args = sys.argv[1:]
    # args = [int(arg) for arg in args]
    text = input()
    datelist = text.split('/')
    year, month, day = [int(i) for i in datelist]

    if year< 2019:
        print('Heisei')
    elif year == 2019:
        if month<4:
            print('Heisei')
        elif month == 4:
            if day <= 30:
                print('Heisei')
            else:
                print('TBD')
        else:
            print('TBD')
    else:
        print('TBD')

if __name__ == '__main__':
    _main()
# -*- coding: utf-8 -*-
"""
Created on Wed May  2 21:28:06 2018
ALDS1_5a_r2  Time Limit Exceeded
@author: maezawa
"""

n = int(input())
a = list(map(int, input().split()))
q = int(input())
m_array = list(map(int, input().split()))
can_c_array = [[None for _ in range(m)] for _ in range(n)]

def can_comp(i, m): #i番目以降の数列をつかってmを作れるか？
    if m == 0:
        return True
    elif i == n:
        return False
    else:
        if can_c_array[i+1][m] == None:
            c1 = can_comp(i+1, m)
            can_c_array[i+1][m] = c1
        else:
            c1 = can_c_array[i+1][m] 
        if can_c_array[i+1][m-a[i]] == None:
            c2 = can_comp(i+1, m-a[i])
            can_c_array[i+1][m-a[i]] = c2
        else:
            c2 = can_c_array[i+1][m-a[i]]     
        return c1 or c2

for m in m_array:
    if can_comp(0, m):
        print('yes')
    else:
        print('no')



### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed May  2 21:28:06 2018
ALDS1_5a_r1  
@author: maezawa
"""
import itertools as itr

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

sum_array = []
for r in range(1,n+1):
    for comb in itr.combinations(a, r):
        sum_array.append(sum(comb))
sum_array.sort()

for i in m:
    left = 0
    right = len(sum_array)
    yesorno = 'no'
    while(left < right):
        #print(left, right)
        mid = (left+right)//2
        if sum_array[mid] == i:
            yesorno = 'yes'
            break
        elif sum_array[mid] > i:
            right = mid
        else:
            left = mid+1
            
    print(yesorno)
N, K = map(int, input().split())
S = list(input())
S[K-1] = S[K-1].lower()
print(sum(S))

### FIXED CODE ###

N, K = map(int, input().split())
S = list(input())
S[K-1] = S[K-1].lower()
print("".join(S))
r = input(int())
print(3 * r ** 2)

### FIXED CODE ###

r = int(input())
print(3 * r ** 2)
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
l = [-1]*n
flag = True
for i in range(m):
    s,c = iim()
    if l[s-1] != -1 and l[s-1] != c:
        flag = False
    else:
        l[s-1] = c

if n > 1 and l[0] == 0:
    flag = False

ans = ''
for i,item in enumerate(l):
    if item == -1:
        if i == 0 and n > 1:
            ans += '1'
        else:
            ans += '0'
    else:
        ans += str(item)
print(ans if flag else -1)


### FIXED CODE ###

n = int(input())
print(n//2+n%2)
n, t =map(int, input().split())
l = [tuple(map(int, input().split())) for i in range(n)]
m = sorted([i for i in l if i[1] <= t])
print(m[0][0])

### FIXED CODE ###

n, t =map(int, input().split())
l = [tuple(map(int, input().split())) for i in range(n)]
m = [i for i in l if i[1] <= t]
if m == []:
  print("TLE")
else:
  m.sort()
  print(m[0][0])
def main():
  S=input()
  s=0
  N=len(S)
  for i in range(N//2):
    if S[i]!=S[N-1-i]:
      S[N-1-i]=S[i]
      s+=1
    else:
      s=s
  print(s)
main()

### FIXED CODE ###

def main():
  S=input()
  s=0
  N=len(S)
  for i in range(N//2):
    if S[i]!=S[N-1-i]:
      s+=1
  print(s)
main()
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
for i in range(n-1):
  if a[i]!=a[i+1]-1:
    c[a[i]]=0
print(sum(b)+sum(c))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
c.append(0)
for i in range(n-1):
  if a[i]!=a[i+1]-1:
    c[a[i]-1]=0
c[a[n-1]-1]=0
print(sum(b)+sum(c))
N, M = map(int, raw_input().split())

res = 1
for i in range(1, M + 1):
	if i * i > M:
		break
	if M % i != 0:
		continue
	j = M / i
	if long(i) * N <= M:
		res = max(res, i)
	if long(j) * N <= M:
		res = max(res, j)
print res


### FIXED CODE ###

import math
N, M = map(int, raw_input().split())

MAX_RES = int(math.sqrt(M))
res = 1
for i in range(1, MAX_RES + 1):
	if i * i > M:
		break
	if M % i != 0:
		continue
	j = M / i
	if i * N <= M:
		res = max(res, i)
	if j * N <= M:
		res = max(res, j)
print res
S = str(input())

if S = 'ABC':
  print('ARC')
  
else:
  print('ABC')

### FIXED CODE ###

S = str(input())

if S == 'ABC':
  print('ARC')
  
else:
  print('ABC')
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#n = ip()                              #入力整数1つ
#h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
print(a[0],end=“”)
print(len(a)-2,end=“”)
print(a[len(a)-1])


### FIXED CODE ###

from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("Heisei")
    else:print("TBD")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
#h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
l = len(a)
print(a[0],end='')
print(l-2,end='')
print(a[l-1])
a,b = int(input().split())

if 1 <= a <= 9 and 1 <= b <= 9:
	print(a * b)
else:
	print('-1')	
	

### FIXED CODE ###

a, b = map(int, input().split())
if a <= 9 and b <= 9:
	c = a * b
	print(c)
else:
	print('-1')
A,B,M = [int(x) for x in input().split()]
A_list = [int(x) for x in input().split()]
B_list = [int(y) for y in input().split()]
discount = []
min = 10000000
for _ in range(M):
  case = [int(x) for x in input().split()]
  discount.append(case)

min_a = sorted(A_list)[0]
min_b = sorted(B_list)[0]

for i in range(M):
  temp = A_list[discount[i][0]-1] + B_list[discount[i][1]-1] - discount[i][2]
  if temp < min:
    min = temp
    
if min_a + min_b > min:
  print(min)
else:
  print(min_a + min_b)

### FIXED CODE ###

S = input()
ans = True
for i in range(0,len(S)-1,2):
  if S[i] != "h" or S[i+1] != "i":
    ans = False
    break
if not ans or len(S)%2 == 1:
  print("No")
else:
  print("Yes")
strN = input()
s = 0
for c in strN:
  s += int(c)

  if s % 9 == 0:
    print("Yes")
    else:
      print("No")

### FIXED CODE ###


strN = input()
s = 0
for c in strN:
  s += int(c)

if s % 9 == 0:
  print("Yes")
else:
  print("No")
from pprint import pprint
import heapq

def solve(n, a, b):
    b_pq = []
    b_rev = {}
    for i, b_i in enumerate(b):
        heapq.heappush(b_pq, (-1 * b_i, i))

    count = 0
    while b_pq:
        tmp = heapq.heappop(b_pq)
        # pprint(tmp)
        b_i = tmp[0] * -1
        i_b = tmp[1]
        # print(i_b, b_i)
        i_a = (i_b - 1 + n) % n
        i_c = (i_b + 1) % n
        b_cand = b_i
        if b_cand - b[i_a] - b[i_c] < a[i_b]:
            continue

        #while b_cand - b[i_a] - b[i_c] >= a[i_b]:
        #    b_cand = b_cand - b[i_a] - b[i_c]
        #    count += 1
        tmp_count =  b_cand // (b[i_a] + b[i_c])
        b_cand -= (b[i_a] + b[i_c]) * tmp_count
        count += tmp_count

        b[i_b] = b_cand
        heapq.heappush(b_pq, (-1 * b_cand, i_b))
        # print("count: ", count)
        # pprint(b)
        if b_cand == a[i_b] and b == a:
            return count
    
    return -1


if __name__ == '__main__':

    n = int(input().strip())
    a = list(map(int, input().strip().split(" ")))
    b = list(map(int, input().strip().split(" ")))
    print(solve(n, a, b))

### FIXED CODE ###

from pprint import pprint
import heapq

def solve(n, a, b):
    b_pq = []
    b_rev = {}
    delete = []
    for i, b_i in enumerate(b):
        if b_i == a[i]:
            continue
        heapq.heappush(b_pq, (-1 * b_i, i))

    count = 0
    while b_pq:
        tmp = heapq.heappop(b_pq)
        # pprint(tmp)
        b_i = tmp[0] * -1
        i_b = tmp[1]
        # print(i_b, b_i)
        i_a = (i_b - 1 + n) % n
        i_c = (i_b + 1) % n
        b_cand = b_i
        if b_cand - b[i_a] - b[i_c] < a[i_b]:
            continue

        #while b_cand - b[i_a] - b[i_c] >= a[i_b]:
        #    b_cand = b_cand - b[i_a] - b[i_c]
        #    count += 1
        tmp_count =  (b_cand - a[i_b]) // (b[i_a] + b[i_c])
        b_cand -= (b[i_a] + b[i_c]) * tmp_count
        count += tmp_count

        b[i_b] = b_cand
        if b_cand != a[i_b]:
            heapq.heappush(b_pq, (-1 * b_cand, i_b))
        # print("count: ", count)
        # pprint(b)
         

        if b_cand == a[i_b] and b == a:
            return count
    
    return -1


if __name__ == '__main__':

    n = int(input().strip())
    a = list(map(int, input().strip().split(" ")))
    b = list(map(int, input().strip().split(" ")))
    print(solve(n, a, b))
import math
import functools
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return functools.reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)



n=int(input())
t=[]
for i in range(n):
    t.append(int(input()))
print(lcm_list(t))


### FIXED CODE ###

import functools

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return functools.reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)



n=int(input())
t=[]
for i in range(n):
    t.append(int(input()))
print(lcm_list(t))
import re
import bisect
s = input()
len_s = len(s)
t = input()

ind_dict = {i : [] for i in t}
for i, _s in enumerate(s):
    if _s in t:
        ind_dict[_s] += [i]
ind_ls = [[j.start(0) for j in re.finditer(i,s)] for i in t]

def get_least(last, s, dic):
    ls = dic[s]
    ind = bisect.bisect_right(ls, last)
    if ind >= len(ls):
        return ls[0]
    else:
        return ls[ind]

if -1 in [s.find(_t) for _t in t]:
    print(-1)
else:
    cnt = 0
    last = get_least(0, t[0], ind_dict)
    for _t in t[1:]:
        _next = get_least(last, _t, ind_dict)
        if _next < last:
            cnt += 1
        last = _next
    print(cnt * len(s) + _next + 1)

### FIXED CODE ###

import bisect
s = input()
len_s = len(s)
t = input()

ind_dict = {i : [] for i in t}
for i, _s in enumerate(s):
    if _s in t:
        ind_dict[_s] += [i]

def get_least(last, s, dic):
    ls = dic[s]
    ind = bisect.bisect_right(ls, last)
    if ind >= len(ls):
        return ls[0]
    else:
        return ls[ind]

if -1 in [s.find(_t) for _t in t]:
    print(-1)
else:
    cnt = 0
    last = get_least(-1, t[0], ind_dict)
    _next = last
    for _t in t[1:]:
        _next = get_least(last, _t, ind_dict)
        if _next <= last:
            cnt += 1
        last = _next
    print(cnt * len(s) + _next + 1)
N = int(input())
S = input()
if N%" == 1:
	print("NO")
else:
  if (S[0: int(N/2)] == S[int(N/2):N]):
    print("YES")
  else:
    print("NO")
  

### FIXED CODE ###

n = int(input())
print(round(n*n))
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = -1000000000
for i in range(N):
  cost = 0
  S = []
  x = P[i] - 1
  l = 1
  while 1:
    cost += C[x]
    S.append(cost)
    if x == i:
      break
    l += 1
    x = P[x] - 1
  print(S, l)
  if cost > 0:
    ans = max(ans, cost * (K // l) + max(S[:K % l]))
  else:
    ans = max(ans, max(S))
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = -1000000000
for i in range(N):
  cost = 0
  S = []
  x = P[i] - 1
  l = 1
  while 1:
    cost += C[x]
    S.append(cost)
    if x == i:
      break
    l += 1
    x = P[x] - 1
  if cost > 0:
    for j in range(l):
      ans = max(ans, S[j] + cost * ((K - j - 1) // l))
  else:
    ans = max(ans, max(S[:min(K, l)]))
print(ans)