#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;
int p[100];
struct stu
{
char id[25];
int score;
}s[1010];
bool cmp (stu a, stu b)
{
if(a.score==b.score)
{
string s1(a.id);
string s2(b.id);
return s1<s2;
//return a.id<b.id;//ch不能这么比较char[]时,转化成string可以
//return strcmp(a.id,b.id)<0?1:0;//这样可以
}
else return a.score>b.score;
}
int main()
{
int n,m,g;
int c,tmp;
while(scanf("%d",&n)!=-1&&n)
{
scanf("%d%d",&m,&g);
int sum=0;
for(int i=1;i<=m;i++)
{
scanf("%d",&p[i]);
}
for(int i=1;i<=n;i++)
{
s[i].score=0;
scanf("%s %d",s[i].id,&c);
for(int j=0;j<c;j++)
{
scanf("%d",&tmp);
s[i].score+=p[tmp];
}
if(s[i].score>=g)
sum++;
}
sort(s+1,s+n+1,cmp);
printf("%d\n",sum);
for(int i=1;i<=sum;i++)
{
printf("%s %d\n",s[i].id,s[i].score);
}
}
return 0;
}