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 <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n, h, m;

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

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=(b-a+360) % 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<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/10;
    b=m*6;
    //cout << a<< ' '<<b<<endl;
   
    c=max(a,b)-min(a,b);
    if(c>180)c=180-c;

    //cout<<c<<endl;

    if(c<30){
      cout<<"alert"<<endl;
    }else if(90<=c&&c<=180){
      cout<<"safe"<<endl;
    }else{
      cout<<"warning"<<endl;
    }
  }
  return 0;
}

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

const double pi = acos(-1);

int main() {
  int n;
  scanf("%d", &n);
  while(n--) {
    int h, m;
    scanf("%d:%d", &h, &m);
    double rh = (h+m/60.0)/6.0;
    double rm = m/30.0;
    double rad = min(abs(rh-rm), abs(fmod(rh+1,2)-fmod(rm+1,2)));
    if(rad < 1.0/6.0) {
      cout << "alert" << endl;
    } else if(1.0/2.0 <= rad && rad <= 1.0) {
      cout << "safe" << endl;
    } else {
      cout << "warning" << endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<ios>
#include<algorithm>
using namespace std;
int n;
main()
{
	cin>>n;
	for(;n--;)
	{
		int h,m;
		scanf("%d:%d",&h,&m);
		int dm=m*12;
		int dh=h*60+m;
		int a=abs(dm-dh);
		if(a>360)a=720-a;
		cout<<(a<60?"alert":a>=180?"safe":"warning")<<endl;
	}
}

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

int main()
{
  int n;
  cin>>n;
  for(;n--;)
    {
      int h,s;
      char buf;
      cin>>h>>buf>>s;
      //cout<<h<<" "<<s<<endl;
      double hr=h*(360/12.0)+s*(30/60.0);
      double sr=s*(360/60.0);
      //      cout<<hr<<" "<<sr<<endl;
      if(hr<sr)
	swap(hr,sr);
      double diff=min(hr-sr,360-hr+sr);
      //      cout<<diff<<endl;
      if(diff<30)
	cout<<"alert"<<endl;
      else if(diff>=90)
	cout<<"safe"<<endl;
      else
	cout<<"warning"<<endl;
    }

}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n;
  cin>>n;
  REP(i,n){
    int h,m;
    scanf("%d:%d",&h,&m);
    if(h>=12) h -= 12;
    double t1 = h * 30 + (double)m/2;  
    double t2 = m * 6; 
    if(abs(t1-t2)<30||abs(t1-t2)>330){
      cout<<"alert"<<endl;
    }else if(abs(t1-t2)>=90&&abs(t1-t2)<=270){
      cout<<"safe"<<endl;
    }else{
      cout<<"warning"<<endl;
    }
  }
  return 0;
}

C++: //include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
   double n,h,m,hantei;
   char c;
   cin >> n;
   rep(i,n){
      cin >> h>>c>>m;
      h=360*h/12+360*m/12/60;
      m=360*m/60;
      hantei=abs(h-m);
      if(hantei>180) hantei=360-hantei;
      if(hantei<30) cout << "alert" << endl;
      else if(hantei<90) cout << "warning" << endl;
      else cout << "safe" << endl;
   }
}

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

int main(){
  int t,h,m;
  double l,s,ans;

  scanf("%d",&t);
  while(t--){
    scanf("%d:%d",&h,&m);
    s = m*6;
    l = h*30 + (double)m/2;

    ans = l-s;
    if(ans<0.0)ans *= -1.0;
    if(ans>180.0)ans = 360.0 - ans;

    if(ans<30.0)printf("alert\n");
    else if(ans<90.0)printf("warning\n");
    else printf("safe\n");
  }
}