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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n; cin >> n;
    rep(i,n){
        int h,m;
        scanf("%d:%d",&h,&m);
        h=h*60+m;
        m*=720/60;
        int dt=min(abs(h-m),(h+60*12-m));
        // cout << dt << endl;
        string ans;
        if(dt<60*1) ans = "alert";
        else if(dt>=60*3) ans = "safe";
        else ans = "warning";
        cout << ans << endl;
    }
}

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

double ang(double a, double b){
    return min(abs(a-b), 360-abs(a-b));
}

int main(){
    int n;
    for(scanf("%d",&n);n--;){
        double a, b;
        scanf("%lf:%lf",&a,&b);
        a = a*30 + b/20;
        b = b*6;
        if( ang(a,b) < 30 ) puts("alert");
        else if( ang(a,b) < 90 ) puts("warning");
        else puts("safe");
    }
    return 0;
}

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

int main(void){
	int n;
	
	cin>> n ;
	for(int i = 0 ; i < n ; i++){
		int a,b; char c;
		
		cin>>a>>c>>b;
//		cout<<a<<" "<<b<<endl;
		double A =a/12.0+b/60.0/12;
		double B =b/60.0;
		
		double judge =fabs(A-B);
//		if(180<judge)judge = 360.0 - judge;
//		cout<<judge<<endl;
	
		if(judge>0.5){
			judge = 1 - judge;
		}
		if(judge<30.0/360)cout<<"alert"<<endl;
		else if(judge<90.0/360)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>
using namespace std;

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int hh,mm;
		char cc;
		cin>>hh>>cc>>mm;
		double tyousin=mm*6;
		double tansin=hh*30+mm*0.5;
		int sita=abs(tyousin-tansin);
		if(sita>180)sita=360-sita;
		if(sita<30)cout<<"alert"<<endl;
		else if(sita>=90 &&sita<180)cout<<"safe"<<endl;
		else cout<<"warning"<<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(key > 180){
      key -= 180;
    }
  
    if(0 <= key && key < 30){
      puts("alert");
    }else if(90 <= key && key <= 180){
      puts("safe");
    }else{
      puts("warning");
    } 
  }

  return 0;
}

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

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int hh,mm;
		char cc;
		cin>>hh>>cc>>mm;
		double tyousin=mm*6;
		double tansin=hh*30+mm*0.5;
		int sita=abs(tyousin-tansin);
		if(sita<30)cout<<"alert"<<endl;
		else if(sita>=90 &&sita<180)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
	return 0;
}

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

int main(){

  int n;
  int h,m;
  char c;
  double a,b;
  double ans;

  cin >> n;

  for(int l=0;l<n;l++){
    cin >> h >> c >> m;
    b = m * 6;
    a = 30 * h + 0.5 * m;

    ans = max(a,b) - min(a,b);
    if(ans > 180) ans -= 180;

    if(ans < 30) cout << "alert";
    else if(ans >= 90) cout << "safe";
    else cout << "warning";
    cout << endl;
  }
}

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

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int h,m;
		char _;
		cin>>h>>_>>m;
		h%=12;
		int d=abs(h*60+m-12*m);
		if(d<30*2){
			cout<<"alert\n";
		}else if(d<90*2){
			cout<<"warning\n";
		}else{
			cout<<"safe\n";
		}
	}
	return 0;
}

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

using namespace std;

inline int toInt(string s) { stringstream ss(s); int x; ss >> x; return x; }

int main() {
  int n;
  string s;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> s;
    int sh = toInt(s.substr(0, 2));
    int lg = toInt(s.substr(3));
    double argSh = sh*5*6;
    double argLg = lg*6; argSh += argLg/12;
    
    double hen = abs(argSh-argLg);
    hen = min(hen, 360.0-hen);
    if(0<=hen && hen<30) cout << "alert" << endl;
    else if(90<=hen && hen) 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 = hh / 12.0 * 360.0 + mm / 60.0 * 30.0;
    double ang2 = mm / 60.0 * 360.0;
    double diff = fabs( ang1 - ang2 );

    if ( diff > 0.0 || fabs( diff ) < 1e-9 ) {
        if ( diff < 30.0 || fabs( diff - 30.0 ) < 1e-9 ) return ALERT;
    }
    if ( diff > 90.0 || fabs( diff - 90.0 ) < 1e-9 ) {
        if ( diff < 180.0 || fabs( diff - 180.0 ) < 1e-9 ) 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 <iostream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  vector<string> result;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int h, m;
    double rh, rm;
    scanf("%d:%d", &h, &m);
    // (m / 60 * 360) == (h * 6)                                                                                                                  
    rm = m * 6.0;
    rm += (rm > 180 ? -360 : 0);
    // (h / 12 * 360) == (h * 6)                                                                                                                  
    rh = h * 30.0;
    rh += m * 0.5;
    rh += (rh > 180 ? -360 : 0);
    double dis = rh - rm;
    dis *= (dis >= -0.0 ? 1 : -1);
    if (dis < 30.0)
      result.push_back("alert");
    else if (90.0 <= dis)
      result.push_back("safe");
    else
      result.push_back("warning");
  }

  for (int i = 0; i < n; i++)
    cout << result[i] << endl;
  return 0;
}