Harryxun/stf_run huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

const int MAX_N = 200001;
int par[MAX_N];
int rnk[MAX_N];

void init(int n) {
    rep(i,n) {
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rnk[x] < rnk[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

void solve() {
    int N, K, L, p, q;
    cin >> N >> K >> L;
    init(N);
    rep(i,K) {
        cin >> p >> q;
        unite(p - 1, q - 1);
    }
    int roads[N];
    rep(i,N) roads[i] = find(i);
    init(N);
    rep(i,L) {
        cin >> p >> q;
        unite(p - 1, q - 1);
    }
    map<pair<int, int>, int> d;
    rep(i,N) d[make_pair(roads[i], find(i))]++;
    rep(i,N) cout << d[make_pair(roads[i], find(i))] << " ";
    cout << endl;
    return;
}

int main() {
    solve();
}

### FIXED CODE ###

def init(par, n):
    global rank
    par = [i for i in range(n)]
    rank = [0] * n

def find(par, x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par, par[x])
        return par[x]

def unite(par, x, y):
    global rank
    x = find(par, x)
    y = find(par, y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

N, K, L = map(int, input().split())
roads = [i for i in range(N)]
rank = [0] * N
for i in range(K):
    p, q = map(int, input().split())
    unite(roads, p - 1, q - 1)
rails = [i for i in range(N)]
rank = [0] * N
for i in range(L):
    p, q = map(int, input().split())
    unite(rails, p - 1, q - 1)
d = {}
for i in range(N):
    d[find(roads, i), find(rails, i)] = d.get((find(roads, i), find(rails, i)), 0) + 1
for i in range(N):
    print(d[find(roads, i), find(rails, i)], end = " ")
print()
def main():
	N=input()
	if N[1] != '0':
		print(100)
	else:
		print(0)
main()

### FIXED CODE ###

from collections import deque
import math
import os
import random
import re
import sys
#n=list(map(int, input().split()))
#n=map(int, input().split())

def main():
	n=int(input())
	change = n%1000
	if change:
		print(1000-change)
	else:
		print(0)
		
	
main()

'''
if __name__ == '__main__':
    main()
'''
31415 92653

### FIXED CODE ###

a,b = map(int,input().split())
c = 0
for i in range(a,b+1):
    if str(i) == str(i)[::-1]:
        c +=1   
print(c)
search_s = input()
cnt = 0
while True:
    word_list = input().lower().split()
    if word_list[0] == "END_OF_TEXT" : break
    for word in word_list:
        if word == search_s:cnt += 1

print(cnt)

### FIXED CODE ###

search_s = input()
cnt = 0
while True:
    s = input()
    if s == "END_OF_TEXT": break
    word_list = s.lower().split()
    for word in word_list:
        if word == search_s:cnt += 1

print(cnt)
f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
n, m = map(int, f.readline().split())
ab = []
c= []
keys = ["" for _ in range(m)]

for i in range(m):
    ab.append(list(map(int, f.readline().split())))
    kari = list(map(int, f.readline().split()))
    c.append(kari)
    for j in range(n):
        if j+1 in kari:
            keys[i] = keys[i]+"1"
        else:
            keys[i] = keys[i] + "0"

all_patterns = ["0","1"]
options = ["0", "1"]

for _ in range(n-1):
    all_patterns = [j+i for i in (options) for j in all_patterns]

dp_dict = dict()
for pattern in all_patterns:
    dp_dict[pattern] = 1e+10
dp_dict["0"*n] = 0

for j in range(m):
    for key in dp_dict.keys():
        kari1 = dp_dict[key]+ab[j][0]
        kari2 = dp_dict[format(int(key,2)|int(keys[j],2),"0"+str(n)+"b")]
        if kari1 < kari2:
            dp_dict[format(int(key,2)|int(keys[j],2),"0"+str(n)+"b")] = kari1

if dp_dict["1"*n] != 1e+10:
    print(dp_dict["1"*n])
else:
    print(-1)

### FIXED CODE ###


n, m = map(int, input().split())
ab = []
c= []
keys = ["" for _ in range(m)]

for i in range(m):
    ab.append(list(map(int, input().split())))
    kari = list(map(int, input().split()))
    c.append(kari)
    for j in range(n):
        if j+1 in kari:
            keys[i] = keys[i]+"1"
        else:
            keys[i] = keys[i] + "0"

all_patterns = ["0","1"]
options = ["0", "1"]

for _ in range(n-1):
    all_patterns = [j+i for i in (options) for j in all_patterns]

dp = [1e+10 for i in range(2**n)]
dp[0] = 0

#%%
for j in range(m):
    for i in range(len(dp)):
        kari1 = dp[i]+ab[j][0]
        kari2 = dp[i|int(keys[j],2)]
        if kari1 < kari2:
            dp[i|int(keys[j],2)] = kari1

if dp[-1] != 1e+10:
    print(dp[-1])
else:
    print(-1)
a,b=map(int,input().split())
bits=[]
perfect=False
while b>0:
  bits.append(b%2)
  b= b//2
if 1==i for i in bits:
  perfect=True
for i in range(len(bits)):
  if (bits[i]==1 and a//2==1) or (bits[i]==0 and a//2==0):
    bits[i]=0
  else:
    bits[i]=1
ans=0
for i in range(len(bits)):
  ans+= bits[i]*(2**i)
if perfect:
  print(ans+1)
else:
  print(ans)

### FIXED CODE ###

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

def xor(p):
  if p%4 == 0:
    return p
  elif p%4 == 1:
    return 1
  elif p%4 == 2:
    return p+1
  elif p%4 == 3:
    return 0

if a==0:
  print(xor(b))
elif a == b:
  print(a)
else:
  s=max(xor(b),xor(a-1))
  t=min(xor(a-1),xor(b))
  data=[]
  while s>0:
    data.append(s%2)
    s=s//2
  for i in range(len(data)):
    if (data[i] == t%2):
      data[i] = 0
    else:
      data[i] = 1
    t = t//2
  sum=0
  for i in range(len(data)):
    sum+= data[i]*(2**i)
  print(sum)
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
s=0
b=True
for i in a:
  s+=a
  
for i in range(0,m):
  if a[i]>=s/4/m:
    b=True
  else:
    b=False
    
if b:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
s=0
b=True
for i in a:
  s+=i

  
for i in range(0,m):
  if a[i]>=s/4/m:
    b=True
  else:
    b=False
    
if b:
  print('Yes')
else:
  print('No')
def memo(v):
    if dp[v]!=-1:return dp[v]
    ans = 0
    for next_v in g[v]:
        ans = max(ans,memo(next_v)+1)
    dp[v] = ans
    return dp[v]

n,m = map(int,input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    x,y = map(int,input().split())
    g[x].append(y)
    
dp = [-1]*(n+1)

ans = 0
for v in range(1,n+1):
    print("v={}".format(v))
    ans = max(ans, memo(v))
    
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5+10)
def memo(v):
    if dp[v]!=-1:return dp[v]
    ans = 0
    for next_v in g[v]:
        ans = max(ans,memo(next_v)+1)
    dp[v] = ans
    return ans

n,m = map(int,input().split())
g = [[] for _ in range(n+1)]
for _ in range(m):
    x,y = map(int,input().split())
    g[x].append(y)
    
dp = [-1]*(n+1)

ans = 0
for v in range(1,n+1):
    ans = max(ans, memo(v))
    
print(ans)
ls = [x for x in input().split()]

if ls[1]=="+":
    print(int(ls[0]+ls[2]))
else:
    print(int(ls[0]-ls[2]))



### FIXED CODE ###

ls = [x for x in input().split()]

if ls[1]=="+":
    print(int(ls[0])+int(ls[2]))
else:
    print(int(ls[0])-int(ls[2]))
n,c=input().split()
n=int(n)
c=int(c)
x=[]
v=[]
e=[]
v_max=10**9
c_max=10**14
for _ in range(n):
    s = input().split()
    x.append(int(s[0]))
    v.append(int(s[1]))
    e.append(int(s[1])-int(s[0]))
ans=0
l=set()
while True:
    p = 0
    ee_max = 0
    for i in range(p, n):
        if i in l:
            continue
        ee = e[i]
        if ee > ee_max and max_ee > 0:
            p = i
            ee_max = ee
    if ee_max <= 0:
        break
    ans = ans + e[p]
    l.add(p)
    #for i in range(n):
    #    x[i] = min(abs(x[i]-x[p]), c-abs(x[i]-x[p]))
    #    e[i] = x[i] - v[i]
print(ans)

### FIXED CODE ###

n, c = input().split()
n = int(n)
c = int(c)
x = [0]
v = [0]
gs1 = [0]
gs2 = [0]
gs3 = [0]
gs4 = [0]
s = 0
for i in range(n):
    xx, vv = input().split()
    xx = int(xx)
    vv = int(vv)
    x.append(xx)
    v.append(vv)
    s += vv
    f = s - xx
    gs1.append(max(gs1[-1], f))
    f = s - 2 * xx
    gs2.append(max(gs2[-1], f))
s = 0
for i in range(-1, -n - 1, -1):
    s += v[i]
    f = s - (c - x[i])
    gs3.append(max(gs3[-1], f))
    f = s - 2 * (c - x[i])
    gs4.append(max(gs4[-1], f))
ans = 0
for i in range(n + 1):
    ans = max(ans, gs1[i] + gs4[n - i], gs2[i] + gs3[n - i])
print(ans)
count = 0
A = [input().split()]
while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    count += 1
print(count)

### FIXED CODE ###

input()
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
  A = [a/2 for a in A]
  count += 1
print(count)
n=int(input())
l=[111,222,333,444,555,666,777,888,999]
ans=[]
for i in range(8):
    if l[i]-n>=0:
        ans.append(i)
        
print(l[ans[0]])

### FIXED CODE ###

n=int(input())
if n%111==0:
    print(n)
else:
    print(-((-n)//111)*111)
a = input()
print(a.replace(',', ' ')

### FIXED CODE ###

a = input()
print(a.replace(',', ' '))
N = input()  #一応読むけど、ループ回せば不要では
aList=input().split()


opCnt = 0
isAllE = True  #奇数見つかるまでは見なしTrue

while isAllE:
  for a in aList:
    if a%2 == 1:
      isAllE = False
  else:
    opCnt = opCnt + 1

print(opCnt)
      

### FIXED CODE ###

N = input()  #一応読むけど、ループ回せば不要では
aList=input().split()

opCnt = 0
isAllE = True  #奇数見つかるまでは見なしTrue

while isAllE:
  for a in aList:
    if int(a)%2 == 1:
      isAllE = False
      break
  else:
    opCnt = opCnt + 1
    for i,a in enumerate(aList):
      aList[i] = int(int(a)/2)

print(opCnt)
n = input()
fx = 0
for i in range(len(n)):
  fx += n[i]
if int(n)%fx == 0:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n = input()
fx = 0
for i in range(len(n)):
  fx += int(n[i])
if int(n)%fx == 0:
  print('Yes')
else:
  print('No')
import heapq
N, M = map(int, input().split())
A = [-i for i in map(int, input().split())]
heapq.heapify(A)
for _ in xrange(M):
    cur = -(-heapq.heappop(A) // 2)
    heapq.heappush(A, cur)
print(-sum(A))

### FIXED CODE ###

import heapq

N, M = map(int, input().split())
A = [-i for i in map(int, input().split())]
heapq.heapify(A)
for i in range(M):
  tmp = -((-heapq.heappop(A))//2)
  heapq.heappush(A, tmp)

print(-sum(A))
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
r.sort()
del p[:-X]
del q[:-Y]
if len(r)>X+Y:
    del r[:-max(X+Y)]
ans=sum(p)+sum(q)
for i in range(len(r)):
    a=r[-(i+1)]
    minp=min(p)
    minq=min(q)
    if minp<=minq and minp<a:
        ans=ans-minp+a
        del p[p.index(minp)]
        p.append(a)
    elif minp>=minq and minq<a:
        ans=ans-minq+a
        del q[q.index(minq)]
        q.append(a)
    else:
        break
print(ans)

### FIXED CODE ###

X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
ans=[]
for i in range(X):
    a=i+1
    ans.append(p[-a])
for i in range(Y):
    a=i+1
    ans.append(q[-a])
for i in r:
    ans.append(i)
ans.sort()
Ans=0
for i in range(X+Y):
    a=i+1
    Ans+=ans[-a]
print(Ans)
def gcd(x,y):
    if x < y:
        swap(x,y)
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

x,y = map(int,input().split())
print(gcd(x,y))


### FIXED CODE ###

def gcd(x,y):
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

x,y = map(int,input().split())
print(gcd(x,y))
from itertools import groupby
n = int(input())
h = list(map(int,input().split()))

h_diff = []
for i in range(len(h)-1):
    h_diff.append(h[i+1] - h[i])
    
result = [sum(item) for val, item in groupby([1 if x > 0 else -1 for x in h_diff])]
print(-min(result))

### FIXED CODE ###

from itertools import groupby
n = int(input())
h = list(map(int,input().split()))

h_diff = []
for i in range(len(h)-1):
    h_diff.append(h[i+1] - h[i])
    
result = [sum(item) for val, item in groupby([1 if x > 0 else -1 for x in h_diff])] + [0]
print(-min(result))
import math
N, K = map(int, input().split())
s = 10**9+7
for i in range(1, K+1):
    ans1 = (math.factorial(N-K+1)) // (math.factorial(i)) //(math.factorial(N-K-i+1))
    ans2 = (math.factorial(K-1)) // (math.factorial(i-1)) // (math.factorial(K-i))
    print(ans1 % s * ans2 % s)

### FIXED CODE ###

N, K = map(int, input().split())
s = 10**9+7
x = N-K+1
y = 1
for i in range(1, K+1):
    print(x*y%s)
    x = x * (N-K+1-i) // (i+1)
    y = y * (K-i) // i
F=lambda*m:max(len(str(x))for x in m);print(m)
N=int(input())
print(min(F(x,N//x)for x in range(1,int(N**.5)+1)if N%x==0))

### FIXED CODE ###

F=lambda*m:max(len(str(x))for x in m)
N=int(input())
print(min(F(x,N//x)for x in range(1,int(N**.5)+1)if N%x==0))
import argparse

def make_parser():
    parser = argparse.ArgumentParser()

    parser.add_argument('S')
    parser.add_argument('T')

    args = parser.parse_args()

    return args

def main():
    args = make_parser()
    T = args.T
    S = args.S

    print(T + S)

if __name__ == "__main__":
    main()


### FIXED CODE ###

S,T = map(str, input().split())
print(T + S)
n,x = map(int,input().split())

def get_result():
    if x == 1 or x == 2*n-1:
        return []
    
    if N == 2:
        return [1,2,3]
    
    if x == 2:
        center = [3,2,1,4]
        others = list(range(5,2*n))
    elif x == 2*n-1:
        center = [2*n-3,2*n-2,2*n-1,2*n-4]
        others = list(range(1,2*n-4))
    else:
        center = [x+1,x,x-1,x+2]
        others = list(range(1,x-1)) + list(range(x+3,2*n))
    split_idx = 2*n-2
    result = others[:split_idx] + center + others[split_idx:]
    
    return result


res = get_result()
if len(res)==0:
    print("No")
else:
    print("Yes")
    for r in res:
        print(r)
        

### FIXED CODE ###

n,x = map(int,input().split())

def get_result():
    if x == 1 or x == 2*n-1:
        return []
    
    if n == 2:
        return [1,2,3]
    
    if x == 2:
        center = [3,2,1,4]
        others = list(range(5,2*n))
    elif x == 2*n-2:
        center = [2*n-3,2*n-2,2*n-1,2*n-4]
        others = list(range(1,2*n-4))
    else:
        center = [x+1,x,x-1,x+2]
        others = list(range(1,x-1)) + list(range(x+3,2*n))
    split_idx = n-2
    result = others[:split_idx] + center + others[split_idx:]
    
    return result


res = get_result()
if len(res)==0:
    print("No")
else:
    print("Yes")
    for r in res:
        print(r)
n=int(input())

result=[]
for i in range(1,n+1):
    if i %3==0:
        result.append(i)
    else:
        k=i
        for j in range(1,len(str(n)+1):
            if k%(10**j)==3:
                result.append(i)
                break
            else:
                k=k//10**j
        else:
            continue

print(*result)

### FIXED CODE ###

n=int(input())
 
result=[]
for i in range(1,n+1):
    if i %3==0:
        result.append(i)
    else:
        k=i
        for j in range(1,5):
            if k%10==3:
                result.append(i)
                break
            else:
                k=k//10
        else:
            continue
 
print("",*result)
numList = input().split()
numList = list(map(int, numList))
commandList = [
	[2,0,0],
	[0,2,0],
	[0,0,2],
	[0,1,1],
	[1,0,1],
	[1,1,0]
]
numListList = [numList]

def search(depth):
	global numListList
	tmpList = []
	for numList in numListList:
		for command in commandList:
			sumedList = sumList(numList, command)
			if check(sumedList, depth+1):
				return
			tmpList.append(sumedList)
	numListList = tmpList
	search(depth+1)

def sumList(list1, list2):
	return [list1[0]+list2[0], list1[1]+list2[1], list1[2]+list2[2]]

def check(list1, count):
	if list1[0] == list1[1] and list1[1] == list1[2]:
		print(count)
		return True

	if list1[0] == list1[1]:
		if list1[0] > list1[2]:
			print(int(count+(list1[0]-list1[2])/2)+1)
			return True
		if list1[2] > list1[0]:
			print(int(count+(list1[2]-list1[0])))
			return True

	if list1[1] == list1[2]:
		if list1[1] > list1[0]:
			print(int(count+(list1[0]-list1[2])/2)+1)
			return True
		if list1[0] > list1[1]:
			print(int(count+(list1[0]-ist1[1])))
			return True

	if list1[0] == list1[2]:
		if list1[0] > list1[1]:
			print(int(count+(list1[0]-list1[1])/2)+1)
			return True
		if list1[1] > list1[0]:
			print(int(count+(list1[1]-list1[0])))
			return True

	

search(0)

### FIXED CODE ###

numList = input().split()
numList = list(map(int, numList))
commandList = [
	[2,0,0],
	[0,2,0],
	[0,0,2],
	[0,1,1],
	[1,0,1],
	[1,1,0]
]
numListList = [numList]

def search(depth):
	global numListList
	tmpList = []
	for numList in numListList:
		for command in commandList:
			sumedList = sumList(numList, command)
			if check(sumedList, depth+1):
				return
			tmpList.append(sumedList)
	numListList = tmpList
	search(depth+1)

def sumList(list1, list2):
	return [list1[0]+list2[0], list1[1]+list2[1], list1[2]+list2[2]]

def check(numList, count):
	if numList[0] == numList[1] and numList[1] == numList[2]:
		print(count)
		return True

	if numList[0] == numList[1]:
		return check2(numList[0], numList[2], count)

	if numList[1] == numList[2]:
		return check2(numList[1], numList[0], count)

	if numList[0] == numList[2]:
		return check2(numList[0], numList[1], count)

	return False

def check2(num1, num2, count):
	if num1 > num2:
		if (num1-num2)%2 == 0:
			print(int(count+(num1-num2)/2))
			return True
		else:
			print(int(count+(num1-num2)/2)+2)
			return True
	else:
		print(int(count+(num2-num1)))
		return True

if check(numList, 0):
	pass
else:
	search(0)
N = int input()
a = list(map(int,input().split()))
b = 0

for i in range(N):
  if a[i] % 2 == 0:
    if a[i] % 3 != 0 or a[i] % 5 != 0:
      b = 1
      break
if b == 0:
  print("APPROVED")
else:
  print("DENIED")


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
c = 0
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] %3 != 0 :
            if A[i] %5 != 0:
                c = 1
                break
if c == 0:
    print("APPROVED")
else:
    print("DENIED")
S=input()
if S == "Sunny" :
    print("Cloudy")
else if S =="Cloudy":
    print("Rainy")
else
    print("Sunny")

### FIXED CODE ###

S=input()
if S == "Sunny" :
    print("Cloudy")
elif S =="Cloudy":
    print("Rainy")
else:
    print("Sunny")
N = int(input())
List = sort(list(map(int, input().split())))
for i in range (N):
  for j in range (i+1, N):
    if List[j] == List[i]:
      print("NO")
      break
  else:
    continue
  break
else:
  print("YES")

### FIXED CODE ###

N = int(input())
List = sorted(list(map(int, input().split())))
for i in range(N-1):
  if List[i] == List[i + 1]:
    print("NO")
    break
else:
  print("YES")
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, m = readmi()
a = deque([0] )* (10 ** 5 + 2)
q = [readl() for _ in range(m)]
for i in q:
    a[i[0]] = 1
    a[i[1] + 1] = -1
for i in range(n + 1):
    a[i + 1] += a[i]
print(a.count(max(a)))

### FIXED CODE ###

# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n, m = map(int, input().split())
a = [0] * (n + 2)
r = defaultdict(int)
for i in range(m):
    x,y = map(int,input().split())
    a[x - 1] += 1
    a[y] += -1

for i in range(n + 1):
    a[i + 1] += a[i]
count = 0
flg = True
for i in range(n):
    if a[i] >= m:
        count += 1
print(count)
n,w = map(int,input().split())
d = {}
p = []
for i in range(n):
    k,v = map(int,input().split())
    d[k] = v
    p.append(k)

dp = []
for i in range(n+1):
    o = []
    for j in range(w+1):
        o.append(0)

    dp.append(o)


for i in range(n):
    for j in range(w+1):
        if p[i] > j:
            dp[i+1][j] = dp[i][j]

        else:
            dp[i+1][j] = max(d[p[i]] + dp[i][j - p[i]], dp[i][j])

print(dp[n][w])n,w = map(int,input().split())
d = {}
p = []
for i in range(n):
    k,v = map(int,input().split())
    d[k] = v
    p.append(k)

dp = []
for i in range(n+1):
    o = []
    for j in range(w+1):
        o.append(0)

    dp.append(o)


for i in range(n):
    for j in range(w+1):
        if p[i] > j:
            dp[i+1][j] = dp[i][j]

        else:
            dp[i+1][j] = max(d[p[i]] + dp[i][j - p[i]], dp[i][j])

print(dp[n][w])

### FIXED CODE ###

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0]*(w+1) for _ in range(n+1)]
for i in range(n):
    w_, v_ = wv[i]
    for j in range(w+1):
        if j < w_:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j-w_]+v_, dp[i][j])
print(dp[n][w])
#D
from collections import deque
n,k = map(int,input().split())
a = list(map(int,input().split()))
tel = deque()
tel.append(1)
visit = [False for _ in range(n)]
visit[0] = True
for i in range(n):
    nx = a[tel[i]-1]
    if visit[nx-1] == True :
        tel.append(nx)
        #ループの始まりのindexをidxに格納
        idx = tel.index(nx)
        break
    tel.append(nx)
    visit[nx-1] == True
    
#print(tel)
if k - idx <=0:
    print(tel[k-1])
else:
    k -= idx
    loop_num = len(tel) - idx - 1
    #print('idx:',idx)
    #print('loop_num:',loop_num)
    goal = tel[idx + k%loop_num]
    
    print(goal)

### FIXED CODE ###

#D
from collections import deque
n,k = map(int,input().split())
a = list(map(int,input().split()))
tel = deque()
tel.append(1)
visit = [False for _ in range(n)]
visit[0] = True
for i in range(n):
    nx = a[tel[i]-1]
    if visit[nx-1] == True :
        tel.append(nx)
        #ループの始まりのindexをidxに格納
        idx = tel.index(nx)
        break
    tel.append(nx)
    visit[nx-1] = True
    
#print(tel)
#print(visit)
if k <= idx:
    goal = tel[k]
else:
    k -= idx
    loop_num = len(tel) - idx - 1
    #print('idx:',idx)
    #print('loop_num:',loop_num)
    goal = tel[idx + k%loop_num]
    
print(goal)
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 24 20:27:19 2019

@author: screamLab
"""

s = input()
atcg = ['A','T','C','G']
ans = 0
long = 0
for i in range(len(s)):
    if s[i] in atcg:
        if s[i+1] in atcg:
            ans += 1
        else:
            ans += 1
    long = max(long,ans)
    ans = 0
long = max(long,ans)
print(long)
        

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Mar 24 20:27:19 2019

@author: screamLab
"""

s = input()
s += 'H'
atcg = ['A','T','C','G']
ans = 0
long = 0
for i in range(len(s)):
    if s[i] in atcg:
        if i == len(s):
            break
        if s[i+1] in atcg:
            ans += 1
        else:
            ans += 1
            long = max(long,ans)
            ans = 0
long = max(long,ans)
print(long)
N , K = map(int,input().split())
B = {}
C = {}
D = {0}
A = list(map(int,input().split()))
place = 0
num = 0
C[0] = 0
while True:
    place = int(A[place]) - 1
    num += 1   
    if place in D:
        Y = int(num) - int(C[place])
        break
    elif num == K:
        break
    else:
        B[num] = place
        C[place] = num
        D.add(place)
try:
    X = (K - num) % Y
    print(B[C[place] + X] + 1)
except:
    print(A[place])

    

### FIXED CODE ###

S = input()
T = input()
s = list(S)
t = list(T)
n = len(t)
t.pop(n-1)
if s == t:
    print("Yes")
else:
    print("No")
n=input()
for i in range(n):
	a=input()
	b=input()
	print(a+b)

### FIXED CODE ###

n=int(input())
for i in range(n):
	a=int(input())
	b=int(input())
	c=a+b
	c=str(c)
	if len(c)>80:
		print("overflow")
	else:
		print(c)