#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,a) for(int i=(int)0;i<(int)a;++i) #define pb push_back #define eb emplace_back using ll=long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 50; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } using namespace std; void solve(){ int n,m,k; cin>>n>>m>>k; vector>A(n,vector(m)); int ans=0,sum=0; rep(i,n){ int minv=1000; rep(j,m){ cin>>A[i][j]; minv=min(minv,A[i][j]); } sum+=minv; } if(sum>k){ cout<<-1<<"\n"; return; } rep(i,m){ int sum2=0; rep(j,n){ sum2+=A[j][i]; } if(sum2>k){ for(int bit=0;bit<(1<