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

def Main(S, Q, queries):
    ans = S
    flipped = False
    T1 = 0
    for q in queries:
        if int(q[0]) == 1:
            if not flipped:
                flipped = True
            else:
                flipped = False
            continue
        else:
            if int(q[1]) == 1:
                if flipped:
                    ans += q[2]
                else:
                    a = q[2] + ans
                    ans = a
            else:
                if flipped:
                    a = q[2] + ans
                    ans = a
                else:
                    ans += q[2]
    if flipped:
        l = list(ans)
        l.reverse()
        ans = "".join(l)
    return ans
        

def main():
    S = str(input())
    Q = int(input())
    queries = []
    for i in range(Q):
        queries.append(list(map(str, input().split())))
    print(Main(S, Q, queries))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def Main(S, Q, queries):
    right = S
    left = ""
    flipped = False
    T1 = 0
    for q in queries:
        if int(q[0]) == 1:
            if not flipped:
                flipped = True
            else:
                flipped = False
            continue
        else:
            if int(q[1]) == 1:
                if flipped:
                    right += q[2]
                else:
                    left += q[2]
            else:
                if not flipped:
                    right += q[2]
                else:
                    left += q[2]
    le = list(left)
    le.reverse()
    left = "".join(le)
    ans = left + right
    if flipped:
        l = list(ans)
        l.reverse()
        ans = "".join(l)
    return ans
        

def main():
    S = str(input())
    Q = int(input())
    queries = []
    for i in range(Q):
        queries.append(list(map(str, input().split())))
    print(Main(S, Q, queries))

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

def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

n,a,b = map(int,input().split())
p = 10**9 +7
print((power_func(2,n,p)-1-comb(n,a,p)-comb(n,b,p))%p)

### FIXED CODE ###

def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

def comb(n,r,mod=10**9+7):
    a=1
    b=1
    r = min(r,n-r)
    for i in range(r):
        a = a*(n-i)%mod
        b = b*(i+1)%mod
    return a*pow(b,mod-2,mod)%mod

n,a,b = map(int,input().split())
p = 10**9 +7
print((pow(2,n,p)-1-comb(n,a,p)-comb(n,b,p))%p)
### BUGGY CODE ###

import math
k = int(input())

ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            ans += math.gcd(math.gcd(a, b), c)

print(ans)

### FIXED CODE ###

k = int(input())

import math

ans = 0
ans += 0.5*k*(k+1)
# print(ans)

for a in range(1, k):
    for b in range(a+1,k+1):
        n = math.gcd(a, b)
        ans += n*6
        for c in range(b+1, k+1):
            if c != b:
                ans += math.gcd(n, c)*6

# for i in range(1, k-1):
#     for j in range(i+1, k):
#         for k in range(j+1, k+1):
#             d = math.gcd(i, j)
#             ans += math.gcd(d, k)*6

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

import itertools

n,m,q = map(int, input().split())
list_ = [list(map(int, input().split())) for _ in range(q)]
tmp = list(range(1,m+1))
cases = [sorted(list(arr)) for arr in itertools.product(tmp, repeat=n)]

max_score = 0
visited = set()
for arr in cases:
  score = 0
  if str(arr) in visited:
    pass
  else:
    visited.add(str(arr))
    for arr_2 in list_:
      if arr[arr_2[1]-1] - arr[arr_2[0]-1] == arr_2[2]:
        score+=arr_2[3]
  max_score = max(max_score, score)
print(max_score)

### FIXED CODE ###

import itertools

n,m,q = map(int, input().split())
list_ = [list(map(int, input().split())) for _ in range(q)]

num=1
seed = [[i] for i in range(1,m+1)]
while num!=n:
  num+=1
  tmp_list = []
  while seed:
    tmp = seed.pop()
    for i in range(tmp[-1],m+1):
      tmp_list.append(tmp+[i])
  seed = tmp_list.copy()

max_score = 0
visited = set()
for arr in seed:
  score = 0
  for arr_2 in list_:
    if arr[arr_2[1]-1] - arr[arr_2[0]-1] == arr_2[2]:
      score+=arr_2[3]
      max_score = max(max_score, score)
