/* TU Darmstadt Programming Contest 2001
 * Problem: Oil
 * Author : Joerg Treschau <treschau@rbg.informatik.tu-darmstadt.de>
 * Comment:
 */

#include <iostream>
using namespace std;


#define SIZE 1025
//#define SIZE 16
#define INDEX(X, Y) ((Y)*SIZE + X)


/**
 */
void solve(int* field, const int maxDist)
{
	int* tempField = new int[SIZE*SIZE];

	// filter in x
	for(int y=0; y<SIZE; y++)
	{
		// calculate initial sum for first field
		int sum=0;
		for(int x=0; x<=maxDist; x++)
		{
			if(x>=SIZE)
				break;
			sum += field[INDEX(x,y)];
		}
		tempField[INDEX(0, y)] = sum;

		// for every second field just subtract the leftmost and add a new one at the right
		for(int x=1; x<SIZE; x++)
		{
			if(x>maxDist)
				sum -= field[INDEX(x-maxDist-1,y)];
			if(x<SIZE-maxDist)
				sum += field[INDEX(x+maxDist,y)];

			tempField[INDEX(x,y)] = sum;
		}
	}

	int maxIntensity = 0;
	// filter in y
	for(int x=0; x<SIZE; x++)
	{
		// calculate initial sum for first field
		int sum=0;
		for(int y=0; y<=maxDist; y++)
		{
			if(y>=SIZE)
				break;
			sum += tempField[INDEX(x,y)];
		}
		field[INDEX(x, 0)] = sum;
		if(sum>maxIntensity)
			maxIntensity = sum;

		// for every second field just subtract the leftmost and add a new one at the right
		for(int y=1; y<SIZE; y++)
		{
			if(y>maxDist)
				sum -= tempField[INDEX(x,y-maxDist-1)];
			if(y<SIZE-maxDist)
				sum += tempField[INDEX(x,y+maxDist)];

			field[INDEX(x,y)] = sum;
			if(sum>maxIntensity)
				maxIntensity = sum;
		}
	}

	delete[] tempField;

	/*
	for(int x=0; x<SIZE; x++)
	{
		for(int y=0; y<SIZE; y++)
			cerr << field[INDEX(x,y)] << "  ";
		cerr << endl;
	}
	cerr << endl;
	 */

	for(int x=0; x<SIZE; x++)
	{
		for(int y=0; y<SIZE; y++)
		{
			if(field[INDEX(x,y)] == maxIntensity)
			{
				cout << x << " " << y << " " << maxIntensity << "\n";
				return;
			}
		}
	}
}

/**
 */
int main(int argc, char** args)
{
	int* field = new int[SIZE*SIZE];

	int problems = 0;
	cin >> problems;

	for(int i=0; i<problems; i++)
	{
		int maxDist;
		int hotspotCount;
		cin >> maxDist >> hotspotCount;

		for(int j=0; j<SIZE*SIZE; j++)
			field[j] = 0;

		for(int hs=0; hs<hotspotCount; hs++)
		{
			int x, y, intensity;
			cin >> x >> y >> intensity;
			field[INDEX(x,y)] = intensity;
		}

		solve(field, maxDist);
	}

	delete[] field;
	return 0;
}
