n,m,k = map(int,input().split()) sur_list = [] diff_list = [] diff_plus_list = [] conv_bin_list = [] for i in range(n): sur_list.append(list(map(int,input().split()))) first_row = 0 for i in range(n): first_row += sur_list[i][0] if first_row > k: print("-1") exit() for i in range(n): for j in range(1,m): diff_list.append(sur_list[i][j] - sur_list[i][0]) for i in range(2 ** (n*(m-1))): conv_bin = bin(i) conv_bin_list.append(conv_bin[2::].zfill(n)) for i in range(len(conv_bin_list)): tar_conv = conv_bin_list[i] price = 0 for j in range(n): price += int(tar_conv[j]) * diff_list[j] diff_plus_list.append(price) print(conv_bin_list) print(diff_plus_list) for i in range(k - first_row, 0, -1): if i in diff_plus_list: print(k - (first_row + i)) exit() print(k - first_row)