#include using namespace std; using lint = long long; template using V = vector; template using VV = V< V >; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; bitset<1000> bs; bs[0] = 1; while (n--) { bitset<1000> nbs; for (int _ = 0; _ < m; ++_) { int a; cin >> a; nbs |= bs << a; } swap(bs, nbs); } for (int x = k; x >= 0; --x) if (bs[x]) { return cout << k - x << '\n', 0; } return cout << -1 << '\n', 0; }