#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxv = 1e5 +5;
int n,L,H;
struct Stu{
char id[10];//因为8位数 的id 所以不能直接用int存然后直接比大小?
int a;
int b;
int sum;
int type;
}stu[maxv];
bool cmp(Stu a, Stu b){
if(a.type != b.type) return a.type < b.type; //按类型
else if(a.sum != b.sum) return a.sum > b.sum;//按总分
else if(a.a != b.a) return a.a > b.a;//按照德分
else return strcmp(a.id,b.id) < 0;//按照序号
}
int main()
{
scanf("%d%d%d",&n,&L,&H);
int m = n;//及格人数
for(int i = 0; i < n; i++){
scanf("%s %d %d", &stu[i].id, &stu[i].a, &stu[i].b);
stu[i].sum = stu[i].a + stu[i].b;
if(stu[i].a < L || stu[i].b < L){
stu[i].type = 5;
m--;
}else if(stu[i].a >= H && stu[i].b >= H){
stu[i].type = 1;
}else if(stu[i].a >= H && stu[i].b < H){
stu[i].type = 2;
}else if( stu[i].a >= stu[i].b){//注意是德分 不低于才分!!所以包括等于
stu[i].type = 3;
}else {
stu[i].type = 4;
}
}
sort(stu, stu + n, cmp);
printf("%d\n", m);
for(int i = 0; i < m; i++){
printf("%s %d %d\n", stu[i].id, stu[i].a, stu[i].b);
}
//cout << "Hello world!" << endl;
return 0;
}