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<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 "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(ans<30.0){cout<<"alert"<<endl;}
		else if(90.0<=ans&&ans<=180.0){cout<<"safe"<<endl;}
		else{cout<<"warning"<<endl;}
	}
}

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 = 360.0 * ( (double)hh * 60.0 + (double)mm ) / 720.0;
    double ang2 = 360.0 * (double)mm / 60.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 <cstdio>
#define ABS(n) (((n)>0)?(n):(-(n)))
using namespace std;
int main()
{
  int n,h,m;
  float l,s,d;
  cin >> n;
  while(n--){
    scanf("%d:%d",&h,&m);
    s = m * 6;
    l = (60*h+m) / 2;
    d = ABS(l-s);
    if(d > 180) d = 360 - d;
    if(d < 30) cout << "alert" << endl;
    else if(d < 90) cout << "warning" << endl;
    else cout << "safe" << endl;
  }
  return 0;
}

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

int n,hh,mm;

int main(){
	scanf("%d",&n);
	for(int t = 0; t < n; t++){
		scanf("%d:%d",&hh,&mm);
		int rm = mm*12;
		int rh = hh*60+mm;
		int r = fabs(rm-rh);
		if(r < 30*2 || r > 330*2){
			puts("alert");
		}
		else if(r >= 90*2 && r <= 270*2){
			puts("safe");
		}
		else{
			puts("warning");
		}
	}

	return 0;
}

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

int main() {
	int a,b,n;
	char c;
	cin >> n;
	for (;n>0;n--) {
	scanf("%d%c%d",&a,&c,&b);
	a*=30; b*=6;
	b=(720+b-a) % 360;
    cout << "b=" << b << endl;
	b= b >180 ? 360-b : b;
	if (b<=30) cout << "alert" << endl; else
		if (b>=90) cout << "safe" << endl; else cout << "warning" << endl;
	cout << "b=" << b << endl;
	}
return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

#define rep(i, n) for(int i = 0; i < n; i++)

double cross(const xy_t &a, const xy_t &b){
	return imag(conj(a) * b);
}

double dot(const xy_t &a, const xy_t &b){
	return real(conj(a) * b);
}

xy_t projection(const line &l, const xy_t &p){
	double t = dot(p - l.first, l.first - l.second) / norm(l.first - l.second);
	return l.first + t * (l.first - l.second);
}

bool intersectSP(const line &l, const xy_t &p){
	return abs(l.first- p) + abs(l.second - p) - abs(l.first - l.second) < EPS;
}

double distanceSP(line s, xy_t p){
	const xy_t r = projection(s, p);
	if(intersectSP(s, r)) return abs(r - p);
	return min(abs(s.first - p), abs(s.second - p));
}

int main(){
	int n;
	cin >> n;
	string s;
	rep(i, n){
		cin >> s;
		int h = (s[0]-'0') * 10 + s[1] - '0';
		int m = (s[3]-'0') * 10 + s[4] - '0';
		double angle1 = h * 30 + (double)m / 10;
		double angle2 = m * 6;
		double d = abs(angle1 - angle2);
		if(d > 180.0) d -= 180.0;
		if(d < 30.0) {
			cout << "alert" << endl;
		}else if(90.0 - EPS < d) cout << "safe" << endl;
		else cout << "warning" << endl;
	}
	return 0;
}

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

int main(){
  int n;
  double h,m;
  string s;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    cin >> s;
    int st = s[0] == '0'?1:0;
    h = (atoi)(s.substr(st,s[0]=='0'?1:2).c_str());
    st = s[3] == '0'?4:3;
    m = (atoi)(s.substr(st,s[3]=='0'?1:2).c_str());
    h = h*30+m*0.5;
    m = m*6;
   
    if(0<= abs(h-m)&& abs(h-m) < 30)cout << "alert" << endl;
    else if(90 <= abs(h-m ) && abs(h-m ) <= 180)cout << "safe" << endl;
    else cout << "warning" << endl;  


  }

  return 0;
}



/*
時計の針は

いきなりうごくわけじゃあない

ps.
DIOの再来が怖くて夜も眠れない
 */

C++: #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int a, b, n;
double d, e, f;
int main() {
	cin >> n;
	for (int i = 0; i < n;i++) {
		scanf("%d:%d", a, b);
		d = b * 6;
		e = 1.0*(a * 30 + b) / 2.0;
		f = abs(d - e);
		if (f > 180) { f = 360 - f; }
		if (f < 30) { cout << "alert" << endl; }
		else if (f < 90) { cout << "warning" << endl; }
		else { cout << "safe" << endl; }
	}
}

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

int main(){
	long n;
	cin>>n;
	for(int i=0;i<n;i++){
		int hh,mm;
		char cc;
		cin>>hh>>cc>>mm;
		double tyousin=mm*6;
		double tansin=hh*30+mm*0.5;
		double sita=abs(tyousin-tansin);
		if(sita<30)cout<<"alert"<<endl;
		else if(sita>=90 && sita<=180)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
	return 0;
}