n = gets.to_i
n.times do
  time = gets.chomp
  hour = time[0,2].to_i
  minute = time[3,2].to_i
  long_hand = minute
  shor_hand = 5*hour + minute/12.0
  dif = (shor_hand-long_hand).abs
  if (15..30).include?(dif)
    puts "safe"
  elsif (0..5).include?(dif) || (50..60).include?(dif)
    puts "alert"
  else
    puts "warning"
  end
end