QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 64 MB Total points: 100

#13174. Plot purchase

Statistics

Byteasar is going to buy an industrial plot. His fortune is estimated at $k$ bythalers and this is exactly the amount Byteasar would like to spend on the parcel. Finding a parcel worth exactly $k$ bythalers, however, is not an easy task. For this reason Byteasar is ready to buy a more expensive plot. He considers taking out a loan. The Byteotian Credit Bank will grant him a loan of up to $k$ bythalers. Thus, Byteasar can spend no more than $2k$ bythalers on the parcel and he would like to spend no less than $k$ bythalers.

The area in which Byteasar wants to buy his parcel is a square with side length of $n$ metres. The current landlords have set up various prices per square metre. Byteasar has spoken to each one of them and has then prepared a price map of the area. The map depicts the price of every metre by metre square. Clearly, there are $n^2$ such squares. Now is the time to find the dream parcel. It has to be rectangular and consist of whole unit squares. Byteasar has already started looking for the plot on the map, but after many hours he was still unable to find a suitable one. Be a chap and help him!

Write a programme that:

  • reads the numbers and from the standard input, along with the price map of the area,
  • determines a parcel with price in the interval $[k,2k]$ or states that no such parcel exists,
  • writes out the result to the standard output.

Input

The first line of the standard input contains two integers, $k$ and $n$, separated by a single space, $1 ≤ k ≤ 1\,000\,000\,000$, $1 ≤ n ≤ 2\,000$. Each of the following $n$ lines contains $n$ non-negative integers, separated by single spaces. $i^{\text{th}}$ number in the line no. $j+1$ denotes the price of unit square with coordinates $(i,j)$. The price of one square metre does not exceed $2\,000\,000\,000$ bythalers.

Output

If no plot with price in the interval $[k,2k]$ exists, your programme should output exactly one line with word NIE (NO in Polish). Otherwise it should print out one line with four positive integers $x_1$,$y_1$,$x_2$,$y_2$ separated by single spaces and denoting the rectangle's coordinates. $(x_1,y_1)$ denotes the upper left rectangle corner, while $(x_2,y_2)$ the lower right corner. Then it consists of the squares: $\{(x,y)|x_1 ≤ x ≤ x_2 and y_1 ≤ y ≤ y_2\}$. The sum $c$ of prices of the squares forming up this rectangle should satisfy the inequality $k ≤ c ≤ 2k$. If more than one rectangular parcel satisfies this condition, pick one arbitrarily.

Example

Input

4 3
1 1 1
1 9 1
1 1 1

Output

NIE

Input

8 4
1 2 1 3
25 1 2 1
4 20 3 3
3 30 12 2

Output

2 1 4 2
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.