#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  int n,x,t;
  cin>>n>>x>>t;
  int times=(n+x-1)/x;
  int ans=times*t;
  cout<<ans<<endl;
}
#include<iostream>
using namespace std;

char getAns(int m,int e,int j){
	if(m==100||e==100||j==100)return 'A';
	if((m+e)/2>=90)return 'A';
	if((m+e+j)/3>=80)return 'A';
	if((m+e+j)/3>=70)return 'B';
	if((m+e+j)/3>=50&& (m>=80||e>=80))return 'B';
	return 'C';

}
int main(){
	int d;
	while(cin>>d){
		int pm,pe,pj;
		for(;d>0;d--){
			cin>>pm>>pe>>pj;
			cout<<getAns(pm,pe,pj)<<endl;
		}
	}
}