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>
using namespace std;

string func(int s, int l){
	int a = l * 180 / 60;
	int b = s * 180 / 12 + l / 4;
	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;
}*/

#include <iostream>
#include <string>
using namespace std;

int func(int s, int l){
	int a = l * 180 / 60;
	int b = s * 180 / 12 + l / 4;
	if(30 <= abs(a - b)){
		if(90 <= abs(a -b)){cout << "safe";return 0;}
		cout << "warning";return 0;
	}
	cout << "alert";
	return 0;
	
}

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

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

int main() {
	int n, h, m, v; char dm;
	cin >> n;
	for(int i=0; i<n; ++i) {
		cin >> h >> dm >> m;
		v = abs(60*h-11*m); if(v>360) v=720-v;
		cout << (v<60?"alert":180<=v&&v<=360?"safe":"warning") << endl;
	}
	return 0;
}

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

int main()
{
	int n;
	std::cin>>n;
	for(int i=0;i<n;i++)
	{
		char c;
		int h,m;
		
		std::cin>>h>>c>>m;
		
		int angl=h*60+m;
		int angs=m*12;

		int diff=abs(angl-angs);
		if(diff>360)diff=720-diff;
		
		if(diff<60)
		{
			std::cout<<"alert"<<std::endl;
		}
		else if(diff<180)
		{
			std::cout<<"warning"<<std::endl;
		}
		else
		{
			std::cout<<"safe"<<std::endl;
		}
	}
	return 0;
}

C++: #include<stdio.h>

int main(){

int n;
double h,m;
double g=0,gm=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%lf:%lf",&h,&m);
g=30*h;gm=6*m;
g+=(0.5*m);
double H=0;
H=gm-g;
if(H<0)H*=-1;
if(H>180)H=360-H;

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

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

const double EPS=1e-10;

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		int h,m;
		scanf("%d:%d",&h,&m);
		//~ð720ª
		int ha=h*60+m;
		int ma=m*12;
		int da=abs(ha-ma);
		da=min(da,720-da);
		if(da<60)
			cout<<"alert"<<endl;
		else if(da>=180)
			cout<<"safe"<<endl;
		else
			cout<<"warning"<<endl;
	}
	
	return 0;
}

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

int main(){
	int h,m;
	int n;
	double l,s;
	double mi = 0;
	cin >> n;
	while(n--){
		mi = (1<<21);
		scanf("%d:%d",&h,&m);
		l = m * 0.5 + h * 30.0;
		s = m * 6 ;
		mi = min(mi,fabs(l-s));
		if(l>s)s+=360.0;
		else   l+=360.0;
		mi = min(mi,fabs(l-s));
		
		if(mi<30.0){
			cout << "alert" << endl;
		}else if(mi<90.0){
			cout << "warning" << endl;
		}else{
			cout << "safe" << endl;
		}
	}
}

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);
    int H = h * 30;
    int M = 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<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;
		double a = abs(H - M);
		if (a >= 360)a -= 360;
		if (a < 30)cout << "alert" << endl;
		else if (a < 90)cout << "warning" << endl;
		else cout << "safe" << endl;
	}
	return 0;
}

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