import java.io.*;
import java.util.*;

public class Main {
	static Scanner in; static int next() throws Exception {return in.nextInt();}
	static PrintWriter out;
//	static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
//	static BufferedReader in;

	public static void main(String[] args) throws Exception {
		in = new Scanner(System.in);
//		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		int n = next();
		int m = next();
		int k = next();

		int[][] a = new int[n][m];
		int[][] b = new int[n][m];
		int[][] c = new int[n][m];

		for (int i = 0; i < n; i++) {
			in.next();
			for (int j = 0; j < m; j++) {
				a[i][j] = next();
				b[i][j] = next();
				c[i][j] = next();
			}
		}

		int max = -1;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++) if (j != i) {
				int[] d = new int[m];
				for (int t = 0; t < m; t++) d[t] = b[j][t] - a[i][t];
				int kk = k;

				int sum = 0;
				while (kk > 0) {
					int ind = -1;
					int mx = 0;
					for (int t = 0; t < m; t++) if (d[t] > mx) {
						mx = d[t];
						ind = t;
					}

					if (ind < 0) break;

					sum += Math.min(kk, c[i][ind]) * d[ind];
					kk -= Math.min(kk, c[i][ind]);

					d[ind] = -1000000;
				}

				max = Math.max(max, sum);
			}

		out.println(max);

		out.close();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Solution {
    static class Pl {
        int[] a, b, c;

        public Pl(BufferedReader in, int m) throws IOException {
            a = new int[m];
            b = new int[m];
            c = new int[m];

            in.readLine();
            for (int i = 0; i < m; i++) {
                StringTokenizer st = new StringTokenizer(in.readLine());
                a[i] = Integer.parseInt(st.nextToken());
                b[i] = Integer.parseInt(st.nextToken());
                c[i] = Integer.parseInt(st.nextToken());
            }
        }
    }

    static class To implements Comparable<To> {
        int id, prof;

        public To(int I, int P) {
            id = I;
            prof = P;
        }

        @Override
        public int compareTo(To t) {
            return t.prof != prof ? t.prof - prof : 0;
        }
    }

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        StringTokenizer st = new StringTokenizer(in.readLine());

        int n = Integer.parseInt(st.nextToken()), m = Integer.parseInt(st.nextToken()), k = Integer.parseInt(st.nextToken());
        Pl[] p = new Pl[n];

        for (int i = 0; i < n; i++)
            p[i] = new Pl(in, m);

        long ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j)
                    continue;

                To[] T = new To[m];

                for (int t = 0; t < m; t++)
                    T[t] = new To(t, p[j].b[t] - p[i].a[t]);

                Arrays.sort(T);

                long locAns = 0, rem = k;
                for (int t = 0; t < m; t++) {
                    int c = p[i].c[T[t].id];
                    if (c >= rem) {
                        if (T[t].prof > 0) {
                            locAns += rem * T[t].prof;
                            rem = 0;
                        }
                        break;
                    } else {
                        if (T[t].prof > 0) {
                            locAns += c * T[t].prof;
                            rem -= c;
                        } else
                            break;
                    }
                }

                ans = Math.max(ans, locAns);
            }
        }

        out.println(ans);
        out.close();
    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;

public class Main {
   public static void main(String[] args) throws IOException
   {
	   (new Main()).solve();
   }
   public void Main() {
   }

   void solve()  throws IOException {
	  //BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	  //Scanner in = new Scanner(System.in);
	   MyReader in = new MyReader();
	  PrintWriter out = new PrintWriter(System.out);
     // Scanner in = new Scanner(new FileReader("input.txt"));
	//  PrintWriter out = new PrintWriter("output.txt");

	  int n = in.nextInt();
	  int m = in.nextInt();
	  int k = in.nextInt();
	  int[][] a = new int[n][m];
	  int[][] b = new int[n][m];
	  int[][] c = new int[n][m];

	  for (int i = 0; i < n; i++) {
		  in.readLine();
		  for (int j = 0; j < m; j++) {
			  a[i][j] = in.nextInt();
			  b[i][j] = in.nextInt();
			  c[i][j] = in.nextInt();
		  }
	  }

	  int max = 0;
	  Record[] r = new Record[m];

	  for (int i = 0; i < n; i++) {
		  for (int j = 0; j < n; j++) {
			  if (i != j) {
				 for (int p = 0; p < m; p++) {
					 r[p] = new Record(b[j][p] - a[i][p], c[i][p]);
				 }
				 Arrays.sort(r, new Record(1, 1));
				 int curK = k;
				 int res = 0;
				 for (Record r1 : r) {
					 if (curK > 0 && r1.d > 0) {
						 int count = Math.min(curK, r1.count);
						 curK -= count;
						 res += (count * r1.d);
					 } else {
						 break;
					 }
				 }
				 if (res > max) {
					 max = res;
				 }
			  }
		  }
	  }

	  out.print(max);

	out.close();
   }

};

class Record implements Comparator<Record> {

	public Record(int d, int count) {
		super();
		this.d = d;
		this.count = count;
	}

	public int d;
	public int count;

	@Override
	public int compare(Record arg0, Record arg1) {
		if (arg0.d < arg1.d) {
			return 1;
		} else if (arg0.d == arg1.d) {
			return 0;
		} else {
			return -1;
		}
	}
}

class MyReader {
	private BufferedReader in;
	String[] parsed;
	int index = 0;

	public MyReader() {
		in = new BufferedReader(new InputStreamReader(System.in));
	}

	public int nextInt() throws NumberFormatException, IOException {
		if (parsed == null || parsed.length == index) {
			read();
		}
		return Integer.parseInt(parsed[index++]);
	}

	public long nextLong() throws NumberFormatException, IOException {
		if (parsed == null || parsed.length == index) {
			read();
		}
		return Long.parseLong(parsed[index++]);
	}

	public String nextString() throws IOException {
		if (parsed == null || parsed.length == index) {
			read();
		}
		return parsed[index++];
	}

	private void read() throws IOException {
		parsed = in.readLine().split(" ");
		index = 0;
	}

	public String readLine() throws IOException {
		return in.readLine();
	}
};

import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

	int [][] a, b, c;

	public void solve () throws Exception {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		a = new int [n][m];
		b = new int [n][m];
		c = new int [n][m];
		for (int i = 0; i < n; i++) {
			String s = in.readLine();
			for (int j = 0; j < m; j++) {
				a [i][j] = nextInt();
				b [i][j] = nextInt();
				c [i][j] = nextInt();
			}
		}
		int sum = 0;
		int add = -1;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i != j) {
					boolean used [] = new boolean [m];
					int capacity = k;
					int all = 0;
					while (capacity > 0) {
						int bestdiff = -1;
						int t = -1;
						for (int type = 0; type < m; type++) {
							if (!used[type] && c[i][type] > 0 && b[j][type] > a[i][type]) {
								if (b[j][type] - a[i][type] > bestdiff) {
									bestdiff = b[j][type] - a[i][type];
									t = type;
								}
							}
						}
						if (bestdiff <= 0) break;
						if (bestdiff > 0 && capacity > 0) {
							all += bestdiff * min (capacity, c[i][t]);
							used [t] = true;
							capacity -= min (capacity, c[i][t]);
						}
					}
					if (all > add) {
						add = all;
					}
				}
			}
		}
		if (add > 0) {
			sum += add;
		}
		out.println(sum);
	}

	static final String fname = "";
	long stime = 0;

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	private String nextToken () throws Exception {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	private int nextInt () throws Exception {
		return Integer.parseInt(nextToken());
	}

	private long nextLong () throws Exception {
		return Long.parseLong(nextToken());
	}

	private double nextDouble () throws Exception {
		return Double.parseDouble(nextToken());
	}

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve ();
		} catch (Exception e) {
			throw new RuntimeException(e);
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Solution(), "", 1<<25).start();
	}

}

import java.io.*;
import java.util.*;

public class TradingBusiness {

	static int[][] a, b, c;

	public static void main(String[] args) throws IOException {
		Kattio io = new Kattio(System.in);
		int n = io.getInt();
		int m = io.getInt();
		int k = io.getInt();
		a = new int[n][m];
		b = new int[n][m];
		c = new int[n][m];
		for (int i = 0; i < n; i++) {
			io.getWord();
			for (int j = 0; j < m; j++) {
				a[i][j] = io.getInt();
				b[i][j] = io.getInt();
				c[i][j] = io.getInt();
			}
		}
		int res = 0;
		for (int i1 = 0; i1 < n; i1++) {
			for (int i2 = 0; i2 < n; i2++) {
				int res2 = 0;
				int kk = k;
				boolean[] used = new boolean[m];
				while (kk > 0) {
					int max = 0;
					int maxI = -1;
					for (int i = 0; i < m; i++) {
						if (!used[i]) {
							if (b[i2][i] - a[i1][i] > max) {
								max = b[i2][i] - a[i1][i];
								maxI = i;
							}
						}
					}
					if (max == 0) break;
					int use = Math.min(kk, c[i1][maxI]);
					res2 += max * use;
					kk -= use;
					used[maxI] = true;
				}
				res = Math.max(res, res2);
			}
		}
		io.println(res);
		io.close();
	}

	static class Kattio extends PrintWriter {
	    public Kattio(InputStream i) {
		super(new BufferedOutputStream(System.out));
		r = new BufferedReader(new InputStreamReader(i));
	    }
	    public Kattio(InputStream i, OutputStream o) {
		super(new BufferedOutputStream(o));
		r = new BufferedReader(new InputStreamReader(i));
	    }

	    public boolean hasMoreTokens() {
		return peekToken() != null;
	    }

	    public int getInt() {
		return Integer.parseInt(nextToken());
	    }

	    public double getDouble() {
		return Double.parseDouble(nextToken());
	    }

	    public long getLong() {
		return Long.parseLong(nextToken());
	    }

	    public String getWord() {
		return nextToken();
	    }

	    private BufferedReader r;
	    private String line;
	    private StringTokenizer st;
	    private String token;

	    private String peekToken() {
		if (token == null)
		    try {
			while (st == null || !st.hasMoreTokens()) {
			    line = r.readLine();
			    if (line == null) return null;
			    st = new StringTokenizer(line);
			}
			token = st.nextToken();
		    } catch (IOException e) { }
		return token;
	    }

	    private String nextToken() {
		String ans = peekToken();
		token = null;
		return ans;
	    }
	}
}

import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

/**
 * @author Roman Elizarov
 */
public class Krok2012_2_A {
	public static void main(String[] args) {
		new Krok2012_2_A().go();
	}

	int n;
	int m;
	int k;
	int[][] a;
	int[][] b;
	int[][] c;

	private void go() {
		Scanner in = new Scanner(System.in);
		PrintStream out = System.out;
		n = in.nextInt();
		m = in.nextInt();
		k = in.nextInt();
		a = new int[n][m];
		b = new int[n][m];
		c = new int[n][m];
		for (int i = 0; i < n; i++) {
			in.next();
			for (int j = 0; j < m; j++) {
				a[i][j] = in.nextInt();
				b[i][j] = in.nextInt();
				c[i][j] = in.nextInt();
			}
		}
		out.println(solve());
	}

	Delta[] d;

	int solve() {
		d = new Delta[m];
		for (int t = 0; t < m; t++)
			d[t] = new Delta();
		int max = 0;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				if (i != j)
					max = Math.max(max, solve2(i, j));
		return max;
	}

	private int solve2(int i, int j) {
		for (int t = 0; t < m; t++) {
			d[t].p = b[j][t] - a[i][t];
			d[t].t = t;
		}
		Arrays.sort(d);
		int rem = k;
		int profit = 0;
		for (int u = 0; k > 0 && u < m; u++) {
			int p = d[u].p;
			if (p <= 0)
				break;
			int cnt = Math.min(rem, c[i][d[u].t]);
			profit += p * cnt;
			rem -= cnt;
		}
		return profit;
	}

	static class Delta implements Comparable<Delta> {
		int t;
		int p;

		public int compareTo(Delta o) {
			return o.p - p;
		}
	}
}

import java.lang.*;
import java.math.BigInteger;
import java.io.*;
import java.util.*;

public class Solution implements Runnable{
    public static BufferedReader br;
    public static PrintWriter out;
    public static StringTokenizer stk;
    public static boolean isStream = true;

    public static void main(String[] args) throws IOException {
    	if (isStream) {
            br = new BufferedReader(new InputStreamReader(System.in));
        } else {
            br = new BufferedReader(new FileReader("in.txt"));
        }
        out = new PrintWriter(System.out);
        new Thread(new Solution()).start();
    }

    public void loadLine() {
        try {
            stk = new StringTokenizer(br.readLine());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }

    public String nextWord() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return stk.nextToken();
    }

    public Integer nextInt() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Integer.valueOf(stk.nextToken());
    }

    public Long nextLong() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Long.valueOf(stk.nextToken());
    }

    public Double nextDouble() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Double.valueOf(stk.nextToken());
    }

    public Float nextFloat() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Float.valueOf(stk.nextToken());
    }

    public void run() {
    	int n = nextInt();
    	int m = nextInt();
    	int t = nextInt();
    	int[][] b = new int[n][m];
    	int[][] s = new int[n][m];
    	int[][] c = new int[n][m];
    	for (int i = 0; i < n; i++) {
    		nextWord();
    		for (int j = 0; j < m; j++) {
    			b[i][j] = nextInt();
    			s[i][j] = nextInt();
    			c[i][j] = nextInt();
    		}
    	}
    	long bestAns = 0;
    	for (int i = 0; i < n; i++) {
    		for (int j = 0; j < n; j++) {
    			if (i == j) continue;
    			TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
    			for (int k = 0; k < m; k++) {
    				int dif = s[j][k] - b[i][k];
    				if (!map.containsKey(dif)) map.put(dif, c[i][k]);
    				else map.put(dif, map.get(dif) + c[i][k]);
    			}
    			int T = t;
    			long ans = 0;
    			while (map.size() > 0 && T > 0) {
    				int dif = map.lastKey();
    				if (dif < 0) break;
    				int cnt = Math.min(T, map.remove(dif));
    				ans += dif * cnt;
    				T -= cnt;
    			}
    			bestAns = Math.max(ans, bestAns);
    		}
    	}
    	out.println(bestAns);
    	out.flush();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Test {
	static BufferedReader reader;
	static StringTokenizer tokenizer;
	static PrintWriter writer;

	static int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	static long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	static double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	static String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	public static void main(String[] args) throws IOException {
		reader = new BufferedReader(new InputStreamReader(System.in));
		tokenizer = null;
		writer = new PrintWriter(System.out);
		solve();
		reader.close();
		writer.close();
	}

	private static void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();

		int[][]a = new int[n][m];
		int[][]b = new int[n][m];
		int[][]c = new int[n][m];

		String s;
		for(int i=0;i<n;i++)
		{
			s = nextToken();
			for(int j=0;j<m;j++)
			{
				a[i][j]=nextInt();
				b[i][j]=nextInt();
				c[i][j]=nextInt();
			}
		}

		int res=0;

		for(int i1=0;i1<n;i1++)
		{
			for(int i2=0;i2<n;i2++)
			{
				if(i2==i1)
					continue;
				ArrayList<Tov> al = new ArrayList<Tov>();
				for(int i=0;i<m;i++)
				{
					al.add(new Tov(b[i2][i]-a[i1][i],c[i1][i]));
				}
				Collections.sort(al);

//				for(int j=0;j<al.size();j++)
//				{
//					writer.println(""+al.get(j).c+" "+al.get(j).diff);
//				}
//				writer.println("---");

				int curr=0;
				int got=0;

				int t=0;
				while(t<m&&got<k)
				{
					Tov ct = al.get(t);
					if(ct.diff<0)
						break;
					if(got+ct.c<=k)
					{
						got+=ct.c;
						curr+=ct.c*ct.diff;
						t++;
					}
					else
					{
						curr+=(k-got)*ct.diff;
						got=k;
					}
				}
				if(curr>res)
					res=curr;
			}
		}
		writer.println(res);
	}
}

class Tov implements Comparable<Tov>
{
	public int diff;
	public int c;
	Tov(int diff, int c)
	{
		this.diff=diff;
		this.c=c;
	}
	@Override
	public int compareTo(Tov o) {
		return o.diff-diff;
	}
}

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {
	BufferedReader in;
	StringTokenizer str;
	PrintWriter out;
	String SK;

	String next() throws IOException {
		while ((str == null) || (!str.hasMoreTokens())) {
			SK = in.readLine();
			if (SK == null)
				return null;
			str = new StringTokenizer(SK);
		}
		return str.nextToken();
	};

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	};

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	};

	long nextLong() throws IOException {
		return Long.parseLong(next());
	};

	class Buy implements Comparable<Buy> {
		int x;
		int left;

		public Buy(int a, int b) {
			x = a;
			left = b;
		}

		public int compareTo(Buy o) {
			return x - o.x;
		}
	}

	void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		int[][] a = new int[n][m];
		int[][] b = new int[n][m];
		int[][] c = new int[n][m];
		for (int i = 0; i < n; i++) {
			String s = next();
			for (int j = 0; j < m; j++) {
				a[i][j] = nextInt();
				b[i][j] = nextInt();
				c[i][j] = nextInt();
			}
		}
		int res = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				Buy[] win = new Buy[m];
				for (int t = 0; t < m; t++) {
					win[t] = new Buy(b[j][t] - a[i][t], c[i][t]);
				}
				Arrays.sort(win);
				int curres = 0;
				int lf = k;
				for (int t = m - 1; t >= 0; t--) {
					if (win[t].x < 0) {
						break;
					}
					if (win[t].left > lf) {
						win[t].left = lf;
					}
					curres += win[t].left * win[t].x;
					lf -= win[t].left;
				}
				res = Math.max(res, curres);
			}
		}
		out.println(res);
	};

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new A().run();
	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class CodeE
{
	static class Scanner
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String nextLine()
		{
			try
			{
				return br.readLine();
			}
			catch(Exception e)
			{
				throw(new RuntimeException());
			}
		}

		public String next()
		{
			while(!st.hasMoreTokens())
			{
				String l = nextLine();
				if(l == null)
					return null;
				st = new StringTokenizer(l);
			}
			return st.nextToken();
		}

		public int nextInt()
		{
			return Integer.parseInt(next());
		}

		public long nextLong()
		{
			return Long.parseLong(next());
		}

		public double nextDouble()
		{
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n)
		{
			int[] res = new int[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextInt();
			return res;
		}

		public long[] nextLongArray(int n)
		{
			long[] res = new long[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextLong();
			return res;
		}

		public double[] nextDoubleArray(int n)
		{
			double[] res = new double[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextLong();
			return res;
		}
		public void sortIntArray(int[] array)
		{
			Integer[] vals = new Integer[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortLongArray(long[] array)
		{
			Long[] vals = new Long[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortDoubleArray(double[] array)
		{
			Double[] vals = new Double[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}
	}

	static class Entrada implements Comparable <Entrada>
	{
		int costo;
		int cuantos;

		Entrada(int co, int cu)
		{
			costo = co;
			cuantos = cu;
		}

		@Override
		public int compareTo(Entrada o)
		{
			return o.costo - costo;
		}
	}

	static class Planeta
	{
		Entrada[] cuantosCompra;
		int[] costoVenta;

		Planeta(int m)
		{
			cuantosCompra = new Entrada[m];
			costoVenta = new int[m];
		}
	}

	public static void main(String[] args)
	{
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		Planeta[] planetas = new Planeta[n];
		for(int i = 0; i < n; i++)
		{
			planetas[i] = new Planeta(m);
			sc.next();
			for(int j = 0; j < m; j++)
			{
				int co = sc.nextInt();
				int ve = sc.nextInt();
				int cu = sc.nextInt();
				planetas[i].cuantosCompra[j] = new Entrada(co, cu);
				planetas[i].costoVenta[j] = ve;
			}
		}
		int mejorGanancia = 0;
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
			{
				if(i == j)
					continue;
				Entrada[] entradasAct = new Entrada[m];
				for(int l = 0; l < m; l++)
					entradasAct[l] = new Entrada(planetas[j].costoVenta[l] - planetas[i].cuantosCompra[l].costo, planetas[i].cuantosCompra[l].cuantos);
				Arrays.sort(entradasAct);
				int kActual = k;
				int ganancia = 0;
				for(Entrada e : entradasAct)
				{
					if(e.costo < 0 || kActual == 0)
						break;
					ganancia += Math.min(kActual, e.cuantos) * e.costo;
					kActual -= Math.min(kActual, e.cuantos);
				}
				mejorGanancia = Math.max(mejorGanancia, ganancia);
			}
		System.out.println(mejorGanancia);
	}

}

import java.io.*;
import java.util.*;

public class Solution {

	private StringTokenizer st;
	private BufferedReader in;
	private PrintWriter out;

	class Pair implements Comparable<Pair> {
		int count, cost;

		public Pair(int cost, int count) {
			this.cost = cost;
			this.count = count;
		}

		@Override
		public int compareTo(Pair o) {
			return o.cost - cost;
		}
	}

	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		int[][] a = new int[n][m];
		int[][] b = new int[n][m];
		int[][] c = new int[n][m];
		for (int i = 0; i < n; ++i) {
			next();
			for (int j = 0; j < m; ++j) {
				a[i][j] = nextInt();
				b[i][j] = nextInt();
				c[i][j] = nextInt();
			}
		}
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				Pair[] ps = new Pair[m];
				for (int t = 0; t < m; ++t) {
					ps[t] = new Pair(b[j][t] - a[i][t], c[i][t]);
				}
				Arrays.sort(ps);
				int count = k;
				int val = 0;
				for (Pair p : ps) {
					if (p.cost > 0) {
						int cc = Math.min(count, p.count);
						val += cc * p.cost;
						count -= cc;
					}
				}
				ans = Math.max(ans, val);
			}
		}
		out.println(ans);
	}

	public void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		eat("");

		solve();

		out.close();
	}

	void eat(String s) {
		st = new StringTokenizer(s);
	}

	String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			if (line == null) {
				return null;
			}
			eat(line);
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public static void main(String[] args) throws IOException {
		Locale.setDefault(Locale.US);
		new Solution().run();
	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Comparator;

public class A176 {

    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(System.out);

    static int nextInt() throws Exception {
        in.nextToken();
        return (int)in.nval;
    }

    static String nextString() throws Exception {
        in.nextToken();
        return in.sval;
    }

    public static void main(String[] args) throws Exception {
        int n = nextInt(), m = nextInt(), k = nextInt();
        int[][] a = new int[n][m];
        int[][] b = new int[n][m];
        int[][] c = new int[n][m];
        for (int i = 0; i < n; i++) {
            nextString();
            for (int j = 0; j < m; j++) {
                a[i][j] = nextInt();
                b[i][j] = nextInt();
                c[i][j] = nextInt();
            }
        }

        int ans = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++) if (i != j) {
                int[][] p = new int[m][2];
                for (int r = 0; r < m; r++) {
                    p[r][0] = b[j][r] - a[i][r];
                    p[r][1] = r;
                }
                Arrays.sort(p, new Comparator<int[]>(){
                    public int compare(int[] a, int[] b) {
                        return b[0] - a[0];
                    }
                });
                int cur = 0, x = k, w = 0;
                while (x > 0 && w < m && p[w][0] > 0) {
                    int q = Math.min(x, c[i][p[w][1]]);
                    cur += q*p[w][0];
                    x -= q;
                    w++;
                }
                if (cur > ans) ans = cur;
            }

        out.println(ans);
        out.flush();
    }

}

import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author niyaznigmatul
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		FastPrinter out = new FastPrinter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    public void solve(int testNumber, FastScanner in, FastPrinter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        int[][] a = new int[n][m];
        int[][] b = new int[n][m];
        int[][] c = new int[n][m];
        for (int i = 0; i < n; i++) {
            in.next();
            for (int j = 0; j < m; j++) {
                a[i][j] = in.nextInt();
                b[i][j] = in.nextInt();
                c[i][j] = in.nextInt();
            }
        }
        boolean[] was = new boolean[m];
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j) {
                    continue;
                }
                int all = k;
                Arrays.fill(was, false);
                int profit = 0;
                while (all > 0) {
                    int min = -1;
                    for (int z = 0; z < m; z++) {
                        int val = b[j][z] - a[i][z];
                        if (was[z] || val <= 0) {
                            continue;
                        }
                        if (min < 0 || val > b[j][min] - a[i][min]) {
                            min = z;
                        }
                    }
                    if (min < 0) {
                        break;
                    }
                    int got = Math.min(all, c[i][min]);
                    all -= got;
                    profit += (b[j][min] - a[i][min]) * got;
                    was[min] = true;
                }
                ans = Math.max(ans, profit);
            }
        }
        out.println(ans);
    }
}

class FastScanner extends BufferedReader {

    boolean isEOF;

    public FastScanner(InputStream is) {
        super(new InputStreamReader(is));
    }

    public int read() {
        try {
            int ret = super.read();
            if (isEOF && ret < 0) {
                throw new InputMismatchException();
            }
            isEOF = ret == -1;
            return ret;
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    public String next() {
        StringBuilder sb = new StringBuilder();
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        while (!isWhiteSpace(c)) {
            sb.appendCodePoint(c);
            c = read();
        }
        return sb.toString();
    }

    static boolean isWhiteSpace(int c) {
        return c >= -1 && c <= 32;
    }

    public int nextInt() {
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int ret = 0;
        while (!isWhiteSpace(c)) {
            if (c < '0' || c > '9') {
                throw new NumberFormatException("digit expected " + (char) c
                        + " found");
            }
            ret = ret * 10 + c - '0';
            c = read();
        }
        return ret * sgn;
    }

    }

class FastPrinter extends PrintWriter {

    public FastPrinter(OutputStream out) {
        super(out);
    }

    public FastPrinter(Writer out) {
        super(out);
    }

}

import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Main implements Runnable {

    static String filename = "";

    public void solve() throws Exception {
        int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt();
        String[] names = new String[n];
        int[][] a = new int[n][m];
        int[][] b = new int[n][m];
        int[][] c = new int[n][m];
        for (int i = 0; i < n; i++) {
            names[i] = in.readLine();
            for (int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
                b[i][j] = sc.nextInt();
                c[i][j] = sc.nextInt();
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                int[] cost = new int[m];
                for (int ii = 0; ii < m; ii++) {
                    cost[ii] = b[j][ii] - a[i][ii];
                }
                int[][] dp = new int[m + 1][k + 1];
                for (int ii = 0; ii < m; ii++) {
                    for (int jj = 0; jj <= k; jj++) {
                        for (int kk = 0; kk <= c[i][ii] && jj + kk <= k; kk++) {
                            dp[ii + 1][jj + kk] = max(dp[ii + 1][jj + kk], dp[ii][jj] + cost[ii] * kk);
                        }
                    }
                }
                ans = max(ans, dp[m][k]);
            }
        }
        out.println(ans);
    }

    BufferedReader in;
    PrintWriter out;
    FastScanner sc;

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 1 << 25).start();
    }

    @Override
    public void run() {
        try {
            init();
            solve();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            out.close();
        }
    }

    void init() throws Exception {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        sc = new FastScanner(in);
    }
}

class FastScanner {

    BufferedReader reader;
    StringTokenizer strTok;

    public FastScanner(BufferedReader reader) {
        this.reader = reader;
    }

    public String nextToken() throws IOException {
        while (strTok == null || !strTok.hasMoreTokens()) {
            strTok = new StringTokenizer(reader.readLine());
        }

        return strTok.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

}

import java.io.*;
import java.util.*;

public class A {

	final String filename = new String("A").toLowerCase();

	void solve() throws Exception {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		int[][] a = new int[n][m], b = new int[n][m], c = new int[n][m];
		for (int i = 0; i < n; i++) {
			nextToken();
			for (int j=  0; j < m; j++) {
				a[i][j] = nextInt();
				b[i][j] = nextInt();
				c[i][j] = nextInt();
			}
		}

		int[][] dp = new int[m + 1][k + 1];
		int best = 0;
		for (int first = 0; first < n; first++) {
			for (int second = 0; second < n; second++) {
				if (first == second) {
					continue;
				}
				for (int[] i : dp) {
					Arrays.fill(i, 0);
				}
				for (int i = 1; i <= m; i++) {
					for (int j = 1; j <= k; j++) {
						for (int t = 0; t <= c[first][i - 1] && t <= j; t++) {
							dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - t] + (b[second][i - 1] - a[first][i - 1]) * t);
						}
					}
				}
				for (int i = 0; i <= k; i++) {
					best = Math.max(best, dp[m][i]);
				}
			}
		}
		out.println(best);
	}

	void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			//			in = new BufferedReader(new FileReader("input.txt"));
			//			out = new PrintWriter("output.txt");

			solve();

			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

	String nextToken() throws Exception {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws Exception {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}

	public static void main(String[] args) {
		new A().run();
	}

}

import java.io.*;
import java.util.*;
import java.math.*;

public class Goods implements Runnable {
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;
	Random rnd;

	static class Pair implements Comparable<Pair> {
		final int profit, count;

		public Pair(int profit, int count) {
			this.profit = profit;
			this.count = count;
		}

		public int compareTo(Pair p) {
			return p.profit - profit;
		}
	}

	void solve() throws IOException {
		int n = nextInt(), m = nextInt(), k = nextInt();

		int[][][] info = new int[n][m][3];

		for(int i = 0; i < n; i++) {
			nextToken();

			for(int j = 0; j < m; j++) {
				for(int z = 0; z < 3; z++) {
					info[i][j][z] = nextInt();
				}
			}
		}

		int res = 0;
		ArrayList<Pair> v = new ArrayList<Goods.Pair>();

		for(int from = 0; from < n; from++) {
			for(int to = 0; to < n; to++) {
				if(from == to) {
					continue;
				}

				v.clear();

				for(int good = 0; good < m;  good++) {
					int count = info[from][good][2];
					int price_from = info[from][good][0];
					int price_to = info[to][good][1];
					v.add(new Pair(price_to - price_from, count));
				}

				Collections.sort(v);

				int profit = 0, remain = k;

				for(Pair p : v) {
					if(p.profit <= 0) {
						continue;
					}
					int can = Math.min(remain, p.count);
					profit += can * p.profit;
					remain -= can;
				}

				res = Math.max(res, profit);
			}
		}

		out.println(res);

	}

