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

N, M, Q = [int(_) for _ in input().split()]

nl = [[0 for i in range(N)] for j in range(N)]
for t in [input().split() for _ in range(M)]:
    i = int(t[0]) - 1
    j = int(t[1]) - 1
    nl[i][j] += 1

l = [[0 for i in range(N)] for j in range(N)]
for i in range(N):
    s = 0
    for j in range(N):
        l[i][j] = s + nl[i][j]
        s = l[i][j]

for k in [input().split() for _ in range(Q)]:
    p = int(k[0])
    q = int(k[1])
    ans = 0
    for i in range(p-1, q):
        if p == 1:
            d = l[i][q-1]
        else:
            d = l[i][q-1] - l[i][p-2]
        ans += d
    print(ans)

### FIXED CODE ###

N, M, Q = [int(_) for _ in input().split()]

l = [[0 for i in range(N+1)] for j in range(N+2)]
for t in [input().split() for _ in range(M)]:
    i = int(t[0])
    j = int(t[1])
    l[i][j] += 1

for k in range(N):
    for i in range(1, N-k+1):
        j = i + k
        l[i][j] += l[i][j-1] + l[i+1][j] - l[i+1][j-1]

for k in [input().split() for _ in range(Q)]:
    p = int(k[0])
    q = int(k[1])
    print(l[p][q])
### BUGGY CODE ###

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

for i in range(n):
    if i % 2 == n % 2:
        b.append(a[i])
    else:
        b.insert(0, a[i])
for i in range(n):
    print(b[i], end=' ')

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [0] * n
total = (n - 1) // 2
if n % 2 == 0:
    for i in range(n):
        div, mod = divmod(i, 2)
        if mod == 0:
            b[-total+div-1] = a[i]
        else:
            b[total-div] = a[i]
else:
    for i in range(n):
        div, mod = divmod(i, 2)
        if mod == 0:
            b[total - div] = a[i]
        else:
            b[-total+div] = a[i]

for i in range(n):
    print(b[i], end=' ')
### BUGGY CODE ###

def op1():
  new = S[::-1]
  return new

def op2(f, c):
  if f == "1":
    return (c + S)
  elif f == "2":
    return (S + c) 
  

S = input()
Q = int(input())
v = [list(input().split()) for i in range(Q)]

for val in v:
  if val[0] == "1":
    S = op1()
  elif val[0] == "2":
    S = op2(val[1], val[2])
    
print(S)

### FIXED CODE ###

def op2(f, c, r):
  if r == 0:
    if f == "1":
      left.append(c)
    elif f == "2":
      right.append(c)

  if r == 1:
    if f == "1":
      right.append(c)
    elif f == "2":
      left.append(c)

S = input()
Q = int(input())
v = [list(input().split()) for i in range(Q)]
rev = 0
left = []
right = []

for val in v:
  if val[0] == "1":
    if rev == 0:
      rev = 1
    elif rev == 1:
      rev = 0
  elif val[0] == "2":
    op2(val[1], val[2], rev)

nleft = left[::-1]
ans = "".join(nleft + [S] + right)

if rev == 0:
  print(ans)
else:
  print(ans[::-1])
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int,input().split())) for i in range(q)]

for i in range(q):
    a = [bc[i][1] if j == bc[i][0] else j for j in a]
    print(sum(a))
    

### FIXED CODE ###

import collections as co
n = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int,input().split())) for i in range(q)]
c = co.Counter(a)
ans = sum(a)
for i in range(q):
    ans += (c[bc[i][0]] * (bc[i][1]-bc[i][0]))
    print(ans)
    c[bc[i][1]] += c[bc[i][0]]
    c[bc[i][0]] = 0
