T=gets.to_i T.times do |i| a,b,c=gets.split.map(&:to_i) if [a,b,c].max<=2 || (a==1 && a==b) || (b==1 && b==c) || (c==1 && c==a) puts -1 next end a,c=c,a if c=3 puts 3 else puts -1 end elsif a