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 <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));
        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 <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
 
const int INF = 1000000;
 
 
 int main(){
 	int k,n,m;
 	cin>>k;
 	for(int i = 0; i < k; i++){
 		scanf("%d:%d", &m, &n);
	 	m = m>12?m-12:m;
		double d = 360.0 * m / 12.0;
		d += 30.0 * n / 60.0;
		double e = 360.0 * n / 60.0;
		double f = min(abs(d-e),abs(360-abs(d-e)));
		
		if(f < 30.0) cout<<"alert"<<endl;
		else if(f >= 90.0) cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
 }

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

string func(int s, int l){
	int a = l * 6;
	int b = s * 30 + l / 2;
	int m = abs(a - b);
	if(m > 180)m = 360 - m;
	if(30 <= m){
		if(90 <= m)return "safe";
		return "warning";
	}else return "alert";
	cout << a  << " " << b;
	return "a";
}

int main(){
	int n, s, l;cin >> n;
	char c;
	while(n--){
		cin >> s >> c >> l;
		cout << func(s, l) << endl;
	}
	return 0;
}

C++: #include<bits//stdc++.h>
using namespace std;
int main() {
	double n=0.5,m=6,n2=30;
	int a,b,n4,e=0;
	cin>>n4;
	for(int i=0;i<n4;i++){
		string d;
		cin>>d;
		d+=":";
		string h;
		e=0;
		for(int j=0;j<d.length();j++){
			if(d[j]==':'){
				if(e==0)
					a=atoi(h.c_str());
				else
					b=atoi(h.c_str());
				h="";
				e++;
			}
			else
				h+=d[j];
		}
		double n3,m3;
		n3=0;
		n3+=(a*n2+b*n);
		m3=0;
		m3+=b*m;
		double c=n3-m3;
		if(c<0)
			c=0-c;
		if(360-c<c){
			c=360-c;
		}
		if(c>=90&&c<=180)
			printf("safe\n");
		else if(c>=0&&c<30)
			printf("alert\n");
		else
			printf("warning\n");
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>

using namespace std;

inline int toInt(string s) { stringstream ss(s); int x; ss >> x; return x; }

int main() {
  int n;
  string s;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> s;
    int sh = toInt(s.substr(0, 2));
    int lg = toInt(s.substr(3));
    long double argSh = sh*5*6;
    long double argLg = lg*6; argSh += argLg/12;
    
    long double hen = abs(argSh-argLg);
    //cout << argSh << " " << argLg << " " << hen << endl;
    if(0<=hen && hen<30) cout << "alert" << endl;
    else if(90<=hen && hen<180) cout << "safe" << endl;
    else cout << "warning"<< endl;
  }
  
  return 0;
}

C++: #include<stdio.h>
int min(int a,int b){return a>b?b:a;}
int abs(int a){return a<0?-a:a;}
int main(){
	int a;
	scanf("%d",&a);
	while(a--){
		int b,c;
		scanf("%d:%d",&b,&c);
		int hun=12*c;
		int ji=b*60+c;
		int ans=min(abs(hun-ji),720-abs(hun-ji));
		if(ans>=180)printf("safe\n");
		else if(ans>=60)printf("warning\n");
		else printf("alert\n");
	}
}

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

double degree(int h, int m) {
	double s = m * 6;
	double l = h * 30 + m * 0.5;
	double d = abs(l - s);
	if (d >= 180) d -= 180;
	return d;
}

string judge(int h, int m) {
	double d = degree(h, m);
	if (d < 30) return "alert";
	else if (d < 90) return "warning";
	return "safe";
}

int main() {
	int n; cin >> n;
	while (n--) {
		int h, m; char d;
		cin >> h >> d >> m;
		cout << judge(h, m) << endl;
	}
	return 0;
}

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

double ang(double a, double b){
    return min(abs(a-b), 360-abs(a-b));
}

int main(){
    int n;
    for(scanf("%d",&n);n--;){
        double a, b;
        scanf("%lf:%lf",&a,&b);
        a = a*30 + b/2;
        b = b*6;
        if( ang(a,b) < 30 ) puts("alert");
        else if( ang(a,b) < 90 ) puts("warning");
        else puts("safe");
    }
    return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n;
double a,b,ans;
int main(){
	cin>>n;
	rep(i,n){
		scanf("%lf:%lf",&a,&b);
		ans=abs(((a*60+b)*0.5 )-b*6);
		if(0<=ans&&ans<30.0){cout<<"alert"<<endl;}
		else if(90.0<=ans&&ans<=180.0){cout<<"safe"<<endl;}
		else{cout<<"warning"<<endl;}
	}
}

C++: #include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        double h,m;
        scanf("%lf:%lf",&h,&m);
        double totalm=h*60+m;
        double hh=totalm/2,mm=m*6;
        while(360<hh)hh-=360;
        double ans=fabs(hh-mm);
        if(ans<30)puts("alert");
        else if(ans<90)puts("warning");
        else puts("safe");
    }
    return 0;
}

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;
	int h,m;
	char co;
	for(int i=0;i<n;i++){
		double d=0;
	cin>>h>>co>>m;
		d=double(360)/12*h;
		d+=double(360)/12/60*m;
		d-=double(360)/60*m;
		d=abs(d);
		if(d>180)
			d=360-d;
		if(d>=0&&d<30)
			cout<<"alert"<<endl;
		else if(d>=90&&d<=180)
			cout<<"safe"<<endl;
		else
			cout<<"warning"<<endl;
	}
}