	public static void main(String[] args) {
		new Thread(null, new Goods(), "yarrr", 1 << 24).start();
	}

	public void run() {
		try {
			final String className = this.getClass().getName().toLowerCase();

			try {
				in = new BufferedReader(new FileReader(className + ".in"));
				out = new PrintWriter(new FileWriter(className + ".out"));
			} catch (FileNotFoundException e) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(42);
		}
	}

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null) {
				return null;
			}

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

import java.io.*;
import java.util.*;

public class Main implements Runnable {

    public void _main() throws Exception {
	int n = nextInt();
	int m = nextInt();
	int k = nextInt();
	int[][] a = new int[n][m];
	int[][] b = new int[n][m];
	int[][] c = new int[n][m];
	for (int i = 0; i < n; i++) {
	    next();
	    for (int j = 0; j < m; j++) {
		a[i][j] = nextInt();
		b[i][j] = nextInt();
		c[i][j] = nextInt();
	    }
	}
	int res = 0;
	for (int from = 0; from < n; from++) {
	    for (int to = 0; to < n; to++) {
		if (from == to) continue;
		Goods[] g = new Goods[m];
		for (int i = 0; i < m; i++) {
		    int cost = -a[from][i] + b[to][i];
		    int am = c[from][i];
		    g[i] = new Goods(cost, am);
		}
		Arrays.sort(g);
		int space = k;
		int cur = 0;
		for (int i = 0; i < m; i++) {
		    int take = Math.min(g[i].am, space);
		    if (g[i].cost >= 0) {
			cur += take * g[i].cost;
		    }
		    space -= take;
		}
		res = Math.max(res, cur);
	    }
	}
	out.println(res);
    }

    class Goods implements Comparable<Goods> {
	int cost;
	int am;

	public Goods(int cost, int am) {
	    this.cost = cost;
	    this.am = am;
	}

	public int compareTo(Goods o) {
	    if (cost != o.cost) {
		return cost > o.cost ? -1 : 1;
	    }
	    return am - o.am;
	}
    }

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer st;

    private String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String rl = in.readLine();
            if (rl == null) return null;
            st = new StringTokenizer(rl);
        }
        return st.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            _main();

            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(202);
        }
    }

    public static void main(String[] args) {
        new Thread(new Main()).run();
    }

}

import java.util.Scanner;

public class C {

    public static void main(String[] argv){
        Scanner in = new Scanner ( System.in );
        int n=in.nextInt();
        int m=in.nextInt();
        int k=in.nextInt();
        int[][] a=new int[n][m];int[][] b=new int[n][m];int[][] c=new int[n][m];

        for(int i=0; i<n; i++){
            in.next();
            for(int j=0; j<m; j++){
                a[i][j]=in.nextInt(); b[i][j]=in.nextInt(); c[i][j]=in.nextInt();
            }
        }

        int Profit=0;
        for(int s=0; s<n; s++){
            for(int d=0; d<n; d++ ){
                if(d==s)continue;

                int[] aa_source=new int[m]; int[] bb_source=new int[m]; int[] cc_source=new int[m];
                for(int ii=0; ii<m; ii++){
                    aa_source[ii]=a[s][ii];
                    bb_source[ii]=b[s][ii];
                    cc_source[ii]=c[s][ii];
                }
                int[] aa_dest=new int[m]; int[] bb_dest=new int[m]; int[] cc_dest=new int[m];
                for(int ii=0; ii<m; ii++){
                    aa_dest[ii]=a[d][ii];
                    bb_dest[ii]=b[d][ii];
                    cc_dest[ii]=c[d][ii];
                }

                int charge=0;
                int temp_profit=0;
                //int ind=-1;
                while(charge<k){
                    int ind=-1;
                    int temp=0;
                    for(int i=0; i<m; i++){
                        if((bb_dest[i]-aa_source[i])>=temp & cc_source[i]!=0){
                            temp=(bb_dest[i]-aa_source[i]);
                            ind=i;
                        }
                    }
                    if(ind==-1)
                        break;
                    temp_profit+=(bb_dest[ind]-aa_source[ind]);
                    cc_source[ind]--;
                    charge++;
                }

                Profit=Math.max(temp_profit, Profit);
            }

        }
        System.out.println(Profit);

    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Locale;
import java.util.StringTokenizer;

public class A {

	private class Planet {
		public final int id;
		public final int[] a;
		public final int[] b;
		public final int[] c;

		public Planet(int id, int m) {
			this.id = id;
			a = new int[m];
			b = new int[m];
			c = new int[m];
		}
	}

	private void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();

		Planet[] p = new Planet[n];
		for (int i = 0; i < n; i++) {
			nextToken();
			p[i] = new Planet(i, m);
			for (int j = 0; j < m; j++) {
				p[i].a[j] = nextInt();
				p[i].b[j] = nextInt();
				p[i].c[j] = nextInt();
			}
		}

		int res = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i != j) {
					res = Math.max(res, f(p[i], p[j], k));
				}
			}
		}

		println(res);
	}

	private int f(Planet s, Planet t, int k) {
		int res = 0;

		int m = s.a.length;
		int[] a = new int[m];
		int[] b = new int[m];
		int[] c = new int[m];
		for (int i = 0; i < m; i++) {
			a[i] = s.a[i];
			b[i] = t.b[i];
			c[i] = s.c[i];
		}

		while (k != 0) {
			int j = -1;
			for (int i = 0; i < m; i++) {
				if (c[i] != 0 && (j == -1 || (b[j] - a[j]) < b[i] - a[i])) {
					j = i;
				}
			}

			if (j == -1 || b[j] - a[j] <= 0) {
				break;
			}

			int p = Math.min(k, c[j]);
			res += p * (b[j] - a[j]);
			k -= p;
			c[j] -= p;
		}

		return res;
	}

	private String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	private int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	private double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private void print(Object o) {
		writer.print(o);
	}

	private void println(Object o) {
		writer.println(o);
	}

	private void printf(String format, Object... o) {
		writer.printf(format, o);
	}

	public static void main(String[] args) {
		long time = System.currentTimeMillis();
		Locale.setDefault(Locale.US);
		new A().run();
		System.err.printf("%.3f\n", 1e-3 * (System.currentTimeMillis() - time));
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	private void run() {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(13);
		}
	}
}

import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;

public class A {

        final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null;
        BufferedReader in;
        PrintWriter out;
        StringTokenizer tok = new StringTokenizer("");

        void init() throws FileNotFoundException{
                if (ONLINE_JUDGE){
                        in = new BufferedReader(new InputStreamReader(System.in));
                        out = new PrintWriter(System.out);
                }else{
                        in = new BufferedReader(new FileReader("input.txt"));
                        out = new PrintWriter("output.txt");
                }
        }

        String readString() throws IOException{
                while(!tok.hasMoreTokens()){
                        tok = new StringTokenizer(in.readLine());
                }
                return tok.nextToken();
        }

        int readInt() throws IOException{
                return Integer.parseInt(readString());
        }

        long readLong() throws IOException{
                return Long.parseLong(readString());
        }

        double readDouble() throws IOException{
                return Double.parseDouble(readString());
        }

        int[] readArr(int n) throws IOException{
        	int[] res = new int[n];
        	for(int i = 0; i < n; i++){
        		res[i] = readInt();
        	}
        	return res;
        }

        long[] readArrL(int n) throws IOException{
        	long[] res = new long[n];
        	for(int i = 0; i < n; i++){
        		res[i] = readLong();
        	}
        	return res;
        }

        public static void main(String[] args){
                new A().run();
        }

        public void run(){
                try{
                        long t1 = System.currentTimeMillis();
                        init();
                        solve();
                        out.close();
                        long t2 = System.currentTimeMillis();
                        System.err.println("Time = "+(t2-t1));
                }catch (Exception e){
                        e.printStackTrace(System.err);
                        System.exit(-1);
                }
        }

        void solve() throws IOException{
        	int n = readInt();
        	int m = readInt();
        	int k = readInt();

        	int[][] a = new int[n][m];

        	int[][] b = new int[n][m];

        	int[][] c = new int[n][m];

        	for(int i = 0; i < n; i++){
        		String s = readString();
        		for(int j = 0; j < m; j++){
        			a[i][j] = readInt();
        			b[i][j] = readInt();
        			c[i][j] = readInt();
        		}
        	}
        	int max = 0;
        	for(int i = 0; i < n; i++){
        		for(int j = 0; j < n; j++){
        			if(i == j) continue;
        			Point[] cur = new Point[m];

        			for(int l = 0; l < m; l++){
        				cur[l] = new Point(-a[i][l] + b[j][l], l);
        			}

        			Arrays.sort(cur, new Comparator<Point>() {

						@Override
						public int compare(Point o1, Point o2) {
							return -o1.x + o2.x;
						}

					});

        			int curK = k;
        			int curSum = 0;
        			int i1 = 0;

        			while(curK > 0 && i1 < m){
        				if(cur[i1].x < 0) break;
        				if(curK >= c[i][cur[i1].y]){
        					curK -= c[i][cur[i1].y];
        					curSum += c[i][cur[i1].y] * cur[i1].x;
        					i1++;
        				}
        				else{
        					curSum += curK * cur[i1].x;
        					curK = 0;
        				}
        			}
        			if(curSum > max) max = curSum;
        		}
        	}
        	out.println(max);
        }

        void maxHepify(int[] a, int i, int length){
        	int l = (i<<1) + 1;
        	int r = (i<<1) + 2;
        	int largest = i;
        	if(l < length && a[l] > a[largest])
        		largest = l;
        	if(r < length && a[r] > a[largest])
        		largest = r;
        	if(largest != i){
        		a[largest] += a[i];
        		a[i] = a[largest] - a[i];
        		a[largest] -= a[i];
        		maxHepify(a, largest, length);
        	}
        }

        void buildMaxHeap(int[] a){
        	for(int i = a.length/2 - 1; i >= 0; i--){
        		maxHepify(a, i, a.length);
        	}
        }

        void heapSort(int[] a){
        	buildMaxHeap(a);
        	for(int i = a.length - 1; i > 0; i--){
        		a[i] += a[0];
        		a[0] = a[i] - a[0];
        		a[i] -= a[0];
        		maxHepify(a, 0, i);
        	}
        }

        int[] zFunction(char[] s){
        	int[] z = new int[s.length];
        	z[0] = 0;
        	for (int i=1, l=0, r=0; i<s.length; ++i) {
        		if (i <= r)
        			z[i] = min (r-i+1, z[i-l]);
        		while (i+z[i] < s.length && s[z[i]] == s[i+z[i]])
        			++z[i];
        		if (i+z[i]-1 > r){
        			l = i;
        			r = i+z[i]-1;
        		}
        	}
        	return z;
        }

        int[] prefixFunction(char[] s){
        	int[] pr = new int[s.length];
        	for (int i = 1; i< s.length; ++i) {
        		int j = pr[i-1];
        		while (j > 0 && s[i] != s[j])
        			j = pr[j-1];
        		if (s[i] == s[j])  ++j;
        		pr[i] = j;
        	}
        	return pr;
        }

        int ModExp(int a, int n, int mod){
        	int res = 1;
        	while (n!=0)
        		if ((n & 1) != 0) {
        			res = (res*a)%mod;
        			--n;
        		}
        		else {
        			a = (a*a)%mod;
        			n >>= 1;
        		}
        	return res;
        }

        public static class Utils {

        	private Utils() {}

        	public static void mergeSort(int[] a) {
                    mergeSort(a, 0, a.length - 1);
            }

        	private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
                    final int MAGIC_VALUE = 50;
                    if (leftIndex < rightIndex) {
                            if (rightIndex - leftIndex <= MAGIC_VALUE) {
                                    insertionSort(a, leftIndex, rightIndex);
                            } else {
                                    int middleIndex = (leftIndex + rightIndex) / 2;
                                    mergeSort(a, leftIndex, middleIndex);
                                    mergeSort(a, middleIndex + 1, rightIndex);
                                    merge(a, leftIndex, middleIndex, rightIndex);
                            }
                    }
            }

            private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
            	int length1 = middleIndex - leftIndex + 1;
            	int length2 = rightIndex - middleIndex;
                int[] leftArray = new int[length1];
                int[] rightArray = new int[length2];
                System.arraycopy(a, leftIndex, leftArray, 0, length1);
                System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
                for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
                    if (i == length1) {
                            a[k] = rightArray[j++];
                    } else if (j == length2) {
                            a[k] = leftArray[i++];
                    } else {
                            a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
                    }
                }
            }

            private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
                for (int i = leftIndex + 1; i <= rightIndex; i++) {
            		int current = a[i];
                    int j = i - 1;
                	while (j >= leftIndex && a[j] > current) {
                        a[j + 1] = a[j];
                        j--;
                        }
                    a[j + 1] = current;
                }
            }
        }

        boolean isPrime(int a){
        	for(int i = 2; i <= sqrt(a); i++)
        		if(a % i == 0) return false;
        	return true;
        }

        static double distance(long x1, long y1, long x2, long y2){
        	return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        }

        static long gcd(long a, long b){
        	if(min(a,b) == 0) return max(a,b);
        	return gcd(max(a, b) % min(a,b), min(a,b));
        }

        static long lcm(long a, long b){
        	return a * b /gcd(a, b);
        }
}

/*class Treap<K extends Comparable<K>>{

	public K x;
	public double y;
	public Treap<K> left;
	public Treap<K> right;

	public Treap(K x, double y, Treap<K> left, Treap<K> right) {
		this.x = x;
		this.y = y;
		this.left = left;
		this.right = right;
	}

	public static <K extends Comparable<K>> Treap<K> merge(Treap<K> l, Treap<K> r){
		if(l == null) return r;
		if(r == null) return l;
		if(l.y > r.y){
			return new Treap<K>(l.x, l.y, l.left, merge(l.right, r));
		}
		else{
			return new Treap<K>(r.x, r.y, merge(l, r.left), r.right);
		}
	}

	public void split(K x, Treap<K> left, Treap<K> right){
		Treap<K> newTreap = null;
		if(this.x.compareTo(x) <= 0){
			if(this.right == null){
				right = null;
			}
			else{
				right.split(x, newTreap, right);
			}
			left = new Treap<K>(this.x, this.y, left, newTreap);
		}
		else{
			if(this.left == null){
				left = null;
			}
			else{
				left.split(x, left, newTreap);
			}
			right = new Treap<K>(x, y, newTreap, right);
		}
	}

	public Treap<K> add(K x){
		Treap<K> left = null, right = null;
		this.split(x, left, right);
		Treap<K> temp = new Treap<K>(x, random(), null, null);
		return merge(merge(left, temp), right);
	}

	@SuppressWarnings("null")
	public Treap<K> remove(K x){
		Treap<K> left = null, temp = null, right = null;
		this.split(x, left, right);
		right.split(x, temp, right);
		return merge(left, right);
	}

	public static <K extends Comparable<K>> Treap<K> build(K[] a){
		Treap<K> temp = new Treap<K>(a[0], random(), null, null);
		for(int i = 1; i < a.length; i++){
			temp = temp.add(a[i]);
		}
		return temp;
	}
}*/

import java.util.*;
import java.awt.*;

public class A
{
	/*
	public static Comparator<Point> cmp = new Comparator<Point>()
	{
		public int compare(Point a, Point b)
		{

		}
	};
	*/

	public static void main(String args[])
	{
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int m = scan.nextInt();
		int k = scan.nextInt();

		int[][] a = new int[n][m];
		int[][] b = new int[n][m];
		int[][] c = new int[n][m];

		for(int i=0;i < n;i++)
		{
			scan.next();
			for(int j=0;j < m;j++)
			{
				a[i][j] = scan.nextInt();
				b[i][j] = scan.nextInt();
				c[i][j] = scan.nextInt();
			}
		}

		//Process
		int rtn = 0;

		for(int i=0;i < n;i++)
		for(int j=0;j < n;j++)
		{
			if(i == j) continue;

			ArrayList<Integer> al = new ArrayList<Integer>();

			for(int ii=0;ii < m;ii++)
			{
				int val = b[j][ii] - a[i][ii];
				//System.out.println("\t" + i + " " + j + " " + ii + " " + val + " " + c[i][ii]);
				if(val <= 0) continue;
				for(int jj=0;jj < c[i][ii];jj++)
					al.add(val);

			}

			//System.out.println("\t" + al.size());
			Collections.sort(al);
			int subrtn = 0;

			for(int ii=al.size()-1;ii >= Math.max(0, al.size()-k);ii--)
				subrtn += al.get(ii);

			//System.out.println(i + " " + j + " " + subrtn);
			rtn = Math.max(rtn, subrtn);
		}

		System.out.println(rtn);
	}
}

import java.io.*;
import java.util.*;

public class taskA {

	PrintWriter out;
	BufferedReader br;
	StringTokenizer st;

	String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		long[][] a = new long[n][m];
		long[][] b = new long[n][m];
		long[][] c = new long[n][m];
		for (int i = 0; i < n; i++) {
			String s = nextToken();
			for (int j = 0; j < m; j++) {
				a[i][j] = nextInt();
				b[i][j] = nextInt();
				c[i][j] = nextInt();
			}
		}
		long ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i == j)
					continue;
				int l = k;
				boolean[] was = new boolean[m];
				int max = 0;
				long profit = 0;
				while ((l > 0)) {
					for (int t = 0; t <  m; t++) {
						if ((!was[t]) && ((b[j][t] - a[i][t] > b[j][max] - a[i][max]) || (was[max])))
							max = t;
					}
					if (was[max])
						break;
					if (b[j][max] - a[i][max] <= 0)
						break;
					profit += Math.min(l, c[i][max]) * (b[j][max] - a[i][max]);
					was[max] = true;
					l -= Math.min(l, c[i][max]);

				}
				if (profit > ans)
					ans = profit;
			}
		}
		out.println(ans);

	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			//br = new BufferedReader(new FileReader("taskA.in"));
			//out = new PrintWriter("taskA.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new taskA().run();
	}
}

import java.awt.Point;
import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class CROC2012_Round2_A implements Runnable {

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;

	public static void main(String[] args) {
		new Thread(null, new CROC2012_Round2_A(), "", 256 * (1L << 20)).start();
	}

	@Override
	public void run() {
		try {
			long startTime = System.currentTimeMillis();
			if (ONLINE_JUDGE) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			} else {
				in = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter("output.txt");
			}
			Locale.setDefault(Locale.US);
			tok = new StringTokenizer("");
			solve();
			in.close();
			out.close();
			long freeMemory = Runtime.getRuntime().freeMemory();
			long totalMemory = Runtime.getRuntime().totalMemory();
			long endTime = System.currentTimeMillis();
			System.err.println("Time = " + (endTime - startTime));
			System.err.println("Memory = " + ((totalMemory - freeMemory) >> 10));
		} catch (Throwable t) {
			t.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}

	void debug(Object... o) {
		if (!ONLINE_JUDGE) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	/** http://pastebin.com/j0xdUjDn */
	static class Utils {

		private Utils() {}

		public static void mergeSort(int[] a) {
			mergeSort(a, 0, a.length - 1);
		}

		private static final int MAGIC_VALUE = 50;

		private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
			if (leftIndex < rightIndex) {
				if (rightIndex - leftIndex <= MAGIC_VALUE) {
					insertionSort(a, leftIndex, rightIndex);
				} else {
					int middleIndex = (leftIndex + rightIndex) / 2;
					mergeSort(a, leftIndex, middleIndex);
					mergeSort(a, middleIndex + 1, rightIndex);
					merge(a, leftIndex, middleIndex, rightIndex);
				}
			}
		}

		private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
			int length1 = middleIndex - leftIndex + 1;
			int length2 = rightIndex - middleIndex;
			int[] leftArray = new int[length1];
			int[] rightArray = new int[length2];
			System.arraycopy(a, leftIndex, leftArray, 0, length1);
			System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
			for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
				if (i == length1) {
					a[k] = rightArray[j++];
				} else if (j == length2) {
					a[k] = leftArray[i++];
				} else {
					a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
				}
			}
		}

		private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
			for (int i = leftIndex + 1; i <= rightIndex; i++) {
				int current = a[i];
				int j = i - 1;
				while (j >= leftIndex && a[j] > current) {
					a[j + 1] = a[j];
					j--;
				}
				a[j + 1] = current;
			}
		}

	}

	// solution

	void solve() throws IOException {
		int n = readInt();
		int m = readInt();
		int k = readInt();
		int[][] a = new int[n][m];
		int[][] b = new int[n][m];
		int[][] c = new int[n][m];
		for (int i = 0; i < n; i++) {
			String name = readString();
			for (int j = 0; j < m; j++) {
				a[i][j] = readInt();
				b[i][j] = readInt();
				c[i][j] = readInt();
			}
		}
		int best = 0;
		for (int from = 0; from < n; from++) {
			for (int to = 0; to < n; to++) {
				if (from != to) {
					int cur = solve(m, k, a[from], b[to], c[from]);
					best = max(best, cur);
				}
			}
		}
		out.println(best);
	}

	class PointComparator implements Comparator<Point> {

		@Override
		public int compare(Point o1, Point o2) {
			if (o1.x > o2.x) return -1;
			if (o1.x < o2.x) return 1;
			return 0;
		}

	}

	PointComparator comparator = new PointComparator();

	private int solve(int m, int k, int[] buyCost, int[] sellCost, int[] remaining) {
		List<Point> list = new ArrayList<Point>();
		int all = 0;
		for (int i = 0; i < m; i++) {
			if (buyCost[i] < sellCost[i] && remaining[i] > 0) {
				list.add(new Point(sellCost[i] - buyCost[i], remaining[i]));
				all += remaining[i];
			}
		}
		Collections.sort(list, comparator);
		int rem = min(k, all);
		int ans = 0;
		for (int i = 0; i < list.size(); i++) {
			int val = list.get(i).x;
			int cnt = list.get(i).y;
			if (rem >= cnt) {
				ans += cnt * val;
				rem -= cnt;
			} else {
				ans += rem * val;
				rem = 0;
			}
			if (rem <= 0) {
				break;
			}
		}
		return ans;
	}

}

/**
 * Created with IntelliJ IDEA.
 * User: Zakhar_Voit
 * Date: 21.04.12
 * Time: 1:48
 */

import java.io.*;
import java.util.*;

import static java.lang.System.exit;

public class C {

    class Pair implements Comparable<Pair> {
        long u;
        long v;

        public Pair(long u, long v) {
            this.u = u;
            this.v = v;
        }

        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return (int) (hu * 31 + hv);
        }

        public boolean equals(Object o) {
            Pair other = (Pair) o;
            return u == other.u && v == other.v;
        }

        public int compareTo(Pair other) {
            if (u != other.u)
                return u < other.u ? -1 : 1;

            return v < other.v ? -1 : v > other.v ? 1 : 0;
        }

        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }

    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");

    public void openIO() throws IOException {
        if (new File("input.txt").exists()) {
            System.setIn(new FileInputStream("input.txt"));
            out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
        } else {
            out = new PrintWriter(System.out);
        }
        in = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() throws IOException {
        while (!st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextLine() throws IOException {
        st = new StringTokenizer("");
        return in.readLine();
    }

    boolean EOF() throws IOException {
        while (!st.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null)
                return true;
            st = new StringTokenizer(s);
        }
        return false;
    }

    int n, m, k, ans = 0;
    int[][] a, b, c;

    static void swap(int[] a, int i, int j) {
        int t = a[j];
        a[j] = a[i];
        a[i] = t;
    }

    void init() {

    }

    void read() throws IOException {
        n = nextInt();
        m = nextInt();
        k = nextInt();
        a = new int[n][m];
        b = new int[n][m];
        c = new int[n][m];
        for (int i = 0; i < n; i++) {
            nextLine();
            for (int j = 0; j < m; j++) {
                a[i][j] = nextInt();
                b[i][j] = nextInt();
                c[i][j] = nextInt();
            }
        }
    }

    void solve() {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                int[] diff = new int[m], cnt = new int[m];
                for (int k = 0; k < m; k++) cnt[k] = c[i][k];
                for (int k = 0; k < m; k++) {
                    diff[k] = Math.max(0, b[j][k] - a[i][k]);
                }
                for (int t = 0; t < m; t++) {
                    for (int c = 0; c + 1< m; c++) {
                        if (diff[c] < diff[c + 1]) {
                            swap(diff, c, c + 1);
                            swap(cnt, c, c + 1);
                        }
                    }
                }
                int cur = 0, profit = 0, idx = 0;
                while (cur < k && idx < m) {
                    int lastcur = cur;
                    cur += Math.min(k - lastcur, cnt[idx]);
                    profit += Math.min(k - lastcur, cnt[idx]) * diff[idx];
                    idx++;
                }
                ans = Math.max(ans, profit);
            }
        }
    }

    void write() {
        out.println(ans);
    }

    public void run() throws IOException {
        openIO();
        init();
        read();
        solve();
        write();
        out.close();
    }

    static public void main(String[] args) throws IOException {
        new Thread(null, new Runnable() {
            public void run() {
                try {
                    new C().run();
                } catch (Throwable e) {
                    e.printStackTrace();
                    exit(999);
                }
            }
        }, "1", 1 << 23).start();
    }
}

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.InputMismatchException;

/**
 * http://codeforces.com/contest/181/problem/C
 *
 * @author sultan.of.swing
 *
 */

public class TaskC {

	public FasterScanner mFScanner;
	public PrintWriter mOut;
	int planets;
	int types, capacity;
	int buy[][], sell[][], items[][];

	public TaskC() {
		mFScanner = new FasterScanner();
		mOut = new PrintWriter(System.out);
	}

	public void solve() {

		planets = mFScanner.nextInt();
		types = mFScanner.nextInt();
		capacity = mFScanner.nextInt();

		buy = new int[planets][types];
		sell = new int[planets][types];
		items = new int[planets][types];

		int i, j;

		for (i = 0; i < planets; i++) {
			mFScanner.nextLine();
			for (j = 0; j < types; j++) {
				buy[i][j] = mFScanner.nextInt();
				sell[i][j] = mFScanner.nextInt();
				items[i][j] = mFScanner.nextInt();
			}
		}

		long profit = 0;

		for (i = 0; i < planets; i++) {
			for (j = 0; j < planets; j++) {

				if (i == j)
					continue;

				profit = Math.max(profit, maxProfit(i, j));

			}
		}

		mOut.println(profit);

	}

	public long maxProfit(int planetBuy, int planetSell) {
		ArrayList<Items> profitItems = new ArrayList<>();
		int profit;

		for (int i = 0; i < types; i++) {
			profit = sell[planetSell][i] - buy[planetBuy][i];
			if (profit >= 0)
				profitItems.add(new Items(profit, this.items[planetBuy][i]));
		}

		Collections.sort(profitItems);
		profit = 0;
		long capacity = 0;
		int remCap = this.capacity;

		for (int i = 0; i < profitItems.size(); i++) {

			capacity = profitItems.get(i).capacity;
			capacity = Math.min(capacity, remCap);

			profit += (1L * capacity * profitItems.get(i).profit);
			remCap -= capacity;

		}

		return profit;

	}

	class Items implements Comparable<Items> {
		int profit;
		int capacity;

		public Items(int profit, int capacity) {
			this.profit = profit;
			this.capacity = capacity;
		}

		@Override
		public int compareTo(Items o) {
			// TODO Auto-generated method stub
			return Integer.compare(o.profit, this.profit);
		}
	}

	public void flush() {
		mOut.flush();
	}

	public void close() {
		mOut.close();
	}

	public static void main(String[] args) {
		TaskC mSol = new TaskC();
		mSol.solve();
		mSol.flush();
		mSol.close();
	}

	class FasterScanner {
		private InputStream mIs;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FasterScanner() {
			this(System.in);
		}

