n, m, money = map(int,input().split()) A = [0]*n for i in range(n): A[i] = list(map(int,input().split())) dp = [[0]*(money+1) for _ in range(n+1)] dp[0][0] = 1 for i in range(n): for j in range(m): for k in range(money): if k + A[i][j] <= money and dp[i][k]: dp[i+1][k+A[i][j]] = 1 for j in range(money, -1, -1): if dp[n][j]: print(money-j) exit() print(-1)