You are given $n$ words. Some words may repeat. For each word, output its number of occurrences. The output order should correspond with the input order of appearance of the word. See the sample input/output for clarification. 

Note: Each input line ends with a "\n" character.

Constraints: 

$1\leq n\leq10^5$ 

The sum of the lengths of all the words do not exceed $10^{6}$ 

All the words are composed of lowercase English letters only.

Input Format

The first line contains the integer, $n$. 

The next $n$ lines each contain a word. 

Output Format

Output $2$ lines. 

On the first line, output the number of distinct words from the input. 

On the second line, output the number of occurrences for each distinct word according to their appearance in the input.

Sample Input
4
bcdef
abcdefg
bcde
bcdef

Sample Output
3
2 1 1

Explanation

There are $3$ distinct words. Here, "bcdef" appears twice in the input at the first and last positions. The other words appear once each. The order of the first appearances are "bcdef", "abcdefg" and "bcde" which corresponds to the output.

Source: hackerrank | Difficulty: MEDIUM


Solutions:
Cases = int(input())
dict = {}
index = 0
orderlist = []
for i in range(0, Cases):
	current = str(input())
	curVal = dict.get(current, 0)
	if curVal == 0:
		dict.update({current: curVal + 1})
		orderlist.append(current)
	else:
		dict[current] = curVal + 1
print(len(dict))
result = ''
for i in range(0, len(orderlist)):
	result += str(dict[orderlist[i]]) + ' '
print(result.strip())


from collections import OrderedDict
n = int(input())
di = OrderedDict()
for i in range(0, n):
	line = input()
	if line not in di:
		di[line] = 1
	else:
		di[line] = di[line] + 1
print(len(di))
for x in di.values():
	print(x, end=' ')


from collections import OrderedDict
d = OrderedDict()
n = int(input())
for i in range(n):
	s = input()
	if s in d.keys():
		d[s] += 1
	else:
		d[s] = 1
print(len(d.keys()))
print(' '.join([str(d[k]) for k in d.keys()]))


N = int(input())
D = {}
words = []
for q in range(N):
	word = input()
	words.append(word)
	if word in D:
		D[word] += 1
	else:
		D[word] = 1
out = []
for word in words:
	if word in D:
		out.append(str(D[word]))
		del D[word]
print(len(out))
print(' '.join(out))


from collections import defaultdict
n = int(input())
d = defaultdict(int)
lis = []
for i in range(n):
	t = input()
	if t not in d.keys():
		lis.append(t)
		d[t] = 1
	else:
		d[t] += 1
print(len(lis))
for j in lis:
	print(d[j], end=' ')


from collections import OrderedDict
a = int(input())
c = OrderedDict()
for i in range(a):
	d = input()
	if d in c:
		c[d] = c[d] + 1
	else:
		c[d] = 1
print(len(c.keys()))
for i in c.values():
	print(i, end=' ')


from collections import Counter, OrderedDict

class OrderedCounter(Counter, OrderedDict):

	def __repr__(self):
		return '%s(%r)' % (self.__class__.__name__, OrderedDict(self))

	def __reduce__(self):
		return (self.__class__, (OrderedDict(self),))
n = int(input())
N = []
for i in range(n):
	add = input()
	N.append(add)
oc = OrderedCounter(N)
count = []
for i in oc:
	count.append(oc[i])
print(len(count))
print(str(count).replace('[', '').replace(']', '').replace(',', ''))


import collections
length = int(input())
terms = collections.OrderedDict()
for i in range(length):
	term = input()
	if term in terms:
		terms[term] += 1
	else:
		terms[term] = 1
print(len(terms))
for v in terms.values():
	print(v, end=' ')


from collections import Counter
n = int(input())
words = list((input().strip() for _ in range(n)))
count = Counter(words)
print(len(count))
ls = list()
for word in words:
	x = count.pop(word, None)
	if x != None:
		ls.append(x)
print(' '.join((str(x) for x in ls)))


