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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n, h, m;

int main(){
	cin >> n;
	REP(i, n){
		scanf("%d:%d", &h, &m);
		double s = (double)h * 30.0 + (double)m*0.5, l = (double)m * 6.0;
		double d = max(l, s) - min(l, s);
		if (d > 180)d = 360 - d;
		if (d < 30.0)cout << "alert\n";
		else if (d < 90.0)cout << "warning\n";
		else cout << "safe\n";
	}
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int main()
{
	int t;
	cin >> t;

	REP( dt, 0, t )
	{
		string line;
		cin >> line;

		UREP( i, 0, line.length() )
		{
			if ( line[i] == ':' )
			{
				line[i] = ' ';
				break;
			}
		}

		double hour, min;

		istringstream( line ) >> hour >> min;

		hour += ( min / 60 );
		hour *= 5;

		if ( abs( hour - min ) < 5 )
		{
			cout << "alert" << endl;
		}
		else if ( abs( hour - min ) < 15 )
		{
			cout << "warning" << endl;
		}
		else
		{
			cout << "safe" << endl;
		}
	}
	
	return 0;
}

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

#define DEBUG(x) // cerr << #x << " = " << x << endl

const long double EPS = 1e-8;

long double deg_long(int hh, int mm) {
    hh %= 12;
    long double deg = (1.0 * 360) * hh / 12;
    deg += (1.0 * 360 / 12) * mm / 60;
    return deg;
}

long double deg_short(int mm) {
    return 1.0 * 360 * mm / 60;
}

int main() {
    int N; scanf("%d", &N);
    while(N--) {
        int hh, mm; scanf("%d:%d", &hh, &mm);
        long double diff = abs(deg_long(hh, mm) - deg_short(mm));
        DEBUG(diff);
        if (diff < 30) puts("alert");
        else if(90 <= diff) puts("safe");
        else puts("warning");
    }
}

C++: #include <stdio.h>
#include <algorithm>
using namespace std;
int n, h, m, r, a;
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%02d:%02d", &h, &m); r = h * 60 + m; m *= 12;
		a = min(abs(r - m), 720 - abs(r - m));
		if(a < 60) printf("alert\n");
		else if(a < 180) printf("warning\n");
		else printf("safe\n");
	}
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>

int main(){

	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++){
		int h, m;
		scanf("%d:%d", &h, &m);

		long double ang ;
		ang = 6 * m - (30 * h + 30 * ((long double)m / 60));
		ang = std::abs(ang);

		if (0 <= ang && ang < 30)printf("alert\n");
		else if (90 <= ang && ang <= 180)printf("safe\n");
		else printf("warning\n");
	}

	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	while (n--)
	{
		int h, m;
		scanf("%d:%d", &h, &m);
		double t = abs(h/12.0 - m/60.0);
		if (t > 0.5)
			t = 1 - t;
		t *= 360;

		if (t < 30)
			puts("alert");
		else if (t < 90)
			puts("warning");
		else
			puts("safe");
	}

	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {
	int n;
	int hour,minute;
	char d;
	double kakuh,kakum,sa;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> hour >> d >> minute;
		kakuh = 30.0 * hour + minute * 0.5;
		kakum = 6.0 * minute;
		sa = fabs(kakuh-kakum);
		if (sa > 180.0) {
			sa = sa - 180;
		}
		if (sa <30.0) {
			cout << "alert" << endl;
		} else if (sa >= 90.0) {
			cout << "safe" << endl;
		} else {
			cout << "warning" << endl;
		}
	}
	return 0;
}

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

int main(){

	int n, h, m;
	double deg_l, deg_s, deg;
	string str;

	cin >> n;
	
	for(int i=0; i<n; i++){
		cin >> str;
		
		h = (str[0] - '0') * 10 + (str[1] - '0');
		m = (str[3] - '0') * 10 + (str[4] - '0');
		deg_l = 360.0 * (m / 60.0);
		deg_s = 360.0 * (h / 12.0) + 30.0 * (m / 60.0);
		
		deg = min(abs(deg_l - deg_s), 360.0 - abs(deg_l - deg_s));
		
		if(deg < 30.0) cout << "alert" << endl;
		else if(deg < 90.0) cout << "warning" << endl;
		else cout << "safe" << endl;
	}

	return 0;

}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
 
int main() {
  int Tc; cin >> Tc;
  int H, M;
   
  while(Tc --) {
    scanf("%d:%d", &H, &M);
     
    double h = H*30.0 + M/2.0, m = M*6;
     
    int ang = abs(h - m);
    if(ang > 180) ang = 360 - ang;
    if(0 <= ang && ang < 30) {
      cout << "alert" << endl;
    }
    else if(90 <= ang && ang <= 180) {
      cout << "safe" << endl;
    }
    else cout << "warning" << endl;
  }
   
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
 
int main() {
	int n; cin >> n;
	int s, l;
	char c;
   
  while(n--) {
     cin >> s >> c >> l;
    double h = s*30.0 + l/2.0, m = l*6;
     
    int ang = abs(h - m);
    if(ang > 180) ang = 360 - ang;
    if(0 <= ang && ang < 30) {
      cout << "alert" << endl;
    }
    else if(90 <= ang && ang <= 180) {
      cout << "safe" << endl;
    }
    else cout << "warning" << endl;
  }
   
  return 0;
}

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;
	if(30 <= abs(a - b)){
		if(90 <= abs(a -b))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;
}