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<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#define act(a,b) (abs((a)-(b))>360?720-abs((a)-(b)):abs((a)-(b)))
using namespace std;
int main(){
  int i;
  int n;
  vector<int> h,m;
  cin>>n;
  h.reserve(n);
  m.reserve(n);
  for(i=0;i<n;i++)
    scanf("%d:%d",&h[i],&m[i]);
  for(i=0;i<n;i++){
    if(act(h[i]%12*60+m[i],m[i]*12)<60)
      puts("alert");
    else if(act(h[i]%12*60+m[i],m[i]*12)<180)
      puts("warning");
    else
      puts("safe");
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  int n;
  double a,b;
  cin>>n;
  while(n--){
    scanf("%lf:%lf",&a,&b);
    a*=5;
    a+=b/60;
    int y=abs(b-a),x=abs(60-b+a);
    if(min(y,x)<5)cout<<"alert"<<endl;
    else if(min(y,x)<15)cout<<"warning"<<endl;
    else cout<<"safe"<<endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	double n,h,t,ans;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%lf:%lf",&h,&t);
		h=h*30+(0.5*t);
		t=t*6;
		if(h<t)swap(h,t);
		ans=h-t;
		if(ans>180)ans=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 <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()
{
  rep(i, in()){
    int h, m;
    scanf("%d:%d", &h, &m);
    h *= 30;
    m *= 6;
    int 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>
using namespace std;

int main() {
	int n;
	double h, m;
	double ha, ma;
	double x;
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%lf:%lf", &h,&m);
		ha = 30 * h + (m / 2);
		ma = m * 6;
		x = ma - ha;
		if (x < 0) { x*= -1;}
		if (x > 180) {
			x*=-1;
		x += 360;
		}
		if (x >= 0 && x < 30) { cout << "alert" << endl; }
		else if (x >= 90 && x <= 180) { 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(){
   int 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 <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	double h,m;
	rep(i,0,n){
		scanf("%lf:%lf",&h,&m);
		if(h>=12) h-=12;
		h=30*h+0.5*m;
		m=6*m;
		double ans=abs(h-m);
		//o(ans);
		if(ans>180) ans=360-ans;
		if(ans<30) o("alert");
		else if(ans>=90) o("safe");
		else o("warning");
	}
}

C++: #include <math.h>
#include <cstdio>
#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 <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

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

int main(){
	int n;
	cin >> n;
	rep(q, n){
		string s;
		cin >> s;
		int h, m;
		h = stoi(s.substr(0, 2)); m = stoi(s.substr(3, 2));
		double a, b;
		a = 360/(60./m); b = 360/(12./h) + 30/(60./m);
		if(abs(a-b) < 30) cout << "alert" << endl;
		else if(abs(a-b) < 90) cout << "warning" << endl;
		else cout << "safe" << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,h,m;
char com;
double s,l;

int main(){
	cin>>n;
	while(cin>>h>>com>>m){
		s=6.0*m;
		l=0.5*(h*60+m);
		double a=l-s;
		if(a<0)a*=-1;
		a=min(a,180.0);
		if(a<30)cout<<"alert"<<endl;
		else if(a<90)cout<<"warning"<<endl;
		else cout<<"safe"<<endl;
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

int main() {
  int Tc; cin >> Tc;
  int H, M;
  
  while(Tc --) {
    scanf("%d:%d", &H, &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;
}