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 <string>
#include <cmath>
using namespace std;

double degree(int h, int m) {
	double s = m * 6;
	double l = h * 30 + m * 0.5;
	double d = abs(l - s);
	if (d > 180) d = 360 - d;
	return d;
}

string judge(int h, int m) {
	double d = degree(h, m);
	if (d < 30) return "alert";
	else if (d < 90) return "warning";
	return "safe";
}

int main() {
	int n; cin >> n;
	while (n--) {
		int h, m; char d;
		cin >> h >> d >> m;
		cout << judge(h, m) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	double n,h,t,ans;
	char c;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%lf%c%lf",&h,&c,&t);
		h=h*30+(0.5*t);
		t=t*6;
		cout<<h<<" "<<t<<endl;
		if(h<t)swap(h,t);
		ans=h-t;
		if(ans>180)ans-=180;
		if(0.0<=ans&&ans<=30.0){
			cout<<"alert"<<endl;
		}else if(90.0<=ans&&ans<180.0){
			cout<<"safe"<<endl;
		}else{
			cout<<"warning"<<endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include <math.h>
int main(){
    int n,i;
    scanf("%d",&n);
    for (i=0; i<n; i++) {
        int h,m;
        double x;
        scanf("%d:%d",&h,&m);
        x=fmod(5.5*(60*h+m),360);
        if ((x>=0&&x<30)||x>330) {
            printf("alert\n");
        }else if (x>=90&&x<=270){
            printf("safe\n");
        }else{
            printf("warning\n");
        }
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
 
int main() {
  int Tc; cin >> Tc;
  int H, M;
	char c;
   
  while(Tc --) {
    //scanf("%d:%d", &H, &M);
     cin >> H >> c >> M;
    double h = H*30.0 + M/2.0, m = M*6;
     
    int ang = abs(h - m);
    if(ang > 180) ang = 360 - ang;
    if(0 <= ang && ang < 30) {
      cout << "alert" << endl;
    }
    else if(90 <= ang && ang <= 180) {
      cout << "safe" << endl;
    }
    else cout << "warning" << endl;
  }
   
  return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  double h,m;
  char c;
  rep(i,n){
    cin >> h >> c >> m;
    h = 30 * h + 0.5*m;
    m = 6 * m;
    double angle = min(360-abs(h-m),abs(h-m));
    if(angle < 30.0){
      cout << "alert"<<endl;
    }
    else if(angle< 90.0){
      cout << "warning"<<endl;
    }
    else{
      cout << "safe"<<endl;
    }
  }
  return 0;
}

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

int main() {
	int n;
	double a,b,d;
	char c;
	cin >> n;
	for (;n>0;n--) {
	scanf("%lf%c%lf",&a,&c,&b);
	a= a>=12 ? a-12 : a;
	a=a*30+b*0.5; b*=6;
	if (a>b) { d=a; a=b; b=d;}
	b-=a;
	b= b>180 ? 360-b : b;
	if (b<30) cout << "alert" << endl; else
		if (b>=90) cout << "safe" << endl; else cout << "warning" << endl;
	}
return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    for (int i=0;i<n;i++) {
        double h,m;
        char c;
        cin>>h>>c>>m;
        double angle_h=30.0*h+30.0*m/60.0;
        double angle_m=m*6;
        double angle=min(abs(angle_h-angle_m),abs(angle_m-angle_h));
        if (angle>=180) {
            angle=360-angle;
        }
        //cout<<angle_h<<" "<<angle_m<<" "<<angle<<endl;
        if (angle<30) {
            cout<<"alert"<<endl;
        } else if (angle>=90&&angle<=180) {
            cout<<"safe"<<endl;
        } else {
            cout<<"warning"<<endl;
        }
    }
}

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

int n,h,m;
double rh, rm, r;

int main(){
	cin >> n;
	for (int t = 0; t < n; t++) {
		scanf(" %d:%d", &h, &m);
		rh = h * 30 + m * 0.5;
		rm = m * 6;
		r = abs(rh - rm);
		if (r < 30 || r > 330) {
			cout << "alert" << endl;
		}
		else if(r >= 90 && r <= 180) {
			cout << "safe" << endl;
		}
		else {
			cout << "warning" << endl;
		}
	}

	return 0;
}

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

int main(){
	//Input
	int N;
	std::cin >> N;

	int H, M;
	while(N--){
		scanf("%d:%d",&H,&M);
		//Processing
		//ツ角ツ度ツづーツ仰づ淞づゥ
		double aH = 30 * H, aM = 6 * M, a;
		std::cout << aH << "," << aM << std::endl;
		if(aH > aM){
			a = aH - aM;
		}
		else{
			a = aM - aH;
		}

		//ツ甘ォツ個ッツつウツづーツ板サツ津ィ
		std::string res;
		if(a >= 0 && a <= 30){
			res = "alert";
		}
		else if(a >= 90 && a <= 180){
			res = "safe";
		}
		else{
			res = "warning";
		}

		std::cout << res << std::endl;
	}
}

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int T; cin >>T;
  REP(t, T){
    string s; cin >>s;
    int h = atoi(s.substr(0, 2).c_str());
    int m = atoi(s.substr(3).c_str());
    double d = fabs((h * 30.0 + m * 0.5) - m * 6.0);
    d = min(d, 360.0 - d);
    cout <<(d >= 0.0 && d < 30.0 ? "alert" : (d >= 90.0 && d <= 180.0 ? "safe" : "warning")) <<endl;
  }
  return 0;
}