#include <iostream>
using namespace std;

int countArrayElm(int *ary,int n,int key){
	int cnt=0;
	for(int i=0;i<n;++i){
		if(ary[i] == key)cnt++;
	}
	return cnt;
}



int main() {
	
	
	int n;
	int *s,*c;
	int count;
	
	
	while(cin>>n,n){
		s = new int[n];
		c = new int[n];
		count = 0;
		
		for(int i=0;i<10;++i){
			cin >> s[i];
			c[i] = 0;
		}
		
		while( 1 ){
			for(int i=0;i<n;++i){
				c[i] = countArrayElm(s,n,s[i]);
			}
			
			if([s,c,n](){ for(int i=0;i<n;++i){if(s[i]!=c[i])return 0;}return 1;}())break;
			
			for(int i=0;i<n;++i){
				s[i] = c[i];
			}
			
			count++;
		}
		
		cout << count << endl;
		for(int i=0;i<n;++i){
			
			cout << (i?" ":"") << c[i];
		}
		cout << endl;
	}
	return 0;
}