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<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int n;
    cin>>n;
    while(n--){
        int h,m;
        scanf("%d:%d",&h,&m);
        double h_angle,m_angle;
        h_angle = h/12.0 + m/720.0;
        m_angle = m/60.0;
        double d = fabs(h_angle - m_angle);
        if(d - (1.0/6) < 1e-8)cout<<"alert"<<endl;
        else if(d - (1.0/4) > -1e-8)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;
char c;
int main() {
	cin >> n;
	while (cin >> a >> c >> b) {
		d = b * 6;
		e = (a * 30 + b) / 2.0;
		f = abs(d - e);
		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>

int main(){
	//Input
	int N;
	std::cin >> N;

	int H, M;
	while(N--){
		scanf("%d:%d",&H,&M);
		//Processing
		//ツ角ツ度ツづーツ仰づ淞づゥ
		double aH = 30 * H + 0.5 * M, aM = 6 * M, a;
		//std::cout << aH << "," << aM << std::endl;
		if(aH > aM){
			a = aH - aM;
		}
		else{
			a = aM - aH;
		}

		//ツ甘ォツ個ッツつウツづーツ板サツ津ィ
		std::string res;
		if(a >= 0 && a < 30){
			res = "alert";
		}
		else if(a >= 90 && a <= 180){
			res = "safe";
		}
		else{
			res = "warning";
		}

		std::cout << res << std::endl;
	}
}

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

using namespace std;


int main(){

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

	double hour,minute,degree1,degree2,div;

	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;

		div = min(fabs(degree1-degree2),360.0-fabs(degree1-degree2));

		if(div < 30.0){
			printf("alert\n");
		}else if(div < 90.0){
			printf("warning\n");
		}else{
			printf("safe\n");
		}
	}

    return 0;
}

C++: #include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
 
    scanf("%d" ,&n);
    while (n--) {
	double h, m;
	scanf("%lf:%lf", &h, &m);
     
	double l = 30*h + m/2;
	double s = m * 6.0;
 
	double key = fabs(l - s);
	key = min(key, 360-key);
	if (0 <= key && key < 30) {
	    puts("alert");
	} else if (90 <= key && key <= 180) {
	    puts("safe");
	} else {
	    puts("warning");
	} 
    }
    return 0;
}

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

int main(){
  int n,h,s;
  double a,b,ans;
  cin>>n;
  while(n--){
    scanf("%d:%d",&h,&s);
    b=s*6;
    a=h*30+b/360;
    ans=abs(a-b);
    if(ans>180)ans=360-ans;
    if(0<=ans&&ans<=30)cout<<"alert"<<endl;
    else if(90<=ans&&ans<=180)cout<<"safe"<<endl;
    else cout<<"warning"<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    while(--n >= 0){
        int h, m;
        char c;
        cin >> h >> c >> m;

        int a = 60 * h - 11 * m;
        if(a < 30*2 || a > 330*2)
            cout << "alert" << endl;
        else if(90*2 <= a && a <= 270*2)
            cout << "safe" << endl;
        else
            cout << "warning" << endl;
    }

    return 0;
}

C++: // AOJ 0135 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0135)
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)

int h;

int main()
{
	scanf( "%d", &h );
	rep( i, h )
	{
		int hh, mm;
		scanf( "%d:%d", &hh, &mm );

		int diff = abs(hh*30+mm/2-mm*6);
		diff = std::min( diff, 360-diff );

		puts( diff<30?"alert":diff<90?"warning":"safe" );
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#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()

struct hms {		// ツ篠楪甘板、ツ閉ェツ、ツ秒ツつェツ与ツつヲツづァツづェツつスツづつォツづ個計ツ算ツ陛「ツ渉閉。ツ秒ツづ可環キツ算ツ。ツ青ョツ青板氾。
  int t;
  int h, m, s;
  hms(int _h, int _m, int _s) {h=_h;m=_m;s=_s;t=h*3600+m*60+s;}
  hms(int _t) {t = _t; h = t/3600; m = t%3600/60; s=t%60;}
};

int main() {
  int n;
  cin >> n;
  cin.ignore();
  while(n--) {
    int h,m;
    scanf("%d:%d\n",&h,&m);
    double angh = 360.0*hms(h,m,0).t/hms(12,0,0).t;
    double angm = 360.0*m/60;
    cout << angh << " " << angm << endl;
    double ang = abs(angh-angm);
    ang = min(ang,abs(angh-angm-360));
    ang = min(ang,abs(angh-angm+360));
    if (ang < 30)
      cout << "alert";
    else if (ang >= 90)
      cout << "safe";
    else
      cout << "warning";
    cout << endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	float n,h,t,ans;
	char c;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%lf%c%lf",&h,&c,&t);
		h=h*30+(0.5*t);
		t=t*6;
		if(h<t)swap(h,t);
		ans=h-t;
		if(ans>180)ans=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;
}

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 * 30 + mini * 0.5) - (mini * 6);
            if(angle < 0) angle*= -1;
            if(angle >= 0 && angle < 30)
                cout << "alert" << endl;
            else if(angle >= 90 && angle <= 180)
                cout << "safe" << endl;
            else
                cout << "warning" << endl;
        }
    }
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n;
	cin >> n;
	rep(q, n){
		string s;
		cin >> s;
		int h, m;
		h = stoi(s.substr(0, 2)); m = stoi(s.substr(3, 2));
		double a, b;
		a = 360/(60./m); b = 360/(12./h) + 30/(60./m);
		if(abs(a-b) < 30) cout << "alert" << endl;
		else if(abs(a-b) < 90) cout << "warning" << endl;
		else cout << "safe" << endl;
	}
}