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

from bisect import bisect_left as bl

N, Q = map(int, input().split())
ans = 0
q1 = []
q2 = []
query = []
for _ in range(Q):
    n, p = map(int, input().split())
    query.append((n, p))
    if n == 1:
        q1.append(p)
    else:
        q2.append(p)
q1.sort()
q2.sort()
board = [N - 2, N - 2]
for n, p in query:
    if n == 1:
        if p > board[1] + 1:
            continue
        index = bl(q1, p)
        ans += board[0] * (len(q1) - index)
        board[1] = p - 2
        q1 = q1[:index]
    else:
        if p > board[0] + 1:
            continue
        index = bl(q2, p)
        ans += board[1] * (len(q2) - index)
        board[0] = p - 2
        q2 = q2[:index]
print((N - 2) ** 2 - ans)

### FIXED CODE ###

from bisect import bisect_left as bl

N, Q = map(int, input().split())
ans = 0
q1 = []
q2 = []
query = []
for _ in range(Q):
    n, p = map(int, input().split())
    query.append((n, p))
    if n == 1:
        q1.append(p)
    else:
        q2.append(p)
q1.sort()
q2.sort()
board = [N - 2, N - 2]
count1 = len(q1)
count2 = len(q2)
for n, p in query:
    if n == 1:
        if p > board[1] + 1:
            continue
        index = bl(q1, p)
        ans += board[0] * (count1 - index)
        board[1] = p - 2
        count1 = index
    else:
        if p > board[0] + 1:
            continue
        index = bl(q2, p)
        ans += board[1] * (count2 - index)
        board[0] = p - 2
        count2 = index
print((N - 2) ** 2 - ans)
### BUGGY CODE ###

n=int(input())
s=list(input())
ans=0

for i in range(1000):
    num=list(str(i).zfill(3))
    k=0
    for j in range(n):
        if num[k]==s[j]:
            k+=1
            if k==3:
                break
    if k==3:
        ans+=1

print(ans)
    
    

### FIXED CODE ###

n=int(input())
s=list(input())
ans=0

for i in range(1000):
    num=list(str(i).zfill(3))
    k=0
    for j in range(n):
        if num[k]==s[j]:
            k+=1
            if k==3:
                break
    if k==3:
        ans+=1

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

N = int(input())
A = list(map(int,input().split()))
d = N // 2
a = [i for i in set(A) if A.count(i) == 2 and i != 0]
# ans = []
# def linking_up():
# ans_1 = [ i for i in range(N) if i % 2 == 1 and i!= 0 and A.count(i) == 2]
    # for i in range(N):
        # if i % 2 == 0 and i != 0:
            # if A.count(i) == 2 and A.count(0) == 1:
                # ans.append('c')
# ans_2 = [ i for i in range(N) if i % 2 == 0 and A.count(i) == 2]
        # else:
            # if A.count(i) == 2:
                # ans.append('a')
# linking_up()
if len(a) == d:
    a = (2 ** d) % (10 ** 9 + 7)
    print(a)
else:
    print(0)
        




### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
mod=10**9+7
if n%2==0:
  for i in range(n):
    if a[i]!=(i//2)*2+1:
      print(0)
      exit()
  print(pow(2,n//2,mod))
else:
  for i in range(n):
    if a[i]!=((i+1)//2)*2:
      print(0)
      exit()
  print(pow(2,n//2,mod))
### BUGGY CODE ###

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
tot=0
for a in A:
  tot^=a
T=[0]*30
for i in range(30):
  if tot&(1<<i):
    T[i]=1

Ans=[0]*n
for i in range(n):
  cur=0
  for j in range(30):
    if A[i]&(1<<j)>0 and T[j]==0:
      cur+=2**j
    elif A[i]&(1<<j)==0 and T[j]==1:
      cur+=2**j
  Ans[i]=cur
print(*Ans)
  

### FIXED CODE ###

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
tot=0
for a in A:
  tot^=a
T=[0]*30
for i in range(30):
  if tot&(1<<i):
    T[i]=1

Ans=[0]*n
for i in range(n):
  cur=0
  for j in range(30):
    if A[i]&(1<<j)>0 and T[j]==0:
      cur+=2**j
    elif A[i]&(1<<j)==0 and T[j]==1:
      cur+=2**j
  Ans[i]=cur
print(*Ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [a.count(x)-1 for x in a]
c = sum(b)//2

for y in b:
	print(c-y)

### FIXED CODE ###

import collections

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

c = collections.Counter(a)
for i in c:
  cnt += c[i]*(c[i]-1)//2



for i in range(n):
	print(cnt-c[a[i]]+1)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
N = int(input())
a = []
count = 0
for i in range(N):
    a += [''.join(sorted(input()))]
sorted_a = sorted(a)
for i in range(N-1):
    for j in range(1, N):
        if i+j >= N:
            break
        if sorted_a[i] == sorted_a[i+j]:
            count += 1
        else:
            break
print(count)

### FIXED CODE ###

from collections import defaultdict

n = int(input())
s = [input() for _ in range(n)]

d = defaultdict(int)
for i in range(n):
    d["".join(sorted(s[i]))] += 1

ans = 0
for k in d.keys():
    ans += d[k] * (d[k]-1) // 2
print(ans)
### BUGGY CODE ###


n = int(input())
a = [int(input()) for i in range(n)]

for a_i in a:
    b = a.copy()
    b.remove(a_i)
    print(max(b))


### FIXED CODE ###


n = int(input())
a = [int(input()) for i in range(n)]

a_max = max(a)
b = a.copy()
b.remove(a_max)
a_max_second = max(b)

for a_i in a:
    if a_i != a_max:
        print(a_max)
    else:
        print(a_max_second)
### BUGGY CODE ###

from decimal import Decimal
from numba import njit, i4, i8


@njit(i8(i8, i4), cache=True)
def div(n, d):
    cnt = 0
    while n % d == 0:
        n //= d
        cnt += 1
    return cnt


@njit(cache=True)
def solve(arr):
    ans = 0
    for i in range(len(arr)):
        for j in range(i + 1, len(arr)):
            (a, b), (c, d) = arr[i], arr[j]
            if a + c >= 18 and b + d >= 18:
                ans += 1
    return ans


n = int(input())
arr = [int(Decimal(input()) * 10**9) for _ in range(n)]
arr = [(div(x, 2), div(x, 5)) for x in arr]

ans = 0
for i in range(len(arr)):
    for j in range(i + 1, len(arr)):
        (a, b), (c, d) = arr[i], arr[j]
        if a + c >= 18 and b + d >= 18:
            ans += 1

print(ans)

### FIXED CODE ###

def div(n, d):
    cnt = 0
    while n % d == 0 and cnt < 18:
        n //= d
        cnt += 1
    return cnt


n = int(input())
dp = [[0]*19 for _ in range(19)]

ans = 0
for _ in range(n):
    x = round(float(input()) * pow(10, 9))
    two = div(x, 2)
    five = div(x, 5)
    ans += dp[18 - two][18 - five]
    for i in range(two + 1):
        for j in range(five + 1):
            dp[i][j] += 1

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

import sys

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

max_a=max(a)
min_a=min(a)
a0=a.count(min_a)
a1=a.count(min_a+1)
ans=1
for i in range(min_a+1,max_a):
    a2=a.count(i+1)
    ans=max(ans,(a0+a1+a2))
    a0=a1
    a1=a2
    if i ==max_a-1:
        print(ans)
        sys.exit()

print(N)

### FIXED CODE ###

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

nums=[0]*(10**5+1)
for i in a:
    nums[i]+=1

ans0=nums[0]+nums[1]+nums[2]
ans=ans0
for i in range(2,10**5-1):
    ans1=ans0-nums[i-2]+nums[i+1]
    ans=max(ans,ans1)
    ans0=ans1

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

s = input()
slen = len(s)
ans = 0

for i in range(len(s)):
  sub = s
  s = s.replace("01",'')
  s = s.replace("10",'')
  if sub == s:
    break
  
print(slen-len(s))



### FIXED CODE ###

s = input()
print(2*min(s.count("0"),s.count("1")))
### BUGGY CODE ###

a, b, c, x, y= map(int, input().split())
# a, b, c, x, y = 1500, 2000, 1600, 3, 2

price = []
for i in range(10000000):
    price.append(i * 2*c + max(0,x-i) * a + max(0,y-i) * b)

print(min(price))

### FIXED CODE ###

a, b, c, x, y= map(int, input().split())

price = []
for i in range(10**5+1):
    price.append(i * 2*c + max(0,x-i) * a + max(0,y-i) * b)
print(min(price))
### BUGGY CODE ###

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

st = 0
cnt = 0
mx = max(A)

for i in range(1, mx+1):
    if i in A:
        cnt += 1
        st = A.index(i)
        A = A[st:]
    elif N == N - cnt:
        print(-1)
        exit()
    else:
        print(N-cnt)
        exit()
print(N-cnt)

### FIXED CODE ###

N = int(input())
a = [int(s) - 1 for s in input().split()]

result = 0
for i in range(N):
    if a[i] != (i - result):
        result += 1

if result == N:
    print(-1)
else:
    print(result)
### BUGGY CODE ###

input_arr = [int(x) for x in input().split()]
 
L = input_arr[0]
R = input_arr[1]
 
min_ans = 10**18
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = (i*j)%2019
        
        if ans < min_ans:
            min_ans = ans
        if min_ans == 0:
            break
print(min_ans)

### FIXED CODE ###

L,R = [int(x) for x in input().split()]
 
min_ans = 10**18

if R-L>=2019:
  min_ans=0
else:
  for i in range(L,R):
      for j in range(i+1,R+1):
          ans = (i*j)%2019

          if ans < min_ans:
              min_ans = ans
          if min_ans == 0:
              break
print(min_ans)
### BUGGY CODE ###

N = int(input())
max_int = int(N**0.5)
for v in range(max_int,N+1):
    if N % v == 0:
        w = int(N/v)
        print(v+w-2)
        break
    else:
        pass

### FIXED CODE ###

input_number = int(input())
walk_count = int(1000000000000)
number_list_A = range(1,1000001)
#number_list_B = number_list_A

for a in number_list_A:
	if input_number % a == 0:
		b = input_number / a
		new_walk_count = int(a + b - 2)
	if new_walk_count < walk_count:
		walk_count = new_walk_count
	new_walk_count = 1000000000000

print(walk_count)
### BUGGY CODE ###

n = int(input())
s = input()
M = 10**9 + 7

def mod(v):
    if v >= M:
        return v % M
    return v

dp = [[1] * n + [0] for _ in range(2)]
for i in reversed(range(n - 1)):
    for j in range(n - 1):
        dp[1][j + 1] = mod(dp[1][j + 1] + dp[1][j])
        dp[0][j] = dp[1][j]
    dp[0][-2] = dp[1][-2]
    # print(dp[0])

    for zk in range(n):
        cnt = 0

        if s[i] == "<":
            cnt = dp[0][zk - 1]
        else:
            zj = n - i - zk - 1
            cnt = dp[0][zk + zj - 1] - dp[0][zk - 1]
        dp[1][zk] = cnt

print(sum(dp[1]) % M)


### FIXED CODE ###

n = int(input())
s = input()
M = 10**9 + 7

def mod(v):
    if v >= M:
        return v % M
    return v


dp = [[1] * n + [0] for _ in range(2)]
s = [v == "<" for v in s]
for i in reversed(range(n - 1)):
    for j in range(n - 1):
        dp[1][j + 1] = dp[1][j + 1] + dp[1][j]
        dp[0][j] = dp[1][j]
    dp[0][-2] = dp[1][-2]

    for zk in range(n - i):
        cnt = 0

        if s[i]:
            cnt = dp[0][zk - 1]
        else:
            zj = n - i - zk - 1
            cnt = dp[0][zk + zj - 1] - dp[0][zk - 1]
        dp[1][zk] = mod(cnt)

print(sum(dp[1]) % M)
### BUGGY CODE ###

n = input()
array = []
for i in range(n):
	inst = raw_input().split()
	if inst[0] == "insert":
		array.append(inst[1])
	if inst[0] == "delete":
		if inst[1] in array:
			x = array[::-1].index(inst[1])
			if x != -1:
				del array[-x-1]
	if inst[0] == "deleteFirst":
		array.pop()
	if inst[0] == "deleteLast":
		array.pop(0)
print " ".join(map(str,array[::-1]))

### FIXED CODE ###

n = input()
array = []
base = 0
for i in xrange(n):
    inst = raw_input().split()
    if inst[0][0] == 'i':
        array.append(int(inst[1]))
    elif inst[0] == "delete":
        if int(inst[1]) in array:
            x = array[::-1].index(int(inst[1]))
            if x != -1 and int(inst[1]):
                del array[-x-1]
    elif inst[0][6] == 'F':
        array.pop()
    else:
        base += 1
print (" ".join(map(str,array[base:][::-1])))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

H,W = map(int,input().split())
INF = 10**18
q = []

visited = [[True]*(W+2)]
visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)]
visited.append([True]*(W+2))
  
for i in range(1,H+1):
  for j in range(1,W+1):
    if visited[i][j]:
      q.append((i,j))

moves = [(0,1),(0,-1),(1,0),(-1,0)]

ans = -1
while q:
  qq = []
  ans += 1
  for x,y in q:
    for dx,dy in moves:
      xx = x+dx
      yy = y+dy
      if not visited[xx][yy]:
        visited[xx][yy] = True
        qq.append((xx,yy))
  q = qq
  
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

H,W = map(int,input().split())
INF = 10**18
q = []

visited = [[True]*(W+2)]
visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)]
visited.append([True]*(W+2))
  
for i in range(1,H+1):
  for j in range(1,W+1):
    if visited[i][j]:
      q.append((i,j))

moves = [(0,1),(0,-1),(1,0),(-1,0)]

ans = -1
while q:
  qq = []
  ans += 1
  for x,y in q:
    if not visited[x-1][y]:
      visited[x-1][y] = True
      qq.append((x-1,y))
    if not visited[x+1][y]:
      visited[x+1][y] = True
      qq.append((x+1,y))
    if not visited[x][y-1]:
      visited[x][y-1] = True
      qq.append((x,y-1))
    if not visited[x][y+1]:
      visited[x][y+1] = True
      qq.append((x,y+1))
  q = qq
  
print(ans)
### BUGGY CODE ###

# -*- coding:utf8 -*-

l, r = map(int, input().split())
if (l - r) >= 2019:
    ans = 0
else:
    ans = min({(i * j) % 2019 for i in range(l, r) for j in range(i + 1, r + 1)})
print(ans)

### FIXED CODE ###

# -*- coding:utf8 -*-

l, r = map(int, input().split())
if (l - r) >= 2019:
    ans = 0
else:
    ans = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            m =  (i * j) % 2019
            if m == 0:
                print(m)
                exit()
            elif m < ans:
                ans = m
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
d=[]
for _ in range(m):
    b,c=map(int,input().split())
    for _ in range(b):
    	d.append(c)

d=sorted(d,reverse=True)
right=sum(a)
left=0

for i in range(min(n,len(d))):
    if a[i]<d[i]:
        left+=d[i]
        right-=a[i]
    else:
        break
print(right+left)

### FIXED CODE ###

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

for i in range(m):
    b,c=map(int,input().split())
    arr.append((b,c))

a=sorted(a)
arr=sorted(arr,key=lambda x:-x[1])

flag=0
left=0
for tup in arr:
    for i in range(left,min(left+tup[0],n)):
        if tup[1]>a[i]:
            a[i]=tup[1]
        else:
            flag=-1
            break
        if i==n-1:
            flag=-1
            break
    left+=tup[0]
    if flag==-1:
        break

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

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))

dots = XY[:]

import sys
INT_MAX = sys.maxsize

x_dots = [(x, y) for x, y in dots]
x_dots = sorted(x_dots)
y_dots = [(y, x) for x, y in dots]
y_dots = sorted(y_dots)
y_dots = [(x, y) for y, x in y_dots]

ans = INT_MAX
for i in range(N):
    for j in range(i+1, N):
        for k in range(N):
            for l in range(k+1, N):
                #print("----")
                #print(x_dots[i:j+1])
                #print(y_dots[k:l+1])
                intersection = (set(x_dots[i:j+1]) & set(y_dots[k:l+1]))
                if len(intersection) >= K:
                    xl = x_dots[i:j+1][0][0]
                    xr = x_dots[i:j+1][-1][0]
                    yl = y_dots[k:l+1][0][1]
                    yr = y_dots[k:l+1][-1][1]
                    area = (xl-xr) * (yl-yr)
                    ans = min(ans, area)
print(ans)
                
                

### FIXED CODE ###

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
dots = XY[:]

import sys
INT_MAX = sys.maxsize

ans = INT_MAX

import itertools
for ((left_x, _), (right_x, _)) in itertools.combinations(dots, 2):
    if left_x > right_x:
        left_x, right_x = right_x, left_x
    for ((_, under_y), (_, top_y)) in itertools.combinations(dots, 2):
        if under_y > top_y:
            under_y, top_y = top_y, under_y
        counter = 0
        for d_x, d_y in dots:
            if  (left_x <= d_x) and (d_x <= right_x) and (under_y <= d_y) and (d_y <= top_y):
                counter += 1
                
        if counter >= K:
            area = (top_y-under_y) * (right_x-left_x)
            if ans > area:
                ans = area
            
print(ans)
### BUGGY CODE ###

from collections import Counter

def solve():
    MOD = 10**9 + 7
    maxA = 10**6

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

    isPrimes = [False]*2 + [True]*(maxA-1)
    minFs = [1] * (maxA+1)
    for i in range(2, int(maxA**0.5) + 1):
        if isPrimes[i]:
            for x in range(i*i, maxA+1, i):
                isPrimes[x] = False
                minFs[x] = i

    def getPrimeFactors(x):
        anss = []
        while minFs[x] > 1:
            anss.append(minFs[x])
            x //= minFs[x]
        if x != 1:
            anss.append(x)
        return anss

    PFss = []
    Primes = set()
    for A in As:
        PFs = getPrimeFactors(A)
        cnt = Counter(PFs)
        PFss.append(cnt)
        Primes |= cnt.keys()

    lcmA = 1
    for P in Primes:
        num = 0
        for PFs in PFss:
            if PFs[P] > num:
                num = PFs[P]
        lcmA *= pow(P, num, MOD)
        lcmA %= MOD

    def getInvs(n, MOD):
        invs = [1] * (n+1)
        for x in range(2, n+1):
            invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
        return invs

    invs = getInvs(10**6, MOD)

    ans = 0
    for A in As:
        ans += lcmA * invs[A]
        ans %= MOD

    print(ans)

solve()


### FIXED CODE ###

from collections import Counter

def solve():
    MOD = 10**9 + 7
    maxA = 10**6

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

    isPrimes = [False]*2 + [True]*(maxA-1)
    minFs = [1] * (maxA+1)
    for i in range(2, int(maxA**0.5) + 1):
        if isPrimes[i]:
            for x in range(i*i, maxA+1, i):
                isPrimes[x] = False
                minFs[x] = i

    def getPrimeFactors(x):
        anss = []
        while minFs[x] > 1:
            anss.append(minFs[x])
            x //= minFs[x]
        if x != 1:
            anss.append(x)
        return anss

    PFss = []
    Primes = set()
    for A in As:
        PFs = getPrimeFactors(A)
        cnt = Counter(PFs)
        PFss.append(cnt)
        Primes |= cnt.keys()

    cntP = Counter()
    for PFs in PFss:
        for key, num in PFs.items():
            cntP[key] = max(cntP[key], num)

    lcmA = 1
    for key, num in cntP.items():
        lcmA *= pow(key, num, MOD)
        lcmA %= MOD

    def getInvs(n, MOD):
        invs = [1] * (n+1)
        for x in range(2, n+1):
            invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
        return invs

    invs = getInvs(10**6, MOD)

    ans = 0
    for A in As:
        ans += lcmA * invs[A]
        ans %= MOD

    print(ans)

solve()
### BUGGY CODE ###

n,m = map(int,input().split())
if abs(n-m) != 0 and abs(n-m) != 1 :
    print(0)
else:
    x = 1
    for i in range(1,min(n,m)+1):
        x = x * i

    if abs(n-m) == 0:
        print((2 * x * x)%(10**9+7))
    else:
        print((x * x * max(n,m))%(10**9+7))

### FIXED CODE ###

import math
n,m = map(int,input().split())
if abs(n-m) != 0 and abs(n-m) != 1 :
    print(0)
else:
    x = math.factorial(min(m,n))

    if abs(n-m) == 0:
        print((2 * x * x)%(10**9+7))
    else:
        print((x * x * max(n,m))%(10**9+7))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

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

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

counter = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    p -= 1
    counter[p] += x

ans = [0] * n


def f(par, node, count):
    count += counter[node]
    ans[node] = count
    for n in edges[node]:
        if n == par:
            continue
        f(node, n, count)


f(-1, 0, 0)
print(*ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

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

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

counter = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    p -= 1
    counter[p] += x

ans = [0] * n


def f(par, node, count):
    count += counter[node]
    ans[node] = count
    for n in edges[node]:
        if n == par:
            continue
        f(node, n, count)


f(-1, 0, 0)
print(*ans)
### BUGGY CODE ###

import math
X = int(input())
N = math.floor(X ** (1/2)) + 1

for a in range(N):
  for b in range(-N,N):
    x = a**5
    y = b**5
    T = 0
    if x-y == X:
      print(a,b)
      T = 1
      break
  if T == 1:
    break

### FIXED CODE ###

import math
X = int(input())
N = math.floor(X ** (2/5)) + 1

for a in range(N):
  for b in range(-N,N):
    x = a**5
    y = b**5
    T = 0
    if x-y == X:
      print(a,b)
      T = 1
      break
  if T == 1:
    break
### BUGGY CODE ###

def main():
    n, frnd, blck = map(int, input().split())
    blst = [set() for i in range(n)]
    flst = [set() for i in range(n)]
    alst = [set() for i in range(n)]
    for _ in range(frnd):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        flst[a].add(b)
        flst[b].add(a)
        alst[a] = alst[a] | alst[b] | flst[a] | flst[b]
        alst[b] = alst[a] | alst[b] | flst[a] | flst[b]
        for v in alst[a]:
            alst[v] = alst[v] | alst[b]
        for v in alst[b]:
            alst[v] = alst[v] | alst[a]
        alst[a] = alst[a] | alst[b] | flst[a] | flst[b]
        alst[b] = alst[a] | alst[b] | flst[a] | flst[b]
    for _ in range(blck):
        c, d = map(int, input().split())
        c -= 1
        d -= 1
        blst[c].add(d)
        blst[d].add(c)
    for i in range(n):
        if i in alst[i]:
            alst[i].remove(i)
        for v in flst[i]:
            if v in alst[i]:
                alst[i].remove(v)
        for v in blst[i]:
            if v in alst[i]:
                alst[i].remove(v)
    for i in range(n):
        print(len(alst[i]), end="")
        if i < n:
            print(" ", end="")

if __name__ == "__main__":
    main()

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    n, frnd, blck = map(int, input().split())
    blst = [set() for i in range(n)]
    flst = [set() for i in range(n)]
    uf = UnionFind(n)
    for _ in range(frnd):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        flst[a].add(b)
        flst[b].add(a)
        uf.union(a, b)
    for _ in range(blck):
        c, d = map(int, input().split())
        c -= 1
        d -= 1
        blst[c].add(d)
        blst[d].add(c)
    for i in range(n):
        ans = uf.size(i) - len(flst[i]) - 1
        for v in blst[i]:
            if uf.same(i, v):
                ans -= 1
        print(ans, end="")
        if i < n:
            print(" ", end="")

if __name__ == "__main__":
    main()