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 <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	int n,h,t;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d:%d",&h,&t);
		h=h*30;
		t=t*6;
		if(t<h)swap(t,h);
		if(0<=abs(h-t)&&abs(h-t)<=30){
			cout<<"alert"<<endl;
		}else if(90<=abs(h-t)&&abs(h-t)<180){
			cout<<"safe"<<endl;
		}else{
			cout<<"warning"<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	double n,h,t,ans;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%lf:%lf",&h,&t);
		h=h*30+(0.5*t);
		t=t*6;
		ans=abs(h-t);
		if(ans>=180)ans-180;
		if(0.0<=ans&&ans<=30.0){
			cout<<"alert"<<endl;
		}else if(90.0<=ans&&ans<180.0){
			cout<<"safe"<<endl;
		}else{
			cout<<"warning"<<endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;


int main() {
	int n, sh, lh;
	double degreeOfSh, degreeOflh, result;
	char c;

	cin >> n;
	while (n--) {
		cin >> sh >> c >> lh;
		//cout << sh << ends << lh << endl;
		degreeOfSh = sh * 30 + lh*0.5;
		degreeOflh = lh * 6;
		//cout << degreeOfSh << ends << degreeOflh << endl;
		result = min(fabs(degreeOfSh - degreeOflh), 360 - fabs(degreeOfSh - degreeOflh));
		if (result < 30) {
			cout << "alert" << endl;
		}
		else if (result >= 90 && result <= 270) {
			cout << "safe" << endl;
		}
		else {
			cout << "warning" << endl;
		}
	}

	return 0;
}

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

#define f first
#define s second
#define mp make_pair

#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()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int n;
  scanf("%d",&n);
  while(n --> 0){
    int h,m;
    scanf("%d:%d",&h,&m);
    double hh,mm;
    mm = m * (360.0/60.0);
    hh = (h + (m/60.0)) * (360.0/12.0);
    /*
    int hhh,mmm;
    hhh = round(hh*2);
    mmm = round(mm*2);
    */
    double diff = abs(hh - mm);
    if(diff > 180) diff = 360 - diff;

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

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

int main(){
  int n;
  cin >> n;
  while(n--){
    int h, m;
    scanf("%d:%d", &h, &m);
    double H = (double)h * 30 + m*0.5;
    double M = (double)m * 6;
    
    int ans = abs(H-M);
    
    if(0 <= ans && ans < 30) cout << "alert" << endl;
    else if(90 <= ans && ans <= 180) cout << "safe" << endl;
    else cout << "warning" << endl;
  }
  return 0;
}

C++: 
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }



int main()
{
	int n;
	cin >> n;
	while(n--)
	{
		double h, m;
		char k;
		
		cin >> h >> k >> m;
		
		/*
		h = (h * 30.0) + (m / 2.0);
		m *= 6.0;
		
		double d = (180.0 < abs(h - m) ? 360.0 - abs(h - m) : abs(h - m));
		
		cout << (d < 30.0 ? "aleart" : (d < 90.0 ? "warning" : "safe")) << endl;
		 */
		
		h = h * 60 + m;
		
		m *= 12.0;
		
		int d = (360 < abs(h - m) ? 720 - abs(h - m) : abs(h - m));
		
		cout << (d < 60 ? "alert" : (d < 180 ? "warning" : "safe")) << endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }



int main()
{
	int n;
	cin >> n;
	while(n--)
	{
		/*
		int h, m;
		char k;
		
		cin >> h >> k >> m;
				
		h = h * 60 + m;
		
		m *= 12.0;
		
		int d = (360 < abs(h - m) ? 720 - abs(h - m) : abs(h - m));
		
		cout << (d < 60 ? "alert" : (d < 180 ? "warning" : "safe")) << endl;
		 */
		
		int h, m;
		char k;
		
		cin >> h >> k >> m;
		
		int lg = h * 60 + m;
		int st = m * 12;
		
		int d = abs(lg - st);
		if(360 < d) d -= 360;
		
		cout << (d < 60 ? "alert" : (d < 180 ? "warning" : "safe")) << endl;
	}
}

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,c,d; char g;
        cin>>a>>b>>g>>c>>d;
        int l=(c-'0')*10+(d-'0');
        int s=(a-'0')*10+(b-'0');
        l*=6;
        s*=30;
        int val=min(abs(l-s),360-abs(l-s));
        if(0<=val&&val<=30)cout<<"alert"<<endl;
        else if(90<=val&&val<=180)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}