import java.util.*; public class Main { static int[][] goods; static int[][] dp; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int k = sc.nextInt(); goods = new int[n][m]; dp = new int[n][k + 1]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { goods[i][j] = sc.nextInt(); } Arrays.fill(dp[i], -1); } int ans = dfw(n - 1, k); if (ans > k) { ans = -1; } System.out.println(ans); } static int dfw(int idx, int money) { if (money < 0) { return Integer.MAX_VALUE; } if (idx < 0) { return money; } if (dp[idx][money] != -1) { return dp[idx][money]; } dp[idx][money] = Integer.MAX_VALUE; for (int i = 0; i < goods[idx].length; i++) { dp[idx][money] = Math.min(dp[idx][money], dfw(idx - 1, money - goods[idx][i])); } return dp[idx][money]; } }