#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct
{
int score;
char name[21];
}stu;
int main(void)
{
int N, M, G, m, ans, sum, num;
stu a[1001], temp;
int b[11], i, j;
while (scanf("%d%d%d", &N, &M, &G) != EOF &&N != 0)
{
ans = 0;
for (i = 0; i < M; i++)
{
scanf("%d", &b[i]);
}
for (i = 0; i < N; i++)
{
sum = 0;
scanf("%s", a[i].name); //考号
scanf("%d", &m); //做出的题目数
for (j = 0; j < m; j++)
{
scanf("%d", &num);//读入做出的题号
sum += b[num - 1];
}
a[i].score = sum;
if (sum >= G)
{
ans++;
}
}
for (i = 0; i < N - 1; i++)
{
for (j = 0; j < N - 1 - i; j++)
{
if (a[j].score < a[j + 1].score)
{
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
if (a[j].score == a[j + 1].score)
{
if (strcmp(a[j].name, a[j + 1].name) > 0)
{
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
}
printf("%d\n", ans);
for (i = 0; i < ans; i++)
{
printf("%s %d\n", a[i].name, a[i].score);
}
}
return 0;
}