import std.stdio, std.string, std.conv, std.algorithm, std.math;

struct P { int x,y; }
void main()
{
    int n = readln.chomp.to!int;
    foreach(_; 0 .. n)
    {
        P[] rooms;
        P cur;
        while(true)
        {
            auto inp = readln.split.map!(to!int);
            if(!inp[0] && !inp[1]) break;
            cur.x += inp[0];
            cur.y += inp[1];
            rooms ~= cur;
        }
        int dis = 0;
        P farRoom;
        foreach(room; rooms)
        {
            int d = room.x * room.x + room.y * room.y;
            if(dis < d || (dis == d && farRoom.x < room.x))
            {
                dis = d;
                farRoom = room;
            }
        }
        writeln(farRoom.x, " ", farRoom.y);
    }
}