		public FasterScanner(InputStream is) {
			mIs = is;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = mIs.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public double nextDouble() {
			Double next;
			next = Double.parseDouble(nextString());
			return next;
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public char[] nextCharArray(int N) {
			int i;
			char[] array;
			String str;

			array = new char[N];

			i = 0;

			str = nextLine();

			for (i = 0; i < N && i < str.length(); i++) {
				array[i] = str.charAt(i);
			}

			return array;
		}

		public char[][] nextChar2DArray(int M, int N) {
			int i;
			char[][] array;

			array = new char[M][N];

			i = 0;

			for (i = 0; i < M; i++) {
				array[i] = nextCharArray(N);
			}

			return array;
		}

		public int[] nextIntArray(int N) {
			int i;
			int[] array;

			array = new int[N];

			i = 0;

			for (i = 0; i < N; i++) {
				array[i] = nextInt();
			}

			return array;
		}

		public int[][] nextInt2DArray(int M, int N) {
			int i;
			int[][] array;

			array = new int[M][N];

			i = 0;

			for (i = 0; i < M; i++) {
				array[i] = nextIntArray(N);
			}

			return array;
		}

		public long[] nextLongArray(int N) {
			int i;
			long[] array;

			array = new long[N];

			i = 0;

			for (i = 0; i < N; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public long[][] nextLong2DArray(int M, int N) {
			int i;
			long[][] array;

			array = new long[M][N];

			i = 0;

			for (i = 0; i < M; i++) {
				array[i] = nextLongArray(N);
			}

			return array;
		}

		public double[] nextDoubleArray(int N) {
			int i;
			double[] array;

			array = new double[N];

			for (i = 0; i < N; i++) {
				array[i] = nextDouble();
			}

			return array;
		}

		public double[][] nextDouble2DArray(int M, int N) {
			int i;
			double[][] array;

			array = new double[M][N];

			for (i = 0; i < M; i++) {
				array[i] = nextDoubleArray(N);
			}

			return array;
		}

	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C181 {

    static StringTokenizer st;
    static BufferedReader in;
    static PrintWriter pw;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int m = nextInt();
        int k = nextInt();
        int[][]a = new int[n+1][m+1], b = new int[n+1][m+1], c = new int[n+1][m+1];
        for (int i = 1; i <= n; i++) {
            next();
            for (int j = 1; j <= m; j++) {
                a[i][j] = nextInt();
                b[i][j] = nextInt();
                c[i][j] = nextInt();
            }
        }
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (i != j) {
                    int sum = 0;
                    int[]cc = c[i].clone();
                    for (int j2 = 1; j2 <= k; j2++) {
                        int max = 0, t = 0;
                        for (int j3 = 1; j3 <= m; j3++) {
                            if (b[j][j3]-a[i][j3] > max && cc[j3] > 0) {
                                max = b[j][j3]-a[i][j3];
                                t = j3;
                            }
                        }
                        if (max==0)
                            break;
                        sum += max;
                        cc[t]--;
                    }
                    ans = Math.max(ans, sum);
                }
            }
        }
        System.out.println(ans);
        pw.close();
    }
    private static int nextInt() throws IOException{
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException{
        return Long.parseLong(next());
    }

    private static double nextDouble() throws IOException{
        return Double.parseDouble(next());
    }

    private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
}

import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * User: Linkov Mikl
 * Date: 20.04.12
 * Time: 18:49
 * To change this template use File | Settings | File Templates.
 */
public class ProblemThree {
    static class Planet {
        private int m;
        private int [] a;
        private int [] b;
        private int [] c;

        public Planet(int m) {
            this.m = m;
            a = new int[m];
            b = new int[m];
            c = new int[m];
        }

        public void set(int i, int a, int b, int c) {
            this.a[i] = a;
            this.b[i] = b;
            this.c[i] = c;
        }

    }

    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int k = scanner.nextInt();

        Planet [] planets = new Planet[n];

        scanner.nextLine();
        for (int i = 0; i < n; i++) {
            scanner.nextLine();
            Planet planet = new Planet(m);

            for (int j = 0; j < m; j++) {
                int a = scanner.nextInt();
                int b = scanner.nextInt();
                int c = scanner.nextInt();

                planet.set(j, a, b, c);
            }
            planets[i] = planet;
            scanner.nextLine();
        }

        int max = 0;

        for (int i = 0; i < n; i++) {

            for (int j = 0; j < n; j++) {
                if (i == j) {
                    continue;
                }
                int [] d = new int[m];
                int sum = 0;

                for (int index = 0; index < m; index++) {
                    d[index] = planets[i].b[index] - planets[j].a[index];

                }

                int count = 0;
                int [] bool = new int[m];

                while (true) {

                    int maxx = -1000000;
                    int pos = -1;
                    for (int ind = 0; ind < m; ind++) {
                        if (bool[ind] == 0) {
                            if (d[ind] > maxx) {
                                maxx = d[ind];
                                pos = ind;
                            }
                        }
                    }

                    if (maxx <= 0) {
                        break;
                    }

                    if (count + planets[j].c[pos] <= k) {
                        sum += planets[j].c[pos] * d[pos];
                        bool[pos] = 1;
                        count += planets[j].c[pos];
                    } else {
                        sum += (k - count) * d[pos];
                        bool[pos] = 1;
                        break;
                    }
                }
                if (sum > max) {
                    max = sum;
                }
            }

        }
        System.out.println(max);
    }
}

import java.io.*;
import java.util.*;

public class test3
{

	public static void main(String[] args) throws Exception
	{
		new test3().run();
	}

	PrintWriter out = null;

	Product[][] products = null;
	int n, m, k;
	int max = 0;

	void Trade(int x, int y)
	{
		for (int i = 0; i < m; i++)
		{
			if (products[x][i].a < products[y][i].b && products[x][i].c != 0)
				products[x][i].d = products[y][i].b - products[x][i].a;
			else
				products[x][i].d = -1;
		}

		Arrays.sort(products[x]);

		int total = 0;
		int i = 0;
		int kk = k;

		while (kk > 0 && i < m)
		{
			if (products[x][i].d < 0)
				break;

			total += products[x][i].d * Math.min(products[x][i].c, kk);
			kk -= Math.min(products[x][i].c, kk);
			i++;
		}

		max = Math.max(max, total);

		Arrays.sort(products[x], new Comparator<Product>()
		{
			public int compare(Product o1, Product o2)
			{
				return o1.id - o2.id;
			}
		});
	}

	void run() throws Exception
	{
		Scanner in = new Scanner(System.in);
		out = new PrintWriter(System.out);

		n = in.nextInt();
		m = in.nextInt();
		k = in.nextInt();

		products = new Product[n][m];

		for (int i = 0; i < n; i++)
		{
			in.next();
			for (int j = 0; j < m; j++)
			{
				products[i][j] = new Product(j, in.nextInt(), in.nextInt(),
						in.nextInt());
			}
		}

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
			{
				if (i == j)
					continue;

				Trade(i, j);
			}

		out.println(max);
		out.close();
	}
}

class Product implements Comparable<Product>
{
	int id;
	int a;
	int b;
	int c;
	int d;

	public Product(int _id, int _a, int _b, int _c)
	{
		id = _id;
		a = _a;
		b = _b;
		c = _c;
	}

	public int compareTo(Product o)
	{
		return o.d - d;
	}
}

import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.Vector;

public class Main {

	static Vector<Vector<State> > v = new Vector<Vector<State> >();
	public static void main(String[] args) throws IOException {
		v.setSize(12);

		BufferedReader cin = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tok = new StringTokenizer(cin.readLine());
		int n = Integer.parseInt(tok.nextToken());
		int m = Integer.parseInt(tok.nextToken());
		int k = Integer.parseInt(tok.nextToken());
		for (int i = 0; i < n; i++) {
			v.set(i, new Vector<State>());
			cin.readLine();
			for (int j = 0; j < m; j++) {
				State s = new State();
				tok = new StringTokenizer(cin.readLine());
				s.a = Integer.parseInt(tok.nextToken());
				s.b = Integer.parseInt(tok.nextToken());
				s.c = Integer.parseInt(tok.nextToken());
				v.get(i).add(s);
			}
		}

		int mx=0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if(i == j) continue;
				int val = 0;
				Vector<Point> pro = new Vector<Point>();
				for (int kk = 0; kk < v.get(i).size(); kk++) {
					if(v.get(j).get(kk).b <= v.get(i).get(kk).a) continue;
					pro.add(new Point(v.get(j).get(kk).b - v.get(i).get(kk).a, v.get(i).get(kk).c));
				}
				int lim = k;
				Collections.sort(pro, new cmp());
				for (int kk = 0; kk < pro.size(); kk++) {
					if(pro.get(kk).y <= lim){
						lim -= pro.get(kk).y;
						val += pro.get(kk).x*pro.get(kk).y;
					}
					else{
						val += pro.get(kk).x*lim;
						break;
					}
				}
				mx = Math.max(mx,val);
			}
		}
		System.out.println(mx);
	}

}
class State{
	public int a,b,c;

}

class cmp implements Comparator<Point>{

	@Override
	public int compare(Point o1, Point o2) {
		if(o1.x > o2.x) return -1;
		if(o1.x < o2.x) return 1;
		if(o1.y > o2.y) return -1;
		if(o1.y < o2.y) return 1;
		return 0;
	}

}

import java.util.*;
import java.math.*;
import java.awt.Point;
import java.io.*;
public class Main
	{
	public static void main(String args[])	throws IOException
		{
		BufferedReader c=new BufferedReader(new InputStreamReader(System.in));
		String S[]=c.readLine().split(" ");
		int N=Integer.parseInt(S[0]);
		int M=Integer.parseInt(S[1]);
		int K=Integer.parseInt(S[2]);

		int costs[][][]=new int[N][M][3];
		for(int i=0;i<N;i++)
			{
			c.readLine();
			for(int j=0;j<M;j++)
				{
				String temp[]=c.readLine().split(" ");
				for(int k=0;k<3;k++)
					costs[i][j][k]=Integer.parseInt(temp[k]);
				}
			}

		int max=0;
		for(int i=0;i<N;i++)
			{
			for(int j=0;j<N;j++)
				{
				if(i!=j)
					{
					//buy at i and sell at j
					int profits[]=new int[M];
					int maxBuy[]=new int[M];
					for(int k=0;k<M;k++)
						{
						profits[k]=costs[j][k][1]-costs[i][k][0];
						maxBuy[k]=costs[i][k][2];
						}
					int temp=knapsack(profits,maxBuy,K);
					if(temp>max)
						max=temp;
					}
				}
			}
		System.out.println(max);
		}

	private static int knapsack(int[] profits,int[] maxBuy,int K)
		{
		int N=profits.length;
		//System.out.println("Knapsack!");
		//System.out.println(Arrays.toString(profits));
		//System.out.println(Arrays.toString(maxBuy));
		int DP[][]=new int[N][K+1];		//maximum profit considering only the 1st i items, and buying exactly j items
		if(profits[0]>0)
			{
			for(int j=1;j<=Math.min(maxBuy[0],K);j++)
				DP[0][j]=j*profits[0];
			}
		for(int i=1;i<N;i++)
			{
			for(int j=0;j<=K;j++)
				DP[i][j]=DP[i-1][j];

			if(profits[i]<=0)
				continue;

			for(int j=0;j<=K;j++)
				{
				for(int buy=0;buy<=maxBuy[i];buy++)
					{
					if(buy<=j)
						{
						if(DP[i-1][j-buy]+buy*profits[i]>DP[i][j])
							DP[i][j]=DP[i-1][j-buy]+buy*profits[i];
						}
					}
				}
			}
		int max=0;
		for(int i=0;i<N;i++)
			{
			for(int j=0;j<=K;j++)
				{
				if(DP[i][j]>max)
					max=DP[i][j];
				}
			}
		return max;
		}

	}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class ProblemC {

    static class G implements Comparable<G> {
        long gain;
        int idx;
        G(long g, int i) {
            gain = g;
            idx = i;
        }

        public int compareTo(G arg0) {
            return Long.signum(arg0.gain - gain);
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        String[] data = s.readLine().split(" ");
        int n = Integer.valueOf(data[0]);
        int m = Integer.valueOf(data[1]);
        int k = Integer.valueOf(data[2]);
        long[][][] items = new long[n][m][3];
        for (int i = 0 ; i < n ; i++) {
            s.readLine();
            for (int j = 0 ; j < m ; j++) {
                String[] dat = s.readLine().split(" ");
                items[i][j][0] = Integer.valueOf(dat[0]);
                items[i][j][1] = Integer.valueOf(dat[1]);
                items[i][j][2] = Integer.valueOf(dat[2]);
            }
        }

        long max = 0;
        for (int from = 0 ; from < n ; from++) {
            for (int to = 0 ; to < n ; to++) {
                G[] gain = new G[m];
                for (int i = 0 ; i < m ; i++) {
                    gain[i] = new G(items[to][i][1] - items[from][i][0], i);
                }
                Arrays.sort(gain);

                long left = k;
                long total = 0;
                for (int i = 0 ; i < m ; i++) {
                    if (gain[i].gain <= 0) {
                        break;
                    }

                    long maxtake = items[from][gain[i].idx][2];
                    long take = Math.min(maxtake, left);
                    total += take * gain[i].gain;
                    left -= take;
                    if (left == 0) {
                        break;
                    }
                }
                max = Math.max(max, total);
            }
        }
        System.out.println(max);
    }
}

import java.util.Scanner;

public class CF_181C {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int nplanets 	= in.nextInt();
		int ntypes 		= in.nextInt();
		int cap			= in.nextInt();

		int[][] buyp  = new int[nplanets][ntypes];
		int[][] sellp = new int[nplanets][ntypes];
		int[][] avail = new int[nplanets][ntypes];

		for(int i = 0; i < nplanets; i++) {
			in.next();
			for(int j = 0; j < ntypes; j++) {
				buyp[i][j]  = in.nextInt();
				sellp[i][j] = in.nextInt();
				avail[i][j] = in.nextInt();
			}
		}

		int profit = 0;
		for(int i = 0; i < nplanets; i++) {
			for(int j = 0; j < nplanets; j++) {
				if(i == j) continue;
				int remcap = cap;
				int sum = 0;
				boolean[] used = new boolean[ntypes];
				for(int k = 0; k < ntypes; k++) {
					int cm = -1, cp = 0;
					for(int m = 0; m < ntypes; m++) {
						int p = sellp[j][m] - buyp[i][m];
						if(p > cp && !used[m]) {
							cp = p;
							cm = m;
						}
					}
					if(cm == -1 || remcap == 0) break;

					sum += cp * Math.min(remcap, avail[i][cm]);
					remcap -= Math.min(remcap, avail[i][cm]);
					used[cm] = true;
				}

				profit = Math.max(profit, sum);
			}
		}

		System.out.println(profit);

	}

}

import java.util.*;
import java.io.*;
import java.awt.*;

public class C {
    public static void main(String[] args) throws Throwable {
	BufferedReader f=new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st=new StringTokenizer(f.readLine());
	int planets=Integer.parseInt(st.nextToken());
	int items=Integer.parseInt(st.nextToken());
	int cap=Integer.parseInt(st.nextToken());

	int[][] buy=new int[planets][items];
	int[][] sell=new int[planets][items];
	int[][] remain=new int[planets][items];
	for(int i=0;i<planets;i++) {
	    f.readLine(); //ignore planets name
	    for(int j=0;j<items;j++) {
		st=new StringTokenizer(f.readLine());
		buy[i][j]=Integer.parseInt(st.nextToken());
		sell[i][j]=Integer.parseInt(st.nextToken());
		remain[i][j]=Integer.parseInt(st.nextToken());
		}
	    }
	int max=0;
	for(int i=0;i<planets;i++) { //buy place
	    for(int j=0;j<planets;j++) { //sell place
		Item[] profit=new Item[items];
		for(int k=0;k<items;k++) {
		    profit[k]=new Item(sell[j][k]-buy[i][k], remain[i][k]);
		    }
		Arrays.sort(profit);
		int left=cap;
		int cur=0;
		for(Item it: profit) {
		    if(it.price<=0) break;
		    if(left>it.amt) {
			left-=it.amt;
			cur+=it.price*it.amt;
			}
		    else {
			cur+=it.price*left;
			break;
			}
		    }
		max=Math.max(max,cur);
		}
	    }
	System.out.println(max);
	}
    static class Item implements Comparable<Item> {
	int price, amt;
	public Item(int a, int b) {
	    price=a;
	    amt=b;
	    }
	public int compareTo(Item i) {
	    return i.price-price; //opp to make decreasing order
	    }
 	public String toString() {
	    return "Price: "+price+" Amt: "+amt;
	    }
	}
    }

import java.io.*;
import java.util.*;

public class A
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;
	String FInput="";

	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{

			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}

	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}
		catch (NullPointerException e)
		{
			line=null;

		}

	}

	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	long NextLong()
	{
		String n = inputParser.nextToken();
		long val = Long.parseLong(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}

	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	public static void main(String [] argv)
	{
		String filePath=null;
		if(argv.length>0)filePath=argv[0];
		new A(filePath);
	}

	public void readFInput()
	{
		for(;;)
		{
			try
			{
				readNextLine();
				FInput+=line+" ";
			}
			catch(Exception e)
			{
				break;
			}
		}
		inputParser = new StringTokenizer(FInput, " ");
	}

	public A(String inputFile)
	{
		openInput(inputFile);

		readNextLine();
		int ret=0;

		int N=NextInt();
		int M=NextInt();
		int K=NextInt();
		String [] names=new String[N];
		int [][] a = new int [N][M];
		int [][] b = new int [N][M];
		int [][] c = new int [N][M];

		for(int i=0; i<N; i++)
		{
			readNextLine();
			names[i]=line;

			for(int j=0; j<M;j++)
			{
				readNextLine();
				a[i][j]=NextInt();
				b[i][j]=NextInt();
				c[i][j]=NextInt();

			}
		}

		for(int i=0; i<N; i++)
		{

			for(int j=0; j<N;j++)
			{
				if(i==j)continue;
				int n=0;
				ArrayList <Item> items= new ArrayList<Item>();
				for(int k=0; k<M; k++)
				{
					if(b[j][k]>a[i][k])items.add(new Item(a[i][k], b[j][k], Math.min(K, c[i][k])));
				}

				int cnt=K;
				Collections.sort(items);
				while(cnt>0)
				{
					int id=0;
					while(id<items.size()&&items.get(id).cnt==0)id++;
					if(id==items.size())break;
					int num=Math.min(cnt, items.get(id).cnt);
					cnt-=num;
					items.get(id).cnt-=num;
					n+=num*(items.get(id).sell-items.get(id).buy);
					for(Item item:items)item.cnt=Math.min(cnt, item.cnt);
				}
				ret=Math.max(ret, n);
			}
		}
		System.out.println(ret);

        closeInput();
	}

	private class Item implements Comparable<Item>
	{
		int cnt,buy,sell;
		Item (int a, int b, int c)
		{
			buy=a;
			sell=b;
			cnt=c;
		}
		public int compareTo(Item d)
		{
			return d.sell-d.buy-(sell-buy);
		}
	}

}

import java.io.*;
import java.util.*;
import java.util.Map.Entry;

public class A {
    private static class Solver {
        int greedy(int[][] buy, int[][] sell, int K) {
            final int m = buy.length;
            int[] xs = new int[m * K];
            for(int i = 0; i < m; i++) {
                for(int j = 0; j < K && j < buy[i][2]; j++) {
                    xs[i * K + j] = sell[i][1] - buy[i][0];
                }
            }

            int res = 0;
            Arrays.sort(xs);
            for(int i = xs.length - 1, j = 0; j < K && xs[i] > 0; j++, i--) {
                res += xs[i];
            }

            return res;
        }

        public void run() throws IOException {
            final int n = IOFast.nextInt();
            final int m = IOFast.nextInt();
            final int K = IOFast.nextInt();

            int[][][] planet = new int[n][m][3];

            for(int i = 0; i < n; i++) {
                IOFast.next();
                for(int j = 0; j < m; j++) {
                    for(int k = 0; k < 3; k++)
                        planet[i][j][k] = IOFast.nextInt();
                }
            }

            int res = 0;
            for(int i = 0; i < n; i++)
                for(int j = 0; j < n; j++) if(i != j) {
                    res = Math.max(res, greedy(planet[i], planet[j], K));
                }

            IOFast.out.println(res);
        }
    }

    public static void main(String[] args) throws IOException {
        new Solver().run();
        IOFast.out.flush();
    }

    static public class IOFast {
        private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        private static PrintWriter out = new PrintWriter(System.out);

//      private static final int BUFFER_SIZE = 50 * 200000;
        private static final StringBuilder buf = new StringBuilder();
        private static boolean[] isDigit = new boolean[256];
        private static boolean[] isSpace = new boolean[256];

        static {
            for(int i = 0; i < 10; i++) {
                isDigit['0' + i] = true;
            }
            isDigit['-'] = true;
            isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true;
        }

        static boolean endInput;

        private static int nextInt() throws IOException {
            boolean plus = false;
            int ret = 0;
            while(true) {
                final int c = in.read();

                if(c == -1) {
                    endInput = true;
                    return Integer.MIN_VALUE;
                }

                if(isDigit[c]) {
                    if(c != '-') {
                        plus = true;
                        ret = c - '0';
                    }
                    break;
                }
            }

            while(true) {
                final int c = in.read();
                if(c == -1 || !isDigit[c]) {
                    break;
                }
                ret = ret * 10 + c - '0';
            }

            return plus ? ret : -ret;
        }

        private static long nextLong() throws IOException {
            boolean plus = false;
            long ret = 0;
            while(true) {
                final int c = in.read();

                if(c == -1) {
                    endInput = true;
                    return Integer.MIN_VALUE;
                }

                if(isDigit[c]) {
                    if(c != '-') {
                        plus = true;
                        ret = c - '0';
                    }
                    break;
                }
            }

            while(true) {
                final int c = in.read();
                if(c == -1 || !isDigit[c]) {
                    break;
                }
                ret = ret * 10 + c - '0';
            }

            return plus ? ret : -ret;
        }

        private static String next() throws IOException {
            buf.setLength(0);

            while(true) {
                final int c = in.read();

                if(c == -1) {
                    endInput = true;
                    return "-1";
                }

                if(!isSpace[c]) {
                    buf.append((char)c);
                    break;
                }
            }

            while(true) {
                final int c = in.read();

                if(c == -1 || isSpace[c]) {
                    break;
                }
                buf.append((char)c);
            }

            return buf.toString();
        }

        private static double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

    }

}

import static java.util.Arrays.deepToString;

import java.io.*;
import java.math.*;
import java.util.*;

public class A {

	static void solve() {
		int n = nextInt(), m = nextInt(), k = nextInt();
		int[][] a = new int[n][m];
		int[][] b = new int[n][m];
		int[][] c = new int[n][m];
		for (int i = 0; i < n; i++) {
			next();
			for (int j = 0; j < m; j++) {
				a[i][j] = nextInt();
				b[i][j] = nextInt();
				c[i][j] = nextInt();
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (j == i)
					continue;
				int[][] p1 = new int[][] { Arrays.copyOf(a[i], m), Arrays.copyOf(b[i], m), Arrays.copyOf(c[i], m) };
				int[][] p2 = new int[][] { Arrays.copyOf(a[j], m), Arrays.copyOf(b[j], m), Arrays.copyOf(c[j], m) };
				int cur = 0;
				for (int t = 0; t < k; t++) {
					int best = -1, bestD = 0;
					for (int q = 0; q < m; q++) {
						if (p1[2][q] > 0 && bestD < p2[1][q] - p1[0][q]) {
							best = q;
							bestD = p2[1][q] - p1[0][q];
						}
					}
					if (best == -1)
						break;
					cur += bestD;
					p1[2][best]--;
				}
				ans = Math.max(ans, cur);
			}
		}
		writer.println(ans);
	}

	public static void main(String[] args) throws Exception {
		reader = new BufferedReader(new InputStreamReader(System.in));
		writer = new PrintWriter(System.out);

		setTime();
		solve();
		printTime();
		printMemory();

		writer.close();
	}

	static BufferedReader reader;
	static PrintWriter writer;
	static StringTokenizer tok = new StringTokenizer("");
	static long systemTime;

	static void debug(Object... o) {
		System.err.println(deepToString(o));
	}

	static void setTime() {
		systemTime = System.currentTimeMillis();
	}

	static void printTime() {
		System.err.println("Time consumed: " + (System.currentTimeMillis() - systemTime));
	}

	static void printMemory() {
		System.err.println("Memory consumed: "
				+ (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1000 + "kb");
	}

	static String next() {
		while (!tok.hasMoreTokens()) {
			String w = null;
			try {
				w = reader.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (w == null)
				return null;
			tok = new StringTokenizer(w);
		}
		return tok.nextToken();
	}

	static int nextInt() {
		return Integer.parseInt(next());
	}

	static long nextLong() {
		return Long.parseLong(next());
	}

	static double nextDouble() {
		return Double.parseDouble(next());
	}

	static BigInteger nextBigInteger() {
		return new BigInteger(next());
	}
}

import java.io.*;
import java.util.*;

public class A {

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

	String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}

	public class Pair implements Comparable<Pair> {
		long u;
		long v;

		public Pair(long u, long v) {
			this.u = u;
			this.v = v;
		}

		public int hashCode() {
			int hu = (int) (u ^ (u >>> 32));
			int hv = (int) (v ^ (v >>> 32));
			return (int) (hu * 31 + hv);
		}

		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return u == other.u && v == other.v;
		}

		public int compareTo(Pair other) {
			if (u != other.u)
				return u < other.u ? -1 : 1;

			return v < other.v ? -1 : v > other.v ? 1 : 0;
		}

		public String toString() {
			return "[u=" + u + ", v=" + v + "]";
		}
	}

	void solve() throws Exception {
		int n = nextInt(), m = nextInt(), k = nextInt();
		int buy[][] = new int[n][m];
		int sell[][] = new int[n][m];
		int left[][] = new int[n][m];
		String name[] = new String[n];
		for (int i = 0; i < n; i++) {
			name[i] = next();
			for (int j = 0; j < m; j++) {
				buy[i][j] = nextInt();
				sell[i][j] = nextInt();
				left[i][j] = nextInt();
			}
		}
		long ans = 0;
		for (int from = 0; from < n; from++) {
			for (int to = 0; to < n; to++) {
				Pair diff[] = new Pair[m];
				for (int i = 0; i < m; i++)
					diff[i] = new Pair(-(sell[to][i] - buy[from][i]), left[from][i]);
				Arrays.sort(diff);
				// System.err.println(Arrays.toString(diff));
				long profit = 0;
				int space = k;
				for (int i = 0; i < m; i++) {
					int pr = (int) -diff[i].u;
					if (pr <= 0)
						continue;
					if (space < diff[i].v) {
						profit += space * pr;
						space = 0;
					} else {
						profit += diff[i].v * pr;
						space -= diff[i].v;
					}
				}
				if (profit > ans)
					ans = profit;
			}
		}
		out.println(ans);
	}

