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 <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 = ( hh * 60.0 + mm ) / 720.0 * 360.0;
    double ang2 = mm / 60.0 * 360.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;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n;
double h, m;

int main(){
	cin >> n;
	REP(i, n){
		scanf("%lf:%lf", &h, &m);
		double s = h * 30.0 + m*0.5, l = m * 6.0;
		//cout << max(l, s) - min(l, s) << endl;
		if (max(l, s) - min(l, s) < 30)cout << "alert" << endl;
		else if (max(l, s) - min(l, s) < 90)cout << "warning" << endl;
		else cout << "safe" << endl;
	}
}

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

int main() {
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		double s=0;
		string p;
		cin >> p;		
		s = ((p[0] - '0') * 10 + (p[1] - '0')) * 30 - ((p[3] - '0') * 10 + (p[4] - '0'))*5.5;
		if (s < 0)s = s - s * 2;
		if (s > 360 - s)s = 360 - s;
			if (s < 30)cout << "alert" << endl;
			else if (s < 90)cout << "warning" << endl;
			else cout << "safe" << endl;
	}
}

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

int main()
{
	int n;

	while( cin >> n ){
		for( int i = 0; i < n; ++i ){
			int h, m;
			char dummy;
			cin >> h >> dummy >> m;

			int hAngle = h * 300 + m * 10 / 4;
			int mAngle = m * 10 * 360 / 60;
			int angle = hAngle - mAngle;
			string message;
			if( angle < 300 && angle > -300 ){
				message = "alert";
			}else if( ( angle >= 900 && angle <= 2700 ) || ( angle <= -900 && angle >= -2700 ) ){
				message = "safe";
			}else{
				message = "warning";
			}

			cout << message << endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)

int main(){

	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		string str;
		double lg,sh;
		cin>>str;
		lg=atoi(str.substr(0,2).c_str())*30;
		sh=((atoi(str.substr(3,2).c_str())))*6;
		lg+=((double)sh/120);
		double dis=abs(lg-sh);
		dis=min(dis,360-dis);
		if((dis>0||EQ(dis,0))&&dis<30){
			cout<<"alert"<<endl;
		}
		else if((dis>90||EQ(dis,90))&&(dis<180||EQ(dis,180))){
			cout<<"safe"<<endl;
		}
		else{
			cout<<"warning"<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n;
	float s, t;
	
	cin >> n;
	while(n--){
		scanf("%f:%f", &s, &t);
		
		s = s*30-5.5*t;
		
		if(s < 0){
			s = -s;
		}
		if(s > 180){
			s = 360 - s;
		}
		
		if(s < 30){
			cout << "alert" << endl;
		} else if(s < 90){
			cout << "warning" << endl;
		} else {
			cout << "safe" << endl;
		}
	}
}

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+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++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n;
	while (n--) {
		string s; cin >> s;
		double sh = stoi(s.substr(3, 2)) / 60.0 * 360;
		double lo = stoi(s.substr(0, 2)) * 5 / 60.0 * 360 + sh / 360.0 * 30;
		double dif = min(fabs(lo - sh), 360.0 - fabs(lo - sh));
		dump(lo); dump(sh); dump(dif);
		if (dif < 30.0)cout << "alert" << endl;
		else if (dif < 90)cout << "warning" << endl;
		else cout << "safe" << 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 = abs(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;
}