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

import sys,collections as cl,bisect as bs,copy
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

h,w = m()

k = [[0 for j in range(w)] for i in range(h)]
for i in range(h):
	l = list(input())
	for j in range(w):
		if l[j] != "#":
			k[i][j] = 1

kk = copy.deepcopy(k)
ma = 0
for i in range(h):
	for j in range(1,w):
		if k[i][j] != 0:
			k[i][j] += k[i][j-1]
	for j in range(w-2,-1,-1):
		if k[i][j] != 0 and k[i][j+1]  != 0:
			k[i][j] = k[i][j+1]

for i in range(w):
	for j in range(1,h):
		if kk[j][i] != 0:
			kk[j][i] += kk[j-1][i]
	for j in range(h-2,-1,-1):
		if kk[j][i] != 0 and kk[j+1][i] != 0:
			kk[j][i] = kk[j+1][i]

for i in range(h):
	for j in range(w):
		if ma <= kk[i][j] + k[i][j] - 1:
			ma = kk[i][j] + k[i][j] - 1
print(ma)


### FIXED CODE ###

import sys,collections as cl,bisect as bs,copy
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

h,w = m()

k = [[0 for j in range(w)] for i in range(h)]
for i in range(h):
	l = list(input())
	for j in range(w):
		if l[j] != "#":
			k[i][j] = 1

kk = copy.deepcopy(k)
ma = 0
for i in range(h):
	for j in range(1,w):
		if k[i][j] != 0:
			k[i][j] += k[i][j-1]
	for j in range(w-2,-1,-1):
		if k[i][j] != 0 and k[i][j+1]  != 0:
			k[i][j] = k[i][j+1]

for i in range(w):
	for j in range(1,h):
		if kk[j][i] != 0:
			kk[j][i] += kk[j-1][i]
	for j in range(h-2,-1,-1):
		if kk[j][i] != 0 and kk[j+1][i] != 0:
			kk[j][i] = kk[j+1][i]

for i in range(h):
	for j in range(w):
		if ma <= kk[i][j] + k[i][j] - 1:
			ma = kk[i][j] + k[i][j] - 1
print(ma)
### BUGGY CODE ###

inList = []
startCnt = int(input())
goalCnt = 0
for i in range(5):
    inList.append(int(input()))
endCnt = startCnt
stausList = [0] * 5
cnt = 0
stausList[0] = startCnt
while goalCnt < endCnt:
    if inList[4] >= stausList[4]:
        goalCnt += stausList[4]
        stausList[4] = 0
    else:
        goalCnt += inList[4]
        stausList[4] -= inList[4]

    if stausList[4] == 0:
        if inList[3] >= stausList[3]:
            stausList[4] = stausList[3]
            stausList[3] = 0
        else:
            stausList[4] = inList[3]
            stausList[3] -= inList[3]
    else:
        if inList[3] >= abs(stausList[4] - stausList[3]):
            stausList[4] += abs(stausList[4] - stausList[3])
            stausList[3] -= abs(stausList[4] - stausList[3])
        else:
            stausList[4] += abs(stausList[4] - inList[3])
            stausList[3] -= abs(stausList[4] - inList[3])

    if stausList[3] == 0:
        if inList[2] >= stausList[2]:
            stausList[3] = stausList[2]
            stausList[2] = 0
        else:
            stausList[3] = inList[2]
            stausList[2] -= inList[2]
    else:
        if inList[2] >= abs(stausList[3] - stausList[2]):
            stausList[3] += abs(stausList[3] - stausList[2])
            stausList[2] -= abs(stausList[3] - stausList[2])
        else:
            stausList[3] += abs(stausList[3] - inList[2])
            stausList[2] -= abs(stausList[3] - inList[2])

    if stausList[2] == 0:
        if inList[1] >= stausList[1]:
            stausList[2] = stausList[1]
            stausList[1] = 0
        else:
            stausList[2] = inList[1]
            stausList[1] -= inList[1]
    else:
        if inList[1] >= abs(stausList[2] - stausList[1]):
            stausList[2] += abs(stausList[2] - stausList[1])
            stausList[1] -= abs(stausList[2] - stausList[1])
        else:
            stausList[2] += abs(stausList[2] - inList[1])
            stausList[1] -= abs(stausList[2] - inList[1])

    if stausList[1] == 0:
        if inList[0] >= stausList[0]:
            stausList[1] = stausList[0]
            stausList[0] = 0
        else:
            stausList[1] = inList[0]
            stausList[0] -= inList[0]
    else:
        if inList[0] >= abs(stausList[1] - stausList[0]):
            stausList[1] += abs(stausList[1] - stausList[0])
            stausList[0] -= abs(stausList[1] - stausList[0])
        else:
            stausList[1] += abs(stausList[1] - inList[0])
            stausList[0] -= abs(stausList[1] - inList[0])
    cnt += 1