	void run() {
		try {
			Locale.setDefault(Locale.US);
			boolean oj = System.getProperty("ONLINE_JUDGE") != null;
			Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
			Writer writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("output.txt");
			in = new BufferedReader(reader);
			out = new PrintWriter(writer);
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public static void main(String[] args) {
		new A().run();

	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int P = in.nextInt();
            int T = in.nextInt();
            int left = in.nextInt();
            Planet[] planets = new Planet[P];
            for (int i = 0; i < P; i++)
            {
                in.next();
                long[] buy = new long[T];
                long[] sell = new long[T];
                long[] cap = new long[T];
                for (int j = 0; j < T; j++)
                {
                    buy[j] = in.nextInt();
                    sell[j] = in.nextInt();
                    cap[j] = in.nextInt();
                }
                planets[i] = new Planet(buy, sell, cap);
            }
            long best = 0;
            for (int i = 0; i < P; i++)
            {
                for (int j = 0; j < P; j++)
                {
//                if (i == j)
//                {
//                    continue;
//                }

                    PriorityQueue<Item> q = new PriorityQueue<>();
                    for (int k = 0; k < T; k++)
                    {
                        long b = planets[i].buy[k];
                        long s = planets[j].sell[k];
                        long c = planets[i].cap[k];
                        q.add(new Item(b, s, c));
                    }

                    long cap = left;
                    long earn = 0;
                    while (cap > 0 && !q.isEmpty())
                    {
                        Item item = q.poll();
                        long min = Math.min(cap, item.cap);
                        long p = item.sell - item.buy;
                        if (p <= 0)
                        {
                            continue;
                        }
                        earn += min * p;
                        cap -= min;
                    }
                    best = Math.max(best, earn);
                }
            }
            out.println(best);
        }

        class Planet
        {
            long[] buy;
            long[] sell;
            long[] cap;

            Planet(long[] buy, long[] sell, long[] cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

        }

        class Item implements Comparable<Item>
        {
            long buy;
            long sell;
            long cap;

            public Item(long buy, long sell, long cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

            public int compareTo(Item that)
            {
                return Long.compare(that.sell - that.buy, this.sell - this.buy);
            }

            public String toString()
            {
                return " Buy = " + buy + " Sell = " + sell + " Cap = " + cap;
            }

        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }
}

import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		try {
			if (new File("input.txt").exists())
				System.setIn(new FileInputStream("input.txt"));
		} catch (SecurityException e) {
		}
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new Main().run();
				} catch (IOException e) {
					e.printStackTrace();
					exit(999);
				}
			}
		}, "kek", 1 << 23).start();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");

	private void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		in.close();
		out.close();
	}
	private void solve() throws IOException{
		int n = nextInt();
		int m = nextInt();
		int cnt = nextInt();

		int buy[][] = new int[n][m];
		int sell[][] = new int[n][m];
		int count[][] = new int[n][m];

		for(int i = 0; i < n; i++){
			nextToken();
			for(int j = 0; j < m; j++){
				buy[i][j] = nextInt();
				sell[i][j] = nextInt();
				count[i][j] = nextInt();
			}
		}

		int ans = 0;

		Event ev[] = new Event[m];
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++){
				if(i == j) continue;
				int pev = 0;
				for(int type = 0; type < m; type++){
					ev[pev++] = new Event(sell[i][type] - buy[j][type], type);
				}
				sort(ev, 0, pev);
				int curCnt = 0;
				int id = 0;
				int win = 0;
				while(id < pev & curCnt < cnt && ev[id].delta > 0){
					Event e = ev[id++];
					int add = min(cnt - curCnt, count[j][e.id]);
					win += add * e.delta;
					curCnt += add;
				}
				ans = max(ans, win);
			}

		out.println(ans);

	}
	class Event implements Comparable<Event>{
		int delta;
		int id;
		public Event(int de, int cc) {
			delta = de;
			id = cc;
		}
		@Override
		public int compareTo(Event e) {
			return e.delta - delta;
		}
	}
	String nextToken() throws IOException {

		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int P = in.nextInt();
            int T = in.nextInt();
            int left = in.nextInt();
            Planet[] planets = new Planet[P];
            for (int i = 0; i < P; i++)
            {
                in.next();
                long[] buy = new long[T];
                long[] sell = new long[T];
                long[] cap = new long[T];
                for (int j = 0; j < T; j++)
                {
                    buy[j] = in.nextInt();
                    sell[j] = in.nextInt();
                    cap[j] = in.nextInt();
                }
                planets[i] = new Planet(buy, sell, cap);
            }
            long best = 0;
            for (int i = 0; i < P; i++)
            {
                for (int j = 0; j < P; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    PriorityQueue<Item> q = new PriorityQueue<>();
                    for (int k = 0; k < T; k++)
                    {
                        long b = planets[i].buy[k];
                        long s = planets[j].sell[k];
                        long c = planets[i].cap[k];
                        q.add(new Item(b, s, c));
                    }

                    long cap = left;
                    long earn = 0;
                    while (cap > 0 && !q.isEmpty())
                    {
                        Item item = q.poll();
                        long min = Math.min(cap, item.cap);
                        long p = item.sell - item.buy;
                        if (p <= 0)
                        {
                            continue;
                        }
                        earn += min * p;
                        cap -= min;
                    }
                    best = Math.max(best, earn);
                }
            }
            out.println(best);
        }

        class Planet
        {
            long[] buy;
            long[] sell;
            long[] cap;

            Planet(long[] buy, long[] sell, long[] cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

        }

        class Item implements Comparable<Item>
        {
            long buy;
            long sell;
            long cap;

            public Item(long buy, long sell, long cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

            public int compareTo(Item that)
            {
                return Long.compare(that.sell - that.buy, this.sell - this.buy);
            }

            public String toString()
            {
                return " Buy = " + buy + " Sell = " + sell + " Cap = " + cap;
            }

        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }
}

import java.io.*;
import java.util.*;
import java.math.*;

//4/20/12 7:02 PM
//by Abrackadabra

public class A {
    public static void main(String[] args) throws IOException {
        if (args.length > 0 && args[0].equals("Abra")) debugMode = true;
        new A().run();
        /*new Thread(null, new Runnable() {
            public void run() {
                try {
                    new A().run();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }, "1", 1 << 24).start();*/
    }

    int IOMode = 0; //0 - consoleIO, 1 - <taskName>.in/out, 2 - input.txt/output.txt, 3 - test case generator
    String taskName = "";

    class good implements Comparable<good> {
        int ind, prib;

        good(int ind, int prib) {
            this.ind = ind;
            this.prib = prib;
        }

        @Override
        public int compareTo(good o) {
            int c = Integer.compare(prib, o.prib);
            if (c != 0) return c;
            return Integer.compare(ind, o.ind);  //To change body of implemented methods use File | Settings | File Templates.
        }
    }

    void solve() throws IOException {
        int n = nextInt(), m = nextInt(), k = nextInt();
        int[][][] a = new int[n][m][3];
        for (int i = 0; i < n; i++) {
            String name = nextString();
            for (int j = 0; j < m; j++) {
                a[i][j][0] = nextInt();
                a[i][j][1] = nextInt();
                a[i][j][2] = nextInt();
            }
        }
        int max = -1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                ArrayList<good> al = new ArrayList<good>();
                for (int q = 0; q < m; q++) {
                    al.add(new good(q, a[j][q][1] - a[i][q][0]));
                }
                Collections.sort(al);
                int tk = k, pr = 0;
                for (int q = m - 1; q >= 0; q--) {
                    good g = al.get(q);
                    if (g.prib <= 0) break;
                    int c = Math.min(a[i][g.ind][2], tk);
                    tk -= c;
                    pr += c * g.prib;
                }
                max = Math.max(pr, max);
            }
        }
        out.println(max);
    }

    long startTime = System.nanoTime(), tempTime = startTime, finishTime = startTime;
    long startMem = Runtime.getRuntime().totalMemory(), finishMem = startMem;

    void run() throws IOException {
        init();
        if (debugMode) {
            con.println("Start");
            con.println("Console:");
        }
        solve();
        finishTime = System.nanoTime();
        finishMem = Runtime.getRuntime().totalMemory();
        out.flush();
        if (debugMode) {
            int maxSymbols = 1000;
            BufferedReader tbr = new BufferedReader(new FileReader("input.txt"));
            char[] a = new char[maxSymbols];
            tbr.read(a);
            if (a[0] != 0) {
                con.println("File input:");
                con.println(a);
                if (a[maxSymbols - 1] != 0) con.println("...");
            }
            tbr = new BufferedReader(new FileReader("output.txt"));
            a = new char[maxSymbols];
            tbr.read(a);
            if (a[0] != 0) {
                con.println("File output:");
                con.println(a);
                if (a[maxSymbols - 1] != 0) con.println("...");
            }
            con.println("Execution time: " + (finishTime - startTime) / 1000000000.0 + " sec");
            con.println("Used memory:    " + (finishMem - startMem) + " bytes");
            con.println("Total memory:   " + Runtime.getRuntime().totalMemory() + " bytes");
        }
    }

    boolean tick(double x) {
        if (System.nanoTime() - tempTime > x * 1e9) {
            tempTime = System.nanoTime();
            con.println("Tick at " + (tempTime - startTime) / 1000000000 + " sec");
            con.print("   ");
            return true;
        }
        return false;
    }

    static boolean debugMode = false;
    PrintStream con = System.out;

    void init() throws IOException {
        if (debugMode && IOMode != 3) {
            br = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter(new FileWriter("output.txt"));
        } else
            switch (IOMode) {
                case 0:
                    br = new BufferedReader(new InputStreamReader(System.in));
                    out = new PrintWriter(System.out);
                    break;
                case 1:
                    br = new BufferedReader(new FileReader(taskName + ".in"));
                    out = new PrintWriter(new FileWriter(taskName + ".out"));
                    break;
                case 2:
                    br = new BufferedReader(new FileReader("input.txt"));
                    out = new PrintWriter(new FileWriter("output.txt"));
                    break;
                case 3:
                    out = new PrintWriter(new FileWriter("input.txt"));
                    break;
            }
    }

    BufferedReader br;
    PrintWriter out;
    StringTokenizer in;

    boolean hasMoreTokens() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) return false;
            in = new StringTokenizer(line);
        }
        return true;
    }

    String nextString() throws IOException {
        return hasMoreTokens() ? in.nextToken() : null;
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextString());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextString());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextString());
    }
}

import static java.lang.Double.parseDouble;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.System.exit;
import static java.util.Arrays.sort;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Comparator;
import java.util.StringTokenizer;

public class A {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	static void solve() throws Exception {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		int a[][] = new int[n][m];
		int b[][] = new int[n][m];
		int c[][] = new int[n][m];
		for (int i = 0; i < n; i++) {
			next();
			for (int j = 0; j < m; j++) {
				a[i][j] = nextInt();
				b[i][j] = nextInt();
				c[i][j] = nextInt();
			}
		}
		long ans = 0;
		Integer idx[] = new Integer[m];
		for (int i = 0; i < m; i++) {
			idx[i] = i;
		}
		for (int p1 = 0; p1 < n; p1++) {
			for (int p2 = 0; p2 < n; p2++) {
				final int ca[] = a[p1];
				final int cb[] = b[p2];
				int cc[] = c[p1];
				sort(idx, new Comparator<Integer>() {
					public int compare(Integer o1, Integer o2) {
						return (cb[o2] - ca[o2]) - (cb[o1] - ca[o1]);
					}
				});
				long cans = 0;
				int cs = k;
				for (int i = 0; i < m; i++) {
					int ci = idx[i];
					if (cb[ci] <= ca[ci]) {
						break;
					}
					if (cs > cc[ci]) {
						cans += (long) (cb[ci] - ca[ci]) * cc[ci];
						cs -= cc[ci];
					} else {
						cans += (long) (cb[ci] - ca[ci]) * cs;
						break;
					}
				}
				ans = max(ans, cans);
			}
		}
		out.println(ans);
	}

	static int nextInt() throws IOException {
		return parseInt(next());
	}

	static long nextLong() throws IOException {
		return parseLong(next());
	}

	static double nextDouble() throws IOException {
		return parseDouble(next());
	}

	static String next() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Solution {

    static class Pair implements Comparable<Pair> {
        int key, val;

        Pair(int key, int val) {
            this.key = key;
            this.val = val;
        }

        @Override
        public int compareTo(Pair o) {
            return - key + o.key;
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt(), k = in.nextInt();
        int[][] a = new int[n][m], b = new int[n][m], c = new int[n][m];
        for (int i = 0; i < n; i++) {
            in.next();
            for (int j = 0; j < m; j++) {
                a[i][j] = in.nextInt();
                b[i][j] = in.nextInt();
                c[i][j] = in.nextInt();
            }
        }

        int profit = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++) {
                if (i == j) continue;
                ArrayList<Pair> v = new ArrayList<Pair>();
                for (int q = 0; q < m; q++)
                    v.add(new Pair(b[j][q] - a[i][q], q));

                Collections.sort(v);
                int sum = 0, tk = k;
                for (int t = 0; t < m && v.get(t).key > 0; t++) {
                    int ind = v.get(t).val;
                    sum += v.get(t).key * Math.min(tk, c[i][ind]);
                    tk -= Math.min(tk, c[i][ind]);
                }
                profit = Math.max(profit, sum);
            }
        System.out.println(profit);
    }

}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * 4 4
 * 1 5 3 4
 * 1 2
 * 1 3
 * 2 3
 * 3 3
 *
 *
 * @author pttrung
 */
public class A {

    public static long Mod = (long) (1e9) + 7;
    static int time = 0;
    static int[][] dp;
    static boolean[][] check;

    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();

        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        int[][][] data = new int[n][m][3];
        for (int i = 0; i < n; i++) {
            in.next();
            for (int j = 0; j < m; j++) {
                data[i][j][0] = in.nextInt();//buy
                data[i][j][1] = in.nextInt();//sell
                data[i][j][2] = in.nextInt();//num
            }
        }
        dp = new int[m][k + 1];
        int result = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i != j) {
                    check = new boolean[m][k + 1];
                    int tmp = cal(0, k, i, j, data);
                    result = Math.max(tmp, result);
                }
            }
        }
        out.println(result);
        out.close();
    }

    static int cal(int index, int left, int buy, int sell, int[][][] data) {
        if (index == data[buy].length) {
            return 0;
        }
        if (left == 0) {
            return 0;
        }
        if (check[index][left] ) {
            return dp[index][left];
        }
        check[index][left] = true;
        int result = 0;
        if (data[buy][index][0] < data[sell][index][1]) {
            for (int i = 1; i <= Math.min(left, data[buy][index][2]); i++) {
                int tmp = (data[sell][index][1] - data[buy][index][0]) * i + cal(index + 1, left - i, buy, sell, data);
                result = Math.max(result, tmp);
            }
        }
        result = Math.max(result, cal(index + 1, left, buy, sell, data));
        return dp[index][left] = result;
    }

    static long squareDist(int x, int y) {
        long X = x;
        long Y = y;
        return X * X + Y * Y;
    }

    static int find(int index, int[] u) {
        if (index != u[index]) {
            return u[index] = find(u[index], u);
        }
        return index;
    }

    public static long pow(int a, int b, long mod) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long v = pow(a, b / 2, mod);
        if (b % 2 == 0) {
            return (v * v) % mod;
        } else {
            return (((v * v) % mod) * a) % mod;
        }
    }

    public static int[][] powSquareMatrix(int[][] A, long p) {
        int[][] unit = new int[A.length][A.length];
        for (int i = 0; i < unit.length; i++) {
            unit[i][i] = 1;
        }
        if (p == 0) {
            return unit;
        }
        int[][] val = powSquareMatrix(A, p / 2);
        if (p % 2 == 0) {
            return mulMatrix(val, val);
        } else {
            return mulMatrix(A, mulMatrix(val, val));
        }

    }

    public static int[][] mulMatrix(int[][] A, int[][] B) {
        int[][] result = new int[A.length][B[0].length];
        for (int i = 0; i < result.length; i++) {
            for (int j = 0; j < result[0].length; j++) {
                long temp = 0;
                for (int k = 0; k < A[0].length; k++) {

                    temp += ((long) A[i][k] * B[k][j] % Mod);
                    temp %= Mod;
                }
                temp %= Mod;
                result[i][j] = (int) temp;
            }
        }

        return result;
    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;

    }

    static class FT {

        int[] data;

        FT(int n) {
            data = new int[n];
        }

        void update(int index, int val) {
            // System.out.println("UPDATE INDEX " + index);
            while (index < data.length) {
                data[index] += val;
                index += index & (-index);

                //    System.out.println("NEXT " +index);
            }
        }

        int get(int index) {
            //  System.out.println("GET INDEX " + index);
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= index & (-index);
                // System.out.println("BACK " + index);
            }
            return result;
        }
    }

    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    static long pow(long a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {

            return val * val % Mod;
        } else {
            return (val * val % Mod) * a % Mod;
        }
    }

//    static Point intersect(Point a, Point b, Point c) {
//        double D = cross(a, b);
//        if (D != 0) {
//            return new Point(cross(c, b) / D, cross(a, c) / D);
//        }
//        return null;
//    }
//
//    static Point convert(Point a, double angle) {
//        double x = a.x * cos(angle) - a.y * sin(angle);
//        double y = a.x * sin(angle) + a.y * cos(angle);
//        return new Point(x, y);
//    }
    static Point minus(Point a, Point b) {
        return new Point(a.x - b.x, a.y - b.y);
    }
//
//    static Point add(Point a, Point b) {
//        return new Point(a.x + b.x, a.y + b.y);
//    }
//

    /**
     * Cross product ab*ac
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static double cross(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return cross(ab, ac);
    }

    static double cross(Point a, Point b) {
        return a.x * b.y - a.y * b.x;
    }

    /**
     * Dot product ab*ac;
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static long dot(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return dot(ab, ac);
    }

    static long dot(Point a, Point b) {
        long total = a.x * b.x;
        total += a.y * b.y;
        return total;
    }

    static double dist(Point a, Point b) {
        long total = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        return Math.sqrt(total);
    }

    static long norm(Point a) {
        long result = a.x * a.x;
        result += a.y * a.y;
        return result;
    }

    static double dist(Point a, Point b, Point x, boolean isSegment) {
        double dist = cross(a, b, x) / dist(a, b);
        // System.out.println("DIST " + dist);

        if (isSegment) {
            Point ab = new Point(b.x - a.x, b.y - a.y);

            long dot1 = dot(a, b, x);
            long norm = norm(ab);
            double u = (double) dot1 / norm;
            if (u < 0) {
                return dist(a, x);
            }

            if (u > 1) {
                return dist(b, x);
            }
        }
        return Math.abs(dist);

    }

    static long squareDist(Point a, Point b) {
        long x = a.x - b.x;
        long y = a.y - b.y;
        return x * x + y * y;
    }

    static class Point {

        int x, y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public String toString() {
            return "Point{" + "x=" + x + ", y=" + y + '}';
        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            //System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader(new File("A-large (2).in")));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author codeKNIGHT
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n=in.nextInt(),m=in.nextInt(),k=in.nextInt(),i,j,x,y,max=0;
        String s;
        int a[][][]=new int[n][m][3];
        for(i=0;i<n;i++)
        {
            s=in.next();
            for(j=0;j<m;j++)
            {
                a[i][j][0]=in.nextInt();
                a[i][j][1]=in.nextInt();
                a[i][j][2]=in.nextInt();
            }
        }
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                if(i==j)
                    continue;
                items profit[]=new items[m];
                for(x=0;x<m;x++)
                {
                    profit[x]=new items(a[j][x][1]-a[i][x][0],x);
                }
                Arrays.sort(profit);

                int t=k,count=0,number;
                x=0;
                while(t>0&&x<m)
                {
                    number=Math.min(a[i][profit[x].index][2],t);
                    if(profit[x].p<=0)
                        break;
                    count+=profit[x].p*number;
                    x++;
                    t-=number;
                }
                if(count>max)
                    max=count;

            }
        }
        out.println(max);
	}
    class items implements Comparable<items>
    {
        int index,p;
        public items(int p,int index)
        {
            this.p=p;
            this.index=index;
        }
        public int compareTo(items a)
        {
            if(a.p>this.p)
                return 1;
            return -1;
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class C {

	final int MOD = 1000000007;
	final double eps = 1e-9;

	public C () throws IOException {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();

		int [][][] P = new int [N][M][];
		for (int n = 0; n < N; ++n) {
			sc.next();
			for (int m = 0; m < M; ++m)
				P[n][m] = sc.nextInts();
		}

		int res = 0;
		Integer [] L = new Integer[M];
		for (int i = 0; i < M; ++i)
			L[i] = i;

		for (int b = 0; b < N; ++b)
			for (int s = 0; s < N; ++s) {
				final int [] R = new int [M];
				for (int m = 0; m < M; ++m)
					R[m] = P[s][m][1] - P[b][m][0];
				Arrays.sort(L, new Comparator<Integer>() {
					public int compare(Integer x, Integer y) {
						return R[y] - R[x];
					}
				});
				int [] S = new int [M];
				for (int i = 0, k = 0; i < M && k < K; ++i) {
					int m = L[i];
					if (R[m] <= 0) break;
					S[m] = Math.min(P[b][m][2], K-k);
					k += S[m];
				}
				int Z = 0;
				for (int m = 0; m < M; ++m)
					Z += S[m] * R[m];
				res = Math.max(res, Z);
			}
		exit(res);
	}

	////////////////////////////////////////////////////////////////////////////////////

	static MyScanner sc;

	static void print (Object... a) {
		StringBuffer b = new StringBuffer();
		for (Object o : a)
			b.append(" ").append(o);
		System.out.println(b.toString().trim());
	}

	static void exit (Object... a) {
		print(a);
		exit();
	}

	static void exit () {
		System.err.println((millis() - t) / 1000.0);
		System.exit(0);
	}

	static class MyScanner {
		String next() throws IOException {
			newLine();
			return line[index++];
		}

		char [] nextChars() throws IOException {
			return next().toCharArray();
		}

		double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		String nextLine() throws IOException {
			line = null;
			return r.readLine();
		}

		String [] nextStrings() throws IOException {
			line = null;
			return r.readLine().split(" ");
		}

		int [] nextInts() throws IOException {
			String [] L = nextStrings();
			int [] res = new int [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Integer.parseInt(L[i]);
			return res;
		}

		long [] nextLongs() throws IOException {
			String [] L = nextStrings();
			long [] res = new long [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Long.parseLong(L[i]);
			return res;
		}

		boolean eol() {
			return index == line.length;
		}

		//////////////////////////////////////////////

		private final BufferedReader r;

		MyScanner () throws IOException {
			this(new BufferedReader(new InputStreamReader(System.in)));
		}

		MyScanner(BufferedReader r) throws IOException {
			this.r = r;
		}

		private String [] line;
		private int index;

		private void newLine() throws IOException {
			if (line == null || eol()) {
				line = r.readLine().split(" ");
				index = 0;
			}
		}
	}

	////////////////////////////////////////////////////////////////////////////////////

	public static void main(String[] args) throws IOException {
		start();
		run();
		exit();
	}

	static void start() {
		t = millis();
	}

	static void run () throws IOException {
		sc = new MyScanner ();
		new C();
	}

	static long t;

	static long millis() {
		return System.currentTimeMillis();
	}
}

import java.io.*;
import java.util.Arrays;
import java.util.Comparator;

public class C {

	public C () throws IOException {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int K = sc.nextInt();

		int [][][] P = new int [N][M][3];
		for (int n = 0; n < N; ++n) {
			sc.next();
			for (int m = 0; m < M; ++m)
				for (int z = 0; z < 3; ++z)
					P[n][m][z] = sc.nextInt();
		}

		solve(N, M, K, P);
	}

	public void solve (int N, int M, int K, int [][][] P) {
		int res = 0;
		Integer [] L = new Integer[M];
		for (int i = 0; i < M; ++i)
			L[i] = i;

		for (int b = 0; b < N; ++b)
			for (int s = 0; s < N; ++s) {
				final int [] R = new int [M];
				for (int m = 0; m < M; ++m)
					R[m] = P[s][m][1] - P[b][m][0];
				Arrays.sort(L, new Comparator<Integer>() {
					public int compare(Integer x, Integer y) {
						return R[y] - R[x];
					}
				});
				int [] S = new int [M];
				for (int i = 0, k = 0; i < M && k < K; ++i) {
					int m = L[i];
					if (R[m] <= 0) break;
					S[m] = Math.min(P[b][m][2], K-k);
					k += S[m];
				}
				int Z = 0;
				for (int m = 0; m < M; ++m)
					Z += S[m] * R[m];
				res = Math.max(res, Z);
			}
		exit(res);
	}

	////////////////////////////////////////////////////////////////////////////////////

	static MyScanner sc;
	static long t;

	static void print (Object o) {
		System.out.println(o);
	}

	static void exit (Object o) {
		print(o);
		//print2((millis() - t) / 1000.0);
		System.exit(0);
	}

	static void run () throws IOException {
		sc = new MyScanner ();
		new C();
	}

	public static void main(String[] args) throws IOException {
		run();
	}

	static long millis() {
		return System.currentTimeMillis();
	}

	static void start() {
		t = millis();
	}

	static class MyScanner {
		String next() throws IOException {
			newLine();
			return line[index++];
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		String nextLine() throws IOException {
			line = null;
			return r.readLine();
		}

		//////////////////////////////////////////////

		private final BufferedReader r;

		MyScanner () throws IOException {
			this(new BufferedReader(new InputStreamReader(System.in)));
		}

		MyScanner(BufferedReader r) throws IOException {
			this.r = r;
		}

		private String [] line;
		private int index;

		private void newLine() throws IOException {
			if (line == null || index == line.length) {
				line = r.readLine().split(" ");
				index = 0;
			}
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;

public class Main {

	public static class Goods{
		int[]buy = null;
		int[]sell = null;
		int[]rem = null;
		public Goods(int[]buyi, int[]selli, int[]remi){
			buy = buyi;
			sell = selli;
			rem = remi;
		}
		public Goods cloneK(){
			int[]buyi = new int[buy.length];
			int[]selli = new int[buy.length];
			int[]remi = new int[buy.length];
			for(int i = 0; i < buy.length; i++){
				buyi[i] = buy[i];
				selli[i] = sell[i];
				remi[i] = rem[i];
			}
			return new Goods(buyi, selli, remi);
		}
	}

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[]parts = br.readLine().split("\\s+");
		int n = Integer.parseInt(parts[0]);
		int m = Integer.parseInt(parts[1]);
		int k = Integer.parseInt(parts[2]);

		Map<Integer, Goods> map = new HashMap<Integer, Main.Goods>();
		for(int i = 0; i < n; i++){
			String name = br.readLine();
			int[]buy = new int[m];
			int[]sell = new int[m];
			int[]rem = new int[m];
			for(int j = 0; j < m; j++){
				parts = br.readLine().split("\\s+");
				buy[j] = Integer.parseInt(parts[0]);
				sell[j] = Integer.parseInt(parts[1]);
				rem[j] = Integer.parseInt(parts[2]);
			}
			Goods g = new Goods(buy, sell, rem);
			map.put(i, g);
		}
		int max = 0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(i == j)continue;
				Set<Integer> used = new HashSet<Integer>();
				int prods = k;
				Goods buyFrom = map.get(i).cloneK();
				Goods sellTo = map.get(j).cloneK();
				int profit = 0;
				while(prods>0&&used.size()!=m){
					int maxPrice = Integer.MIN_VALUE;
					int idx = -1;
					for(int l = 0; l < m; l++){
						if(used.contains(l))continue;
						if(maxPrice < sellTo.sell[l]-buyFrom.buy[l]){
							maxPrice = sellTo.sell[l]-buyFrom.buy[l];
							idx = l;
						}
					}
					int numToBuy = Math.min(buyFrom.rem[idx],prods);
					if(numToBuy*maxPrice < 0){
						used.add(idx);
						continue;
					}
					profit += numToBuy*maxPrice;
					buyFrom.rem[idx] -= numToBuy;
					if(buyFrom.rem[idx] == 0){
						used.add(idx);
					}
					prods -= numToBuy;
				}
				if(profit > max)max = profit;
			}
		}
		System.out.println(max);

	}
}

import java.io.*;
import java.util.*;

public class test3
{

	public static void main(String[] args) throws Exception
	{
		new test3().run();
	}

	PrintWriter out = null;

	Product[][] products = null;
	int n, m, k;
	int max = 0;

	void Trade(int x, int y)
	{
		for (int i = 0; i < m; i++)
		{
			if (products[x][i].a < products[y][i].b && products[x][i].c != 0)
				products[x][i].d = products[y][i].b - products[x][i].a;
			else
				products[x][i].d = -1;
		}

		Arrays.sort(products[x]);

		int total = 0;
		int i = 0;
		int kk = k;

		while (kk > 0 && i < m)
		{
			if (products[x][i].d < 0)
				break;

			total += products[x][i].d * Math.min(products[x][i].c, kk);
			kk -= Math.min(products[x][i].c, kk);
			i++;
		}

		max = Math.max(max, total);

		Arrays.sort(products[x], new Comparator<Product>()
		{
			public int compare(Product o1, Product o2)
			{
				return o1.id - o2.id;
			}
		});
	}

	void run() throws Exception
	{
		Scanner in = new Scanner(System.in);
		out = new PrintWriter(System.out);

		n = in.nextInt();
		m = in.nextInt();
		k = in.nextInt();

		products = new Product[n][m];

		for (int i = 0; i < n; i++)
		{
			in.next();
			for (int j = 0; j < m; j++)
			{
				products[i][j] = new Product(j, in.nextInt(), in.nextInt(),
						in.nextInt());
			}
		}

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
			{
				if (i == j)
					continue;

				Trade(i, j);
			}

		out.println(max);
		out.close();
	}
}

class Product implements Comparable<Product>
{
	int id;
	int a;
	int b;
	int c;
	int d;

	public Product(int _id, int _a, int _b, int _c)
	{
		id = _id;
		a = _a;
		b = _b;
		c = _c;
	}

	public int compareTo(Product o)
	{
		return o.d - d;
	}
}

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().run();
    }

    Scanner in;
    PrintWriter out;

    void run() {
        in = new Scanner(System.in);
        out = new PrintWriter(System.out);
        try {
            solve();
        } finally {
            out.close();
        }
    }

    class Profit {
        int val, index;

        Profit(int v, int i) {
            val = v;
            index = i;
        }
        public String toString() {
            return val + " " + index;
        }
    }

    class Prod {
        int cnt;
        int buy;
        int sell;
        int index;

        Prod(int b, int s, int k, int index) {
            buy = b;
            sell = s;
            cnt = k;
            this.index = index;
        }
    }

    int min(int a, int b) {
        return Math.min(a, b);
    }

    class List {
        Prod[] a;

        List(Prod[] b) {
            a = b;
        }

        int getProfit(List b, int cap) {
            Profit[] p = new Profit[b.a.length];
            int len = b.a.length;
            for (int i = 0; i < len; i++) {
                p[i] = new Profit(b.a[i].sell - a[i].buy, i);
            }
            Arrays.sort(p, new Comparator<Profit>() {
                public int compare(Profit p1, Profit p2) {
                    return p2.val - p1.val;
                }
            });
            int input = 0;
            int profit = 0;
            int index = 0;
            while (index < len && input != cap) {
                int i = p[index].index;
                int cntProd = min(a[i].cnt, cap - input);
                if (p[index].val < 0) {
                    break;
                }
                profit += cntProd * p[index].val;
                input += cntProd;
                index++;
            }
            return profit;
        }
    }

    void solve() {
        int n = in.nextInt();
        int m = in.nextInt();
        int cap = in.nextInt();
        int profit = 0;
        List[] a = new List[n];
        for (int i = 0; i < n; i++) {
            in.next();
            Prod buf[] = new Prod[m];
            for (int j = 0; j < m; j++) {
                buf[j] = new Prod(in.nextInt(), in.nextInt(), in.nextInt(), j);
            }
            a[i] = new List(buf.clone());
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j)
                    continue;
                profit = Math.max(profit, a[i].getProfit(a[j], cap));
            }
        }
        out.println(profit);

    }
}

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().run();
    }

    Scanner in;
    PrintWriter out;

    void run() {
        in = new Scanner(System.in);
        out = new PrintWriter(System.out);
        try {
            solve();
        } finally {
            out.close();
        }
    }

    class Profit {
        int val, index;

        Profit(int v, int i) {
            val = v;
            index = i;
        }

        @Override
        public String toString() {
            return val + " " + index;
        }
    }

    class Prod {
        int cnt;
        int buy;
        int sell;
        int index;

        Prod(int b, int s, int k, int index) {
            buy = b;
            sell = s;
            cnt = k;
            this.index = index;
        }

        @Override
        public String toString() {
            return buy + " " + sell + " " + cnt;
        }
    }

    int min(int a, int b) {
        return Math.min(a, b);
    }

    class List {
        Prod[] a;

        List(Prod[] b) {
            a = b;
        }

        int getProfit(List b, int cap) {
            //out.println("...try...");
            Profit[] p = new Profit[b.a.length];
            int len = b.a.length;
            for (int i = 0; i < len; i++) {
                p[i] = new Profit(b.a[i].sell - a[i].buy, i);
                //out.println(p[i]);
            }
            //out.println("...sorting...");
            Arrays.sort(p, new Comparator<Profit>() {
                @Override
                public int compare(Profit p1, Profit p2) {
                    return p2.val - p1.val;
                }
            });
            //out.println("result :");
            //for (Profit pr : p) {
            //  out.println(pr);
            //}
            int input = 0;
            int profit = 0;
            int index = 0;
            while (index < len && input != cap) {
                int i = p[index].index;
                //out.println("keep " + i);
                //out.println(a[i].cnt + " : " + (cap - input));
                int cntProd = min(a[i].cnt, cap - input);
                //out.println(p[index].val);
                if (p[index].val < 0) {
                    break;
                }
                //out.println("plus " + cntProd * p[index].val);
                profit += cntProd * p[index].val;
                input += cntProd;
                //out.println(input);
                index++;
            }
            return profit;
        }
    }

    void solve() {
        int n = in.nextInt();
        int m = in.nextInt();
        int cap = in.nextInt();
        int profit = 0;
        List[] a = new List[n];
        for (int i = 0; i < n; i++) {
            in.next();
            Prod buf[] = new Prod[m];
            for (int j = 0; j < m; j++) {
                buf[j] = new Prod(in.nextInt(), in.nextInt(), in.nextInt(), j);
            }
            a[i] = new List(buf.clone());
        }
    //  for (int i = 0; i < n; i++) {
        //  for (int j = 0; j < m; j++) {
        //      out.println(a[i].a[j]);
        //  }
        //  out.println();
        //}
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j)
                    continue;
                // пытаемся закупиться у первого и продать второму
                //out.println("try from " + i + " to " + j);
                profit = Math.max(profit, a[i].getProfit(a[j], cap));
            }
        }
        out.println(profit);

    }
}

//package croc2012.r2;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;

public class A {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni(), m = ni(), K = ni();
		int[][][] f = new int[n][m][];
		for(int i = 0;i < n;i++){
			ns();
			for(int j = 0;j < m;j++){
				f[i][j] = new int[]{ni(), ni(), ni()};
			}
		}

		int gpro = 0;
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				int[][] d = new int[m][];
				for(int k = 0;k < m;k++){
					d[k] = new int[]{Math.max(0, f[j][k][1]-f[i][k][0]), f[i][k][2]};
				}
				Arrays.sort(d, new Comparator<int[]>() {
					public int compare(int[] a, int[] b) {
						return -(a[0] - b[0]);
					}
				});

				int left = K;
				int pro = 0;
				for(int k = 0;k < m;k++){
					int use = Math.min(left, d[k][1]);
					pro += use * d[k][0];
					left -= use;
					if(left == 0)break;
				}
				gpro = Math.max(gpro, pro);
			}
		}
		out.println(gpro);
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new A().run();
	}

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

import static java.lang.Math.*;

public class A implements Runnable{

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new A(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory(){
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10) + " KB");
    }

    void debug(Object... objects){
        if (DEBUG){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException{
        int n = readInt();
        int m = readInt();
        int k = readInt();

        int[][] a = new int[n][m];
        int[][] b = new int[n][m];
        int[][] c = new int[n][m];

        for (int i = 0; i < n; i++){
            readString();

            for (int j = 0; j < m; j++){
                a[i][j] = readInt();
                b[i][j] = readInt();
                c[i][j] = readInt();
            }
        }

        int ans = 0;

        boolean[] used = new boolean[m];
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                if (i == j) continue;

                int x = 0;
                int sum = 0;

                Point max = new Point(0, -1);
                Arrays.fill(used, false);

                while (x < k){
                    for (int ii = 0; ii < m; ii++){
                        if (used[ii]) continue;
                        if (b[j][ii] - a[i][ii] > max.x){
                            max.x = b[j][ii] - a[i][ii];
                            max.y = ii;
                        }
                    }

                    if (max.y != -1) used[max.y] = true;
                    else break;

                    if (c[i][max.y] <= k - x){
                        sum += c[i][max.y] * (b[j][max.y] - a[i][max.y]);

                        x += c[i][max.y];
                    }else{
                        sum += (k - x) * (b[j][max.y] - a[i][max.y]);

                        x = k;
                    }

                    max.x = 0;
                    max.y = -1;
                }

                ans = max(ans, sum);
            }
        }

        out.print(ans);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Comparator;
import java.util.Hashtable;
import java.util.Vector;
import java.util.PriorityQueue;

public class Main {

    /**
     * @param args
     * @throws IOException
     */
    public static class Product{
        public int a;
        public int b;
        public int c;
        Product(int a,int b,int c){
            this.a=a;
            this.b=b;
            this.c=c;
        }
    }
    public static class Profit{
        public int dif;
        public int c;
        Profit(int d,int c){
            this.dif=d;
            this.c=c;
        }
    }
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        //Scanner in=new Scanner(System.in);
        PrintWriter out=new PrintWriter(System.out);
        String[] cur=in.readLine().split(" ");
        int n=Integer.parseInt(cur[0]);
        int m=Integer.parseInt(cur[1]);
        int k=Integer.parseInt(cur[2]);
        Vector<Vector<Product>> vect=new Vector<Vector<Product>>();
        Vector<String> names=new Vector<String>();
        for(int i=0; i<n; i++){
            names.add(in.readLine());
            vect.add(new Vector<Product>());
            for(int j=0; j<m; j++){
                String[] product=in.readLine().split(" ");
                vect.get(i).add(new Product(Integer.parseInt(product[0]),Integer.parseInt(product[1]),Integer.parseInt(product[2])));
            }
        }
        long maxProfit=0;
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
           if(i!=j){
                Vector<Product> f=vect.get(i);
                Vector<Product> s=vect.get(j);
                PriorityQueue<Profit> ch=new PriorityQueue<Profit>(m,new Comparator<Profit>(){
                    public int compare(Profit a,Profit b){
                        if(a.dif>b.dif) return -1;
                        else if(a.dif<b.dif) return 1;
                        return 0;
                    }
                });
                for(int z=0; z<m; z++){
                    ch.add(new Profit(s.get(z).b-f.get(z).a,f.get(z).c));

                }
                int curK=k;
                int curProfit=0;
                while(curK>0 && !ch.isEmpty()){
                    Profit curProf=ch.poll();
                    int step=Math.min(curK,curProf.c);
                    if(curProf.dif>0) curProfit+=step*curProf.dif;
                    else break;
                    curK-=curProf.c;
                }
                if(curProfit>maxProfit) maxProfit=curProfit;
            }
           }
        }
        out.println(maxProfit);
        out.close();
    }

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {

	public static StreamTokenizer in;
	static {in = new StreamTokenizer(new InputStreamReader(System.in));}
	public static int nextInt() throws Exception{
		in.nextToken();
		return (int)in.nval;
	}
	public static String nextString() throws Exception{
		in.nextToken();
		return in.sval;
	}
	public class Product implements Comparable<Product>{
		int buy;
		int sell;
		int quantity;
		public Product(int buy, int sell, int quantity) {
			this.buy = buy;
			this.sell = sell;
			this.quantity = quantity;
		}
		@Override
		public int compareTo(Product o) {
			return this.buy - o.buy;
		}

	}
	//public static BufferedReader in;
	//static {in = new BufferedReader(new InputStreamReader(System.in));}
	public static void main(String[] args) throws Exception {
		Main mai = new Main();
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		Product[][] a = new Product[n][m];
		for (int i = 0; i < n; i++) {
			nextString();
			for (int j = 0; j < m; j++) {
				a[i][j] = mai.new Product(nextInt(), nextInt(), nextInt());
			}
		}
		int max_res = 0;
		Product[] current = new Product[m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (i == j)
					continue;
				for (int l = 0; l < m; l++)
					current[l] = mai.new Product(a[j][l].sell - a[i][l].buy, 0, a[i][l].quantity);
				Arrays.sort(current);
				int res = 0;
				int filled = 0;
				for (int l = m - 1; l >= 0; l--) {
					if (current[l].buy < 1 || filled == k)
						break;
					if (current[l].quantity + filled <= k) {
						res += current[l].quantity * current[l].buy;
						filled += current[l].quantity;
					}
					else {
						res += (k - filled) * current[l].buy;
						filled = k;
					}
				}
				if (res > max_res){
					max_res = res;
				}
			}
		}
		System.out.print(max_res);
		System.out.flush();
	}

}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main
{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer tokenizer=null;

	public static void main(String[] args) throws IOException
	{
		new Main().execute();
	}

	void debug(Object...os)
	{
		System.out.println(Arrays.deepToString(os));
	}

	int ni() throws IOException
	{
		return Integer.parseInt(ns());
	}

	long nl() throws IOException
	{
		return Long.parseLong(ns());
	}

	double nd() throws IOException
	{
		return Double.parseDouble(ns());
	}

	String ns() throws IOException
	{
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(br.readLine());
		return tokenizer.nextToken();
	}

	String nline() throws IOException
	{
		tokenizer=null;
		return br.readLine();
	}

	//Main Code starts Here
	int totalCases, testNum;
	int m,n,k;

	void execute() throws IOException
	{
		totalCases = 1;
		for(testNum = 1; testNum <= totalCases; testNum++)
		{
			input();
			solve();
		}
	}

	void solve()
	{
		//debug("k",k);
		long best=Long.MIN_VALUE;
		for(int i = 0;i<n;i++)
			for(int j =0;j<n;j++)
			{
				//debug(best);
				if(i==j)
					continue;
				Pair[] diff = new Pair[m];
				int dd = 0;
				for(int r =0;r<m;r++)
				{
					int temp = arr[j][r][1]-arr[i][r][0];
					diff[r] = new Pair(temp,r);
				}
				Arrays.sort(diff);
				long profit = 0;
				int index = 0;
				int l = k;
				while(l>0 && index<m && diff[index].a>0)
				{
					int max = arr[i][diff[index].b][2];
					int pr = diff[index].a;
					profit+=pr*Math.min(l,max);
					l = l-Math.min(l,max);
					if(l>0)
						index++;
				}
				//debug(i,j,profit,diff);
				best = Math.max(best,profit);
			}
		System.out.println(Math.max(0,best));
	}

	void printarr(int [] a,int b)
	{
		for(int i = 0;i<=b;i++)
		{
			if(i==0)
				System.out.print(a[i]);
			else
				System.out.print(" "+a[i]);
		}
		System.out.println();
	}
	int[][][] arr;

	class Pair implements Comparable<Pair>
	{
		int a,b;
		Pair(int _a,int _b)
		{
			a=_a;
			b=_b;
		}

		public int compareTo(Pair x)
		{
			if(a == x.a) return b-x.b;
			return -(a-x.a);
		}

		public boolean equals(Pair x)
		{
			return (a==x.a && b==x.b);
		}

		public String toString()
		{
			return "("+a+","+b+")";
		}
	}

	boolean input() throws IOException
	{
		n = ni();
		m = ni();
		k = ni();
		arr = new int[n][m][3];

		for(int i = 0 ;i<n;i++)
		{
			nline();
			for(int j = 0 ;j<m;j++)
			{
					arr[i][j][0]=ni();
					arr[i][j][1]=ni();
					arr[i][j][2]=ni();
			}
		}
		//debug(arr);
		return true;
	}
}

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int k = scanner.nextInt();

        int[][] a = new int[n][m];
        int[][] b = new int[n][m];
        int[][] c = new int[n][m];

        int ans = 0;
        for(int i = 0; i < n; i++) {
            scanner.nextLine();
            String name = scanner.nextLine();
            for(int j = 0; j < m; j++) {
                a[i][j] = scanner.nextInt();
                b[i][j] = scanner.nextInt();
                c[i][j] = scanner.nextInt();
            }
        }

        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                int buy = 0;
                int sell = 0;
                int cnt = k;
                Queue<Node> priorityQueue = new PriorityQueue<>(new Comparator<Node>() {
                    @Override
                    public int compare(Node o1, Node o2) {
                        return o2.value - o1.value;
                    }
                });

                for(int z = 0; z < m; z++) {
                    priorityQueue.offer(new Node(z, b[j][z] - a[i][z]));
                }

                while(cnt > 0 && !priorityQueue.isEmpty()) {
                    Node node = priorityQueue.poll();
                    if(node.value > 0) {
                        if (c[i][node.id] <= cnt) {
                            buy += a[i][node.id] * c[i][node.id];
                            sell += b[j][node.id] * c[i][node.id];
                            cnt -= c[i][node.id];
                        } else {
                            buy += a[i][node.id] * cnt;
                            sell += b[j][node.id] * cnt;
                            cnt = 0;
                        }
                    } else {
                        break;
                    }

                }
                ans = Math.max(ans, sell - buy);
            }
        }
        System.out.println(ans);
    }

    static class Node {
        int id;
        int value;

        public Node(int id, int value) {
            this.id = id;
            this.value = value;
        }
    }
}

