import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int m = Integer.parseInt(sa[1]); int k = Integer.parseInt(sa[2]); int[][] a = new int[n][m]; for (int i = 0; i < n; i++) { sa = br.readLine().split(" "); for (int j = 0; j < m; j++) { a[i][j] = Integer.parseInt(sa[j]); } } br.close(); boolean[][] b = new boolean[n + 1][k + 1]; b[0][k] = true; for (int i = 0; i < n; i++) { for (int j = 0; j <= k; j++) { if (b[i][j]) { for (int j2 = 0; j2 < m; j2++) { if (j >= a[i][j2]) { b[i + 1][j - a[i][j2]] = true; } } } } } for (int j = 0; j <= k; j++) { if (b[n][j]) { System.out.println(j); return; } } System.out.println(-1); } }