from collections import OrderedDict
units = int(input())
wordDict = OrderedDict()
for i in range(units):
	word = input()
	if word in wordDict:
		wordDict[word] += 1
	else:
		wordDict[word] = 1
print(len(wordDict))
for word in wordDict:
	print(wordDict[word], end=' ')


import collections
n = int(input())
l = []
for i in range(n):
	l.append(input())
repeated_l = collections.OrderedDict(collections.Counter(l).items())
print(len(repeated_l))
s = ''
keys = repeated_l.keys()
li = []
for i in l:
	if i in keys:
		li.append(repeated_l.pop(i))
print(' '.join(map(str, li)))


from collections import defaultdict
from operator import itemgetter
n = int(input())
db = defaultdict(list)
for i in range(n):
	db[input().strip()].append(i)
result = [[key, len(val), min(val)] for (key, val) in db.items()]
print(len(result))
print(' '.join([str(entry[1]) for entry in sorted(result, key=itemgetter(2))]))


A = {}
for x in range(int(input())):
	word = input()
	if word in A:
		A[word][1] += 1
	else:
		A[word] = [x, 1]
A = [A[x] for x in A]
A = sorted(A, key=lambda x: x[0])
print(len(A))
print(' '.join([str(x[1]) for x in A]))


n = int(input())
l = []
d = {}
M = set()
for i in range(n):
	s = input().strip()
	if s in M:
		d[s] += 1
	else:
		M.add(s)
		l.append(s)
		d[s] = 1
print(len(d))
for i in range(len(l)):
	print(d[l[i]], '', end='')


import collections
n = int(input())
l = []
for i in range(0, n):
	l.append(input().strip())
print(len(set(l)))
d = collections.OrderedDict()
for i in l:
	if i in d.keys():
		d[i] += 1
	else:
		d[i] = 1
print(' '.join((str(x) for x in d.values())))


from collections import Counter, OrderedDict

class OrderedCounter(Counter, OrderedDict):

	def __repr__(self):
		return '%s(%r)' % (self.__class__.__name__, OrderedDict(self))

	def __reduce__(self):
		return (self.__class__, (OrderedDict(self),))
n = int(input().rstrip('\n'))
c = OrderedCounter([input().rstrip('\n') for i in range(0, n)])
print(len(c))
[print(c[key], end=' ') for key in c]


import sys
from collections import OrderedDict
d = OrderedDict()
n = int(sys.stdin.readline())
mydict = {}
for _ in range(0, n):
	strng = sys.stdin.readline()
	if strng in d.keys():
		d[strng] = d[strng] + 1
	else:
		d.__setitem__(strng, 1)
print(d.__len__())
print(*d.values(), sep=' ')


from collections import defaultdict
words = []
count = defaultdict(lambda : 0)
for _ in range(int(input())):
	word = input()
	if not count[word]:
		words.append(word)
	count[word] += 1
print(len(count))
print(' '.join((str(count[word]) for word in words)))


num = int(input())
words = []
dic = {}
for i in range(num):
	word = input()
	if word in dic:
		dic[word] += 1
	else:
		dic[word] = 1
		words.append(word)
print(len(words))
counts = []
for word in words:
	counts.append(dic[word])
print(' '.join(list(map(str, counts))))


import collections
N = int(input())
temp = collections.OrderedDict()
for x in range(0, N):
	strtemp = input()
	temp[strtemp] = temp.get(strtemp, 0) + 1
print(len(temp))
for (k, v) in temp.items():
	print(v, end=' ')


import collections
li = [input() for x in range(int(input()))]
ans = collections.Counter(li)
print(len(ans))
for i in li:
	if i in ans:
		print(ans[i], end=' ')
		del ans[i]


from collections import OrderedDict
dict = OrderedDict()
for i in range(0, int(input())):
	word = input()
	if word in dict:
		dict[word] += 1
	else:
		dict[word] = 1
print(len(dict))
keys = [str(dict[key]) for key in dict]
print(' '.join(keys))