### BUGGY CODE ###

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def comb(n,k,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


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 main():
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10 ** 9 + 7

    pos = [-1] * 100010
    for i, a in enumerate(A):
        if pos[a] != -1:
            pos1, pos2 = min(pos[a], i), max(pos[a], i)
            break
        pos[a] = i

    dist = pos2 - pos1
    for i in range(1, N + 2):
        ans = comb(N + 1, i, MOD)
        if i <= dist:
            ans -= comb(N + 1 - dist - 1, i - 1, MOD)

        print(ans % MOD)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import defaultdict, Counter
from itertools import product, groupby, combinations
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right

INF = 10 ** 10


class Combination:
    def __init__(self, n, mod):
        assert 0 < n
        self.mod = mod
        self.fact = [1] * (n + 1)
        self.inv = [1] * (n + 1)
        for i in range(1, len(self.fact)):
            self.fact[i] = (i * self.fact[i - 1]) % self.mod
            self.inv[i] = pow(self.fact[i], self.mod - 2, self.mod)

    def nCr(self, n, k):
        assert 0 < n < len(self.fact) and 0 <= k, (n, k)
        a = self.fact[n]
        b = (self.inv[k] * self.inv[n - k]) % self.mod
        return a * b % self.mod


def main():
    MOD = 10 ** 9 + 7
    n = int(input())
    a_list = list(map(int, input().split()))

    dual = Counter(a_list).most_common(1)[0][0]
    pre, post = [i for i, a in enumerate(a_list) if a == dual]
    x = pre + (n - post)

    comb = Combination(10 ** 5 + 1, MOD)
    for i in range(1, n + 2):
        a, b = comb.nCr(n + 1, i), 0
        if i == 1:
            b = 1
        elif 0 < x and i - 1 <= x:
            b = comb.nCr(x, i - 1)
        print((a - b) % MOD)


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

from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
d = defaultdict(lambda: 0)
d[0] = 1000

for i in range(N):
    dd = d.copy()
    for s,m in dd.items():
        temp = m//A[i]
        for j in range(1,temp+1):
            if(d[s+j]<m-j*A[i]):
                d[s+j]=m-j*A[i]
        for j in range(1,s+1):
            if(d[s-j]<m+j*A[i]):
                d[s-j]=m+j*A[i]

print(d[0])





### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
m=1000
s=0
for i in range(N-1):
    if A[i] < A[i+1]:
        s+=m//A[i]
        m=m%A[i]
    if A[i] > A[i+1]:
        m += A[i]*s
        s=0

print(m+A[N-1]*s)
### BUGGY CODE ###

n = int(input())
s = input()
q = int(input())
k = list(map(int, input().split()))
for ki in k:
    D=M=DM=C=0
    #for i, c in enumerate(s):
    for i in range(n):
        c = s[i]
        if c == "D":
            D += 1
        elif c == "M":
            M += 1
            DM += D
        if i >= ki:
            j = i-ki
            if s[j] == "D":
                D -= 1
                DM -= M
            elif s[j] == "M":
                M -= 1
        if c == "C":
            C += DM
    print(C)


### FIXED CODE ###

# コピペ https://atcoder.jp/contests/dwacon5th-prelims/submissions/7670569
# 自分の https://atcoder.jp/contests/dwacon5th-prelims/submissions/7822126
# とほぼ変わらないのに自分のものはTLEするので検証
n=int(input())
s=input()
q=int(input())
for i in list(map(int,input().split())):
    a=0
    v=[0,0,0]
    for j in range(n):
        if s[j]=="D":
            v[0]+=1
        elif s[j]=="M":
            v[1]+=1
            v[2]+=v[0]
        if j>=i:
            if s[j-i]=="D":
                v[0]-=1
                v[2]-=v[1]
            elif s[j-i]=="M":
                v[1]-=1
        if s[j]=="C":
            a+=v[2]
    print(a)
### BUGGY CODE ###

from collections import Counter

N = int(input())
S = list(input())
Q = int(input())

for i in range(Q):
    a, b, c = input().split()
    if a == "1":
        S[int(b)-1] = c
    else:
        count = Counter(S[int(b)-1:int(c)])
        print(len(count))

### FIXED CODE ###

import bisect

n = int(input())
s = list(input())
q = int(input())

pos = [[] for i in range(26)]
alp = "abcdefghijklmnopqrstuvwxyz"
atoi = {}
for i in range(26):
    atoi[alp[i]] = i
for i in range(n):
    pos[atoi[s[i]]].append(i)

for i in range(q):
    a, b, c = input().split()
    if a == "1":
        b = int(b)-1
        if c == s[b]:
            continue
        index = bisect.bisect_left(pos[atoi[s[b]]], b)
        del pos[atoi[s[b]]][index]
        bisect.insort_left(pos[atoi[c]], b)
        s[b] = c
    else:
        l, r = int(b)-1, int(c)
        ans = 0
        for i in range(26):
            cnt = bisect.bisect_left(pos[i], r) - bisect.bisect_left(pos[i], l)
            if cnt > 0:
                ans += 1
        print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
#sys.setrecursionlimit(1000000)
S = list(input())
length=len(S)
dp = [[0]*13 for _ in range(length)]
dp[0][0]=1
for i in range(length-1):
    if S[length-i-2] == "?":
        for k in range(10):
            for j in range(13):
                j_sub = j-k*10**i%13
                if j_sub < 0: j_sub+= 13
                dp[i+1][j]+=dp[i][j_sub]
    else:
        for j in range(13):
            j_sub = j-int(S[length-i-2])*10**i%13
            if j_sub < 0: j_sub+= 13
            dp[i+1][j]+=dp[i][j_sub]
print(dp[length-1][5]%1000000007)

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():  
    S = list(input())
    S.pop()
    length=len(S)
    dp = [0]*13
    dp[0]=1
    mul=1
    mod=1000000007
    for i in range(1,length+1):
        next_dp = [0]*13
        for j in range(13):
            if S[length-i] == "?":
                for k in range(10):
                    j_sub=(j+k*mul)%13
                    next_dp[j_sub]+=dp[j]
                    next_dp[j_sub]%=mod
            else:
                j_sub=(j+int(S[length-i])*mul)%13
                next_dp[j_sub]+=dp[j]
                next_dp[j_sub]%=mod
        dp=next_dp
        mul=mul*10%13
    print(dp[5]%1000000007)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())
