#include <bits/stdc++.h>
using namespace std;
int main()
{
int a=0,b=0;
cin>>a>>b;
int a1=a,b1=b;
int N=0;
cin>>N;
int aS=0,aA=0,bS=0,bA=0;
int temp=0;
for(int i=0;i<N;i++)
{
cin>>aS>>aA>>bS>>bA;
temp=aS+bS;
if(temp==aA&&(aA!=bA))a1--;
else if(temp==bA&&(aA!=bA))b1--;
if(a1<0){cout<<"A"<<endl<<b-b1;break;}
else if(b1<0){cout<<"B"<<endl<<a-a1;break;}
}
system("pause");
}