var
n, m_server, c_server, a_m, a_c, b_m, b_c, i, z, m, c, t, id, cnt_servers : longint;
servers, nodes : array[0..500000] of longint;
sz: longint;
begin
read(n, m_server, c_server);
a_m := m_server;
a_c := c_server;
b_m := m_server;
b_c := c_server;
cnt_servers := 0;
sz := 0;
for i := 0 to n-1 do
begin
read(z);
if z = 0 then
begin
read(m, c, t);
if t = 1 then
begin
if (a_m - m >= 0) AND (a_c - c >= 0) then
begin
servers[sz] := cnt_servers;
nodes[sz] := 0;
sz := sz + 1;
a_m := a_m - m;
a_c := a_c - c;
continue;
end;
if (b_m - m >= 0) AND (b_c - c >= 0) then
begin
servers[sz] := cnt_servers;
nodes[sz] := 1;
sz := sz + 1;
b_m := b_m - m;
b_c := b_c - c;
continue;
end;
end
else
begin
if (a_m - (m div 2) >= 0) AND (a_c - (c div 2) >= 0) AND (b_m - (m div 2) >= 0) AND (b_c - (c div 2) >= 0) then
begin
servers[sz] := cnt_servers;
nodes[sz] := -1;
sz := sz + 1;
a_m := a_m - m div 2;
a_c := a_c - c div 2;
b_m := b_m - m div 2;
b_c := b_c - c div 2;
continue;
end;
end;
cnt_servers := cnt_servers + 1;
a_m := m_server;
a_c := c_server;
b_m := m_server;
b_c := c_server;
servers[sz] := cnt_servers;
nodes[sz] := 0;
sz := sz + 1;
m := m div t;
c := c div t;
a_m := a_m - m;
a_c := a_c - c;
if t = 2 then
begin
b_m := b_m - m;
b_c := b_c - c;
nodes[sz - 1] := -1;
end;
end
else
begin
read(id);
end;
end;
writeln(cnt_servers + 1);
for i := 0 to sz - 1 do
begin
if nodes[i] = 0 then writeln(servers[i] + 1, ' A');
if nodes[i] = 1 then writeln(servers[i] + 1, ' B');
if nodes[i] = -1 then writeln(servers[i] + 1);
end;
end.