a=[0,1,1,2,1,0,1,0,0,1] gets.chars{|x|a[x=x.to_i]=-~a[x]%3} puts"#{a.index 1} #{a.index 2}"