input_list = [int(i) for i in input().split()]

sum_num = 1
for t in input_list:
    sum_num *= t


if sum_num > 10 ** 18:
    print('-1')
else:
    print(sum_num)

### FIXED CODE ###

N = int(input())
input_list = [int(i) for i in input().split()]
max_num = 10 ** 18

sum_num = 1
if 0 in input_list:
    print('0')
else:
    for i in input_list:
        sum_num *= i
        if sum_num > max_num:
            sum_num = -1
            break
    print(sum_num)
### BUGGY CODE ###

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

cnt = 0
for i in range(n):
  cnt_j = 0
  for j in range(i+1):
    if p[i] <= p[j]:
      cnt_j += 1
    if cnt_j == i+1:
      cnt += 1
print(cnt)



### FIXED CODE ###

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

cnt = 0
p_min = p[0]
for i in range(n):
  pi = p[i]
  if pi <= p_min:
    cnt += 1
    p_min = pi
print(cnt)
### BUGGY CODE ###

import math
 
k = int(input())
sum = 0
 
for a in range(k):
  for b in range(k):
    for c in range(k):
      sum += math.gcd(a + 1, math.gcd(b + 1, c + 1))
      
print(sum)

### FIXED CODE ###

import math
 
k = int(input())
sum = 0
 
for a in range(k - 2):
  for b in range(a + 1, k - 1):
    for c in range(b + 1, k):
      sum += 6 * math.gcd(a + 1, math.gcd(b + 1, c + 1))
      
for a in range(k - 1):
  for b in range(a + 1, k):
    sum += 6 * math.gcd(a + 1, b + 1)
    
sum += k * (k + 1) // 2
      
print(sum)
### BUGGY CODE ###

a, b = map(int,input().split())
for i in range(10**9+1):
    if abs(a-i) == abs(b-i):
            print(i)
            break
    elif a<i and b<i and abs(a-i) != abs(b-i):
            print('IMPOSSIBLE')
            break

### FIXED CODE ###

