#include <bits/stdc++.h>
using namespace std;
string S, E;
int k;
int len;
long long ans = 0;
string temp;
int a[10][100][3];
int max_sale[10][100];
bool my_comp(pair<int, pair<int, int> >& a, pair<int, pair<int, int> >& b) {
  if (a.second.first > b.second.first)
    return true;
  else
    return false;
  if (a.first < b.first)
    return true;
  else if (a.first == b.first) {
    if (a.second.first > b.second.first)
      return true;
    else if (a.second.first == b.second.first) {
      if (a.second.second > b.second.second)
        return true;
      else
        return false;
    } else
      return false;
  } else
    return false;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  string temp;
  vector<pair<int, pair<int, int> > > vv;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    for (int j = 0; j < m; j++) {
      cin >> a[i][j][0] >> a[i][j][1] >> a[i][j][2];
      max_sale[i][j] = max(max_sale[i][j], a[i][j][1]);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    vector<pair<int, pair<int, int> > > v;
    for (int j = 0; j < n; j++) {
      if (j == n) continue;
      v.clear();
      for (int k = 0; k < m; k++) {
        v.push_back((make_pair(
            a[i][k][0], (make_pair(max_sale[j][k] - a[i][k][0], a[i][k][2])))));
      }
      sort(v.begin(), v.end(), my_comp);
      int cnt = 0;
      int cur_sale = 0;
      int temp = 0;
      while (cnt < k) {
        temp = 0;
        for (int jj = 0; jj < v.size(); jj++) {
          if (v[jj].second.second > 0 && v[jj].second.first > 0) {
            cur_sale += v[jj].second.first;
            cnt++;
            v[jj].second.second--;
            break;
          } else {
            temp++;
          }
        }
        if (temp == v.size()) break;
      }
      ans = max(ans, cur_sale);
    }
  }
  cout << ans << endl;
  return 0;
  return 0;
}