print(cnt)

### FIXED CODE ###

inList = []
startCnt = int(input())
goalCnt = 0
minLst = 1000000000000000
for i in range(5):
    A = int(input())
    inList.append(A)
    minLst = min(minLst, A)
ans = (-(-startCnt // minLst)) + 4
print(ans)
### BUGGY CODE ###

import bisect
from collections import Counter
N = int(input())
p = list(map(int, input().split()))

cnt = Counter(p)

ps = set(p)
plst = list(ps)
plst.sort()
temp = plst[:]
ans = 0
while temp:
    jdg = True
    q = temp[0]
    m = bisect.bisect_left(temp, 2*q)
    if len(temp)==1: lst = []
    else: lst = temp[1:m]
    for i in temp[m:]:
        if i%q!=0: lst.append(i)
    if cnt[q] == 1: ans += 1
    temp = lst[:]

print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
p = list(map(int, input().split()))

cnt = Counter(p)

ps = set(p)
plst = list(ps)
plst.sort()

ans = [0] * (plst[-1] + 1)

for i in range(len(plst)):
    for j in range(plst[i], plst[-1]+1, plst[i]):
        ans[j] += 1
d = 0
for i in range(len(plst)):
    if ans[plst[i]]==1 and cnt[plst[i]]==1: d += 1
print(d)
### BUGGY CODE ###

A, B, N = map(int, input().split())

# x=0の場合、値は0
ans = 0
# x=1～Nについて
for x in range(1, min(B+1,N+1)):
    if (A*x)//B - A*(x//B) > ans:
        ans = (A*x)//B - A*(x//B)
        
print(ans)

### FIXED CODE ###

A, B, N = map(int, input().split())

if N>=B:
    print(A*(B-1)//B)
else:
    print(A*N//B)
### BUGGY CODE ###

def check_sosu(x):
  for i in range(2,x//2+1):
    if x%i==0:
      return False
  return True
sosu=[]
for i in range(1,10**3+1):
  if check_sosu(i):
    sosu.append(i)
n=int(input())
ans=1
p=10**9+7
for i in sosu:
  if i<=n:
    stack=0
    num=i
    while num<=n:
      stack+=n//num
      num*=i
    ans*=(stack+1)
    ans%=p
print(ans)
      

### FIXED CODE ###

sosu=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]
n=int(input())
ans=1
p=10**9+7
for i in sosu:
  if i<=n:
    stack=0
    num=i
    while num<=n:
      stack+=n//num
      num*=i
    ans*=(stack+1)
    ans%=p
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, K: int, A: "List[int]"):
    p = 1
    for i in range(K):
        p*=A[i]
    
    for i in range(K, N):
        pre = p
        p = p // A[i-K] * A[i]
        if p > pre: print(YES)
        else: print(NO)
        pre = p

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from collections import deque

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, K: int, A: "List[int]"):

    A = deque(A)
    a = deque()

    p = 1
    for i in range(K):
        t=A.popleft()
        a.append(t)
    
    for i in range(K, N):
        t = A.popleft()
        c = a.popleft()
        if t > c: print(YES)
        else: print(NO)
        a.append(t)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

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

import sys


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


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = 10 ** 18


def main():
    N = int(input())
    A = list(map(int, input().split()))
    answer = 1
    for i in range(N):
        answer *= A[i]

    if answer > INF:
        print(-1)
    else:
        print(answer)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys


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


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = 10 ** 18


def main():
    N = int(input())
    A = list(map(int, input().split()))
    if 0 in A:
        print(0)
        return

    answer = 1
    for i in range(N):
        answer *= A[i]
        if answer > INF:
            print(-1)
            return

    print(answer)


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

from collections import deque 
n, m = map(int, input().split())
es = [[] for i in range(n)]
co = [[] for i in range(n)] # 有効辺の向きを逆にした
for i in range(n - 1 + m):
    a, b = map(int, input().split())    
    es[a - 1].append(b - 1)
    co[b - 1].append(a - 1)

v = 0
while co[v]:
    v = co[v][0]

parent = [-1] * n
parent[v] = 0

q = deque([v])

while q:
    v = q.popleft()
    for e in es[v]:
        f = 1
        for p in co[e]:
            if parent[p] == -1:
                f = 0
                break
        if f:
            parent[e] = v + 1
            q.append(e)

for i in parent:
    print(i)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n, m = map(int, input().split())
es = [[] for i in range(n)]
co = [[] for i in range(n)] # 有効辺の向きを逆にした
for i in range(n - 1 + m):
    a, b = map(int, input().split())    
    es[a - 1].append(b - 1)
    co[b - 1].append(a - 1)

dp = [-1] * n

def memo(v):
    if dp[v] != -1: #更新済
        return dp[v]
    a = 0
    for i in co[v]:
        a = max(a, memo(i) + 1)
    dp[v] = a
    return a

for i in range(n):
    memo(i)

parent = [0] * n
for v in range(n):
    for e in es[v]:
        if dp[v] + 1 == dp[e]:
            parent[e] = v + 1

for i in parent:
    print(i)
### BUGGY CODE ###

# ABC127 D-Integer Cards
from operator import itemgetter
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

BC.sort(key=itemgetter(1),reverse=True)
# print(A)
# print('sort',BC)
for i in range(M):
    x = 0
    while x < BC[i][0]:
        A.sort()
        # print(i,A)
        if BC[i][1] > A[0]:
            A[0] = BC[i][1]
        x += 1 
print(sum(A))

### FIXED CODE ###

# ABC127 D-Integer Cards
from operator import itemgetter
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

A.sort()
BC.sort(key=itemgetter(1),reverse=True)
# print(A)
# print('sort',BC)
c = 0
for i in range(M):
    for j in range(BC[i][0]):
        if A[c] < BC[i][1]:
            A[c] = BC[i][1]
        else:
            print(sum(A))
            exit()
        c += 1
        if c == N:
            print(sum(A))
            exit()
# for i in range(M):
#     x = 0
#     while x < BC[i][0]:
#         A.sort()
#         print(i,A)
#         if BC[i][1] > A[0]:
#             A[0] = BC[i][1]
#         x += 1 
print(sum(A))
### BUGGY CODE ###

import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
bnum = [n - bisect.bisect_right(c, b[i]) for i in range(n)]
ans = 0
for i in range(n):
  ai = a[i]
  ans += sum(bnum[bisect.bisect_right(b, ai):n])
print(ans)

### FIXED CODE ###

import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in b:
  ai = bisect.bisect_left(a, i)
  ci = n - bisect.bisect_right(c, i)
  ans += ai*ci
print(ans)
### BUGGY CODE ###

S = input()
N = len(S)
t = int(S)

ans = 0
cnt = [0] * 2019
for i in range(1, N+1):
    cnt[(t % (10)**i) % 2019] += 1
ans += cnt[0]
for i in range(1, 2019):
    if cnt[i] >= 2:
        ans += cnt[i] * (cnt[i] - 1) // 2
print(ans)


### FIXED CODE ###

S = list(input())
N = len(S)

ans = 0
cnt = [0] * 2019
a = 1
s = 0

for i in range(N)[::-1]:
    s = int(S[i]) * a + s
    a *= 10
    a = a % 2019
    cnt[s % 2019] += 1
    s = s % 2019

ans += cnt[0]
for i in range(2019):
    ans += cnt[i] * (cnt[i] - 1) // 2
print(ans)
### BUGGY CODE ###

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

ans=[]
for i in range(1,n+1):
  for j in range(n):
    if A[j]==i:
      ans.append(j+1)
print(*ans)

### FIXED CODE ###

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

ans=[]
for i,a in enumerate(A):
  ans.append([i+1,a])
ans.sort(key=lambda x:x[1])
for a in ans:
  print(a[0],end=' ')
### BUGGY CODE ###

import sys
n = int(input())
s = list(map(int, input().split()))

c = 0
a = 'a'

def merge(A, left, mid, right):
    global c
    L = A[left:mid]
    R = A[mid:right]
    L.append(sys.maxsize)
    R.append(sys.maxsize)
    i = 0
    j = 0
    for k in range(left, right):
        c += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergesort(A, left, right):
    if left+1 < right:
        mid = (left+right)//2
        mergesort(A, left, mid)
        mergesort(A, mid, right)
        merge(A, left, mid, right)
        return A

ans = mergesort(s, 0, n)

for i in ans:
    a = str(a) + str(i) + ' '
print(a[1:-1])
print(c)


### FIXED CODE ###

import sys
n = int(input())
s = list(map(int, input().split()))
c = 0
a = 'a'
def merge(A, left, mid, right):
    global c
    L = A[left:mid]
    R = A[mid:right]
    L.append(sys.maxsize)
    R.append(sys.maxsize)
    i = 0
    j = 0
    for k in range(left, right):
        c += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergesort(A, left, right):
    if left+1 < right:
        mid = (left+right)//2
        mergesort(A, left, mid)
        mergesort(A, mid, right)
        merge(A, left, mid, right)

mergesort(s, 0, n)

for i in range(n-1):
    print(s[i], end=' ')
print(s[n-1])
print(c)
### BUGGY CODE ###

from  operator import itemgetter
import numpy as np

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

sushi = []
for i in range(n):
    sushi.append(list(map(int, input().split())))

#print(sushi)

sushi.sort(key=itemgetter(1), reverse=True)

#print(sushi)

sushi = np.array(sushi)

#print(sushi)

total = len(set(sushi[:,0]))

#print(total)

initial = len(set(sushi[:k, 0]))

#print(initial)

g = []

#print(initial, total)
for i in range(initial, min(total, k)+1):
    check = [0 for i in range(n)]
    value = i * i
    types = []
    s = 0
    for j in range(i):
        while True:
            if sushi[s, 0] not in types:
                types.append(sushi[s, 0])
                value += sushi[s, 1]
                check[s] = 1
                s += 1
                break
            s += 1

    s = 0

    for j in range(k-i):
        while True:
            if check[s] == 0:
                value += sushi[s, 1]
                s += 1
                break
            s += 1
    
    g.append(value)

#print(g)
print(max(g))
        

### FIXED CODE ###

# 入力
n, k = map(int, input().split())
A = [] # 寿司のネタの美味しさと種類を入れるリスト
for _ in range(n):
    A.append(list(map(int, input().split())))

# 美味しさ順にソートする
A.sort(key=lambda x: x[1], reverse=True)

# 美味しさで貪欲にとる
X = [] # 同じ種類で他に美味しさの大きい寿司が存在する
Y = [] # 取った寿司の中の各々の種類で美味しさが最も大きい
st = set() # 種類
for i in range(k):
    t, d = A[i]
    if t in st:
        X.append(d)
    else:
        Y.append(d)
        st.add(t)

# 美味しさポイントを求める
x = sum(X)
y = sum(Y)
v = len(Y) # 種類数
ans = x + y + v ** 2
for i in range(k, n):
    if not X:
        break
    t, d = A[i]
    if t in st:
        continue
    st.add(t)
    x -= X.pop()
    y += d
    v += 1
    ans = max(ans, x + y + v ** 2)

print(ans)
### BUGGY CODE ###

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

s=0
cmb=1
for i in range(k-1,n):
	s+=(a[i]-a[n-i-1])*cmb
	s%=10**9+7
	cmb=cmb*(i+1)//(i-k+2)
print(s)

### FIXED CODE ###

def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
    
n,k=map(int,input().split())
a=sorted(list(map(int, input().split())))
MOD=10**9+7

fac, ifac=make_tables(MOD,n)

s=0
for i in range(k-1,n):
	s+=(a[i]-a[n-i-1])*cmb(i,k-1,MOD,fac,ifac)
	s%=10**9+7
print(s)
### BUGGY CODE ###

import re

n, q = map(int, input().split())
s = input()

for i in range(q):
    l, r = map(int, input().split())
    sl = s[l - 1 : r]
    # sl = sl.replace("AC", "-")
    # ans = sl.count("-")
    # print(ans)

    result = re.findall(r"AC", sl)
    print(len(result))


### FIXED CODE ###

n, q = map(int, input().split())
s = input()

t = [0] * (n + 1)
for i in range(n):
    t[i + 1] = t[i] + (1 if s[i : i + 2] == "AC" else 0)
# print(t)
for j in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])
### BUGGY CODE ###

