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 <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int n;
	cin >> n;
	REP(i, n) {
		double h, m;
		char c;
		cin >> h >> c >> m;

		double hr = 30*h+30*(m/60);
		double mr = 6*m;

		double res = max(hr, mr)-min(hr, mr);
		res = min(res, 360-res);

		if(res < 30) {
			cout << "alert" << endl;
		} else if(res < 90) {
			cout << "warning" << endl;
		} else {
			cout << "safe" << endl;
		}
	}

	return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
int main(){
	int hh,mm;
	char c;
	int n;
	cin>>n;
	rep(i,n){
		cin>>hh>>c>>mm;
		hh=30*hh+0.5*mm;mm*=6;
//		cout<<hh<<"-"<<mm<<"="<<abs(hh-mm)<<" "<<abs(hh-mm);
		if(abs(hh-mm)<=30)cout<<"alert";
		else if(90<=abs(hh-mm)&&abs(hh-mm)<=180)cout<<"safe";
		else cout<<"warning";
		cout<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  double n,a,b;
  cin>>n;
  while(n--){
    scanf("%lf:%lf",&a,&b);
    double c=abs(a*30+b/2-b*6);
    double 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>
#include <cmath>

using namespace std;

int main(){
  int n;

  scanf("%d" ,&n);
  while(n--){
    double h,m;
    scanf("%lf:%lf" ,&h ,&m);
    
    double l = 30*h+m/2;
    double s = m * 6.0;

    double key = fabs(l-s);
  
    if(0 <= key && key < 30){
      puts("alert");
    }else if(90 <= key && key <= 180){
      puts("safe");
    }else{
      puts("warning");
    } 
  }

  return 0;
}

C++: #include <cstdio>
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main()
{
	int n; scanf("%d", &n);
	rep(i, n) {
		int h, m; scanf("%d:%d", &h, &m);
		int ah = 60 * h + m;
		int am = 12 * m;
		int diff = ah - am; if (diff < 0) diff = -diff;
		if (diff > 360) diff -= 360;

		double d = 0.5 * diff;
		if (d < 30) puts("alert");
		else if (d < 90) puts("warning");
		else puts("safe");
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

double topos(int in){
  return in * 0.2;
}

void solve(double h, double m){
  if(h < m) swap(h,m);
  if(h - m <= 1.0) cout << "alert" << endl;
  else if(h - m < 3.0) cout << "warning" << endl;
  else cout << "safe" << endl;
}

int main(){
  int in;
  cin >> in;
  for(int i = 0; i < in; i++){
    int hour,minite;
    char trash;
    cin >> hour >> trash >> minite;
    //cout << hour << " " << trash << " " << minite<<endl;
    double pos = topos(minite);
    solve((double)hour,pos);
  }
  return 0;
}

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

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

using namespace std;

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

	rep(i,n)
	{
		double a,b;
		char c;
		cin >> a >> c >> b;

		double r = a*30 + b*6/12;
		double r2 = b*6;
		if(r2 < r) swap(r2,r);

		double rad = min(r2-r,360 - (r2-r));

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

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

signed main(){
	int N,H,M;
	cin>>N;
	for(int i=0;i<N;i++){
		scanf("%d:%d",&H,&M);
		double d;
		d = abs(360.0*(H%12)/12.0-360.0*M/60.0);
		if(d>180.0) d = 360.0-d;
		if(d<=30) puts("alert");
		else if(90<=d && d<=180) puts("safe");
		else puts("warning");
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
  int T;
  cin>>T;
  while(T--){
  int h,m;
  scanf("%d:%d",&h,&m);
  double A,B;
  A=360*(h/12.0);
  B=360*(m/60.0);
  if(abs(A-B)<30)cout<<"alert"<<endl;
  else if(abs(A-B)<90)cout<<"warning"<<endl;
  else cout<<"safe"<<endl;
  
  }
  return 0;
}

C++: // AOJ 0135 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0135)
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)

int h;

int main()
{
	scanf( "%d", &h );
	rep( i, h )
	{
		int hh, mm;
		scanf( "%d:%d", &hh, &mm );

		double diff = fabs(hh*30+mm/2.0-mm*6);
		diff = std::min( diff, 360-diff );

		puts( diff<30?"alert":diff<90?"warning":"safe" );
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  int n,a,b;
  cin>>n;
  while(n--){
    scanf("%d:%d",&a,&b);
    a*=5;
    int y=abs(b-a),x=abs(60-b+a);
    if(min(y,x)<=5)cout<<"alert"<<endl;
    else if(min(y,x)<=15)cout<<"warning"<<endl;
    else cout<<"safe"<<endl;
  }
}

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

int main(){
  int n,h,m;
  string s;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    cin >> s;
    int st = s[0] == '0'?1:0;
    h = (atoi)(s.substr(st,s[0]=='0'?1:2).c_str());
    st = s[3] == '0'?4:3;
    m = (atoi)(s.substr(st,s[3]=='0'?1:2).c_str());
    h *= 30;
    m *= 6;
    h += m/12.0;
    
    if(0<= abs(h-m)&& abs(h-m) < 30)cout << "alert" << endl;
    else if(90 <= abs(h-m ) && abs(h-m ) <= 180)cout << "safe" << endl;
    else cout << "warning" << endl;  


  }

  return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n=in();
	int i;
	for(i=0;i<n;i++){
		int h,m;
		scanf("%d:%d",&h,&m);
		int dis=abs(h*60-m*11);
		if(dis<60)cout<<"alert"<<endl;
		else if(dis>=180)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
	return 0;
}