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 <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,c,d; char g;
        cin>>a>>b>>g>>c>>d;
        double l=(c-'0')*10+(d-'0');
        double s=(a-'0')*10+(b-'0');
        l*=6;
        s*=30;
        s+=(l)/12;
        double val=min(abs(l-s),360-abs(l-s));
        if(0<=val&&EPS<=30-val)cout<<"alert"<<endl;
        else if(90<=val&&EPS<=180-val)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}

C++: #include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		rep(i,n){
			char ch;
			int h,m;
			cin>>h>>ch>>m;


			if(330<abs(30*h+h/2.0-6*m) || abs(30*h+h/2.0-6*m)<30)cout<<"alert"<<endl;
			else if(90<=abs(30*h+h/2.0-6*m) && abs(30*h+h/2.0-6*m)<=270)cout<<"safe"<<endl;
			else cout<<"warning"<<endl;

		}
	}
	return 0;
}

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

int main(void){
	int n;
	
	cin>> n ;
	for(int i = 0 ; i < n ; i++){
		double a,b; char c;
		
		cin>>a>>c>>b;
//		cout<<a<<" "<<b<<endl;
		double A =(double)a*30+b*0.5;
		double B =(double)b*6;
		
		double judge = abs(A-B);
		if(180<judge)judge -= 360;
//		cout<<judge<<endl;
	
//		cout<<a<<" "<<b<<" "<<judge<<endl;
		if(0<=judge && judge<30)cout<<"alert"<<endl;
		else if(90<=judge && judge<180)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}

}

C++: #include<iostream>
using namespace std;
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        int t,m;
        (cin>>t).ignore()>>m;
        double t_ang=30*t,m_ang=6*m;
        t_ang+=30*(m/60.0);
        double dif=max(t_ang,m_ang)-min(t_ang,m_ang);
        dif=min(dif,360-dif);
        if(dif-30<0)cout<<"alert"<<endl;
        else if(dif-90>=0)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int T; cin >>T;
  REP(t, T){
    string s; cin >>s;
    int h = atoi(s.substr(0, 2).c_str());
    int m = atoi(s.substr(3).c_str());
    int d = abs((h * 30 + m * 0.5) - m * 6);
    cout <<(d >= 0 && d < 30 ? "alert" : (d >= 90 && d <= 180 ? "safe" : "warning")) <<endl;
  }
  return 0;
}

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

int main(){
    int n;
    int hour, minute;

    cin >> n;

    for(int i=1; i<=n; i++){
        scanf("%d:%d", &hour, &minute);
        double hour_angle;
        double minute_angle;

        minute_angle = minute * 6.0;
        if(minute_angle == 360.0){
            minute_angle = 0.0;
        }
        hour_angle = (hour * 60.0 + minute) * 360.0 / (12.0 * 60.0);
        if(hour_angle == 360.0){
            hour_angle = 0.0;
        }

        double diff = abs(minute_angle - hour_angle);
        if(diff > 180.0){
            diff = 360.0 - diff;
        }

        if(0<= diff && diff < 30){
            cout << "alert" << endl;
        }else if(90<= diff && diff <= 180){
            cout << "safe" << endl;
        }else{
            cout << "warning" << endl;
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int getNum(string str, int pos) {
	int res = str[pos++] - '0';
	while (isdigit(str[pos])) {
		res = res * 10 + str[pos++] - '0';
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		string str;
		cin >> str;
		int h = getNum(str, 0), m = getNum(str, 3);
		
		double angle1 = m * 6.0, angle2 = h * 30.0 + angle1 / 360.0;
		double div = abs(angle1 - angle2);
		
		if (div >= 0.0 && div < 30.0)
			puts("alert");
		else if (div >= 90.0 && div <= 180.0)
			puts("safe");
		else
			puts("warning");
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<sstream>


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

#define PII pair<int,int>
#define PP pair< int,PII >


using namespace std;



int main(){
	int n;
	int h,m;
	scanf("%d", &n);
	rep(i,n){
		int flag = 0;
		scanf("%d:%d", &h, &m);
		h = 30*h;
		h += m/2;
		m = m*6;
		
		int ha = (h+330)%360;
		rep(i,60){
			if(ha%360 == m){
				flag = 1;
			}
			ha++;
		}
		
		int hs = (h+90)%360;
		rep(i,181){
			if(hs%360 == m){
				flag = 2;
			}hs++;
		}
		
		if(flag == 1){
			cout << "alert" << endl;
		}else if(flag == 2){
			cout << "safe" << endl;
		}else{
			cout << "warning" << endl;
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	double n,h,t,ans;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%lf:%lf",&h,&t);
		h=h*30+(0.5*t);
		t=t*6;
		if(h<t)swap(h,t);
		ans=h-t;
		if(ans>180)ans-180;
		if(0.0<=ans&&ans<=30.0){
			cout<<"alert"<<endl;
		}else if(90.0<=ans&&ans<180.0){
			cout<<"safe"<<endl;
		}else{
			cout<<"warning"<<endl;
		}
	}
	return 0;
}