(1..gets.to_i).each { gets.chomp.split(":").each_slice(2).map { |a, b| puts (b == "00" or a == b or a == b.reverse or %w(0123 1024 1234 2048 2345).include?(a + b) and a < '24' and b < '60') ? "YES" : "NO" } }