problem-3-6

Hardutta is planning an inter college football league. He has invited n teams, including our own team from BPHC. Now, one of the organizers Ramehta was hell bent on knowing one thing : How many matches will all the teams play in their home kit and how many matches will they play in their away kit? A little backstory on Ramehta, he is an Arsenal fan and pretty much annoys the hell out of everybody with his facebook commenting. So Hardutta wants your help to stop Ramehta from annoying him by providing the answer. 

The kit for home games of the i-th team has color xi and the kit for away games of this team has color yi (xi ≤ yi). In the tournament, each team plays exactly one home game and exactly one away game with each other team. 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.

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 xi, yi (1 ≤ xi,yi ≤ 10^5; xi and yi are not equal) — the color numbers for the home and away kits of the i-th team.
Output
For each team, print on a line the number of games this team is going to play in home and away kits, correspondingly, separated by spaces. Print the answers for the teams in the order they appeared in the input.

SAMPLE INPUT
2
1 2
2 1

SAMPLE OUTPUT
2 0
2 0

Explanation

Since the second teams away kit clashes with the first teams home kit and vice- versa, both the teams always wear home kits.

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
T = int(input())
l=[]
h=[]
a=[]
n=T
while T>0:
	l.append(tuple(input().split()))
	T=T-1
for i in l:
	h.append(int(i[0]))
	a.append(int(i[1]))

for i in range(len(l)):
	home=n-1
	away=n-1	
	temp=h.count(a[i])
	home = home+temp
	away = away-temp
	print(str(home)+' '+str(away))


A = []
B = [0 for i in range(100001)]
n = eval(input())
for i in range(n):
	x, y = list(map(int, input().split()))
	A.append(y)
	B[x] += 1
for x in A:
	a, b = n - 1, n - 1
	a += B[x]
	b -= B[x]
	print(a, b)


class team(object):
	def __init__(self,n,h,a):
		self.n=n
		self.h=h
		self.a=a
arr=[]
n=int(input())
ans=[]
for i in range(n):
	inp=input()
	temp=[int(j) for j in inp.split()]
	arr.append(team(i+1,temp[0],temp[1]))
for i in range(len(arr)):
	obj=arr[i]
	p,q=n-1,0
	for j in range(len(arr)):
		rep=arr[j]
		if rep.n==obj.n:
			continue
		if obj.a==rep.h:
			p+=1
		else:
			q+=1
	ans.append([p,q])
for x in ans:
	print(str(x[0])+" "+str(x[1]))