#include <iostream>
using namespace std;

int main(void)
{
	int n;
	int dx,dy;
	int x,y;
	int max,max_x,max_y;
	int d;

	int i1,i2;

	
	
	
	

	cin >> n;

	for(i1=0; i1<n; i1++){
		x = 0;
		y = 0;
		max = 0;
		max_x = 0;
		max_y = 0;


		while(1){

			cin >> dx >> dy;
			if(dx==0 && dy==0)break;

			x += dx;
			y += dy;
			d = x*x + y*y;

			if( max <= d){
				if( max == d){
					if (max_x < x){
						max = d;
						max_x = x;
						max_y = y;
					}
				}
				else {
					max = d;
					max_x = x;
					max_y = y;
				}
			}

		}

		cout << max_x << " " << max_y << endl;
	}


	return 0;
}