Harryxun/stf_run huggingface dataset:
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 1

if k == n:
    for i in range(n):
        ans *= a[i]
        ans %= mod
    print(ans)
    exit()
if max(a) < 0:
    a.sort(reverse=True)
    for i in range(k):
        ans *= a[i]
        ans %= mod
    print(ans)
    exit()

plus, minus = [], []
for i in range(n):
    if a[i] >= 0: plus.append(a[i])
    else: minus.append(a[i])

plus.sort()
minus.sort(reverse=True)
while k > 0:
    if len(plus) >= 2: nump = plus[-1] * plus[-2]
    elif len(plus) == 1: nump = plus[-1]
    else: nump = -10**10
    if len(minus) >= 2: numm = minus[-1] * minus[-2]
    elif len(minus) == 1: numm = minus[-1]
    else: numm == -10**10
    if nump > numm or k == 1:
        ans *= plus.pop()
        ans %= mod
        k -= 1
    else:
        ans *= minus.pop()
        ans *= minus.pop()
        ans %= mod
        k -= 2
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 1

if k == n:
    for i in range(n):
        ans *= a[i]
        ans %= mod
    print(ans)
    exit()
if max(a) < 0 and k%2 == 1:
    a.sort(reverse=True)
    for i in range(k):
        ans *= a[i]
        ans %= mod
    print(ans)
    exit()

a.sort(key=lambda x: abs(x))
cnt = 0
for i in range(1, k+1):
    ans *= a[-i]
    ans %= mod
    if a[-i] < 0:
        cnt += 1

if cnt%2 == 0:
    print(ans)
else:
    a_plus = None
    a_minus = None
    b_plus = None
    b_minus = None
    for i in range(k, 0, -1):
        if a[-i] >= 0 and a_plus == None:
            a_plus = a[-i]
        if a[-i] < 0 and a_minus == None:
            a_minus = a[-i]
    for i in range(k+1, n+1):
        if a[-i] >= 0 and b_plus == None:
            b_plus = a[-i]
        if a[-i] < 0 and b_minus == None:
            b_minus = a[-i]
    if a_plus == None or b_minus == None:
        ans *= pow(a_minus, mod-2, mod)
        ans %= mod
        ans *= b_plus
        ans %= mod
    elif a_minus == None or b_plus == None:
        ans *= pow(a_plus, mod-2, mod)
        ans %= mod
        ans *= b_minus
        ans %= mod
    else:
        if abs(a_plus*b_plus) > abs(a_minus*b_minus):
            ans *= pow(a_minus, mod-2, mod)
            ans %= mod
            ans *= b_plus
            ans %= mod
        else:
            ans *= pow(a_plus, mod-2, mod)
            ans %= mod
            ans *= b_minus
            ans %= mod
    print(ans)
c=list(map(int, input().split()))

W = c[0]
H = c[1]
x = c[2]
y = c[3]



if W*y <= float(W*H)/2:
    S1 = W*y
else:
    S1 = W*H - W*y

if H*x <= float(W*H)/2:
    S2 = H*x
else:
    S2 = W*H - H*x

if S1 < S2:
    Sm = S2
    co = 0
elif S1 > S2:
    Sm = S1
    co = 0
else:
    Sm = S1
    co = 1
    
print(Sm,co)

### FIXED CODE ###

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

if x < a:
    print(0)
else:
    print(10)
n =int,input()

print(n*(n+1)/2)

### FIXED CODE ###

n = int(input())

print(round(n*(n+1)/2))
n = int(input())
c = 0
c1=0
for x in range(n):
  a,b = map(int,input().split())
  if a==b:
    c+=1
    if c==3:
        c1 = 1
      	print('Yes')
      	break
  else:
    c=0
if c1==0:
    print('No')


### FIXED CODE ###

n = int(input())
c = 0
c1=0
for x in range(n):
  a,b = map(int,input().split())
  if a==b:
    c+=1
    if c==3:
        c1 = 1
        print('Yes')
        break
  else:
    c=0
if c1==0:
    print('No')
from collections import Counter
import statistics