from collections import defaultdict as dd
d = dd(int)
a = []
for i in range(int(input())):
	x = input()
	if not d[x]:
		a += [x]
	d[x] += 1
print(len(d))
print(' '.join(map(str, [d[i] for i in a])))


from collections import OrderedDict
d = OrderedDict()
n = int(input())
for x in range(n):
	val = input()
	if not val in d:
		d[val] = 1
	else:
		d[val] += 1
ans = [str(val) for val in list(d.values())]
print(len(ans))
print(' '.join(ans))


from collections import OrderedDict

def __starting_point():
	num = int(input().strip())
	history = OrderedDict()
	for _ in range(num):
		word = str(input().strip().split())
		if word not in list(history.keys()):
			history[word] = 1
		else:
			history[word] += 1
	print(len(list(history.keys())))
	print(' '.join(map(str, list(history.values()))))
__starting_point()


from collections import OrderedDict
n = int(input())
total = OrderedDict()
for i in range(n):
	word = input()
	if word not in total:
		total[word] = 1
	else:
		total[word] += 1
print(len(total))
for i in total.values():
	print(i, '', end='')


from collections import OrderedDict
words = OrderedDict()
n = int(input())
for i in range(0, int(n)):
	w = input().strip()
	if w in words:
		words[w] += 1
	else:
		words[w] = 1
print(len(words))
print(' '.join([str(x) for (y, x) in words.items()]))


m = int(input())
d = {}
order_ls = []
for _ in range(m):
	inp = input()
	if inp in d:
		d[inp] += 1
	else:
		order_ls.append(inp)
		d[inp] = 1
print(len(d.keys()))
freq = [str(d[word]) for word in order_ls]
print(' '.join(freq))


from collections import OrderedDict
n = int(input())
d = OrderedDict()
for ni in range(n):
	word = input().strip()
	if word not in d:
		d[word] = 1
	else:
		d[word] = d[word] + 1
print(len(d))
[print(d[__], end=' ') for __ in d]


from collections import defaultdict
n = int(input().strip())
l = list()
d = defaultdict(int)
b = defaultdict(bool)
last = defaultdict(int)
ile = 0
out = str()
for i in range(0, n):
	l.append(input().strip())
	last[l[i]] = i
	d[l[i]] = d[l[i]] + 1
	if not b[l[i]]:
		ile = ile + 1
	b[l[i]] = True
for i in range(0, n):
	b[l[i]] = False
print(ile)
for i in range(0, n):
	if not b[l[i]]:
		print(d[l[i]], end=' ')
	b[l[i]] = True
print()


from collections import OrderedDict
n = int(input())
words = [input() for _ in range(n)]
occurences = OrderedDict()
for word in words:
	if word in occurences:
		occurences[word] += 1
	else:
		occurences[word] = 1
print(len(occurences))
for (key, value) in occurences.items():
	print(value, end=' ')


from collections import OrderedDict
N = int(input())
D = OrderedDict()
for _ in range(N):
	word = input()
	if word in D:
		D[word] = D[word] + 1
	else:
		D[word] = 1
print(len(D))
for key in D:
	print(D[key], end=' ')


from collections import OrderedDict
n = int(input())
di = OrderedDict()
for i in range(0, n):
	word = input().strip()
	if not word in di:
		di[word] = 1
	else:
		di[word] += 1
print(len(di))
print(' '.join([str(di[key]) for key in di]))


from _collections import defaultdict
n = int(input())
d = defaultdict(int)
myList = []
doneSet = set()
printList = []
for i in range(n):
	myList.append(input())
for k in myList:
	d[k] += 1
for i in myList:
	if not doneSet.__contains__(i):
		doneSet.add(i)
		printList.append(d[i])
print(len(printList))
print(str(printList).strip('[]').replace(',', ''))


from collections import Counter, OrderedDict

class OrderedCounter(Counter, OrderedDict):
	pass
