Consider a football tournament where n teams participate. Each team has two football kits: for home games, and for away games. The kit for home games of the i-th team has color x_{i} and the kit for away games of this team has color y_{i} (x_{i} ≠ y_{i}).

In the tournament, each team plays exactly one home game and exactly one away game with each other team (n(n - 1) games in total). The team, that plays the home game, traditionally plays in its home kit. The team that plays an away game plays in its away kit. However, if two teams has the kits of the same color, they cannot be distinguished. In this case the away team plays in its home kit.

Calculate how many games in the described tournament each team plays in its home kit and how many games it plays in its away kit.


-----Input-----

The first line contains a single integer n (2 ≤ n ≤ 10^5) — the number of teams. Next n lines contain the description of the teams. The i-th line contains two space-separated numbers x_{i}, y_{i} (1 ≤ x_{i}, y_{i} ≤ 10^5; x_{i} ≠ y_{i}) — the color numbers for the home and away kits of the i-th team.


-----Output-----

For each team, print on a single line two space-separated integers — the number of games this team is going to play in home and away kits, correspondingly. Print the answers for the teams in the order they appeared in the input.


-----Examples-----
Input
2
1 2
2 1

Output
2 0
2 0

Input
3
1 2
2 1
1 3

Output
3 1
4 0
2 2

Difficulty: EASY
Tags: Complete search

Implementation

Greedy algorithms
Skill types: Complete search

Greedy algorithms

Starter code:

Solutions:
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans
uniform = dict()
li = []
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	li.append(y)
	uniform.setdefault(y, 0)
	uniform.setdefault(x, 0)
	uniform[x] += 1
for i in range(n):
	print(n - 1 + uniform[li[i]], n - 1 - uniform[li[i]])


import math
import sys
from collections import *
from bisect import bisect_left, bisect_right

def cint():
	return list(map(int, sys.stdin.readline().strip().split()))

def cstr():
	return list(map(str, input().split(' ')))

def solve():
	n = int(input())
	lst1 = []
	lst2 = []
	for i in range(n):
		(x, y) = cint()
		lst1.append(x)
		lst2.append(y)
	cnt = {}
	for i in lst1:
		if cnt.get(i) is None:
			cnt[i] = 1
		else:
			cnt[i] += 1
	for i in range(n):
		same = cnt.get(lst2[i])
		if same is None:
			same = 0
		home = n - 1 + same
		away = n - 1 - same
		print(home, away)
t = 1
while t != 0:
	solve()
	t -= 1


def main():
	n = int(input())
	l = list((tuple(map(int, input().split())) for _ in range(n)))
	(xx, yy) = ([0] * 100001, [0] * 100001)
	for (x, y) in l:
		xx[x] += 1
		yy[y] += 1
	n -= 1
	for (i, (_, y)) in enumerate(l):
		x = xx[y]
		l[i] = '{:d} {:d}'.format(n + x, n - x)
	print('\n'.join(l))
main()


n = int(input())
i = 0
l1 = list()
l2 = list()
l3 = [0] + [0] * 10 ** 5
l4 = [0] + [0] * 10 ** 5
i = 0
while i < n:
	(x, y) = map(int, input().split())
	l1.append(x)
	l2.append(y)
	l3[x] += 1
	l4[y] += 1
	i += 1
i = 0
for i in range(n):
	print(n - 1 + l3[l2[i]], n - 1 - l3[l2[i]])


n = int(input())
away = [0] * n
home = [0] * 100001
for i in range(n):
	(h, away[i]) = map(int, input().split())
	home[h] += 1
for i in range(n):
	print(n - 1 + home[away[i]], n - 1 - home[away[i]])


n = int(input())
(l, m, p, r) = ([0] * n, [0] * n, [n - 1] * n, {})
for i in range(n):
	(l[i], m[i]) = map(int, input().split())
	r[l[i]] = r.get(l[i], 0) + 1
l = set(l)
for i in range(n):
	if m[i] in l:
		p[i] += r[m[i]]
	print(p[i], 2 * n - 2 - p[i])


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
for _ in range(1):
	n = nmbr()
	hk = {}
	l = []
	for i in range(n):
		(x, y) = lst()
		hk[x] = hk.get(x, 0) + 1
		l += [[x, y]]
	for (h, a) in l:
		hh = n - 1 + hk.get(a, 0)
		print(hh, 2 * (n - 1) - hh)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		n = I()
		xy = [LI() for _ in range(n)]
		m = n - 1
		c = collections.Counter([x for (x, y) in xy])
		for (x, y) in xy:
			t = c[y]
			rr.append(JA([m + t, m - t], ' '))
	return JA(rr, '\n')
print(main())


import sys

def main():
	line_num = 0
	teams_num = 0
	teams_per_color = {}
	teams = []
	for line in sys.stdin:
		if line_num == 0:
			teams_num = int(line.strip())
		elif line_num <= teams_num:
			res = list([int(x) for x in line.strip().split(' ')])
			if res[0] not in teams_per_color:
				teams_per_color[res[0]] = 0
			teams_per_color[res[0]] = teams_per_color[res[0]] + 1
			teams.append((res[0], res[1]))
		line_num += 1
		if line_num > teams_num:
			break
	for i in range(0, teams_num):
		away_color = teams[i][1]
		result = (teams_num - 1 + teams_per_color.get(away_color, 0), teams_num - 1 - teams_per_color.get(away_color, 0))
		print('{} {}'.format(result[0], result[1]))

def __starting_point():
	main()
__starting_point()


def main():
	n = int(input())
	a = [0] * n
	uni_col = [0] * 100001
	for i in range(n):
		(h, a[i]) = map(int, input().split())
		uni_col[h] += 1
	for i in range(n):
		print(n - 1 + uni_col[a[i]], n - 1 - uni_col[a[i]])
main()


import sys
import math
n = int(sys.stdin.readline())
a = [0] * 100000
b = [0] * 100000
d = []
for i in range(n):
	(h, g) = [int(x) for x in sys.stdin.readline().split()]
	d.append((h - 1, g - 1))
	a[h - 1] += 1
	b[g - 1] += 1
for i in d:
	print(str(n - 1 + a[i[1]]) + ' ' + str(n - a[i[1]] - 1))


from collections import Counter
n = int(input())
(x, y) = ([], [])
for _ in range(n):
	(a, b) = map(int, input().split())
	x.append(a)
	y.append(b)
home = Counter(x)
away = Counter(y)
ans = 0
(mHome, mAway) = ([n - 1] * n, [n - 1] * n)
for i in range(n):
	if y[i] in home:
		mHome[i] += home[y[i]]
		mAway[i] -= home[y[i]]
for j in range(n):
	print(mHome[j], mAway[j])


n = int(input())
(x, y) = ([0] * n, [0] * n)
for i in range(n):
	(x[i], y[i]) = map(int, input().split())
c = [0] * 1000001
for i in x:
	c[i] += 1
for i in y:
	print(n - 1 + c[i], n - 1 - c[i])


from sys import stdin
n = int(stdin.readline())
list1 = [0] * 100001
list2 = [0] * 100001
list3 = []
for i in range(n):
	(a, b) = map(int, stdin.readline().strip().split())
	list1[a] += 1
	list2[b] += 1
	list3.append((a, b))
for i in range(n):
	s2 = list1[list3[i][1]]
	print(n - 1 + s2, n - 1 - s2)


n = int(input())
colors = []
for i in range(n):
	colors.append(list(map(int, input().split(' '))))
dic_maincolor = {}
for i in range(n):
	if colors[i][0] in dic_maincolor.keys():
		dic_maincolor[colors[i][0]] += 1
	else:
		dic_maincolor[colors[i][0]] = 1
