#include <iostream>
using namespace std;

int main(){
  int n,ix,iy,nx,ny,mx,my,c,mc;
  cin>>n;
  while(n--){
    mc=mx=my=nx=ny=0;
    while(1){
      cin>>ix>>iy;
      if(!ix&&!iy) break;
      nx+=ix,ny+=iy;
      c=nx*nx+ny*ny;
      if(mc<c||(mc==c&&mx<nx)) mx=nx,my=ny,mc=c;
    }
    cout<<mx<<' '<<my<<endl;
  }
  return 0;
}