L1-096 谁管谁叫爹
#include <bits/stdc++.h>
using namespace std;
int digit_sum(int num){
int sum=0;
while(num){
sum+=(num%10);
num/=10;
}
return sum;
}
int main(){
int N;
int i,j;
int A,B;
cin>>N;
for(i=0;i<N;i++){
cin>>A>>B;
if(!(A%digit_sum(B))&&(B%digit_sum(A))) cout<<"A"<<endl;
else if(!(B%digit_sum(A))&&(A%digit_sum(B))) cout<<"B"<<endl;
else if((!(A%digit_sum(B))&&!(B%digit_sum(A)))||(A%digit_sum(B))&&(B%digit_sum(A)))
{
A>B?cout<<"A"<<endl:cout<<"B"<<endl;
}
}
return 0;
}