import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class main
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n, m_server, c_server;
n = in.nextInt();
m_server = in.nextInt();
c_server = in.nextInt();
int a_m, a_c, b_m, b_c;
a_m = m_server;
a_c = c_server;
b_m = m_server;
b_c = c_server;
ArrayList<Integer> servers = new ArrayList<>();
ArrayList<Integer> nodes = new ArrayList<>();
int cnt_servers = 0;
for (int i = 0; i < n; i++)
{
int z;
z = in.nextInt();
if (z == 0)
{
int m, c, t;
m = in.nextInt();
c = in.nextInt();
t = in.nextInt();
if (t == 1)
{
if (a_m - m >= 0 && a_c - c >= 0)
{
servers.add(cnt_servers);
nodes.add(0);
a_m -= m;
a_c -= c;
continue;
}
if (b_m - m >= 0 && b_c - c >= 0)
{
servers.add(cnt_servers);
nodes.add(1);
b_m -= m;
b_c -= c;
continue;
}
}
else
{
if (a_m - m/2 >= 0 && a_c - c/2 >= 0 && b_m - m/2 >= 0 && b_c - c/2 >= 0)
{
servers.add(cnt_servers);
nodes.add(-1);
a_m -= m/2;
a_c -= c/2;
b_m -= m/2;
b_c -= c/2;
continue;
}
}
cnt_servers += 1;
a_m = m_server;
a_c = c_server;
b_m = m_server;
b_c = c_server;
servers.add(cnt_servers);
nodes.add(0);
m /= t;
c /= t;
a_m -= m;
a_c -= c;
if (t == 2)
{
b_m -= m;
b_c -= c;
nodes.set(nodes.size() - 1, -1);
}
}
else
{
int id;
id = in.nextInt();
}
}
System.out.println(cnt_servers + 1);
for (int i = 0; i < servers.size(); i++)
{
if (nodes.get(i) == 0)
System.out.println(Integer.toString(servers.get(i) + 1) + " A");
if (nodes.get(i) == 1)
System.out.println(Integer.toString(servers.get(i) + 1) + " B");
if (nodes.get(i) == -1)
System.out.println(servers.get(i) + 1);
}
}
}