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<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        rep(i,n){
            double hour, mini;
            scanf("%lf%*c%lf", &hour, &mini);
            double angle1 = (hour * 300 + mini * 5);
            double angle2 = (mini * 60);
            double angle = sqrt((angle1 - angle2) * (angle1 - angle2));
            if(angle > 1800) angle-= 1800;
            if(angle >= 0 && angle < 300)
                cout << "alert" << endl;
            else if(angle >= 900 && angle <= 1800)
                cout << "safe" << endl;
            else
                cout << "warning" << endl;
        }
    }
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n=in();
	int i;
	for(i=0;i<n;i++){
		int h,m;
		scanf("%d:%d",&h,&m);
		int dis=abs(h*60-m*11);
		chmin(dis,720-dis);
//cout<<dis<<endl;
		if(dis<60)cout<<"alert"<<endl;
		else if(dis>=180)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	int n;
	
	cin>> n ;
	for(int i = 0 ; i < n ; i++){
		double a,b; char c;
		int judge;
		
		cin>>a>>c>>b;
//		cout<<a<<" "<<b<<endl;
		a=a*360/12+b*360/12/60;
		b=b*360/60;
		judge=(int)(a-b)%180;
	
		if(judge<0)judge=-1*judge;
//		cout<<judge<<endl;
	
//		cout<<a<<" "<<b<<" "<<judge<<endl;
		if(judge<30)cout<<"alert"<<endl;
		else if(judge<90)cout<<"warning"<<endl;
		else cout<<"safe"<<endl;
	}

}

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

using namespace std;

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		int h, m;
		char c;
		cin >> h >> c >> m;
		double hour_hand = h * 30 + m / 2;
		double minute_hand = m * 6;
		if(fabs(hour_hand - minute_hand) < 30)
		{
			cout << "alert" << endl;
		}
		else if(fabs(hour_hand - minute_hand) < 90)
		{
			cout << "warning" << endl;
		}
		else
		{
			cout << "safe" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  int n;
  double a,b;
  cin>>n;
  while(n--){
    scanf("%lf:%lf",&a,&b);
    a*=5;
    a+=b/60;
    double y=abs(b-a),x=abs(60-b+a);
    if(min(y,x)<5)cout<<"alert"<<endl;
    else if(min(y,x)<15)cout<<"warning"<<endl;
    else cout<<"safe"<<endl;
  }
}

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

int main(){
  int n;
  double h,m;
  string s;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    cin >> s;
    int st = s[0] == '0'?1:0;
    h = (atoi)(s.substr(st,s[0]=='0'?1:2).c_str());
    st = s[3] == '0'?4:3;
    m = (atoi)(s.substr(st,s[3]=='0'?1:2).c_str());
    h = h*30+m*0.5;
    m = m*6;
    double dif=fabs(h-m);
    if(fabs(h-m) > 180)dif = 360-dif;
    if(0<= dif&& dif < 30)cout << "alert" << endl;
    else if(90 <= dif && dif <= 180)cout << "safe" << endl;
    else cout << "warning" << endl;  


  }

  return 0;
}



/*
時計の針は

いきなりうごくわけじゃあない
 */

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+mm*0.5;
    
    mm*=6;
    //cout<<hh<<":"<<mm<<endl;
    int diff=abs(hh-mm);
    if(mm>hh)diff=abs(mm-hh);
    if(diff>180)diff=360-diff;

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

C++: #include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;


int main(){

	int n;
	scanf("%d",&n);

	double hour,minute,degree1,degree2;

	char buf[6];

	for(int i=0; i < n; i++){
		scanf("%s",buf);

		hour = 10*(buf[0]-'0')+(buf[1]-'0');
		minute = 10*(buf[3]-'0')+(buf[4]-'0');

		degree1 = 360*(minute/60);
		degree2 = (60*hour+minute)/2;

		if(fabs(degree1-degree2) <= 30.0){
			printf("alert\n");
		}else if(fabs(degree1-degree2) >= 90.0 && fabs(degree1-degree2) <= 180.0){
			printf("safe\n");
		}else{
			printf("warning\n");
		}
	}

    return 0;
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    rep(_,n){
        char a,b,g,c,d; cin>>a>>b>>g>>c>>d;
        double h=(a-'0')*10+(b-'0');
        double m=(c-'0')*10+(d-'0');
        double hoge=h*30;
        h=m/2.0+hoge;
        m*=6;
        if(m>h)swap(m,h);
        double cal=min(h-m,360+m-h);
        if(0<=cal&&cal<=30)cout<<"alert"<<endl;
        else if(90<=cal&&cal<=180)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}