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++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)

typedef unsigned long long ull;

int main(){
	int n; cin>>n;
	FOR(i,n){
		int x,y;
		scanf("%d:%d",&x,&y);
		double h = (x * 60 + y) / (60.0 * 12) * 360.0;
		double m = y * 6.0;
		double df = abs(h-m);
		df = min(df,360-df);
		if(df < 30) puts("alert");
		else if(df >= 90) puts("safe");
		else puts("warning");
	}

	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=360-c;
    }
 
    //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 <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EPS (1e-8)

int getNum(string str, int pos) {
	return (str[pos] - '0') * 10 + str[pos + 1] - '0';
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		string str;
		cin >> str;
		int h = getNum(str, 0), m = getNum(str, 3);
		
		double angle1 = m * 6.0, angle2 = h * 30.0 + m / 2.0;
		double div = min(abs(angle1 - angle2), 360.0 - abs(angle1 - angle2));
		cout << div << endl;
		
		if (div >= 0 && div < 30.0)
			puts("alert");
		else if (div >= 90.0 && div <= 180.0)
			puts("safe");
		else
			puts("warning");
	}
	return 0;
}

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

int main()
{
	int n; std::cin >> n;
	for (int i=0; i<n; i++) {
		int h, m;
		scanf("%d:%d", &h, &m);
		float dh = 30.0 * (float)h + 0.5 * (float)m;
		float dm = 6.0 * (float)m;
		float d = std::abs(dm - dh);
		if ((0.0 <= d && d < 30.0) || (330.0 < d && d <= 360.0)) std::cout << "alert" << std::endl;
		else if ((30.0 <= d && d < 90.0) || (270.0 < d && d <= 330.0)) std::cout << "warning" << std::endl;
		else std::cout << "safe" << std::endl;
	}
	
	return 0;
}

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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main() {

  int n;
  cin>> n;
  while(n--) {
    int l_hand, s_hand;
    double l_angle, s_angle;
    double angle;

    scanf("%d:%d",&l_hand, &s_hand);
    l_angle = (double)l_hand*30 + (double)s_hand*0.5;
    s_angle = (double)s_hand*6;
    angle = abs(l_angle-s_angle);

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

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

double max( double a, double b )
{
    if( a > b )
        return a;
    else
        return b;
}

int main()
{
    int n;
    double a, b;
    string s;

    cin >> n;

    for( int i = 0; i < n; i++ )
    {
        cin >> s;
        a = ( s[0] - '0' ) * 10 + ( s[1] - '0' );
        b = ( s[3] - '0' ) * 10 + ( s[4] - '0' );
        a = a * 30 + b * 0.5;
        b *= 6;
        double diff = max( a - b, b - a );
        
         if( diff > 180 )
             diff = 360 - diff;

        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<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 <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

const double EPS=1e-10;

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		int h,m;
		scanf("%d:%d",&h,&m);
		//~ð720ª
		int ha=h*60+m;
		int ma=m*12;
		int da=abs(ha-ma);
		da=min(da,720-da);
		if(da<60)
			cout<<"aleart"<<endl;
		else if(da>=180)
			cout<<"safe"<<endl;
		else
			cout<<"warning"<<endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

const double EPS=1e-10;

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		int h,m;
		scanf("%d:%d",&h,&m);
		double ha=(h+m/60.0)*2*M_PI/12;
		double ma=m*2*M_PI/60.0;
		double da=abs(ha-ma);
		if(cos(da)>sqrt(3)/2+EPS)
			cout<<"aleart"<<endl;
		else if(cos(da)+EPS<0)
			cout<<"safe"<<endl;
		else
			cout<<"warning"<<endl;
	}
	
	return 0;
}