import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int S, D, M;
    int[] P, W;
    int[][] P1, W1;
    bool input() {
        int r = scanf("%d %d %d\n", &S, &D, &M);
        if (r == EOF) return false;
        P.clear;
        W.clear;
        P1 = new int[][S];
        W1 = new int[][S];
        foreach (i; 0 .. S) {
            int k; scanf("%d\n", &k);
            P1[i] = new int[k];
            W1[i] = new int[k];
            foreach (j; 0 .. k) {
                int w, p;
                scanf("%d %d", &w, &p);
                P1[i][j] = p;
                W1[i][j] = w;
            }
        }
        foreach (i; 0 .. D) {
            int f; scanf("%d", &f);
            P ~= P1[f];
            W ~= W1[f];
        }
        return true;
    }

    void solve() {
        auto dp = new int[][](2, M + 1);
        foreach (i; 0 .. 2) dp[i][] = int.min;
        auto N = P.length;
        dp[0][0] = 0;
        for (long n = 1; n <= N; n++) {
            for (long c = 0; c <= M; c++) {
                dp[n & 1][c] = dp[(n - 1) & 1][c];
                if (c - P[n - 1] >= 0) {
                    dp[n & 1][c] = max(dp[n & 1][c], dp[(n - 1) & 1][c - P[n - 1]] + W[n - 1]);
                }
            }
        }
        int x = dp[N & 1].reduce!max;
        writeln(x, " ", dp[N & 1].countUntil(x));
    }
    while (input) solve;
}