#include <stdio.h>

int main() {
  int n;
  int i;
  int dx, dy;
  int nx, ny;
  int maxdist2;
  int tx, ty;
  int temp;

  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    nx = ny = 0;
    maxdist2 = -1;
    while(1) {
      scanf("%d %d", &dx, &dy);
      if(dx == 0 && dy == 0) break;
      nx += dx;
      ny += dy;
      temp = nx*nx + ny*ny;
      if(temp > maxdist2) {
	maxdist2 = temp;
	tx = nx;
	ty = ny;
      } else if(temp == maxdist2) {
	if(nx > tx) {
	  maxdist2 = temp;
	  tx = nx;
	  ty = ny;
	}
      }
    }
    printf("%d %d\n", tx, ty);
  }
  return 0;
}