N=gets.hex t={} $<.map{|s|eval"t[0d%d%d]=%d"%s.split} p (R=*0...N).permutation.map{|a|R.product(R).map{|i,j|i