#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
double EPS=1e-10;
double EQ(double a,double b){
    return abs(a-b)<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}
template<class T>
string IntToString(T num){
  string res;stringstream ss;ss<<num;
  return ss.str();
}
ll StringToInt(string &str){
  ll res;
  for(int i=0;i<(int)str.size();i++)
    res=(res*10+str[i]-'0');
  return res;
}
int S,D,M;
vector<pii> ss[1001];
int fs[1001];
pii dp[101][51][1001];
const int INF=1<<30;
pii dfs(int pos,int k,int money){
  if(dp[pos][k][money].first!=INF)return dp[pos][k][money];
  pii res;
  int kind=fs[pos];
  if(pos==D)return res;
  if(k==(int)ss[kind].size())return dfs(pos+1,0,money);
  res=min(res,dfs(pos,k+1,money));
  if(money-ss[kind][k].second>=0){
    pii tmp=dfs(pos,k+1,money-ss[kind][k].second);
    tmp.first-=ss[kind][k].first;
    tmp.second+=ss[kind][k].second;
    res=min(res,tmp);
  }
  return dp[pos][k][money]=res;
}

int main(){
  while(cin>>S>>D>>M){
    for(int i=0;i<101;i++)
      for(int k=0;k<51;k++)
	for(int j=0;j<301;j++)
	  dp[i][k][j].first=INF;
    for(int i=0;i<S;i++){
      ss[i].clear();
      int k;
      cin>>k;
      for(int j=0;j<k;j++){
	int w,p;
	cin>>w>>p;
	ss[i].push_back(pii(w,p));
      }
    }
    for(int i=0;i<D;i++)cin>>fs[i];
    pii p=dfs(0,0,M);
    cout<<-p.first<<" "<<p.second<<endl;
  }
  return 0;  
}