The Rebel fleet is on the run. It consists of m ships currently gathered around a single planet. Just a few seconds ago, the vastly more powerful Empire fleet has appeared in the same solar system, and the Rebels will need to escape into hyperspace. In order to spread the fleet, the captain of each ship has independently come up with the coordinate to which that ship will jump. In the obsolete navigation system used by the Rebels, this coordinate is given as the value of an arithmetic expression of the form $\frac{a + b}{c}$.

To plan the future of the resistance movement, Princess Heidi needs to know, for each ship, how many ships are going to end up at the same coordinate after the jump. You are her only hope!


-----Input-----

The first line of the input contains a single integer m (1 ≤ m ≤ 200 000) – the number of ships. The next m lines describe one jump coordinate each, given as an arithmetic expression. An expression has the form (a+b)/c. Namely, it consists of: an opening parenthesis (, a positive integer a of up to two decimal digits, a plus sign +, a positive integer b of up to two decimal digits, a closing parenthesis ), a slash /, and a positive integer c of up to two decimal digits.


-----Output-----

Print a single line consisting of m space-separated integers. The i-th integer should be equal to the number of ships whose coordinate is equal to that of the i-th ship (including the i-th ship itself).


-----Example-----
Input
4
(99+98)/97
(26+4)/10
(12+33)/15
(5+1)/7

Output
1 2 2 1 


-----Note-----

In the sample testcase, the second and the third ship will both end up at the coordinate 3.

Note that this problem has only two versions – easy and hard.

Source: codeforces | Difficulty: MEDIUM
Tags: Mathematics


Solutions:
m = int(input())
positions = []
poscount = {}
for i in range(m):
	crew = list(input())
	n = len(crew)
	i = 1
	a = ''
	while crew[i] != '+':
		a += crew[i]
		i += 1
	b = ''
	i += 1
	while crew[i] != ')':
		b += crew[i]
		i += 1
	c = ''
	i += 2
	while i < n:
		c += crew[i]
		i += 1
	a = int(a)
	b = int(b)
	c = int(c)
	res = (a + b) / c
	positions.append(res)
	if res in poscount:
		poscount[res] += 1
	else:
		poscount[res] = 1
ans = []
for i in range(m):
	ans.append(poscount[positions[i]])
print(*ans, sep=' ')


m = int(input())
ans = []
for i in range(m):
	s = list(input())
	s.remove('(')
	s.remove(')')
	a = ''
	k = -1
	for i in range(len(s)):
		if s[i] != '+':
			a += s[i]
		else:
			k = i
			break
	b = ''
	l = 0
	for i in range(k + 1, len(s)):
		if s[i] != '/':
			b += s[i]
		else:
			l = i
			break
	c = ''
	for i in range(l + 1, len(s)):
		c += s[i]
	a = int(a)
	b = int(b)
	c = int(c)
	ans.append((a + b) / c)
b = list(set(ans))
dic = {}
for i in range(len(b)):
	dic[b[i]] = 0
for i in range(len(ans)):
	dic[ans[i]] += 1
for i in range(len(ans)):
	print(dic[ans[i]], end=' ')


d = {}
l = []
for _ in range(int(input())):
	n = input()
	s = n.split('+')
	s1 = s[0].split('(')
	s2 = s[1].split(')/')
	a = int(s1[1])
	b = int(s2[0])
	c = int(s2[1])
	k = (a + b) / c
	l.append(k)
	if k in d.keys():
		d[k] += 1
	else:
		d[k] = 1
for i in range(len(l)):
	print(d[l[i]], end=' ')


from fractions import gcd
ans = []
dic = {}
n = int(input())
for i in range(n):
	word = input()
	word = word.replace('(', ',')
	word = word.replace('+', ',')
	word = word.replace(')/', ',')
	w = word.split(',')
	a = int(w[1])
	b = int(w[2])
	numerator = a + b
	denumerator = int(w[3])
	x = numerator // gcd(numerator, denumerator)
	y = denumerator // gcd(numerator, denumerator)
	ans.append((x, y))
	if (x, y) in dic:
		dic[x, y] += 1
	else:
		dic[x, y] = 1
for i in range(n):
	if i > 0:
		print(' ', end='')
	print(dic[ans[i]], end='')
print('\n', end='')