import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;
import java.text.*;
import java.io.*;
		public final class Solve {
		static PrintWriter out = new PrintWriter(System.out);
		static void flush() {
	 	out.flush();
	 	}
		static void run(long s, long e) {
		NumberFormat formatter = new DecimalFormat("#0.00000");
		System.out.print("Execution time is " + formatter.format((e - s) / 1000d) + " seconds");
		}
		static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;

	    public FastReader() {
	    br = new BufferedReader(new
	    InputStreamReader(System.in));
	    }
	    static boolean isPalindrome(String str1, String str2) {
	    String str3 = str1+str2;
	    int i = 0, j = str3.length()-1;
	    while(i < j) {
	    char a = str3.charAt(i), b = str3.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    static boolean isPalindrome(String str) {
	    int i = 0, j = str.length()-1;
	    while(i < j) {
	    char a = str.charAt(i), b = str.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    String next() {
	    while (st == null || !st.hasMoreElements()) {
	    try{st = new StringTokenizer(br.readLine());}
	    catch (IOException  e) {e.printStackTrace();}
	    }
	    return st.nextToken();
	    }
	    int nextInt(){ return Integer.parseInt(next()); }
	    long nextLong() { return Long.parseLong(next());}
	    static int fact(int n) {
	    if(n == 1) return 1;
	    return n * fact(n-1);
	   	}
	    public int[] readIntArray(int n) {
	    int[] arr = new int[n];
		for(int i=0; i<n; ++i)
		arr[i]=nextInt();
		return arr;
		}
	    public int[][] readIntArray(int m, int n){
		int[][] arr = new int[m][n];
		for(int i = 0;i<m;i++)
		for(int j = 0;j<n;j++)
		arr[i][j] = nextInt();
		return arr;
	    }
	    public String[] readStringArray(int n) {
		String[] arr = new String[n];
		for(int i=0; i<n; ++i)
		arr[i]= nextLine();
		return arr;
	    }
		static int gcd(int a, int b) {
		if (b == 0) return a;
		return gcd(b, a % b);
		}
	    double nextDouble() {return Double.parseDouble(next());}
	    String nextLine() {
	    String str = "";
	    try{str = br.readLine();}
	    catch (IOException e) {e.printStackTrace();}
	    return str;}
	    }
		static void solve(int[] arr, int n, int k) {
		}
		public static void main(String args[]) throws Exception {
	    FastReader sc = new FastReader();
	    long s = System.currentTimeMillis();

	    int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt();

	    int[][][] arr = new int[n][m][];

	    for(int i = 0;i<n;i++) {
	    	String str = sc.nextLine();

	    	for(int j = 0;j<m;j++) {
	    		arr[i][j] = new int[] {sc.nextInt(), sc.nextInt(), sc.nextInt()};
	    	}
	    }
	    int result = 0;
	    for(int i = 0;i<n;i++) {
	    	for(int j = 0;j<n;j++) {
	    		int[][] pl = new int[m][];
	    		for(int l = 0;l<m;l++) {
	    			pl[l] = new int[] {Math.max(0, arr[j][l][1] - arr[i][l][0]), arr[i][l][2]};
	    		}
	    		Arrays.sort(pl, new Comparator<int[]>(){
	    			public int compare(int[] x, int[] y) {
	    				return -(x[0] - y[0]);
	    			}
	    		});

	    		int d = k;
	    		int res = 0;

	    		for(int l = 0;l<m;l++) {
	    			int b = Math.min(d, pl[l][1]);
	    			res += b * pl[l][0];
	    			d -= b;
	    			if(d == 0) break;
	    		}
	    		result = Math.max(result, res);
	    	}
	    }
	    out.println(result);
	    flush();
	    long e = System.currentTimeMillis();
//	    run(s,e);
	    }
	}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main
{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer tokenizer=null;

	public static void main(String[] args) throws IOException
	{
		new Main().execute();
	}

	void debug(Object...os)
	{
		System.out.println(Arrays.deepToString(os));
	}

	int ni() throws IOException
	{
		return Integer.parseInt(ns());
	}

	long nl() throws IOException
	{
		return Long.parseLong(ns());
	}

	double nd() throws IOException
	{
		return Double.parseDouble(ns());
	}

	String ns() throws IOException
	{
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(br.readLine());
		return tokenizer.nextToken();
	}

	String nline() throws IOException
	{
		tokenizer=null;
		return br.readLine();
	}

	//Main Code starts Here
	int totalCases, testNum;
	int n,m,k;
	int arr[][][];

	void execute() throws IOException
	{
		totalCases = 1;
		for(testNum = 1; testNum <= totalCases; testNum++)
		{
			if(!input())
				break;
			solve();
		}
	}

	void solve() throws IOException
	{
		int maxi = 0;
		for(int i = 0;i<n;i++)
		{
			for(int j = 0;j<n;j++)
			{
				if(i!=j)
				{
					int MAXN = 10100;
					int profit[] = new int[MAXN];
					int index = 0;
					for(int l = 0;l<m;l++)
					{
						int pr = (arr[j][l][1] - arr[i][l][0]);
						for(int z = 0;z<arr[i][l][2];z++)
						{
							profit[index++] = pr;
						}
					}
					Arrays.sort(profit);
					//debug(profit);
					int tep = 0;
					int taken = 0;
					for(int l = MAXN-1;l>=0;l--)
					{
						if(profit[l]>0 && taken<k)
						{
							tep+=profit[l];
							taken++;
						}
						else
							break;
					}
					if(maxi<tep)
						maxi = tep;

				}
			}
		}
		System.out.println(maxi);

	}

	boolean input() throws IOException
	{
		n = ni();
		m = ni();
		k = ni();
		arr = new int[n][m][3];
		for(int i = 0;i<n;i++)
		{
			String s = nline();
			for(int j = 0;j<m;j++)
			{
				arr[i][j][0] = ni();
				arr[i][j][1] = ni();
				arr[i][j][2] = ni();
			}
		}
		return true;
	}

}

import java.util.*;
public class C {
	Scanner sc = new Scanner(System.in);
	class Data {
		int a, b, c;
		Data() {}
		Data(int a, int b, int c) {
			this.a = a; this.b = b; this.c = c;
		}
	}
	class Diff implements Comparable<Diff>{
		int d; int idx;
		Diff() { }
		Diff(int d, int idx) { this.d = d; this.idx = idx; }
		public int compareTo(Diff other) { // 大きい順に並び替える
			if(d > other.d) return -1;
			if(d < other.d) return +1;
			return 0;
		}
	}
	void doIt()
	{
		int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt();
		Data [][] data = new Data[n][m];
		for(int i = 0; i < n; i++) {
			String name = sc.next();
			for(int j = 0; j < m; j++) {
				int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
				data[i][j] = new Data(a, b, c);
			}
		}
		int ans = 0;
		for(int from = 0; from < n; from++) {
			for(int to = 0; to < n; to++) {
				if(from==to) continue;
				ArrayList<Diff> diffs = new ArrayList<Diff>();
				for(int i = 0; i < m; i++) {
					int d = data[to][i].b - data[from][i].a;
					if(d > 0) diffs.add(new Diff(d, i));
				}
				Collections.sort(diffs);
				int rem = k, work = 0;
				for(Diff d: diffs) {
					int qty = data[from][d.idx].c;
					if(qty < rem) {
						rem -= qty;
						work += qty * d.d;
					} else {
						work += rem * d.d;
						break;
					}
				}
				ans = Math.max(ans, work);
			}
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new C().doIt();
	}

}

import java.lang.reflect.Array;
import java.util.*;

public class Main {
    private static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {

        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();

        List<Al> alList = new ArrayList<>();

        for(int i = 0; i < n; i++){
            String s = in.next();
            Al al = new Al(s);
            for(int j = 0; j < m; j++){
                int num1 = in.nextInt();
                int num2 = in.nextInt();
                int num3 = in.nextInt();
                al.list.add(new A(num1,num2,num3));
            }
            alList.add(al);
        }

        Vector<Integer> vector1 = new Vector<>();

        for(int i = 0; i < n; i++){
            Al ali = alList.get(i);
            for(int j = 0; j < n; j++){
                Al alj = alList.get(j);
                vector1.add(ali.getPrice(alj,k));
            }
        }
        int ans1 = 0;
        for(int i = 0; i < vector1.size(); i++){
            ans1 = Math.max(ans1,vector1.get(i));
        }
        System.out.println(ans1);
    }
}

class A{

    int ip;
    int np;
    int w;

    public A( int ip, int np,int w) {
        this.w = w;
        this.ip = ip;
        this.np = np;
    }

}

class C implements Comparable{
    int dp;
    int index;

    public int getDp() {
        return dp;
    }

    public void setDp(int dp) {
        this.dp = dp;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    @Override
    public String toString() {
        return "C{" +
                "dp=" + dp +
                ", index=" + index +
                '}';
    }

    @Override
    public int compareTo(Object o) {
        C c = (C) o;
        if(this.dp > c.dp){
            return -1;
        }else if(this.dp < c.dp){
            return 1;
        }else
            return 0;
    }
}

class Al{
    String ALName;
    List<A> list = new ArrayList<>();

    public Al(String ALName) {
        this.ALName = ALName;
    }

    public String getALName() {
        return ALName;
    }

    public void setALName(String ALName) {
        this.ALName = ALName;
    }

    public List<A> getList() {
        return list;
    }

    public void setList(List<A> list) {
        this.list = list;
    }

    public int getPrice(Al al,int k){
        int len = al.list.size();
        Vector<C> cs = new Vector<>();

        for(int i = 0; i < len; i++){
            C c = new C();
            c.dp = al.list.get(i).np - this.list.get(i).ip;
            c.index = i;
            cs.add(c);
        }

        Collections.sort(cs);

        int j = 0;
        int ans = 0;
        while (k > 0 && j < len){
            if(cs.get(j).dp > 0){
                if(k < this.list.get(cs.get(j).index).w){
                    ans = ans + cs.get(j).dp * k;
                    k = 0;
                    break;
                }else{
                    ans = ans + cs.get(j).dp * this.list.get(cs.get(j).index).w;
                    k -= this.list.get(cs.get(j).index).w;
                }
            }
            j++;
        }

        return ans;
    }
}

import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Krok2C{
    static BufferedReader br;
    public static void main(String args[])throws Exception{
        br=new BufferedReader(new InputStreamReader(System.in));
        int nm[]=toIntArray();
        int n=nm[0];
        int m=nm[1];
        int k=nm[2];
        Planet p[]=new Planet[n];
        for(int i=0;i<n;i++){
            String name=toStr();
            p[i]=new Planet(name,m);
            for(int j=0;j<m;j++){
                nm=toIntArray();
                Item a=new Item(nm[0],nm[1],nm[2]);
                p[i].addItem(a);
            }
        }
        int res=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i==j)continue;
                Planet buy=p[i];
                Planet sell=p[j];
                Keep ar[]=new Keep[m];
                for(int q=0;q<m;q++){
                    int v=sell.it[q].b-buy.it[q].a;
                    ar[q]=new Keep(v,q);
                }
                Arrays.sort(ar);
                int resT=0;
                int num=k;
                for(int x=0;x<m;x++){
                    if(ar[x].val>0){
                        if(num>0){
                            int count=Math.min(buy.it[ar[x].ind].c,num);
                            resT+=ar[x].val*count;
                            num-=count;
                            if(num<=0) break;
                        }
                    }
                }
                res=Math.max(resT,res);
            }
        }

        System.out.println(res);
    }

    /****************************************************************/
    public static int[] toIntArray()throws Exception{
       String str[]=br.readLine().split(" ");
       int k[]=new int[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Integer.parseInt(str[i]);
       }
       return k;
    }
    public static int toInt()throws Exception{
       return Integer.parseInt(br.readLine());
    }
    public static long[] toLongArray()throws Exception{
       String str[]=br.readLine().split(" ");
       long k[]=new long[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Long.parseLong(str[i]);
       }
       return k;
    }
    public static long toLong()throws Exception{
       return Long.parseLong(br.readLine());
    }
    public static double[] toDoubleArray()throws Exception{
       String str[]=br.readLine().split(" ");
       double k[]=new double[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Double.parseDouble(str[i]);
       }
       return k;
    }
    public static double toDouble()throws Exception{
       return Double.parseDouble(br.readLine());
    }
    public static String toStr()throws Exception{
       return br.readLine();
    }
    public static String[] toStrArray()throws Exception{
       String str[]=br.readLine().split(" ");
       return str;
    }
    /****************************************************************/

}
class Item{
    int a;
    int b;
    int c;
    public Item(int aa, int bb, int cc){
        a=aa;
        b=bb;
        c=cc;
    }
}
class Planet{
    String name;
    Item it[];
    int c=0;
    public Planet(String n, int m){
        name=n;
        it=new Item[m];
    }
    public void addItem(Item i){
        it[c++]=i;
    }
}
class Keep implements Comparable<Keep>{
    int val;
    int ind;
    public Keep(int num, int i){
        val=num;
        ind=i;
    }
    public int compareTo(Keep k){
        if(val<k.val){
            return 1;
        }
        else if(val>k.val){
            return -1;
        }
        else return 0;
    }

}

import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int k = scan.nextInt();
        scan.nextLine();
        int[][] a = new int[n][m];
        int[][] b = new int[n][m];
        int[][] c = new int[n][m];
        for (int i = 0; i < n; i++) {
            scan.nextLine();
            for (int j = 0; j < m; j++) {
                a[i][j] = scan.nextInt();
                b[i][j] = scan.nextInt();
                c[i][j] = scan.nextInt();
            }
            scan.nextLine();
        }
        long result = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j) {
                    continue;
                }
                Integer[][] diff = new Integer[m][2];
                for (int index = 0; index < m; index++) {
                    diff[index][1] = c[i][index];
                    diff[index][0] = b[j][index] - a[i][index];
                }
                Arrays.sort(diff, new Comparator<Integer[]>() {

                    @Override
                    public int compare(Integer[] o1, Integer[] o2) {
                        return o2[0] - o1[0];
                    }

                });
                long temp = 0;
                int left = k;
                for (int index = 0; index < diff.length; index++) {
                    if (diff[index][0] <= 0) {
                        break;
                    }
                    int cut = Math.min(left, diff[index][1]);
                    temp += 1L * cut * diff[index][0];
                    left -= cut;
                }
                result = Math.max(result, temp);
            }
        }
        System.out.println(result);
    }
}

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main implements Runnable {
    int a[][];
    int b[][];
    int c[][];

    void solution() throws Exception {
        int n = nextInt();
        int m = nextInt();
        int k = nextInt();
        a = new int[n][m];
        b = new int[n][m];
        c = new int[n][m];
        for (int i = 0; i < n; i++) {
            String name = next();
            for (int j = 0; j < m; j++) {
                a[i][j] = nextInt();
                b[i][j] = nextInt();
                c[i][j] = nextInt();
            }
        }
        boolean[] used = new boolean[m];
        int ret = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                if (i != j) {
                    int have = k;
                    int curProfit = 0;
                    Arrays.fill(used, false);
                    for (; ; ) {
                        if (have == 0) break;
                        int best = -1, bestDelta = 0;
                        for (int l = 0; l < m; l++) {
                            int curDelta = b[j][l] - a[i][l];
                            if (!used[l] && curDelta > bestDelta) {
                                bestDelta = curDelta;
                                best = l;
                            }
                        }
                        if (best == -1 || bestDelta <= 0) break;
                        int take = Math.min(have, c[i][best]);
                        used[best] = true;
                        curProfit += take * bestDelta;
                        have -= take;
                    }
                    ret = Math.max(ret, curProfit);
                }
        out.println(ret);
    }

    ///////////////////// Template definitions //////////////////////////
    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String l = in.readLine();
            if (l == null) return null;
            st = new StringTokenizer(l);
        }
        return st.nextToken();
    }

    public static void main(String args[]) {
        //Locale.setDefault(Locale.UK);
        new Thread(new Main()).start();
    }

    public void run() {
        try {
            boolean online = true;
            Reader reader = online
                    ? new InputStreamReader(System.in)
                    : new FileReader("my.in");
            in = new BufferedReader(reader);
            out = new PrintWriter(System.out);
            solution();
            out.flush();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(202);
        }
    }

    BufferedReader in;
    StringTokenizer st;
    PrintWriter out;
}

import java.util.*; import java.text.*; import java.io.BufferedReader;import java.math.*; import java.util.regex.*; import java.awt.geom.*; import static java.lang.Math.*; import static java.lang.Character.*; import static java.lang.Integer.*; import static java.lang.Double.*; import static java.lang.Long.*; import static java.lang.System.*; import static java.util.Arrays.*;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;

public class C {
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static PrintStream out = System.out;
    static int m,n,K;
    static int[][] a,b,c;
	static void readInput() throws IOException {
		int[] x = parseArrInt(in.readLine());
		n = x[0];
		m = x[1];
		K = x[2];
		a = new int[n][m];
		b = new int[n][m];
		c = new int[n][m];
		for (int i = 0; i < n; i++) {
			String s = in.readLine();
			for (int j = 0; j < m; j++) {
				x = parseArrInt(in.readLine());
				a[i][j]= x[0];
				b[i][j]= x[1];
				c[i][j]= x[2];
			}
		}
	}

	static void process() {
		int res = 0;
		for (int u = 0; u < n; u++) for (int v = 0; v < n; v++) if (u!=v){
			ArrayList<Integer> list = new ArrayList<Integer>();
			for (int i = 0; i < m; i++) {
				int profit = b[v][i] - a[u][i];
				if (profit>0) for (int j = 0; j < c[u][i]; j++) list.add(profit);
			}
			Collections.sort(list);
			int[] k = new int[list.size()];
			for (int i = 0; i < k.length; i++) k[i] = list.get(list.size()-i-1);
			int temp = 0;
			for (int i = 0; i < k.length && i<K; i++) {
				temp += k[i];
			}
			res = Math.max(res, temp);
		}
		System.out.println(res);
	}

