#include <stdio.h>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	int value,cost;
};

Info info[100][50];
int item_num[100],sell_count[100];
int dp[301],next_dp[301];

int main(){

	int S,D,M;

	while(scanf("%d %d %d",&S,&D,&M) != EOF){

		for(int i = 0; i < S; i++)sell_count[i] = 0;

		for(int i = 0; i < S; i++){
			scanf("%d",&item_num[i]);

			for(int k = 0; k < item_num[i]; k++){
				scanf("%d %d",&info[i][k].value,&info[i][k].cost);
			}
		}

		int tmp;
		for(int i = 0; i < D; i++){
			scanf("%d",&tmp);
			sell_count[tmp]++;
		}

		dp[0] = 0;
		next_dp[0] = 0;
		for(int i = 1; i <= M; i++){
			dp[i] = -1;
			next_dp[i] = -1;
		}

		vector<int> Updated;

		for(int i = 0; i < S; i++){
			if(sell_count[i] == 0)continue;

			for(int k = 0; k < item_num[i]; k++){
				for(int num = 1; num <= sell_count[i]; num++){
					for(int budget = M; budget-num*info[i][k].cost >= 0; budget--){
						if(dp[budget-num*info[i][k].cost] >= 0){
							if(next_dp[budget] < dp[budget-num*info[i][k].cost]+num*info[i][k].value){
								next_dp[budget] = dp[budget-num*info[i][k].cost]+num*info[i][k].value;
								Updated.push_back(budget);
							}
						}
					}
				}
				for(int p = 0; p < Updated.size(); p++){
					dp[Updated[p]] = next_dp[Updated[p]];
				}
				Updated.clear();
			}
		}

		int max_effect = -1,min_budget;
		for(int budget = 0; budget <= M; budget++){
			if(max_effect < dp[budget]){
				max_effect = dp[budget];
				min_budget = budget;
			}
		}

		printf("%d %d\n",max_effect,min_budget);
	}
	return 0;
}