/*
//出错代码
#include <iostream>
using namespace std;
int main()
{
int a,b;//A-甲 B-乙
cin>>a>>b;
int n;
cin>>n;
int a1[n],a2[n],b1[n],b2[n];
for(int i=0;i<n;i++)
{
cin>>a1[i]>>a2[i]>>b1[i]>>b2[i];
}
int a3=0,b3=0;
for(int i=0;i<n;i++)
{
if(a3>a)
{
cout<<"A"<<endl;
cout<<b3<<endl;
break;
}
if(b3>b)
{
cout<<"B"<<endl;
cout<<a3<<endl;
break;
}
int m=a1[i]+b1[i];
if(a2[i]==m&&b2[i]!=m)a3++;
if(b2[i]==m&&a2[i]!=m)b3++;
}
return 0;
}
*/
#include <stdio.h>
int main()
{
int num,a,b,c,d,ma,mb,na,nb;
scanf("%d%d%d",&na,&nb,&num);
ma=na;
mb=nb;
while(num--)
{
scanf("%d%d%d%d",&a,&b,&c,&d);
if(b==a+c&&d!=a+c)ma--;
if(b!=a+c&&d==a+c)mb--;
if(ma==-1)
{
printf("A\n%d",nb-mb);
break;
}
if(mb==-1)
{
printf("B\n%d",na-ma);
break;
}
}
return 0;
}