gets.to_i.times do a, b, c = gets.split.map(&:to_i) result = if b <= 2 -1 elsif a == b && b == c 3 elsif a == b || b == c 1 else 0 end puts result end