#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() #define fi first #define se second template inline bool chmax(A &a, B b) { if (a inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } using ll = long long; using pii = pair; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = 0; //---------------------------------// int N, M, K; int A[10][10]; bool dp[10][501]; int main() { cin >> N >> M >> K; REP(i, N) REP(j, M) scanf("%d", &A[i][j]); dp[0][0] = true; REP(i, N) REP(j, 501) if (dp[i][j]) { REP(k, M) if (j + A[i][k] < 501) { dp[i + 1][j + A[i][k]] = true; } } int ans = -1; REP(i, K + 1) if (dp[N][i]) ans = i; if (ans == -1) cout << -1 << endl; else cout << K - ans << endl; return 0; }