#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	int i;
	int dx,dy,x,y,mx,my;
	int n;
	
	scanf("%d ",&n);

	for(i=0;i<n;i++)
		{
			x=0;
			y=0;
			mx = 0;
			my = 0;

			while(1)
				{
					scanf("%d %d ",&dx,&dy);

					if(dx == 0 && dy ==0)break;

					x += dx;
					y += dy;

					if(mx*mx+my*my < x*x+y*y)
						{
							mx = x;
							my = y;
						}
					else if(mx*mx+my*my == x*x+y*y)
						{
							if(mx < x)
								{
									mx = x;
									my = y;
								}
						}	
				}
			printf("%d %d\n",mx,my);
		}
	return 0;
}