m = int(input())
d = {}
ans = []
for _ in range(m):
	s = input().split('/')
	s[0] = s[0].replace('(', '')
	s[0] = s[0].replace(')', '')
	(a, b) = s[0].split('+')
	c = int(s[-1])
	a = int(a)
	b = int(b)
	ans.append([a, b, c])
	x = '{0:.4f}'.format((a + b) / c)
	d[x] = d.get(x, 0) + 1
for (a, b, c) in ans:
	x = '{0:.4f}'.format((a + b) / c)
	print(d[x], end=' ')


n = int(input())
lst = []
d = dict()
for temp in range(n):
	(input_str, z) = input().split('/')
	(x, y) = input_str.split('+')
	x = x[1:]
	y = y[:len(y) - 1]
	x = int(x)
	y = int(y)
	z = int(z)
	ans = (x + y) / z
	if ans in d.keys():
		d[ans] += 1
	else:
		d[ans] = 1
	lst.append(ans)
for i in lst:
	print(d[i], end=' ')


n = int(input())
ct = {}
ctx = []
for ni in range(0, n):
	st = input().strip()[1:]
	p1 = st.index('+')
	a = int(st[:p1])
	st = st[p1 + 1:]
	p2 = st.index(')')
	b = int(st[:p2])
	c = int(st[p2 + 2:])
	v = (a + b) / c
	if v in ct:
		ct[v] += 1
	else:
		ct[v] = 1
	ctx.append(v)
st = []
for cti in ctx:
	st.append(str(ct[cti]))
print(' '.join(st))


x = int(input())
a = []
b = dict()
for i in range(x):
	s = input()
	a.append(eval(s))
	if a[i] not in b:
		b[a[i]] = 1
	else:
		b[a[i]] += 1
for i in range(x):
	print('%d ' % b[a[i]], end='')
print()


from fractions import Fraction as f
from sys import stdin, stdout
m = int(input())
d = dict()
v = []
for i in range(m):
	s = stdin.readline()
	for c in ['(', ')', '+', '/']:
		s = s.replace(c, ' ')
	a = [int(i) for i in s.split()]
	fr = f(a[0] + a[1], a[2])
	if fr not in d.keys():
		d[fr] = 0
	d[fr] += 1
	v.append(fr)
for i in v:
	stdout.write(str(d[i]) + ' ')


n = int(input())
d = {}
for i in range(n):
	s = input()
	s = s.replace('(', '')
	s = s.replace(')', '')
	s = s.split('/')
	c = float(s[-1])
	s = s[0]
	s = s.split('+')
	a = float(s[0])
	b = float(s[1])
	ans = (a + b) / c
	if ans in d:
		d[ans].append(i)
	else:
		d[ans] = [i]
l = [0] * n
for k in list(d.keys()):
	for i in d[k]:
		l[i] = str(len(d[k]))
print(' '.join(l))


n = int(input())
d = {}
aaa = []
for ii in range(n):
	s = input().strip()
	arr = list(s)
	for i in range(len(arr)):
		if arr[i] is '(' or arr[i] is '+' or arr[i] is ')' or (arr[i] is '/'):
			if arr[i] is '/':
				arr[i] = ''
			else:
				arr[i] = ' '
	(a, b, c) = map(int, ''.join(arr).split())
	ans = (a + b) / c
	if ans in d.keys():
		d[ans][0] += 1
		d[ans][1].append(ii)
	else:
		d[ans] = [1, [ii]]
	aaa.append(ans)
arr1 = {}
for i in d.keys():
	for j in d[i][1]:
		arr1[j] = d[i][0]
for i in range(n):
	print(arr1[i], end=' ')
print('')


def solve(s):
	for i in range(len(s)):
		if s[i] == '+':
			break
	a = s[1:i]
	for j in range(i + 1, len(s)):
		if s[j] == ')':
			break
	b = s[i + 1:j]
	c = s[j + 2:]
	return (int(a) + int(b)) / int(c)
m = int(input())
a = []
for i in range(m):
	s = input()
	a.append(solve(s))
b = list(set(a))
dic = {}
for i in range(len(b)):
	dic[b[i]] = 0
for i in range(len(a)):
	dic[a[i]] += 1
for i in range(len(a)):
	print(dic[a[i]], end=' ')


n = int(input())
a = []
M = dict()
for i in range(n):
	a.append(eval(input()))
	M[a[-1]] = M.get(a[-1], 0) + 1
for i in range(n):
	print(M[a[i]], end=' ')


