Don't put up with what you're sick of! The Smart Beaver decided to escape from the campus of Beaver Science Academy (BSA). BSA is a b×b square on a plane. Each point x,y (0≤x,y≤b) belongs to BSA. To make the path quick and funny, the Beaver constructed a Beaveractor, an effective and comfortable types of transport.
The campus obeys traffic rules: there are n arrows, parallel to the coordinate axes. The arrows do not intersect and do not touch each other. When the Beaveractor reaches some arrow, it turns in the arrow's direction and moves on until it either reaches the next arrow or gets outside the campus. The Beaveractor covers exactly one unit of space per one unit of time. You can assume that there are no obstacles to the Beaveractor.
The BSA scientists want to transport the brand new Beaveractor to the "Academic Tractor" research institute and send the Smart Beaver to do his postgraduate studies and sharpen pencils. They have q plans, representing the Beaveractor's initial position (xi,yi), the initial motion vector wi and the time ti that have passed after the escape started.
Your task is for each of the q plans to determine the Smart Beaver's position after the given time.
Output
Print
q lines. Each line should contain two integers − the Beaveractor's coordinates at the final moment of time for each plan. If the Smart Beaver manages to leave the campus in time
ti, print the coordinates of the last point in the campus he visited.
Examples
Output
0 0
0 1
0 2
1 2
2 2
3 2
3 2
2 2
3 2
1 3
2 2
1 3