Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)

N, Q = map(int, input().split())
repn = [[] for i in range(N)]

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

count = [0] * N

## analysis of tree structure
parent = [-1] + ['nul'] * (N - 1)

for v in repn[0]:
    parent[v] = 0

deq = deque(repn[0])

while deq:
    v = deq.popleft()
    for w in repn[v]:
        if parent[v] == w:
            pass
        else:
            parent[w] = v
            deq.append(w)

multi_child = [[] for i in range(N)]
for i in range(N):
    multi_child[i].append(i)
    v = parent[i]
    while v != -1:
        multi_child[v].append(i)
        v = parent[v]



## soltion
for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    for v in multi_child[p]:
        count[v] += x
    
print(' '.join(map(str, count)))


### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)

N, Q = map(int, input().split())
repn = [[] for i in range(N)]

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

count = [0] * N

## analysis of tree structure
parent = [-1] + ['nul'] * (N - 1)
child = [[] for i in range(N)]
child[0] = repn[0]

for v in child[0]:
    parent[v] = 0

deq = deque(repn[0])

while deq:
    v = deq.popleft()
    for w in repn[v]:
        if parent[v] == w:
            pass
        else:
            parent[w] = v
            child[v].append(w)
            deq.append(w)


## soltion
for i in range(Q):
    p, x = map(int, input().split())
    p -= 1
    count[p] += x
    
deq = deque([0])
while deq:
    v = deq.popleft()
    for w in child[v]:
        count[w] += count[v]
        deq.append(w)



print(' '.join(map(str, count)))
### BUGGY CODE ###

n = int(input())
p = [int(_) for _ in input().split()]

ans = 0
for i in range(len(p)):
    if i == 0:
        ans += 1
    else:
        p_min = min(p[0:i+1])
        if p_min == p[i]:
            ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
p = [int(_) for _ in input().split()]

t = 200001
ans = 0
for i in range(n):
    if p[i] < t:
        ans += 1
        t = p[i]
print(ans)
### BUGGY CODE ###

N = int(input())
array=[int(n) for n in input().split()]
import copy
lst=[None for i in range(N+1)]
left_lst = copy.deepcopy(lst)
right_lst = copy.deepcopy(lst)
left_array=array[:N] 
right_array=array[-N:]
l_sum=sum(left_array)
r_sum=sum(right_array)
left_lst[0]= l_sum
right_lst[0]=r_sum
for k in range(N,2*N):
    new_a,new_b=array[k],array[-k-1]
    left_array.append(new_a)
    old_a=min(left_array)
    left_array.remove(old_a)
    l_sum+=(new_a-old_a)
    left_lst[k-N+1]=l_sum
    right_array.append(new_b)
    old_b=max(right_array)
    right_array.remove(old_b)
    r_sum+=(new_b-old_b)
    right_lst[k-N+1]=r_sum
lst = [a-b for a,b in zip(left_lst,list(reversed(right_lst)))]
print(max(lst))

### FIXED CODE ###

N = int(input())
array = [int(n) for n in input().split()]
import copy
import heapq
lst = [None for i in range(N + 1)]
left_lst = copy.deepcopy(lst)
right_lst = copy.deepcopy(lst)
left_array = array[:N]
right_array= [-n for n in array[-N:]]
l_sum = sum(left_array)
r_sum = sum(right_array)
heapq.heapify(left_array)
heapq.heapify(right_array)
left_lst[0] = l_sum
right_lst[0] = r_sum

for k in range(N, 2 * N):
    new_a, new_b = array[k], array[-k - 1]*-1
    heapq.heappush(left_array,new_a)
    heapq.heappush(right_array,new_b)
    old_a = heapq.heappop(left_array)
    l_sum += (new_a - old_a)
    left_lst[k - N + 1] = l_sum
    old_b = heapq.heappop(right_array)
    r_sum += (new_b - old_b)
    right_lst[k - N + 1] = r_sum
