Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		input := strings.Split(scanner.Text(), ":")
		h, _ := strconv.Atoi(input[0])
		m, _ := strconv.Atoi(input[1])
		H, M := (30*h+(m/2))*2, (6*m)*2
		if m&1 == 1 {
			H++
		}
		a := H - M
		if a < 0 {
			a = -a
		}
		a2 := 720 - a
		if a2 < a {
			a = a2
		}
		if a < 60 {
			fmt.Println("alert")
		} else if a >= 180 && a <= 360 {
			fmt.Println("safe")
		} else {
			fmt.Println("warning")
		}
	}
}

Python: 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), abs(360 - angle1 - angle2))

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

Python: import math

N = int(input())

for l in range(N):
    s = input()
    hh = int(s[0:2])
    mm = int(s[3:5])

    deg2 = 6 * mm
    deg1 = 30 * hh + deg2 / 12

    #print(deg1, deg2)
    d = abs(deg1-deg2)
    if d < 30 or 330 < d:
        print("alert")
    elif 90 <= d and d <= 270:
        print("safe")
    else:
        print("warning")

Python: 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")

Python: n = int(input())

for _ in range(n):
    hh, mm = map(int, input().split(":"))
    short = mm / 60 * 360
    long = hh * 30 + (mm / 60 * 30)
    judge = min(abs(short - long), 360 - abs(short - long))

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

Python: # -*- 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:])

Python: n = int(input())
for i in range(n):
    m,s = map(int,input().split(":"))
    m_kak = 30 * m + 0.5 * s
    s_kak = 6 * s
    if m_kak - 30 < s_kak < m_kak + 30:
        print("alert")
    elif m_kak - 90 < s_kak < m_kak + 90:
        print("warning")
    else:
        print("safe")

Python: for _ in [0]*int(input()):
    h,m=map(int,input().split(":"))
    s=l=.0
    l=m*6
    s=30*(h+(m/60))
    if l<s:l,s=s,l
    if l-s>180:d=360-l+s
    else:d=l-s
    if d<30: print('alert')
    elif d<90: print('warning')
    else: print('safe')

Python: 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]))

Python: n=int(input())
t=[[int(num)for num in input().split(':')]for i in range(n)]
for i in range(n):
    h=t[i][0]
    m=t[i][1]
    an_s=h*30+m/120
    an_l=m*6
    dif=0
    if abs(an_s-an_l)<180:dif=abs(an_s-an_l)
    else:dif=360-abs(an_s-an_l)
    if dif<30:
        print("alert")
    elif dif<90:
        print("warning")
    else:
        print("safe")

Python: num = int(input())

for _ in range(num):
    h, m = [int(x) for x in input().split(":")]
    
    #angle in 12 * 60 = 720 in 1/2 degree
    ha = h * 60 + m
    ma = m * 12
    da = abs(ha-ma)/2
    if da > 180:
        da = 360 - da
    
    if da >= 90:
        print("safe")
    elif da >= 30:
        print("warning")
    else:
        print("alert")

Python: 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), abs(360 + angle1 - angle2))

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

Python: n = int(input())
for i in range(n):
    m,s = map(int,input().split(":"))
    m_kak = 30 * m + 0.5 * s
    s_kak = 6 * s
    if m_kak - 30 < s_kak < m_kak + 30:
        print("alert")
    elif m_kak - 90 < s_kak < m_kak + 90:
        print("warnimg")
    else:
        print("safe")

Python: import math
n = int(input())
for i in range(n):
    m,s = map(int,input().split(":"))
    m_kak = 30 * m + 0.5 * s
    s_kak = 6 * s
    kak = min(math.fabs(m_kak - s_kak), 360 - math.fabs(m_kak - s_kak) )
    if kak < 30:
        print("alert")
    elif kak < 90:
        print("warning")
    else:
        print("safe")

Python: import math

N = int(input())

for l in range(N):
    s = input()
    hh = int(s[0:2])
    mm = int(s[3:5])

    deg2 = 6 * mm
    deg1 = 30 * hh + deg2 / 60

    #print(deg1,deg2)

    d = abs(deg1-deg2)
    if d < 30:
        print("alert")
    elif d >= 90:
        print("safe")
    else:
        print("warning")

Python: n = int(input())
for i in range(n):
    a, b = map(int, input().split(":"))
    a = a + (b/60)
    b = b / 5
    a = abs(a - b)
    if a > 6:
        a = 12 - a
    if a < 1:
        print("alert")
    elif 3 <= a <= 6:
        print("safe")
    else:
        print("warning")

Python: 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]))

Python: import math

N = int(input())

for l in range(N):
    s = input()
    hh = int(s[0:2])
    mm = int(s[3:5])

    deg2 = 6 * mm
    deg1 = 30 * hh + deg2 / 60

    #print(deg1, deg2)
    d = abs(deg1-deg2)
    if d < 30 or 330 < d:
        print("alert")
    elif (30 <= d and d < 90) or (270 < d and d <= 330):
        print("warning")
    else:
        print("safe")

Python: # AOJ 0135 Clock Short Hand and Long Hand
# Python3 2018.6.18 bal4u

for _ in range(int(input())):
	h, m = list(map(int, input().split(':')))
	H, M = (30*h+(m//2))*2, (6*m)*2
	if (m & 1) == 1: H += 1
	a = H-M
	if a < 0: a = -a
	a2 = 720-a
	if a2 < a: a = a2
	if a < 60: print("alert")
	elif a >= 180 and a <= 360: print("safe")
	else: print("warning")

Python: n=int(input())
while n:
    h,m=map(int,input().split(":"))
    s=l=.0
    l=m*6.0
    s=30.0*(h+(m/60.0))
    if l<s:l,s=s,l
    if l-s>180.0:d=360-l+s
    else:d=l-s
    if d<30: print("alert")
    elif d<90: print("warning")
    else: print("safe")
    n-=1