#include <iostream>
#include <vector>
#include <map>
#include <cctype>
#include <algorithm>
#include <set>
#include <cmath>

using namespace std;
int main(){
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
	int cx = 0,cy = 0;
	int x,y;
	int ans = 0;
	int ans_x = 0;
	int ans_y = 0;
	while(cin >> x >> y && (x || y)){
	  cx += x;
	  cy += y;
	  if(ans <= (cx*cx + cy*cy)){
		if(ans == (cx*cx + cy*cy)){
		  if(ans_x < cx){
			ans_x = cx;
			ans_y = cy;
			ans = (cx*cx + cy*cy);
		  }
		}else{
		  ans_x = cx;
		  ans_y = cy;
		  ans = (cx*cx + cy*cy);
		}
	  }
	}
	cout << ans_x << " " << ans_y << endl;
  }
  return 0;
}