#include using namespace std; #define rep(i,N) for(int i=0;i; typedef long long ll; const int MOD = 1e9+7; const int INF = 1e9; int A[15][15]; int N,M,K; vector ans; void dfs(int pre,int sum){ if(sum>K)return; if(pre == M){ ans.push_back(sum); return; } for(int j = 0; j < M; ++j){ dfs(pre+1,sum+A[pre+1][j]); } } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); cin>>N>>M>>K; rep(i,N)rep(j,M){ cin>>A[i][j]; } rep(i,M){ dfs(0,A[0][i]); } //print(ans); sort(all(ans)); if(ans[0]>K){ cout<<-1<=ans[i]){ res = min(res,max(0,K-ans[i])); } } cout<