#include #define rep(i,N) for(ll (i)=0;(i)<(N);(i)++) #define chmax(x,y) x=max(x,y) #define chmin(x,y) x=min(x,y) using namespace std; typedef long long ll; typedef pair P; const int mod = 1000000007; const int INF = 1001001001; int n, m, k; vector> a; int dfs(int depth, int money) { if (money < 0) return INF; if (depth == n) return money; int res = INF; rep(i, m) { int ncost = money - a[depth][i]; chmin(res, dfs(depth + 1, ncost)); } return res; } int main() { cin >> n >> m >> k; a.resize(n, vector(m)); rep(i, n) rep(j, m) { cin >> a[i][j]; } int ans = dfs(0, k); if (ans == INF) ans = -1; cout << ans << endl; }