#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n,dx,dy;
    cin>>n;
    while(n--){
        int x=0,y=0;
        int ax,ay,mx=0;
        while(cin>>dx>>dy,dx|dy){
            x+=dx,y+=dy;
            if(mx<x*x+y*y||mx==x*x+y*y&&ax<x){
                mx=x*x+y*y,ax=x,ay=y;
            }
        }
        cout<<ax<<" "<<ay<<endl;
    }
    return 0;
}
