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>

using namespace std;

int different( double h, double m )
{
	double a = h - m;
	h += m / 60.0;
	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 <math.h>
#include <cstdio>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

int n,h,m;
double rh, rm, r;

int main(){
	cin >> n;
	for (int t = 0; t < n; t++) {
		scanf(" %d:%d", &h, &m);
		rh = h * 30 + m * 0.5;
		rm = m * 6;
		r = abs(rh - rm);
		if (r < 30 || r > 330) {
			cout << "alert" << endl;
		}
		else if(r >= 90 && r <= 180) {
			cout << "safe" << endl;
		}
		else {
			cout << "warning" << endl;
		}
	}

	return 0;
}

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

using namespace std;

void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		int h, m;
		char c;
		cin >> h >> c >> m;
		double hour_hand = h * 30 + m / 2;
		double minute_hand = m * 6;
		double min_diff = min(fabs(hour_hand - minute_hand), 360 - fabs(hour_hand - minute_hand));
		if(min_diff < 30)
		{
			cout << "alert" << endl;
		}
		else if(min_diff < 90)
		{
			cout << "warning" << endl;
		}
		else
		{
			cout << "safe" << endl;
		}
	}
}

int main()
{
	solve();
	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<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);
		cout << (v<60?"alert":180<=v&&v<360?"safe":"warning") << endl;
	}
	return 0;
}

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

string func(int s, int 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)return "alert";
	if(90 <= ang && ang <= 180)return "safe";
	return "warning";
}
 
int main() {
	int n, s, l; cin >> n;
	char c;
	while(n--) {
		cin >> s >> c >> l;
		cout << func(s, l) << endl;
	}
  	return 0;
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int T; cin >>T;
  REP(t, T){
    string s; cin >>s;
    int h = atoi(s.substr(0, 2).c_str());
    int m = atoi(s.substr(3).c_str());
    double d = fabs((h * 30.0 + m * 0.5) - m * 6.0);
    cout <<(d >= 0.0 && d < 30.0 ? "alert" : (d >= 90.0 && d <= 180.0 ? "safe" : "warning")) <<endl;
  }
  return 0;
}

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;
	cout << a  << " " << b;
	
}

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 <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a, b;
        scanf("%d:%d", &a, &b);
        int aa = a*60+b, bb = 12*b;
        int p = min(abs(aa-bb), (720-abs(aa-bb))%720);
        if(p < 60) puts("alert");
        else if(p < 180) puts("warning");
        else puts("safe");
    }
    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;
	while(cin>>n){
		if(n==0)break;
		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<bits/stdc++.h>
using namespace std;

int main()
{
  int n;
  string s;
  double x,y,a,b,ans=0;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    x=(s[0]-'0')*10+(s[1]-'0');
    y=(s[3]-'0')*10+(s[4]-'0');
    a=(x+y/(60*12))*5;
    b=y;
    ans=6*abs(a-b);
    if(ans<30)cout<<"alert"<<endl;
    else if(90<=ans && ans<=180)cout<<"safe"<<endl;
    else cout<<"warning"<<endl;
  }

  return 0;
}