word_ar = []
n = int(input())
for i in range(n):
	word_ar.append(input().strip())
word_counter = OrderedCounter(word_ar)
print(len(word_counter))
for word in word_counter:
	print(word_counter[word], end=' ')


from collections import defaultdict
n = int(input())
li = []
for i in range(n):
	s = input()
	li.append(s)
d = defaultdict(list)
for i in range(len(li)):
	d[li[i]].append(i + 1)
dd = sorted(d.items(), key=lambda x: x[1][0])
print(len(dd))
for x in dd:
	print(len(x[1]), end=' ')
print('')


from collections import OrderedDict
counter = OrderedDict()
for _ in range(int(input())):
	s = input()
	if s in counter:
		counter[s] += 1
	else:
		counter[s] = 1
print(len(counter))
print(' '.join([str(v) for v in counter.values()]))


__author__ = 'Maciej'
n = int(input())
array = []
for i in range(0, n):
	array.append(input())
stringMap = dict()
for x in array:
	if x not in stringMap:
		stringMap[x] = 1
	else:
		stringMap[x] += 1
result = ''
for x in array:
	if stringMap[x] != -1:
		result += str(stringMap[x]) + ' '
		stringMap[x] = -1
print(stringMap.__len__())
print(result)


from collections import Counter
n = int(input())
c = Counter()
str = []

def f7(seq):
	seen = set()
	seen_add = seen.add
	return [x for x in seq if not (x in seen or seen_add(x))]
for i in range(0, n):
	str.append(input())
c.update(str)
print(len(c))
print(*[c[s] for s in f7(str)])


order = []
words = {}
n = int(input())
for i in range(n):
	w = input()
	if w not in words:
		order.append(w)
		words[w] = 0
	words[w] += 1
print(len(order))
for i in order:
	print(words[i], end=' ')


import collections

class OrderedCounter(collections.Counter, collections.OrderedDict):
	pass
n = int(input())
buckets = OrderedCounter()
for i in range(n):
	buckets[input()] += 1
print(len(buckets))
print(' '.join((str(count) for count in buckets.values())))


N = int(input())
d = {}
pos = []
for i in range(N):
	word = input()
	if word in d:
		d[word] += 1
	else:
		d[word] = 1
		pos.append(word)
print(len(d))
for word in pos:
	print(d[word], '', end='')


from collections import OrderedDict
from itertools import islice
num = int(input())
mapper = OrderedDict()
for i in range(num):
	line = input()
	mapper.update({line: mapper.get(line, 0) + 1})
	i += 1
print(len(mapper))
print(*mapper.values(), sep=' ')


from collections import Counter, OrderedDict

class OrderedCounter(Counter, OrderedDict):

	def __repr__(self):
		return '%s(%r)' % (self.__class__.__name__, OrderedDict(self))

	def __reduce__(self):
		return (self.__class__, (OrderedDict(self),))
counter = OrderedCounter([input().rstrip() for _ in range(int(input().rstrip()))])
print(len(counter))
for i in counter:
	print(counter[i], end=' ')


n = int(input())
words = []
counts = dict()
for _ in range(n):
	word = input().strip()
	words.append(word)
	if word in counts:
		counts[word] += 1
	else:
		counts[word] = 1
print(len(counts))
for word in words:
	if word in counts:
		print(counts[word], end=' ')
		del counts[word]
print


n = int(input())
D = dict()
for i in range(n):
	s = input()
	if s not in D:
		D[s] = [i, 1]
	else:
		D[s][1] += 1
print(len(D))
print(' '.join([str(v[1][1]) for v in sorted(D.items(), key=lambda a: a[1][0])]))


from collections import OrderedDict, Counter

class OCD(OrderedDict, Counter):
	pass
N = OCD()
for _ in range(int(input())):
	N[input()] += 1
print(len(N))
print(' '.join([str(x[1]) for x in list(N.items())]))


