#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<double,double>P;
#define f first
#define s second
int n,m,a,b;
int main(){
  cin>>n;
  while(n--){
    int x=0,y=0,q,w,ma=0;
    while(cin>>q>>w,q||w){
      x+=q,y+=w;
      if(ma<x*x+y*y){
        ma=x*x+y*y;
        a=x,b=y;
      }
      else if(ma==x*x+y*y&&a<x){
        a=x,b=y;
      }
    }
    cout<<a<<' '<<b<<endl;
  }
}