from heapq import heapify,heappush,heappop

def main():
    N,M = map(int,input().split())
    A = [ -x for x in map(int,input().split()) ]

    for i in range(M):
        heapify(A)
        #print(A)
        tmp = -heappop(A)
        #print(tmp)
        tmp = tmp//2
        #print(tmp)
        heappush(A,-tmp)


    ans = 0
    for i in range(N):
        ans += A[i]

    ans = abs(ans)
    return ans

print(main())


### FIXED CODE ###

from heapq import heapify,heappush,heappop

def main():
    N,M = map(int,input().split())
    A = [ -x for x in map(int,input().split()) ]
    heapify(A)

    for i in range(M):
        #print(A)
        tmp = -heappop(A)
        #print(tmp)
        tmp = tmp//2
        #print(tmp)
        heappush(A,-tmp)


    ans = 0
    for i in range(N):
        ans += A[i]

    ans = abs(ans)
    return ans

print(main())
### BUGGY CODE ###

N, M = map(int, input().split())
A = []
B = []
sumcost = 0
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
k = 0
while k < M:
    min_index = A.index(min(A))
    B[min_index] -= 1
    sumcost += A[min_index]
    if B[min_index]<1:
        del A[min_index]
        del B[min_index]
    k += 1



print(sumcost)

