#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	const int N = 12;
	int n,i,c;
	int a[N],b[N],(*pre)[N], (*next)[N];
	for(;;)
	{
		scanf("%d",&n);
		if(!n) break;
		for(i = 0; i < n; ++i)
			scanf("%d", &a[i]);

		c = 0;
		pre = &a;
		next = &b;
		for(;;)
		{
			for(i = 0; i < n; ++i)
			{
				(*next)[i] = count(*pre, *pre+N, (*pre)[i]);
			}
			{
				bool b=true;
				for(i = 0; i < n; ++i)
					if((*pre)[i] != (*next)[i])
						b = false;
				if(b) break;
			}
			//if(equal(*pre, *pre+N, *next))
			//	break;
			swap(next, pre);
			c++;
		}
		printf("%d\n", c);
		for(i = 0; i < n; ++i)
			printf("%s%d", (i?" ":""), (*pre)[i]);
		putchar('\n');
	}
	return 0;
}