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 <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	double h,m;
	rep(i,0,n){
		scanf("%lf:%lf",&h,&m);
		if(h>=12) h-=12;
		h=30*h+0.5*m;
		m=6*m;
		double ans=abs(h-m);
		o(ans);
		if(ans>180) ans=360-ans;
		if(ans<30) o("alert");
		else if(ans>=90) o("safe");
		else o("warning");
	}
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

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

double cross(const xy_t &a, const xy_t &b){
	return imag(conj(a) * b);
}

double dot(const xy_t &a, const xy_t &b){
	return real(conj(a) * b);
}

xy_t projection(const line &l, const xy_t &p){
	double t = dot(p - l.first, l.first - l.second) / norm(l.first - l.second);
	return l.first + t * (l.first - l.second);
}

bool intersectSP(const line &l, const xy_t &p){
	return abs(l.first- p) + abs(l.second - p) - abs(l.first - l.second) < EPS;
}

double distanceSP(line s, xy_t p){
	const xy_t r = projection(s, p);
	if(intersectSP(s, r)) return abs(r - p);
	return min(abs(s.first - p), abs(s.second - p));
}

int main(){
	int n;
	cin >> n;
	string s;
	rep(i, n){
		cin >> s;
		int h = (s[0]-'0') * 10 + s[1] - '0';
		int m = (s[3]-'0') * 10 + s[4] - '0';
		double angle1 = h * 30 + (double)m / 10;
		double angle2 = m * 6;
		double d = abs(angle1 - angle2);
		if(d > 180.0) d = 360.0 - d;
		if(d < 30.0) {
			cout << "alert" << endl;
		}else if(90.0 - EPS < d) cout << "safe" << endl;
		else cout << "warning" << endl;
	}
	return 0;
}

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

std::pair<int, int> stot(const std::string &str) {
	auto idx = str.find(':');
	return std::make_pair<int, int>(stoi(str.substr(0, idx)), stoi(str.substr(idx + 1)));
}

int main() {
	int n;
	std::cin >> n;
	for (auto i = 0; i < n; ++i) {
		std::string arg;
		std::cin >> arg;
		auto time = stot(arg);
		auto dist = (time.first * 60 - time.second * 11) * (time.first * 60 - time.second * 11);
		if (dist < 3600) {
			std::cout << "alert\n";
		}
		else if (dist >= 32400) {
			std::cout << "safe\n";
		}
		else {
			std::cout << "warning\n";
		}
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s;
    while (n--) {
        cin >> s;
        int h = (s[0] - '0') * 10 + (s[1] - '0');
        int m = (s[3] - '0') * 10 + (s[4] - '0');
        int d = abs(60 * h - 11 * m);
        if (360 <= d) {
            d = 720 - d;
        }
        if (d < 60) {
            cout << "alert" << endl;
        } else if (d < 180) {
            cout << "warning" << endl;
        } else {
            cout << "safe" << endl;
        }
    }
    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);
  double r=abs(A-B);
  if(r>180)r=360-r;

  if(0<=r&&r<=30)cout<<"alert"<<endl;
  else if(90<=r&&r<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 = ( hh * 60.0 + mm ) / 720.0 * 360.0;
    double ang2 = mm / 60.0 * 360.0;
    double diff = fabs( ang1 - ang2 );

    if ( diff > 180.0 ) diff = 360.0 - diff;
    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 <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);
		if(da<60)
			cout<<"aleart"<<endl;
		else if(da>=180)
			cout<<"safe"<<endl;
		else
			cout<<"warning"<<endl;
	}
	
	return 0;
}