#include <iostream>
#include <cmath>
using namespace std;


int main(){
  int n, dx, dy;
  int px, py;
  long long int mdis, dis;
  int mpx, mpy;
  cin>> n;
  for(int i = 0;i < n;i++){
    px = py = 0;
    mdis = 0;
    do{
      cin >> dx >> dy;
      px += dx; py += dy;
      dis = pow(px,2)+pow(py,2);
      if( mdis < dis){
        mpx = px;mpy = py;
        mdis = dis;
      }else if(mdis == dis && mpx < px){
        mpx = px;mpy = py;
      }
    }while(dx||dy);
    cout << mpx << " " << mpy << endl;
  }
  return 0;
}