#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,l,h;
struct Student
{
int num; //准考证号
int d_score; //德分
int c_score; //才分
int sum_score; //总分
int rank; //等级(1-5)
}student[N];
bool cmp(Student s1,Student s2)
{
//先按等级(小优先),再按总分(大优先),再按德分(大优先),最后按考号(小优先)
if(s1.rank<s2.rank) return true;
else if(s1.rank==s2.rank && s1.sum_score>s2.sum_score) return true;
else if(s1.rank==s2.rank && s1.sum_score==s2.sum_score && s1.d_score>s2.d_score) return true;
else if(s1.rank==s2.rank && s1.sum_score==s2.sum_score && s1.d_score==s2.d_score && s1.num<s2.num) return true;
return false;
}
int main()
{
cin>>n>>l>>h;
int m=n; //m用于统计达到最低分数线的考生人数
for(int i=0;i<n;i++)
{
cin>>student[i].num>>student[i].d_score>>student[i].c_score;
student[i].sum_score=student[i].d_score+student[i].c_score;
if(student[i].d_score>=h && student[i].c_score>=h) //确定等级
student[i].rank=1;
else if(student[i].d_score>=h && student[i].c_score>=l)
student[i].rank=2;
else if(student[i].d_score<h && student[i].c_score<h && student[i].d_score>=student[i].c_score && student[i].c_score>=l)
student[i].rank=3;
else if(student[i].d_score>=l && student[i].c_score>=l)
student[i].rank=4;
else
{
student[i].rank=5;
m--;
}
}
cout<<m<<endl;
sort(student,student+n,cmp);
for(int i=0;i<m;i++)
cout<<student[i].num<<' '<<student[i].d_score<<' '<<student[i].c_score<<endl;
return 0;
}