Problem2049--Run for Exercise

2049: Run for Exercise

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 2  Solved: 2
[Submit] [Status] [Web Board] [Creator:]

Description

        The programmers in ACM learn very hard every day. The health is much better than learning, all of them know. Therefore, they decide to run d meters every day. They run on a plane as a square whose lower left corner is at the original point and the length of side is A meters. The sides of the square are parallel to coordinate axes. In order to do exercise more effectively, they are going to exercise n days. In addition, the starting point for their running is the end point of the last day, and run counter-clockwise. Of course, at the first day, they start at the original point.

         They invite you to note everyday end point. Can you help them?

Input

         The first line of input contains the only positive number T (T <= 10), the following T cases.

         For each case, the first line contains two positive integer A, n (A<=1000, n<=10,000). Number a denotes the length of the square's side, number n denotes the number of the days they plan to run. Next, we input n lines, each of which contains only integer di, which denotes the length of their running at I’th day (i=1,2,,n).

Output

        For each case, you should output which case firstly.

        Next, print n lines. The i’th line should contain two numbers x and y, which denote the end point at the i’th day (i=1,2,,n).

Sample Input Copy

1
3 3
1
2
3

Sample Output Copy

Case #1:
1 0
3 0
3 3

Source/Category