from collections import defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue,copy,time sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.stdin.readline().split()) N,M,K = inpl() dp = [[False]*(K+1) for _ in range(N+1)] dp[0][K] = True for i in range(1,N+1): AA = inpl() for k in range(K+1): flag = False for A in AA: if k+A <= K and dp[i-1][k+A]: dp[i][k] = True for i,f in enumerate(dp[-1]): if f: print(i) exit() print(-1)