m = int(input())
l = []
dict1 = {}
for i in range(m):
	k = input().split('/')
	k[0] = k[0][1:len(k[0]) - 1]
	k[0] = k[0].split('+')
	val = (int(k[0][0]) + int(k[0][1])) / int(k[1])
	if val in dict1:
		dict1[val] += 1
	else:
		dict1[val] = 1
	l.append(val)
for i in l:
	print(dict1[i], end=' ')


def fun(str):
	list = str.split('/')
	dem = int(list[1])
	list = list[0]
	list = list[1:-1]
	list1 = list.split('+')
	num = int(list1[0]) + int(list1[1])
	return num / dem
dict = {}
list = []
n = int(input())
while n != 0:
	n = n - 1
	str = input()
	ans = fun(str)
	if ans in dict:
		dict[ans] = dict[ans] + 1
	else:
		dict[ans] = 1
	list.append(ans)
for i in range(len(list)):
	print(dict[list[i]], end=' ')


from collections import defaultdict
m = int(input())
value = {}
count = defaultdict(int)
for i in range(m):
	s = input()
	ans = 0
	z = ''
	n = len(s)
	for j in range(1, n):
		if s[j] == '+':
			ans = int(z)
			z = ''
			continue
		elif s[j] == ')':
			ans += int(z)
			z = ''
			j += 2
			while j < n:
				z += s[j]
				j += 1
			ans = ans / int(z)
			count[ans] += 1
			value[i] = ans
		else:
			z = z + s[j]
for i in range(m):
	print(count[value[i]], end=' ')
print()


a = int(input())
dict = {}
k = []
for i in range(a):
	l = eval(input())
	k.append(l)
	if l not in dict:
		dict[l] = 1
	else:
		dict[l] += 1
for i in range(a):
	print(dict[k[i]], end=' ')


table = {}
cur = 1

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

def read():
	nonlocal cur
	nonlocal table
	s = input().split('/')
	nom = eval(s[0])
	den = int(s[1])
	g = gcd(nom, den)
	nom //= g
	den //= g
	h_code = nom * 1000 + den
	if h_code in table:
		table[h_code].append(cur)
	else:
		table[h_code] = [cur]
	cur += 1
m = int(input())
for i in range(m):
	read()
ans = [0] * 213456
for (key, val) in table.items():
	for idx in val:
		ans[idx] = len(val)
for i in range(1, m + 1):
	print(ans[i], end=' ')


from __future__ import division, print_function

def main():
	from collections import defaultdict
	dct = defaultdict(int)
	n = int(input())
	lst = [0] * n
	for i in range(n):
		t = input().strip()
		(a, b, c) = map(int, (t[1:t.index('+')], t[t.index('+') + 1:t.index(')')], t[t.index('/') + 1:]))
		x = (a + b) / c
		lst[i] = x
		dct[x] += 1
	for i in lst:
		print(dct[i], end=' ')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


import re
n = int(input())
A = []
B = []
freq = {}
myDict1 = {}
for i in range(n):
	A.append(0)
for i in range(10 ** 6):
	B.append(0)
for i in range(n):
	a = input()
	a = a.split('(')
	a = a[1].split('+')
	b = a[0]
	c = a[1].split(')')
	d = c[0]
	e = c[1].split('/')[1]
	ans = (int(b) + int(d)) / int(e)
	if ans in freq:
		freq[ans] += 1
	else:
		freq[ans] = 1
	myDict1[i] = ans
for (key, value) in myDict1.items():
	print(freq[value], end=' ')


m = int(input())

def findCoor(S):
	(f, s, t) = (False, False, False)
	(a, b, c) = ('', '', '')
	for i in S:
		if i == '(':
			f = True
		elif i == '+':
			s = True
		elif i == ')' or i == '/':
			t = True
		elif t:
			c += i
		elif s:
			b += i
		elif f:
			a += i
	return float((int(a) + int(b)) / int(c))
dic = {}
value = []
for i in range(m):
	s = str(input())
	n = findCoor(s)
	value.append(n)
	if n not in dic:
		dic[n] = 1
	else:
		dic[findCoor(s)] += 1
for i in value:
	print(dic[i], end=' ')


import re
num = int(input())
des = []
map = {}
for i in range(num):
	(z, a, b, w, c) = re.split('[`\\-=~!@#$%^&*()_+\\[\\]{};\\\'\\\\:"|<,./<>?]', input().strip())
	value = (int(a) + int(b)) / int(c)
	des.append(value)
	map[value] = map.get(value, 0) + 1