print(max_score)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
sum = [0]*N
for i in range(N):
    sum[i] = A.count(i+1)
    print(sum[i])

### FIXED CODE ###

import numpy as np
N = int(input())
A = list(map(int,input().split()))
ans = np.zeros(N)
for i in A:
    ans[i-1] +=1
for i in ans:
    print(int(i))
### BUGGY CODE ###

R,G,B,N = map(int, input().split())
sum = 0
for i in range(int(N / R) + 1):
  for j in range(int(N / G) + 1):
    for k in range(int(N / B) + 1):
      ans = i * R + j * G + k * B
      if (ans == N):
        sum += 1
print(sum)


### FIXED CODE ###

R,G,B,N = map(int, input().split())

sum = 0
for i in range(N // R + 1):
  for j in range(N // G + 1):
    b = N - (i * R) - (j * G)
    if (b >= 0 and b % B == 0):
      sum += 1
print(sum)
### BUGGY CODE ###


"""
bitDPというらしい
dp[i][j] = i番目の入力に対して、状態jを実現する最小値
j : 2^12通り。それぞれの宝箱をbitと見立てる
"""

N, M = map(int, input().split())
INF = 10**5+1


dp = [[INF for i in range(2**N+1)] for j in range(1100)]
dp[0][0] = 0

for i in range(M):
    dp[i+1] = [v for v in dp[i]]
    cost,b = map(int, input().split())
    boxes = list(map(int, input().split()))
    status = 0
    for box in boxes:
        status += 2**(box-1)
    for j in range(2**N):
        if dp[i][j] != INF:
            nxt = status | j
            dp[i+1][nxt] = min(dp[i][j] + cost, dp[i][nxt], dp[i+1][nxt])

ans = dp[M][2**N-1]
if ans == INF:
    print(-1)
else:
    print(ans)

# for i in range(M):
#     print(dp[i])

### FIXED CODE ###


"""
bitDPというらしい
dp[i][j] = i番目の入力に対して、状態jを実現する最小値
j : 2^12通り。それぞれの宝箱をbitと見立てる
"""

N, M = map(int, input().split())
INF = 10**5+1


dp = [[INF for i in range(2**N+1)] for j in range(1100)]
dp[0][0] = 0

for i in range(M):
    dp[i+1] = [v for v in dp[i]]
    cost,b = map(int, input().split())
    boxes = list(map(int, input().split()))
    status = 0
    for box in boxes:
        status += 2**(box-1)
    for j in range(2**N):
        if dp[i][j] != INF:
            nxt = status | j
            dp[i+1][nxt] = min(dp[i][j] + cost, dp[i][nxt], dp[i+1][nxt])

ans = dp[M][2**N-1]
if ans == INF:
    print(-1)
else:
    print(ans)

# for i in range(M):
#     print(dp[i])
### BUGGY CODE ###

N, Q = map(int, input().split())
S = list(input())
cnt = [0] * (N)

last = S[0]
for i in range(1, N):
    c = S[i]
    if (last + c) == 'AC':
        cnt[i] = 1
    last = c

for _ in range(Q):
    l, r = map(int, input().split())
    ans = sum(cnt[l:r])
    print(ans)


### FIXED CODE ###

N, Q = map(int, input().split())
S = list(input())
cnt = [0] * (N)

for i in range(1, N):
    if S[i - 1] + S[i] == 'AC':
        cnt[i] = cnt[i - 1] + 1
    else:
        cnt[i] = cnt[i - 1]

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

N,M=map(int,input().split())
L=[]
R=[]
for i in range(M):
  l,r=map(int,input().split())
  L.append(l)
  R.append(r)
count=0
for i in range(1,N+1):
  if max(L)<=i<=min(R):
    count+=1
print(count)

### FIXED CODE ###

N,M=map(int,input().split())
L=[]
R=[]
for i in range(M):
  l,r=map(int,input().split())
  L.append(l)
  R.append(r)
count=0
if max(L)>min(R):
  print(0)
else:
  print(min(R)-max(L)+1)
### BUGGY CODE ###

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

res = 0
for i in range(N):
    if(min(P[:i+1]) == P[i]):
        res += 1
print(res)


### FIXED CODE ###

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

res = 0
mini = P[0]
for i in range(N):
    mini = min(mini, P[i])
    if(mini >= P[i]):
        res += 1
print(res)
### BUGGY CODE ###

class UnionFind():
    def __init__(self, n=0):
        self.d = [-1 for _ in range(n)]
        self.g = set()
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.g.add(x)
        if y in self.g:self.g.remove(y)
        self.d[y] = x
        return True

    def same(self,x,y): return self.find(x)==self.find(y)
    def size(self,x): return -self.d[self.find(x)]
    
def comb2(n):
  return n*(n-1)//2
    
N,M=map(int,input().split())
edges=[list(map(int,input().split())) for i in range(M)][::-1]

total=comb2(N)
ans = [total]
uf = UnionFind(N+1)
for i in range(M-1):
  a,b=edges[i]
  uf.unite(a,b)
  ans.append(total-sum(map(lambda x: comb2(uf.size(x)),uf.g)))

for i in range(M):
  print(ans[-1-i])

### FIXED CODE ###

from collections import defaultdict

class UnionFind():
    def __init__(self, n=0):
        self.d = [-1]*n
        self.g = set()
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.g.add(x)
        if y in self.g:self.g.remove(y)
        self.d[y] = x
        return True

    def same(self,x,y): return self.find(x)==self.find(y)
    def size(self,x): return -self.d[self.find(x)]
    
def comb2(n):
  return n*(n-1)//2
    
N,M=map(int,input().split())
E = [tuple(map(int,input().split())) for _ in range(M)]

total=comb2(N)
uf = UnionFind(N+1)
ans = [total]
for i in range(M-1):
  a,b = E[-i-1]
  if uf.same(a,b):
    ans.append(ans[-1])
    continue
  else:
    size1,size2 = uf.size(a),uf.size(b)
    uf.unite(a,b)
    size3 = uf.size(a)
    tmp = ans[-1]+comb2(size1)+comb2(size2)-comb2(size3)
    ans.append(tmp)
print(*ans[::-1])
### BUGGY CODE ###

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


# 公約数をリストとして得る
def comn_div(n, m):
    """give common divisor"""
    div_n = []
    div_m = []
    for i in range(1, n+1):
        if n % i == 0:
            div_n.append(i)
    for j in range(1, m+1):
        if m % j == 0:
            div_m.append(j)
    cdiv_nm = set(div_n) & set(div_m)
    return(list(cdiv_nm))
# 自然数以外が入ったら弾きたい


cdiv_ab = comn_div(a, b)
disjoint = []
for i in range(len(cdiv_ab)):
    state = True
    # 自分より若い数字が約数の場合は除外
    for j in range(i):
        if comn_div(cdiv_ab[i], cdiv_ab[j]) != [1]:
            state = False
    if state:
        disjoint.append(i)
# print(cdiv_ab)
# print(disjoint)
print(len(disjoint))


### FIXED CODE ###

# def max_comn_div(n, m):
#     """give max common divisor"""
#     if n > m:
#         a, b = n, m
#     else:
#         a, b = m, n
#     while b != 0:
#         a, b = b, a % b
#     return a


# a = int(input())
# b = int(input())
# print(max_comn_div(a, b))

# def euc(a, b):
#      if a % b == 0:
#          return b
#      else:
#          return euc(b, a % b)


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


def div(n):
    """give divisors"""
    divisors = [1]
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            divisors.append(i)
            n /= i
    if n != 1:
        divisors.append(int(n))
    return set(divisors)


a, b = map(int, input().split())
# print(euc(a, b))
c = div(euc(a, b))
# print(c)
print(len(c))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
A = list(map(int, input().split()))
for _ in range(M):
    b, c = map(int, input().split())
    A.extend([c] * b)
A.sort(reverse = True)
print(sum(A[:N]))


### FIXED CODE ###

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
A = [int(i) for i in input().split()]
table = []
for i in range(N):
    table.append((A[i], 1))
for i in range(M):
    b, c = map(int, input().split())
    table.append((c, b))

table = sorted(table)
cnt = N
ans = 0
while cnt > 0:
    #print(ans,s)
    c, b = table.pop()
    if b >= cnt:
        ans += c*cnt
        break
    ans += c*b
    cnt -= b
print(ans)
### BUGGY CODE ###

import math

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

for i in range(m):
  a.sort()
  a[-1]=math.floor(a[-1]/2)

print(sum(a))

### FIXED CODE ###

import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*-1, input().split()))
heapq.heapify(a)