### FIXED CODE ###

N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
A.sort()
sumcost = 0
for i in range(M):
    sumcost += A[0][0]
    A[0][1] -= 1
    if A[0][1] < 1:
        A.pop(0)

print(sumcost)
### BUGGY CODE ###

n,m=map(int,input().split())
f=lambda x:int(x)-1
l=[[] for _ in range(n)]
for i in range(m):
  a,b=map(f,input().split())
  l[a].append(b)
  l[b].append(a)
m=0  
for i in range(n):
  queue=[i]
  visit=set()
  visit.add(i)
  cnt=1
  while len(queue)>0:
    now=queue.pop(0)
    for j in l[now]:
      if j not in visit:
        visit.add(j)
        queue.append(j)
        cnt+=1
  m=max(m,cnt)
print(m)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

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

par=[i for i in range(n)]

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

def union(x,y):
  x=find(x)
  y=find(y)
  if x!=y:
    par[x]=y
 
f=lambda x:int(x)-1
for i in range(m):
  x,y=map(f,input().split())
  union(x,y)
  
for j in range(n):
  find(j)
from collections import Counter
c=Counter(par)
cv=c.values()
print(max(cv))
### BUGGY CODE ###

N, M = map(int, input().split())
ab = [sorted(list(map(int, input().split()))) for _ in range(M)]
judge = False
m = []
for i, (a, b) in enumerate(ab):
    if a == 1:
        m.append(b)

