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<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<sstream>


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

#define PII pair<int,int>
#define PP pair< int,PII >


using namespace std;



int main(){
	int n;
	int h,m;
	scanf("%d", &n);
	rep(i,n){
		int flag = 0;
		double x,y;
		scanf("%d:%d", &h, &m);
		
		x = 30*h+m/2.0;
		y = m*6;
		
		if(x-30 < y && y < x+30){
			cout << "alert" << endl;
		}else if(x-390 < y && y < x-330){
			cout << "alert" << endl;
		}else if(x-90 < y && y < x+90){
			cout << "warning" << endl;
		}else if(x-470 < y && y < x-270){
			cout << "warning" << endl;
		}else{
			cout << "safe" << endl;
		}
		
	}
	
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int n;
	int hour,minute;
	char d;
	double kakuh,kakum,sa;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> hour >> d >> minute;
		kakuh = 30.0 * hour + minute * 0.5;
		kakum = 6.0 * minute;
		sa = abs(kakuh-kakum);
		if (sa > 180.0) {
			sa = sa - 180;
		}
		if (sa <30.0) {
			cout << "alert" << endl;
		} else if (sa >= 90.0) {
			cout << "safe" << endl;
		} else {
			cout << "warning" << endl;
		}
	}
	return 0;
}

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

int main()
{
	int n;
	double t, m;
	double AngleT = 360.0/12.0;
	double AngleT2 = 360.0/12.0/60.0;
	double AngleM = 360.0/60.0;
	double dif;
	cin>>n;
	while (scanf("%lf:%lf",&t,&m) != EOF) {
		dif = t*AngleT + m*AngleT2 - m*AngleM;
		if (dif<0.0) dif*=-1;
		if (dif>180.0)dif -= 360.0;
		if (dif<0.0) dif*=-1;
		if (dif<30.0) cout<<"alert"<<endl;
		else if (dif<90.0) cout<<"warning"<<endl;
		else cout<<"safe"<<endl;
	}
	return 0;
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    rep(_,n){
        char a,b,g,c,d; cin>>a>>b>>g>>c>>d;
        double h=(a-'0')*10+(b-'0');
        double m=(c-'0')*10+(d-'0');
        double hoge=h*30;
        h=m/2.0+hoge;
        m*=6;
        double cal=min(abs(h-m),360-abs(h-m));
        cout<<cal<<endl;
        if(0<=cal&&cal<=30)cout<<"alert"<<endl;
        else if(90<=cal&&cal<=180)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}

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

int main() {
  int n, h, m;
  double hr, mr, dr;
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    scanf("%d:%d", &h, &m);
    mr = m * 6;
    hr = h * 30 + m * 0.5;
    dr = fabs(mr - hr);
    if (dr > 180.0) {
      dr = 360.0 - dr;
    }
    if (dr < 30.0) {
      printf("alert\n");
    } else if (dr < 90.0) {
      printf("warning\n");
    } else {
      printf("safe\n");
    }
  }
  return 0;
}

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

int main(){

	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++){
		int h, m;
		scanf("%d:%d", &h, &m);

		double ang ;
		ang = 6 * m - (30 * h + 30 * ((double)m / 60));
		ang = std::abs(ang);

		if (0 <= ang && ang < 30)printf("alert\n");
		else if (90 <= ang && ang <= 180)printf("safe\n");
		else printf("warning\n");
	}

	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  for (int dataset=0; dataset<n; dataset++)
  {
    char dummy;
    int hour,minutes;
    cin >> hour >> dummy >> minutes;

    int hour_angle = hour * 30 + minutes / 2;
    int minutes_angle = minutes * 6;
    int angle_diff = hour_angle - minutes_angle;

    if ( -30 < angle_diff && angle_diff < 30 )
    {
      cout << "alert" << endl;
    }
    else if ( ( 90 <= angle_diff && angle_diff <= 180 ) || ( -90 <= angle_diff && angle_diff <= -180 ) )
    {
      cout << "safe" << endl;
    }
    else
    {
      cout << "warning" <<endl;
    }
  }
}

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 > 180.0 || fabs( diff - 180.0 ) < 1e-9 ) 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 <cstdio>
#include <cmath>

using namespace std;

#define EPS 1e-6

int main(){
  int n;

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

    double key = fabs(l-s) + EPS;

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

  return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int a, b, n;
double d, e, f;
int main() {
	cin >> n;
	for (int i = 0; i < n;i++) {
		scanf("%d:%d", &a, &b);
		d = b * 6;
		e = 1.0*(a * 30 + b) / 2.0;
		f = abs(d - e);
		if (f > 180) { f = 360 - f; }
		if (f < 30) { cout << "alert" << endl; }
		else if (f < 90) { cout << "warning" << endl; }
		else { cout << "safe" << endl; }
	}
}