#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct Stu{
	string seq;
	int num;
	int total;
};
bool cmp(Stu lhs, Stu rhs){
	if (lhs.total > rhs.total){
		return true;
	}
	else if (lhs.total == rhs.total&&lhs.seq < rhs.seq){
		return true;
	}
	else{
		return false;
	}
}
int main(){
	int n;
	while (scanf("%d", &n) != EOF){
		if (n == 0){
			break;
		}
		int M, G;
		scanf("%d%d", &M, &G);
		int scr[10];
		for (int i = 0; i < M; i++){
			scanf("%d", &scr[i]);
		}
		Stu sam[1000];
		for (int i = 0; i < n; i++){
			cin >> sam[i].seq;
			scanf("%d", &sam[i].num);
			sam[i].total = 0;
			for (int j = 0; j < sam[i].num; j++){
				int t;
				scanf("%d", &t);
				sam[i].total = sam[i].total + scr[t-1];
			}
		}
		sort(sam, sam + n,cmp);
		int y=0;
		for (; y < n; y++){
			if (sam[y].total < G){
				break;
			}
		}
		printf("%d\n", y);
		for (int i = 0; i < y; i++){
			cout << sam[i].seq;
			printf(" %d\n", sam[i].total);
		}
	}
}