
def angle(h, m)
  v = (360.0 *
   ((h.to_f/12.0) + (m.to_f/(12.0 * 60.0)) -
    m.to_f/60.0)).abs
  v > 180.0 ? v - 180.0 : v
end

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

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