lst = [ a + b for a, b in zip(left_lst, list(reversed(right_lst)))]
print(max(lst))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
n,q=map(int,input().split())
G=[[]*n for i in range(n)]
P=[0]*n
V=[0]*n
for i in range(n-1):
	a,b=map(int,input().split())
	G[a-1].append(b-1)
	G[b-1].append(a-1)
for i in range(q):
	c,d=map(int,input().split())
	P[c-1]+=d
def dsf(i,p):
	V[i]=1
	P[i]+=p
	p=0
	for j in G[i]:
		if V[j]!=1:
			dsf(j,P[i])
dsf(0,0)
print(' '.join(map(str,P)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
s=sys.stdin.readlines()
n,q=map(int,s[0].split())
G=[[]*n for i in range(n)]
P=[0]*n
V=[0]*n
R=[0]*n
for e in s[1:n]:
    a,b=map(int,e.split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
for e in s[n:]:
    c,d=map(int,e.split())
    P[c-1]+=d

def dsf(i,p):
    V[i]=1
    R[i]+=p+P[i]
    p=0
    for j in G[i]:
        if V[j]!=1:
            dsf(j,R[i])
dsf(0,0)
print(' '.join(map(str,R)))
### BUGGY CODE ###

from collections import deque
from collections import defaultdict

N,M=map(int,raw_input().split())
nl=[ [] for i in range(N+1) ]
cost={}
test={}

for i in range(M):
	L,R,D=map(int,raw_input().split())
	if i==0:start=L
	nl[L].append(R)
	nl[R].append(L)
	cost[(L,R)]=D
	cost[(R,L)]=-D
	test[(L,R)]=D


d=[ -1 for i in range(N+1) ]

def dfs(start):
	V=[ 0 for i in range(N+1) ]
	q = deque([]) 
	V[start]=1
	d[start]=0
	q.append(start)

	while len(q)!=0:
		v=q.pop()
		for i in nl[v]:
			if V[i]!=1:
				V[i]=1
				q.append(i)
				d[i]=d[v]+cost[(v,i)]

for i in range(1,N+1):
	if d[i]==-1:
		dfs(i)


for i,j in test.items():
	x1=i[0]
	x2=i[1]
	if d[x2]-d[x1]==j:
		continue
	else:
		print "No"
		quit()
else:
	print "Yes"




### FIXED CODE ###

from collections import deque
from collections import defaultdict

N,M=map(int,raw_input().split())
nl=[ [] for i in range(N+1) ]
cost={}

for i in range(M):
	L,R,D=map(int,raw_input().split())
	if i==0:start=L
	nl[L].append(R)
	nl[R].append(L)
	cost[(L,R)]=D
	cost[(R,L)]=-D


d=[ None for i in range(N+1) ]
V=[ 0 for i in range(N+1) ]

def dfs(start):
	q = deque([]) 
	V[start]=1
	d[start]=0
	q.append(start)

	while len(q)!=0:
		v=q.pop()
		for i in nl[v]:
			if V[i]!=1:
				V[i]=1
				q.append(i)
				d[i]=d[v]+cost[(v,i)]
			else:
				if d[i]-d[v]!=cost[(v,i)]:
					print "No"
					quit()

for i in range(1,N+1):
	if V[i]==0:
		dfs(i)
else:
	print "Yes"
### BUGGY CODE ###

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

a = 100000000000
for i in range(L,R + 1):
  if a == 0:
    break
  for j in range(i + 1,R + 1):
    if a >= i * j % 2019:
      a = i * j % 2019
    elif a == 0:
      break
  

print(a)

### FIXED CODE ###

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

a = 100000000000
for i in range(L,R + 1):
  if a == 0:
    break
  for j in range(i + 1,R + 1):
    if a >= i * j % 2019:
      a = i * j % 2019
      if a == 0:
        break
  

print(a)
### BUGGY CODE ###

import numpy as np
n,k = map(int, input().split())
As = list(map(int, input().split()))

def f(x):
    # サイズxで切る
    cnt = 0
    for a in As:
        # 斬らなければイケない本数
        cnt += int(np.ceil(a/x))-1
    # 斬らなければいけない本数がk本以下
    return cnt <= k

l = 10**-6
r = 10**9
while r-l > 10**-5:
    # print(l,r)
    m = (l+r)/2
    if f(m):
        r = m
    else:
        l = m
print(int(np.ceil(l)))

### FIXED CODE ###

n,k = map(int, input().split())
As = list(map(int, input().split()))

def f(x):
    # サイズxで切る
    cnt = 0
    for a in As:
        # 斬らなければイケない本数
        cnt += int((a-0.01)/x)
        if cnt > k:
            return False
    # 斬らなければいけない本数がk本以下
    return cnt <= k

l = 10**-2
r = 10**9
while r-l > 10**-1:
    m = (l*r)**0.5
    if f(m):
        r = m
    else:
        l = m
print(int(l)+1)
### BUGGY CODE ###

import copy
N,M=map(int,input().split())
dp=[float("inf") for _ in range(2**N)]
dp[0]=0
for _ in range(M):
    a,b=map(int,input().split())
    C=list(map(int,input().split()))
    for v in range(2**N):
        nv=copy.copy(v)
        for c in C:
            bi=2**(c-1)
            if (v//bi)%2==0:
                nv+=bi
        dp[nv]=min(dp[nv],dp[v]+a)
if dp[-1]==float("inf"):
    print(-1)
else:
    print(dp[-1])

### FIXED CODE ###

N,M=map(int,input().split())
dp=[float("inf") for _ in range(2**N)]
dp[0]=0
for _ in range(M):
    a,b=map(int,input().split())
    c=sum([2**(int(i)-1) for i in input().split()])
    for v in range(2**N):
        nv=v|c
        dp[nv]=min(dp[nv],dp[v]+a)
if dp[-1]==float("inf"):
    print(-1)
else:
    print(dp[-1])
### BUGGY CODE ###

import math
from functools import reduce
a = int(input())

target_list = []
for x in range(1, a+1):
    for y in range(1, a+1):
        for z in range(1, a+1):
            target_list.append((x, y, z))
result = 0
for target in target_list:
    result += reduce(math.gcd, target)
print(result)

### FIXED CODE ###

import math
from functools import reduce
a = int(input())
result = 0
for x in range(1, a+1):
    for y in range(1, a+1):
        for z in range(1, a+1):
            result += reduce(math.gcd, (x, y, z))
            
print(result)
### BUGGY CODE ###

h, w, m = map(int, input().split())
nh = [0 for i in range(h)]
nw = [0 for j in range(w)]
bomb = [[] for i in range(h)]
for i in range(m):
    inp = list(map(int, input().split()))
    nh[inp[0] - 1] += 1
    nw[inp[1] - 1] += 1
    bomb[inp[0]-1].append(inp[1]-1)
maxh = max(nh)
maxw = max(nw)
counth = 0
countw = 0
hlis = []
wlis = []
for j in range(h):
    if nh[j] == maxh:
        counth += 1
        hlis.append(j)
for i in range(w):
    if nw[i] == maxw:
        countw += 1
        wlis.append(i)
if counth * countw > m:
    print(maxh + maxw)
    exit()
else:
    for j in hlis:
        for i in wlis:
            flag = False
            if i in bomb[j]:
                flag = True
            if not flag:
                print(maxh + maxw)
                exit()
    else:
        print(maxh + maxw - 1)

### FIXED CODE ###

h, w, m = map(int, input().split())
nh = [0 for i in range(h)]
nw = [0 for j in range(w)]
bomb = [set() for i in range(h)]
for i in range(m):
    inp = list(map(int, input().split()))
    nh[inp[0] - 1] += 1
    nw[inp[1] - 1] += 1
    bomb[inp[0]-1].add(inp[1]-1)
maxh = max(nh)
maxw = max(nw)
counth = 0
countw = 0
hlis = []
wlis = []
for j in range(h):
    if nh[j] == maxh:
        counth += 1
        hlis.append(j)
for i in range(w):
    if nw[i] == maxw:
        countw += 1
        wlis.append(i)
if counth * countw > m:
    print(maxh + maxw)
    exit()
else:
    for j in hlis:
        for i in wlis:
            flag = False
            if i in bomb[j]:
                flag = True
            if not flag:
                print(maxh + maxw)
                exit()
    else:
        print(maxh + maxw - 1)
### BUGGY CODE ###

import sys
INFTY = 1<<30
a = [None] * (2000000 + 1)
h = 0
ret = [None] * (2000000 + 1)
i = 0

def left(i):
    return 2 * i

def right(i):
    return 2 * i + 1

def maxHeapify(i):
    global a, h
    l = left(i)
    r = right(i)
    if l <= h and a[l] > a[i]:
        largest = l
    else:
        largest = i
    if r <= h and a[r] > a[largest]:
        largest = r
    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        maxHeapify(largest)

def extract():
    global a, h
    if h < 1:
        return -INFTY
    maxv = a[1]
    a[1] = a[h]
    h -= 1
    maxHeapify(1)
    return maxv
    
def increaseKey(i, k):
    global a
    if k < a[i]:
        return
    a[i] = k
    while i > 1 and a[i//2] < a[i]:
        a[i], a[i//2] = a[i//2], a[i]
        i = i // 2

def insert(k):
    global a, h
    h += 1
    a[h] = -INFTY
    increaseKey(h, k)

coms = sys.stdin.readlines()
for com in coms:
    if com[0] == "i":
        k = int(com.split()[1])
        insert(k)
    elif com[0:2] == "ex":
        ret[i] = extract()
        i += 1
    else:
        sys.stdout.write("\n".join([str(s) for s in ret[:i]]))
        print()


    

### FIXED CODE ###

import heapq
import sys

h = []

for com in sys.stdin.readlines():
    if com[0] == "i":
        heapq.heappush(h, -int(com[7:]))
    elif com[1] == "x":
        print(-heapq.heappop(h))
### BUGGY CODE ###

h, w, d = map(int, input().split())
amd = {}
for i in range(h):
  al = map(int, input().split())
  for j, a in enumerate(al):
    amd[a] = (j+1, i+1)

q = int(input())
for _ in range(q):
  ans = 0
  ansd = {}
  l, r = map(int, input().split())
  if (l, r) in ansd:
    print(ansd[(l, r)])
  else:
    prevx, prevy = amd[l]
    for x in range(l+d, r+1, d):
      _x, _y = amd[x]
      ans += abs(_x - prevx) + abs(_y - prevy)
      prevx, prevy = _x, _y
    print(ans)
    ansd[(l, r)] = ans

### FIXED CODE ###

h, w, d = map(int, input().split())
amd = {}
for i in range(h):
  al = map(int, input().split())
  for j, a in enumerate(al):
    amd[a] = (j+1, i+1)

dsum = [0 for _ in range(d+1)]
for i in range(d+1, h*w+1):
  dsum.append(dsum[-d] + abs(amd[i][0]-amd[i-d][0]) + abs(amd[i][1]-amd[i-d][1]))

q = int(input())
for _ in range(q):
  ans = 0
  l, r = map(int, input().split())
  print(dsum[r] - dsum[l])
### BUGGY CODE ###

def main():
  import sys
  input = sys.stdin.readline

  X,Y,Z,K = map(int,input().split())
  A = list(map(int,input().split()))
  B = list(map(int,input().split()))
  C = list(map(int,input().split()))
  res = [a+b+c for a in A for b in B for c in C]
  res.sort(reverse = True)
  print("\n".join(list(map(str,res[:K]))))

if __name__ == "__main__":
  main()

### FIXED CODE ###

def main():
  import sys
  input = sys.stdin.readline

  X,Y,Z,K = map(int,input().split())
  A = list(map(int,input().split()))
  B = list(map(int,input().split()))
  C = list(map(int,input().split()))
  A.sort(reverse = True)
  B.sort(reverse = True)
  C.sort(reverse = True)
  AB = [a+b for a in A for b in B]
  AB.sort(reverse = True)
  res = [c+ab for ab in AB[:min(K, len(AB))] for c in C]
  res.sort(reverse = True)
  print("\n".join(list(map(str,res[:K]))))

if __name__ == "__main__":
  main()
### BUGGY CODE ###

def lucas(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    else:
        return lucas(n-1) + lucas(n-2)

n = int(input())
print(lucas(n))

### FIXED CODE ###

n = int(input())
l = []

for i in range(n+1):
    if i == 0:
        l.append(2)
    elif i == 1:
        l.append(1)
    else:
        l.append(l[-1]+l[-2])

print(l[n])
### BUGGY CODE ###

A, B, K = map(int, input().split())
for i in range(A,B+1):
    if (i <= A + K - 1) or (i >= B - K + 1):
        print(i)

### FIXED CODE ###

A, B, K = map(int, input().split())
ans = []
if A == B:
    print(A)
    exit()
for i in range(A,A+K):
    if B <= i:
        break
    ans.append(i)
for i in range(B-K+1,B+1):
    if i <= A:
        continue
    ans.append(i)
ans2 = set(ans)
ans3 = list(ans2)
ans3.sort()
for i in ans3:
    print(i)
### BUGGY CODE ###

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

p_list = []
y_list = []
shi_map = {}

for i in range(M):
    p, y = map(int, input().split())
    p_list.append(p)
    y_list.append(y)
    if p in shi_map:
        shi_map[p].append(y)
    else:
        shi_map[p] = [y]
shi_map = sorted(shi_map.items(), key=lambda x: x[0])
shi_map = dict(shi_map)
shi_map2 = {}
for k, v in shi_map.items():
    v = sorted(v)
    shi_map2[k] = v

for i in range(M):
    p = p_list[i]
    y = y_list[i]
    j = shi_map2[p].index(y)
    p_str = str(p).zfill(6)
    j_str = str(j+1).zfill(6)
    print(p_str + j_str)



### FIXED CODE ###

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

shi_map = []

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

shi_map = sorted(shi_map, key=lambda x: (x[1], x[2]))

result = {}
shi_count = {}
for i, p, y in shi_map:

    if p in shi_count:
        c = shi_count[p]
        count = c + 1
        shi_count[p] = count
    else:
        shi_count[p] = 1
        count = 1
    result[i] = [p, count]
result = list(sorted(result.items(), key=lambda x: x[0]))

for i, p in result:

    p2 = str(p[0]).zfill(6)

    y = str(p[1]).zfill(6)
    r = p2+y
    print(r)
### BUGGY CODE ###

X,Y,Z,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
DD = []
A.sort()
B.sort()
C.sort()
for i in A:
    for j in B:
       DD.append(i+j)
DD.sort()
F = []
for i in DD[max(len(DD)-3010,0):]:
    for j in C:
        F.append(i+j)
F.sort()
for i in range(K):
    print(F[-1-i])
        


### FIXED CODE ###

import sys
import heapq
input = sys.stdin.readline
X,Y,Z,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
DD = [i+j for i in A for j in B]
DD.sort()
heap = []
for i in DD[max(len(DD)-3001,0):]:
     for j in C:
         heapq.heappush(heap,-(i+j))
for i in range(K):
    print(-heapq.heappop(heap))
### BUGGY CODE ###

n = int(input())
ans = 1
i = 1
while i<=n:
  ans = ans*i%(1000000007)
  i=+1
print(ans)
  

### FIXED CODE ###

n = int(input())
ans = 1
i = 1
while i<=n:
  ans = ans*i%(1000000007)
  i += 1
print(ans)
### BUGGY CODE ###

lim = 10 ** 9 + 7
n = int(input())
result = 1
for q in range(n):
    result *= q + 1
print(result % lim)

### FIXED CODE ###

lim = 1000000007
result = 1
n = int(input())

for q in range(n):
    result = result % lim
    result *= q + 1
print(result % lim)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

class Factorization:	
	def __init__(self):
		# privateなインスタンス変数を作成
		self.__factors = dict()
		self.__n = 0
	
	
	def get_factors(self, n):
		# [summary] 素因数分解した結果を、辞書([素因数, 指数]...)で返す
		self.__factors.clear()
		self.__n = n
		
		if n < 2:
			# 2より小さい数の場合、素因数分解できない
			return { n:1 }
		else:
			self.__factorization()
			
			return self.__factors


	def	__factorization(self):
		# [summary]素因数分解した結果を、インスタンス変数に格納
		
		# 2,3,5で、割れなくなるまで割り続ける
		# (末尾に2,3,5のつく数は素数でないことが明白なので
		# 後続の処理で素数のリストに入れないように、先に処理する)
		self.__divide_with(2)
		self.__divide_with(3)
		self.__divide_with(5)
			
		# 平方根以下の素数で総当たりで試し割りする
		# (実際は、素数らしき数)
		import math
		sqrt_ = math.floor(math.sqrt(self.__n))
			
		primes = [7, 11, 13, 17, 19, 23, 29, 31]
		i = 0
		is_break = False
			
		while self.__n > 1:
			for p in primes:
				if p + i <= sqrt_:
					self.__divide_with(p + i)
				else:
					# 試し割りする数が平方根を超えたら、ループを抜ける
					is_break = True
						
					# 1が素因数に追加されることを防止
					if self.__n > 1:
						self.__factors.setdefault(self.__n, 1)
				
			if is_break:
				break
			else:
				i += 30
	
	
	def __divide_with(self, d):
		count = 0
		
		while self.__n % d == 0:
			self.__n //= d
			count += 1
		
		if count > 0:
			self.__factors.setdefault(d, count)


# D - Sum of Divisors
N = int(input())

lib = Factorization()
dic = dict()

for i in range(N, 1, -1):
	if not i in dic.keys():
		factors = lib.get_factors(i)
		divisors = dict()
		divisors[1] = 1
		
		for k, v in factors.items():
			import copy
			copied = copy.deepcopy(divisors)

			for j in range(1, v + 1):
				for c_k, c_v in copied.items():
					d = c_k * (k ** j)			
					count = c_v * (j + 1)
					divisors.setdefault(d, count)

					dic.setdefault(d, 0)
					dic[d] = count

ans = 1

for k, v in dic.items():
	ans += k * v

print(ans)

### FIXED CODE ###

# D - Sum of Divisors
N = int(input())
ans = (1 + N) * N

for i in range(2, N//2 + 1):
	j = 2
	
	while True:
		if i * j <= N:
			
			ans += i * j
			j += 1
		else:
			break

print(ans - 1)
### BUGGY CODE ###

from bisect import bisect_left, bisect_right

n = int(input())
s = list(input())
q = int(input())

d = {}
for i in range(n):
	d.setdefault(s[i], []).append(i)

flag = {}
for i in range(q):
	q1,q2,q3 = map(str,input().split())
	if q1 == '1':
		q2 = int(q2) - 1
		if s[q2] != q3:
			flag.setdefault(s[q2], []).append(q2)
			d.setdefault(q3, []).append(q2)
			flag[s[q2]].sort()
			d[q3].sort()
			s[q2] = q3
	else:
		ans = 0
		q2 = int(q2) - 1
		q3 = int(q3) - 1
		if q2 == q3:
			print(1)
			continue
		for string,l in d.items():
			res = 0
			left = bisect_left(l,q2)
			right = bisect_right(l,q3)
			if string in flag:
				left2 = bisect_left(flag[string],q2)
				right2 = bisect_right(flag[string],q3)
			else:
				left2 = 0
				right2 = 0
			if left != right:
				if right - left > right2 - left2:
					res = 1
			ans += res
			#print(string,l,res)
		print(ans)


### FIXED CODE ###

from bisect import bisect_left, bisect_right, insort_left
import sys
readlines = sys.stdin.readline
def main():

	n = int(input())
	s = list(input())
	q = int(input())

	d = {}
	flag = {}
	for i in list('abcdefghijklmnopqrstuvwxyz'):
		d.setdefault(i, []).append(-1)
		flag.setdefault(i, []).append(-1)
	for i in range(n):
		d.setdefault(s[i], []).append(i)
	for i in range(q):
		q1,q2,q3 = map(str,input().split())
		if q1 == '1':
			q2 = int(q2) - 1
			if s[q2] != q3:
				insort_left(flag[s[q2]],q2)
				insort_left(d[q3],q2)
				s[q2] = q3
		else:
			ans = 0
			q2 = int(q2) - 1
			q3 = int(q3) - 1
			if q2 == q3:
				print(1)
				continue
			for string,l in d.items():
				res = 0
				if d[string] != [-1]:
					left = bisect_left(l,q2)
					right = bisect_right(l,q3)
				else:
					left = 0
					right = 0
				if string in flag:
					left2 = bisect_left(flag[string],q2)
					right2 = bisect_right(flag[string],q3)
				else:
					left2 = 0
					right2 = 0
				if left != right:
					if right - left > right2 - left2:
						res = 1
				ans += res
				#print(string,l,res)
			print(ans)
if __name__ == '__main__':
	main()
### BUGGY CODE ###

k = int(input())
num = 7
i = 1
while True:
    if num % k == 0:
        print(i)
        exit()
    if i >= k:
        print('-1')
        exit()
    num *= 10
    num += 7
    i += 1


### FIXED CODE ###

k = int(input())

if k % 2 == 0:
    print('-1')
    exit()

mod = [pow(10, i, k) for i in range(0, 1000000)]

num = 0
for i in range(0, 1000000):
    num += mod[i]
    if 7 * num % k == 0:
        print(i + 1)
        exit()

print('-1')
### BUGGY CODE ###

from functools import reduce

from operator import mul

N=int(input())

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

if 10**18>=reduce(mul,list):
	print(reduce(mul,list))

else:
  	print("-1")

### FIXED CODE ###

def main ():
	N = int(input())
	A = list(map(int,input(). split ()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)

main ()
### BUGGY CODE ###

N = int(input())
n = N
flag = True
S = 0
a = 0
while flag:
  a = n % 10
  S +=a
  n = n -a //10
  if n == 0:
    flag =False
if N % S == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = int(input())
n = N
flag = True
S = 0
a = 0
while flag:
  a = n % 10
  S +=a
  n = (n -a) //10
  if n == 0:
    flag =False
if N % S == 0:
  print("Yes")
else:
  print("No")
### BUGGY CODE ###

import bisect 
N = int(input())
max_keys = []
max_cnt = 1
c = {}
for _ in range(N):
    s = input()
    if s in set(c.keys()):
        c[s] += 1
    else:
        c[s] = 1

    if max_cnt == c[s]:
        bisect.insort(max_keys, s)
    elif max_cnt < c[s]:
        max_keys = [s]
        max_cnt = c[s]

for x in max_keys:
    print(x)

### FIXED CODE ###

import collections
N = int(input())
S = [input() for _ in range(N)]
C = collections.Counter(S)
max_cnt = C.most_common()[0][1]
tmp = sorted([k for k,v in C.items() if v == max_cnt])
for ans in tmp:
    print(ans)