{
Written by Fyodor Menshikov 04.02.2005
22:25-22:52
idea changed at 23:35
idea changed at 23:50 Accepted!!!
}
{$R+,Q+}
const
   maxN=100;
var
   remove:array[1..maxN*2]of record
      n:integer;
      c:char;
   end;
   removeCnt:integer;

   procedure add(n:integer;c:char);
   begin
      inc(removeCnt);
      remove[removeCnt].n:=n;
      remove[removeCnt].c:=c;
   end;

   procedure print;
   var
      i:integer;
   begin
      writeln(removeCnt);
      for i:=1 to removeCnt do
         writeln(remove[i].c,remove[i].n);
   end;

var
   ia,ib,na,nb,ne,ie,maxca,maxcb,maxia,maxib,ia1,ib1,n0a,n0b:integer;
   edge:array[1..maxN,1..maxN]of boolean;
   ca,cb:array[1..maxN]of integer;
begin
//   assign(input,'input.txt');
   reset(input);
//   assign(output,'output.txt');
   rewrite(output);
   readln(na,nb,ne);
   for ia:=1 to na do
      for ib:=1 to nb do
         edge[ia,ib]:=false;
   for ia:=1 to na do
      ca[ia]:=0;
   for ib:=1 to nb do
      cb[ib]:=0;
   for ie:=1 to ne do begin
      readln(ia,ib);
      edge[ia,ib]:=true;
      inc(ca[ia]);
      inc(cb[ib]);
   end;
   removeCnt:=0;
   while ne>0 do begin
      ia1:=0;
      for ia:=1 to na do
         if ca[ia]=1 then begin
            ia1:=ia;
            break;
         end;
      if ia1>0 then begin
         for ib:=1 to nb do
            if edge[ia1,ib] then begin
               dec(ne,cb[ib]);
               cb[ib]:=0;
               add(ib,'B');
               for ia:=1 to na do
                  if edge[ia,ib] then begin
                     edge[ia,ib]:=false;
                     dec(ca[ia]);
                  end;
            end;
         continue;
      end;
      ib1:=0;
      for ib:=1 to nb do
         if cb[ib]=1 then begin
            ib1:=ib;
            break;
         end;
      if ib1>0 then begin
         for ia:=1 to na do
            if edge[ia,ib1] then begin
               dec(ne,ca[ia]);
               ca[ia]:=0;
               add(ia,'A');
               for ib:=1 to nb do
                  if edge[ia,ib] then begin
                     edge[ia,ib]:=false;
                     dec(cb[ib]);
                  end;
            end;
         continue;
      end;
      n0a:=0;
      for ia:=1 to na do
         if ca[ia]<>0 then
            inc(n0a);
      n0b:=0;
      for ib:=1 to nb do
         if cb[ib]<>0 then
            inc(n0b);
      if n0a<n0b then begin
         maxca:=0;
         maxia:=0;
         for ia:=1 to na do
            if ca[ia]>maxca then begin
               maxca:=ca[ia];
               maxia:=ia;
            end;
         dec(ne,maxca);
         ca[maxia]:=0;
         add(maxia,'A');
         for ib:=1 to nb do
            if edge[maxia,ib] then begin
               edge[maxia,ib]:=false;
               dec(cb[ib]);
            end;
      end
      else begin
         maxcb:=0;
         maxib:=0;
         for ib:=1 to nb do
            if cb[ib]>maxcb then begin
               maxcb:=cb[ib];
               maxib:=ib;
            end;
         dec(ne,maxcb);
         cb[maxib]:=0;
         add(maxib,'B');
         for ia:=1 to na do
            if edge[ia,maxib] then begin
               edge[ia,maxib]:=false;
               dec(ca[ia]);
            end;
      end;
   end;
   print;
end.