from collections import OrderedDict
d = OrderedDict()
N = int(input())
for n in range(N):
	word = input()
	d.setdefault(word, [])
	d[word].append(n)
print(len(d))
for (key, val) in d.items():
	print(len(val), end=' ')


from collections import OrderedDict, Counter

class OrderedCounter(Counter, OrderedDict):

	def __repr__(self):
		return '%s(%r)' % (self.__class__.__name__, OrderedDict(self))

	def __reduce__(self):
		return (self.__class__, (OrderedDict(self),))
n = int(input())
vals = OrderedCounter((input().strip() for _ in range(n))).values()
print(len(vals))
print(*vals)


from collections import Counter, OrderedDict
n = int(input())

class OrderedCounter(Counter, OrderedDict):

	def __repr__(self):
		return '%s(%r)' % (self.__class__.__name__, OrderedDict(self))

	def __reduce__(self):
		return (self.__class__, (OrderedDict(self),))
lis = []
for i in range(n):
	lis.append(input().strip('\r'))
oc = OrderedCounter(lis)
print(len(oc))
for (x, y) in oc.items():
	print(y, end=' ')


num_words = int(input())
from collections import OrderedDict
words = OrderedDict()
for i in range(num_words):
	word = input().strip()
	words[word] = words.get(word, 0) + 1
print(len(words))
print(' '.join(map(str, (counts for (word, counts) in words.items()))))


from collections import OrderedDict
N = int(input().strip())
hist = OrderedDict()
for i in range(0, N):
	word = input().strip()
	if word in hist:
		hist[word] += 1
	else:
		hist[word] = 1
print(len(hist))
print(' '.join((str(v) for (k, v) in hist.items())))


import collections
d = collections.OrderedDict()
for i in range(int(input())):
	i = input()
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
print(len(d))
print(' '.join(list((str(d[i]) for i in d))))


from collections import OrderedDict
N = int(input())
words = OrderedDict()
for i in range(N):
	new = input().strip()
	if new not in words:
		words[new] = 1
	else:
		words[new] = words.get(new, 0) + 1
print(len(words))
string = []
print(' '.join([str(words[key]) for key in words]))


n = int(input())
a = []
c = []
m = {}
for i in range(n):
	x = input().strip()
	j = m.get(x, -1)
	if j < 0:
		a.append(x)
		c.append(1)
		m[x] = len(c) - 1
	else:
		c[j] += 1
print(len(c))
print(' '.join(map(str, c)))


n = int(input())
d = {}
l = []
s = set()
for i in range(n):
	st = input()
	if st not in s:
		s.add(st)
		l.append(st)
		d[st] = 1
	else:
		d[st] += 1
print(len(s))
for i in range(len(s)):
	print(d[l[i]], end=' ')


from collections import OrderedDict
words_count = int(input())
words = OrderedDict()
for single_word in range(words_count):
	word = input()
	try:
		words[word] += 1
	except KeyError:
		words[word] = 1
print(len(words))
print(' '.join(map(str, list(words.values()))))


word_count = input()
words = []
uniq_words = {}
for i in range(int(word_count)):
	word = input()
	if word not in uniq_words:
		uniq_words[word] = 1
		words += [word]
	else:
		uniq_words[word] += 1
print(len(uniq_words))
counts = ''
for i in enumerate(words):
	words[i[0]] = uniq_words[i[1]]
print(' '.join(map(str, words)))


from collections import Counter
from collections import OrderedDict

class OrderedCounter(Counter, OrderedDict):

	def __str__(self):
		return '{}({})'.format(self.__class__.__name__, OrderedDict(self))

	def __reduce__(self):
		return (self.__class__, (OrderedDict(self),))

def get_input():
	N = int(input())
	words = []
	for i in range(N):
		words.append(input())
	return words

def count_words(words):
	c = OrderedCounter(words)
	return c
words = get_input()
counted = count_words(words)
print(len(counted.values()))
print(*counted.values())


