
def angle(h, m)
  v = (30 * h + m/2.0 - 6 * m).abs
  v > 180 ? v - 180 : v
end

def to_msg(angle)
  if angle < 30
    "alert"
  elsif angle >= 90
    "safe"
  else
    "warning"
  end
end

gets.to_i.times do
  h, m = gets.split(":").map(&:to_i)
  puts to_msg(angle(h, m))
end