// AOJ 0218
#include<iostream>

int main()
{
	int n, pm, pe, pj;
	while( std::cin >> n, n )
	{
		int rank;
		for( int i = 0; i != n; ++i )
		{
			std::cin >> pm >> pe >> pj;
			int ave = ( pm + pe + pj ) / 3;

			if( pm == 100 || pe == 100 || pj == 100 )
				rank = 0;
			else if( ( pm + pe ) / 2 >= 90 )
				rank = 0;
			else if( ave >= 80 )
				rank = 0;
			else if( ave >= 70 )
				rank = 1;
			else if( ave >= 50 && ( pm >= 80 || pe >= 80 ) )
				rank = 1;
			else
				rank = 2;

			std::cout << (char)('A' + rank) << std::endl;
		}
	}

	return 0;
}