while eval(input())!=0:

  a=list(map(int,input().split()))

  c=0

  while 1:

    b=[a.count(e) for e in a]

    if a==b: break

    else: a=b; c+=1

  print(c)

  for e in a: print(e, end=' ')

  print()
while eval(input())!=0:

  a=list(map(int,input().split()))

  c=0

  while 1:

    b=[a.count(e) for e in a]

    if a==b: break

    else: a=b; c+=1

  print(c)

  print(" ".join(map(str,a)))
while eval(input()) != 0:
    a = list(map(int, input().split()))
    c = 0
    while 1:
        b = [a.count(e) for e in a]
        if a == b:
            break
        else:
            a = b
            c += 1
    print(c)
    for e in a:
        print(e, end=" ")
    print()

while eval(input()) != 0:
    a = list(map(int, input().split()))
    c = 0
    while 1:
        b = [a.count(e) for e in a]
        if a == b:
            break
        else:
            a = b
            c += 1
    print(c)
    print(" ".join(map(str, a)))

-    for e in a: -        print(e, end=" ") -    print() +    print(" ".join(map(str, a)))