#include <bits/stdc++.h>
using namespace std;
int main()
{
int jia, yi, n;
cin >> jia >> yi >> n;
int cnt1 = 0, cnt2 = 0;
while (n--)
{
int a, b, c, d;
cin >> a >> b >> c >> d;
if (b == a + c && d == a + c || b != a + c && d != a + c)
continue;
if (b == a + c) cnt1++;
if (d == a + c) cnt2++;
if (cnt1 > jia)
{
puts("A");
cout << cnt2;
return 0;
}
if (cnt2 > yi)
{
puts("B");
cout << cnt1;
return 0;
}
}
return 0;
}