#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <stdio.h>
#include <math.h>
typedef std::vector<int> vi;
using namespace std;
#define max(a, b) (a < b ? b : a)
#define min(a, b) (a > b ? b : a)
int main() {
int t;
static int killed[1025][1025];
cin >>t;
while(t--){
int d, n, x, y, sz, max=0;
cin >>d>>n;
fill_n(&killed[0][0], 1025*1025,0);
while(n--){
cin >> x >>y>>sz;
for(int X=max(0, x-d);X<=min(x+d, 1024);X++)
for(int Y=max(0, y-d);Y<=min(y+d, 1024);Y++)
killed[X][Y]+=sz;
}
for(int X=0;X<1025;X++)
for(int Y=0;Y<1025;Y++)
if(killed[X][Y]>max){
max=killed[X][Y];
x=X;y=Y;
}
cout<<x<<" "<<y<<" "<<max<<endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8c3RhY2s+CiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8bWF0aC5oPgp0eXBlZGVmIHN0ZDo6dmVjdG9yPGludD4gdmk7CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbWF4KGEsIGIpICAoYSA8IGIgPyBiIDogYSkKI2RlZmluZSBtaW4oYSwgYikgIChhID4gYiA/IGIgOiBhKQoKaW50IG1haW4oKSB7CglpbnQgdDsKCXN0YXRpYyBpbnQga2lsbGVkWzEwMjVdWzEwMjVdOwoJY2luID4+dDsKCXdoaWxlKHQtLSl7CgkJaW50IGQsIG4sIHgsIHksIHN6LCBtYXg9MDsKCQljaW4gPj5kPj5uOwoJCWZpbGxfbigma2lsbGVkWzBdWzBdLCAxMDI1KjEwMjUsMCk7CgkJd2hpbGUobi0tKXsKCQkJY2luID4+IHggPj55Pj5zejsKCQkJZm9yKGludCBYPW1heCgwLCB4LWQpO1g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