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")
		}
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second

main(){
  int n;
  cin>>n;
  while(n--){
    long double hh,mm;
    scanf("%Lf:%Lf",&hh,&mm);
    hh=30*hh+360.0/12*mm/60;
    mm*=6;
    //cout<<hh<<":"<<mm<<endl;
    int diff=abs(hh-mm);
    if(diff>180)diff=360-diff;

    if(diff<=30)puts("alert");
    else if(diff>=90)puts("safe");
    else puts("warning");
  }
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int a,b,n;
	char c;
	cin >> n;
	for (;n>0;n--) {
	scanf("%d%c%d",&a,&c,&b);
	a*=30; b*=6;
	b=(b-a+360) % 360;
	b= b >180 ? 360-b : b;
	if (b>=0 && b<30) cout << "alert" << endl; else
		if (b>=90) cout << "safe" << endl; else cout << "warning" << endl;
	}
return 0;
}

C++: #include <cstdio>
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main()
{
	int n; scanf("%d", &n);
	rep(i, n) {
		int h, m; scanf("%d:%d", &h, &m);
		int ah = 60 * h + m;
		int am = 12 * m;
		int diff = ah - am; if (diff < 0) diff = -diff;
		if (diff > 360) diff -= 360;

		double d = 0.5 * diff;
		if (d < 30) puts("alert");
		else if (d < 90) puts("warning");
		else puts("safe");
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;

const double pi = 3.14159265358979;
#define EPS (1e-10)

int main(){
	int n;
	scanf("%d", &n);
	for(int i=0 ; i < n ; i++ ){
		int h, m;
		scanf("%d:%d", &h, &m);
		double hour_hand = (double)h / 12.0 * 360.0 + (double)m / 60.0 * 30.0 + 360.0 ;
		double minute_hand = (double)m / 60.0 * 360.0 + 360.0 ;
		double d = fabs( hour_hand - minute_hand );
		//cout << "h : " << hour_hand - 360.0 << endl;
		//cout << "m : " << minute_hand - 360.0 << endl;
		//cout << "d : " << d << endl;
		if( d < 30.0+EPS ){
			cout << "alert" << endl;
		}else if( d < 90.0+EPS ){
			cout << "warning" << endl;
		}else{
			cout << "safe" << endl;
		}
	}
}

C++: #include <bits/stdc++.h>

typedef long long ll;
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n; cin >> n;

	for (int i = 0;i < n;i++){
		char a[6]; cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
		double h = 10*(a[0]-'0') + (a[1]-'0');
		double m = 10*(a[3]-'0') + (a[4]-'0');
		double ha = 30 * h + m/2;
		double ma = 6 * m;
		double d = max(ha,ma) - min(ha,ma);
		if(d < 30 || d > 330) cout << "alert" << endl; 
		else if(d < 90 || d > 270) cout << "warning" << endl;
		else cout << "safe" << endl;
	}

	return 0;

}

C++: #include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,h,m,tan,tyo,sa,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%d:%d",&h,&m);
		tan=h*300+m*5;
		tyo=m*60;
		sa=tan-tyo;
		if(sa<0)	sa=-sa;
		if(sa>1800)	sa=3600-sa;
		if(sa<300)	printf("alert\n");
		else if(sa>=900)	printf("safe\n");
		else printf("warning\n");
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n;
	cin >> n;

	rep(i,n)
	{
		double a,b;
		char c;
		cin >> a >> c >> b;

		double d = a*5 + b/12.0;	
		if(fabs(d-b) <= 5)
		{
			cout << "alert" << endl;
		}
		else if(15 < fabs(d-b) && fabs(d-b) < 30)
		{
			cout << "safe" << endl;
		}
		else if(d > b){
			double temp = fabs((60-d)-b);
			if(temp < 5)
			{
				cout << "alert" << endl;
			}
			else if(15 < temp && temp < 30)
			{
				cout << "safe" << endl;
			}
			else
			{
				cout << "warning" << endl;
			}
		}
		else if(d < b)
		{
			double temp = fabs((60-b)-d);
			if(temp < 5)
			{
				cout << "alert" << endl;
			}
			else if(15 < temp && temp < 30)
			{
				cout << "safe" << endl;
			}
			else
			{
				cout << "warning" << endl;
			}
		}
	}
	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int a, b, n;
double d, e, f;
int main() {
	cin >> n;
	for (int i = 0; i < n;i++) {
		scanf("%d:%d", &a, &b);
		f = abs(a * 30 - b * 11.0 / 2.0);
		if (f > 180) { f = 360 - f; }
		if (f < 30) { cout << "alert" << endl; }
		else if (f < 90) { cout << "warning" << endl; }
		else { cout << "safe" << endl; }
	}
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
	long n;
	cin>>n;
	for(int i=0;i<n;i++){
		int hh,mm;
		char cc;
		cin>>hh>>cc>>mm;
		double tyousin=mm*6;
		double tansin=hh*30+mm*0.5;
		double sita=abs(tyousin-tansin);
		if(sita>180)sita=360-sita;
		if(0<=sita &&sita<30)cout<<"alert"<<endl;
		else if(sita>=90 && sita<=180)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n--){
		int h,m,hp,mp;
		scanf("%02d:%02d",&h,&m);
		hp=h*60+m;
		mp=m*12;
		if((int)abs((double)(mp-hp))%(60*12)<(60*12)*30/360) cout<<"alert\n";
		else if((int)abs((double)(mp-hp))%(60*12)>=(60*12)*90/360&&(int)abs((double)(mp-hp))%(60*12)<=(60*12)*180/360) cout<<"safe\n";
		else cout<<"warning\n";
	}
	return 0;
}

C++: #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
using namespace std;
typedef long long ll;

int main(){
    int n;
    scanf("%d\n",&n);
    for(int ix=0;ix<n;ix++){
        int h,m;
        scanf("%d:%d\n",&h,&m);
        int tan=(60*h+m)%720,tyo=(12*m)%720;
        if(abs(tan-tyo)<60) printf("alert\n");
        else if(180<=abs(tan-tyo)) printf("safe\n");
        else printf("warning\n");
    }
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<char,int> P;

static const double eps = 10e-9;

string getAlert(int h,int m){
	int angleM = m * 6;
	int angleH = h * 30 + (m*6)/12;

	int dist = min(abs(angleH-angleM),360-abs(angleH-angleM));
	if(90 <= dist && dist <= 180) return "safe";
	else if(0 <= dist && dist < 30) return "alert";
	else return "warning";
}

int main(){
	int n,h,m;
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++){
			scanf("%d:%d",&h,&m);
			cout << getAlert(h,m) << endl;
		}
	}
}