#include <iostream>
#include <bits/stdc++.h>
using namespace std;
struct Node
{
int id;
int g1;
int g2;
Node(int tid,int tg1,int tg2):id(tid),g1(tg1),g2(tg2) {}
};
vector<Node>nodes1;
vector<Node>nodes2;
vector<Node>nodes3;
vector<Node>nodes4;
int N,L,H;
bool safe(int g1,int g2,int v)
{
return g1>=v && g2>=v;
}
int cmp1(const Node & a,const Node &b)
{
if(a.g1+a.g2!=b.g1+b.g2)
{
return a.g1+a.g2>b.g1+b.g2;
}
else if(a.g1!=b.g1)
{
return a.g1>b.g1;
}
else
{
return a.id<b.id;
}
}
int main()
{
int tid,tg1,tg2;
int c = 0;
cin>>N>>L>>H;
for(int i = 0; i<N; i++)
{
cin>>tid>>tg1>>tg2;
if(safe(tg1,tg2,L))
{
if(safe(tg1,tg2,H))
{
nodes1.push_back(Node(tid,tg1,tg2));
}
else if(tg1>=H){
nodes2.push_back(Node(tid,tg1,tg2));
}
else if(tg1>=tg2){
nodes3.push_back(Node(tid,tg1,tg2));
}
else{
nodes4.push_back(Node(tid,tg1,tg2));
}
c++;
}
}
sort(nodes1.begin(),nodes1.end(),cmp1);
sort(nodes2.begin(),nodes2.end(),cmp1);
sort(nodes3.begin(),nodes3.end(),cmp1);
sort(nodes4.begin(),nodes4.end(),cmp1);
cout<<c<<endl;
for(int i = 0;i<nodes1.size();i++){
cout<<nodes1[i].id<<" "<<nodes1[i].g1<<" "<<nodes1[i].g2<<endl;
}
for(int i = 0;i<nodes2.size();i++){
cout<<nodes2[i].id<<" "<<nodes2[i].g1<<" "<<nodes2[i].g2<<endl;
}
for(int i = 0;i<nodes3.size();i++){
cout<<nodes3[i].id<<" "<<nodes3[i].g1<<" "<<nodes3[i].g2<<endl;
}
for(int i = 0;i<nodes4.size();i++){
cout<<nodes4[i].id<<" "<<nodes4[i].g1<<" "<<nodes4[i].g2<<endl;
}
return 0;
}
/**
14 60 80
10000001 64 90
10000002 90 60
10000011 85 80
10000003 85 80
10000004 80 85
10000005 82 77
10000006 83 76
10000007 90 78
10000008 75 79
10000009 59 90
10000010 88 45
10000012 80 100
10000013 90 99
10000014 66 60
**/