	public static void main(String[] args) throws IOException {
		readInput();
		process();
	}

	public static void debug(Object...os) {
		System.err.println(Arrays.deepToString(os));
	}
	static int[] parseArrInt(String s) {
		StringTokenizer st = new StringTokenizer(s);
		ArrayList<Integer> list = new ArrayList<Integer>();
		while (st.hasMoreTokens()) {
			list.add(Integer.parseInt(st.nextToken()));
		}
		Integer[] temp = list.toArray(new Integer[]{});
		int[] res = new int[temp.length];
		for (int i = 0; i < temp.length; i++) {
			res[i] = temp[i];
		}
		return (res);
	}

}

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class A176 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();
        int K = in.nextInt();
        int[][] buy = new int[N][M];
        int[][] sell = new int[N][M];
        int[][] amount = new int[N][M];
        for (int n=0; n<N; n++) {
            in.next(); // name
            for (int m=0; m<M; m++) {
                buy[n][m] = in.nextInt();
                sell[n][m] = in.nextInt();
                amount[n][m] = in.nextInt();
            }
        }
        int max = 0;
        for (int from=0; from<N; from++) {
            for (int to=0; to<N; to++) {
                Data[] data = new Data[M];
                for (int m=0; m<M; m++) {
                    Data d = new Data();
                    d.amount = amount[from][m];
                    d.profit = sell[to][m] - buy[from][m];
                    data[m] = d;
                }
                Arrays.sort(data, new Comparator<Data>() {
                    @Override
                    public int compare(Data o1, Data o2) {
                        return o2.profit - o1.profit;
                    }
                });
                int current = 0;
                int capacity = K;
                for (Data d : data) {
                    if (d.profit > 0) {
                        int items = Math.min(d.amount, capacity);
                        capacity -= items;
                        current += d.profit*items;
                    }
                }
                max = Math.max(max, current);
            }
        }
        System.out.println(max);
    }

    static class Data {
        int amount;
        int profit;
    }

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 *
 */

/**
 * @author antonio081014
 * @time: Apr 20, 2012, 9:26:07 AM
 */
public class C {

    public static void main(String[] args) throws Exception {
	C main = new C();
	main.run();
	System.exit(0);

    }

    public void run() throws Exception {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] str = br.readLine().split("\\s");
	int n = Integer.parseInt(str[0]);
	int m = Integer.parseInt(str[1]);
	int k = Integer.parseInt(str[2]);

	int[][][] planet = new int[n][m][3];
	for (int i = 0; i < n; i++) {
	    br.readLine();
	    for (int j = 0; j < m; j++) {
		str = br.readLine().split("\\s");
		planet[i][j][0] = Integer.parseInt(str[0]);
		planet[i][j][1] = Integer.parseInt(str[1]);
		planet[i][j][2] = Integer.parseInt(str[2]);
	    }
	}

	int max = Integer.MIN_VALUE;
	for (int i = 0; i < n; i++) {
	    for (int j = 0; j < n; j++) {
		List<Item> list = new ArrayList<Item>();
		for (int p = 0; p < m; p++) {
		    list.add(new Item(planet[i][p][0] - planet[j][p][1],
			    planet[i][p][2]));
		}
		Collections.sort(list);
		int left = k;
		int sum = 0;
		for (int p = 0; p < m; p++) {
		    if (list.get(p).price >= 0)
			break;
		    if (left > list.get(p).amount) {
			sum += -list.get(p).price * list.get(p).amount;
			left -= list.get(p).amount;
		    } else if (left != 0) {
			sum += -list.get(p).price * left;
			left = 0;
			break;
		    }
		}
		max = Math.max(max, sum);
	    }
	}
	System.out.println(max);
    }
}

class Item implements Comparable<Item> {
    public int price;
    public int amount;

    public Item(int b, int s) {
	this.price = b;
	this.amount = s;
    }

    public int compareTo(Item item) {
	// if (this.price != item.price)
	return this.price - item.price;
	// return this.amount - item.amount;
    }
}

import java.util.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  test  {

	//ArrayList<Integer> lis = new ArrayList<Integer>();
	//ArrayList<String> lis = new ArrayList<String>();
	//ArrayList<test> lis = new ArrayList<test>();
//	static long sum=0;
	int a,b,c;

public  static void main(String[] args) {
   Scanner sc =new Scanner(System.in);
   while(sc.hasNext()){
		 // =ni(sc)
	   long sum=0;
	 //  int d=sc.nextInt(),m=sc.nextInt(),pr=d;
	   int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt();
	  test x[][]=new test[n][m];
	  for(int i=0 ; i<n ; i++){
		  sc.next();
		  for(int t=0 ; t<m ; t++){

		  x[i][t] = new test();
		  x[i][t].a=sc.nextInt();
		  x[i][t].b=sc.nextInt();
		  x[i][t].c=sc.nextInt();}

	  }

	   for(int i=0 ; i<n ; i++){
		   for(int t=0 ; t<n ; t++){
			  if(i==t)continue;
			   PriorityQueue<pair> que = new PriorityQueue<pair>();

			   for(int u=0;u<m;u++){
				   que.add( new pair(x[t][u].b-x[i][u].a , x[i][u].c) );
				  // db(que.peek().v);
			   }
			   int f=0,s=0;
			 //  db(sum);
			   while(f<k && que.size()!=0){
				 pair te = que.poll();
				 int y = te.v;
			//	 db(f,y,te.vv);
				 if(y<=0 )break;
				 if( te.vv==0 )continue;
				 s+=y;
				 f++;
				 que.add( new pair(y , te.vv-1 ) );
			   }
			   sum=max(sum,s);

		   }
	   }

	 	 System.out.println(sum);

   }
}

    static void db(Object... os){
	         System.err.println(Arrays.deepToString(os));

	}

}

class pair implements Comparable<pair>{
    int v,vv;
	pair(int v,int vv){
		this.v=v;
	    this.vv=vv;
	}

public int compareTo(pair x){
	 return x.v-v;
}

}

import java.util.PriorityQueue;
import java.util.Scanner;

public class PlanetBuySell {

	public static class PlanetDetails{
		String name;
		int buyCost[];
		int sellCost[];
		int items[];
		PlanetDetails(int m){
			this.buyCost = new int[m];
			sellCost = new int[m];
			items = new int[m];
		}
	}
	public static class Item implements Comparable<Item>{
		int buy;
		int sell;
		int cap;
		Item(int a, int b, int c){
			buy = a;
			sell = b;
			cap = c;
		}
		public int compareTo(Item item) {
			return Integer.compare(item.sell - item.buy, this.sell - this.buy);
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt(); //No. of planets
        int m = cin.nextInt(); //Item types
        int k = cin.nextInt(); //Capacity
        PlanetDetails planets[] = new PlanetDetails[n];
        for(int i=0; i<n; i++) {
        	planets[i] = new PlanetDetails(m);
        	planets[i].name = cin.next();

        	for(int j = 0; j<m; j++) {
        		planets[i].buyCost[j] = cin.nextInt();
        		planets[i].sellCost[j] = cin.nextInt();
        		planets[i].items[j] = cin.nextInt();
        	}
        }
        int best = 0;
        for(int i=0; i<n; i++) {
        	for(int j=0; j<n; j++) {
        		 PriorityQueue<Item> q = new PriorityQueue<>();
                 for (int l = 0; l < m; l++)
                 {
                     int b = planets[i].buyCost[l];
                     int s = planets[j].sellCost[l];
                     int c = planets[i].items[l];
                     q.add(new Item(b, s, c));
                 }

                 int cap = k;
                 int earn = 0;
                 while (cap > 0 && !q.isEmpty())
                 {
                     Item item = q.poll();
                     int min = Math.min(cap, item.cap);
                     int p = item.sell - item.buy;
                     if (p <= 0)
                     {
                         continue;
                     }
                     earn += min * p;
                     cap -= min;
                 }
                 best = (int) Math.max(best, earn);
        	}
        }
        cin.close();
        System.out.println(best);
	}

}

import java.util.*;
public class C181{
	public static void main(String[] args){
		Scanner br = new Scanner(System.in);
		int n = br.nextInt();
		int m = br.nextInt();
		int k = br.nextInt();
		int[][] cost = new int[n][m];
		int[][] sell = new int[n][m];
		int[][] am = new int[n][m];
		for(int i = 0;i<n;i++){
			String name = br.next();
			for(int j = 0;j<m;j++){
				cost[i][j] = br.nextInt();
				sell[i][j] = br.nextInt();
				am[i][j] = br.nextInt();
			}
		}
		int best = 0;
		for(int i = 0;i<n;i++){
			for(int j = 0;j<n;j++){
				if(i == j){
					continue;
				}
				int tk = k;
				int profit = 0;
				boolean bought = true;
				int[] left = new int[m];
				for(int l = 0;l<m;l++){
					left[l] = am[i][l];
				}
				while(tk > 0 && bought){
					bought = false;
					int bp = -1;
					int index = -1;
					for(int something = 0;something<m;something++){
						if(left[something] > 0){
							if(sell[j][something]-cost[i][something] > bp){
								bp = sell[j][something]-cost[i][something];
								index = something;
							}
						}
					}
					if(bp != -1){
						bought = true;
						int tam = Math.min(tk, left[index]);
						tk-=tam;
						left[index]-=tam;
						profit+=(bp*tam);
					}
				}
				best = Math.max(best, profit);
			}
		}
		System.out.println(best);
	}
}

import java.io.*;
import java.math.*;
import java.util.*;

public class Solution implements Runnable {

	void solve() throws Exception {
		int pl = nextInt(), goods = nextInt(), place = nextInt();
		//int pl = 10, goods = 100, place = 100;
		int[][] buy = new int[pl][goods];
		int[][] sell = new int[pl][goods];
		int[][] left = new int[pl][goods];
		for (int i = 0; i < pl; ++i) {
			nextToken();
			for (int j = 0; j < goods; ++j) {
				buy[i][j] = nextInt();
				sell[i][j] = nextInt();
				left[i][j] = nextInt();
				//left[i][j] = 100;
			}
		}
		int maxProfit = 0;
		for (int pFr = 0; pFr < pl; ++pFr) {
			for (int pTo = 0; pTo < pl; ++pTo) {
				int[][] curMax = new int[2][place + 1];
				int cur = 0, ne = 1;
				for (int g = 0; g < goods; ++g) {
					Arrays.fill(curMax[ne], 0);
					for (int am = 0; am <= place; ++am) {
						int cM = Math.min(am, left[pFr][g]);
						for (int toBuy = 0; toBuy <= cM; ++toBuy) {
							curMax[ne][am] = Math.max(curMax[ne][am], curMax[cur][am - toBuy] + toBuy * (sell[pTo][g] - buy[pFr][g]));
						}
						maxProfit = Math.max(maxProfit, curMax[ne][am]);
					}
					cur ^= 1;
					ne ^= 1;
				}
			}
		}
		out.print(maxProfit);
	}

	public void run() {
		try {
			solve();
		} catch (Exception e) {
			NOO(e);
		} finally {
			out.close();
		}
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	String nextToken() {
		while (!stringTokenizer.hasMoreTokens()) {
			String line = null;
			try {
				line = in.readLine();
			} catch (IOException e) {
				NOO(e);
			}
			if (line == null) {
				return null;
			}
			stringTokenizer = new StringTokenizer(line);
		}
		return stringTokenizer.nextToken();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer stringTokenizer;

	void NOO(Exception e) {
		e.printStackTrace();
		System.exit(42);
	}

	public Solution(String name) {
		try {
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter(new FileWriter("output.txt"));
			stringTokenizer = new StringTokenizer("");
		} catch (Exception e) {
			NOO(e);
		}
	}

	public Solution() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			stringTokenizer = new StringTokenizer("");
		} catch (Exception e) {
			NOO(e);
		}
	}

	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		new Solution().run();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Solver {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException, IOException {
        Solver solver = new Solver();
        solver.open();
        solver.solve();
        solver.close();
    }

    public void open() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    public String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }

    public class Razn implements Comparable<Razn>{
        public int count;
        public int dif;
        @Override
        public int compareTo(Razn o) {
            return o.dif-dif;
        }

    }

    Razn[] ar = null;

    public long check(int[][] planet1, int[][] planet2, int m, int k){

        for (int i=0;i<m;i++){
            ar[i].dif =
                    planet2[i][1]-planet1[i][0];
            ar[i].count = planet1[i][2];
        }
        Arrays.sort(ar);

        int i=0;
        long result = 0;
        while (i<m && k>0 && ar[i].dif>0){
            int count = Math.min(k, ar[i].count);
            result += count*1l*ar[i].dif;
            k -= count;
            i++;
        }

        return result;
    }

    public void solve() throws NumberFormatException, IOException {
        int n = nextInt();
        int m = nextInt();
        int k = nextInt();
        ar = new Razn[m];
        for (int i=0;i<m;i++){
            ar[i] = new Razn();
        }
        int[][][] planets = new int[n][m][3];
        for(int i=0;i<n;i++){
            nextToken();
            for(int j=0;j<m;j++){
                planets[i][j][0] = nextInt();
                planets[i][j][1] = nextInt();
                planets[i][j][2] = nextInt();
            }
        }

        long result = 0;

        for (int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if (i!=j){
                    long tmp = check(planets[i],planets[j],m,k);
                    if(tmp>result) result = tmp;
                }
            }
        }

        out.println(result);
    }

    public void close() {
        out.flush();
        out.close();
    }

}

import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {

    private void solve() {
        int n=in.nextInt();
        int m=in.nextInt();
        int k=in.nextInt();
        int[][]buy = new int[n][m];
        int[][]sell = new int[n][m];
        int[][]count = new int[n][m];
        for(int i=0;i<n;++i) {
            String name=in.nextToken();
            for(int j=0;j<m; ++j) {
                buy[i][j]=in.nextInt();
                sell[i][j]=in.nextInt();
                count[i][j]=in.nextInt();
            }
        }
        int best=0;
        for(int i=0;i<n;++i) {
            for(int j=0;j<n; ++j) {
                if (i == j)
                    continue;
                int space=k;

                int cur=0;
                int[] my = count[i].clone();
                while (space>0) {
                    int good=-1;
                    for(int v=0;v<m; ++v) {
                        if (buy[i][v] < sell[j][v] && my[v] > 0 && (good == -1 || sell[j][v]-buy[i][v] > sell[j][good] -buy[i][good])) {
                            good=v;
                        }
                    }
                    if (good==-1)
                        break;
                    //out.println("this");
                    int oper = Math.min(space, my[good]);
                    my[good]-=oper;
                    cur += oper * (sell[j][good]-buy[i][good]);
                    space -= oper;
                }
                best = Math.max(best, cur);
            }
        }
        out.println(best);

    }

    private void run() {
        try {
            long start = System.currentTimeMillis();
            in = new FastScanner("input.txt", "output.txt");
            solve();
            out.flush();
            System.err.print("running time = " + (System.currentTimeMillis() - start) * 1e-3);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    FastScanner in;
    static PrintWriter out;
    static class FastScanner {
        public BufferedReader reader;
        private StringTokenizer tokenizer;
        public FastScanner(String input, String output) {
            try {
                reader = new BufferedReader(new FileReader(new File(input)));
                out = new PrintWriter(new File(output));
                tokenizer = null;
            } catch (Exception e) {
                reader = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
                tokenizer = null;
            }
        }
        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
        public String nextToken() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (Exception e) {
                    //return "-1";
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(nextToken());
        }
        long nextLong() {
            return Long.parseLong(nextToken());
        }
    }
 }

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A176 {

    static StringTokenizer st;
    static BufferedReader in;
    static class Sort implements Comparable<Sort> {
        int profit, rest;
        public int compareTo(Sort arg0) {
            return -(this.profit-arg0.profit);
        }
    }
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int m = nextInt();
        int k = nextInt();
        int[][]a = new int[n+1][m+1], b = new int[n+1][m+1], c = new int[n+1][m+1];
        for (int i = 1; i <= n; i++) {
            next();
            for (int j = 1; j <= m; j++) {
                a[i][j] = nextInt();
                b[i][j] = nextInt();
                c[i][j] = nextInt();
            }
        }
        int max = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (i != j) {
                    Sort[]t = new Sort[m+1];
                    for (int j2 = 1; j2 <= m; j2++) {
                        t[j2] = new Sort();
                        t[j2].profit = b[j][j2] - a[i][j2];
                        t[j2].rest = c[i][j2];
                    }
                    Arrays.sort(t, 1, m+1);
                    int sum = 0;
                    int total = k;
                    for (int j2 = 1; j2 <= m; j2++) {
                        if (t[j2].profit <= 0)
                            break;
                        if (t[j2].rest < total) {
                            sum += t[j2].profit * t[j2].rest;
                            total -= t[j2].rest;
                        }
                        else {
                            sum += t[j2].profit * total;
                            break;
                        }
                    }
                    max = Math.max(max, sum);
                }
            }
        }
        pw.println(max);
        pw.close();
    }
    private static int nextInt() throws IOException{
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException{
        return Long.parseLong(next());
    }

    private static double nextDouble() throws IOException{
        return Double.parseDouble(next());
    }

    private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
}

import java.util.*;

/**
 * Created by IntelliJ IDEA.
 * User: piyushd
 * Date: 3/26/11
 * Time: 10:53 PM
 * To change this template use File | Settings | File Templates.
 */
public class TaskC {

    class Planet {
        int a;
        int b;
        int c;

        Planet(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }
    }

    class State implements Comparable<State> {
        int item;
        int profit;

        State(int item, int profit) {
            this.item = item;
            this.profit = profit;
        }

        @Override
        public int compareTo(State state) {
            return state.profit - profit;
        }
    }

