#include <stdio.h>

int main(void) {
	int case_num,current_case;
	long long x,y;
	long long rx,ry;
	long long rd,cd;
	long long dx,dy;
	scanf("%d",&case_num);
	for(current_case=0;current_case<case_num;current_case++) {
		x=y=0;
		rx=ry=0;
		rd=0;
		while(1) {
			scanf("%lld%lld",&dx,&dy);
			if(dx==0 && dy==0)break;
			x+=dx;y+=dy;
			cd=x*x+y*y;
			if(cd>rd || (cd==rd && x>rx)) {
				rd=cd;
				rx=x;ry=y;
			}
		}
		printf("%lld %lld\n",rx,ry);
	}
	return 0;
}