#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}

int n;
int main()
{
  cin >>n;
  int dx,dy;
  double dist,dist1;
  for(int i = 0;i < n;i++){
    int px,py;
    px = 0;
    py = 0;
    dist = dist1 = 0;
    int nx = 0;
    int ny = 0;
    while(cin>>dx>>dy,dx||dy){
      nx = dx + nx;
      ny = dy + ny;
     dist = (nx*nx+ny*ny);
     if(dist > dist1){
       px = nx;
       py = ny;
       dist1 = dist;
     }else if(dist==dist1){
       if(nx >px){
	 px = nx;
	 py = ny;
       }
     }
    }
    printf("%d %d\n",px,py);
  }

  return 0;
}