for i in range(n):
	mainadd = dic_maincolor[colors[i][1]] if colors[i][1] in dic_maincolor.keys() else 0
	print('{} {}'.format(n - 1 + mainadd, n - 1 - mainadd))


n = int(input())
arr = []
for i in range(n):
	li = [int(x) for x in input().split()]
	arr.append(li)
ans = [[0, 0] for i in range(n)]
d = {}
for i in range(n):
	if arr[i][0] in d:
		d[arr[i][0]] += 1
	else:
		d[arr[i][0]] = 1
for i in range(n):
	ans[i][0] = n - 1
	s = 0
	if arr[i][1] in d:
		s = d[arr[i][1]]
	t = n - s - 1
	ans[i][0] += s
	ans[i][1] += t
for ele in ans:
	print(*ele)


from sys import stdin
from collections import defaultdict
n = int(stdin.readline().rstrip())
d1 = defaultdict(int)
d2 = defaultdict(int)
l = []
for i in range(n):
	(a, b) = map(int, stdin.readline().split())
	l.append(b)
	d1[a] += 1
	d2[b] += 1
for i in range(n):
	print(str(n - 1 + d1[l[i]]) + ' ' + str(n - 1 - d1[l[i]]))


n = int(input())
h = []
a = []
d = [0] * (10 ** 5 + 1)
for i in range(n):
	(c, b) = map(int, input().split())
	d[c] += 1
	a.append(b)
for i in a:
	print(n - 1 + d[i], n - 1 - d[i])


n = int(input())
L = [0] * n
c = [0] * (10 ** 5 + 1)
for i in range(n):
	(a, b) = map(int, input().split())
	L[i] = b
	c[a] += 1
for i in range(n):
	print(n - 1 + c[L[i]], n - 1 - c[L[i]])


import sys
import math as m

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans
mod = int(1000000000.0) + 7

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

def iinp():
	return int(input())

def ninp():
	return map(int, sys.stdin.readline().strip().split())

def llinp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
n = iinp()
home = [0] * 100005
away = [0] * 100005
ansh = [n - 1] * n
ansa = [n - 1] * n
l1 = []
l2 = []
for i in range(n):
	(a, b) = ninp()
	l1.append(a)
	l2.append(b)
	home[a] += 1
	away[b] += 1
for i in range(n):
	if home[l2[i]] != 0:
		ansh[i] = ansh[i] + home[l2[i]]
		ansa[i] = ansa[i] - home[l2[i]]
	print(ansh[i], ansa[i])


n = int(input())
colors = [tuple(map(int, input().split())) for x in range(n)]
resp = [[0, 0] for x in range(n)]
count_home = [0 for x in range(100001)]
for i in range(n):
	resp[i][0] += n - 1
	count_home[colors[i][0]] += 1
for i in range(n):
	color_away = colors[i][1]
	color_home = colors[i][0]
	aux = count_home[color_away]
	resp[i][0] += aux
	resp[i][1] += n - 1 - aux
for r in resp:
	print(r[0], r[1])


teams = int(input())
home_kit = {}
away_kit = []
for i in range(teams):
	temp = list(map(int, input().split()))
	away_kit.append(temp[1])
	if str(temp[0]) in home_kit:
		home_kit[str(temp[0])] += 1
	else:
		home_kit[str(temp[0])] = 1
for j in range(teams):
	if str(away_kit[j]) in home_kit:
		print(f'{home_kit[str(away_kit[j])] + teams - 1} {2 * (teams - 1) - (home_kit[str(away_kit[j])] + teams - 1)}')
	else:
		print(f'{teams - 1} {teams - 1}')


n = int(input())
a = [0] * n
c = [0] * 100001
for i in range(n):
	(s, a[i]) = map(int, input().split())
	c[s] += 1
for i in range(n):
	print(n - 1 + c[a[i]], n - 1 - c[a[i]])


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.setrecursionlimit(int(pow(10, 6)))
	sys.stdin = open('input.txt', 'r')
except:
	pass
n = L()[0]
home = [0 for i in range(n)]
away = [0 for i in range(n)]
d = {}
for i in range(n):
	(home[i], away[i]) = L()
	d[home[i]] = d.get(home[i], 0) + 1
for i in range(n):
	ans = d.get(away[i], 0)
	print(n - 1 + ans, n - 1 - ans)
endtime = time.time()


n = int(input())
C = [0] * 100001
home = n - 1
lst = []
for i in range(n):
	(x, y) = map(int, input().split())
	C[x] += 1
	lst.append(y)
for i in lst:
	print(home + C[i], home - C[i])


(n, i, o) = (int(input()), [0 for z in range(10 ** 5 + 1)], [])
for k in range(n):
	(inp1, inp2) = list(map(int, input().split()))
	i[inp1] += 1
	o.append(inp2)
for k in o:
	print(n - 1 + i[k], n - 1 - i[k])


n = int(input())
home = []
guest = []
for _ in range(n):
	(x, y) = map(int, input().split())
	home.append(x)
	guest.append(y)
ah = dict()
ag = dict()
for elem in home:
	if elem in ah:
		ah[elem] += 1
	else:
		ah[elem] = 1
for elem in guest:
	if elem in ag:
		ag[elem] += 1
	else:
		ag[elem] = 1
games = 2 * (n - 1)
for i in range(n):
	try:
		ahh = ah[guest[i]]
	except KeyError:
		ahh = 0
	anshome = n - 1 + ahh
	ansguest = games - anshome
	print(anshome, ansguest)


n = int(input())
local = [0] * (10 ** 5 + 1)
kits = []
for i in range(n):
	(x, y) = list(map(int, input().split(' ')))
	kits.append((x, y))
	local[x] += 1
res = ['%s %s' % (n - 1 + local[y], n - 1 - local[y]) for (x, y) in kits]
print('\n'.join(res))


while True:
	try:

		def solv():
			n = int(input())
			awy = [0] * (10 ** 5 + 1)
			aw = list()
			for i in range(n):
				(hm, a) = map(int, input().split())
				aw.append(a)
				awy[hm] += 1
			for i in range(n):
				print(n + awy[aw[i]] - 1, n - 1 - awy[aw[i]])
		if __name__ == '__main__':
			solv()
	except EOFError:
		break


import sys
input = sys.stdin.readline
n = int(input())
A = []
B = []
C = [0] * (10 ** 5 + 1)
for i in range(n):
	(x, y) = map(int, input().split())
	A.append(x)
	B.append(y)
	C[x] += 1
for i in range(n):
	print(n - 1 + C[B[i]], n - 1 - C[B[i]])


n = int(input())
home = []
away = []
lst = [0] * 200000
for i in range(n):
	l = list(map(int, input().split()))
	home.append(l[0])
	away.append(l[1])
	lst[int(l[0]) - 1] += 1
for i in range(n):
	s = away[i]
	num = int(lst[s - 1])
	a = n - 1 + num
	b = n - 1 - num
	ls = [str(a), str(b)]
	print(' '.join(ls))


Home = [0] * (10 ** 5 + 1)
A = []
a = int(input())
for i in range(a):
	(m, n) = map(int, input().split())
	Home[m] += 1
	A.append([m, n])
for i in A:
	print(a - 1 + Home[i[1]], a - 1 - Home[i[1]])


n = int(input())
teams = []
for i in range(n):
	teams.append(list(map(int, input().split())))
dic = {}
for i in teams:
	dic[i[0]] = dic.get(i[0], 0) + 1
for i in teams:
	home = n - 1 + dic.get(i[1], 0)
	away = 2 * (n - 1) - home
	print(home, ' ', away)


