#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int main(){
	int n;
	cin>>n;
	while(n--){
		int ansx=0,ansy=0,x=0,y=0;
		int dx,dy;
		while(cin>>dx>>dy){
			if(dx==0 && dy==0)break;
			x+=dx;
			y+=dy;
			if(ansx*ansx+ansy*ansy<x*x+y*y || (ansx<x && ansx*ansx+ansy*ansy==x*x+y*y)){
				ansy=y;
				ansx=x;
			}
		}
		cout<<ansx<<" "<<ansy<<endl;
	}
}