#pragma once #include #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector VI; typedef pair P; typedef tuple t3; typedef tuple t4; #define rep(a,n) for(ll a = 0;a < n;a++) #define repi(a,b,n) for(ll a = b;a < n;a++) const ll mod = 1000000007; int main(void) { ll n, m, k; cin >> n >> m >> k; vector> as(n, vector(m, 0)); rep(i, n) { rep(j, m) cin >> as[i][j]; } vector> bits(n+1); bits[0].set(0); rep(i, n) { rep(j, m) { bits[i + 1] |= (bits[i] << as[i][j]); } } ll r = -1; rep(i, k + 1) { if (bits[n][i]) { r = max(r, i); } } if (r < 0) cout << -1 << endl; else cout << k-r << endl; return 0; }