import os, sys
from io import BytesIO, IOBase

def main():
	from collections import defaultdict
	n = int(input())
	x = defaultdict(lambda : 0)
	y = defaultdict(lambda : 0)
	z = []
	an = []
	for i in range(n):
		(a, b) = map(int, input().split())
		x[a] += 1
		y[b] += 1
		an.append(b)
	for j in y:
		y[j] = n - 1 + x[j]
	for i in range(n):
		print(y[an[i]], 2 * (n - 1) - y[an[i]])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return map(int, input().split())

def array():
	return [int(i) for i in input().split()]
n = int(input())
a = []
away = defaultdict(int)
for i in range(n):
	(h, w) = value()
	a.append((h, w))
	away[h] += 1
s = away.keys()
for team in a:
	h = n - 1
	w = n - 1
	if team[1] in away:
		h += away[team[1]]
		w = 2 * (n - 1) - h
	print(h, w)


def main():
	n = int(input())
	teams = [input().split() for _ in range(n)]
	ans = [list((0, 0)) for _ in range(n)]
	home = dict()
	for i in range(n):
		home[teams[i][0]] = home.get(teams[i][0], 0) + 1
	for i in range(n):
		ans[i][0] = n - 1 + home.get(teams[i][1], 0)
		ans[i][1] = n - 1 - home.get(teams[i][1], 0)
	for i in range(n):
		ans[i] = '{} {}'.format(ans[i][0], ans[i][1])
	print('\n'.join(ans))
main()


n = int(input())
ak = []
hkd = {}
ans = ''
for i in range(n):
	(x, y) = input().split()
	ak.append(y)
	hkd[x] = hkd.get(x, 0) + 1
for i in range(n):
	home = away = n - 1
	cnt = hkd.get(ak[i], 0)
	away -= cnt
	home += cnt
	ans += f'{home} {away}\n'
print(ans)


from sys import stdin
n = int(stdin.readline().rstrip())
h = [0] * (10 ** 5 + 6)
a = [0] * (n + 1)
for i in range(n):
	l = list(map(int, stdin.readline().rstrip().split(' ')))
	h[l[0]] += 1
	a[i + 1] = l[1]
for i in range(1, n + 1):
	print(n - 1 + h[a[i]], 2 * n - 2 - (n - 1 + h[a[i]]))


import sys
inf = float('inf')
(mod, MOD) = (1000000007, 998244353)
from collections import deque, Counter, OrderedDict, defaultdict

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
away = {}
home = {}
away = defaultdict(lambda : 0, away)
home = defaultdict(lambda : 0, home)
for i in range(n):
	(x, y) = get_ints()
	home[x] = home.get(x, 0) + 1
	away[i + 1] = y
for i in range(1, n + 1):
	x = n - 1 + home[away[i]]
	y = n - 1 - home[away[i]]
	print(x, y)


n = int(input())
home = {}
guest = []
for i in range(n):
	(h, g) = [int(c) for c in input().split()]
	home[h] = 1 if not h in home else home[h] + 1
	guest.append(g)
for i in range(n):
	h = n - 1 + (0 if not guest[i] in home else home[guest[i]])
	print('%s %s' % (h, (n - 1) * 2 - h))


from sys import stdin
from collections import Counter
input = stdin.readline
n = int(input())
(home, away) = ([0] * n, [0] * n)
for i in range(n):
	(home[i], away[i]) = map(int, input().split())
cnt = Counter(home)
k = n - 1
for i in away:
	x = cnt[i]
	print(k + x, k - x)


from collections import Counter
n = int(input())
arr = [list(map(int, input().split())) for _ in range(n)]
home = [0] * 100001
for (h, a) in arr:
	home[h] += 1
num_match = n - 1
for (h, a) in arr:
	x = home[a]
	print(num_match + x, num_match - x)


from collections import Counter
n = int(input())
x = []
y = []
for i in range(n):
	tmp = [int(i) for i in input().split()]
	x.append(tmp[0])
	y.append(tmp[1])
xx = Counter(x)
yy = Counter(y)
for i in range(n):
	print(n - 1 + xx[y[i]], n - 1 - xx[y[i]])


c = []
d = []
n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	c.append(x)
	d.append(y)
total = 2 * (n - 1)
dir = {}
for i in c:
	try:
		dir[i] += 1
	except:
		dir[i] = 1
for i in range(n):
	try:
		print(int(total / 2 + dir[d[i]]), int(total / 2 - dir[d[i]]))
	except:
		print(int(total / 2), int(total / 2))


from collections import Counter as co
home = []
away = []
homec = []
awayc = []
t = int(input())
for _ in range(t):
	(m, n) = map(int, input().split())
	home.append(m)
	away.append(n)
	homec.append(t - 1)
	awayc.append(t - 1)
ho = co(home)
aw = co(away)
for i in range(len(away)):
	homec[i] += ho[away[i]]
	awayc[i] -= ho[away[i]]
for i in range(len(away)):
	print(homec[i], awayc[i])


import sys
from collections import Counter

def fmax(n, h, a):
	th = [n - 1] * n
	ta = [n - 1] * n
	ch = Counter(h)
	ca = Counter(a)
	for i in range(n):
		t = a[i]
		ct = ch[t]
		ta[i] = ta[i] - ct
		th[i] = th[i] + ct
	return (th, ta)
input = sys.stdin.read()
data = list(map(int, input.split()))
t = int(data[0])
l = 0
n = t
h = []
a = []
for i in range(t):
	h.append(data[l + 1])
	a.append(data[l + 2])
	l = l + 2
(th, ta) = fmax(n, h, a)
for i in range(t):
	print(th[i], ta[i])


n = int(input())
a = []
b = []
home = [0] * (10 ** 5 + 10)
for i in range(n):
	(na, nb) = list(map(int, input().split()))
	a.append(na)
	b.append(nb)
	home[na] += 1
total = 0
for i in range(len(a)):
	home_count = n - 1 + home[b[i]]
	guest_count = 2 * (n - 1) - home_count
	print(home_count, guest_count)


n = int(input())
l = []
m = [0] * 111111
for i in range(n):
	(x, y) = [int(x) for x in input().split()]
	l.append((x, y))
	m[x] += 1
for i in range(n):
	print(n - 1 + m[l[i][1]], n - 1 - m[l[i][1]])


n = int(input())
x = [0 for i in range(n)]
y = [0 for i in range(n)]
d1 = {}
d2 = {}
for i in range(n):
	(x[i], y[i]) = map(int, input().split())
	d1.setdefault(y[i], 0)
	d1[y[i]] += 1
	d2.setdefault(x[i], 0)
	d2[x[i]] += 1
for i in range(n):
	d1.setdefault(x[i], 0)
	d2.setdefault(y[i], 0)
	print(d2[y[i]] + n - 1, n - 1 - d2[y[i]])


from sys import stdin
from collections import defaultdict
n = int(stdin.readline())
teams = []
home = defaultdict(lambda : 0)
away = defaultdict(lambda : 0)
for _ in range(n):
	(a, b) = list(map(int, stdin.readline().rstrip().split(' ')))
	home[a] += 1
	away[b] += 1
	teams.append((a, b))
for (a, b) in teams:
	h = n - 1 + home[b]
	aw = n - 1 - home[b]
	print(h, aw)


n = int(input())
c = [0] * 100001
y = [0] * n
for i in range(n):
	(x, y[i]) = map(int, input().split())
	c[x] += 1
for i in range(n):
	a = n - 1 + c[y[i]]
	b = 2 * n - 2 - a
	print(a, b)


