#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
  int T;
  int dx, dy;
  int x, y, ansx, ansy;

  cin >> T;
  while(T--){
    x = 0, y = 0, ansx = 0, ansy = 0;
    while(cin >> dx >> dy){
      if(dx == 0 && dy == 0) break;      
      x += dx;
      y += dy;
      
      if(hypot(x,y) > hypot(ansx, ansy)){
	ansx = x;
	ansy = y;
      }
      else if(hypot(x, y) == hypot(ansx, ansy) && ansx < x){
	ansx = x;
	ansy = y;
      }
    }
    cout << ansx << ' ' << ansy << endl;
  }
  return 0;
}