def calculate_mode(data):
    c = Counter(data)
    # すべての要素とその出現回数を取り出します。
    freq_scores = c.most_common()
    #c.most_common内の最も多い要素[0]の最大出現回数[1]を[0][1]で指定
    max_count = freq_scores[0][1]

    modes = []
    #出現回数と最大出現回数が等しいかを確認します。
    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    return(modes)

n = int(input())
v = list(map(int, input().split()))
a = []
b = []
c = []
d = []
ans = 0
for i in range(len(v)):
    if i%2 == 1:
        a.append(v[i])
        c.append(v[i])
    if i%2 == 0:
        b.append(v[i])
        d.append(v[i])
f = statistics.mode(a)
g = statistics.mode(b)

#if f == g :
    #for i in range(len(a)):
        #if f == a[i]:
            #a.remove(f)
        #if g == b[i]:
            #b.remove(g)
    #f = calculate_mode(a)
    #g = calculate_mode(b)


for i in range(len(a)):
    if f != c[i]:
        ans += 1
    if g != d[i]:
        ans += 1

print(ans)


### FIXED CODE ###

#Miccさんのコードを参考にさせていただきました
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
e = v[1::2] #偶数番号
o = v[0::2] #奇数番号
ans = 0

a = Counter(e) #Counterオブジェクトを作成(dictのサブクラスでキーに要素、値に出現回数をもつ)
b = Counter(o)

c = a.most_common(2) #出現回数が2番目に多い数までのCounterオブジェクト作成
d = b.most_common(2)

if c[0][0] != d[0][0]: #出現回数が１番多いものが違う時
    ans = n -c[0][1] -d[0][1]
else:                  #出現回数が１番多いものが同じ時
    if len(c) == 1:
        if len(d) == 1:
            ans = n//2
        else:
            ans = n -d[0][1]
    elif len(d) == 1 and len(c) != 1:
        ans = n -c[0][1]
    elif c[0][1] > d[0][1]:
        ans = n -c[0][1] -d[1][1]
    else:
        if c[0][1]==d[0][1]:
            ans = min(n-c[0][1]-d[1][1],n-c[1][1]-d[0][1])
        else:
            ans = n -c[1][1] -d[0][1]
    
print(ans)
X,Y = map(input().split()) #input number of animals and legs

crane_legs = 2
turtle_legs = 4

answer = "No"

for i in range(X+1): #X+1 because it will only consider 0,1,2
    remaining = X-i
    if crane_legs*i + turtle_legs*remaining == Y:
        answer = "Yes"
#Loop to check combinations of animals is correct

print(answer)

### FIXED CODE ###

#definiition
x,y= map(int,input().split())
crane= 2
turtle= 4
ans="No"
#Loop
for i in range(x+1):
    b=x-i
    if crane*i + turtle*b == y:
        ans = "Yes"
print(ans)
N = input()
a = []
f = True
for i in range(N):
  a.append(input())
    
for x in range(N-1):
  if a[x][:1] != a[x+1][-1:]:
    f = False
    
if len(a) != len(set(a)):
  f = False

if f:
  print "Yes"
else:
  print "No"

### FIXED CODE ###

N = input()
a = []
f = True
for i in range(N):
  a.append(raw_input())
    
for x in range(N-1):
  if a[x][-1:] != a[x+1][:1]:
    f = False
    
if len(a) != len(set(a)):
  f = False

if f:
  print "Yes"
else:
  print "No"
ok = True
a.sort()
if n%2==0:
    for i in range(n):
        if a[i]!= i-i%2+1:
            ok = False
            break
else:
    for i in range(n):
        if a[i]!= i+i%2:
            ok = False
            break