for i in range(m):
  m = heapq.heappop(a)
  heapq.heappush(a, (-m//2)*-1)

print(-sum(a))
### BUGGY CODE ###

# coding: utf-8
import sys
sysread = sys.stdin.readline
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**6)
def run():

    N,M,K = map(int,sysread().split())
    to = [[] for _ in range(N+1)]
    for i in range(1,M+1):
        a,b = map(int, sysread().split())
        to[a].append(b)
        to[b].append(a)


    stack = defaultdict(lambda:[])
    visited = [False] * (N+1)
    belong = [None] * (N+1)

    def dfs(n, tree= None):
        visited[n] = True
        if tree==None:
            tree = n
        stack[tree].append(n)
        belong[n] = tree
        for next in to[n]:
            if not visited[next]:
                dfs(next, tree)
        return None

    while True:
        k = -1
        for i in range(1,N+1):
            if not visited[i]:
                k = i
                break
        if k == -1:break
        dfs(k)

    block = [[] for _ in range(N+1)]
    for i in range(1, K+1):
        c,d = map(int, sysread().split())
        if belong[c] == belong[d]:
            block[c].append(d)
            block[d].append(c)

    candidates = [0] * (N+1)

    for tree in stack.keys():
        length = len(stack[tree])
        for k in stack[tree]:
            candidates[k] = length - 1 - len(to[k]) - len(block[k])

    print(' '.join(map(str, candidates[1:])))

if __name__ == "__main__":
    run()

### FIXED CODE ###

# coding: utf-8
import sys
sysread = sys.stdin.readline
from collections import defaultdict
sys.setrecursionlimit(10**7)
def run():

    N,M,K = map(int,sysread().split())
    to = [[] for _ in range(N+1)]
    n_to = [0 for _ in range(N + 1)]
    for i in range(1,M+1):
        a,b = map(int, sysread().split())
        #a,b = AB[i]
        to[a].append(b)
        n_to[a] += 1
        to[b].append(a)
        n_to[b] += 1

    stack = defaultdict(lambda:0)
    visited = [False] * (N+1)
    belong = [None] * (N+1)


    def dfs(n):
        _stack = [n]
        visited[n] = True
        while _stack:
            node = _stack.pop()
            stack[n] += 1
            belong[node] = n
            for next in to[node]:
                if not visited[next]:
                    _stack.append(next)
                    visited[next] = True
        return None


    for i in range(1,N+1):
        if not visited[i]:
            dfs(i)

    block = [0 for _ in range(N+1)]
    for i in range(1, K+1):
        c,d = map(int, sysread().split())
        #c, d = CD[i]
        if belong[c] == belong[d]:
            block[c] += 1
            block[d] += 1

    candidates = [0] * (N+1)

    for k in range(1,N+1):
        tr = belong[k]
        candidates[k] = stack[tr] - 1 - n_to[k] - block[k]

    print(' '.join(map(str, candidates[1:])))

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

#!/usr/bin/env python3

import sys


def main():
    n, m, q = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]

    cities_l = [[] for i in range(n+1)]
    cities_r = [[] for i in range(n+1)]
    #cities_l = [set() for i in range(n+1)]
    #cities_r = [set() for i in range(n+1)]

    for i in range(m):
        l, r = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
        cities_l[l].append(i)
        cities_r[r].append(i)
        #cities_l[l].add(i)
        #cities_r[r].add(i)

    for i in range(q):
        qp, qq = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
        list_l = []
        list_r = []
        #set_l = set()
        #set_r = set()
        for j in range(qp, qq+1):
            list_l += cities_l[j]
            list_r += cities_r[j]
            #set_l |= cities_l[j]
            #set_r |= cities_r[j]
        print(len(set(list_l) & set(list_r)))
        #print(len(set_l & set_r))

