#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MX 10100
struct node{
string s;
int score;
node(string s="",int score=0):s(s),score(score){
}
bool operator<(const node&o)const{
return score==o.score?s<o.s:score > o.score;
}
}a[10100];
int main(){
int n, g, k;
cin >> n >> g >> k;
for (int i = 0; i < n;++i){
string s;
int score;
cin >> s >> score;
a[i] = node(s, score);
}
sort(a, a + n);
int p1 = lower_bound(a, a + n, node("",g-1))-a;
int p2 = lower_bound(a, a + n, node("", 60-1)) - a;
cout << p1 * 50 + (p2 - p1) * 20<<"\n";
int rank = 1;
int cnt = 0;
int lst = 9999;
while(rank<=k){
if(a[cnt].score<lst)
rank = cnt+1;
if(rank>k)
break;
lst = a[cnt].score;
cout << rank << " " << a[cnt].s<<" " << a[cnt].score << "\n";
cnt++;
}
}