peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from collections import deque

S = deque(input())
Q = int(input())

inv_flag = False
for _ in range(Q):
    query = list(input().split())
    if int(query[0]) == 1:
        inv_flag = not inv_flag
    else:
        if (int(query[1]) - 1) ^ inv_flag:
            S.append(query[2])
        else:
            S.appendleft(query[2])
if inv_flag:
    print(''.join(reversed(S)))
else:
    print(''.join(S))
# Judge status: Accepted
A, B= map(int, input().split())

if A==1:
    A = 14

if B==1:
    B = 14

if A > B:
    print("Alice")
elif B > A:
    print("Bob")
else :
    print("Draw")
# Judge status: Accepted
n = int(input())
s = input()

m = 0
now = 0
for i in s:
    if i == ')':
        now += 1
        if m < now:
            m = now
    else:
        now -= 1

print('('*m + s + ')'*(m + 2*s.count('(') - len(s)))
# Judge status: Wrong Answer
n = int(input())  
num_list = []
for i in range(n):
    num_list.append(list(map(int,input().split())))

ans = []
for i in range(n):
  a = num_list[i]
  a1= a[0]
  a2 = a[1]
  if a1 == a2:
    ans.append(1)
    if i > 1 and ans[i-2] == 1 and ans[i-1] == 1 and ans[i] == 1:
      print('Yes')
      break
  else:
    ans.append(0)
if len(ans) == n and n != i+1 :
  print('No')
# Judge status: Accepted
x,y = map(int,input().split())
if x%y == 0:
    print(-1)
else:
    print(x)
# Judge status: Wrong Answer
N = int(input())
ans = 0
for i in range(1,N):
    string_i = str(i)
    if len(string_i)%2 != 0:
        ans += 1
print(ans)
# Judge status: Accepted
n,k = map(int,input().split())
a = tuple(map(int,input().split()))

for i in range(n-k):
  if a[i] < a[k+i]:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
#!/usr/bin/env python3
n = int(input())
ans = 0


def gcd(n, m):
    a, b = n, m
    if a > b:
        a, b = b, a
    while a != 0:
        a, b = b % a, a
    return b


for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            ans += gcd(k, gcd(i, j))
print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
s=input()

if s[a]=="-" and s.count("-")==1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
x, y = map(int, input().split())
if x >= 0 and y >= 0:
  if x <= y:
    print(y-x)
  else:
    if y == 0:
      print(abs(y-x)+1)
    else:
      print(abs(y-x)+2)
elif x < 0 and y >= 0:
  print(min(y+abs(x), abs(y-abs(x))+1))
elif x >= 0 and y < 0:
  print(abs(abs(y)-abs(x))+1)
else:
  if x <= y:
    print(abs(abs(y)-abs(x)))
  else:
    print(abs(abs(y)-abs(x))+2)
