#include <bits/stdc++.h>
using namespace std;
int in() {
  int a;
  scanf("%d", &a);
  return a;
}
double din() {
  double a;
  scanf("%lf", &a);
  return a;
}
int gcd(int a, int b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
const double eps = 1e-6;
int logbin(int a) {
  a--;
  int res = 1;
  while (a) a >>= 1, res <<= 1;
  return res;
}
int binpow(int a, int n) {
  int res = 1;
  while (n) {
    if (n & 1) res *= a;
    a *= a;
    n >>= 1;
  }
  return res;
}
vector<vector<int> > g;
vector<char> u;
vector<int> p;
void dfs(int v) {
  u[v] = 1;
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (!u[to]) {
      p[to] = v;
      dfs(to);
    } else {
      if (u[to] == 1) {
        int vv = v;
        while (p[vv] != to) {
          u[vv] = 3;
          vv = p[vv];
        }
      }
    }
  }
  if (u[v] == 1) u[v] = 2;
}
int main() {
  int n = in();
  int m = in(), k = in();
  vector<vector<pair<int, pair<int, int> > > > g(
      n, vector<pair<int, pair<int, int> > >());
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < m; ++j) {
      int u = in(), e = in(), h = in();
      g[i].push_back(make_pair(u, make_pair(e, h)));
    }
  }
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      vector<pair<int, pair<int, int> > > s, t;
      s = g[i];
      t = g[j];
      vector<int> c;
      long long r = 0;
      for (int y = 0; y < m; ++y) {
        int nn = s[y].second.second;
        for (int h = 0; h < nn; ++h) {
          int buf = t[y].second.first - s[y].first;
          if (buf > 0)
            c.push_back(buf);
          else
            break;
        }
      }
      sort((c).rbegin(), (c).rend());
      for (int i = 0; i < min((int)c.size(), k); ++i) {
        r += c[i];
      }
      res = max(res, r);
    }
  }
  cout << res;
  return 0;
}