    void run() {
        int N = nextInt(), M = nextInt(), K = nextInt();
        Planet[][] p = new Planet[N][M];
        for (int i = 0; i < N; i++) {
            String s = next();
            for (int j = 0; j < M; j++) {
                p[i][j] = new Planet(nextInt(), nextInt(), nextInt());
            }
        }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (i == j) continue;
                State[] s = new State[M];
                for (int k = 0; k < M; k++) s[k] = new State(k, p[j][k].b - p[i][k].a);
                Arrays.sort(s);

                int taken = 0, profit = 0;
                for (int k = 0; k < M; k++) {
                    if (s[k].profit > 0) {
                        int canTake = p[i][s[k].item].c;
                        canTake = Math.min(canTake, K - taken);

                        profit += s[k].profit * canTake;
                        taken += canTake;
                    }
                }

                ans = Math.max(ans, profit);
            }
        }

        System.out.println(ans);
    }

    int nextInt(){
        try{
            int c = System.in.read();
            if(c == -1) return c;
            while(c != '-' && (c < '0' || '9' < c)){
                c = System.in.read();
                if(c == -1) return c;
            }
            if(c == '-') return -nextInt();
            int res = 0;
            do{
                res *= 10;
                res += c - '0';
                c = System.in.read();
            }while('0' <= c && c <= '9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }

    long nextLong(){
        try{
            int c = System.in.read();
            if(c == -1) return -1;
            while(c != '-' && (c < '0' || '9' < c)){
                c = System.in.read();
                if(c == -1) return -1;
            }
            if(c == '-') return -nextLong();
            long res = 0;
            do{
                res *= 10;
                res += c-'0';
                c = System.in.read();
            }while('0' <= c && c <= '9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }

    double nextDouble(){
        return Double.parseDouble(next());
    }

    String next(){
        try{
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while(Character.isWhitespace(c))
                c = System.in.read();
            do{
                res.append((char)c);
            }while(!Character.isWhitespace(c=System.in.read()));
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }

    String nextLine(){
        try{
            StringBuilder res = new StringBuilder("");
            int c = System.in.read();
            while(c == '\r' || c == '\n')
                c = System.in.read();
            do{
                res.append((char)c);
                c = System.in.read();
            }while(c != '\r' && c != '\n');
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }

    public static void main(String[] args){
        new TaskC().run();
    }
}

/**
 * Created with IntelliJ IDEA.
 * User: Zakhar_Voit
 * Date: 21.04.12
 * Time: 1:48
 */

import java.io.*;
import java.util.*;

import static java.lang.System.exit;

public class C {

    class Pair implements Comparable<Pair> {
        long u;
        long v;

        public Pair(long u, long v) {
            this.u = u;
            this.v = v;
        }

        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return (int) (hu * 31 + hv);
        }

        public boolean equals(Object o) {
            Pair other = (Pair) o;
            return u == other.u && v == other.v;
        }

        public int compareTo(Pair other) {
            if (u != other.u)
                return u < other.u ? -1 : 1;

            return v < other.v ? -1 : v > other.v ? 1 : 0;
        }

        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }

    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");

    public void openIO() throws IOException {
        if (new File("input.txt").exists()) {
            System.setIn(new FileInputStream("input.txt"));
            out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
        } else {
            out = new PrintWriter(System.out);
        }
        in = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() throws IOException {
        while (!st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextLine() throws IOException {
        st = new StringTokenizer("");
        return in.readLine();
    }

    boolean EOF() throws IOException {
        while (!st.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null)
                return true;
            st = new StringTokenizer(s);
        }
        return false;
    }

    int n, m, k, ans = 0;
    int[][] a, b, c;

    static void swap(int[] a, int i, int j) {
        int t = a[j];
        a[j] = a[i];
        a[i] = t;
    }

    void init() {

    }

    void read() throws IOException {
        n = nextInt();
        m = nextInt();
        k = nextInt();
        a = new int[n][m];
        b = new int[n][m];
        c = new int[n][m];
        for (int i = 0; i < n; i++) {
            nextLine();
            for (int j = 0; j < m; j++) {
                a[i][j] = nextInt();
                b[i][j] = nextInt();
                c[i][j] = nextInt();
            }
        }
    }

    void solve() {
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int[] diff = new int[m], cnt = new int[m];
                for (int k = 0; k < m; k++) cnt[k] = c[i][k];
                for (int k = 0; k < m; k++) {
                    diff[k] = b[j][k] - a[i][k];
                }
                for (int t = 0; t < m; t++) {
                    for (int c = 0; c + 1< m; c++) {
                        if (diff[c] < diff[c + 1]) {
                            swap(diff, c, c + 1);
                            swap(cnt, c, c + 1);
                        }
                    }
                }
                int cur = 0, profit = 0, idx = 0;
                while (cur < k && idx < m) {
                    int lastcur = cur;
                    cur += Math.min(k - lastcur, cnt[idx]);
                    profit += Math.min(k - lastcur, cnt[idx]) * diff[idx];
                    idx++;
                }
                ans = Math.max(ans, profit);
            }
        }
    }

    void write() {
        out.println(ans);
    }

    public void run() throws IOException {
        openIO();
        init();
        read();
        solve();
        write();
        out.close();
    }

    static public void main(String[] args) throws IOException {
        new Thread(null, new Runnable() {
            public void run() {
                try {
                    new C().run();
                } catch (Throwable e) {
                    e.printStackTrace();
                    exit(999);
                }
            }
        }, "1", 1 << 23).start();
    }
}

/**
 * Created with IntelliJ IDEA.
 * User: Zakhar_Voit
 * Date: 21.04.12
 * Time: 1:48
 */

import java.io.*;
import java.util.*;

import static java.lang.System.exit;

public class C {

    class Pair implements Comparable<Pair> {
        long u;
        long v;

        public Pair(long u, long v) {
            this.u = u;
            this.v = v;
        }

        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return (int) (hu * 31 + hv);
        }

        public boolean equals(Object o) {
            Pair other = (Pair) o;
            return u == other.u && v == other.v;
        }

        public int compareTo(Pair other) {
            if (u != other.u)
                return u < other.u ? -1 : 1;

            return v < other.v ? -1 : v > other.v ? 1 : 0;
        }

        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }

    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");

    public void openIO() throws IOException {
        if (new File("input.txt").exists()) {
            System.setIn(new FileInputStream("input.txt"));
            out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
        } else {
            out = new PrintWriter(System.out);
        }
        in = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() throws IOException {
        while (!st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextLine() throws IOException {
        st = new StringTokenizer("");
        return in.readLine();
    }

    boolean EOF() throws IOException {
        while (!st.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null)
                return true;
            st = new StringTokenizer(s);
        }
        return false;
    }

    int n, m, k, ans = 0;
    int[][] a, b, c;

    static void swap(int[] a, int i, int j) {
        int t = a[j];
        a[j] = a[i];
        a[i] = t;
    }

    void init() {

    }

    void read() throws IOException {
        n = nextInt();
        m = nextInt();
        k = nextInt();
        a = new int[n][m];
        b = new int[n][m];
        c = new int[n][m];
        for (int i = 0; i < n; i++) {
            nextLine();
            for (int j = 0; j < m; j++) {
                a[i][j] = nextInt();
                b[i][j] = nextInt();
                c[i][j] = nextInt();
            }
        }
    }

    void solve() {
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int[] diff = new int[m], cnt = c[i];
                for (int k = 0; k < m; k++) {
                    diff[k] = b[j][k] - a[i][k];
                }
                for (int t = 0; t < m; t++) {
                    for (int c = 0; c + 1< m; c++) {
                        if (diff[c] < diff[c + 1]) {
                            swap(diff, c, c + 1);
                            swap(cnt, c, c + 1);
                        }
                    }
                }
                int cur = 0, profit = 0, idx = 0;
                while (cur < k && idx < m) {
                    int lastcur = cur;
                    cur += Math.min(k - lastcur, cnt[idx]);
                    profit += Math.min(k - lastcur, cnt[idx]) * diff[idx];
                    idx++;
                }
                ans = Math.max(ans, profit);
            }
        }
    }

    void write() {
        out.println(ans);
    }

    public void run() throws IOException {
        openIO();
        init();
        read();
        solve();
        write();
        out.close();
    }

    static public void main(String[] args) throws IOException {
        new Thread(null, new Runnable() {
            public void run() {
                try {
                    new C().run();
                } catch (Throwable e) {
                    e.printStackTrace();
                    exit(999);
                }
            }
        }, "1", 1 << 23).start();
    }
}

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.InputMismatchException;

/**
 * http://codeforces.com/contest/181/problem/C
 *
 * @author sultan.of.swing
 *
 */

public class TaskC {

	public FasterScanner mFScanner;
	public PrintWriter mOut;
	int planets;
	int types, capacity;
	int buy[][], sell[][], items[][];

	public TaskC() {
		mFScanner = new FasterScanner();
		mOut = new PrintWriter(System.out);
	}

	public void solve() {

		planets = mFScanner.nextInt();
		types = mFScanner.nextInt();
		capacity = mFScanner.nextInt();

		buy = new int[planets][types];
		sell = new int[planets][types];
		items = new int[planets][types];

		int i, j;

		for (i = 0; i < planets; i++) {
			mFScanner.nextLine();
			for (j = 0; j < types; j++) {
				buy[i][j] = mFScanner.nextInt();
				sell[i][j] = mFScanner.nextInt();
				items[i][j] = mFScanner.nextInt();
			}
		}

		int profit = 0;

		for (i = 0; i < planets; i++) {
			for (j = 0; j < planets; j++) {

				if (i == j)
					continue;

				profit = Math.max(profit, maxProfit(i, j));

			}
		}

		mOut.println(profit);

	}

	public int maxProfit(int planetBuy, int planetSell) {
		ArrayList<Items> items = new ArrayList<>();
		int profit;

		for (int i = 0; i < types; i++) {
			profit = sell[planetSell][i] - buy[planetBuy][i];
			items.add(new Items(profit, this.items[planetBuy][i]));
		}

		Collections.sort(items);
		profit = 0;
		int capacity = 0;
		int remCap = this.capacity;

		for (int i = 0; i < items.size(); i++) {

			capacity = items.get(i).capacity;
			capacity = Math.min(capacity, remCap);

			profit += (capacity * items.get(i).profit);
			remCap -= capacity;

		}

		return profit;

	}

	class Items implements Comparable<Items> {
		int profit;
		int capacity;

		public Items(int profit, int capacity) {
			this.profit = profit;
			this.capacity = capacity;
		}

		@Override
		public int compareTo(Items o) {
			// TODO Auto-generated method stub
			return Integer.compare(o.profit, this.profit);
		}
	}

	public void flush() {
		mOut.flush();
	}

	public void close() {
		mOut.close();
	}

	public static void main(String[] args) {
		TaskC mSol = new TaskC();
		mSol.solve();
		mSol.flush();
		mSol.close();
	}

	class FasterScanner {
		private InputStream mIs;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FasterScanner() {
			this(System.in);
		}

		public FasterScanner(InputStream is) {
			mIs = is;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = mIs.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public double nextDouble() {
			Double next;
			next = Double.parseDouble(nextString());
			return next;
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public char[] nextCharArray(int N) {
			int i;
			char[] array;
			String str;

			array = new char[N];

			i = 0;

			str = nextLine();

			for (i = 0; i < N && i < str.length(); i++) {
				array[i] = str.charAt(i);
			}

			return array;
		}

		public char[][] nextChar2DArray(int M, int N) {
			int i;
			char[][] array;

			array = new char[M][N];

			i = 0;

			for (i = 0; i < M; i++) {
				array[i] = nextCharArray(N);
			}

			return array;
		}

		public int[] nextIntArray(int N) {
			int i;
			int[] array;

			array = new int[N];

			i = 0;

			for (i = 0; i < N; i++) {
				array[i] = nextInt();
			}

			return array;
		}

		public int[][] nextInt2DArray(int M, int N) {
			int i;
			int[][] array;

			array = new int[M][N];

			i = 0;

			for (i = 0; i < M; i++) {
				array[i] = nextIntArray(N);
			}

			return array;
		}

		public long[] nextLongArray(int N) {
			int i;
			long[] array;

			array = new long[N];

			i = 0;

			for (i = 0; i < N; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public long[][] nextLong2DArray(int M, int N) {
			int i;
			long[][] array;

			array = new long[M][N];

			i = 0;

			for (i = 0; i < M; i++) {
				array[i] = nextLongArray(N);
			}

			return array;
		}

		public double[] nextDoubleArray(int N) {
			int i;
			double[] array;

			array = new double[N];

			for (i = 0; i < N; i++) {
				array[i] = nextDouble();
			}

			return array;
		}

		public double[][] nextDouble2DArray(int M, int N) {
			int i;
			double[][] array;

			array = new double[M][N];

			for (i = 0; i < M; i++) {
				array[i] = nextDoubleArray(N);
			}

			return array;
		}

	}
}

import java.io.*;
import java.util.*;

public class test3
{

	public static void main(String[] args) throws Exception
	{
		new test3().run();
	}

	PrintWriter out = null;

	Product[][] products = null;
	int n, m, k;
	int max = 0;

	void Trade(int x, int y)
	{
		for (int i = 0; i < m; i++)
		{
			if (products[x][i].a < products[y][i].b && products[x][i].c != 0)
				products[x][i].d = products[y][i].b - products[x][i].a;
			else
				products[x][i].d = -1;
		}

		Arrays.sort(products[x]);

		int total = 0;
		int i = 0;
		int kk = k;

		while (kk > 0 && i < m)
		{
			if (products[x][i].d < 0)
				break;

			total += products[x][i].d * Math.min(products[x][i].c, kk);
			kk -= Math.min(products[x][i].c, kk);
			i++;
		}

		max = Math.max(max, total);

		Arrays.sort(products[x], new Comparator<Product>()
		{
			public int compare(Product o1, Product o2)
			{
				return o1.id - o2.id;
			}
		});
	}

	void run() throws Exception
	{
		Scanner in = new Scanner(System.in);
		out = new PrintWriter(System.out);

		n = in.nextInt();
		m = in.nextInt();
		k = in.nextInt();

		products = new Product[n][m];

		for (int i = 0; i < n; i++)
		{
			in.next();
			for (int j = 0; j < m; j++)
			{
				products[i][j] = new Product(m, in.nextInt(), in.nextInt(),
						in.nextInt());
			}
		}

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
			{
				// if (i == j)
				// continue;

				Trade(i, j);
			}

		out.println(max);
		out.close();
	}
}

class Product implements Comparable<Product>
{
	int id;
	int a;
	int b;
	int c;
	int d;

	public Product(int _id, int _a, int _b, int _c)
	{
		id = _id;
		a = _a;
		b = _b;
		c = _c;
	}

	public int compareTo(Product o)
	{
		return o.d - d;
	}
}

import java.io.*;
import java.util.*;

public class test3
{

	public static void main(String[] args) throws Exception
	{
		new test3().run();
	}

	PrintWriter out = null;

	Product[][] products = null;
	int n, m, k;
	int max = 0;

	void Trade(int x, int y)
	{
		for (int i = 0; i < m; i++)
		{
			if (products[x][i].a < products[y][i].b)
				products[x][i].d = products[y][i].b - products[x][i].a;
			else
				products[x][i].d = -1;
		}

		Arrays.sort(products[x]);

		int total = 0;
		int i = 0;
		int kk = k;

		while (kk > 0 && i < m)
		{
			if (products[x][i].d < 0)
				break;

			total += products[x][i].d * Math.min(products[x][i].c, kk);
			kk -= Math.min(products[x][i].c, kk);
			i++;
		}

		max = Math.max(max, total);

		Arrays.sort(products[x], new Comparator<Product>()
		{
			public int compare(Product o1, Product o2)
			{
				return o1.id - o2.id;
			}
		});
	}

	void run() throws Exception
	{
		Scanner in = new Scanner(System.in);
		out = new PrintWriter(System.out);

		n = in.nextInt();
		m = in.nextInt();
		k = in.nextInt();

		products = new Product[n][m];

		for (int i = 0; i < n; i++)
		{
			in.next();
			for (int j = 0; j < m; j++)
			{
				products[i][j] = new Product(m, in.nextInt(), in.nextInt(),
						in.nextInt());
			}
		}

		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
			{
				if (i == j)
					continue;

				Trade(i, j);
			}

		out.println(max);
		out.close();
	}
}

class Product implements Comparable<Product>
{
	int id;
	int a;
	int b;
	int c;
	int d;

	public Product(int _id, int _a, int _b, int _c)
	{
		id = _id;
		a = _a;
		b = _b;
		c = _c;
	}

	public int compareTo(Product o)
	{
		return o.d - d;
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int P = in.nextInt();
            int T = in.nextInt();
            int left = in.nextInt();
            Planet[] planets = new Planet[P];
            for (int i = 0; i < P; i++)
            {
                in.next();
                long[] buy = new long[T];
                long[] sell = new long[T];
                long[] cap = new long[T];
                for (int j = 0; j < T; j++)
                {
                    buy[j] = in.nextInt();
                    sell[j] = in.nextInt();
                    cap[j] = in.nextInt();
                }
                planets[i] = new Planet(buy, sell, cap);
            }
            long best = 0;
            for (int i = 0; i < P; i++)
            {
                for (int j = 0; j < T; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    PriorityQueue<Item> q = new PriorityQueue<>();
                    for (int k = 0; k < T; k++)
                    {
                        long b = planets[i].buy[k];
                        long s = planets[j].sell[k];
                        long c = planets[i].cap[k];
                        q.add(new Item(b, s, c));
                    }

                    long cap = left;
                    long earn = 0;
                    while (cap > 0 && !q.isEmpty())
                    {
                        Item item = q.poll();
                        long min = Math.min(cap, item.cap);
                        long p = item.sell - item.buy;
                        earn += min * p;
                        cap -= min;
                    }
                    best = Math.max(best, earn);
                }
            }
            out.println(best);
        }

        class Planet
        {
            long[] buy;
            long[] sell;
            long[] cap;

            public Planet(long[] buy, long[] sell, long[] cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

        }

        class Item implements Comparable<Item>
        {
            long buy;
            long sell;
            long cap;

            public Item(long buy, long sell, long cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

            public int compareTo(Item that)
            {
                double r1 = this.sell / (1.0 * this.buy);
                double r2 = that.sell / (1.0 * that.buy);
                return Double.compare(r2, r1);
            }

            public String toString()
            {
                return " Buy = " + buy + " Sell = " + sell + " Cap = " + cap;
            }

        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int n = in.nextInt();
            int m = in.nextInt();
            int left = in.nextInt();
            Planet[] planets = new Planet[n];
            for (int i = 0; i < n; i++)
            {
                in.next();
                long[] buy = new long[m];
                long[] sell = new long[m];
                long[] cap = new long[m];
                for (int j = 0; j < m; j++)
                {
                    buy[j] = in.nextInt();
                    sell[j] = in.nextInt();
                    cap[j] = in.nextInt();
                }
                planets[i] = new Planet(buy, sell, cap);
            }
            long best = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    PriorityQueue<Item> q = new PriorityQueue<>();
                    for (int k = 0; k < m; k++)
                    {
                        long b = planets[i].buy[k];
                        long s = planets[j].sell[k];
                        long c = planets[i].cap[k];
                        q.add(new Item(b, s, c));
                    }

                    long cap = left;
                    long earn = 0;
                    while (cap > 0 && !q.isEmpty())
                    {
                        Item item = q.poll();
                        long min = Math.min(cap, item.cap);
                        long p = item.sell - item.buy;
                        earn += min * p;
                        cap -= min;
                    }
                    best = Math.max(best, earn);
                }
            }
            out.println(best);
        }

        class Planet
        {
            long[] buy;
            long[] sell;
            long[] cap;

            public Planet(long[] buy, long[] sell, long[] cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

        }

        class Item implements Comparable<Item>
        {
            long buy;
            long sell;
            long cap;

            public Item(long buy, long sell, long cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

            public int compareTo(Item that)
            {
                double r1 = this.sell / (1.0 * this.buy);
                double r2 = that.sell / (1.0 * that.buy);
                return Double.compare(r2, r1);
            }

            public String toString()
            {
                return " Buy = " + buy + " Sell = " + sell + " Cap = " + cap;
            }

        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int n = in.nextInt();
            int m = in.nextInt();
            int left = in.nextInt();
            Planet[] planets = new Planet[n];
            for (int i = 0; i < n; i++)
            {
                in.next();
                long[] buy = new long[m];
                long[] sell = new long[m];
                long[] cap = new long[m];
                for (int j = 0; j < m; j++)
                {
                    buy[j] = in.nextInt();
                    sell[j] = in.nextInt();
                    cap[j] = in.nextInt();
                }
                planets[i] = new Planet(buy, sell, cap);
            }
            long best = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
//                if (i == j)
//                {
//                    continue;
//                }

                    PriorityQueue<Item> q = new PriorityQueue<>();
                    for (int k = 0; k < m; k++)
                    {
                        long b = planets[i].buy[k];
                        long s = planets[j].sell[k];
                        long c = planets[i].cap[k];
                        q.add(new Item(b, s, c));
                    }

                    long cap = left;
                    long earn = 0;
                    while (cap > 0 && !q.isEmpty())
                    {
                        Item item = q.poll();
                        long min = Math.min(cap, item.cap);
                        long p = item.sell - item.buy;
                        earn += min * p;
                        cap -= min;
                    }
                    best = Math.max(best, earn);
                }
            }
            out.println(best);
        }

        class Planet
        {
            long[] buy;
            long[] sell;
            long[] cap;

            public Planet(long[] buy, long[] sell, long[] cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

        }

        class Item implements Comparable<Item>
        {
            long buy;
            long sell;
            long cap;

            public Item(long buy, long sell, long cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

            public int compareTo(Item that)
            {
                double r1 = this.sell / (1.0 * this.buy);
                double r2 = that.sell / (1.0 * that.buy);
                return Double.compare(r2, r1);
            }

            public String toString()
            {
                return " Buy = " + buy + " Sell = " + sell + " Cap = " + cap;
            }

        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int n = in.nextInt();
            int m = in.nextInt();
            int left = in.nextInt();
            Planet[] planets = new Planet[n];
            for (int i = 0; i < n; i++)
            {
                in.next();
                int[] buy = new int[m];
                int[] sell = new int[m];
                int[] cap = new int[m];
                for (int j = 0; j < m; j++)
                {
                    buy[j] = in.nextInt();
                    sell[j] = in.nextInt();
                    cap[j] = in.nextInt();
                }
                planets[i] = new Planet(buy, sell, cap);
            }
            int best = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    PriorityQueue<Item> q = new PriorityQueue<>();
                    for (int k = 0; k < m; k++)
                    {
                        int b = planets[i].buy[k];
                        int s = planets[j].sell[k];
                        int c = planets[i].cap[k];
                        q.add(new Item(b, s, c));
                    }

                    int cap = left;
                    int earn = 0;
                    while (cap > 0 && !q.isEmpty())
                    {
                        Item item = q.poll();
                        int min = Math.min(cap, item.cap);
                        int p = item.sell - item.buy;
                        earn += min * p;
                        cap -= min;
                    }
                    best = Math.max(best, earn);
                }
            }
            out.println(best);
        }

        class Planet
        {
            int[] buy;
            int[] sell;
            int[] cap;

            public Planet(int[] buy, int[] sell, int[] cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

        }

        class Item implements Comparable<Item>
        {
            int buy;
            int sell;
            int cap;

            public Item(int buy, int sell, int cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

            public int compareTo(Item that)
            {
                double r1 = this.sell / (1.0 * this.buy);
                double r2 = that.sell / (1.0 * that.buy);
                return Double.compare(r2, r1);
            }

            public String toString()
            {
                return " Buy = " + buy + " Sell = " + sell + " Cap = " + cap;
            }

        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int P = in.nextInt();
            int T = in.nextInt();
            int left = in.nextInt();
            Planet[] planets = new Planet[P];
            for (int i = 0; i < P; i++)
            {
                in.next();
                long[] buy = new long[T];
                long[] sell = new long[T];
                long[] cap = new long[T];
                for (int j = 0; j < T; j++)
                {
                    buy[j] = in.nextInt();
                    sell[j] = in.nextInt();
                    cap[j] = in.nextInt();
                }
                planets[i] = new Planet(buy, sell, cap);
            }
            long best = 0;
            for (int i = 0; i < P; i++)
            {
                for (int j = 0; j < P; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    PriorityQueue<Item> q = new PriorityQueue<>();
                    for (int k = 0; k < T; k++)
                    {
                        long b = planets[i].buy[k];
                        long s = planets[j].sell[k];
                        long c = planets[i].cap[k];
                        q.add(new Item(b, s, c));
                    }

                    long cap = left;
                    long earn = 0;
                    while (cap > 0 && !q.isEmpty())
                    {
                        Item item = q.poll();
                        long min = Math.min(cap, item.cap);
                        long p = Math.max(0, item.sell - item.buy);
                        earn += min * p;
                        cap -= min;
                    }
                    best = Math.max(best, earn);
                }
            }
            out.println(best);
        }

        class Planet
        {
            long[] buy;
            long[] sell;
            long[] cap;

            public Planet(long[] buy, long[] sell, long[] cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

        }

        class Item implements Comparable<Item>
        {
            long buy;
            long sell;
            long cap;

            public Item(long buy, long sell, long cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

            public int compareTo(Item that)
            {
                double r1 = this.sell / (1.0 * this.buy);
                double r2 = that.sell / (1.0 * that.buy);
                return Double.compare(r2, r1);
            }

            public String toString()
            {
                return " Buy = " + buy + " Sell = " + sell + " Cap = " + cap;
            }

        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            int P = in.nextInt();
            int T = in.nextInt();
            int left = in.nextInt();
            Planet[] planets = new Planet[P];
            for (int i = 0; i < P; i++)
            {
                in.next();
                long[] buy = new long[T];
                long[] sell = new long[T];
                long[] cap = new long[T];
                for (int j = 0; j < T; j++)
                {
                    buy[j] = in.nextInt();
                    sell[j] = in.nextInt();
                    cap[j] = in.nextInt();
                }
                planets[i] = new Planet(buy, sell, cap);
            }
            long best = 0;
            for (int i = 0; i < P; i++)
            {
                for (int j = 0; j < P; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    PriorityQueue<Item> q = new PriorityQueue<>();
                    for (int k = 0; k < T; k++)
                    {
                        long b = planets[i].buy[k];
                        long s = planets[j].sell[k];
                        long c = planets[i].cap[k];
                        q.add(new Item(b, s, c));
                    }

                    long cap = left;
                    long earn = 0;
                    while (cap > 0 && !q.isEmpty())
                    {
                        Item item = q.poll();
                        long min = Math.min(cap, item.cap);
                        long p = Math.max(0, item.sell - item.buy);
                        if (p == 0)
                        {
                            continue;
                        }
                        earn += min * p;
                        cap -= min;
                    }
                    best = Math.max(best, earn);
                }
            }
            out.println(best);
        }

        class Planet
        {
            long[] buy;
            long[] sell;
            long[] cap;

            public Planet(long[] buy, long[] sell, long[] cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

        }

        class Item implements Comparable<Item>
        {
            long buy;
            long sell;
            long cap;

            public Item(long buy, long sell, long cap)
            {
                this.buy = buy;
                this.sell = sell;
                this.cap = cap;
            }

            public int compareTo(Item that)
            {
                double r1 = this.sell / (1.0 * this.buy);
                double r2 = that.sell / (1.0 * that.buy);
                return Double.compare(r2, r1);
            }

            public String toString()
            {
                return " Buy = " + buy + " Sell = " + sell + " Cap = " + cap;
            }

        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }
}

import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author codeKNIGHT
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n=in.nextInt(),m=in.nextInt(),k=in.nextInt(),i,j,x,y,max=0;
        String s;
        int a[][][]=new int[n][m][3];
        for(i=0;i<n;i++)
        {
            s=in.next();
            for(j=0;j<m;j++)
            {
                a[i][j][0]=in.nextInt();
                a[i][j][1]=in.nextInt();
                a[i][j][2]=in.nextInt();
            }
        }
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                if(i==j)
                    continue;
                items profit[]=new items[m];
                for(x=0;x<m;x++)
                {
                    profit[x]=new items(a[j][x][1]-a[i][x][0],x);
                }
                Arrays.sort(profit);

                int t=k,count=0,number;
                x=0;
                while(t>0&&x<m)
                {
                    number=Math.min(a[i][profit[x].index][2],t);
                    count+=profit[x].p*number;
                    x++;
                    t-=number;
                }
                if(count>max)
                    max=count;

            }
        }
        out.println(max);
	}
    class items implements Comparable<items>
    {
        int index,p;
        public items(int p,int index)
        {
            this.p=p;
            this.index=index;
        }
        public int compareTo(items a)
        {
            if(a.p>this.p)
                return 1;
            return -1;
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;

public class Main {

	public static class Goods{
		int[]buy = null;
		int[]sell = null;
		int[]rem = null;
		public Goods(int[]buyi, int[]selli, int[]remi){
			buy = buyi;
			sell = selli;
			rem = remi;
		}
		public Goods clone(){
			int[]buyi = new int[buy.length];
			int[]selli = new int[buy.length];
			int[]remi = new int[buy.length];
			for(int i = 0; i < buy.length; i++){
				buyi[i] = buy[i];
				selli[i] = sell[i];
				remi[i] = rem[i];
			}
			return new Goods(buyi, selli, remi);
		}
	}

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[]parts = br.readLine().split("\\s+");
		int n = Integer.parseInt(parts[0]);
		int m = Integer.parseInt(parts[1]);
		int k = Integer.parseInt(parts[2]);

		Map<Integer, Goods> map = new HashMap<Integer, Main.Goods>();
		for(int i = 0; i < n; i++){
			String name = br.readLine();
			int[]buy = new int[m];
			int[]sell = new int[m];
			int[]rem = new int[m];
			for(int j = 0; j < m; j++){
				parts = br.readLine().split("\\s+");
				buy[j] = Integer.parseInt(parts[0]);
				sell[j] = Integer.parseInt(parts[1]);
				rem[j] = Integer.parseInt(parts[2]);
			}
			Goods g = new Goods(buy, sell, rem);
			map.put(i, g);
		}
		int max = 0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(i == j)continue;
				Set<Integer> used = new HashSet<Integer>();
				int prods = k;
				Goods buyFrom = map.get(i).clone();
				Goods sellTo = map.get(j).clone();
				int profit = 0;
				while(prods>0&&used.size()!=m){
					int maxPrice = Integer.MIN_VALUE;
					int idx = -1;
					for(int l = 0; l < m; l++){
						if(used.contains(l))continue;
						if(maxPrice < sellTo.sell[l]-buyFrom.buy[l]){
							maxPrice = sellTo.sell[l]-buyFrom.buy[l];
							idx = l;
						}
					}
					int numToBuy = Math.min(buyFrom.rem[idx],prods);
					profit += numToBuy*maxPrice;
					buyFrom.rem[idx] -= numToBuy;
					if(buyFrom.rem[idx] == 0){
						used.add(idx);
					}
					prods -= numToBuy;
				}
				if(profit > max)max = profit;
			}
		}
		System.out.println(max);

	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Comparator;
import java.util.Hashtable;
import java.util.Vector;
import java.util.PriorityQueue;

public class Main {

    /**
     * @param args
     * @throws IOException
     */
    public static class Product{
        public int a;
        public int b;
        public int c;
        Product(int a,int b,int c){
            this.a=a;
            this.b=b;
            this.c=c;
        }
    }
    public static class Profit{
        public int dif;
        public int c;
        Profit(int d,int c){
            this.dif=d;
            this.c=c;
        }
    }
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        //Scanner in=new Scanner(System.in);
        PrintWriter out=new PrintWriter(System.out);
        String[] cur=in.readLine().split(" ");
        int n=Integer.parseInt(cur[0]);
        int m=Integer.parseInt(cur[1]);
        int k=Integer.parseInt(cur[2]);
        Vector<Vector<Product>> vect=new Vector<Vector<Product>>();
        Vector<String> names=new Vector<String>();
        for(int i=0; i<n; i++){
            names.add(in.readLine());
            vect.add(new Vector<Product>());
            for(int j=0; j<m; j++){
                String[] product=in.readLine().split(" ");
                vect.get(i).add(new Product(Integer.parseInt(product[0]),Integer.parseInt(product[1]),Integer.parseInt(product[2])));
            }
        }
        long maxProfit=0;
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                Vector<Product> f=vect.get(i);
                Vector<Product> s=vect.get(j);
                PriorityQueue<Profit> ch=new PriorityQueue<Profit>(m,new Comparator<Profit>(){
                    public int compare(Profit a,Profit b){
                        if(a.dif>b.dif) return -1;
                        else if(a.dif<b.dif) return 1;
                        return 0;
                    }
                });
                for(int z=0; z<m; z++){
                    ch.add(new Profit(s.get(z).b-f.get(z).a,f.get(z).c));

                }
                int curK=k;
                int curProfit=0;
                while(curK>0 && !ch.isEmpty()){
                    Profit curProf=ch.poll();
                    int step=Math.min(curK,curProf.c);
                    if(curProf.dif>0) curProfit+=step*curProf.dif;
                    else break;
                    curK-=curProf.c;
                }
                if(curProfit>maxProfit) maxProfit=curProfit;
            }
        }
        out.println(maxProfit);
        out.close();
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Comparator;
import java.util.Hashtable;
import java.util.Vector;
import java.util.PriorityQueue;

public class Main {

    /**
     * @param args
     * @throws IOException
     */
    public static class Product{
        public int a;
        public int b;
        public int c;
        Product(int a,int b,int c){
            this.a=a;
            this.b=b;
            this.c=c;
        }
    }
    public static class Profit{
        public int dif;
        public int c;
        Profit(int d,int c){
            this.dif=d;
            this.c=c;
        }
    }
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        //Scanner in=new Scanner(System.in);
        PrintWriter out=new PrintWriter(System.out);
        String[] cur=in.readLine().split(" ");
        int n=Integer.parseInt(cur[0]);
        int m=Integer.parseInt(cur[1]);
        int k=Integer.parseInt(cur[2]);
        Vector<Vector<Product>> vect=new Vector<Vector<Product>>();
        Vector<String> names=new Vector<String>();
        for(int i=0; i<n; i++){
            names.add(in.readLine());
            vect.add(new Vector<Product>());
            for(int j=0; j<m; j++){
                String[] product=in.readLine().split(" ");
                vect.get(i).add(new Product(Integer.parseInt(product[0]),Integer.parseInt(product[1]),Integer.parseInt(product[2])));
            }
        }
        long maxProfit=0;
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                Vector<Product> f=vect.get(i);
                Vector<Product> s=vect.get(j);
                PriorityQueue<Profit> ch=new PriorityQueue<Profit>(m,new Comparator<Profit>(){
                    public int compare(Profit a,Profit b){
                        if(a.dif>b.dif) return -1;
                        else if(a.dif<b.dif) return 1;
                        return 0;
                    }
                });
                for(int z=0; z<m; z++){
                    ch.add(new Profit(s.get(z).b-f.get(z).a,f.get(z).c));

                }
                int curK=k;
                int curProfit=0;
                while(k>0 && !ch.isEmpty()){
                    Profit curProf=ch.poll();
                    int step=Math.min(curK,curProf.c);
                    if(curProf.dif>0) curProfit+=step*curProf.dif;
                    else break;
                    curK-=curProf.c;
                }
                if(curProfit>maxProfit) maxProfit=curProfit;
            }
        }
        out.println(maxProfit);
        out.close();
    }

}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main
{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer tokenizer=null;

	public static void main(String[] args) throws IOException
	{
		new Main().execute();
	}

	void debug(Object...os)
	{
		System.out.println(Arrays.deepToString(os));
	}

	int ni() throws IOException
	{
		return Integer.parseInt(ns());
	}

	long nl() throws IOException
	{
		return Long.parseLong(ns());
	}

	double nd() throws IOException
	{
		return Double.parseDouble(ns());
	}

	String ns() throws IOException
	{
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(br.readLine());
		return tokenizer.nextToken();
	}

	String nline() throws IOException
	{
		tokenizer=null;
		return br.readLine();
	}

	//Main Code starts Here
	int totalCases, testNum;
	int m,n,k;

	void execute() throws IOException
	{
		totalCases = 1;
		for(testNum = 1; testNum <= totalCases; testNum++)
		{
			input();
			solve();
		}
	}

	void solve()
	{
		//debug("k",k);
		long best=Long.MIN_VALUE;
		for(int i = 0;i<n;i++)
			for(int j =0;j<n;j++)
			{
				if(i==j)
					continue;
				Pair[] diff = new Pair[m];
				for(int r =0;r<m;r++)
				{
					int temp = arr[j][r][1]-arr[i][r][0];
					diff[r] = new Pair(temp,r);
				}
				Arrays.sort(diff);
				long profit = 0;
				int index = 0;
				int l = k;
				while(l>0 && index<m)
				{
					int max = arr[i][diff[index].b][2];
					int pr = diff[index].a;
					profit+=pr*Math.min(l,max);
					l = l-Math.min(l,max);
					if(l>0)
						index++;
				}
				//debug(i,j,profit,diff);
				best = Math.max(best,profit);
			}
		System.out.println(best);
	}

	void printarr(int [] a,int b)
	{
		for(int i = 0;i<=b;i++)
		{
			if(i==0)
				System.out.print(a[i]);
			else
				System.out.print(" "+a[i]);
		}
		System.out.println();
	}
	int[][][] arr;

	class Pair implements Comparable<Pair>
	{
		int a,b;
		Pair(int _a,int _b)
		{
			a=_a;
			b=_b;
		}

		public int compareTo(Pair x)
		{
			if(a == x.a) return b-x.b;
			return -(a-x.a);
		}

		public boolean equals(Pair x)
		{
			return (a==x.a && b==x.b);
		}

		public String toString()
		{
			return "("+a+","+b+")";
		}
	}

	boolean input() throws IOException
	{
		n = ni();
		m = ni();
		k = ni();
		arr = new int[n][m][3];

		for(int i = 0 ;i<n;i++)
		{
			nline();
			for(int j = 0 ;j<m;j++)
			{
					arr[i][j][0]=ni();
					arr[i][j][1]=ni();
					arr[i][j][2]=ni();
			}
		}
		//debug(arr);
		return true;
	}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main
{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer tokenizer=null;

	public static void main(String[] args) throws IOException
	{
		new Main().execute();
	}

	void debug(Object...os)
	{
		System.out.println(Arrays.deepToString(os));
	}

	int ni() throws IOException
	{
		return Integer.parseInt(ns());
	}

	long nl() throws IOException
	{
		return Long.parseLong(ns());
	}

	double nd() throws IOException
	{
		return Double.parseDouble(ns());
	}

	String ns() throws IOException
	{
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(br.readLine());
		return tokenizer.nextToken();
	}

	String nline() throws IOException
	{
		tokenizer=null;
		return br.readLine();
	}

	//Main Code starts Here
	int totalCases, testNum;
	int m,n,k;

	void execute() throws IOException
	{
		totalCases = 1;
		for(testNum = 1; testNum <= totalCases; testNum++)
		{
			input();
			solve();
		}
	}

	void solve()
	{
		//debug("k",k);
		long best=Long.MIN_VALUE;
		for(int i = 0;i<n;i++)
			for(int j =0;j<n;j++)
			{
				if(i==j)
					continue;
				Pair[] diff = new Pair[m];
				for(int r =0;r<m;r++)
				{
					int temp = arr[j][r][1]-arr[i][r][0];
					diff[r] = new Pair(temp,r);
				}
				Arrays.sort(diff);
				long profit = 0;
				int index = 0;
				int l = k;
				while(l>0 && index<m)
				{
					int max = arr[i][diff[index].b][2];
					int pr = diff[index].a;
					profit+=pr*Math.min(l,max);
					l = l-Math.min(l,max);
					if(l>0)
						index++;
				}
				//debug(i,j,profit,diff);
				best = Math.max(best,profit);
			}
		System.out.println(Math.max(0,best));
	}

	void printarr(int [] a,int b)
	{
		for(int i = 0;i<=b;i++)
		{
			if(i==0)
				System.out.print(a[i]);
			else
				System.out.print(" "+a[i]);
		}
		System.out.println();
	}
	int[][][] arr;

	class Pair implements Comparable<Pair>
	{
		int a,b;
		Pair(int _a,int _b)
		{
			a=_a;
			b=_b;
		}

		public int compareTo(Pair x)
		{
			if(a == x.a) return b-x.b;
			return -(a-x.a);
		}

		public boolean equals(Pair x)
		{
			return (a==x.a && b==x.b);
		}

		public String toString()
		{
			return "("+a+","+b+")";
		}
	}

	boolean input() throws IOException
	{
		n = ni();
		m = ni();
		k = ni();
		arr = new int[n][m][3];

		for(int i = 0 ;i<n;i++)
		{
			nline();
			for(int j = 0 ;j<m;j++)
			{
					arr[i][j][0]=ni();
					arr[i][j][1]=ni();
					arr[i][j][2]=ni();
			}
		}
		//debug(arr);
		return true;
	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 *
 */

/**
 * @author antonio081014
 * @time: Apr 20, 2012, 9:26:07 AM
 */
public class C {

    public static void main(String[] args) throws Exception {
	C main = new C();
	main.run();
	System.exit(0);

    }

    public void run() throws Exception {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] str = br.readLine().split("\\s");
	int n = Integer.parseInt(str[0]);
	int m = Integer.parseInt(str[1]);
	int k = Integer.parseInt(str[2]);

	int[][][] planet = new int[n][m][3];
	for (int i = 0; i < n; i++) {
	    br.readLine();
	    for (int j = 0; j < m; j++) {
		str = br.readLine().split("\\s");
		planet[i][j][0] = Integer.parseInt(str[0]);
		planet[i][j][1] = Integer.parseInt(str[1]);
		planet[i][j][2] = Integer.parseInt(str[2]);
	    }
	}

	int max = 0;
	for (int i = 0; i < n; i++) {
	    for (int j = 0; j < n; j++) {
		List<Item> list = new ArrayList<Item>();
		for (int p = 0; p < m; p++) {
		    list.add(new Item(planet[i][p][0] - planet[j][p][1],
			    planet[i][p][2]));
		}
		Collections.sort(list);
		int left = k;
		int sum = 0;
		for (int p = 0; p < m; p++) {
		    if (left > list.get(p).amount) {
			sum += -list.get(p).price * list.get(p).amount;
			left -= list.get(p).amount;
		    } else if (left != 0) {
			sum += -list.get(p).price * left;
			left = 0;
			break;
		    }
		}
		max = Math.max(max, sum);
	    }
	}
	System.out.println(max);
    }
}

class Item implements Comparable<Item> {
    public int price;
    public int amount;

    public Item(int b, int s) {
	this.price = b;
	this.amount = s;
    }

    public int compareTo(Item item) {
	// if (this.price != item.price)
	return this.price - item.price;
	// return this.amount - item.amount;
    }
}

import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int k = scanner.nextInt();

        int[][] a = new int[n][m];
        int[][] b = new int[n][m];
        int[][] c = new int[n][m];

        int ans = 0;
        for(int i = 0; i < n; i++) {
            scanner.nextLine();
            String name = scanner.nextLine();
            for(int j = 0; j < m; j++) {
                a[i][j] = scanner.nextInt();
                b[i][j] = scanner.nextInt();
                c[i][j] = scanner.nextInt();
            }
        }

        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                int buy = 0;
                int sell = 0;
                int cnt = k;
                Queue<Node> priorityQueue = new PriorityQueue<>(new Comparator<Node>() {
                    @Override
                    public int compare(Node o1, Node o2) {
                        return o2.value - o1.value;
                    }
                });

                for(int z = 0; z < m; z++) {
                    priorityQueue.offer(new Node(z, b[j][z] - a[i][z]));
                }

                while(cnt > 0 && !priorityQueue.isEmpty()) {
                    Node node = priorityQueue.poll();
                    if (c[i][node.id] <= cnt) {
                        buy += a[i][node.id] * c[i][node.id];
                        sell += b[j][node.id] * c[i][node.id];
                        cnt -= c[i][node.id];
                    } else {
                        buy += a[i][node.id] * cnt;
                        sell += b[j][node.id] * cnt;
                        cnt = 0;
                    }
                }
                ans = Math.max(ans, sell - buy);
            }
        }
        System.out.println(ans);
    }

    static class Node {
        int id;
        int value;

        public Node(int id, int value) {
            this.id = id;
            this.value = value;
        }
    }
}

import java.lang.reflect.Array;
import java.util.*;

public class Main {
    private static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {

        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();

        List<Al> alList = new ArrayList<>();

        for(int i = 0; i < n; i++){
            String s = in.next();
            Al al = new Al(s);
            for(int j = 0; j < m; j++){
                int num1 = in.nextInt();
                int num2 = in.nextInt();
                int num3 = in.nextInt();
                al.list.add(new A(num1,num2,num3));
            }
            alList.add(al);
        }

        Vector<Integer> vector1 = new Vector<>();

        for(int i = 0; i < n; i++){
            Al ali = alList.get(i);
            for(int j = 0; j < n; j++){
                Al alj = alList.get(j);
                vector1.add(ali.getPrice(alj,k));
            }
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            ans = Math.max(ans,vector1.get(i));
        }
        System.out.println(ans);
    }
}

class A{

    int ip;
    int np;
    int w;

    public A( int ip, int np,int w) {
        this.w = w;
        this.ip = ip;
        this.np = np;
    }

}

class C implements Comparable{
    int dp;
    int index;

    public int getDp() {
        return dp;
    }

    public void setDp(int dp) {
        this.dp = dp;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    @Override
    public String toString() {
        return "C{" +
                "dp=" + dp +
                ", index=" + index +
                '}';
    }

    @Override
    public int compareTo(Object o) {
        C c = (C) o;
        if(this.dp > c.dp){
            return -1;
        }else if(this.dp < c.dp){
            return 1;
        }else
            return 0;
    }
}

class Al{
    String ALName;
    List<A> list = new ArrayList<>();

    public Al(String ALName) {
        this.ALName = ALName;
    }

    public Al(String ALName, List<A> list) {
        this.list = list;
        this.ALName = ALName;
    }

    public String getALName() {
        return ALName;
    }

    public void setALName(String ALName) {
        this.ALName = ALName;
    }

    public List<A> getList() {
        return list;
    }

    public void setList(List<A> list) {
        this.list = list;
    }

    public int getPrice(Al al,int k){
//        System.out.println("11111");
        int len = al.list.size();
        Vector<C> cs = new Vector<>();
        for(int i = 0; i < len;i++){
            C c = new C();
            c.dp = al.list.get(i).np - this.list.get(i).ip;
            c.index = i;
            cs.add(c);
        }

        Collections.sort(cs);

        int j = 0;
        int ans = 0;
        while (k > 0 && j < cs.size()){
            if(cs.get(j).dp > 0){
                if(k < this.list.get(cs.get(j).index).w){
                    ans = ans + cs.get(j).dp * k;
                    k =0;
                }else{
                    ans = ans + cs.get(j).dp * this.list.get(cs.get(j).index).w;
                    k -= this.list.get(cs.get(j).index).w;
                }
            }
            j++;
        }

        return ans;
    }
}

import java.util.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  test  {

	//ArrayList<Integer> lis = new ArrayList<Integer>();
	//ArrayList<String> lis = new ArrayList<String>();
	//ArrayList<test> lis = new ArrayList<test>();
//	static long sum=0;
	int a,b,c;

public  static void main(String[] args) {
   Scanner sc =new Scanner(System.in);
   while(sc.hasNext()){
		 // =ni(sc)
	   long sum=0;
	 //  int d=sc.nextInt(),m=sc.nextInt(),pr=d;
	   int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt();
	  test x[][]=new test[n][m];
	  for(int i=0 ; i<n ; i++){
		  sc.next();
		  for(int t=0 ; t<m ; t++){

		  x[i][t] = new test();
		  x[i][t].a=sc.nextInt();
		  x[i][t].b=sc.nextInt();
		  x[i][t].c=sc.nextInt();}

	  }

	   for(int i=0 ; i<n ; i++){
		   for(int t=i+1 ; t<n ; t++){
			   PriorityQueue<pair> que = new PriorityQueue<pair>();

			   for(int u=0;u<m;u++){
				   que.add( new pair(x[t][u].b-x[i][u].a , x[i][u].c) );
				  // db(que.peek().v);
			   }
			   int f=0,s=0;
			 //  db(sum);
			   while(f<k && que.size()!=0){
				 pair te = que.poll();
				 int y = te.v;
			//	 db(f,y,te.vv);
				 if(y<=0 )continue;
				 if( te.vv==0 )continue;
				 s+=y;
				 f++;
				 que.add( new pair(y , te.vv-1 ) );
			   }
			   sum=max(sum,s);

		   }
	   }

	 	 System.out.println(sum);

   }
}

    static void db(Object... os){
	         System.err.println(Arrays.deepToString(os));

	}

}

class pair implements Comparable<pair>{
    int v,vv;
	pair(int v,int vv){
		this.v=v;
	    this.vv=vv;
	}

public int compareTo(pair x){
	 return x.v-v;
}

}

import java.util.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  test  {

	//ArrayList<Integer> lis = new ArrayList<Integer>();
	//ArrayList<String> lis = new ArrayList<String>();
	//ArrayList<test> lis = new ArrayList<test>();
//	static long sum=0;
	int a,b,c;

public  static void main(String[] args) {
   Scanner sc =new Scanner(System.in);
   while(sc.hasNext()){
		 // =ni(sc)
	   long sum=0;
	 //  int d=sc.nextInt(),m=sc.nextInt(),pr=d;
	   int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt();
	  test x[][]=new test[n][m];
	  for(int i=0 ; i<n ; i++){
		  sc.next();
		  for(int t=0 ; t<m ; t++){

		  x[i][t] = new test();
		  x[i][t].a=sc.nextInt();
		  x[i][t].b=sc.nextInt();
		  x[i][t].c=sc.nextInt();}

	  }

	   for(int i=0 ; i<n ; i++){
		   for(int t=i+1 ; t<n ; t++){
			   PriorityQueue<pair> que = new PriorityQueue<pair>();

			   for(int u=0;u<m;u++){
				   que.add( new pair(x[t][u].b-x[i][u].a , x[i][u].c) );
				  // db(que.peek().v);
			   }
			   int f=0,s=0;
			 //  db(sum);
			   while(f<k && que.size()!=0){
				 pair te = que.poll();
				 int y = te.v;
			//	 db(f,y,te.vv);
				 if(y<=0 )break;
				 if( te.vv==0 )continue;
				 s+=y;
				 f++;
				 que.add( new pair(y , te.vv-1 ) );
			   }
			   sum=max(sum,s);

		   }
	   }

	 	 System.out.println(sum);

   }
}

    static void db(Object... os){
	         System.err.println(Arrays.deepToString(os));

	}

}

class pair implements Comparable<pair>{
    int v,vv;
	pair(int v,int vv){
		this.v=v;
	    this.vv=vv;
	}

public int compareTo(pair x){
	 return x.v-v;
}

}

import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

	int [][] a, b, c;

	public void solve () throws Exception {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		a = new int [n][m];
		b = new int [n][m];
		c = new int [n][m];
		for (int i = 0; i < n; i++) {
			String s = in.readLine();
			for (int j = 0; j < m; j++) {
				a [i][j] = nextInt();
				b [i][j] = nextInt();
				c [i][j] = nextInt();
			}
		}
		int sum = 0;
		while (k > 0) {
			int add = -1;
			int pi = -1, pj = -1, t = -1;
			for (int type = 0; type < m; type++) {
				for (int i = 0; i < n; i++) {
					if (c[i][type] > 0) {
						for (int j = i + 1; j < n; j++) {
							if (b[j][type] - a[i][type] > add) {
								add = b[j][type] - a[i][type];
								pi = i;
								pj = j;
								t = type;
							}
						}
					}
				}
			}
			if (add <= 0) break;
			sum += add;
			c[pi][t] --;
			k --;
		}
		out.println(sum);
	}

	static final String fname = "";
	long stime = 0;

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	private String nextToken () throws Exception {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	private int nextInt () throws Exception {
		return Integer.parseInt(nextToken());
	}

	private long nextLong () throws Exception {
		return Long.parseLong(nextToken());
	}

	private double nextDouble () throws Exception {
		return Double.parseDouble(nextToken());
	}

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve ();
		} catch (Exception e) {
			throw new RuntimeException(e);
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Solution(), "", 1<<25).start();
	}

}

import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

	int [][] a, b, c;

	public void solve () throws Exception {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		a = new int [n][m];
		b = new int [n][m];
		c = new int [n][m];
		for (int i = 0; i < n; i++) {
			String s = in.readLine();
			for (int j = 0; j < m; j++) {
				a [i][j] = nextInt();
				b [i][j] = nextInt();
				c [i][j] = nextInt();
			}
		}
		int sum = 0;
		int add = -1;
		for (int i = 0; i < n; i++) {
			int all = 0;
			for (int j = 0; j < n; j++) {
				if (i != j) {
					boolean used [] = new boolean [m];
					int capacity = k;
					while (capacity > 0) {
						int bestdiff = -1;
						int t = -1;
						for (int type = 0; type < m; type++) {
							if (!used[type] && c[i][type] > 0 && b[j][type] > a[i][type]) {
								if (b[j][type] - a[i][type] > bestdiff) {
									bestdiff = b[j][type] - a[i][type];
									t = type;
								}
							}
						}
						if (bestdiff <= 0) break;
						if (bestdiff > 0 && capacity > 0) {
							all += bestdiff * min (capacity, c[i][t]);
							used [t] = true;
							capacity -= min (capacity, c[i][t]);
						}
					}
				}
			}
			if (all > add) {
				add = all;
			}
		}
		if (add > 0) {
			sum += add;
		}
		out.println(sum);
	}

	static final String fname = "";
	long stime = 0;

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	private String nextToken () throws Exception {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	private int nextInt () throws Exception {
		return Integer.parseInt(nextToken());
	}

	private long nextLong () throws Exception {
		return Long.parseLong(nextToken());
	}

	private double nextDouble () throws Exception {
		return Double.parseDouble(nextToken());
	}

	@Override
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve ();
		} catch (Exception e) {
			throw new RuntimeException(e);
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Solution(), "", 1<<25).start();
	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Comparator;

public class A176 {

    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(System.out);

    static int nextInt() throws Exception {
        in.nextToken();
        return (int)in.nval;
    }

    static String nextString() throws Exception {
        in.nextToken();
        return in.sval;
    }

    public static void main(String[] args) throws Exception {
        int n = nextInt(), m = nextInt(), k = nextInt();
        int[][] a = new int[n][m];
        int[][] b = new int[n][m];
        int[][] c = new int[n][m];
        for (int i = 0; i < n; i++) {
            nextString();
            for (int j = 0; j < m; j++) {
                a[i][j] = nextInt();
                b[i][j] = nextInt();
                c[i][j] = nextInt();
            }
        }

        int ans = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++) if (i != j) {
                int[][] p = new int[m][2];
                for (int r = 0; r < m; r++) {
                    p[r][0] = b[j][r] - a[i][r];
                    p[r][1] = r;
                }
                Arrays.sort(p, new Comparator<int[]>(){
                    public int compare(int[] a, int[] b) {
                        return b[0] - a[0];
                    }
                });
                int cur = 0, x = k, w = 0;
                while (x > 0 && w < m) {
                    int q = Math.min(x, c[i][p[w][1]]);
                    cur += q*p[w][0];
                    x -= q;
                    w++;
                }
                if (cur > ans) ans = cur;
            }

        out.println(ans);
        out.flush();
    }

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Comparator;

public class A176 {

    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(System.out);

    static int nextInt() throws Exception {
        in.nextToken();
        return (int)in.nval;
    }

    static String nextString() throws Exception {
        in.nextToken();
        return in.sval;
    }

    public static void main(String[] args) throws Exception {
        int n = nextInt(), m = nextInt(), k = nextInt();
        int[][] a = new int[n][m];
        int[][] b = new int[n][m];
        int[][] c = new int[n][m];
        for (int i = 0; i < n; i++) {
            nextString();
            for (int j = 0; j < m; j++) {
                a[i][j] = nextInt();
                b[i][j] = nextInt();
                c[i][j] = nextInt();
            }
        }

        int ans = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++) {
                int[][] p = new int[m][2];
                for (int r = 0; r < m; r++) {
                    p[r][0] = b[i][r] - a[j][r];
                    p[r][1] = r;
                }
                Arrays.sort(p, new Comparator<int[]>(){
                    public int compare(int[] a, int[] b) {
                        return b[0] - a[0];
                    }
                });
                int cur = 0, x = k, w = 0;
                while (x > 0 && w < m) {
                    int q = Math.min(x, c[j][p[w][1]]);
                    cur += q*p[w][0];
                    x -= q;
                    w++;
                }
                if (cur > ans) ans = cur;
            }

        out.println(ans);
        out.flush();
    }

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Comparator;

public class A176 {

    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(System.out);

    static int nextInt() throws Exception {
        in.nextToken();
        return (int)in.nval;
    }

    static String nextString() throws Exception {
        in.nextToken();
        return in.sval;
    }

    public static void main(String[] args) throws Exception {
        int n = nextInt(), m = nextInt(), k = nextInt();
        int[][] a = new int[n][m];
        int[][] b = new int[n][m];
        int[][] c = new int[n][m];
        for (int i = 0; i < n; i++) {
            nextString();
            for (int j = 0; j < m; j++) {
                a[i][j] = nextInt();
                b[i][j] = nextInt();
                c[i][j] = nextInt();
            }
        }

        int ans = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++) {
                int[][] p = new int[m][2];
                for (int r = 0; r < m; r++) {
                    p[r][0] = b[j][r] - a[i][r];
                    p[r][1] = r;
                }
                Arrays.sort(p, new Comparator<int[]>(){
                    public int compare(int[] a, int[] b) {
                        return b[0] - a[0];
                    }
                });
                int cur = 0, x = k, w = 0;
                while (x > 0 && w < m) {
                    int q = Math.min(x, c[i][p[w][1]]);
                    cur += q*p[w][0];
                    x -= q;
                    w++;
                }
                if (cur > ans) ans = cur;
            }

        out.println(ans);
        out.flush();
    }

}

import java.io.*;
import java.util.*;

public class Main implements Runnable {

    public void _main() throws Exception {
	int n = nextInt();
	int m = nextInt();
	int k = nextInt();
	int[][] a = new int[n][m];
	int[][] b = new int[n][m];
	int[][] c = new int[n][m];
	for (int i = 0; i < n; i++) {
	    next();
	    for (int j = 0; j < m; j++) {
		a[i][j] = nextInt();
		b[i][j] = nextInt();
		c[i][j] = nextInt();
	    }
	}
	int res = 0;
	for (int from = 0; from < n; from++) {
	    for (int to = 0; to < n; to++) {
		if (from == to) continue;
		Goods[] g = new Goods[m];
		for (int i = 0; i < m; i++) {
		    int cost = -a[from][i] + b[to][i];
		    int am = c[from][i];
		    g[i] = new Goods(cost, am);
		}
		Arrays.sort(g);
		int space = k;
		int cur = 0;
		for (int i = 0; i < m; i++) {
		    int take = Math.min(g[i].am, space);
		    cur += take * g[i].cost;
		    space -= take;
		}
		res = Math.max(res, cur);
	    }
	}
	out.println(res);
    }

    class Goods implements Comparable<Goods> {
	int cost;
	int am;

	public Goods(int cost, int am) {
	    this.cost = cost;
	    this.am = am;
	}

	public int compareTo(Goods o) {
	    if (cost != o.cost) {
		return cost > o.cost ? -1 : 1;
	    }
	    return am - o.am;
	}
    }

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer st;

    private String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String rl = in.readLine();
            if (rl == null) return null;
            st = new StringTokenizer(rl);
        }
        return st.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            _main();

            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(202);
        }
    }

    public static void main(String[] args) {
        new Thread(new Main()).run();
    }

}

import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;

public class A {

        final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null;
        BufferedReader in;
        PrintWriter out;
        StringTokenizer tok = new StringTokenizer("");

        void init() throws FileNotFoundException{
                if (ONLINE_JUDGE){
                        in = new BufferedReader(new InputStreamReader(System.in));
                        out = new PrintWriter(System.out);
                }else{
                        in = new BufferedReader(new FileReader("input.txt"));
                        out = new PrintWriter("output.txt");
                }
        }

        String readString() throws IOException{
                while(!tok.hasMoreTokens()){
                        tok = new StringTokenizer(in.readLine());
                }
                return tok.nextToken();
        }

        int readInt() throws IOException{
                return Integer.parseInt(readString());
        }

        long readLong() throws IOException{
                return Long.parseLong(readString());
        }

        double readDouble() throws IOException{
                return Double.parseDouble(readString());
        }

        int[] readArr(int n) throws IOException{
        	int[] res = new int[n];
        	for(int i = 0; i < n; i++){
        		res[i] = readInt();
        	}
        	return res;
        }

        long[] readArrL(int n) throws IOException{
        	long[] res = new long[n];
        	for(int i = 0; i < n; i++){
        		res[i] = readLong();
        	}
        	return res;
        }

        public static void main(String[] args){
                new A().run();
        }

        public void run(){
                try{
                        long t1 = System.currentTimeMillis();
                        init();
                        solve();
                        out.close();
                        long t2 = System.currentTimeMillis();
                        System.err.println("Time = "+(t2-t1));
                }catch (Exception e){
                        e.printStackTrace(System.err);
                        System.exit(-1);
                }
        }

        void solve() throws IOException{
        	int n = readInt();
        	int m = readInt();
        	int k = readInt();
        	int[][] a = new int[n][m];

        	int[][] b = new int[n][m];

        	int[][] c = new int[n][m];

        	for(int i = 0; i < n; i++){
        		String s = readString();
        		for(int j = 0; j < m; j++){
        			a[i][j] = readInt();
        			b[i][j] = readInt();
        			c[i][j] = readInt();
        		}
        	}
        	int max = 0;
        	for(int i = 0; i < n; i++){
        		for(int j = 0; j < n; j++){
        			if(i == j) continue;
        			Point[] cur = new Point[m];
        			for(int l = 0; l < m; l++){
        				cur[l] = new Point(-a[i][l] + b[j][l], l);
        			}
        			Arrays.sort(cur, new Comparator<Point>() {

						@Override
						public int compare(Point o1, Point o2) {
							return -o1.x + o2.x;
						}

					});

        			int curK = k;
        			int curSum = 0;
        			int i1 = 0;
        			while(curK > 0 && i1 < m){
        				if(curK >= c[i][cur[i1].y]){
        					curK -= c[i][cur[i1].y];
        					curSum += c[i][cur[i1].y] * cur[i1].x;
        					i1++;
        				}
        				else{
        					curSum += curK * cur[i1].x;
        					curK = 0;
        				}
        			}
        			if(curSum > max) max = curSum;
        		}
        	}
        	out.println(max);
        }

        void maxHepify(int[] a, int i, int length){
        	int l = (i<<1) + 1;
        	int r = (i<<1) + 2;
        	int largest = i;
        	if(l < length && a[l] > a[largest])
        		largest = l;
        	if(r < length && a[r] > a[largest])
        		largest = r;
        	if(largest != i){
        		a[largest] += a[i];
        		a[i] = a[largest] - a[i];
        		a[largest] -= a[i];
        		maxHepify(a, largest, length);
        	}
        }

        void buildMaxHeap(int[] a){
        	for(int i = a.length/2 - 1; i >= 0; i--){
        		maxHepify(a, i, a.length);
        	}
        }

        void heapSort(int[] a){
        	buildMaxHeap(a);
        	for(int i = a.length - 1; i > 0; i--){
        		a[i] += a[0];
        		a[0] = a[i] - a[0];
        		a[i] -= a[0];
        		maxHepify(a, 0, i);
        	}
        }

        int[] zFunction(char[] s){
        	int[] z = new int[s.length];
        	z[0] = 0;
        	for (int i=1, l=0, r=0; i<s.length; ++i) {
        		if (i <= r)
        			z[i] = min (r-i+1, z[i-l]);
        		while (i+z[i] < s.length && s[z[i]] == s[i+z[i]])
        			++z[i];
        		if (i+z[i]-1 > r){
        			l = i;
        			r = i+z[i]-1;
        		}
        	}
        	return z;
        }

        int[] prefixFunction(char[] s){
        	int[] pr = new int[s.length];
        	for (int i = 1; i< s.length; ++i) {
        		int j = pr[i-1];
        		while (j > 0 && s[i] != s[j])
        			j = pr[j-1];
        		if (s[i] == s[j])  ++j;
        		pr[i] = j;
        	}
        	return pr;
        }

        int ModExp(int a, int n, int mod){
        	int res = 1;
        	while (n!=0)
        		if ((n & 1) != 0) {
        			res = (res*a)%mod;
        			--n;
        		}
        		else {
        			a = (a*a)%mod;
        			n >>= 1;
        		}
        	return res;
        }

        public static class Utils {

        	private Utils() {}

        	public static void mergeSort(int[] a) {
                    mergeSort(a, 0, a.length - 1);
            }

        	private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
                    final int MAGIC_VALUE = 50;
                    if (leftIndex < rightIndex) {
                            if (rightIndex - leftIndex <= MAGIC_VALUE) {
                                    insertionSort(a, leftIndex, rightIndex);
                            } else {
                                    int middleIndex = (leftIndex + rightIndex) / 2;
                                    mergeSort(a, leftIndex, middleIndex);
                                    mergeSort(a, middleIndex + 1, rightIndex);
                                    merge(a, leftIndex, middleIndex, rightIndex);
                            }
                    }
            }

            private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
            	int length1 = middleIndex - leftIndex + 1;
            	int length2 = rightIndex - middleIndex;
                int[] leftArray = new int[length1];
                int[] rightArray = new int[length2];
                System.arraycopy(a, leftIndex, leftArray, 0, length1);
                System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
                for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
                    if (i == length1) {
                            a[k] = rightArray[j++];
                    } else if (j == length2) {
                            a[k] = leftArray[i++];
                    } else {
                            a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
                    }
                }
            }

            private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
                for (int i = leftIndex + 1; i <= rightIndex; i++) {
            		int current = a[i];
                    int j = i - 1;
                	while (j >= leftIndex && a[j] > current) {
                        a[j + 1] = a[j];
                        j--;
                        }
                    a[j + 1] = current;
                }
            }
        }

        boolean isPrime(int a){
        	for(int i = 2; i <= sqrt(a); i++)
        		if(a % i == 0) return false;
        	return true;
        }

        static double distance(long x1, long y1, long x2, long y2){
        	return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        }

        static long gcd(long a, long b){
        	if(min(a,b) == 0) return max(a,b);
        	return gcd(max(a, b) % min(a,b), min(a,b));
        }

        static long lcm(long a, long b){
        	return a * b /gcd(a, b);
        }
}

