#include <algorithm>
#include <string>
#include <iostream>
using namespace std;


bool mani(int a[12], int n)
{
	int b[12];
	fill(b, b + 12, 0);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (a[i] == a[j])
				b[i]++;
	bool f = true;
	for (int i = 0; i < n; i++)
	{
		if (a[i] != b[i])
		{
			f = false;
			break;
		}
	}
	for (int i = 0; i < n; i++)
		a[i] = b[i];
	return f;
}


int main()
{
	int n, a[12];
	cin >> n;
	while (true)
	{
		int c = 0;
		int it = 0;
		while (cin >> a[it])
		{
			it++;
			if (it == n)
				break;
		}
		if (it < n) break;
		while (true)
		{
			if (mani(a, n))
				break;
			c++;
		}
		cout << c << endl;
		cout << a[0];
		for (int i = 1; i < n; i++)
			cout << " " << a[i];
		cout << endl;
	}
	return 0;
}