n = int(input())
l = []
home = {}
for i in range(n):
	k = list(map(int, input().split()))
	if k[0] not in home.keys():
		home[k[0]] = 1
	else:
		home[k[0]] += 1
	l.append(k)
for i in range(n):
	homie = n - 1
	if l[i][1] in home.keys():
		extra = home[l[i][1]]
	else:
		extra = 0
	k1 = homie + extra
	k2 = n - 1 - extra
	print(k1, k2)


import sys
f = sys.stdin
n = int(f.readline().strip())
A = []
F = {}
for k in range(n):
	t = list(map(int, f.readline().strip().split()))
	A.append(t)
	if t[0] in F:
		F[t[0]] += 1
	else:
		F[t[0]] = 1
res = ''
p = []
for u in A:
	if u[1] in F:
		p.append(str(n - 1 + F[u[1]]) + ' ' + str(n - 1 - F[u[1]]))
	else:
		p.append(str(n - 1) + ' ' + str(n - 1))
print('\n'.join(p))


import sys
import math

def fn(n, x, y):
	cnt = [0] * 100001
	for i in range(n):
		cnt[x[i]] = cnt[x[i]] + 1
	for i in range(n):
		print(n - 1 + cnt[y[i]], n - 1 - cnt[y[i]])
input = sys.stdin.read()
data = list(map(int, input.split()))
n = data[0]
x = []
y = []
l = 1
for i in range(1, 2 * n + 1):
	if i % 2 == 0:
		y.append(data[i])
	else:
		x.append(data[i])
fn(n, x, y)


n = int(input())
cnt = [0] * (10 ** 5 + 1)
x = []
y = []
for i in range(n):
	(a, b) = map(int, input().split())
	x.append(a)
	y.append(b)
	cnt[x[i]] += 1
ans_home = [0] * n
ans_away = [0] * n
for i in range(n):
	ans_home[i] = n - 1
	ans_home[i] += cnt[y[i]]
	ans_away[i] = 2 * (n - 1) - ans_home[i]
for i in range(n):
	print(ans_home[i], ans_away[i])


size = int(input())
match = size - 1
commands_colours = []
cnt = [0] * 100001
for i in range(0, size):
	commands_colours.append([int(x) for x in input().split()])
	cnt[commands_colours[i][0]] = cnt[commands_colours[i][0]] + 1
for i in range(0, size):
	print(match + cnt[commands_colours[i][1]], match - cnt[commands_colours[i][1]])


n = int(input())
a = [0] * 10 ** 6
b = []
for i in range(n):
	(q, w) = map(int, input().split())
	a[q] += 1
	b.append(w)
for i in range(n):
	print(n - 1 + a[b[i]], n - 1 - a[b[i]])


def main():
	n = int(input())
	(l, xx) = ([], {})
	for _ in range(n):
		(x, y) = map(int, input().split())
		xx[x] = xx.get(x, 0) + 1
		l.append(y)
	n -= 1
	for (i, y) in enumerate(l):
		x = xx.get(y, 0)
		l[i] = '{:d} {:d}'.format(n + x, n - x)
	print('\n'.join(l))
main()


import sys
import bisect
import heapq
from math import *
from collections import defaultdict as dd
from collections import deque
from collections import Counter as c
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(var):
	sys.stdout.write(var)

def l():
	return list(map(int, data().split()))

def sl():
	return list(map(str, data().split()))

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
n = int(data())
(dp1, dp2) = (dd(int), dd(int))
teams = list()
for i in range(n):
	(a, b) = sp()
	teams.append([a, b])
	dp1[a] += 1
	dp2[b] += 1
for i in range(n):
	(a, b) = (teams[i][0], teams[i][1])
	(home, away) = (n - 1, n - 1)
	if b in dp1.keys():
		home += dp1[b]
		away -= dp1[b]
	print(home, away)


n = int(input())
a = [0] * n
x = [0] * 100001
for i in range(n):
	(s, a[i]) = list(map(int, input().split()))
	x[s] += 1
for i in range(n):
	print(n - 1 + x[a[i]], n - 1 - x[a[i]])


from collections import deque, Counter, OrderedDict
from heapq import nsmallest, nlargest
from math import ceil, floor, log, log2, sqrt, gcd, factorial, pow, pi
from bisect import bisect_left, bisect_right

def binNumber(n, size=4):
	return bin(n)[2:].zfill(size)

def iar():
	return list(map(int, input().split()))

def ini():
	return int(input())

def isp():
	return map(int, input().split())

def sti():
	return str(input())

def par(a):
	print(' '.join(list(map(str, a))))

def tdl(outerListSize, innerListSize, defaultValue=0):
	return [[defaultValue] * innerListSize for i in range(outerListSize)]

def sts(s):
	s = list(s)
	s.sort()
	return ''.join(s)

class pair:

	def __init__(self, f, s):
		self.fi = f
		self.se = s

	def __lt__(self, other):
		return (self.fi, self.se) < (other.fi, other.se)

def check(a):
	s = a[0][0] + a[1][0] + a[2][0]
	for i in range(3):
		if sum(a[i]) != s:
			return False
	for i in range(3):
		s1 = 0
		for j in range(3):
			s1 += a[i][j]
		if s1 != s:
			return False
	s1 = a[1][1] + a[2][2] + a[0][0]
	s2 = a[2][0] + a[1][1] + a[0][2]
	if s1 != s or s2 != s:
		return False
	return True
c1 = [0] * 100005
c2 = [0] * 100005
n = ini()
i1 = []
i2 = []
for i in range(n):
	(x, y) = isp()
	i1.append(x)
	i2.append(y)
	c1[x] += 1
	c2[y] += 1
for i in range(n):
	hm = n - 1 + c1[i2[i]]
	aw = 2 * (n - 1) - hm
	print(hm, aw)


n = int(input())
count_homes = [0] * 100001
away = [0] * n
for i in range(n):
	(x, y) = map(int, input().split())
	count_homes[x] += 1
	away[i] = y
for i in range(n):
	(a, b) = (n - 1, n - 1)
	odds = count_homes[away[i]]
	a += odds
	b -= odds
	print(a, b)


def solve2(n, arr):
	home = [0] * int(100000.0 + 1)
	away = [0] * int(100000.0 + 1)
	for a in arr:
		home[a[0]] += 1
		away[a[1]] += 1
	num_match = n - 1
	for a in arr:
		print(num_match + home[a[1]], num_match - home[a[1]])
n = int(input())
arr = [list(map(int, input().split())) for _ in range(n)]
solve2(n, arr)


class CodeforcesTask432BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.kits = []

	def read_input(self):
		self.n = int(input())
		for x in range(self.n):
			self.kits.append([int(y) for y in input().split(' ')])

	def process_task(self):
		home_kits = {}
		for kit in self.kits:
			if kit[0] not in home_kits:
				home_kits[kit[0]] = 1
			else:
				home_kits[kit[0]] += 1
		result = []
		for x in range(self.n):
			if self.kits[x][1] in home_kits:
				wrong = home_kits[self.kits[x][1]]
				result.append(str(self.n - 1 + wrong) + ' ' + str(self.n - 1 - wrong))
			else:
				result.append(str(self.n - 1) + ' ' + str(self.n - 1))
		self.result = '\n'.join(result)

	def get_result(self):
		return self.result
Solution = CodeforcesTask432BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
l = [[0, 0] for i in range(n)]
m = [0] * 100001
for i in range(n):
	(x, y) = [int(x) for x in input().split()]
	l[i][0] = x
	l[i][1] = y
	m[x] += 1
for i in range(n):
	x = m[l[i][1]]
	print(n - 1 + x, n - 1 - x)