/*class Treap<K extends Comparable<K>>{

	public K x;
	public double y;
	public Treap<K> left;
	public Treap<K> right;

	public Treap(K x, double y, Treap<K> left, Treap<K> right) {
		this.x = x;
		this.y = y;
		this.left = left;
		this.right = right;
	}

	public static <K extends Comparable<K>> Treap<K> merge(Treap<K> l, Treap<K> r){
		if(l == null) return r;
		if(r == null) return l;
		if(l.y > r.y){
			return new Treap<K>(l.x, l.y, l.left, merge(l.right, r));
		}
		else{
			return new Treap<K>(r.x, r.y, merge(l, r.left), r.right);
		}
	}

	public void split(K x, Treap<K> left, Treap<K> right){
		Treap<K> newTreap = null;
		if(this.x.compareTo(x) <= 0){
			if(this.right == null){
				right = null;
			}
			else{
				right.split(x, newTreap, right);
			}
			left = new Treap<K>(this.x, this.y, left, newTreap);
		}
		else{
			if(this.left == null){
				left = null;
			}
			else{
				left.split(x, left, newTreap);
			}
			right = new Treap<K>(x, y, newTreap, right);
		}
	}

	public Treap<K> add(K x){
		Treap<K> left = null, right = null;
		this.split(x, left, right);
		Treap<K> temp = new Treap<K>(x, random(), null, null);
		return merge(merge(left, temp), right);
	}

	@SuppressWarnings("null")
	public Treap<K> remove(K x){
		Treap<K> left = null, temp = null, right = null;
		this.split(x, left, right);
		right.split(x, temp, right);
		return merge(left, right);
	}

	public static <K extends Comparable<K>> Treap<K> build(K[] a){
		Treap<K> temp = new Treap<K>(a[0], random(), null, null);
		for(int i = 1; i < a.length; i++){
			temp = temp.add(a[i]);
		}
		return temp;
	}
}*/

import java.io.*;
import java.util.*;

public class taskA {

	PrintWriter out;
	BufferedReader br;
	StringTokenizer st;

	String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		long[][] a = new long[n][m];
		long[][] b = new long[n][m];
		long[][] c = new long[n][m];
		for (int i = 0; i < n; i++) {
			String s = nextToken();
			for (int j = 0; j < m; j++) {
				a[i][j] = nextInt();
				b[i][j] = nextInt();
				c[i][j] = nextInt();
			}
		}
		long ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (i == j)
					continue;
				int l = k;
				boolean[] was = new boolean[m];
				int max = 0;
				long profit = 0;
				while ((l > 0)) {
					for (int t = 0; t <  m; t++) {
						if ((!was[t]) && ((b[j][t] - a[i][t] > b[j][max] - a[i][max]) || (was[max])))
							max = t;
					}
					if (was[max])
						break;
					if (b[j][max] - a[i][max] <= 0)
						break;
					profit += Math.min(l, c[i][max]) * (b[j][max] - a[i][max]);
					was[max] = true;
					l -= Math.min(l, c[i][max]);

				}
				if (profit > ans)
					ans = profit;
			}
		}
		out.println(ans);

	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			//br = new BufferedReader(new FileReader("taskA.in"));
			//out = new PrintWriter("taskA.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new taskA().run();
	}
}

import java.io.*;
import java.util.*;

public class taskA {

	PrintWriter out;
	BufferedReader br;
	StringTokenizer st;

	String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		long[][] a = new long[n][m];
		long[][] b = new long[n][m];
		long[][] c = new long[n][m];
		for (int i = 0; i < n; i++) {
			String s = nextToken();
			for (int j = 0; j < m; j++) {
				a[i][j] = nextInt();
				b[i][j] = nextInt();
				c[i][j] = nextInt();
			}
		}
		long ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (i == j)
					continue;
				int l = k;
				boolean[] was = new boolean[m];
				int max = 0;
				long profit = 0;
				int cnt = 0;
				while ((l > 0) && (cnt < n)) {
					for (int t = 0; t <  m; t++) {
						if ((!was[t]) && ((b[j][t] - a[i][t] > b[j][max] - a[i][max]) || (was[max])))
							max = t;
					}
					if (was[max])
						break;
					profit += Math.min(l, c[i][max]) * (b[j][max] - a[i][max]);
					was[max] = true;
					l -= Math.min(l, c[i][max]);
					cnt++;
				}
				if (profit > ans)
					ans = profit;
			}
		}
		out.println(ans);

	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			//br = new BufferedReader(new FileReader("taskA.in"));
			//out = new PrintWriter("taskA.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new taskA().run();
	}
}