Example:
Input:
2
4 4
0 1 1 1 0 0 1 1 1 1 1 1 0 0 0 0
2 2
0 0 1 1
Output:
2
1
#include <iostream>
using namespace std;
int main() {
//code
int t;
cin >> t;
while (t--) {
int n, m, l = 0, cnt = 0, ans = 0, x;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
cnt = 0;
for (int j = 0; j < m; ++j) {
cin >> x;
if (x == 1) {
cnt++;
}
}
if (cnt > l) {
ans = i;
l = cnt;
}
}
cout << ans << endl;
}
return 0;
}