Problem M

Statement
Copy Copied
Description:
As you all know, the plum harvesting season is on! Little Milutin had his plums planted in an orchard that can be represented as an $$$n$$$ by $$$m$$$ matrix. While he was harvesting, he wrote the heights of all trees in a matrix of dimensions $$$n$$$ by $$$m$$$.

At night, when he has spare time, he likes to perform various statistics on his trees. This time, he is curious to find out the height of his lowest tree. So far, he has discovered some interesting properties of his orchard. There is one particular property that he thinks is useful for finding the tree with the smallest heigh.

Formally, let $$$L(i)$$$ be the leftmost tree with the smallest height in the $$$i$$$-th row of his orchard. He knows that $$$L(i) \le L(i+1)$$$ for all $$$1 \le i \le n - 1$$$. Moreover, if he takes a submatrix induced by any subset of rows and any subset of columns, $$$L(i) \le L(i+1)$$$ will hold for all $$$1 \le i \le n'-1$$$, where $$$n'$$$ is the number of rows in that submatrix.

Since the season is at its peak and he is short on time, he asks you to help him find the plum tree with minimal height.

Input Format:
This problem is interactive.

The first line of input will contain two integers $$$n$$$ and $$$m$$$, representing the number of rows and the number of columns in Milutin's orchard. It is guaranteed that $$$1 \le n, m \le 10^6$$$.

The following lines will contain the answers to your queries.

Output Format:
Once you know have found the minimum value $$$r$$$, you should print ! $$$r$$$ to the standard output.

Note:
None

Submissions

IDLanguageExit CodeTimestampCodeStdoutStderrRetry
4965 go 0 2026-03-07T10:09:14.857112Z View View View Retry

Evaluations

Eval IDRun IDProviderModelLangSuccessTimestampPromptResponseStdoutStderrRetry
1705 20260307-080824 gemini gemini-3-pro-preview go false 2026-03-07T09:36:43.77262Z View View View View Retry