Graphic file
In a two-dimensional raster graphic image, each small square element is known as a pixel. Each pixel is assigned a specific color, represented by a unique number.
Consider an image with a width of W pixels and a height of H pixels. We number the rows of pixels from bottom to top, starting from 1 to H, and within each row, the pixels are numbered from left to right, starting from 1 to W. Thus, a pixel located at coordinates (x, y) is the x-th pixel in the y-th row.
When saving an image to a file, it's crucial to determine the order in which the pixel colors are recorded. A logical approach is to save the colors row by row, starting with the first row from left to right, then the second row, and so on. Therefore, the first number in the file corresponds to the color of the pixel at coordinates (1, 1), and the last number corresponds to the pixel at coordinates (W, H).
For large images, it might be necessary to display only a portion of the image on the screen. Hence, it's important to know where in the file to find the color information for a specific pixel.
Your task is to write a program that can determine the file position of a pixel's color based on its coordinates, and conversely, find the coordinates of a pixel based on its position in the file.
Input
The first line contains two integers W and H, representing the width and height of the image, respectively (1 ≤ W, H ≤ 10000). The second line contains one integer d, indicating the type of transformation (1 - from coordinates to position, 2 - from position to coordinates). On the third line, if d=1, two integers x and y are given (1 ≤ x ≤ W, 1 ≤ y ≤ H), specifying the coordinates of the pixel. If d=2, one integer n is provided, indicating the position in the file where the pixel's color is stored (1 ≤ n ≤ WH).
Output
If d=1, output a single integer n, which is the position in the file where the pixel's color is stored. If d=2, output two integers x and y, representing the coordinates of the corresponding pixel.