#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	
	int n,dx,dy;
	cin>>n;
	
	for(int i=0;i<n;i++){
		int x=0,y=0,px=0,py=0;
		while(cin>>dx>>dy){
			if(dx==0&&dy==0){cout<<px<<" "<<py<<endl;break;}
			else {
				x+=dx;y+=dy;
				if(x*x+y*y>px*px+py*py||x*x+y*y==px*px+py*py&&x>px){px=x;py=y;}
			}
		}
	}
}