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<algorithm>
using namespace std;
int n,h,m;
int a,b,c,d;
char ch;
int main(){
  cin>>n;
  while(n--){
    cin>>h>>ch>>m;
    a=h*30+(m/15)*6;
    b=m*6;
    
   
    c=max(a,b)-min(a,b);
    if(c>180){
      c=min(a,b)+360-max(a,b);
    }

    //cout << a<< ' '<<b<<' '<<c<<endl;
    
    if(0<=c&&c<30){
      cout<<"alert"<<endl;
    }else if(90<=c&&c<=180){
      cout<<"safe"<<endl;
    }else{
      cout<<"warning"<<endl;
    }
    
  }
  return 0;
}

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

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


const string ALERT = "alert";
const string SAFE = "safe";
const string WARNING = "warning";

string solve( string s ) {
    replace( s.begin(), s.end(), ':', ' ' );
    ISS iss( s );
    int hh, mm;
    iss >> hh >> mm;

    double ang1 = 360.0 * ( (double)hh * 60.0 + (double)mm ) / 720.0;
    double ang2 = 360.0 * (double)mm / 60.0;
    double diff = fabs( ang1 - ang2 );

    if ( diff > 180.0 ) diff = 360.0 - diff;
    if ( diff < 30.0 ) return ALERT;
    if ( diff >= 90.0 ) return SAFE;
    return WARNING;
}

int main() {
    int n;
    cin >> n;
    for ( int i = 0; i < n; ++ i ) {
        string s;
        cin >> s;
        cout << solve( s ) << endl;
    }
    return 0;
}

C++: #include <cstdio>
int main(){
	int n,h,m;
	scanf("%d",&n);
	for(;n--;){
		scanf("%d:%d",&h,&m);
		double s=h*30+m/2.,l=m*6,t,d;
		l<s?t=l,l=s,s=t:0;
		d=s-l+360;
		l-s<d?d=l-s:0;
		d<30?
			puts("alert")
		:
			d<90?
				puts("warning")
			:
				puts("safe");
	}
}

C++: 
#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;
    
    double 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 <string>
using namespace std;

int main()
{
	int n;

	while( cin >> n ){
		for( int i = 0; i < n; ++i ){
			int h, m;
			char dummy;
			cin >> h >> dummy >> m;

			int hAngle = h * 300 + m * 10 / 4;
			int mAngle = m * 10 * 360 / 60;
			int angle = hAngle > mAngle ? hAngle - mAngle : mAngle - hAngle;
			string message;
			if( ( angle < 300 && angle >= 0 ) || ( angle <= 3600 && angle > 3300 ) ){
				message = "alert";
			}else if( ( angle >= 900 && angle <= 2700 ) ){
				message = "safe";
			}else{
				message = "warning";
			}

			cout << message << endl;
		}
	}

	return 0;
}

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

int main(){
  int n;
  double 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 = h*30+m*0.5;
    m = m*6;
   
    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;
}



/*
時計の針は

いきなりうごくわけじゃあない

ps.
DIOの再来が怖くて夜も眠れない
 */

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++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    int n; cin >> n;
    double h, m;
    char t;
    double lv, sv;
    REP(n)
    {
        cin >> h >> t >> m;
        lv = m * 360 / 60;//[deg]

        sv = (h * 360 / 12) + m * 30/60;
        
        double dd = fabs(lv - sv);
        if(dd > 180) dd = 360 - dd;
        if(fabs(dd) < 30) { cout << "alert" << endl; continue;}
        if(fabs(dd) < 90) { cout << "warning" << endl; continue;}
        cout << "safe" << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int n,h,m;
int a,b,c,d;
char ch;
int main(){
  cin>>n;
  while(n--){
    cin>>h>>ch>>m;
    a=h*30+(m/12)*6;
    b=m*6;
    
   
    c=max(a,b)-min(a,b);
    if(c>180){
      c=min(a,b)+360-max(a,b);
    }

    //cout << a<< ' '<<b<<' '<<c<<endl;
    
    if(0<=c&&c<30){
      cout<<"alert"<<endl;
    }else if(90<=c&&c<=180){
      cout<<"safe"<<endl;
    }else{
      cout<<"warning"<<endl;
    }
    
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
#include <cmath>
#include <cstdio>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;

int main(){
	int n;
	cin >> n;
	rep(i, n){
		int h, m;
		char c;
		cin >> h >> c >> m;
		int l = 60*h+m;
		int s = 12*m;
		if(l < s) swap(l, s);
		int dif = min(l-s, s-l+720);
		string mes;
		if(dif < 60) mes = "alert";
		else if(dif >= 180) mes = "safe";
		else mes = "warning";
		cout << mes << endl;
	}



    return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n;
double a,b,ans;
int main(){
	cin>>n;
	rep(i,n){
		scanf("%lf:%lf",&a,&b);
		ans=min(abs(((a*60+b)*0.5 )-b*6),360-abs(((a*60+b)*0.5 )-b*6));
		if(0<=ans&&ans<30.0){cout<<"alert"<<endl;}
		else if(90.0<=ans&&ans<=180.0){cout<<"safe"<<endl;}
		else{cout<<"warning"<<endl;}
	}
}

C++: #include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int n;
    cin>>n;
    while(n--){
        int h,m;
        scanf("%d:%d",&h,&m);
        double h_angle,m_angle;
        h_angle = h/12.0 + m/720.0;
        m_angle = m/60.0;
        double d = fabs(h_angle - m_angle);
        if(d - (1.0/6) < 1e-8)cout<<"alert"<<endl;
        else if(d - (1.0/4) < -1e-8)cout<<"warning"<<endl;
        else cout<<"safe"<<endl;
    }


    return 0;
}