#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int calcDist(int x,int y){
	return x*x + y*y;
}

void func(){

	int ans_x = 0,ans_y = 0,tmp_x=0,tmp_y=0,dx,dy,maximum = 0,maximum_x,tmp_dist;

	while(true){
		scanf("%d %d",&dx,&dy);
		if(dx == 0 && dy == 0)break;

		tmp_x += dx;
		tmp_y += dy;

		tmp_dist = calcDist(tmp_x,tmp_y);
		if(tmp_dist > maximum){
			maximum = tmp_dist;
			maximum_x = tmp_x;
			ans_x = tmp_x;
			ans_y = tmp_y;

		}else if(tmp_dist == maximum && maximum_x < tmp_x){
			maximum_x = tmp_x;
			ans_x = tmp_x;
			ans_y = tmp_y;
		}
	}

	printf("%d %d\n",ans_x,ans_y);
}

int main(){

	int N;
	scanf("%d",&N);

	for(int i = 0; i < N; i++)func();

	return 0;
}