from collections import Counter
n = int(input())
home = []
away = []
for i in range(n):
	(xi, yi) = map(int, input().split())
	home.append(xi)
	away.append(yi)
c = Counter(home)
for i in range(n):
	h = c[away[i]]
	homekit = n - 1 + h
	awaykit = n - 1 - h
	print(homekit, awaykit)


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write()
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
a = []
n = int(input())
zx = [0] * (10 ** 5 + 10)
zy = []
for i in range(n):
	(x, y) = map(int, input().rstrip().split())
	zx[x] += 1
	zy.append(y)
for i in range(n):
	print(n - 1 + zx[zy[i]], n - 1 - zx[zy[i]])


n = int(input())
x = []
y = []
for _ in range(n):
	(a, b) = list(map(int, input().split()))
	x.append(a)
	y.append(b)
ans1 = []
ans2 = []
kk = {}
for i in x:
	if i in kk:
		kk[i] += 1
	else:
		kk[i] = 1
for i in y:
	if i in kk:
		k = kk[i]
	else:
		k = 0
	ans1.append(n - 1 + k)
	ans2.append(n - 1 - k)
for i in range(n):
	print(ans1[i], ans2[i])


def zip_sorted(a, b):
	(a, b) = zip(*sorted(zip(a, b)))
	sorted(zip(a, b), key=lambda x: x[1])
	return (a, b)
import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n,) = I()
x = [0] * n
x1 = [0] * (10 ** 5 + 2)
y = [0] * n
y1 = [0] * (10 ** 5 + 2)
for i in range(n):
	(x[i], y[i]) = I()
	x1[x[i]] = x1[x[i]] + 1
	y1[y[i]] = y1[y[i]] + 1
for i in range(n):
	away = 0
	if x[i] != y[i]:
		if x1[y[i]] == 0:
			away = n - 1
		else:
			away = n - 1 - x1[y[i]]
	else:
		away = n - 1 - x1[y[i]] - 1
	home = n - 1 + (n - 1 - away)
	print(home, away, sep=' ')


n = int(input())
h = []
a = []
for i in range(n):
	(k, j) = [int(l) for l in input().split()]
	h.append(k)
	a.append(j)
home = [n - 1 for i in h]
away = [n - 1 for i in a]
c = [0 for i in range(100001)]
for i in range(n):
	c[h[i]] += 1
for i in range(n):
	home[i] += c[a[i]]
	away[i] -= c[a[i]]
for i in range(n):
	print(home[i], away[i])


n = int(input())
home = []
away = []
sumH = [0] * 100001
for i in range(n):
	(x, y) = map(int, input().split())
	home.append(x)
	away.append(y)
	sumH[x] += 1
for i in range(n):
	h = sumH[away[i]] + n - 1 - (home[i] == away[i])
	print(str(h) + ' ' + str(2 * n - 2 - h))


v = int(input())
t = [[v - 1, v - 1] for i in range(v)]
d = []
g = {}
for i in range(v):
	(n, m) = map(int, input().split())
	d.append([n, m])
	if n in g:
		g[n] += 1
	else:
		g[n] = 1
for i in range(v):
	if d[i][1] in g:
		t[i][0] += g[d[i][1]]
		t[i][1] -= g[d[i][1]]
[print(i[0], i[1]) for i in t]


def main():
	n = int(input())
	teams = [list(map(int, input().split())) for _ in range(n)]
	home = [0] * (10 ** 5 + 1)
	ans = list()
	for i in range(n):
		home[teams[i][0]] += 1
	print('\n'.join(('{} {}'.format(n - 1 + home[teams[i][1]], n - 1 - home[teams[i][1]]) for i in range(n))))

def __starting_point():
	main()
__starting_point()


__author__ = 'Lipen'

def main():
	n = int(input())
	X = []
	Y = []
	color = [0] * 100001
	for i in range(n):
		(x, y) = map(int, input().split())
		X.append(x)
		Y.append(y)
		color[x] += 1
	s = ''
	for i in range(n):
		z = color[Y[i]]
		s += '{} {}\n'.format(n - 1 + z, n - 1 - z)
	print(s[:-1])
main()


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from operator import add
inf = float('inf')
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
n = ii()
arr = [rr() for _ in range(n)]
brr = [j for (i, j) in arr]
arr = [i for (i, j) in arr]
x = Counter(arr)
for (i, j) in zip(arr, brr):
	print(n - 1 + x[j], n - 1 - x[j])


import collections
n = int(input())
h = [0] * n
a = [0] * n
d = [0] * (10 ** 5 + 1)
for i in range(n):
	(x, y) = map(int, input().split())
	h[i] = x
	a[i] = y
	d[x] += 1
for i in range(n):
	print(n - 1 + d[a[i]], n - 1 - d[a[i]])


n = int(input())
x = []
for i in range(n):
	x.append(list(map(int, input().split())))
h = {}
a = {}
for i in range(n):
	if h.get(str(x[i][0])):
		h[str(x[i][0])] += 1
	else:
		h[str(x[i][0])] = 1
for i in range(n):
	home = n - 1
	if h.get(str(x[i][1])):
		if h[str(x[i][1])] > 0:
			away = n - 1 - h[str(x[i][1])]
			home += h[str(x[i][1])]
	else:
		away = n - 1
	print(home, away)


import os, sys, atexit
from io import BytesIO, StringIO
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
_OUTPUT_BUFFER = StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
n = int(input())
l = []
home = [0] * 100005
for i in range(n):
	tmp = list(map(int, input().split()))
	l.append(tmp)
	home[tmp[0]] -= -1
ans = [0] * (n + 1)
for i in range(n):
	ans[i] = n - 1 + home[l[i][1]]
	print(ans[i], 2 * (n - 1) - ans[i])


n = int(input())
arr = [0] * (10 ** 5 + 4)
lst = []
for i in range(n):
	(x, y) = map(int, input().split())
	arr[x] += 1
	lst.append(y)
for i in lst:
	print(n - 1 + arr[i], n - 1 - arr[i])


import sys
import os

def changeStdioToFile():
	path = os.path.dirname(os.path.abspath(__file__))
	sys.stdin = open(f'{path}/input.txt', 'r')
	sys.stdout = open(f'{path}/output.txt', 'w')
t = 1
for _ in range(t):
	team = int(input())
	awayKit = [0] * team
	homeKitColorCount = [0] * 100001
	for i in range(team):
		(homeKit, awayKit[i]) = [int(x) for x in input().split()]
		homeKitColorCount[homeKit] += 1
	for i in range(team):
		a = team - 1 + homeKitColorCount[awayKit[i]]
		b = team - 1 - homeKitColorCount[awayKit[i]]
		print(a, b)


g = int(input())
dic = {}
for i in range(g):
	l = []
	t = input()
	for x in t.split():
		l.append(int(x))
	dic[i] = l
kit = []
for ij in range(10 ** 5):
	kit.append(0)
for y in range(g):
	x4 = dic[y][0]
	kit[x4 - 1] += 1
kapde = []
for jk in range(g):
	h = g - 1
	m = dic[jk][1]
	h += kit[m - 1]
	kapde.append(h)
for b in kapde:
	print(b, 2 * (g - 1) - b)


from collections import Counter
from sys import stdin
_data = iter(stdin.read().split('\n'))
input = lambda : next(_data)
n = int(input())
arr = [list(map(int, input().split())) for _ in range(n)]
home = Counter()
for (h, a) in arr:
	home[h] += 1
num_match = n - 1
for (h, a) in arr:
	x = home[a]
	print(num_match + x, num_match - x)