if ok:
    print(2**(n//2)%(10**9+7))
else:
    print(0)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ok = True
a.sort()
if n%2==0:
    for i in range(n):
        if a[i]!= i-i%2+1:
            ok = False
            break
else:
    for i in range(n):
        if a[i]!= i+i%2:
            ok = False
            break
if ok:
    print(2**(n//2)%(10**9+7))
else:
    print(0)
K = int(input())
S = input()

n = len(s)
if n > K:
  print(S)
else:
  print(S[0:K+1]+'...')

### FIXED CODE ###

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

n = len(S)
if n <= K:
    print(S)
else:
    print(S[0:K] + '...')
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())




n,m=mi()
print("Yes" if n==m else "No")

### FIXED CODE ###

# from math import ceil,sqrt,log,gcd
# def ii():return int(input())
# def si():return input()
# def mi():return map(int,input().split())
# def li():return list(mi())




n,m=map(int,input().split())
if(n==m):
    print("Yes")
else:
    print('No')
s= input()
print(s.replace('7', '8',1))

### FIXED CODE ###

s= input()
print(s.replace('7', '8',1))
n,k = map(input().split())
p = list(int,map(input().split()))
p.sort()
print(sum(p[:k]))

### FIXED CODE ###

n, k = map(int,input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:k]))
l = list(map(int, input().split(' ')))
l.sort()
tmp = l[1]
if (l[1]-1>l[0]):
    print(l[1]+l[0])
else if(l[1]=l[0]):
    print(l[0]+l[1]) 
else :
    print(l[1]*2-1)


### FIXED CODE ###

l = list(map(int, input().split(' ')))
l.sort()
tmp = l[1]
if (l[1]-1<l[0]):
    print(l[1]+l[0])
elif(l[1]==l[0]):
    print(l[0]+l[1])
else :
    print(l[1]*2-1)
N, K = map(int, input().split())

S = input()

if N == 1:
    print(0)
    exit()
#左端をLにする場合
now = ""
num_substr = 0
ex = ""
stack = []
for i in range(N):
    if (ex == "L" or ex == "") and S[i] == "R":
        start = i
    if ex == "R" and S[i] == "L":
        end = i-1
        stack.append((start, end))
        num_substr += 1
    ex = S[i]
#左からひっくり返す
tmp = min(K,num_substr,N)
num = stack[tmp-1][1]
ss = "L"*(num+1)+S[num+1:]
ll = num

for i in range(num+1,N):
    if i == 0:
        if (ss[i+1] == "R" and ss[i] == "R"):
            ll += 1
    elif i == N-1:
        if (ss[i-1] == "L" and ss[i] == "L"):
            ll += 1
    else:
        if (ss[i-1] == "L" and ss[i] == "L") or (ss[i+1] == "R" and ss[i] == "R"):
            ll += 1


#右からひっくり返す
tmp = min(K,num_substr,N)
num = stack[len(stack)-tmp][0]
ss = S[:(N-1-num)]+"L"*(N-1-num)

lr = (N-1-num)

for i in range(num):
    if i == 0:
        if (ss[i+1] == "R" and ss[i] == "R"):
            lr += 1
    elif i == N-1:
        if (ss[i-1] == "L" and ss[i] == "L"):
            lr += 1
    else:
        if (ss[i-1] == "L" and ss[i] == "L") or (ss[i+1] == "R" and ss[i] == "R"):
            lr += 1


######################################################################
#左端をRにする場合
now = ""
num_substr = 0
ex = ""
stack = []
for i in range(N):
    if (ex == "R" or ex == "") and S[i] == "L":
        start = i
    if ex == "L" and S[i] == "R":
        end = i-1
        stack.append((start, end))
        num_substr += 1
    ex = S[i]
#左からひっくり返す
tmp = min(K,num_substr,N)
num = stack[tmp-1][1]
ss = "R"*(num+1)+S[num+1:]
rl = num
#print(ll, tmp)
for i in range(num+1,N):
    if i == 0:
        if (ss[i+1] == "R" and ss[i] == "R"):
            rl += 1
    elif i == N-1:
        if (ss[i-1] == "L" and ss[i] == "L"):
            rl += 1
    else:
        if (ss[i-1] == "L" and ss[i] == "L") or (ss[i+1] == "R" and ss[i] == "R"):
            rl += 1


#右からひっくり返す
tmp = min(K,num_substr,N)
num = stack[len(stack)-tmp][0]
ss = S[:(N-1-num)]+"R"*(N-1-num)

rr = (N-1-num)
#print(ll, tmp)
for i in range(num):
    if i == 0:
        if (ss[i+1] == "R" and ss[i] == "R"):
            rr += 1
    elif i == N-1:
        if (ss[i-1] == "L" and ss[i] == "L"):
            rr += 1
    else:
        if (ss[i-1] == "L" and ss[i] == "L") or (ss[i+1] == "R" and ss[i] == "R"):
            rr += 1


print(max([ll,lr,rl,rr]))





### FIXED CODE ###


N, K = map(int, input().split())
S = input()

ans = 0
for x,y in zip(S, S[1:]):
    if x == y: #同じ方向を見ているとき
        ans += 1
#最大K回まで操作をして、そのたびに幸福な人が二人増える。全員同じ方向を向くとN-1
ans = N-1 if ans+2*K >= N-1 else ans+2*K
print(ans)
import math
a, b, n = map(int, input().split())
ans = [0] * n
for i in range(n):
    ans[i] = math.floor(a * (i+1) / b) - a * math.floor((i+1) / b)
print(max(ans))

### FIXED CODE ###

import math
a, b, n = map(int, input().split())
if b <= n:
    print(math.floor((a * (b-1)) / b) - a * math.floor((b-1) / b))
elif b > n:
    print(math.floor((a * (n)) / b) - a * math.floor((n) / b))
s = input()

if s[0] == s[1] and s[2] == s[3] and s[3] == s[1]:
    print('No')
else:
    print('Yes')


### FIXED CODE ###

S = input()
if S[0] == S[1] and S[1] == S[2]:
    print("No")
else:
    print("Yes")
import sys
while True :
    ab = sys.stdin.readline().split()
    a = ab[0]
    b = ab[1]
    if a == 0 and b == 0 :
        break
    else :
        sorted(ab)
        print(ab[0],ab[1])

### FIXED CODE ###

import sys
while True :
    ab = list(map(int,sys.stdin.readline().split()))
    a = ab[0]
    b = ab[1]
    if a == 0 and b == 0 :
        break
    else :
        ab = sorted(ab)
        print(ab[0],ab[1])
N=int(input())
K=int(input())
import math
x=math.floor(math.log10(N))+1
def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
ans=0
if x<K:
  print(0)
  exit(0)
if K==1:
  ans=(x-1)*9
  ans+=(N//10**(x-1))
  print(ans)
elif K==2:
  for i in range(2,x):
    ans+=(9**2)*(i-1)
  f=(N//10**(x-1))
  n=str(N)
  for i in range(1,x):
    if n[i]!='0':
      s_n=x-i
      s=int(n[i])
      break
  ans+=(f-1)*9*(x-1)
  ans+=9*(s_n-1)
  ans+=s
  print(ans)
else:
  for i in range(3,x):
    ans+=(9**3)*combinations_count(i-1,2)
  f=(N//10**(x-1))
  n=str(N)
  for i in range(1,x):
    if n[i]!='0':
      s_n=x-i
      s=int(n[i])
      break
  for i in range(x-s_n+1,x):
    if n[i]!='0':
      t_n=x-i
      t=int(n[i])
      break
  ans+=(f-1)*9**2*combinations_count(x-1,2)
  ans+=9**2*combinations_count(s_n-1,2)
  ans+=(s-1)*9*(s_n-1)
  ans+=9*(t_n-1)
  ans+=t
  print(ans)

### FIXED CODE ###

Nstr=input()
N=int(Nstr)
K=int(input())
x=len(Nstr)
dp0=[[0]*(K+1) for i in range(x+1)]
dp1=[[0]*(K+1) for i in range(x+1)]

dp1[0][0]=1

for i in range(1,x+1):
  dp0[i][0]=dp0[i-1][0]+dp1[i-1][0]
  for j in range(1,K+1):
    if Nstr[i-1]!='0':
      dp1[i][j]=dp1[i-1][j-1]
      dp0[i][j]+=(dp1[i-1][j-1]*(int(Nstr[i-1])-1)+dp1[i-1][j])
    else:
      dp1[i][j]=dp1[i-1][j]
    dp0[i][j]+=(dp0[i-1][j]+dp0[i-1][j-1]*9)

    
  '''  
  if Nstr[i-1]!='0':
    for j in range(1,K+1):
      dp1[i][j]=dp1[i-1][j-1]
      dp0[i][j]+=(dp1[i-1][j-1]*(int(Nstr[i-1])-1)+dp1[i-1][j])
  else:
    for j in range(1,K+1):
      dp1[i][j]=dp1[i-1][j]
  for j in range(1,K+1):
    dp0[i][j]+=(dp0[i-1][j]+dp0[i-1][j-1]*9)
  '''
print(dp0[x][K]+dp1[x][K])
N,K=map(int,input().split())
V=list(map(int,input().split()))
A=0
s=0
S=0
while A<=K:
  B=0
  while B<=K-A:
    C=0
    while (C<=K-A-B and C<=A+B):
      if A==0:
        s=0
      else:
        for i in range(A):
          s=s+V[i]
      if B==0:
        s=s
      else:
        for j in range(B):
          s=s+V[N-j-1]
      left=[]
      for k in range(A):
        left.append(V[k])
      right=[]
      for l in range(B):
        right.append(V[N-l-1])
      v=left+right
      v=sorted(v)
      for m in range(C):
        s=s-v[m]
      print(v)
      print(s)
      C=C+1
    B=B+1
  A=A+1
        


### FIXED CODE ###

from collections import deque
import itertools
n,k=map(int,input().split())
v=deque(list(map(int,input().split())))
a=0
ans=0
while a<=n and a<=k:
  w=deque(itertools.islice(v,0,None))
  b=0
  A=deque([0])
  for i in range(a):
    p=w.popleft()
    A.append(p)
  while a+b<=n and a+b<=k:
    x=deque(itertools.islice(w,0,None))
    B=deque(itertools.islice(A,0,None))
    for j in range(b):
      B.append(x.pop())
    B=deque(sorted(B))
    c=0
    while c<k-a-b and B[0]<0 and c<a+b:
      B.popleft()
      c=c+1
    V=sum(B)
    if V>ans:
      ans=V
    b=b+1
  a=a+1
print(ans)
j=lambda:map(int,raw_input().split())
n,q=j()
u=1
c=[1]*3+[0]*(n-2)+[1]
exec("a,b=d=j();u+=u in d and a+b-2*u;c[a],c[b]=c[b],c[a];c[u-1]=c[u+1]=1"*q)
print sum(c)-2

### FIXED CODE ###

j=lambda:map(int,raw_input().split())
n,q=j()
u=1
c=[1]*3+[0]*(n-2)+[1]
for p in[-1]*q:a,b=d=j();u+=u in d and a+b-2*u;c[a],c[b]=c[b],c[a];c[u-1]=c[u+1]=1
print sum(c)-2
n = int(input())
h = list(map(int, input().split()))

move = []
cnt = 0

for i in range(n-1):
  if h[i] >= h[i+1]:
    cnt += 1
    if i == n-2:
      move.append(cnt)
  else:
    move.append(cnt)
    cnt = 0

print(max(move))

### FIXED CODE ###

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

higher = [0]
move = [0]

for i in range(1, n):
  if h[i-1] < h[i]:
    m = i - higher[len(higher) - 1] - 1
    move.append(m)
    higher.append(i)

move.append(len(h) - 1 - higher[len(higher) - 1])


print(max(move))
import numpy as np
A, B, C, D = map(int, input().split())

def f(num, c, d):
    return num - (num // c + num // d - num // int(c * d / np.gcd(c, d)))

print (f(B, C, D) - f(A - 1, C, D))


### FIXED CODE ###

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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def f(num, c, d):
    return num - (num // c + num // d - num // int(c * d / gcd(c, d)))

print (f(B, C, D) - f(A - 1, C, D))
s = input()

def iseven(str, n):
    for i in range(0, n/2):
        if str[i] != str[i+n/2]:
            return False
    else:
        return True


for i in range(2, n, 2):
    if iseven(s, n-i):
        print(i)


### FIXED CODE ###

s = input()
n = len(s)
def iseven(str, n):
    for i in range(0, n//2):
        if str[i] != str[i+n//2]:
            return False
    else:
        return True


for i in range(2, n, 2):
    if iseven(s, n-i):
        print(n-i)
        break
s = input()
direction = []
cnt_array = []
cnt = 1
for i in range(1, len(s)):
    if s[i] != s[i - 1]:
        direction.append(s[i - 1])
        cnt_array.append(cnt)
        cnt = 1
    else:
        cnt += 1
else:
    direction.append(s[i])
    cnt_array.append(cnt)

ans = 0
now = 0
ans_array = [now]
for i in range(1, len(direction)):
    if direction[i - 1] == "<" and direction[i] == ">":
        ans_array.append(max(cnt_array[i - 1], cnt_array[i]))
        if cnt_array[i - 1] < cnt_array[i]:
            ans_array.append(cnt_array[i - 1] - 1)
        elif cnt_array[i] < cnt_array[i - 1]:
            ans_array.append(cnt_array[i] - 1)
else:
    if direction[-1] == "<":
        ans += 1
print(ans + sum([(x * (x + 1)) // 2 for x in ans_array]))

### FIXED CODE ###

s = input()
len_s = len(s)
ans_array = [0 for x in range(len_s+1)]
for index in range(len_s):
    if s[index] == "<":
        ans_array[index + 1] = ans_array[index]+1
for index in reversed(range(len_s)):
    if s[index] == ">":
        ans_array[index] = max(ans_array[index+1]+1, ans_array[index])
print(sum(ans_array))
#ABC042B
n,l=map(int,input().split())

a=[]
for i in range(n)
    a.append(input())
    
a.sort()

print(''.join(mylist))

### FIXED CODE ###

# 入力
N,L=map(int,input().split())

l=[]
for i in range(N):
  l.append(input())

# ソート
l.sort()

# 出力
print(''.join(l))
N = int(input())

if N % 10 == 2,4,5,7,9 :
  print("hon")

elif N % 10 == 0,1,6,8 :
  print("pon")

elif N % 10 == 3 :
  print("bon")

### FIXED CODE ###

N = int(input())
hon = [2,4,5,7,9]
pon = [0,1,6,8]
 
if N % 10 in hon :
  print("hon")
 
elif N % 10 in pon :
  print("pon")
 
elif N % 10 == 3 :
  print("bon")
n = int(raw_input())
minv = int(raw_input())
maxv = -10**9

 for j in range(0,n-1):
   nums = int(raw_input())
   diff = nums - minv
   maxv = max(maxv,diff)
   minv = min(minv,nums)
 print maxv

### FIXED CODE ###

n = int(raw_input())
minv = int(raw_input())
maxv = -1*10**9
  
for j in range(n-1):
  nums = int(raw_input())  
  diff = nums - minv
  if maxv < diff:
    maxv = diff
  if nums < minv:
    minv = nums
  
print maxv
class UF:
    def __init__(self, N):
        self.uf = [-1]*N

    def find(self, x):
	if self.uf[x]<0: return x
	self.uf[x] = self.find(self.uf[x])
	return self.uf[x]

    def size(self, x):
	return -self.uf[self.find(x)]

    def union(self, x, y):
	x, y = self.find(x), self.find(y)
	if self.size(x) > self.size(y): x, y = y, x
	self.uf[y] += self.uf[x]
	self.uf[x] = y

N, K, L = list(map(int, input().split()))
uf1, uf2 = UF(N), UF(N)
for _ in range(K):
    p, q = list(map(int, input().split()))
    uf1.union(p-1, q-1)

for _ in range(L):
    r, s = list(map(int, input().split()))
    if uf1.find(r-1)==uf1.find(s-1):
        uf2.union(r-1, s-1)

print(*[uf2.size(x) for x in range(N)])

### FIXED CODE ###

class UF:
    def __init__(self, N):
        self.uf = [-1]*N
        self.n = N

    def find(self, x):
        if self.uf[x]<0: return x
        self.uf[x] = self.find(self.uf[x])
        return self.uf[x]

    def size(self, x):
        return -self.uf[self.find(x)]

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x==y: return
        if self.size(x) > self.size(y): x, y = y, x
        self.uf[y] += self.uf[x]
        self.uf[x] = y
        self.n -= 1

N, K, L = list(map(int, input().split()))
uf1, uf2 = UF(N), UF(N)
for _ in range(K):
    p, q = list(map(int, input().split()))
    uf1.union(p-1, q-1)

for _ in range(L):
    r, s = list(map(int, input().split()))
    uf2.union(r-1, s-1)

keys = [(uf1.find(x), uf2.find(x)) for x in range(N)]
count = {}
for key in keys:
    if key in count: count[key]+=1
    else: count[key]=1

print(*[count[key] for key in keys])
d,n=map(int,input().split())
if d==0 and n=!100:
    print(n)
elif d==0 and n==100:
    print(101)
elif d==1 :
    print(n*100)
elif d==1 and n=!100:
    print(10100)
elif d==2 and n!=100:
    print(n*10000)
else :
    print(1010000)

### FIXED CODE ###

d,n=map(int,input().split())
if d==0 and n!=100:
    print(n)
elif d==0 and n==100:
    print(101)
elif d==1 and n!=100:
    print(n*100)
elif d==1 and n==100:
    print(10100)
elif d==2 and n!=100:
    print(n*10000)
elif d==2 and n==100:
    print(1010000)
n, x = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
count = 0
current = 0
while current <= x and  count <= n:
    current += l[count]
    count += 1
if count > n+1:
    print(n+1)
else:
    print(count)

### FIXED CODE ###

n, x = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
count = 1
current = 0

if sum(l) <= x:
    print(n+1)
else:
    while current <= x:
        current += l[count-1]
        count += 1
    print(count-1)
a = int(input())
s = int(input())
if a >= 3200:
    print(s)
else:
    print('red')

### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print('red')
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    l=list(map(int,input().split()))
    for i in l:
        if l.count(i)==1:
            print(i)
            break
resolve()

### FIXED CODE ###

S=list(map(int,input().split()))
for i in range(3):
    if S.count(S[i])==1:
        print(S[i])
import math

N, M = map(int, input().split())
S = input()
T = input()
gcd = math.gcd(N, M)

if gcd == 1:
    print(N*M)
else:
    sl = [i for i in range(0, N, N//gcd)]
    tl = [i for i in range(0, M, M//gcd)]
    for i in range(len(sl)):
        if S[sl[i]] != T[tl[i]]:
            print(-1)
            break
    else:
        print(N*M//gcd)


### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


N, M = map(int, input().split())
S = input()
T = input()
gcd = gcd(N, M)

sl = [i for i in range(0, N, N//gcd)]
tl = [i for i in range(0, M, M//gcd)]
for i in range(len(sl)):
    if S[sl[i]] != T[tl[i]]:
        print(-1)
        break
else:
    print(N*M//gcd)
n=int(input())
h=list(map(int,input().split()))
ans=0
step=0
for i in range(n):
    cnt=0
    for j in range(n):
        if h[step]<h[step+1]: step+=1; break
        cnt+=1; step+=1
        if step+1==n:break
    ans=max(ans,cnt)
    if step+1==n: break
print(ans)

### FIXED CODE ###

n=int(input())
if n==1:print('0'); exit()
h=list(map(int,input().split()))
ans=0
step=0
for i in range(n):
    cnt=0
    for j in range(n):
        if h[step]<h[step+1]: step+=1; break
        cnt+=1; step+=1
        if step+1==n: break
    ans=max(ans,cnt)
    if step+1==n: break
print(ans)
import math
a, b = map(int, input().split())
for n in range(10000):
    x = math.floor(n * 0.08)
    y = math.floor(n * 0.1)
    if a == x and b == y:
        print(n)
        exit()
print(-1)


### FIXED CODE ###

s = input()
if s == 'AAA' or s == 'BBB':
    print('No')
else:
    print('Yes')