public void solve() throws IOException {
    MyReader in = new MyReader();
    PrintWriter out = new PrintWriter(System.out);

    while (true) {
      int n = in.nextInt();
      if (n == 0) break;
      int m = in.nextInt(), g = in.nextInt(), score[] = new int[m];
      for (int i = 0; i < m; i++) score[i] = in.nextInt();

      Student students[] = new Student[n];
      for (int i = 0; i < n; i++) {
        String name = in.next();
        int cnt = in.nextInt(), totScore = 0;
        for (int j = 0; j < cnt; j++) totScore += score[in.nextInt() - 1];
        students[i] = new Student(name, totScore);
      }
      Arrays.sort(students);

      int pass_cnt = 0;
      for (; pass_cnt < n && students[pass_cnt].getScore() >= g; pass_cnt++) ;
      out.println(pass_cnt);
      for (int i = 0; i < pass_cnt; i++) students[i].print(out);

      out.flush();
    }
  }