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 <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 = 720 - d;
		
		cout << (0 <= d && d < 60 ? "alert" : (180 <= d && d <= 360 ? "safe" : "warning")) << endl;
	}
}

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

using namespace std;

int main(void)
{
	int n;
	cin >> n;

	double h, m;
	while (n--){
		scanf("%lf:%lf", &h, &m);
		double hh = 30 * h + 0.5 * m;
		double mm = 6 * m;
		// printf("hour angle %Lf\n", hh);
		// printf("minute angle %Lf\n", mm);
		double diff = abs(hh - mm);
		// cout << diff << endl;
		if (0 <= diff && diff < 30){
			cout << "alert" << endl;
		}
		else if (90 <= diff && diff <= 180){
			cout << "safe" << endl;
		}
		else {
			cout << "warning" << endl;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<ios>
#include<algorithm>
using namespace std;
int n;
main()
{
	cin>>n;
	for(;n--;)
	{
		int h,m;
		scanf("%d:%d",&h,&m);
		int dm=m*12;
		int dh=h*60+m;
		int a=abs(dm-dh);
		if(a>360)return 1;
		cout<<(a<60?"alert":a>=180?"safe":"warning")<<endl;
	}
}

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>
#include <cmath>
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 <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int n, h, m, diff;
	
	cin >> n;
	
	string str;
	
	for(int loop = 0; loop < n; loop++){
		cin >> str;
		h = (str[0] - '0') * 10 + (str[1] - '0');
		m = (str[3] - '0') * 10 + (str[4] - '0');
		diff = abs((h * 60 + m) - m * 12);
		if(diff > 360){
			diff = 720 - diff;
		}
		if(diff < 60){
			printf("alert\n");
		}else if(diff < 180){
			printf("warning\n");
		}else{
			printf("safe\n");
		}
	}
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin>>n;
  while(n--){
    scanf("%d:%d",&a,&b);
    int c=abs(a*30+(b+1)/2-b*6);
    int d=min(c,360-c);
    if(d<30)cout<<"alert"<<endl;
    else if(d<90)cout<<"warning"<<endl;
    else cout<<"safe"<<endl;
  }
  return 0;
}

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

using namespace std;

int different( double h, double m )
{

	h += m / 60.0;
	double a = h - m;
	if( a < 0 ) a = -a;
	
	if( 360 - a < a ) a = 360 - a;

	return a;
}

int main(int argc, char const* argv[])
{
	double h,m;
	int n;

	cin >> n;

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

		h *= 30;
		m *= 6;

		double answer = different( h, m );


		if( answer >= 0 && answer < 30 ) cout << "alert" << endl;
		else if( answer >= 90 && answer <= 180 ) cout << "safe" << endl;
		else cout << "warning" << endl;
	}
	return 0;
}

C++: #include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
	int n;
	cin>>n;
	rep(i,n){
		char ch;
		int h,m;
		cin>>h>>ch>>m;


		if(330<abs(30*h+h/2.0-6*m) || abs(30*h+h/2.0-6*m)<30)cout<<"alert"<<endl;
		else if(90<=abs(30*h+h/2.0-6*m) && abs(30*h+h/2.0-6*m)<=270)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
	return 0;
}

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


int main(void)
{
	//入力変数(時間)
	int time = 0;
	//入力分変数
	int min = 0;
	//入力回数
	int n = 0; 

	cin >> n;

	//出力
	for (int i = 0; i < n; i++)
	{
		scanf("%d:%d" , &time , &min);

		time *= 5;

		time += min / 12;

		//両方足す(負数になると面倒)
		time += 60;
		min += 60;

		if (time + 5 > min && time - 5 < min)
		{
			cout << "alert" << endl;
		}
		else if (time + 15 <= min && time + 30 >= min || time - 15 >= min && time -30 <= min)
		{
			cout << "safe" << endl;
		}
		else
		{
			cout << "warning" << endl;
		}
	}

	return 0;
}

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


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

#define PII pair<int,int>
#define PP pair< int,PII >


using namespace std;



int main(){
	int n;
	int h,m;
	scanf("%d", &n);
	rep(i,n){
		int flag = 0;
		scanf("%d:%d", &h, &m);
		h = 30*h;
		h += m/2;
		m = m*6;
		
		int ha = (h+330)%360;
		rep(i,61){
			if(ha%360 == m){
				flag = 1;
			}
			ha++;
		}
		
		int hs = (h+90)%360;
		rep(i,181){
			if(hs%360 == m){
				flag = 2;
			}hs++;
		}
		
		if(flag == 1){
			cout << "alert" << endl;
		}else if(flag == 2){
			cout << "safe" << endl;
		}else{
			cout << "warning" << endl;
		}
	}
	
	return 0;
}