n = int(input())
team = []
away = {}
home = {}
for i in range(n):
	t = [int(x) for x in input().split()]
	team.append(t)
	if t[0] in home:
		home[t[0]] += 1
	else:
		home[t[0]] = 1
	if t[1] in away:
		away[t[1]] += 1
	else:
		away[t[1]] = 1
ans = []
for t in team:
	if t[1] in home.keys():
		a = n - 1 - home[t[1]]
	else:
		a = n - 1
	h = 2 * (n - 1) - a
	ans.append(str(h) + ' ' + str(a))
print('\n'.join(ans))


from math import *
from sys import *
n = int(stdin.readline())
m = []
for _ in range(n):
	a = list(map(int, stdin.readline().split()))
	m.append(a)
ic = {}
oc = {}
for i in range(n):
	if m[i][0] not in ic:
		ic[m[i][0]] = 0
	ic[m[i][0]] += 1
	if m[i][1] not in oc:
		oc[m[i][1]] = 0
	oc[m[i][1]] += 1
a1 = a2 = n - 1
for i in range(n):
	x = 0
	if m[i][1] in ic:
		x = ic[m[i][1]]
	a1 += x
	a2 -= x
	print(a1, a2)
	a1 = a2 = n - 1


n = int(input())
a = []
b = [0] * 100001
for i in range(n):
	(x, y) = map(int, input().split())
	a += [y]
	b[x] += 1
print('\n'.join(('{} {}'.format(n - 1 + b[y], n - 1 - b[y]) for y in a)))


n = int(input())
x = []
y = []
for i in range(n):
	(x1, y1) = map(int, input().split())
	x.append(x1)
	y.append(y1)
aa = [0] * n
bb = [0] * n
cc = [0] * (max(max(x), max(y)) + 1)
for i in range(n):
	cc[x[i]] += 1
for i in range(n):
	aa[i] = n - 1
	aa[i] += cc[y[i]]
	bb[i] = 2 * (n - 1) - aa[i]
for i in range(n):
	print(aa[i], bb[i])


from collections import defaultdict
f = defaultdict(int)
n = int(input())
arr = []
for i in range(n):
	arr.append(list(map(int, input().split())))
	f[arr[-1][0]] += 1
m = 2 * (n - 1)
for i in range(n):
	hd = n - 1 + f[arr[i][1]]
	ad = m - hd
	print(hd, ad)


def main():
	from sys import stdin, stdout
	import collections
	n = int(stdin.readline())
	home = list((n - 1 for x in range(n)))
	away = list((n - 1 for x in range(n)))
	team = []
	homeDic = collections.Counter()
	awayDic = collections.Counter()
	for _ in range(n):
		(a, b) = map(int, stdin.readline().split())
		homeDic[a] += 1
		awayDic[b] += 1
		team.append((a, b))
	for i in range(n):
		d = homeDic[team[i][1]]
		home[i] += d
		away[i] -= d
	for i in range(n):
		stdout.write(str(home[i]) + ' ' + str(away[i]) + '\n')
main()


from collections import Counter
n = int(input())
arr = [input().split() for _ in range(n)]
home = Counter()
ans = [''] * n
for (h, a) in arr:
	home[h] += 1
num_match = n - 1
for i in range(n):
	x = home[arr[i][1]]
	ans[i] = '{} {}'.format(num_match + x, num_match - x)
print('\n'.join(ans))


from sys import stdin, stdout
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
n = ii1()
a1 = []
d = {}
for _ in range(n):
	(a, b) = iia()
	a1.append([a, b])
	d.setdefault(a, [0])[0] += 1
for i in a1:
	home = n - 1
	temp = d.get(i[1], [0])[0]
	home += temp
	away = n - 1 - temp
	print(home, away)


n = int(input())
(x, y) = ([0] * n, [0] * n)
for i in range(n):
	(x[i], y[i]) = map(int, input().split())
ans = [0] * 100001
for elm in x:
	ans[elm] += 1
for elm in y:
	print(n - 1 + ans[elm], n - 1 - ans[elm])


from sys import stdin, stdout
from collections import defaultdict
n = int(input())
l = []
h = defaultdict(int)
for i in range(n):
	(a, b) = [int(x) for x in stdin.readline().split()]
	l.append([a, b])
	h[a] += 1
for i in range(n):
	a = n - 1 + h[l[i][1]]
	b = n - 1 - h[l[i][1]]
	stdout.write(str(a) + ' ' + str(b))
	stdout.write('\n')


n = int(input())
x = list()
y = list()
home = list()
away = list()
cnt = [0] * 100001
for i in range(n):
	(xi, yi) = map(int, input().split())
	x.append(xi)
	y.append(yi)
	cnt[xi] += 1
for i in range(n):
	temp = cnt[y[i]]
	home.append(n - 1 + temp)
	away.append(n - 1 - temp)
for i in range(n):
	print(home[i], away[i])


from collections import Counter
n = int(input())
m = n - 1
hk = []
ak = []
while n:
	n -= 1
	(h, a) = map(int, input().split())
	hk.append(h)
	ak.append(a)
cnt = Counter(hk)
for i in ak:
	temp = cnt[i]
	print(m + temp, m - temp)


import sys
input = sys.stdin.readline
n = int(input())
h = {}
a = []
for i in range(n):
	(x, y) = map(int, input().split())
	if x in h:
		h[x] += 1
	else:
		h[x] = 1
	a.append(y)
for i in range(n):
	eh = 0
	if a[i] in h:
		eh = h[a[i]]
	print(n - 1 + eh, n - 1 - eh)


n = int(input())
l1 = [0] * 100000
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l1[a - 1] += 1
	l.append(b)
for i in range(n):
	b = l[i]
	k = l1[b - 1]
	print(n + k - 1, n - k - 1)


n = int(input())
h = []
a = []
aa = [n - 1] * n
hh = [n - 1] * n
d = {}
for i in range(n):
	x = input().split()
	h.append(int(x[0]))
	if int(x[0]) not in d:
		d[int(x[0])] = 1
	else:
		d[int(x[0])] += 1
	a.append(int(x[1]))
for i in range(n):
	if a[i] in d:
		aa[i] -= d[a[i]]
		hh[i] += d[a[i]]
for j in range(n):
	print(hh[j], aa[j])


num = int(input())
home = list()
away = list()
for i in range(0, num):
	ind = input().split(' ')
	home.append(int(ind[0]))
	away.append(int(ind[1]))
home_jersey = list()
away_jersey = list()
jersey_count = dict()
for i in range(0, num):
	jersey_count[away[i]] = 0
	jersey_count[home[i]] = 0
for i in range(0, num):
	jersey_count[home[i]] += 1
for i in range(0, num):
	home_jersey.append(num - 1)
	away_jersey.append(num - 1)
	away_jersey[i] -= jersey_count[away[i]]
	home_jersey[i] += jersey_count[away[i]]
for i in range(0, num):
	print(str(home_jersey[i]) + ' ' + str(away_jersey[i]))


def ret(n):
	if n in col:
		return col[n]
	else:
		return 0
n = int(input())
col = {}
t = []
for i in range(n):
	a = input().split()
	t.append([n - 1, a[1]])
	if a[0] not in col:
		col[a[0]] = 1
	else:
		col[a[0]] += 1
print('\n'.join(('%d %d' % (x[0] + ret(x[1]), n - 1 - ret(x[1])) for x in t)))


n = int(input())
home_color_teams = [[] for _ in range(10 ** 5 + 5)]
away_color_teams = [[] for _ in range(10 ** 5 + 5)]
for i in range(n):
	(xi, yi) = map(int, input().split())
	home_color_teams[xi].append(i)
	away_color_teams[yi].append(i)
