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++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> h(n);
	vector<int> m(n);
	vector<string> s(n);
	char co;
	for(int i=0;i<n;i++){
		double d=0;
	cin>>h[i]>>co>>m[i];
		d=double(360)/12*h[i];
		d+=double(360)/12/60*m[i];
		d-=double(360)/60*m[i];
		d=abs(d);
		if(d<30)
			s[i]="alert";
		else if(d>=90&&d<180)
			s[i]="safe";
		else
			s[i]="warning";
	}
	
	for(int i=0;i<n;i++)
		cout<<s[i]<<endl;
	
	

}

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

int main(){
    int n;
    cin >> n;
    for(int p=0; p < n; p++){
        int h, m;
        scanf("%d:%d", &h,&m);
        double hAngle = (360/12)*h + (360.0/12/60)*m;
        double mAngle = (360/60)*m;
        double angle = min(abs(hAngle-mAngle), abs(mAngle-hAngle));
        if(0 <= angle && angle < 30) cout << "alert" << endl;
        else if(90 <= angle && angle <= 180) cout << "safe" << endl;
        else cout << "warning" << endl;
    }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int getNum(string str, int pos) {
	int res = str[pos++] - '0';
	while (isdigit(str[pos])) {
		res = res * 10 + str[pos++] - '0';
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		string str;
		cin >> str;
		int h = getNum(str, 0), m = getNum(str, 3);
		
		double angle1 = m * 6.0, angle2 = h * 30.0 + angle1 / 60.0;
		double div = abs(angle1 - angle2);
		
		if (div >= 0.0 && div < 30.0)
			puts("alert");
		else if (div >= 90.0 && div <= 180.0)
			puts("safe");
		else
			puts("warning");
	}
	return 0;
}

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

#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n'&&c!=EOF;)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;while(isspace(c = gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	times(i, in) {
		int h {in}, m {in};
		double d {abs(h / 12. - m * 11 / 720.)};
		if (d > 0.5)
			d = 1. - d;
		outl(d < 1 / 12. ? "alert" : d < 0.25 ? "warning" : "safe");
	}
}

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

int main(void){
	int n;
	
	cin>> n ;
	for(int i = 0 ; i < n ; i++){
		double a,b; char c;
		
		cin>>a>>c>>b;
//		cout<<a<<" "<<b<<endl;
		a=(double)a*30+b*0.5;
		b=(double)b*6;
		
		double judge = abs(a-b);
	
//		cout<<judge<<endl;
	
//		cout<<a<<" "<<b<<" "<<judge<<endl;
		if(judge<30)cout<<"alert"<<endl;
		else if(judge<90)cout<<"warning"<<endl;
		else cout<<"safe"<<endl;
	}

}

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

std::pair<int, int> stot(const std::string &str) {
	auto idx = str.find(':');
	return std::make_pair<int, int>(stoi(str.substr(0, idx)), stoi(str.substr(idx + 1)));
}

int main() {
	int n;
	std::cin >> n;
	for (auto i = 0; i < n; ++i) {
		std::string arg;
		std::cin >> arg;
		auto time = stot(arg);
		auto hour = time.first * 60 + time.second, minute = time.second * 12;
		auto dist = (hour - minute) * (hour - minute);
		if (dist < 3600) {
			std::cout << "alert\n";
		}
		else if (dist >= 32400) {
			std::cout << "safe\n";
		}
		else {
			std::cout << "warning\n";
		}
	}
	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;
		if (abs(H - M) < 30)cout << "alert" << endl;
		else if (abs(H - M) < 90)cout << "warning" << endl;
		else cout << "safe" << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  double n,a,b;
  cin>>n;
  while(n--){
    scanf("%lf:%lf",&a,&b);
    double c=abs(a*30+b/2-b*6);
    double d=min(c,360-c);
    if(d<30)cout<<"alert"<<endl;
    else if(d<90)cout<<"warning"<<endl;
    else cout<<"safe"<<endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include <math.h>
int main(){
    int n,i;
    scanf("%d",&n);
    for (i=0; i<n; i++) {
        int h,m,x;
        scanf("%d:%d",&h,&m);
        x=fmod(5.5*(60*h+m),360);
        if ((x>=0&&x<30)||x>330) {
            printf("alert\n");
        }else if (x>=90&&x<=270){
            printf("safe\n");
        }else{
            printf("warning\n");
        }
    }
    return 0;
}