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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#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()
#define mp make_pair
#define pb push_back
#define f first
#define s second

main(){
  int n;
  cin>>n;
  while(n--){
    int hh,mm;
    scanf("%d:%d",&hh,&mm);
    hh*=30;
    mm*=6;
    int diff=abs(hh-mm);
    if(diff>180)diff=360-diff;

    if(diff<=30)puts("alert");
    else if(diff>=90)puts("safe");
    else puts("warning");
  }
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	VS str = { "alert","safe","warning" };

	int n; cin >> n;
	rep(i, n) {
		int h, m; char c;
		cin >> h >> c >> m;

		double a1 = (double)h * 30. + (double)m * 0.5, a2 = (double)m * 6.;
		double diff = abs(a1 - a2);
		diff = diff > 180. ? 360. - diff : diff;

		int ans;
		if (0. <= diff && diff < 30.)ans = 0;
		else if (90. <= diff && diff <= 180.)ans = 1;
		else ans = 2;

		Cout(str[ans]);
		//cout << "Angle : " << diff << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#define ABS(n) (((n)>0)?(n):(-(n)))
using namespace std;
int main()
{
  int n,h,m,l,s,d;
  cin >> n;
  while(n--){
    scanf("%d:%d",&h,&m);
    s = m * 12;
    l = 60 * h + m;
    d = ABS(l-s);
    if(d > 360) d = 720 - d;
    if(d < 60) cout << "alert" << endl;
    else if(180 <= d && d <= 360) cout << "safe" << endl;
    else cout << "warning" << endl;
  }
  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;
		double x,y;
		scanf("%d:%d", &h, &m);
		
		x = 30*h+m/2.0;
		y = m*6;
		
		if(x-30 < y && y < x+30){
			cout << "alert" << endl;
		}else if(x-390 < y && y < x-330){
			cout << "alert" << endl;
		}else if(x+330 < y && y < x+390){
			cout << "alert" << endl;
		}else if(x-90 < y && y < x+90){
			cout << "warning" << endl;
		}else if(x-470 < y && y < x-270){
			cout << "warning" << endl;
		}else if(x+270 < y && y < x+470){
			cout << "warning" << endl;
		}else{
			cout << "safe" << endl;
		}
		
	}
	
	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;
    if (abs(angh-angm) < 30)
      cout << "alert";
    else if (abs(angh-angm) >= 90)
      cout << "safe";
    else
      cout << "warning";
    cout << endl;
  }
}

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 = min(360-fabs(a-b),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 <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,g,c,d; cin>>a>>b>>g>>c>>d;
        double h=(a-'0')*10+(b-'0');
        double m=(c-'0')*10+(d-'0');
        double hoge=h*30;
        h+=m/2.0+hoge;
        m*=6;
        double cal=min(abs(h-m),360-abs(h-m));
        cout<<cal<<endl;
        if(0<=cal&&cal<=30)cout<<"alert"<<endl;
        else if(90<=cal&&cal<=180)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}

C++: #include<iostream>
#include<ios>
#include<algorithm>
using namespace std;
int n;
main()
{
	cin>>n;
	for(;n--;)
	{
		int h,m;
		scanf("%d:%d",&h,&m);
		int dm=m*12;
		int dh=h*60+m;
		int a=abs(dm-dh)%360;
		cout<<(a<60?"alert":a>=180?"safe":"warning")<<endl;
	}
}