/*************************
题意:
这个题意应该比较好理解吧
主要就是那些大于等于,大于之类的分清楚就行
************************/

/************************
这里我就利用了sort和vector,基本能解决大部分问题
*************************/
/***********************
笔记:

*********************/
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include<stdlib.h>
#include<algorithm>
#include<string.h>
#include<stack>
#include<map>
#include<unordered_map>
using namespace std;
#define M 110000
#define INF 0x7fffffff
struct people{
int id,v,t;
};
vector<people> sage,noble,fool,small;
bool cmp(people a,people b){
if(a.t + a.v > b.t + b.v)
return true;
else if(a.t + a.v == b.t + b.v){
if(a.v > b.v)
return true;
else if(a.v == b.v){
if(a.t > b.t)
return true;
else if(a.t == b.t)
return a.id <b.id;
else return false;
}
else return false;
}
else return false;
}
int main(){
int n,low,high;
cin>>n>>low>>high;
int id,v,t,i;
struct people p;
for(i=0;i<n;i++){
scanf("%d%d%d",&id,&v,&t);
p.id =id ;p.v =v; p.t =t;
if(v>=low && t>=low){
if(v >= high && t >=high){
sage.push_back(p);
}
else if(v >= high && t<high){
noble.push_back(p);
}
else if(v<high && t<high && v >= t){
fool.push_back(p);
}
else small.push_back(p);
}
}

vector<people> ans;
sort(sage.begin(),sage.end(),cmp);
sort(noble.begin(),noble.end(),cmp);
sort(fool.begin(),fool.end(),cmp);
sort(small.begin(),small.end(),cmp);

cout<<sage.size()+noble.size()+fool.size()+small.size()<<endl;
for(i=0;i<sage.size();i++)
printf("%d %d %d\n",sage[i].id,sage[i].v,sage[i].t);
for(i=0;i<noble.size();i++)
printf("%d %d %d\n",noble[i].id,noble[i].v,noble[i].t);
for(i=0;i<fool.size();i++)
printf("%d %d %d\n",fool[i].id,fool[i].v,fool[i].t);
for(i=0;i<small.size();i++)
printf("%d %d %d\n",small[i].id,small[i].v,small[i].t);
return 0;
}