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<cmath>

using namespace std;

double topos(int in,int num){
  if(num)return in * 6;
  return in * 30;
}

void solve(double h, double m){
  double judge = fabs(h-m);
  if(judge > 180) judge = 360 - judge;
  //cout << judge << endl;
  if(judge <= 30) cout << "alert" << endl;
  else if(judge < 90) cout << "warning" << endl;
  else cout << "safe" << endl;
}

int main(){
  int in;
  cin >> in;
  for(int i = 0; i < in; i++){
    int hour,minite;
    char trash;
    cin >> hour >> trash >> minite;
    //cout << hour << " " << trash << " " << minite<<endl;
    double pos = topos(minite,1);
    double posh = topos(hour,0);
    solve(posh,pos);
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={-1,0,1,0,1,1,-1,-1};
const int INF = 1<<30;
const double EPS = 1e-15;
#define PB push_back
#define mk make_pair
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int N;
	scanf("%d",&N);
	while(N--){
		double a,b;
		int h,m;
		scanf("%d:%d",&h,&m);
		b = m*6.0;
		a = h*30.0+m/2.0;
		double d = fabs(a-b);
		if(d < 30.0){
			puts("alert");
		}
		else if(90.0 <= d && d <= 180.0){
			puts("safe");
		}
		else{
			puts("warning");
		}
	}

    return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#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 all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

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

C++: #include <math.h>
#include <cstdio>
#include <iostream>
using namespace std;

int n,h,m;
double rh, rm, r;

double abs(double a){
 a > 0 ? a : -a;
}

int main(){
	cin >> n;
	for (int t = 0; t < n; t++) {
		scanf(" %d:%d", &h, &m);
		rh = h * 30 + m * 0.5;
		rm = m * 6;
		r = abs(rh - rm);
		if (r < 30 || r > 330) {
			cout << "alert" << endl;
		}
		else if(r >= 90 && r <= 180) {
			cout << "safe" << endl;
		}
		else {
			cout << "warning" << endl;
		}
	}

	return 0;
}

C++: #include <stdio.h>

#define ABS(X) ((X)<0?-(X):(X))

int main(void){
    int n;
    int h,m;
    double angleH, angleM, dAngle;
    
    scanf("%d", &n);
    for (int i=0; i<n; i++){
        scanf("%02d:%02d",&h, &m);
        //printf("%d, %d\n", h, m);
        angleM = 360*m/60.0;
        angleH = 360*h/12.0 + (360/12)*m/60.0;
        dAngle = ABS(angleM - angleH);
        if (dAngle < 30){
            puts("alert");
        } else if (dAngle < 90){
            puts("warning");
        } else {
            puts("safe");
        }
    }
    
    return 0;
}

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

int n;
int h, m;
int main() {
  while (cin >> n) {
	for (int CA = 0; CA < n; ++CA) {
	  scanf("%d:%d", &h, &m);
	  int degh = 300*h+5*m;
	  int degm = 60*m;
	  int deg = min(abs(degh-degm), 3600-abs(degh-degm));
	  if (deg < 300) puts("alert");
	  else if (deg >= 900) puts("safe");
	  else puts("warning");
	}
  }
}

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

int main(void){
	int n;
	double h,m;
	double ans;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lf:%lf",&h,&m);
		h=h*30+m/2;
		m=m*6;
		if(h>m)ans=h-m;
		else ans=m-h;
		if(ans<30 || ans>330)cout << "alert" << endl;
		else if(90<=ans && ans<=270)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+0.5*t;
		t *= 6;
		s -= t;
		if(s < 0){
			s = -s;
		}
		
		if(s < 30){
			cout << "alert" << endl;
		} else if(s < 90){
			cout << "warning" << endl;
		} else {
			cout << "safe" << endl;
		}
	}
}

C++: // AOJ 0135 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0135)
#include<cstdio>
#include<cmath>
#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 );

		double diff = fabs(hh*30+mm/2.0-mm*6);
		diff = std::min( diff, 360-diff );

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

	return 0;
}

C++: #include<iostream>
#include<queue>
#include<map>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define fr first
#define sc second
#define INF 100
typedef pair<int,int>Pt;
int main(){
  int n;
  double H,M,hh,mm,mini;
  scanf("%d",&n);
  while(n--){
    scanf("%lf:%lf",&hh,&mm);
    H = hh * 30.0 + mm * 0.25;
    M = mm * 6.0;
    mini = fabs(H - M);
    if(H<M) H += 360.0;
    else M += 360.0;
    mini = min(mini,fabs(H-M));

    if(mini<30) cout << "alert" << endl;
    else if(mini>=90) cout << "safe" << endl;
    else cout << "warning" << endl;
  }
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	int n; cin >> n;
	rep(i, n) {
		double h, m; scanf("%lf:%lf", &h, &m);
		double d = abs(h * 30. - 5.5 * m);
		if (0. <= d&&d < 30.)puts("alert");
		else if (90. <= d&&d <= 180.)puts("safe");
		else puts("warning");
	}
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n)           REPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
typedef unsigned long long ull;

int main(){
    int n;
    cin >> n;       // 10^4
    REP(i,n){
        int h, m; char c;
        cin >> h >> c >> m;   // hh:mm

        int th1 = 3600/12*h + 300/60*m;
        int th2 = 3600/60*m;
        int th_diff = abs(th1-th2);
        if(th_diff > 1800) th_diff = 3600-th_diff;
        printf("th1 = %d, th2 = %d\n", th1, th2);
        if(th_diff < 300){
            cout << "alert" << endl;
        } else if(th_diff >= 900){
            cout << "safe" << endl;
        } else {
            cout << "warning" << endl;
        }
    }
    return 0;
}