/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
using namespace std;

int n, m, g;
int score[15];
struct node
{
	string name;
	int num;
	int ac[15];
	int sum;
	bool operator <(const node &x)const{
		return sum == x.sum ? name < x.name : sum > x.sum;
	}
}a[1005];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);

	while(scanf("%d", &n) == 1){
		if(!n) break;
		scanf("%d %d", &m, &g);
		for (int i = 1; i <= m; i++){
			scanf("%d", &score[i]);
		}
		for (int i = 1; i <= n; i++){
			cin >> a[i].name >> a[i].num;
			int num;
			a[i].sum = 0;
			for (int j = 1; j <= a[i].num; j++){
				scanf("%d", &num);
				a[i].sum += score[num];
			}
		}
		sort(a + 1, a + 1 + n);
		int ans = 0;
		for (int i = 1; i <= n; i++){
			if(a[i].sum >= g) ans++;
			else break;
		}
		printf("%d\n", ans);
		for (int i = 1; i <= ans; i++){
			cout << a[i].name << " " << a[i].sum << endl;
		}
	}

	return 0;
}
/**/