#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	
	int n, loop, count;
	
	bool same;
	
	int a[20], b[20];
	
	cin >> n;
	
	while(n != 0){
		
		for(int i = 0; i < n; i++){
			cin >> a[i];
		}
		
		for(loop = 0; loop < 20; loop++){
			if(loop % 2 == 0){
				for(int i = 0; i < n; i++){
					count = 0;
					for(int j = 0; j < n; j++){
						if(a[i] == a[j]){
							count++;
						}
					}
					b[i] = count;
				}
			}else{
				for(int i = 0; i < n; i++){
					count = 0;
					for(int j = 0; j < n; j++){
						if(b[i] == b[j]){
							count++;
						}
					}
					a[i] = count;
				}
			}
			
			same = true;
			
			for(int i = 0; i < n; i++){
				if(a[i] != b[i]){
					same = false;
					break;
				}
			}
			if(same){
				break;
			}
		}
		
		printf("%d\n", loop);
		printf("%d", a[0]);
		
		for(int i = 1; i < n; i++){
			printf(" %d", a[i]);
		}
		
		printf("\n");
		
		cin >> n;
	}
	
	return 0;
}