home_color_count = [n - 1 for _ in range(n)]
away_color_count = [n - 1 for _ in range(n)]
for i in range(10 ** 5 + 5):
	c = len(home_color_teams[i])
	for j in range(len(away_color_teams[i])):
		home_color_count[away_color_teams[i][j]] += c
		away_color_count[away_color_teams[i][j]] -= c
for i in range(n):
	print(home_color_count[i], away_color_count[i])


from collections import Counter
n = int(input())
a = []
b = []
for i in range(n):
	(c, d) = map(int, input().split())
	a.append(c)
	b.append(d)
e = Counter(a)
for i in range(len(a)):
	f = e[b[i]]
	print(n - 1 + f, (n - 1) * 2 - (n - 1 + f))


n = int(input())
l = []
ct = [[0, 0] for _ in range(10 ** 5 + 1)]
for _ in range(n):
	(x, y) = map(int, input().split())
	l.append([x, y])
	ct[x][0] += 1
	ct[y][1] += 1
ans = [[n - 1, 0] for i in range(n)]
for i in range(n):
	ans[i][0] += ct[l[i][1]][0]
x = 2 * (n - 1)
for i in ans:
	print(i[0], x - i[0])


import sys
from collections import *
input = sys.stdin.readline
n = int(input())
tot = 2 * (n - 1)
x = []
y = []
for i in range(n):
	(u, v) = [int(x) for x in input().split()]
	x.append(u)
	y.append(v)
h = Counter(x)
for i in range(n):
	count = n - 1 + h[y[i]]
	print(count, tot - count)


n = int(input())
freq = [0] * (10 ** 5 + 1)
a = []
b = []
for i in range(n):
	(temp1, temp2) = map(int, input().split())
	a.append(temp1)
	b.append(temp2)
	freq[a[i]] += 1
m = n - 1
for i in range(n):
	print(m + freq[b[i]], m - freq[b[i]])


from collections import defaultdict
n = int(input())
C = defaultdict(int)
Y = [0] * n
for i in range(n):
	(x, y) = map(int, input().split())
	C[x] += 1
	Y[i] = y
for y in Y:
	print(n - 1 + C[y], n - 1 - C[y])


n = int(input())
(x, y) = ([0] * n, [0] * n)
cnt = [0] * 100005
(team_home, team_away) = ([0] * n, [0] * n)
for i in range(n):
	(x[i], y[i]) = map(int, input().split())
for i in range(n):
	cnt[x[i]] += 1
for i in range(n):
	team_home[i] = n - 1 + cnt[y[i]]
	team_away[i] = n - 1 - cnt[y[i]]
for i in range(n):
	print(team_home[i], team_away[i])


def mi():
	return map(int, input().split())
n = int(input())
(h, a) = ([0] * n, [0] * n)
(hc, ac) = ([0] * (10 ** 5 + 3), [0] * (10 ** 5 + 3))
for i in range(n):
	(h[i], a[i]) = mi()
	hc[h[i]] += 1
	ac[a[i]] += 1
for i in range(n):
	ha = hc[a[i]] + n - 1
	aa = 2 * n - 2 - ha
	print(ha, aa)


from sys import stdin
_data = iter(stdin.read().split('\n'))
input = lambda : next(_data)
from collections import Counter
n = int(input())
ct = Counter()
a = [tuple(map(int, input().split())) for _ in range(n)]
for (x, y) in a:
	ct[x] += 1
buf = []
for (x, y) in a:
	buf.append('{} {}'.format(n - 1 + ct[y], n - 1 - ct[y]))
print('\n'.join(buf))


n = int(input())
cnt1 = [0] * int(100000.0 + 3)
cnt2 = cnt1[:]
arr = []
for i in range(n):
	(c1, c2) = list(map(int, input().split()))
	arr.append([c1, c2])
	cnt1[c1] += 1
	cnt2[c2] += 1
res = ''
for i in range(n):
	res += str(n - 1 + cnt1[arr[i][1]]) + ' ' + str(n - 1 - cnt1[arr[i][1]]) + '\n'
print(res)


home = [0] * 100001
n = int(input())
away = [0] * n
for i in range(n):
	(x, y) = map(int, input().split())
	away[i] = y
	home[x] += 1
ans = ''
for i in range(n):
	a = away[i]
	ans1 = n - 1
	ans2 = n - 1
	ans2 -= home[a]
	ans1 += home[a]
	ans += str(ans1) + ' ' + str(ans2) + '\n'
print(ans)


import sys

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

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
n = iinput()
home = [0] * n
away = [0] * n
for i in range(n):
	(h, a) = rinput()
	home[i] = h
	away[i] = a
cnt = [0] * (10 ** 5 + 1)
for h in home:
	cnt[h] += 1
for i in range(n):
	ans_home = n - 1
	ans_home += cnt[away[i]]
	ans_way = 2 * (n - 1) - ans_home
	print(ans_home, ans_way)


from collections import Counter
n = int(input())
x = []
y = []
for i in range(n):
	(a, b) = [int(tmp) for tmp in input().split()]
	x.append(a)
	y.append(b)
cnt = Counter(x)
for i in range(n):
	t = cnt[y[i]]
	print(n - 1 + t, n - 1 - t)


n = int(input())
hisob = [0] * 100001
berun = [0] * n
for i in range(n):
	(x, b) = map(int, input().split())
	hisob[x] += 1
	berun[i] = b
ans = ''
for i in range(n):
	(cx, cb) = (n - 1, n - 1)
	b = berun[i]
	nametona = hisob[b]
	cb -= nametona
	cx += nametona
	ans += str(cx) + ' ' + str(cb) + '\n'
print(ans)


from collections import Counter
n = int(input())
(h, a) = ([0] * n, [0] * n)
for i in range(n):
	(x, y) = map(int, input().split())
	h[i] = x
	a[i] = y
home = Counter(h)
for i in range(n):
	c = home[a[i]] if a[i] in home else 0
	print(n + c - 1, n - c - 1)


def inp():
	return map(int, input().split())

def fill_arr(n):
	return [0] * n
n = int(input())
(arr1, arr2, count) = ([], [], fill_arr(10 ** 5 + 1))
for i in range(n):
	(x, y) = inp()
	arr1.append(x)
	arr2.append(y)
	count[x] += 1
for i in range(n):
	ex = n - 1 + count[arr2[i]]
	print(ex, (n - 1) * 2 - ex)


n = int(input())
colors = [[int(i) for i in input().split()] for j in range(n)]
plays = [[0, 0] for i in range(n)]
(home, away) = ([0 for i in range(10 ** 5 + 1)], [0 for i in range(10 ** 5 + 1)])
for color in colors:
	home[color[0]] += 1
	away[color[1]] += 1
for i in range(n):
	print(n - 1 + home[colors[i][1]], n - 1 - home[colors[i][1]])


n = int(input())
home = {}
away = []
for i in range(n):
	(h, a) = [int(i) for i in input().split()]
	if not h in home:
		home[h] = 0
	home[h] += 1
	away.append(a)
for a in away:
	same = 0
	if a in home:
		same = home[a]
	print(n - 1 + same, n - 1 - same)


n = int(input())
p = n - 1
a = []
b = []
d = {}
for i in range(n):
	(x, y) = map(int, input().split())
	if y not in d:
		d[y] = 0
	a.append(x)
	b.append(y)
	if x in d:
		d[x] += 1
	else:
		d[x] = 1
for i in range(n):
	print(p + d[b[i]], p - d[b[i]])


from collections import Counter
n = int(input())
arr = [None] * n
home = dict()
for i in range(n):
	(h, a) = input().split()
	arr[i] = [h, a]
	home[h] = home.get(h, 0) + 1