n = int(input())
words_set = dict()
for i in range(n):
	word = input()
	if word in words_set:
		words_set[word][1] += 1
	else:
		words_set[word] = [i, 1]
l = sorted(words_set.values())
print(len(l))
for i in l:
	print(i[1], end=' ')


y = int(input())
inivo = {}
x = []
for i in range(y):
	d = input()
	if d in inivo:
		inivo[d] += 1
	else:
		inivo[d] = 1
		x.append(d)
print(len(x))
for i in x:
	print(inivo[i], end=' ')


import collections
xs = [input() for _ in range(int(input()))]
tally = collections.OrderedDict()
for x in xs:
	if x not in tally:
		tally[x] = 1
	else:
		tally[x] += 1
print(len(set(xs)))
print(*list(tally.values()))


from collections import Counter, OrderedDict
n = int(input())
words = OrderedDict()
for _ in range(n):
	if _ < n:
		in_ = input()
		try:
			words[in_] += 1
		except:
			words[in_] = 1
print(len(words))
for (word, count) in words.items():
	print(count, end=' ')


import collections
n = int(input())
L = [input() for _ in range(n)]
Occ = collections.OrderedDict()
for i in range(n):
	Occ[L[i]] = 0
for i in range(n):
	Occ[L[i]] = Occ[L[i]] + 1
print(len(Occ))
i = 0
for i in Occ:
	print(Occ[i], end=' ')


from collections import OrderedDict as od
d = od()
for i in range(int(input())):
	a = input()
	try:
		d[a] += 1
	except:
		d[a] = 1
A = []
print(len(d))
for i in d:
	A.append(str(d[i]))
print(' '.join(A))


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


import sys
message = sys.stdin.readlines()
message.pop(0)
distinct = 0
d = dict()
uniq_list = []
for s in message:
	s = s.rstrip()
	if s in d:
		d[s] += 1
	else:
		d[s] = 1
		distinct += 1
		uniq_list.append(s)
print(distinct)
print(' '.join([str(d[k]) for k in uniq_list]))


from collections import defaultdict
n = int(input())
d = defaultdict(int)
lis = []
for i in range(n):
	word = input()
	if d[word] == 0:
		lis.append(word)
	d[word] += 1
result = [str(d[x]) for x in lis]
s = ' '.join(result)
print(len(lis))
print(s)


from collections import OrderedDict
words = OrderedDict()
n = int(input())
for i in range(n):
	word = input()
	if word in words:
		words[word] += 1
	else:
		words[word] = 1
print(len(words))
print(' '.join(map(str, [words[word] for word in words])))


N = int(input())
d = {}
w = []
for x in range(N):
	s = input().strip()
	if s in d:
		d[s] += 1
	else:
		d[s] = 1
		w.append(s)
print(len(d))
print(' '.join(map(lambda x: str(d[x]), w)))


from collections import OrderedDict, defaultdict
a = int(input())
words = []
for i in range(a):
	word = input().strip()
	words.append(word)
d = OrderedDict()
for word in words:
	if not d.get(word):
		d[word] = 1
	else:
		d[word] += 1
print(len(d))
for value in d.values():
	print(value, end=' ')


st = set()
arr = []
dic = {}
n = int(input())
for i in range(0, n):
	p = input()
	if p in st:
		dic[p] += 1
	else:
		st.add(p)
		arr.append(p)
		dic[p] = 1
print(len(st))
p = ''
for i in arr:
	p += str(dic[i]) + ' '
print(p[:-1])


d = {}
o = []
n = int(input())
for _ in range(n):
	s = input()
	try:
		d[s] = d[s] + 1
	except:
		d[s] = 1
		o.append(s)
print(len(o))
for x in o:
	print(d[x], end=' ')
print()


import collections
n = int(input())
dic = collections.OrderedDict()
for k in range(0, n):
	word = input()
	if word in dic:
		dic[word] += 1
	else:
		dic[word] = 1
lis = list(dic.values())
print(len(dic))
for k in lis:
	print(k, end=' ')


