#include <iostream>
#include "vector"
#include "queue"
using namespace std;
struct student {
    string num;
    int score;
    student(string s, int i) {
        num = s;
        score = i;
    }
    bool operator< (student B)const {
        if (score == B.score) return num > B.num;
        return score < B.score;
    }

};
int main() {
    int N, M, G;
    while (cin >> N >> M >> G) { // 注意 while 处理多个 case
        // cout << a + b << endl;
        if (N == 0) break;
        priority_queue<student> myQueue;
        vector<int> score;
        score.push_back(0);
        while (M--) {
            int temp;
            cin >> temp;
            score.push_back(temp);
        }
        while (N--) {
            string num;
            cin >> num;
            int finishNum;
            cin >> finishNum;
            int sscore = 0;
            while (finishNum--) {
                int qn;
                cin >> qn;
                sscore += score[qn];
            }
            if (sscore >= G) myQueue.push(student(num, sscore));
        }
        if (myQueue.size() == 0) cout << 0 << endl;
        else {
            cout << myQueue.size() << endl;
            while (!myQueue.empty()) {
                cout << myQueue.top().num << ' ' << myQueue.top().score << endl;
                myQueue.pop();
            }
        }
    }
}
// 64 位输出请用 printf("%lld")