#include <stdio.h>

void dividing(int pm, int pe, int pj);

int main(void)
{
    int students_number;
    int pm[10000], pe[10000], pj[10000];
    scanf("%d", &students_number);
    while (1) {
        if (students_number == 0) {
            break;
        } else {
            for (int i = 0; i < students_number; ++i) {
                scanf("%d %d %d", &pm[i], &pe[i], &pj[i]);
            }
            for (int i = 0; i < students_number; ++i) {
                dividing(pm[i], pe[i], pj[i]);
            }
            scanf("%d", &students_number);
        }
    }
    return 0;
}

void dividing(int pm, int pe, int pj)
{
    char rank;
    if (pm == 100 || pe == 100 || pj == 100) {
        rank = 'A';
    } else if (pm + pe >= 90 * 2) {
        rank = 'A';
    } else if (pm + pe + pj >= 80 * 3) {
        rank = 'A';
    } else if (pm + pe + pj >= 70 * 3) {
        rank = 'B';
    } else if (pm + pe + pj >= 50 * 3 && (pm >= 80 || pe >= 80)) {
        rank = 'B';
    } else {
        rank = 'C';
    }
    printf("%c\n", rank);
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>>;
using GraphEdge = vector<vector<int>>;
long long modinv(long long a, long long m=MOD) {long long b = m, u = 1, v = 0;while (b) {    long long t = a / b;    a -= t * b; swap(a, b);    u -= t * v; swap(u, v);}u %= m; if (u < 0) u += m;return u;}
//MODの割り算の際にa/＝b;をa *= modinv(b,MOD);とする。
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int main(){
    int N;cin >> N;
    if(N==2){
        int a,b;cin >> a >> b;
        cout << a + b << endl;
    }else{
        puts("Hello World");
    }
    return 0;
}