n = int(input())
d = {}
pos = []
for i in range(0, n):
	word = input()
	if word in d:
		d[word] += 1
	else:
		d[word] = 1
		pos.append(word)
print(len(pos))
for word in pos:
	print(d[word], '', end='')


n = int(input())
count = {}
for i in range(n):
	w = input()
	if w in count:
		count[w][1] += 1
	else:
		count[w] = [i, 1]
print(len(count))
print(' '.join((str(count[x][1]) for x in sorted(count, key=lambda x: count[x][0]))))


n = input()
occurrence = {}
occurrence_seq = []
for i in range(int(n)):
	xinput = input()
	if xinput not in occurrence.keys():
		occurrence[xinput] = 1
		occurrence_seq.append(xinput)
	else:
		occurrence[xinput] += 1
print(len(occurrence.keys()))
print(' '.join([str(occurrence[j]) for j in occurrence_seq]))


from collections import *
n = int(input().strip())
word_list = []
for itr in range(n):
	in_word = input().strip()
	word_list.append(in_word)
word_count = Counter(word_list)
word_list = list(OrderedDict.fromkeys(word_list))
print(len(word_count))
for word in word_list:
	print(word_count[word], end=' ')


n = int(input())
l = {}
k = []
length = 0
for x in range(n):
	i = input()
	if i in l:
		k[l[i]] += 1
	else:
		l[i] = length
		k.append(1)
		length += 1
print(length)
for i in k:
	print(i, end=' ')


from collections import OrderedDict
d = OrderedDict()
length = int(input())
for n in range(length):
	word = input()
	if word in d:
		d[word] += 1
	else:
		d[word] = 1
print(len(d))
print(' '.join([str(v) for (k, v) in d.items()]))


import sys
readStd = []
count = 0
for line in sys.stdin:
	if count > 0:
		readStd.append(line)
	count += 1
word_order = {}
duplicates = {}
count_order = 0
for w in readStd:
	w.rstrip()
	if w in duplicates.keys():
		duplicates[w] += 1
	else:
		duplicates[w] = 1
		word_order[count_order] = w
		count_order += 1
print(count_order)
for o in sorted(word_order):
	print(duplicates[word_order[o]], end=' ')


from collections import OrderedDict
occ = OrderedDict()
n = int(input())
for i in range(n):
	word = input()
	if word in occ:
		occ[word] += 1
	else:
		occ[word] = 1
counts = []
for word in occ:
	counts.append(str(occ[word]))
print(len(counts))
print(' '.join(counts))


from collections import OrderedDict
d = OrderedDict()
for _ in range(int(input())):
	s = input()
	d[s] = d.get(s, 0) + 1
print(len(d))
print(' '.join(map(str, d.values())))


word_dict = {}
seen = []
n = int(input())
for i in range(0, n):
	word = input()
	if word in word_dict:
		word_dict[word] += 1
	else:
		word_dict[word] = 1
		seen.append(word)
print(len(word_dict))
res = ''
for word_index in range(0, len(seen) - 1):
	res = res + str(word_dict[seen[word_index]]) + ' '
res = res + str(word_dict[seen[-1]])
print(res)


import sys, collections
n = sys.stdin.readline().strip()
try:
	n = int(n)
except:
	sys.exit(1)
stable_dict = collections.OrderedDict()
for i in range(0, n):
	entry = sys.stdin.readline().strip()
	if entry not in stable_dict:
		stable_dict[entry] = 1
	else:
		stable_dict[entry] += 1
print(len(stable_dict))
for item in stable_dict:
	print('{} '.format(stable_dict[item]), end='')


from collections import OrderedDict
d = OrderedDict()
num_words = int(input())
for i in range(num_words):
	word = input()
	if word in d:
		d[word] += 1
	else:
		d[word] = 1
print(len(d))
for (k, v) in d.items():
	print(v, end=' ')


