n,*a=$<.map(&:to_i) i=c=0 eval'(m-=1).times{|y|e,f=a[y,2] e>f&&(c+=1;a[y,2]=f,e) puts %w(compare swap data:)*" =%3d "%[i+=1,c]+"%3d"*n%a} '*m=n