a, b = map(int,input().split())
x = (a+b)%2
if x == 0:
    print((a+b)//2)
else:
    print('IMPOSSIBLE')
### BUGGY CODE ###

n,m=map(int,input().split())
pricelist=list(map(int,input().split()))
for i in range(m):
    pricelist.sort(reverse=True)
    pricelist[0]//=2
print(sum(pricelist))

### FIXED CODE ###

#ABC-141-D
def main():
    n,m=map(int,input().split(" "))
    s=list(map(int,input().split(" ")))
    
    s.sort(reverse=True)
    while m!=0:
        tmp=s[0]//2
        s[0]=tmp
        m-=1
        for j in range(1,n):
            if m==0:
                break
            else:
                if s[j]>=tmp:
                    s[j]=s[j]//2
                    m-=1
                else:
                    break
        s.sort(reverse=True)
        if s[0]==0:
            break
    print(sum(s))
    
main()
### BUGGY CODE ###

import collections

n = int(input())
q = collections.deque()
for i in range(n):
    x = input()
    l = len(x)
    if x[0] == "i":
        q.insert(0,x[7:])
    elif x[0] == "f":
        try:
            q.index(x[5:])
            print("yes")
        except:
            print("no")
        




### FIXED CODE ###

n = int(input())
d = {}
for i in range(n):
    x = input()
    if x[0] == "i":
        d[x[7:]] = 1
    else :
        if(x[5:] in d.keys()) : print("yes")
        else : print("no")
### BUGGY CODE ###

import sys
def input():
	return sys.stdin.readline().strip()
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[sys.maxsize]*n
dp[0]=0
for i in range(n):
    for j in range(i+1,i+k+1):
        if j<n:
            dp[j]=min(dp[j], dp[i]+ abs(l[i]-l[j]))


print(dp[-1])
    
    


### FIXED CODE ###

import sys
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[sys.maxsize]*n
dp[0]=0
for i in range(n):
    for j in range(i+1,i+k+1):
        if j<n:
            dp[j]=min(dp[j], dp[i]+ abs(l[i]-l[j]))


print(dp[-1])
### BUGGY CODE ###

n,m=map(int,input().split())
i=2
s=[]
while 1<m:
  j=0
  while m % (i**(j+1))==0:
    j+=1
  if j:
    m//=i**j
    s+=[j]
  i+=1
a=1
for v in s:
  c = 1
  for i in range(v):
    c = c * (n+i) // (1+i)
  a = a * c % (10**9+7)
print(a)


### FIXED CODE ###

n,m=map(int,input().split())
i=2
s=[]
while i*i<=m:
  j=0
  while m % i == 0:
    m//=i
    j+=1 
  if j:
    s+=[j]
  i+=1
a=1
if m > 1:
  s+=[1]
  
for v in s:
  c = 1
  for i in range(v):
    c = c * (n+i) // (1+i)
  a = a * c % (10**9+7)
print(a)
### BUGGY CODE ###

N = int(input())

ans = 0

for i in range(N):

    if i == N-1:
        ans += 0
    else:
        ans += (i+1)%(i+2)

print(ans)

### FIXED CODE ###

N = int(input())

#sum[i,1,N-1][i] = N*(N-1)/2

print(N*(N-1)//2)
### BUGGY CODE ###

K = int(input())


if K < 10 ** 4 + 4 * 10 ** 3:
    count = 0
    for _ in range(1, 3234566667):
        i = list(map(int, list(str(_))))
        for j in range(1, len(i)):
            if abs(i[j] - i[j - 1]) > 1:
                break
        else:
            count += 1
            if count == K:
                print(_)
                quit()
else:
    count = 100001
    for _ in range(1, 3234566668)[::-1]:
        i = list(map(int, list(str(_))))
        for j in range(1, len(i)):
            if abs(i[j] - i[j - 1]) > 1:
                break
        else:
            count -= 1
            if count == K:
                print(_)
                quit()


### FIXED CODE ###

from sys import stdin
from collections import deque

K = int(stdin.readline())

deque = deque()
for i in range(1, 10):
    deque.append(i)

for i in range(K - 1):
    s = deque.popleft()
    for j in range(-1, 2):
        add = (s % 10) + j
        if 0 <= add <= 9:
            deque.append(s * 10 + add)

print(deque.popleft())
### BUGGY CODE ###

import numpy as np
import itertools

n,p =input().split()
n = int(n)
p = int(p)

a_list = input().split()
a_list = [int(x) for x in a_list]
a_array = np.array(a_list)

amari = a_array % 2

zero_count = np.sum(amari == 0)
one_count = np.sum(amari == 1)

zero_pattern = 2**zero_count

if p == 0:
    if one_count >= 2:
        i = 1
        one_pattern = 1
        while i*2 <= one_count:
            one_pattern  += len(list(itertools.combinations(np.arange(one_count),i*2)))
            i += 1
    else:
        one_pattern = 1
else:
    if one_count >= 1:
        i = 1
        one_pattern = 0
        while i*2 - 1 <= one_count:
            one_pattern  += len(list(itertools.combinations(np.arange(one_count),i*2-1)))
            i += 1
    if one_count < 1:
        one_pattern = 0
        
print(zero_pattern * one_pattern)

### FIXED CODE ###

import numpy as np

n,p =input().split()
n = int(n)
p = int(p)

a_list = input().split()
a_list = [int(x) for x in a_list]
a_array = np.array(a_list)

amari = a_array % 2

zero_count = np.sum(amari == 0)
one_count = np.sum(amari == 1)

zero_pattern = 2**zero_count
if p == 0:
    if one_count >= 2:
        one_pattern = 2**one_count/2
    else:
        one_pattern = 1
else:
    if one_count >= 1:
        one_pattern = 2**one_count/2
    if one_count < 1:
        one_pattern = 0
        
print(int(zero_pattern * one_pattern))
### BUGGY CODE ###

n=int(input())
k=0
ans=1

for i in range(n):
  k = k+1
  ans=ans*k

print(ans%(10**9+7))

### FIXED CODE ###

n=int(input())


k=0
ans=1
w=10**9+7

for i in range(n):
  k = k+1
  ans*=k
  ans%=w

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

import sys

primes = [2, 3]
for n in range(5, 999999, 2):
    isprime = True
    for i in range(len(primes)):
        if primes[i]**2 > n:
            break
        if n%primes[i] == 0:
            isprime = False
            break
    if isprime:
        primes.append(n)

numbers = []
count = 0
for line in sys.stdin:
    numbers.append(int(line))
    count += 1

counts = []
for i in range(count):
    counts.append(0)

for prime in primes:
    if prime > 999999:
        break
    for i in range(count):
        if prime <= numbers[i]:
            counts[i] += 1

for count in counts:
    print(count)

### FIXED CODE ###

import sys

def prime(maximum):
    sieve = [True] * (maximum + 1)

    def sieved(prime):
        for not_prime in range(prime + prime, len(sieve), prime):
            sieve[not_prime] = False

    sieve[0] = sieve[1] = False
    sieved(2)
    for x in range(3, int(maximum ** 0.5) + 1, 2):
        if sieve[x]: sieved(x)
    return [prime for prime, is_prime in enumerate(sieve) if is_prime]

count = 0
numbers = []
for line in sys.stdin:
    numbers.append(int(line))
    count += 1

counts = []
for i in range(count):
    counts.append(0)

for prime in prime(1000000):
    if prime > 999999:
        break
    for i in range(count):
        if prime <= numbers[i]:
            counts[i] += 1

for count in counts:
    print(count)
### BUGGY CODE ###

N = int(input())

import sys
sys.setrecursionlimit(10 ** 9)

def dfs(x):
    ans = False
    if x == 0:
        return True
    elif x < 0:
        return False
    else:
        ans |= dfs(x - 100)
        ans |= dfs(x - 101)
        ans |= dfs(x - 102)
        ans |= dfs(x - 103)
        ans |= dfs(x - 104)
        ans |= dfs(x - 105)

    return ans
if dfs(N):
    print(1)
else:
    print(0)


### FIXED CODE ###

N = int(input())

import sys
sys.setrecursionlimit(10 ** 9)

memo = [-1] * (N + 1)

def dfs(x):
    if x >= 0 and memo[x] != -1:
        return memo[x]
    ans = False
    if x == 0:
        memo[x] = 1
        return True
    elif x < 0:
        return False
    else:
        ans |= dfs(x - 100)
        ans |= dfs(x - 101)
        ans |= dfs(x - 102)
        ans |= dfs(x - 103)
        ans |= dfs(x - 104)
        ans |= dfs(x - 105)
    memo[x] = 1 if ans else 0
    return ans
if dfs(N):
    print(1)
else:
    print(0)
### BUGGY CODE ###

s=list(input())
t=0
while t<len(s):
    if s[t]=='d':
        if t>len(s)-5:
            print('NO')
            exit()
        if s[t+1]=='r' and s[t+2]=='e' and s[t+3]=='a' and s[t+4]=='m':
            t+=5
            if t==len(s):
                print('YES')
                exit()
            elif t>len(s)-2:
                print('NO')
                exit()
            if s[t]=='e' and s[t+1]=='r':
                if t==len(s)-2:
                    print('YES')
                    exit()
                elif s[t+2]!='a':
                    t+=2
    elif s[t]=='e':
        if t>len(s)-5:
            print('NO')
            exit()
        if s[t+1]=='r' and s[t+2]=='a' and s[t+3]=='s' and s[t+4]=='e':
            t+=5
            if t==len(s):
                print('YES')
                exit()
            elif t>len(s)-1:
                print('NO')
                exit()
            if s[t]=='r':
                if t==len(s)-1:
                    print('YES')
                    exit()
                elif s[t+1]!='a':
                    t+=1
    else:
        print('NO')
        exit()

### FIXED CODE ###

s=list(input())
n=len(s)
t=n-1
while t>=0:
    if s[t]=='r':
        if t<5:
            print('NO')
            exit()
        elif s[t-1]=='e' and s[t-2]=='s' and s[t-3]=='a' and s[t-4]=='r' and s[t-5]=='e':
            t-=6
        elif t<6:
            print('NO')
            exit()
        elif s[t-1]=='e' and s[t-2]=='m' and s[t-3]=='a' and s[t-4]=='e' and s[t-5]=='r' and s[t-6]=='d':
            t-=7
        else:
            print('NO')
            exit()
    elif s[t]=='e':
        if t<4:
            print('NO')
            exit()
        elif s[t-1]=='s' and s[t-2]=='a' and s[t-3]=='r' and s[t-4]=='e':
            t-=5
        else:
            print('NO')
            exit()
    elif s[t]=='m':
        if t<4:
            print('NO')
            exit()
        elif s[t-1]=='a' and s[t-2]=='e' and s[t-3]=='r' and s[t-4]=='d':
            t-=5
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()
print('YES')
### BUGGY CODE ###

import heapq as hq
from collections import defaultdict
N, Q = map(int, input().split())
STX = [list(map(int, input().split())) for i in range(N)]
Dlist = [int(input()) for i in range(Q)]
event = []
for s,t,x in STX:
    event += [[s - x, t-x, x]]
event.sort(key=lambda x:x[0])
h = []
tdic = defaultdict(int)
ind = 0
for Di in Dlist:
    while ind<N and event[ind][0] <= Di:
        #Diまでに始まった工事を追加
        hq.heappush(h, event[ind][2])
        tdic[event[ind][2]] = event[ind][1]
        ind += 1
    while h and Di >= tdic[h[0]]:
        #Diまでに終わった工事を削除
        hq.heappop(h)
    if h:
        print(h[0])
    else:
        print(-1)

### FIXED CODE ###

import heapq as hq
from collections import defaultdict
N, Q = map(int, input().split())
event = []
for i in range(N):
    si, ti, xi = map(int, input().split())
    event.append([si - xi, ti - xi, xi])
#STX = [list(map(int, input().split())) for i in range(N)]
Dlist = [int(input()) for i in range(Q)]
#for s,t,x in STX:
#    event.append([s - x, t-x, x])
event.sort(key=lambda x:x[0])
h = []
tdic = defaultdict(int)
ind = 0
for Di in Dlist:
    while ind<N and event[ind][0] <= Di:
        #Diまでに始まった工事を追加
        hq.heappush(h, event[ind][2])
        tdic[event[ind][2]] = event[ind][1]
        ind += 1
    while h and Di >= tdic[h[0]]:
        #Diまでに終わった工事を削除
        hq.heappop(h)
    if h:
        print(h[0])
    else:
        print(-1)
### BUGGY CODE ###

n = input()
s = sorted(map(int, raw_input().split()))
q = input()
t = sorted(map(int, raw_input().split()))
cnt = 0
for x in t:
    if x in s:
        cnt += 1
print cnt

### FIXED CODE ###

n = input()
s = list(set(map(int, raw_input().split())))
q = input()
t = list(set(map(int, raw_input().split())))
b = [False] * (10**7+1)
for x in s:
    b[x] = True
cnt = 0
for x in t:
    if b[x]:
        cnt += 1
print cnt