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"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

vector<string> split(string s,char ch){
    vector<string> ret;
    string tmp ="";
    rep(i,s.size()){
        if(s[i]==ch){
            ret.pb(tmp);
            tmp = "";
        }else tmp+=s[i];
    }
    if(tmp.size())ret.pb(tmp);
    return ret;
}

int main(){
    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        vector<string> list = split(s,':');
        int h,m;
        h = stoi(list[0]);
        m = stoi(list[1]);

        int x,y;
        x = 60*m;
        y = 300*h+5*m;
        x%=3600;
        y%=3600;
        
        if( abs(x-y)<300 || abs(x-y)>3300 )cout<<"alert"<<endl;
        else if( 900<=abs(x-y) && abs(x-y)<=2700)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}

C++: #include <iostream>

using namespace std;

int main(void){
	int n;
	
	cin >> n;
	for(int i=0;i<n;i++){
		int hh,mm;
		double l,s,arg;
		cin >> hh;
		cin.ignore();
		cin >> mm;
		
		l = mm*6;
		s = hh*30+mm*0.5;
		l>s?arg = l-s:arg= s-l;
		
		if(arg > 180){
			arg = 360-arg;
		}
		if(arg < 30){
			cout << "alert" << endl;
		}else if(90 <= arg){
			cout << "safe" << endl;
		}else{
			cout << "warning" << endl;
		}
	}
}

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

using namespace std;

double topos(int in,int num){
  if(num) return in * 6;
  return in*30;
}

void solve(double h, double m){
  double judge =fabs(h-m);
  if(judge > 180) judge = 360 - judge;
  // cout << judge << endl;
  if(judge < 30) cout << "alert" << endl;
  else if(judge < 90) cout << "warning" << endl;
  else cout << "safe" << endl;
}

int main(){
  int in;
  cin >> in;
  for(int i = 0; i < in; i++){
    int hour,minite;
    char trash;
    cin >> hour >> trash >> minite;
    //cout << hour << " " << trash << " " << minite<<endl;
    double pos = topos(minite,1);
    double posh = topos(hour,0);
    posh += (double)minite/2;
    solve(posh,pos);
  }
  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 hour = time.first * 60 + time.second, minute = time.second * 12;
		auto dist = (hour - minute) * (hour - minute);
		if (dist < 3600 || dist > 435600) {
			std::cout << "alert\n";
		}
		else if (dist < 32400 || dist > 291600) {
			std::cout << "warning\n";
		}
		else {
			std::cout << "safe\n";
		}
	}
	return 0;
}

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

int main(){
	int h,m;
	int n;
	double l,s;
	cin >> n;
	while(n--){
		scanf("%d:%d",&h,&m);
		l = m * 0.5 + h * 30.0;
		s = m * 6 ;
		
		if(fabs(l-s)<30.0){
			cout << "alert" << endl;
		}else if(fabs(l-s)<90.0){
			cout << "warning" << endl;
		}else{
			cout << "safe" << endl;
		}
	}
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n;
	int s, t;
	
	cin >> n;
	while(n--){
		scanf("%d:%d", &s, &t);
		
		s *= 30;
		t *= 6;
		s -= t;
		if(s < 0){
			s = -s;
		}
		
		if(s <= 30){
			cout << "alert" << endl;
		} else if(s < 90){
			cout << "warning" << endl;
		} else {
			cout << "safe" << endl;
		}
	}
}

C++: 4
02:15
06:01
11:55
10:40

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

string func(int s, int l){
	double h = s*30.0 + l/2.0, m = l*6;
     
    int ang = abs(h - m);
    if(ang > 180) ang = 360 - ang;
    if(0 <= ang && ang < 30) {
      return "alert";
    }
    else if(90 <= ang && ang <= 180) {
      return "safe";
    }
    else return "warning";
}
 
int main() {
	int n, s, l; cin >> n;
	char c;
	while(n--) {
		cin >> s >> c >> l;
		cout << func(s, l) << endl;
	}
  	return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        rep(i,n){
            double hour, mini;
            scanf("%lf%*c%lf", &hour, &mini);
            double angle = hour * 360 / 12 - mini * 360 / 60;
            if(angle < 0) angle*= -1;
            if(angle >= 0 && angle < 30)
                cout << "alert" << endl;
            else if(angle >= 90 && angle <= 180)
                cout << "safe" << endl;
            else
                cout << "warning" << endl;
        }
    }
}

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

int main(){
	long 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;
		double sita=abs(tyousin-tansin);
		if(sita>180)sita=360-sita;
		if(0<=sita &&sita<30)cout<<"alert"<<endl;
		else if(sita>=90 && sita<=180)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>
#include <string.h>


using namespace std;


int main(){
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        string temp;
        cin>>temp;
        int h=(temp[0]-'0')*10+(temp[1]-'0');
        int m=(temp[3]-'0')*10+(temp[4]-'0');
        
        double h_angle;
        h_angle = 360.0/12.0 * h + (360.0/12.0)/60.0 * m;
        double m_angle;
        m_angle = 360.0/60.0 * m;
        
        double angle = max(h_angle,m_angle)-min(h_angle,m_angle);
        if(angle>180.0)angle=360.0-angle;
        
        if(angle<30.0)cout<<"alert"<<endl;
        else if(angle>90.0)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;

    }
}

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

string func(int M, int H){
	/*double a = l * 6;
	double b = s * 30.0 + l / 2.0;
	int m = abs(a - b);
	if(180 < m)m = 360 - m;
	if(0 <= m && m < 30)return "alert";
	if(90 <= m && m <= 180)return "safe";
	return "waring";
	if(m > 180)m = 360 - m;
	if(30 <= m){
		if(90 <= m)return "safe";
		return "warning";
	}
	return "alert";*/
	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;
}

int main(){
	int n, s, l;cin >> n;
	char c;
	while(n--){
		cin >> s >> c >> l;
		func(s, l);
	}
	return 0;
}