Title: Short and Long Hands of a Clock

The "Akaruida" primitive slow life organization has received a warning letter about a prank. Akaruida is known for pranks such as throwing pies at important people's faces, but recently, they have escalated to using explosives to scatter mouse fireworks at reception venues. The warning letter reads as follows:

--- Stealing human time from computers. Not good.
When the short and long hands of a clock meet, Akaruida will perform justice.
Slow life is great.

Though it's somewhat unclear, it seems to mean that the prank will be carried out when the short and long hands of a clock overlap.

To guard against this prank, create a program that takes the time as input and outputs "alert" if the short and long hands are close, "safe" if they are far, and "warning" for any other case. "Close" refers to an angle between the short and long hands of 0° to less than 30°, and "far" refers to an angle between 90° and 180°. The time will be between 00:00 and 11:59, inclusive.

Input:
The input is given in the following format:
n
hh1:mm1
hh2:mm2
...
hhn:mmn

The first line contains the number of times to be evaluated, n (1 ≤ n ≤ 10000), and the subsequent lines contain the time hh:mm for each i-th time.

Output:
Output the judgment result "safe", "warning", or "alert" for each i-th time on separate lines.

Sample Input:
4
02:15
06:01
11:55
10:40

Output for the Sample Input:
alert
safe
alert
warning

# Buggy version:
def solve(h,m):
    dm = m / 60.0 * 360.0
    dh = h / 12.0 * 360.0 + 360.0/ 12.0 * m / 60.0
    print(dh, dm)
    if 0 <= abs(dh-dm) < 30.0:
        return("alert")
    elif 90.0 <= abs(dh-dm) < 180.0:
        return("safe")
    else:
        return("warning")

n = int(input().strip())
for i in range(n):
    v = list(map(int, input().strip().split(':')))
    print(solve(v[0],v[1])) 

# Fixed version:
def solve(h,m):
    dh = h / 12.0 * 360.0 + 360.0/ 12.0 * m / 60.0
    dm = m / 60.0 * 360.0
    x = abs(dh-dm)
    if x > 180:
        x = 360 - x
    if 0 <= x < 30.0:
        return("alert")
    elif 90.0 <= x <= 180.0:
        return("safe")
    else:
        return("warning")

n = int(input().strip())
for i in range(n):
    v = list(map(int, input().strip().split(':')))
    print(solve(v[0],v[1]))

# Buggy version:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0135
WA
"""
import sys
from sys import stdin
from math import sqrt, acos, cos, sin, radians, degrees
input = stdin.readline


def solve(time):
    # 12????????????90???
    short_hand_angle = time[1] * -6 + 90
    x_s = cos(radians(short_hand_angle))
    y_s = sin(radians(short_hand_angle))

    long_hand_angle = (time[0]*60+time[1])/(12*60) * -360 + 90
    x_l = cos(radians(long_hand_angle))
    y_l = sin(radians(long_hand_angle))
    c = (x_s * x_l + y_s * y_l) / (sqrt(x_s**2 + y_s**2) * sqrt(x_l**2 + y_l**2))
    ans = degrees(acos(c))

    if ans < 30:
        return 'alert'
    elif ans >= 90:
        return 'safe'
    else:
        return 'warning'


def main(args):
    # n = int(input())
    n = 1
    for _ in range(n):
        time = [int(x) for x in input().split(':')]
        result = solve(time)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

# Fixed version:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0135
WA
"""
import sys
from sys import stdin
from math import sqrt, acos, cos, sin, radians, degrees
input = stdin.readline


def solve(time):
    # 12????????????90???
    short_hand_angle = time[1] * -6 + 90
    x_s = cos(radians(short_hand_angle))
    y_s = sin(radians(short_hand_angle))

    long_hand_angle = (time[0]*60+time[1])/(12*60) * -360 + 90
    x_l = cos(radians(long_hand_angle))
    y_l = sin(radians(long_hand_angle))
    c = (x_s * x_l + y_s * y_l) / (sqrt(x_s**2 + y_s**2) * sqrt(x_l**2 + y_l**2))
    ans = degrees(acos(c))

    if ans < 30:
        return 'alert'
    elif ans >= 90:
        return 'safe'
    else:
        return 'warning'


def main(args):
    n = int(input())
    # n = 1
    for _ in range(n):
        time = [int(x) for x in input().split(':')]
        result = solve(time)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

# Buggy version:
for _ in range(int(input())):
    hour, minute = [int(item) for item in input().split(":")]
    angle1 = hour * 5 * 6
    angle2 = minute * 6

    subtract = abs(angle1 - angle2)

    if subtract < 30:
        print("alert")
    elif 90 <= subtract:
        print("safe")
    else:
        print("warning")



# Fixed version:
for _ in range(int(input())):
    hour, minute = [int(item) for item in input().split(":")]
    angle1 = hour * 5 * 6 + minute * 0.5
    angle2 = minute * 6

    subtract = min(abs(angle1 - angle2), 360 - abs(angle1 - angle2))

    if subtract < 30.0:
        print("alert")
    elif 90.0 <= subtract:
        print("safe")
    else:
        print("warning")