10245 - Spiral Matrix   

Description

Given two positive integers M and N, construct an M-row, N-column matrix that comprises a sequence of numbers from 1 to M*N arranged in clockwise spiral order. For example, if M = 3 and N = 4, the matrix would be
 1  2  3  4
10 11 12  5
 9  8  7  6

If M = 4 and N = 4, the matrix would be
 1  2  3  4
12 13 14  5
11 16 15  6
10  9  8  7

Now, given a query integer P (1 <= P <= M*N), you need to print the position of P in the spiral matrix. For example, if M = 4, N = 4, and P = 14, the position of the integer 14 is at the position of row = 2 and column = 3, so the output is

2 3

Input

The input contains three positive integers M N P, where M denotes the number of rows and N denotes the number of columns of the spiral matrix. Both M and N are not greater than 30. P is the query number.

Output

Print two integers that denote the row and column of the position of P. The two integers are separated by a blank. Print a newline at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss