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>
#include <cmath>
using namespace std;

string func(int s, int l){
	double a = l * 6;
	double b = s * 30 + l / 2;
	int m = abs(a - b);
	if(0 <= m && m < 30)return "alert";
	if(90 <= m && m <= 180)return "safe";
	return "waring";
	/*if(m > 180)m = 360 - m;
	if(30 <= m){
		if(90 <= m)return "safe";
		return "warning";
	}
	return "alert";*/
}

int main(){
	int n, s, l;cin >> n;
	char c;
	while(n--){
		cin >> s >> c >> l;
		cout << func(s, l) << endl;
	}
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	char time[6];
	for(int i=0;i<n;i++){
		double a=0,b=0;
		cin >> time;
		for(int k=0;k<=9;k++){
			if(time[0]-'0' == k)
				a+= k*10;
			if(time[1]-'0' == k)
				a+= k;
			if(time[3]-'0' == k)
				b+= k*10;
			if(time[4]-'0' == k)
				b+= k;
		}
		double ans = max(a*30+b/2,b*6)-min(a*30+b/2,b*6);
		if((ans >= 0 && ans < 30) || (360 >= ans && ans > 330))
			cout << "alert" << endl;
		else if((ans >= 90 && ans <= 180) || (270 >= ans && ans >= 180))
			cout << "safe" << endl;
		else
			cout << "warning" << endl;
	}
	return 0;
}

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

int main() {
	int n, h, m;
	float a1, a2;
	
	cin >> n;
	for(int i=0;i<n;++i){
		scanf("%d:%d",&h,&m);
		
		a1 = fabs((h * 30 + m / 2 ) - 6 * m);
		a2 = 360 - a1;
		
		if(a1 < 30 || a2 < 30){
			cout << "alert" << endl;
		}else if((a1 < 180 && a1 > 90) || (a2 < 180 && a2 > 90)){
			cout << "safe" << endl;
		}else{
			cout << "warning" << endl;
		}
	}
	
	return 0;
}

C++: 
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }



int main()
{
	int n;
	cin >> n;
	while(n--)
	{
		double h, m;
		char k;
		
		cin >> h >> k >> m;
		
		h = (h * 30) + (m / 12);
		m *= 6;
		
		double d = (60 < abs(h - m) ? abs(m - h) : abs(h - m));
		
		cout << (d <= 30 ? "aleart" : (d <= 90 ? "warning" : "safe")) << endl;
	}
}

C++: /*
02:15がalert???
2時のとき短針は60度で
15分のとき長針は90度だから
90-60=30でwarningなのでは???
そもそも角度とは２つ考えられるがどっちのこっちゃい意味わからぬすアドリアーノ
 */
#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 *= 30;
    m *= 6;
    //       cout << h << " " << m << endl;
    if(0<= abs(h-m)&& abs(h-m) < 30)cout << "alert" << endl;
    else if(90 <= abs(h-m ) && abs(h-m ) <= 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(mp-hp)%(60*12)<(60*12)*30/360) cout<<"alert\n";
		else if((int)abs(mp-hp)%(60*12)>=(60*12)*90/360&&(int)abs(mp-hp)%(60*12)<=(60*12)*180/360) cout<<"safe\n";
		else cout<<"warning\n";
	}
	return 0;
}

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

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

    int n;

    std::cin >> n;
    
    for (; n--;) {
        int h, m;
        char tmp;
        std::cin >> h >> tmp >> m;

        double angle_h, angle_m, diff;

        angle_h = 30. * h + 0.5 * m;
        angle_m = 6. * m;

        diff = std::abs(angle_h - angle_m);

        if (diff > 180.) {
            diff = 360. - diff;
        }

        if (diff < 30.) {
            std::cout << "alert" << std::endl;
        }
        else if (diff < 90.) {
            std::cout << "warning" << std::endl;
        }
        else {
            std::cout << "safe" << std::endl;
        }
    }

    return 0;
}

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 angle = (hour * 300 + mini * 5) - (mini * 60);
            if(angle < 0) angle*= -1;
            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 <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


const string ALERT = "alert";
const string SAFE = "safe";
const string WARNING = "warning";

string solve( string s ) {
    replace( s.begin(), s.end(), ':', ' ' );
    ISS iss( s );
    int hh, mm;
    iss >> hh >> mm;

    double ang1 = 360.0 * ( hh * 60.0 + mm ) / 720.0;
    double ang2 = 360.0 * mm / 60.0;
    double diff = fabs( ang1 - ang2 );

    if ( diff > 180.0 ) diff = 360.0 - diff;
    if ( diff < 30.0 ) return ALERT;
    if ( diff > 90.0 ) return SAFE;
    return WARNING;
}

int main() {
    int n;
    cin >> n;
    for ( int i = 0; i < n; ++ i ) {
        string s;
        cin >> s;
        cout << solve( s ) << endl;
    }
    return 0;
}