from collections import OrderedDict
d = OrderedDict()
n = int(input())
for i in range(0, n):
	word = input()
	if word in d.keys():
		d[word] += 1
	else:
		d[word] = 1
print(len(d))
print(' '.join(map(str, d.values())))


n = int(input())
words = {}
for i in range(n):
	word = input()
	if word in words:
		words[word][1] += 1
	else:
		words[word] = [len(words), 1]
print(len(words))
words_sorted = sorted(words.items(), key=lambda i: i[1][0])
print(' '.join([str(w[1][1]) for w in words_sorted]))


from collections import OrderedDict
n = int(input())
mapper = OrderedDict()
count = 0
while count < n:
	line = input()
	mapper.update({line: mapper.get(line, 0) + 1})
	count += 1
print(len(mapper))
print(*mapper.values(), sep=' ')


from collections import OrderedDict
ws = OrderedDict()
for _ in range(int(input())):
	w = input()
	try:
		ws[w] += 1
	except:
		ws[w] = 1
print(len(ws))
for v in ws.values():
	print(v, end=' ')
print('')


x = int(input())
words = {}
k = []
for _ in range(x):
	i = input()
	if i in words.keys():
		words[i] += 1
	else:
		words[i] = 1
		k.append(i)
print(len(words))
for i in k:
	print(words[i], end=' ')


import collections
n = int(input())
cnt = collections.Counter()
trueCnt = []
lst = []
for i in range(n):
	lst.append(str(input()).rstrip())
	cnt[lst[i]] += 1
counted = {}
for item in cnt:
	counted[item] = False
for j in range(n):
	if not counted[lst[j]]:
		trueCnt.append(str(cnt[lst[j]]))
		counted[lst[j]] = True
print(len(cnt))
print(' '.join(trueCnt))


import collections
buffer = collections.OrderedDict()
for i in range(int(input())):
	line = input()
	if line not in buffer:
		buffer[line] = 1
	else:
		buffer[line] += 1
print(len(buffer.keys()))
for i in buffer.items():
	print(i[1], end=' ')


count = int(input())
order = []
words = {}
for i in range(0, count):
	word = input()
	if word in words:
		words[word] += 1
	else:
		order.append(word)
		words[word] = 1
print(len(words))
for word in order:
	print(words[word], end=' ')


no = int(input())
d = {}
inpSet = []
valSet = []
for i in range(0, no):
	s = input()
	if s not in d:
		inpSet.append(s)
		d[s] = 1
	else:
		d[s] += 1
print(len(inpSet))
for i in inpSet:
	print(d[i], end=' ')
print()


words = int(input())
inorder = []
hashed = {}
for w in range(words):
	word = input().strip()
	if word in hashed:
		hashed[word] += 1
	else:
		hashed[word] = 1
		inorder.append(word)
output = []
for word in inorder:
	output.append(str(hashed[word]))
print(len(inorder))
print(' '.join(output))


from collections import OrderedDict

def nb_distincts(words):
	return len(set(words))

def count_in_order(words):
	ordered_dict = OrderedDict()
	for word in words:
		count = ordered_dict.get(word, 0)
		ordered_dict[word] = count + 1
	return ordered_dict

def main():
	number_words = int(input())
	words = [input() for _ in range(number_words)]
	print(nb_distincts(words))
	counts = count_in_order(words)
	print(' '.join((str(count) for count in counts.values())))
main()


def get_row(f=int):
	return [f(s.strip()) for s in input().split(' ')]
N = get_row()[0]
data = {}
for i in range(0, N):
	word = get_row(str)[0]
	if word not in data:
		data[word] = [i, 1]
	else:
		data[word][1] += 1
print(len(data.keys()))
print(' '.join([str(p[1]) for p in sorted(data.values())]))


from collections import OrderedDict
d = OrderedDict()
n = int(input().strip())
for i in range(n):
	word = input().strip()
	if word not in d:
		d[word] = 1
	else:
		d[word] += 1
print(len(d))
for k in d:
	print(d[k], end=' ')