Title: Frequency of Occurrence Operation

There is an operation called "frequency of occurrence operation" for transforming a finite sequence. The result of the transformation is a sequence of the same length. If the sequence S = {s1, s2,... sn}, the resulting sequence C = {c1, c2, ..., cn} represents the frequency of occurrence of each element in S, where ci denotes the count of si in S.

For example, if S = {3, 4, 1, 5, 9, 2, 6, 5, 3}, then C = {2, 1, 1, 2, 1, 1, 1, 2, 2}. Performing the frequency of occurrence operation on C yields P = {4, 5, 5, 4, 5, 5, 5, 4, 4}. This resulting sequence P remains unchanged after the frequency of occurrence operation, and it is referred to as a fixed point of S. It is known that for any sequence, repeating the frequency of occurrence operation will lead to finding its fixed point.

The input consists of multiple datasets. Each dataset is in the following format:
n
s1 s2 ... sn

Where the first line contains an integer n (n ≤ 12) representing the length of the sequence, and the second line contains n integers si (1 ≤ si ≤ 100) representing the elements of sequence S.

The output should include, for each dataset, the minimum number of times the frequency of occurrence operation was executed (an integer) on the first line, and the elements of the corresponding fixed point sequence P (p1, p2, ..., pn) separated by spaces on the second line.

The input ends with a single line containing 0. The number of datasets does not exceed 200.

Sample Input:
10
4 5 1 1 4 5 12 3 5 4
0

Output for the Sample Input:
3
6 6 4 4 6 6 4 4 6 6

# Buggy version:
while True:
	n = int(input())
	if n == 0:
	    break
	s = []
	u = 0
	v = 0
	s = list(input().split())
	while True:
		t = []
		for i in range(n):
			for j in range(n):
				if s[i] == s[j]:
					u += 1
			t.append(u)
			t_str = list(map(str, t))
			u = 0
		if s == t_str:
			print(str(v))
			print(" ".join(t_str))
			break
		else:
			s = t
			v += 1

# Fixed version:
while True:
	n = int(input())
	if n == 0:
	    break
	s = []
	u = 0
	v = 0
	s = list(map(int, input().split()))
	while True:
		t = []
		for i in range(n):
			for j in range(n):
				if s[i] == s[j]:
					u += 1
			t.append(u)
			t_str = list(map(str, t))
			u = 0
		if s == t:
			print(str(v))
			print(" ".join(t_str))
			break
		else:
			s = t
			v += 1

# Buggy version:
def FOA(a, count):
	b = a
	for i in range(len(b)):
		b[i] = a.count(a[i])
	if  b == a:
		print(count)
		print(" ".join(map(str, b)))
		break
	else:
		return FOA(b, count + 1)

while True:
	n = int(input())
	if n == 0:
		break
	a = map(int, input().split())
	FOA(a, 0)

# Fixed version:
def FOA(a, count):
	b = [a.count(a[i]) for i in range(len(a))]
	if  b == a:
		print(count)
		print(" ".join(map(str, b)))
	else:
		return FOA(b, count+1)

while True:
	n = int(input())
	if n == 0:
		break
	a = list(map(int, input().split()))
	FOA(a, 0)

# Buggy version:
import sys
a=sys.stdin
while 1:
 if'0'==a.readline():break
 s=list(map(int,a.readline().split()))
 c=0
 while 1:
  t=s;s=[t.count(e)for e in t]
  if t==s:break
  c+=1
 print(c);print(*s)


# Fixed version:
import sys
a=sys.stdin
while 1:
 if'0\n'==a.readline():break
 s=list(map(int,a.readline().split()))
 c=0
 while 1:
  t=s;s=[t.count(e)for e in t]
  if t==s:break
  c+=1
 print(c);print(*s)