if __name__=='__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python3

import sys


def main():
    n, m, q = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]

    x = [[0 for j in range(n+1)] for i in range(n+1)]
    c = [[0 for j in range(n+1)] for i in range(n+1)]
    z = [[0 for j in range(n+1)] for i in range(n+1)]

    for i in range(m):
        l, r = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
        x[l][r] += 1
    
    for i in range(1, n+1):
        for j in range(1, n+1):
            c[i][j] = c[i][j-1] + x[i][j]

    for j in range(1, n+1):
        for i in range(1, n+1):
            z[i][j] = z[i-1][j] + c[i][j]
    
    for i in range(q):
        qp, qq = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
        print(z[qq][qq] - z[qq][qp-1] - z[qp-1][qq] + z[qp-1][qp-1])


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

import math
mod=10**9+7
n,m=map(int,input().split())
if abs(n-m)>1:
    print(0)
elif abs(n-m)==0:
    print(2*math.factorial(n)*math.factorial(m))
else:
    print(math.factorial(n)*math.factorial(m))

### FIXED CODE ###

import math
mod=10**9+7
factorial=[1 for _ in range(10**5+10)]
for i in range(1, 10**5+10):
    factorial[i]=i*factorial[i-1] % mod
n,m=map(int,input().split())
if abs(n-m)>1:
    print(0)
