n,*d=$<.map &:to_i c=s=_=0 d.map{(n-_+=1).times{|i|s+=1if(p=d[i,2])!=d[i,2]=p.sort puts'compare =%3d swap =%3d data:'%[c+=1,s]+'%3s'*n%d}}