# Judge status: Accepted
a,b,n=map(int,input().split())
if n<b:
    print((a*n)//b)
else:
    print((a*(b-1))//b)
# Judge status: Wrong Answer
S = input()

if (S == 'Sunny'):
    print('Cloudy')
elif (S == 'Cloudy'):
    print('Rainny')
else:
    print('Sunny')
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
cnt2 = 0
cnt4 = 0

for x in a:
    if x%4==0:
        cnt4 += 1
    elif x%2==0:
        cnt2 += 1

if cnt4 + cnt2//2 >= n//2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
f=lambda:map(int,input().split())
k,n=f()
l=list(f())
m=k+l[0]-l[-1]
for i in range(n-1):
  m=max(m,l[i+1]-l[i])
print(k-m)
# Judge status: Wrong Answer
n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

def gcd(a, b):
  if a == 0:
    return b
  return gcd(b % a, a)

l = 1
for i in range(n):
    a[i] //= 2
    l = l * a[i] // gcd(l, a[i])
    if l > 1000000000:
        print(0)
        exit()


ans = m // l
print(ans // 2 + ans % 2)
# Judge status: Wrong Answer
N = int(input())

L0 = 2
L1 = 1

if N == 1:
  ans = L0
elif N == 2:
  ans = L1
else:
  prepre = L0
  pre = L1
  ans=0
  for n in range(2,N+1):
    ans = prepre + pre
    prepre = pre
    pre = ans

print(ans)
# Judge status: Wrong Answer
n = input()
li_n = list(map(int, list(n)))
n = int(n)

rev_pay = []

pls = 0
for i in li_n[::-1]:
  if i + pls <= 5:
    rev_pay.append(i + pls)
    pls = 0
  else:
    rev_pay.append(0)
    pls = 1
if pls == 1:
  rev_pay.append(1)
pay = rev_pay[::-1]
# print(int("".join(map(str, pay))))

turi = int("".join(map(str, pay))) - n

# print(turi)
turi_li = list(str(turi))
# print(turi_li)
ans = sum(pay) + sum(map(int, turi_li))
print(ans)
# Judge status: Accepted
X = int(input())
i = 1
flag = 0
while flag == 0:
    if (360*i) % X ==0:
        flag = 1
    else:
        i += 1

print((360*i)//X)
# Judge status: Wrong Answer
from math import gcd

N = int(input())
T = []

for _ in range(N):
   T.append(int(input()))

res = 0

for i in range(N):
   res = gcd(res, T[i])

print(res)
# Judge status: Accepted
def actual(n, t, a, H):
    avg_temperture = lambda height: t - (height * 0.006)
    diff_a = lambda avg_temperture: abs(avg_temperture - a)

    temperature_diffs = [diff_a(avg_temperture(h)) for h in H]

    return temperature_diffs.index(min(temperature_diffs)) + 1

n = int(input())
t, a = map(int, input().split())
H = map(int, input().split())

print(actual(n, t, a, H))
# Judge status: Accepted
A, B = [int(_) for _ in input().split()]

if A <= 8 and B <= 8:
    ans = "Yay!"
else:
    ans = ":("

print(ans)
# Judge status: Wrong Answer
n, a, b, c, d = map(int, input().split())
s = input()

if '##' in s[a-1:d]:
    print('No')
    exit()

if c < d:
    print('Yes')
    exit()

if '...' in s[b-2:d]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
xx = list(map(int, input().split()))
x=sorted(xx)

for i in range(n):
    if xx[i] < x[n //2]:
        print(x[n // 2])
    else:
        print(x[(n - 1) // 2])
# Judge status: Accepted
from math import gcd
n = int(input())
a = list(map(int,input().split()))
l,r = [a[0]]*n,[a[n-1]]*n
for i in range(1,n-1):
  l[i] = gcd(l[i-1],a[i])
  r[n-i-1] = gcd(r[n-i],a[n-i-1])
ans = [0]*n
ans[0] = r[1]
ans[n-1] = l[n-2]
for i in range(1,n-1):
  ans[i] = gcd(l[i-1],r[i+1])
print(max(ans))
# Judge status: Accepted
d, t, s = map(int, input().split())

if d <= t * s:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a, b = map(int, input().split())
ans = a
if a > b:
  ans -= 1
print(ans)
# Judge status: Accepted
n=int(input())
c=input()
from collections import Counter
w=Counter(c)["W"]
r=0
ans=w
for i in range(n-1,-1,-1):
    if c[i]=="W":
        w-=1
    else:
        r+=1
    ans=min(ans,max(r,w))
print(ans)
# Judge status: Accepted
a,*t=map(int,open(0));c=0
for t in t:
  b=a+t;a=a*(0<a%10<t%10 or t%10<1)or t
  b-=a;c+=b+(10-b%10)*(b%10>0)
print(c+a)
# Judge status: Wrong Answer
import sys
input = lambda: sys.stdin.readline().rstrip()
 
n = int(input())
a = list(map(int, input().split()))
a.sort()
a_max = a[-1]

import bisect

idx_1 = bisect.bisect_left(a, a_max//2)
idx_2 = bisect.bisect_left(a, a_max//2 + 1)

b = [a[idx_1], a[idx_1 - 1], a[idx_2], a[idx_2 - 1]]
ans = [0, 10**10]
for i in b:
    if i == a_max:
        continue
    if a_max//2 - i < ans[1] or a_max//2 + 1 - i < ans[1]:
        ans = [i, a_max - i]
print(a_max, ans[0])
# Judge status: Accepted
n, a, b = [int(_) for _ in input().split()]
print((n // (a + b)) * a + min(n % (a + b), a))
# Judge status: Accepted
from math import floor
a,b,n=map(int,input().split())
x=min(b-1,n)
print(floor(a*x/b)-a*floor(x/b))
# Judge status: Wrong Answer
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

for i in range(M):
  for j in range(BC[i][0]):
    if BC[i][1] > heapq.nsmallest(1, A)[0]:
      heapq.heappop(A)
      heapq.heappush(A, BC[i][1])
    else:
      break
      
print(sum(A))
# Judge status: Accepted
N = int(input())
fmax = int(N/4)+1
smax = int(N/7)+1
for i in range(fmax+1):
  for j in range(smax+1):
    if (4*i+7*j) == N:
      print('Yes')
      exit()
print('No')
# Judge status: Accepted
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = [k[0] for k in sorted({i:ai for i, ai in enumerate(a, 1)}.items(), key=lambda x: x[1])]
    print(*ans)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N,A,B=map(int,input().split())
print(N//(A+B)*A+N%(A+B))
# Judge status: Accepted
N, K = map(int, input().split())

A = [0]*N

for i in range(K):
  d = int(input())
  B = list(map(int, input().split()))
  for j in range(d):
    a = B[j]
    A[a-1] += 1
    
ans = 0
    
for i in range(N):
  if A[i] == 0:
    ans += 1
    
print(ans)
# Judge status: Accepted
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))
B = list(map(int, sys.stdin.readline().rsplit()))

a = 0
b = 0
for i in range(N):
    if A[i] > B[i]:
        a += A[i] - B[i]
    elif B[i] > A[i]:
        b += (B[i] - A[i]) // 2

if b >= a:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def main():
    x = int(input())
    ans = x // 11
    x -= ans * 11
    ans *= 2
    if x <= 0:
        print(ans)
    elif x <= 6:
        print(ans + 1)
    else:
        print(ans + 2)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import math
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
  x=math.ceil(math.log2(k/i))
  ans+=0.5**x
print(ans/n)
# Judge status: Accepted
N = int(input())
V = list(map(int, input().split()))

hoge = [1,1]
for i in range(1,N-1):
    hoge.append(2**i)

V.sort()
ans = 0
for i in range(len(hoge)):
    ans += hoge[i] * V[i]
print(ans/2**(N-1))
# Judge status: Accepted
a, b = map(int, input().split())
if (a < 9) and (b < 9):
  print("Yay!")
else:
  print(":(")
# Judge status: Accepted
N = int(input())
a_list = list(map(int, input().split()))
c = 0

for i in range(N):
    if a_list[i]  % 2 != 0:
        a = 1
    else:
        if (a_list[i] % 3 != 0) and (a_list[i] % 5 != 0):
            c = 1
        else:
            a = 1


if c == 1:
    print("DENIED")
else:
    print("APPROVED")
# Judge status: Wrong Answer
a,b = map(int, input().split())
if a>0 and b>0:
    print("Positive")
elif a<0 and b>0:
    print("Zero")
elif a<0 and b<0:
    print("Negative")
# Judge status: Accepted
N, K = map(int, input().split())

ans = dict()
for i in range(N):
    a, b = map(int, input().split())
    if a in ans:
        ans[a] += b
    else:
        ans[a] = b
    
ans = sorted(ans.items(), key=lambda x:x[0])    
count = 0
for k, v in ans:
    count += v
    if count >= K:
        print(k)
        exit()
# Judge status: Wrong Answer
n, d = map(int,input().split())
d = d*d
sumd = 0
for _ in range(n):
  a, b = map(int,input().split())
  if d <= a**2 + b **2: sumd += 1
print(sumd)
# Judge status: Accepted
x, y, z = map(int, input().split())
if abs(y-x) < abs(z-x):
    print("A")
else:
    print("B")
# Judge status: Wrong Answer
N,M = map(int,input().split())

lst = [-1]*N
flag = False

for _ in range(M):
  s,c = map(int,input().split())
  if lst[s-1] > -1 and lst[s-1] != c:
    flag = True
  elif s == 1 and c== 0:
    flag = True
  else:
    lst[s-1] = c
if flag:
  print("-1")
else:
  for i in range(N):
    if i == 0 and lst[i] == -1:
      lst[i] = 1
    elif lst[i] == -1:
      lst[i] = 0
  print("".join(map(str,lst)))
# Judge status: Accepted
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    if n == 25:
        print("Christmas")
    elif n == 24:
        print("Christmas Eve")
    elif n == 23:
        print("Christmas Eve Eve")
    elif n == 22:
        print("Christmas Eve Eve Eve")
    return


if __name__ == "__main__":
    main()
# Judge status: Accepted
n,m = [int(x) for x in input().split()]
x = sorted([int(x) for x in input().split()])
l = sorted([abs(x[i+1] - x[i]) for i in range(m-1)], reverse=True)

ans = 0

if not l:
    pass
else:
    ans = sum(l[n-1:])

print(ans)
# Judge status: Wrong Answer
a = int(input())
s = input()

if a >= 3200:
  print(s)
else:
  print("pink")
# Judge status: Accepted
from fractions import gcd
def lcm(L):
    x = L[0]
    for i in range(1, len(L)):
        x = (x*L[i])//gcd(x, L[i])
    return x

n = int(input())
T = set()
ans = 1
for i in range(n):
    T.add(int(input()))
print(lcm(list(T)))
# Judge status: Accepted
N = int(input())
Blue = [str(input()) for i in range(N)]
M = int(input())
Red = [str(input()) for i in range(M)]
Blue_Set = list(set(Blue))
X = 0
for i in range(len(Blue_Set)):
  if (Blue.count(Blue_Set[i]) - Red.count(Blue_Set[i])) > X:
    X = Blue.count(Blue_Set[i])-Red.count(Blue_Set[i])
print(X)
# Judge status: Wrong Answer
N = int(input())
Ss = [input() for _ in range(N)]

import collections

c = collections.Counter(Ss)
print(c)
print("AC x " + str(c["AC"]))
print("WA x " + str(c["WA"]))
print("TLE x " + str(c["TLE"]))
print("RE x " + str(c["RE"]))
# Judge status: Accepted
n, x, t = map(int, input().split())
m = n//x
if n%x==0:
  print(m*t)
else:
  print(m*t+t)
# Judge status: Wrong Answer
n, x = map(int, input().split())
p = set(map(int, input().split()))

ans = 0
for i in range(1, 102):
  if i in p:
    continue
  if i < x:
    ans = i
  elif x - ans > i - x:
    ans = i
    break
print(ans)
# Judge status: Wrong Answer
n=int(input())
x=1
for i in range(1,n+1):
    x=x*(i%(10**9+7))
print(x)
# Judge status: Accepted
n = int(input())
xx = list(map(int, input().split()))
yy = sorted(xx)

a = yy[n//2-1]
b = yy[n//2]

for x in xx:
  if x <= a:
    print(b)
  elif x >= b:
    print(a)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 12:16:43 2020

@author: PREET MODH
"""

input()
a=list(map(int,input().split()))
i=0
sum=0
a.append(1000000000)
while(i+1<len(a)-1):
    b=a[i]
    store=0
    if i+1<len(a):
        store=min(a[i+1],a[i+2])
    diff=abs(b-store)
    sum=sum + diff
    if store==a[i+1]:
        i=i+1
    else:
        i=i+2
print(sum)
# Judge status: Accepted
a, b = input().split()
if a < b:
    print(a * int(b))
elif a > b:
    print(b * int(a))
else:
    print(a * int(a))
# Judge status: Wrong Answer
x, y, a, b, c = list(map(int, input().split(' ')))
p_list = sorted(list(map(int, input().split(' '))), reverse=True)
q_list = sorted(list(map(int, input().split(' '))), reverse=True)
r_list = sorted(list(map(int, input().split(' '))), reverse=True)

xy_list = sorted(p_list[:x] + q_list[:y])

i = 0
for r in range(c):
    if r_list[r] > xy_list[0]:
        i += 1
    else:
        break

if i == 0:
    print(sum(xy_list))
else:
    print(sum(xy_list[i:] + r_list[:i]))
# Judge status: Accepted
n, m = map(int, input().split())

if n % m == 0:
    print(0)
else:
    print(1)
# Judge status: Wrong Answer
data = input()

if data[2] == data[3] and data[4]==data[5]:
  print("Yes")
else:
  print("False")
# Judge status: Accepted
n,*a=open(0)
a=list(map(int,a[0].split()))
b=sorted(a)
c=[a-b for a,b in zip(a,b)]
d=int(n)-c.count(0)
print("YES" if d==0 or d==2 else "NO")
# Judge status: Wrong Answer
A,B = [int(i) for i in input().split()]
for i in range(101):
    if int(i*0.08)==A and int(i*0.1)==B:
        print(i);exit()
print(-1)
# Judge status: Accepted
def resolve():
    S = list(input())

    ans = 0
    for i in range(1, len(S)):
        if (S[i - 1] == S[i]):
            ans += 1

            if S[i] == '0':
                S[i] = '1'
            else:
                S[i] = '0'

    print(ans)


resolve()
# Judge status: Wrong Answer
S = [False if s == "<" else True for s in input()]

N = len(S) + 1

a = [0] * N

for i in range(N-1):
    if not S[i]:
        a[i+1] = a[i] + 1

for i in range(N-2, 0, -1):
    if S[i]:
        a[i] = max(a[i], a[i+1] + 1)

print(sum(a))
# Judge status: Wrong Answer
n=int(input())
k=[]
for _ in range(n):
    x,y=map(int,input().split())
    k.append(x+y)


p=max(k)
q=min(k)
print(p-q)
# Judge status: Accepted
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

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

print(gcd_list(a))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
lis=[0]*9
for num in a:
    lis[min(8,num//400)]+=1
kind=0
for i in range(8):
    if lis[i]>0:
        kind+=1
if kind==0:
    mini=1
else:
    mini=kind
maxi=kind+lis[8]
print(mini,maxi)
#print(lis)
# Judge status: Accepted
from math import sqrt
n = int(input())
x,y,s = [],[],0
for _ in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
for i in range(n):
    for j in range(n):
        a = x[i]-x[j]
        b = y[i]-y[j]
        s += sqrt(a*a+b*b)
print(s/n)
# Judge status: Accepted

"""
全探索は無理なオーダー
N個のこま，
M - N回の移動が必要
−＞間の距離の長いのを移動しないように配置すれば良い
"""
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
if N >= M:
    print(0)
    exit()

dist = [X[i+1] - X[i] for i in range(M-1)]
dist.sort(reverse=True)

count = sum(dist)
for i in range(N-1):
    count -= dist[i]

print(count)
# Judge status: Wrong Answer
K=int(input())
if K%2==0:
  print( K//2 * 2 )
else:
  print( K//2 * (K//2+1) )
# Judge status: Accepted
s = list(input())
flag = 1
if s[0] == "A" :
    if s[2:-1].count("C") == 1 :
        for i in range(1,len(s)) :
            if i != s[2:-1].index("C") + 2 :
                if s[i] != s[i].lower() :
                    flag = 0
                    break
    else :
        flag = 0
else :
    flag = 0

print("AC" if flag ==1 else "WA")
# Judge status: Accepted
A,B,M= map(int,input().split())
A_list = list(map(int,input().split()))
B_list = list(map(int,input().split()))
coupon = []
for _ in range(M):
  x,y,d = map(int,input().split())
  coupon.append([x,y,d])
mini = min(A_list) + min(B_list)
Answer = mini

for i in range(M):
  discount = A_list[coupon[i][0]-1] + B_list[coupon[i][1]-1] - coupon[i][2]
  if discount < Answer:
    Answer = discount
print(Answer)
# Judge status: Accepted
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())

N = int(input())

cnt = 0
for i in range(1, N+1) :
  if len(str(i)) % 2 == 1 :
    cnt += 1

print (cnt)
# Judge status: Wrong Answer
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if x*y%3!=0:
  print(0)
else:
  m=int((2*x-y)/3)
  n=int(x-2*m)
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,n,mod))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
n = A[0]
r = A[1]
for a in A[1:]:
    if abs((n/2)-r) > abs((n/2)-a):
        r = a
print(n,r)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
tmp = []
count = 0
for i in range(n):
  tmp.append(p[i])
  if len(tmp)==3:
    if sorted(tmp)[1]==p[i-1]:
      count+=1
    tmp.pop(0)
print(count)
# Judge status: Accepted
k = int(input())
s = input()
if len(s) <= k:
    print(s)
else:
    print(s[:k] + '...')
# Judge status: Accepted
# 数値の取得
a = int(input())
b = int(input())
h = int(input())
 
# 面積を求めて出力
area = int((a + b) * h / 2)
print(area)
# Judge status: Accepted
n,m = map(int,input().split())
l_max,r_min = 0,n
for i in range(m):
    l,r = map(int,input().split())
    l_max = max(l,l_max)
    r_min = min(r,r_min)
print(max(r_min - l_max +1 , 0))
# Judge status: Accepted
n,k = map(int,input().split())
l1 = list(map(int,input().split()))
l = list(i-1 for i in l1)
bit = list(0 for i in range(n))
bit[0] =1
mi = [0]
m = l[0]
er = 0
while er ==0:
  if bit[m]==1:
    a = mi.index(m)
    r = mi[a:]
    er  =1
  else:
    bit[m] = 1
    mi.append(m)
    m = l[m]
 # print(bit)
be = mi[:a]+r
#print(be,r)
if k< len(be):
  print(be[k]+1)
else:
  w = k-len(be)+1
  u = (w%len(r))-1
  print(r[u]+1)
# Judge status: Wrong Answer
a=input()
if(a[0]==a[1]):
    print("Bad")
elif(a[1]==a[2]):
    print("Bad")
elif(a[2]==a[3]):
    print("Bad")
else:
    print("Yes")
# Judge status: Wrong Answer
S = list(input())
n = len(S)

s1 = 0
s2 = 0

for i in range(n):
    if i%2 == 0:
        if S[i] == '1':
            s1 += 1
        else:
            s2 += 1
    else:
        if S[i] == '0':
            s2 += 1
        else:
            s1 += 1
print(min(s1, s2))
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ka = []
cnt = 0
ans = 0
for i in range(n):
    ka_memo = list(map(int, input().split()))
    ka_memo.sort()
    ka.append(ka_memo)

for i in range(1, m + 1):
    cnt = 0
    for j in range(n):
        for k in range(1, ka[j][0] + 1):
            if ka[j][k] == i:
                cnt += 1
        if cnt == n:
            ans += 1

print(ans)
# Judge status: Accepted
s = [i for i in input()]
abc = [chr(i) for i in range(97,97+26)]
for p in s:
  try:
    abc.remove(p)
  except:
    pass
try:
  print(abc[0])
except:
  print("None")
# Judge status: Wrong Answer
n, T = map(int, input().split())
ans = 10000
for _ in range(n):
    c, t = map(int, input().split())
    if t <= T:
        ans = min(ans, c)
print(ans)
# Judge status: Accepted
h, w = map(int, input().split())

syou, amari = divmod(h, 2)
if w % 2 == 1:
    a = w // 2 + 1
    ans = (a + a - 1)* syou + a * amari
else:
    a = w / 2
    ans = (a + a)* syou + a * amari
if h == 1 or w == 1:
    print(1)
else:
    print(int(ans))
# Judge status: Accepted
N, M = map(int, input().split())
if N == 1 and M == 1:
  print(1)
elif N == 1 or M == 1:
  print(max(N, M) - 2)
else:
  print((N - 2)*(M - 2))
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()
n, k = map(int, input().split())
a = list(map(int, input().split()))

now = 1
# for i in range(k):
#     now *= a[i]
# before = now

for i in range(n - k):
    # now *= a[i + k]
    # now /= a[i]
    if a[i] < a[i + k]:
        print('Yes')
    else:
        print('No')
    # before = now
# Judge status: Accepted
lis  = list(map(int,input().split()))

while True:
    lis[2] -= lis[1]
    if lis[2] <= 0:
        print("Yes")
        break
    lis[0] -= lis[3]
    if lis[0] <= 0:
        print("No")
        break
# Judge status: Accepted
from fractions import gcd
a,b=map(int,input().split())
print(a*b//gcd(a,b))
# Judge status: Wrong Answer
# 整数の入力
N = int(input())
if N >1:
    print(int((10 ** (N-2) * N * (N-1) / 2) % (10**9 + 7)))
else:
    print(0)
# Judge status: Accepted
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

table = defaultdict(int)
ans = 0
for a in A:
    table[a] += 1
    ans += a

for _ in range(Q):
    B, C = map(int, input().split())
    diff = table[B] * (C - B)
    table[C] += table[B]
    table[B] = 0
    ans += diff
    print(ans)
# Judge status: Accepted
import fractions
A,B,C,D=map(int,input().split())
c=B//C-(A-1)//C
d=B//D-(A-1)//D
lm=C*D//fractions.gcd(C,D)
cd=B//lm-(A-1)//lm

print(B-A+1-c-d+cd)
# Judge status: Accepted
import sys

n = int(sys.stdin.readline().rstrip())
a = [0] + [int(x) for x in sys.stdin.readline().split()]
b = [0] + [int(x) for x in sys.stdin.readline().split()]

def main():
    for i in range(n):
        a[i+1] += a[i]
        b[i+1] += b[i]
    res = 0
    for i in range(1, n + 1):
        res = max(res, a[i] + b[n] - b[i-1])
    print(res)

if __name__ ==  '__main__':
    main()
# Judge status: Accepted
a,b = map(int, input().split())

if (a*b)%2 == 1 :print("Odd")
else: print("Even")
# Judge status: Accepted
n=int(input())
c=list(input())

import math

rkosu=c.count("R")
wkosu=n-rkosu

ca=["R"]*rkosu+["W"]*wkosu

count=0
for i in range(n):
    if c[i] != ca[i]:
        count+=1

ans=math.ceil(count/2)
print(ans)
# Judge status: Accepted
N,P=map(int, input().split())
*A,=map(int, input().split())
odd=sum(1 for a in A if a&1)
if odd==0:
    if P==1:
        print(0)
    else:
        print(1<<N)
else:
    print(1<<(N-1))
# Judge status: Accepted
s = input()
import re
sep = 'B|D|E|F|H|I|J|K|L|M|N|O|P|Q|R|S|U|V|W|X|Y|Z'
print(max([len(i) for i in re.split(sep, s)]))
# Judge status: Accepted
X, Y = map(int, input().split())

cnt = 0

while X<=Y:
    X *= 2
    cnt += 1

print(cnt)
# Judge status: Wrong Answer
N, M = list(map(int,input().split()))

x = M - 2 * N
if x > 0:
  N += x // 4

print(N)
# Judge status: Accepted
a,b = map(int, input().split())
print(a if a <= b else a-1)