q[661];b;s;main(d){for(;~scanf("%d",&d);)if(getchar(q[d]=1)%4)for(s/=3;q[b]?q[b]=!printf("%s%d",&s,b),s=32:0,b=(b+66)%661;);}