output = []
for i in des:
	output.append(str(map[i]))
print(' '.join(output))


from collections import defaultdict
from sys import stdin
input = stdin.readline
dct = defaultdict(int)
n = int(input())
lst = [0] * n
for i in range(n):
	t = input().strip()
	(a, b, c) = map(int, (t[1:t.index('+')], t[t.index('+') + 1:t.index(')')], t[t.index('/') + 1:]))
	x = (a + b) / c
	lst[i] = x
	dct[x] += 1
for i in lst:
	print(dct[i], end=' ')


from collections import defaultdict
d = defaultdict(lambda : 0)
a = []
for _ in range(int(input())):
	s = input()
	a.append(s)
	d[eval(s)] += 1
for e in a:
	print(d[eval(e)], end=' ')


import io, os
input = io.StringIO(os.read(0, os.fstat(0).st_size).decode()).readline
ii = lambda : int(input())
kk = lambda : map(int, input().split())
ll = lambda : list(kk())

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a * b // gcd(a, b)
d = {}
n = ii()
ls = [None] * n
for _ in range(n):
	state = 0
	s = input()[1:]
	(a, s) = s.split('+')
	(b, c) = s.split(')/')
	(a, b, c) = (int(a), int(b), int(c))
	u = a + b
	lc = gcd(u, c)
	t = (u // lc, c // lc)
	if t not in d:
		d[t] = 0
	d[t] += 1
	ls[_] = t
print(*[d[l] for l in ls])


n = int(input())
cl = []
dic = {}
res = [0] * n
for i in range(n):
	x = eval(input())
	if x not in dic.keys():
		dic.update({x: []})
		dic[x].append(i)
	else:
		dic[x].append(i)
for x in dic.values():
	k = len(x)
	for y in x:
		res[y] = k
result = ''
for x in res:
	result += str(x) + ' '
print(result)


def main():
	n = int(input())
	if n == 0:
		print('')
		return
	store = {}
	res = []
	for i in range(n):
		x = eval(input())
		if x in store:
			store[x] += 1
		else:
			store[x] = 1
		res.append(x)
	for i in range(n):
		res[i] = str(store[res[i]])
	print(' '.join(res))
main()


m = int(input())
lt = []
for _ in range(m):
	s = input().split('/')
	(a, b, c) = (s[0].split('+')[0][1:], s[0].split('+')[1][:-1], s[-1])
	(a, b, c) = (int(a), int(b), int(c))
	lt.append((a + b) / c)
dt = {}
for i in range(m):
	if lt[i] not in dt:
		dt[lt[i]] = 1
	else:
		dt[lt[i]] += 1
for i in range(m):
	lt[i] = dt[lt[i]]
print(*lt)


from collections import Counter
N = int(input())
List = []
for i in range(N):
	S = input()
	slash = S.split('/')
	c = int(slash[1])
	plus = slash[0].split('+')
	a = int(plus[0][1:])
	b = int(plus[1][:-1])
	x = (a + b) / c
	List.append(x)
Dict = Counter(List)
Ans = []
for i in List:
	Ans.append(Dict[i])
print(*Ans)


from fractions import Fraction
n = int(input())
arr = []
cc = {}
for i in range(n):
	line = input()
	(ab, c) = line.split('/')
	ab = ab[1:-1]
	(a, b) = ab.split('+')
	(a, b, c) = [int(x) for x in (a, b, c)]
	p = (a + b) / c
	arr.append(p)
	if p not in cc:
		cc[p] = 1
	else:
		cc[p] += 1
for i in range(n):
	if i > 0:
		print(' ', end='')
	print(cc[arr[i]], end='')


from collections import Counter
from sys import stdin
input = stdin.readline

def gcd(x, y):
	return gcd(y, x % y) if x % y else y
n = int(input())
arr = []
for _ in range(n):
	x = list(input())
	fn = ''
	sn = ''
	i = 1
	while x[i] != '+':
		fn += x[i]
		i += 1
	i += 1
	while x[i] != ')':
		sn += x[i]
		i += 1
	top = int(fn) + int(sn)
	btm = int(''.join(x[i + 2:]))
	d = gcd(top, btm)
	top //= d
	btm //= d
	arr.append((top, btm))
dct = Counter(arr)
print(*map(lambda o: dct[o], arr))


from math import gcd
import sys
input = sys.stdin.readline
from collections import defaultdict as dd
m = int(input())
d = dd(int)
l = []
for i in range(m):
	s = input().split()[0]
	a = 0
	b = 0
	c = 0
	n = len(s)
	ind = 0
	for i in range(1, n):
		if s[i] == '+':
			ind = i + 1
			break
		a = a * 10 + int(s[i])
	for i in range(ind, n):
		if s[i] == ')':
			ind1 = i + 2
			break
		b = b * 10 + int(s[i])
	for i in range(ind1, n):
		c = c * 10 + int(s[i])
	a = a + b
	g = gcd(a, c)
	a = a // g
	c = c // g
	d[a, c] += 1
	l.append((a, c))
for i in l:
	print(d[i], end=' ')


def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
n = int(input())
inp = []
keys = []
d = {}
for i in range(n):
	s = str(input())
	inp.append(s)
	num1 = ''
	num2 = ''
	num3 = ''
	ind1 = 0
	for i in range(1, len(s)):
		if s[i] == '+':
			ind1 = i + 1
			break
		else:
			num1 += s[i]
	for i in range(ind1, len(s)):
		if s[i] == ')':
			ind1 = i + 2
			break
		else:
			num2 += s[i]
	for i in range(ind1, len(s)):
		num3 += s[i]
	num1 = int(num1)
	num2 = int(num2)
	num3 = int(num3)
	numerator = num1 + num2
	denominator = num3
	val = gcd(numerator, denominator)
	numerator = numerator // val
	denominator = denominator // val
	imp = (numerator, denominator)
	if imp not in d:
		d[imp] = 0
	d[imp] += 1
	keys.append(imp)
ans = []
for i in range(n):
	ans.append(d[keys[i]])
print(*ans)


import re
math = re.compile('\\((\\d+)\\+(\\d+)\\)\\/(\\d+)')
d1 = dict()
d2 = dict()

def main():
	n = int(input())
	for i in range(n):
		string = input()
		match = math.match(string)
		a = int(match.group(1))
		b = int(match.group(2))
		c = int(match.group(3))
		d2[i + 1] = (a + b) / c
		try:
			d1[(a + b) / c] += 1
		except:
			d1[(a + b) / c] = 1
	lis = []
	for i in range(n):
		lis.append(str(d1[d2[i + 1]]))
	print(' '.join(lis))

def __starting_point():
	main()
__starting_point()


from collections import Counter

def getList(l, m):
	r = []
	cnt = Counter(l)
	for i in l:
		r.extend([cnt[i]])
	return r
m = int(input())
res = []
for i in range(m):
	(a, b) = [i for i in input().split('/')]
	a = a.split('+')
	a = [a[0].replace('(', ''), a[len(a) - 1].replace(')', '')]
	a = list(map(lambda x: int(x), a))
	b = float(b)
	res.extend([sum(a) / b])
output = getList(res, m) + ['\n']
for i in output:
	print(str(i) + ' ', end='')


import re
n = int(input())
cnt = {}
p = []
for i in range(n):
	s = input().split('/')
	c = int(s[1])
	a = int(s[0].split('+')[0][1:])
	b = int(s[0].split('+')[1][:-1])
	p.append(hash((a + b) / c))
	if hash((a + b) / c) not in cnt:
		cnt[hash((a + b) / c)] = 1
	else:
		cnt[hash((a + b) / c)] += 1
for i in p:
	print(cnt[i], end=' ')


def val(s):
	ans = (int(s.split('+')[0][1:]) + int(s.split('+')[1].split(')')[0])) / int(s.split('/')[1])
	return ans
n = int(input())
s = []
f = {}
for i in range(n):
	ss = input()
	s.append(val(ss))
	if s[i] not in f:
		f[s[i]] = 1
	else:
		f[s[i]] += 1
for i in range(len(s)):
	print(f[s[i]], end=' ')
print()


d = {}
l = []
for i in range(int(input())):
	(a, b, c) = map(int, input().replace('(', '').replace(')/', ' ').replace('+', ' ').split())
	ans = (a + b) / c
	l.append(ans)
	if ans in d:
		d[ans] += 1
	else:
		d[ans] = 1
for i in l:
	print(d[i], end=' ')


f = input
(D, E) = ({}, [eval(f()) for _ in range(int(f()))])
for e in E:
	D[e] = D.get(e, 0) + 1
for e in E:
	print(D[e])


from fractions import Fraction
n = int(input())
coords = [None] * n
count = {}
for i in range(n):
	(num, denum) = input().split('/')
	num = sum(map(int, num[1:-1].split('+')))
	denum = int(denum)
	f = Fraction(num, denum)
	coords[i] = f
	count.setdefault(f, 0)
	count[f] += 1
for coord in coords:
	print(count[coord], end=' ')


x = int(input())
cnt = {}
queue = {}
a = set([])
for i in range(x):
	each = eval(input())
	if (each in a) == False:
		cnt[each] = 0
	cnt[each] += 1
	queue[i] = each
	a.add(each)
for i in range(x):
	print(cnt[queue[i]], end=' ')


n = int(input())
ccnt = {}
sn = {}
for i in range(1, n + 1):
	s = input()
	res = eval(s)
	res = str(format(res, '.6f'))
	if res in ccnt:
		ccnt[res] += 1
	else:
		ccnt[res] = 1
	sn[i] = res
for i in range(1, n + 1):
	print(str(ccnt[sn[i]]) + ' ', end='')
print()


t = int(input())
d = {}
ans = []
for t1 in range(0, t):
	s = input()
	l = list(s)
	i = 1
	a = ''
	b = ''
	while l[i] != '+':
		a = a + l[i]
		i += 1
	i += 1
	a = int(a)
	while l[i] != ')':
		b = b + l[i]
		i += 1
	b = int(b)
	i = i + 2
	c = ''
	while i < len(l):
		c = c + l[i]
		i += 1
	c = int(c)
	x = (a + b) / c
	ans.append(x)
	if x not in d:
		d[x] = 0
	d[x] += 1
for i in ans:
	print(d[i], end=' ')
print()


while True:
	try:
		mp = dict()
		a = list()
		n = int(input())
		for i in range(n):
			s = input()
			num = eval(s)
			a.append(num)
			if num in mp:
				mp[num] = mp[num] + 1
			else:
				mp[num] = 1
		for i in a:
			print(mp[i], end=' ')
		print()
	except EOFError:
		break


import re
from collections import defaultdict
P = re.compile('\\((\\d+)\\+(\\d+)\\)/(\\d+)')
m = int(input())
s = defaultdict(int)
xs = []
for _ in range(m):
	(a, b, c) = list(map(int, P.match(input()).groups()))
	x = (a + b) / c
	s[x] += 1
	xs.append(x)
print(' '.join((str(s[x]) for x in xs)))


n = int(input())
id = [0] * n
dict = {}
for i in range(n):
	s = input()
	id[i] = eval(s)
	if id[i] not in dict:
		dict[id[i]] = 1
	else:
		dict[id[i]] += 1
for i in range(n):
	print(dict[id[i]], end=' ')


n = int(input())
dict1 = {}
dict2 = {}
for i in range(n):
	s = input()
	s = s.split('/')
	c = int(s[1])
	s = s[0].strip('(').strip(')').split('+')
	a = int(s[0])
	b = int(s[1])
	ans = (a + b) / c
	try:
		dict2[ans] += 1
	except:
		dict2[ans] = 1
	dict1[i] = ans
for i in range(n):
	print(dict2[dict1[i]], end=' ')


d = {}
k = []
for i in range(int(input())):
	a = input()
	b = a.split('(')[1].split(')/')[0].split('+')
	c = a.split('(')[1].split(')/')[1].split(')')
	r = (int(b[0]) + int(b[1])) / int(c[0])
	k.append(r)
	d[r] = d.get(r, 0) + 1
for i in range(len(k)):
	print(d[k[i]], end=' ')


from sys import stdin, stdout
n = int(stdin.readline())
lines = stdin.readlines()
m = {}
l = []
for line in lines:
	e = eval(line)
	if e not in m:
		m[e] = 1
	else:
		m[e] += 1
	l.append(e)
res = []
for v in l:
	s = str(m[v])
	res.append(s)
stdout.write(' '.join(res))


TN = 1

def solution():
	m = int(input())
	l = []
	d = {}
	for i in range(m):
		x = str(eval(input()))
		l.append(x)
		if x not in d:
			d[x] = 1
		else:
			d[x] += 1
	for i in l:
		print(d[i], end=' ')
	print()
while TN != 0:
	solution()
	TN -= 1


n = int(input())
a = [0] * n
for i in range(n):
	s = input()
	(x, y) = s.split('+')
	x = float(x[1:])
	(u, v) = y.split('/')
	v = float(v)
	u = float(u[:-1])
	a[i] = (x + u) / v
k = {}
for i in range(n):
	if a[i] not in k:
		k[a[i]] = 0
	k[a[i]] += 1
o = [0] * n
for i in range(n):
	o[i] = str(k[a[i]])
print(' '.join(o))


m = int(input())
esc = [eval(input()) for i in range(m)]
d = {i: 0 for i in esc}
for i in esc:
	d[i] += 1
for i in esc:
	print(d[i], end=' ')


m = int(input())
inputs = []
coords = {}
for i in range(0, m):
	n = eval(input())
	inputs.append(n)
	if n in coords:
		coords[n] += 1
	else:
		coords[n] = 1
output = ''
for i in range(0, len(inputs)):
	output += str(coords[inputs[i]]) + ' '
print(output)


n = int(input())
l = []
dic = {}
while n > 0:
	s = input()
	coord = eval(s)
	l.append(coord)
	dic[coord] = dic.get(coord, 0) + 1
	n -= 1
new_list = [dic[coord] for coord in l]
print(*new_list, sep=' ')


n = int(input())
a = [0] * n
d = {}
for i in range(n):
	tmp = eval(input())
	a[i] = tmp
	d[tmp] = d.get(tmp, 0) + 1
for i in a:
	print(d.get(i, 0), end=' ')


_ = int(input())
x = []
for __ in range(_):
	s = input()
	a = s.split('/')
	c = int(a[1])
	a = a[0]
	a = a.split(')')
	a = a[0]
	a = a.split('+')
	b = int(a[1])
	a = a[0]
	a = a.split('(')
	a = int(a[1])
	x.append((a + b) / c)
d = {}
for i in x:
	d[i] = 0
for i in x:
	d[i] += 1
for i in x:
	print(d[i], end=' ')


arr = []
d = {}
for _ in range(int(input())):
	s = input()
	(a, b, c) = tuple(map(int, s.replace('(', '').replace(')', '').replace('/', '.').replace('+', '.').split('.')))
	x = (a + b) / c
	arr.append(x)
	if x not in d:
		d[x] = 0
	d[x] += 1
for i in arr:
	print(d[i], end=' ')


from collections import Counter
m = int(input())
coord = []
for i in range(m):
	exp = input()
	n1 = int(exp[1:exp.index('+')])
	n2 = int(exp[exp.index('+') + 1:exp.index(')')])
	n3 = int(exp[exp.index('/') + 1:])
	coord.append((n1 + n2) / n3)
cnt = Counter(coord)
for i in range(m):
	print(cnt[coord[i]], end=' ')


from collections import Counter
from math import gcd
m = int(input())
ans = list()
for i in range(m):
	s = input()
	a = int(s[1:s.index('+')])
	b = int(s[s.index('+') + 1:s.index(')')])
	c = int(s[s.index('/') + 1:])
	d = a + b
	g = gcd(c, d)
	ans.append(tuple([d // g, c // g]))
C = Counter(ans)
print(' '.join(map(str, [C[el] for el in ans])))


from collections import Counter
N = int(input())
src = [eval(input()) for i in range(N)]
ctr = Counter(src)
ans = [ctr[a] for a in src]
print(*ans)


m = int(input())
es = [eval(input()) for i in range(m)]
d = {e: 0 for e in es}
for e in es:
	d[e] += 1
for e in es:
	print(d[e], end=' ')


n = int(input())
d = {}
c = {}
for j in range(n):
	s = input()
	st = ''
	sums = 0
	for i in range(len(s)):
		if s[i] == '(' or s[i] == ')':
			continue
		if s[i] == '+' or s[i] == '/':
			sums += int(st)
			st = ''
			continue
		st += s[i]
		if i == len(s) - 1:
			a = sums / int(st)
			d[j] = a
			if a in c:
				c[a] += 1
			else:
				c[a] = 1
for i in range(n):
	print(c[d[i]], end=' ')


import collections

def compute_coorinate(data):
	return eval(data)
m = int(input())
coordinates = []
for i in range(m):
	coordinates.append(compute_coorinate(input()))
numbers = collections.Counter(coordinates)
print(' '.join((str(numbers[x]) for x in coordinates)))


import re
n = int(input())
ships = {}
lst = []
r = re.compile('\\((\\d+)\\+(\\d+)\\)\\/(\\d+)')
for i in range(n):
	line = input()
	m = r.match(line)
	coord = (int(m.group(1)) + int(m.group(2))) / int(m.group(3))
	ships[coord] = ships.get(coord, 0) + 1
	lst.append(coord)
for k in lst:
	print(ships[k])
	pass


n = int(input())
dicti = {}
L = []
for i in range(n):
	s = input()
	a = ''
	b = ''
	c = ''
	i = 1
	while s[i] != '+':
		a += s[i]
		i = i + 1
	i = i + 1
	while s[i] != ')':
		b += s[i]
		i = i + 1
	c = s[i + 2:]
	(a, b, c) = (int(a), int(b), int(c))
	res = (a + b) / c
	if res in dicti:
		dicti[res] += 1
	else:
		dicti[res] = 1
	L.append(res)
for i in range(len(L)):
	print(dicti[L[i]], end=' ')


m = int(input())
ans = []
f = {}
for _ in range(m):
	n = input()
	a = n.split('(')
	b = a[1].split(')')
	(ad, bd) = b[0].split('+')
	cd = b[1].split('/')[1]
	ans.append((int(ad) + int(bd)) / int(cd))
	f[_] = (int(ad) + int(bd)) / int(cd)
freq = {}
for item in ans:
	if item in freq:
		freq[item] += 1
	else:
		freq[item] = 1
for i in range(m):
	print(freq[f[i]], end=' ')


import re
m = int(input())
lis = list()
for i in range(m):
	s = input()
	lis += [re.split('\\W+', s)]
d = dict()
for i in range(m):
	ans = int(lis[i][1]) + int(lis[i][2])
	ans = ans / int(lis[i][3])
	lis[i][0] = ans
	if ans in d:
		d[ans] += 1
	else:
		d[ans] = 1
for i in range(m):
	print(d[lis[i][0]], end=' ')


from math import gcd
n = int(input())
d = dict()
qs = []
for i in range(n):
	s = input()
	a = int(s[1:s.index('+')])
	b = int(s[s.index('+') + 1:s.index(')')])
	c = int(s[s.index(')') + 2:])
	a = a + b
	gc = gcd(a, c)
	res = (a // gc, c // gc)
	qs.append(res)
	if res in d:
		d[res] += 1
	else:
		d[res] = 1
for q in qs:
	print(d[q], end=' ')


from collections import defaultdict
import sys
lines = sys.stdin.readlines()
m = int(lines[0])
vals = [eval(l) for l in lines[1:]]
d = defaultdict(lambda : 0)
for val in vals:
	d[val] += 1
print(' '.join([str(d[val]) for val in vals]))


n = int(input())
l = []
d = {}
for i in range(n):
	ch = input()
	c = eval(ch)
	l.append(c)
	if c in d:
		d[c] += 1
	else:
		d[c] = 1
for i in range(n):
	print(d[l[i]], end=' ')


n = int(input())
a = [0] * n
res = dict()
for i in range(n):
	a[i] = eval(input())
	res[a[i]] = 0
for i in range(n):
	res[a[i]] += 1
for i in a:
	print(res[i], end=' ')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

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

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

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

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	m = int(inp())
	d = {}
	arr = [0] * m
	for i in range(0, m):
		s = list(inp())
		plus = s.index('+')
		a = s[1:plus]
		b = s[plus + 1:s.index(')')]
		c = s[s.index('/') + 1:]
		a = ''.join(a)
		b = ''.join(b)
		c = ''.join(c)
		co = (int(a) + int(b)) / int(c)
		if d.get(co) == None:
			d[co] = [i]
		else:
			d[co].append(i)
		arr[i] = co
	ans = []
	for i in range(m):
		ans.append(len(d[arr[i]]))
	print(' '.join((str(ans[i]) for i in range(len(ans)))))
testcase(1)


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
n = int(input())
cnt = [0 for i in range(20000)]
v = [0 for i in range(n)]
for i in range(n):
	(num, den) = input().split('/')
	num = eval(num)
	den = eval(den)
	g = gcd(num, den)
	num //= g
	den //= g
	key = num * 100 + den
	v[i] = key
	cnt[key] += 1
for i in range(n):
	print(cnt[v[i]], end=' ')
print()


m = int(input())
pos = dict()
arr = list()
for i in range(m):
	p = eval(input())
	arr.append(p)
	if p in pos:
		pos[p] += 1
	else:
		pos[p] = 1
for i in arr:
	print(pos[i])