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>

using namespace std;

int main(void){
	int n;
	
	cin>> n ;
	for(int i = 0 ; i < n ; i++){
		int a,b; char c;
		int judge;
		
		cin>>a>>c>>b;
//		cout<<a<<" "<<b<<endl;
		b*=360/60;
		a=a*360/12;
		judge=(a-b)%180;
	
		if(judge<0)judge=-1*judge;
//		cout<<judge<<endl;
	
//		cout<<a<<" "<<b<<" "<<judge<<endl;
		if(judge<30)cout<<"alert"<<endl;
		else if(judge<90)cout<<"warning"<<endl;
		else cout<<"safe"<<endl;
	}

}

C++: #include <iostream>
#include <cstdio>
#include <math.h>
int main(){
	//Input
	int N;
	std::cin >> N;

  double H, M;
	while(N--){
		scanf("%lf:%lf",&H,&M);
		//Processing
		//ツ角ツ度ツづーツ仰づ淞づゥ
		double aH = (60 * H + M) / 2, aM = 6 * M, a;
		//std::cout << aH << "," << aM << std::endl;
		a = std::min(fabs(aH-aM), 360-fabs(aH-aM));

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

		std::cout << res;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#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 <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second

main(){
  int n;
  cin>>n;
  while(n--){
    long double hh,mm;
    scanf("%Lf:%Lf",&hh,&mm);
    hh=30*hh+mm*0.5;
    if(hh>360){
      hh-=360;
      int k=3,i=0;
      printf("%d",k/i);
    }
    mm*=6;
    //cout<<hh<<":"<<mm<<endl;
    int diff=abs(hh-mm);
    if(diff>180)diff=360-diff;

    if(diff<=30)puts("alert");
    else if(diff>=90)puts("safe");
    else puts("warning");
  }
}

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++: #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/15)*6;
    b=m*6;
    
   
    c=max(a,b)-min(a,b);
    if(c>180){
      c=min(a,b)+360-max(a,b);
    }

    //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>

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

int main()
{
  // 1分で進む角度で考える
  // 長針 1分 => 6度
  // 短針 60分 => 30度 :: 1分 => 0.5度
  rep(i, in()){
    double h, m;
    scanf("%lf:%lf", &h, &m);
    h = (int)h * 30 + m / 2.0;
    m *= 6;
    double deg = min(abs(h - (360 - m)), abs(h - m));
    if (0 <= deg && deg < 30){
      puts("alert");
    }
    else if (90 <= deg && deg <= 180){
      puts("safe");
    }
    else {
      puts("warning");
    }
  }
  return 0;
}

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

int main() {
	int a,b,n;
	char c;
	cin >> n;
	for (;n>0;n--) {
	scanf("%d%c%d",&a,&c,&b);
	a*=30; b*=6;
	b=(720+b-a) % 360;
    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() {
	double n=0.5,m=6,n2=30;
	int a,b,n4,e=0;
	cin>>n4;
	for(int i=0;i<n4;i++){
		string d;
		cin>>d;
		d+=":";
		string h;
		e=0;
		for(int j=0;j<d.length();j++){
			if(d[j]==':'){
				if(e==0)
					a=atoi(h.c_str());
				else
					b=atoi(h.c_str());
				h="";
				e++;
			}
			else
				h+=d[j];
		}
		double n3,m3;
		n3=0;
		n3+=(a*n2+b*n);
		m3=0;
		m3+=b*m;
		double c=n3-m3;
		if(c<0)
			c=0-c;
		if(360-c<c){
			c=360-c;
		}
		if(c>=90&&c<=180)
			printf("safe\n");
		else if(c>=0&&c<30)
			printf("alert\n");
		else
			printf("warning\n");
	}
}

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

int main() {
	int h, m;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		scanf("%d:%d", &h, &m);
		double sh, lh;

		lh = 2 * M_PI * (m / 60.0);
		sh = 2 * M_PI * ((h * 60 + m) / (60.0 * 12));

		if(cos(lh - sh) > cos(M_PI / 6.0))
			cout << "alert" << endl;
		else if(cos(lh - sh) > cos(M_PI / 2.0))
			cout << "warning" << endl;
		else
			cout << "safe" << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  cin >> n;
  cin.ignore();
  while(n--) {
    int h,m;
    scanf("%d:%d\n",&h,&m);
    double angh = h * 30 + m / 2.0;
    double angm = m * 6;
    if (angh<angm) swap(angm,angh);
    double ang = min(angh-angm, angm-angh+360);
    if (ang < 30)
      cout << "alert";
    else if (ang >= 90)
      cout << "safe";
    else
      cout << "warning";
    cout << endl;
  }
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    int n; cin >> n;
    double h, m;
    char t;
    double lv, sv;
    REP(n)
    {
        cin >> h >> t >> m;
        lv = m * 360 / 60;//[deg]

        sv = (h * 360 / 12) + m * 15 / 60;
        
        double dd = fabs(lv - sv);
        if(dd > 180) dd = 360 - dd;
        if(fabs(dd) < 30) { cout << "alert" << endl; continue;}
        if(fabs(dd) < 90) { cout << "warning" << endl; continue;}
        cout << "safe" << endl;
    }

    return 0;
}