num_match = n - 1
for (h, a) in arr:
	x = home.get(a, 0)
	print(num_match + x, num_match - x)


n = int(input())
a = [0] * (10 ** 5 + 1)
c = []
for i in range(n):
	(x, y) = map(int, input().split())
	c.append([x, y])
	a[x] += 1
ans = n - 1
for i in range(n):
	d = ans + a[c[i][1]]
	print(d, 2 * (n - 1) - d)


import bisect
n = int(input())
l = []
m = []
for i in range(n):
	(x, y) = [int(x) for x in input().split()]
	l.append(x)
	m.append(y)
l.sort()
for i in range(n):
	x = bisect.bisect_left(l, m[i])
	y = bisect.bisect(l, m[i])
	print(n - 1 + (y - x), n - 1 - (y - x))


n = input()
n = int(n)
a = dict()
b = list()
for j in range(n):
	p = input()
	p = p.split()
	x = p[0]
	b.append(p[1])
	a[x] = a.get(x, 0) + 1
for i in b:
	k = 0
	if i in a:
		k = a[i]
	print(n - 1 + k, n - 1 - k)


R = lambda : list(map(int, input().split()))
n = int(input())
cnt1 = [0 for i in range(100005)]
cnt2 = cnt1[:]
a = []
for i in range(n):
	(c1, c2) = R()
	a.append([c1, c2])
	cnt1[c1] += 1
	cnt2[c2] += 1
for i in range(n):
	print(n - 1 + cnt1[a[i][1]], n - 1 - cnt1[a[i][1]])


n = int(input())
home = [0] * 100001
away = []
for i in range(n):
	(hom, awa) = map(int, input().split())
	home[hom] += 1
	away.append(awa)
for i in range(n):
	print(n - 1 + home[away[i]], n - 1 - home[away[i]])


n = int(input())
x = [0 for i in range(n)]
y = [0 for i in range(n)]
d = {}
for i in range(n):
	(x[i], y[i]) = map(int, input().split())
	d.setdefault(x[i], 0)
	d[x[i]] += 1
for i in range(n):
	d.setdefault(y[i], 0)
	print(d[y[i]] + n - 1, n - 1 - d[y[i]])


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
(sh, sg) = ([0] * (10 ** 5 + 1), [])
for k in range(n):
	(h, g) = map(int, input().split())
	sh[h] += 1
	sg.append(g)
for u in sg:
	print(n - 1 + sh[u], n - 1 - sh[u])


n = int(input())
arr = []
import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
homedicts = {}
awaydicts = {}
for i in range(n):
	(aa, bb) = get_ints()
	arr.append([aa, bb])
	if aa not in homedicts:
		homedicts[aa] = 1
	else:
		homedicts[aa] += 1
	if bb not in awaydicts:
		awaydicts[bb] = 1
	else:
		awaydicts[bb] += 1
ans = []
for i in range(n):
	curpair = arr[i]
	home = 0
	away = 0
	ih = curpair[0]
	ia = curpair[1]
	if ia not in homedicts:
		ans.append([n - 1, n - 1])
	else:
		home = n - 1
		away = n - 1
		homeaway = homedicts[ia]
		home += homeaway
		away -= homeaway
		ans.append([home, away])
for pair in ans:
	ii = pair[0]
	jj = pair[1]
	print(str(ii) + ' ' + str(jj))


n = int(input())
l1 = [0] * (int(100000.0) + 1)
l = []
for i in range(n):
	(x, y) = map(int, input().split())
	l1[x] += 1
	l.append(y)
for i in range(n):
	print(n - 1 + l1[l[i]], n - 1 - l1[l[i]])


n = int(input())
(u, v) = ([0] * n, [0] * 100001)
for i in range(n):
	(x, y) = map(int, input().split())
	u[i] = y
	v[x] += 1
for i in range(n):
	k = v[u[i]]
	u[i] = str(n - 1 + k) + ' ' + str(n - 1 - k)
print('\n'.join(u))


from collections import Counter
n = int(input())
d = {}
a = []
b = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append(x)
	b.append(y)
c = Counter(a)
for i in range(n):
	f = c[b[i]]
	print(n - 1 + f, n - 1 - f)


n = int(input())
nbColors = [0 for i in range(10 ** 5 + 1)]
teamAway = []
for i in range(n):
	(home, away) = map(int, input().split())
	nbColors[home] += 1
	teamAway.append(away)
for away in teamAway:
	print(n - 1 + nbColors[away], n - 1 - nbColors[away])


n = int(input())
a = []
b = []
d = {}
for i in range(n):
	(a1, b1) = map(int, input().split())
	if a1 in d:
		d[a1] = d[a1] + 1
	else:
		d[a1] = 1
	a.append(a1)
	b.append(b1)
r = []
for i in range(n):
	r1 = n - 1
	if b[i] in d:
		r1 = r1 + d[b[i]]
		r2 = n - 1 - d[b[i]]
	else:
		r2 = n - 1
	rr = []
	rr.append(r1)
	rr.append(r2)
	r.append(rr)
for i in range(n):
	print(r[i][0], r[i][1])


from collections import Counter
n = int(input())
arr = [None] * n
home = [0] * 100001
for i in range(n):
	(h, a) = map(int, input().split())
	arr[i] = [h, a]
	home[h] += 1
num_match = n - 1
for (h, a) in arr:
	x = home[a]
	print(num_match + x, num_match - x)


from sys import stdin
input = stdin.readline

def jersey(arr):
	ans = [[len(arr) - 1, len(arr) - 1] for i in range(len(arr))]
	home = [0] * (10 ** 5 + 1)
	for i in arr:
		home[i[0]] += 1
	for i in range(len(arr)):
		base = home[arr[i][1]]
		ans[i][0] += base
		ans[i][1] -= base
	for i in ans:
		print(*i)
	return ''
a = int(input())
blanck = []
for i in range(a):
	(a, b) = map(int, input().strip().split())
	blanck.append([a, b])
print(jersey(blanck))


from collections import Counter

def solve(n, arr):
	home = Counter()
	away = Counter()
	for i in range(n):
		for j in range(i + 1, n):
			home[i] += 1
			home[j] += 1
			if arr[i][0] == arr[j][1]:
				home[j] += 1
			else:
				away[j] += 1
			if arr[j][0] == arr[i][1]:
				home[i] += 1
			else:
				away[i] += 1
	for i in range(n):
		print(home[i], away[i])

def solve2(n, arr):
	home = [0] * int(100000.0 + 1)
	away = [0] * int(100000.0 + 1)
	for a in arr:
		home[a[0]] += 1
		away[a[1]] += 1
	num_match = n - 1
	for a in arr:
		print(num_match + home[a[1]], num_match - home[a[1]])
n = int(input())
arr = [list(map(int, input().split())) for _ in range(n)]
solve2(n, arr)


n = int(input())
home_kit = [0] * (100000 + 2)
kits = []
temp = n
while temp > 0:
	(h, a) = [int(x) for x in input().split()]
	kits.append([h, a])
	home_kit[h] += 1
	temp -= 1
total = 2 * (n - 1)
for i in kits:
	home = n - 1 + home_kit[i[1]]
	away = total - home
	print(home, away)


n = int(input())
h = {}
hc = []
ac = []
for i in range(n):
	(x, y) = map(int, input().split())
	try:
		h[x] += 1
	except:
		h[x] = 1
	hc.append(x)
	ac.append(y)
for i in range(n):
	try:
		h[ac[i]] += 0
	except:
		h[ac[i]] = 0
for i in range(n):
	print(n - 1 + h[ac[i]], n - 1 - h[ac[i]])