#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stdio.h>
#include <algorithm>
#include <cstdlib>
#include <memory.h>
using namespace std;
#define rep(i,x,n) for(int i = x; i <= n; i++)
typedef long long LL;
typedef pair<int,int> PII;
const int N = 100021;
LL arr[N];
void test();
int main()
{
//test();
int t;
cin>>t;
while(t--) {
int n, m;
scanf("%d %d", &n, &m);
for(int i = 0; i < n; ++i) {
LL pre = 0;
for(int j = 1; j <= m; ++j) {
LL x;
scanf("%lld", &x);
pre += x;
arr[i] += pre;
}
}
LL mx = *max_element(arr+0, arr+n);
LL mi = *min_element(arr+0, arr+n);
cout<< min_element(arr+0, arr+n) - arr + 1<<" "
<<mx - mi<<endl;
memset(arr, 0, sizeof(arr));
}
return 0;
}
void test() {
#define mytest
#ifdef mytest
freopen("ANSWER.txt", "w",stdout);
#endif
}