def main(): N, M, K = map(int, input().split()) omiyage_list = [list(map(int, input().split())) for _ in range(N)] dp_table = [[0 for _ in range(K+1)] for _ in range(N+1)] dp_table[0][0] = 1 for country_idx, country_omiyage in enumerate(omiyage_list, 1): for omiyage_cost in country_omiyage: for origin_sum in range(max(0, K+1-omiyage_cost)): dp_table[country_idx][origin_sum + omiyage_cost] += dp_table[country_idx-1][origin_sum] last_country_sum = dp_table[-1] for idx, value in enumerate(reversed(last_country_sum)): if value > 0: print(idx) break else: print(-1) if __name__ == "__main__": main()