#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T gcd(T a, T b) {     if (a < 0) return gcd(-a, b);     if (b < 0) return gcd(a, -b);     return (b == 0) ? a : gcd(b, a % b);   }   template <class T>   inline T lcm(T a, T b) {     if (a < 0) return lcm(-a, b);     if (b < 0) return lcm(a, -b);     return a * (b / gcd(a, b));   }   template <class T>   inline T sqr(T x) {     return x * x;   }   template <class T>   T power(T N, T P) {     return (P == 0) ? 1 : N * power(N, P - 1);   }   template <class T>   bool inside(T a, T b, T c) {     return (b >= a && b <= c);   }   const long long INF64 = (long long)1E16;   int distsq2d(int x1, int y1, int x2, int y2) {     return sqr(x1 - x2) + sqr(y1 - y2);   }   double dist2d(double x1, double y1, double x2, double y2) {     return sqrt(sqr(x1 - x2) + sqr(y1 - y2));   }   double dist3d(double x1, double y1, double z1, double x2, double y2,                 double z2) {     return sqrt(sqr(x1 - x2) + sqr(y1 - y2) + sqr(z1 - z2));   }   long long toInt64(string s) {     long long r = 0;     istringstream sin(s);     sin >> r;     return r;   }   double LOG(long long N, long long B) { return (log10l(N)) / (log10l(B)); }   string itoa(long long a) {     if (a == 0) return  0 ;     string ret;     for (long long i = a; i > 0; i = i / 10) ret.push_back((i % 10) + 48);     reverse(ret.begin(), ret.end());     return ret;   }   vector<string> token(string a, string b) {     const char *q = a.c_str();     while (count(b.begin(), b.end(), *q)) q++;     vector<string> oot;     while (*q) {       const char *e = q;       while (*e && !count(b.begin(), b.end(), *e)) e++;       oot.push_back(string(q, e));       q = e;       while (count(b.begin(), b.end(), *q)) q++;     }     return oot;   }   int isvowel(char s) {     s = tolower(s);     if (s ==  a  || s ==  e  || s ==  i  || s ==  o  || s ==  u ) return 1;     return 0;   }   int isupper(char s) {     if (s >=  A  and s <=  Z ) return 1;     return 0;   }   int Set(int N, int pos) { return N = N | (1 << pos); }   int reset(int N, int pos) { return N = N & ~(1 << pos); }   int check(int N, int pos) { return (N & (1 << pos)); }   int toggle(int N, int pos) {     if (check(N, pos)) return N = reset(N, pos);     return N = Set(N, pos);   }   void pbit(int N) {     printf( ( );     for (int i = 10; i >= 0; i--) {       bool x = check(N, i);       cout << x;     }     puts( ) );   }   char ts[200];   int n, m;   int a[14][104];   int b[14][104];   int c[14][104];   int dp[14][14][104][104];   int call(int p1, int p2, int idx, int left) {     if (idx == m) return 0;     if (dp[p1][p2][idx][left] != -1) {       return dp[p1][p2][idx][left];     }     int mxx = 0;     for (int i = 1; i <= left and i <= c[p1][idx]; i++) {       int bcost = a[p1][idx] * i;       int scost = b[p2][idx] * i;       int ret = (scost - bcost) + call(p1, p2, idx + 1, left - i);       mxx = max(ret, mxx);     }     int ret = call(p1, p2, idx + 1, left);     mxx = max(ret, mxx);     return dp[p1][p2][idx][left] = mxx;   }   int main() {     memset(dp, -1, sizeof(dp));     ;     int k;     cin >> n >> m >> k;     for (int i = 0; i < n; i++) {       scanf( %s , ts);       for (int j = 0; j < m; j++) {         scanf( %d%d%d , &a[i][j], &b[i][j], &c[i][j]);       }     }     int best = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (i == j) continue;         int ret = call(i, j, 0, k);         best = max(ret, best);       }     }     cout << best << endl;   }