#include<iostream>
#include<list>
using namespace std;
typedef struct{
int id,sum_de,sum_cai;
}datatype;
int ans=0;
bool cmp1(datatype a,datatype b){
return a.sum_de+a.sum_cai>b.sum_de+b.sum_cai;
}
bool cmp2(datatype a){
return a.sum_de>a.sum_cai;
}
void solve(){
int n,L,H;cin>>n>>L>>H;
int i,j,k,t;
list<datatype>list_t;
datatype a;
for(i=0;i<n;i++){
cin>>a.id>>a.sum_de>>a.sum_cai;
if(a.sum_de>=L&&a.sum_cai>=L){
ans++;
list_t.push_back(a);
}
}
list_t.sort(cmp1);
list<datatype>::iterator it=list_t.begin();
cout<<ans<<endl;
for(;it!=list_t.end();++it){
if(it->sum_de>=H&&it->sum_cai>=H){
cout<<it->id<<' '<<it->sum_de<<' '<<it->sum_cai<<endl;
list_t.erase(it);
}
}
list_t.sort(cmp2);
for(;it!=list_t.end();++it){
if(it->sum_de>=H||it->sum_cai>=H){
cout<<it->id<<' '<<it->sum_de<<' '<<it->sum_cai<<endl;
list_t.erase(it);
}
}
for(;it!=list_t.end();++it){
cout<<it->id<<' '<<it->sum_de<<' '<<it->sum_cai<<endl;
list_t.erase(it);
}
}
int main(){
solve();
return 0;
}
#include<list>
using namespace std;
typedef struct{
int id,sum_de,sum_cai;
}datatype;
int ans=0;
bool cmp1(datatype a,datatype b){
return a.sum_de+a.sum_cai>b.sum_de+b.sum_cai;
}
bool cmp2(datatype a){
return a.sum_de>a.sum_cai;
}
void solve(){
int n,L,H;cin>>n>>L>>H;
int i,j,k,t;
list<datatype>list_t;
datatype a;
for(i=0;i<n;i++){
cin>>a.id>>a.sum_de>>a.sum_cai;
if(a.sum_de>=L&&a.sum_cai>=L){
ans++;
list_t.push_back(a);
}
}
list_t.sort(cmp1);
list<datatype>::iterator it=list_t.begin();
cout<<ans<<endl;
for(;it!=list_t.end();++it){
if(it->sum_de>=H&&it->sum_cai>=H){
cout<<it->id<<' '<<it->sum_de<<' '<<it->sum_cai<<endl;
list_t.erase(it);
}
}
list_t.sort(cmp2);
for(;it!=list_t.end();++it){
if(it->sum_de>=H||it->sum_cai>=H){
cout<<it->id<<' '<<it->sum_de<<' '<<it->sum_cai<<endl;
list_t.erase(it);
}
}
for(;it!=list_t.end();++it){
cout<<it->id<<' '<<it->sum_de<<' '<<it->sum_cai<<endl;
list_t.erase(it);
}
}
int main(){
solve();
return 0;
}