P14358 [CSP-J 2025] Seats

Description

The second round of CSP-J 2025 is underway. There are $n \times m$ contestants in the examination room where Little R is located, and the CSP-J 2025 first-round scores of all these contestants are **pairwise distinct**. All $n \times m$ contestants are assigned seats **in a snake-like order from highest score to lowest score** according to their CSP-J 2025 first-round scores, and are arranged into $n$ **rows** and $m$ **columns**. Specifically, let the scores of all contestants in Little R's examination room be $s_1 > s_2 > \dots > s_{n \times m}$ **from highest to lowest**. Then the contestant with score $s_1$ sits at **column** $1$, **row** $1$; the contestant with score $s_2$ sits at **column** $1$, **row** $2$; $\dots$; the contestant with score $s_n$ sits at **column** $1$, **row** $n$; the contestant with score $s_{n+1}$ sits at **column** $2$, **row** $n$; $\dots$; the contestant with score $s_{2n}$ sits at **column** $2$, **row** $1$; the contestant with score $s_{2n+1}$ sits at **column** $3$, **row** $1$; and so on. For example, if $n = 4, m = 5$, then all $4 \times 5 = 20$ contestants are assigned seats in the order of the arrows in the figure below, according to their CSP-J 2025 first-round scores from highest to lowest. :::align{center} ![](https://cdn.luogu.com.cn/upload/image_hosting/hfprtmco.png) ::: Given the **number of rows** $n$ and the **number of columns** $m$ of the seats in Little R's examination room, as well as the CSP-J 2025 first-round scores $a_1, a_2, \dots, a_{n \times m}$ of all contestants in that room, where $a_1$ is the CSP-J 2025 first-round score of Little R, you need to help Little R determine at which **column** and which **row** his seat is.

Input Format

The first line of input contains two positive integers $n, m$, representing the **number of rows** and the **number of columns** of the seats in Little R's examination room, respectively. The second line of input contains $n \times m$ positive integers $a_1, a_2, \dots, a_{n \times m}$, representing the CSP-J 2025 first-round scores of all contestants in Little R's examination room, where $a_1$ is the CSP-J 2025 first-round score of Little R.

Output Format

Output two positive integers $c, r$ on a single line, representing that Little R's seat is at **column** $c$, **row** $r$.

Explanation/Hint

### Example 1 Explanation In the order of scores from highest to lowest, the contestant with score $100$ sits at **column** $1$, **row** $1$; the contestant with score $99$ sits at **column** $1$, **row** $2$; the contestant with score $98$ sits at **column** $2$, **row** $2$; and the contestant with score $97$ sits at **column** $2$, **row** $1$. Little R's score is $99$, so his seat is at **column** $1$, **row** $2$. ### Example 2 Explanation In the order of scores from highest to lowest, the contestant with score $100$ sits at **column** $1$, **row** $1$; the contestant with score $99$ sits at **column** $1$, **row** $2$; the contestant with score $98$ sits at **column** $2$, **row** $2$; and the contestant with score $97$ sits at **column** $2$, **row** $1$. Little R's score is $98$, so his seat is at **column** $2$, **row** $2$. ### Constraints For all test data, it is guaranteed that: - $1 \leq n \leq 10$, $1 \leq m \leq 10$; - for all $1 \leq i \leq n \times m$, $1 \leq a_i \leq 100$, and $a_1, a_2, \dots, a_{n \times m}$ are pairwise distinct. ::cute-table{tuack} | Test point | $n \leq$ | $m \leq$ | Special property | | :--: | :--: | :--: | :--: | | $1$ | $1$ | $1$ | AB | | $2, 3$ | ^ | $10$ | None | | $4, 5$ | $10$ | $1$ | ^ | | $6$ | $2$ | $2$ | A | | $7$ | ^ | ^ | B | | $8, 9$ | ^ | ^ | None | | $10$ | ^ | $10$ | A | | $11$ | ^ | ^ | B | | $12 \sim 14$ | ^ | ^ | None | | $15 \sim 17$ | $10$ | $2$ | ^ | | $18 \sim 20$ | ^ | $10$ | ^ | Special property A: for all $1 \leq i \leq n \times m$, $a_i = i$. Special property B: for all $1 \leq i \leq n \times m$, $a_i = n \times m - i + 1$. Translated by QwenWork