elif abs(n-m)==0:
    print(2*factorial[n]*factorial[m]%mod)
else:
    print(factorial[n]*factorial[m]%mod)
### BUGGY CODE ###

from bisect import bisect_right

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

shop = []
shop_a0 = []

for i in range(n):
    a, b = map(int, input().split())
    if a != 0:
        shop.append([a, b, a/(b+1)])
    else:
        shop_a0.append(b)

shop = sorted(shop, key=lambda x: -x[2])
shop_a0 = sorted(shop_a0)

n = len(shop)

# dp[i][j]:i番目まで見てj個の店を回るのに掛かる所要時間の最小値
dp = [[10**10]*50 for _ in range(n+1)]
dp[0][0] = 0


for j in range(min(n+1, 50)):
    for i in range(n):
        dp[i+1][j] = min(dp[i][j], dp[i][j-1] + 1 +
                         shop[i][0]*(dp[i][j-1]+1) + shop[i][1])

ss = []
if shop_a0:
    ss.append(1+shop_a0[0])
    for i in range(1, len(shop_a0)):
        ss.append(ss[-1]+1+shop_a0[i])

ans = 0

for i in range(min(n+1, 50)):
    if t - dp[n][i] >= 0:
        ans = max(ans, bisect_right(ss, t-dp[n][i]) + i)

print(ans)


### FIXED CODE ###

from bisect import bisect_right
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


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

shop = []
shop_a0 = []

for i in range(n):
    a, b = map(int, input().split())
    if a != 0:
        shop.append([a, b, a/(b+1)])
    else:
        shop_a0.append(b)

shop = sorted(shop, key=lambda x: -x[2])
shop_a0 = sorted(shop_a0)

n = len(shop)

INF = 10**10
# dp[i][j]:i番目まで見てj個の店を回るのに掛かる所要時間の最小値
dp = [[INF for _ in range(31)] for __ in range(n+1)]
dp[0][0] = 0

m = min(n+1, 30)

for i in range(n):
    for j in range(m):
        if (shop[i][0]+1)*(dp[i][j]+1) + shop[i][1] > t:
            dp[i+1][j+1] = dp[i][j+1]
        else:
            dp[i+1][j+1] = min(dp[i][j+1], (shop[i][0]+1)
                               * (dp[i][j]+1) + shop[i][1])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ss = []
if shop_a0:
    ss.append(1+shop_a0[0])
    for i in range(1, len(shop_a0)):
        ss.append(ss[-1]+1+shop_a0[i])

ans = 0

for i in range(m):
    if t - dp[n][i] >= 0:
        ans = max(ans, bisect_right(ss, t-dp[n][i]) + i)

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

n=int(input())
ans=0
d=[]
for i in range(n):
  d.append(list(input()))
  d[i].sort()
  d[i]="".join(d[i])
x=set(d)
x=list(x)
for j in range(len(x)):
  X=d.count(x[j])
  ans+=(X*(X-1))/2
print(int(ans))

### FIXED CODE ###

n=int(input())
d=[list(input()) for i in range(n)]
count=0
ans=0
for i in range(n):
  d[i].sort()
d.sort()

for i in range(n-1):
  if d[i]==d[i+1]:
    count+=1
  elif d[i]!=d[i+1]:
    x=count+1
    count=0
    ans+=(x*(x-1))/2
  if i==(n-2):
    x=count+1
    count=0
    ans+=(x*(x-1))/2
  
print(int(ans))
### BUGGY CODE ###

import collections

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

c = collections.Counter(a)
count = 0

for i in range(k, len(c)):
        count += c.most_common()[i][1]

print(count)

### FIXED CODE ###

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

a.sort()
count = 1
b = []

for i in range(n-1):
    if a[i] != a[i+1]:
        b.append(count)
        count = 1
    else:
        count += 1

b.append(count)

b.sort(reverse=True)

count = 0
if k < len(b):
    for i in range(k, len(b)):
        count += b[i]

print(count)
### BUGGY CODE ###

from collections import deque
from sys import stdin
def f(n, links, groups):
  group_number = 0
  for i in range(n):
    if groups[i] == -1:
      d = deque()
      d.append(i)
      while len(d) != 0:
        j = d.popleft()
        groups[j] = group_number
        for k in links[j]:
          if groups[k] == -1:
            d.append(k)
      group_number += 1
  d = {}
  for i in range(n):
    if groups[i] not in d:
      d[groups[i]] = []
    d[groups[i]].append(i)
  for k in d:
    d[k] = set(d[k])
  return d
def main():
  # from builtins import int, list, map, min
  readline = stdin.readline
  n, k, l = map(int, input().split())
  road_links = [[] for _ in range(n)]
  for i in range(k):
    p, q = map(int, readline().split())
    road_links[p - 1].append(q - 1)
    road_links[q - 1].append(p - 1)
  road_groups = [-1 for _ in range(n)]
  road_set = f(n, road_links, road_groups)
  train_links = [[] for _ in range(n)]
  for i in range(l):
    p, q = map(int, readline().split())
    train_links[p - 1].append(q - 1)
    train_links[q - 1].append(p - 1)
  train_groups = [-1 for _ in range(n)]
  train_set = f(n, train_links, train_groups)
  print(*[len(road_set[road_groups[i]] & train_set[train_groups[i]]) for i in range(n)])
main()


### FIXED CODE ###

from sys import stdin

def find(parent, i):
  if parent[i] == i:
    return i
  parent[i] = find(parent, parent[i])
  return parent[i]

def unite(parent, i, j):
  i = find(parent, i)
  j = find(parent, j)
  if i == j:
    return
  parent[i] = j

n, k, l = map(int, stdin.readline().split())

roads = list(range(n))
rails = list(range(n))

for i in range(k):
  p, q = map(int, stdin.readline().split())
  unite(roads, p - 1, q - 1)

for i in range(l):
  p, q = map(int, stdin.readline().split())
  unite(rails, p - 1, q - 1)

d = {}
for i in range(n):
  t = (find(roads, i), find(rails, i))
  if t in d:
    d[t] += 1
  else:
    d[t] = 1

print(*[d[(find(roads, i), find(rails, i))] for i in range(n)])
### BUGGY CODE ###

def resolve():
    N = int(input())
    P = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        if min(P[:i+1]) == P[i]:
            ans += 1
    print(ans)
resolve()

### FIXED CODE ###

def resolve():
    N = int(input())
    P = list(map(int, input().split()))
    min = P[0]
    ans = 1
    for i in P:
        if i < min:
            min = i
            ans += 1
    print(ans)
resolve()
### BUGGY CODE ###

from itertools import combinations
n = int(input())
l = list(map(int, input().split()))
count = 0
for a, b, c in combinations(l, 3):
    if a<b+c and b<c+a and c<a+b:
        count += 1
print(count)

### FIXED CODE ###

from bisect import bisect_right, bisect_left
n = int(input())
l = list(map(int, input().split()))
count = 0
l.sort()
for i in range(n-2):
    for j in range(i+1, n-1):
        count += bisect_left(l, l[i]+l[j]) -j -1
print(count)