for i, (a, b) in enumerate(ab):
    if a in m and b == N:
        judge = True
        break

if judge:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

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

ans = {True: "POSSIBLE",
    False: "IMPOSSIBLE"}

print(ans[len(set(edge[0]) & set(edge[-1])) > 0])
### BUGGY CODE ###

n = int(input())
a = input().split()
res = 1
for i in a:
  res *= int(i)
if res > 10 ** 18:
  res = -1
print(res)


### FIXED CODE ###

def f(a):
	res = 1
	for i in range(n):
		res *= int(a[i])
		if res > 10 ** 18:
			if zer(i):
				return 0
			else:
				return -1
	return res

def zer(i):
	for j in range(i, n):
		if a[j] == "0":
			return True
	return False
n = int(input())
a = input().split()

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

N = int(input())
A = list(map(int,input().split()))
LS = [0]*N
RS = [0]*N
ans = float("INF")
for i in range(N):
  LS[i] = sum(A[:i+1])
  RS[i] = sum(A[i+1:])
  ans = min(ans, abs(RS[i] - LS[i]))
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
c = sum(A)/2

S = [0] * (N+1)
S[0] = 0
for i in range(N):
  S[i+1] = A[i] + S[i]

m = float("INF")
j = -1
for i in range(1, N+1):
  if abs(c - S[i]) < m:
    m = abs(c - S[i])
    j = i

print(abs((S[N] - S[j]) - S[j]))
### BUGGY CODE ###

S = input()
Q = int(input())
pin = 0
for i in range(Q):
  t = list(input().split())
  if int(t[0]) == 1:
    if pin == 1:
      pin = 0
    else:
      pin = 1
  else:
    if int(t[1]) % 2 == pin :
      S = S + t[2]
    else:
      S = t[2] + S
if pin == 1:
  S = S[::-1]
print(S)

### FIXED CODE ###

import sys
S = input()
Q = int(input())
pin = 0
left = ''
right = ''
for i in range(Q):
  t = list(sys.stdin.readline().split())
  if int(t[0]) == 1:
    pin += 1
  else:
    if int(t[1]) % 2 == pin % 2 :
      right = right + t[2]
    else:
      left = t[2] + left
S = left + S + right
if pin % 2 == 1:
  S = S[::-1]
print(S)