ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1029. Ministry

Time limit: 1.0 second
Memory limit: 64 MB
Mr. F. wants to get a document be signed by a minister. A minister signs a document only if it is approved by his ministry. The ministry is an M-floor building with floors numbered from 1 to M. Each floor has N rooms numbered from 1 to N. In each room there is one (and only one) official.
A document is approved by the ministry only if it is signed by at least one official from the M-th floor. An official signs a document only if at least one of the following conditions is satisfied:
  1. the official works on the first floor;
  2. the document is signed by the official working in the room with the same number but situated one floor below;
  3. the document is signed by an official working in a neighbouring room (rooms are neighbouring if they are situated on the same floor and their numbers differ by one).
Each official collects a fee for signing a document. The fee is a positive integer not exceeding 109.
You should find the cheapest way to approve the document.

Input

The first line contains integers M and N representing the number of floors in the building and the number of rooms per floor (1 ≤ M ≤ 100; 1 ≤ N ≤ 500). Each of the next M lines contains N integers that describe fees (the j-th integer at i-th line is the fee required by the official working in the j-th room at the i-th floor).

Output

Output the numbers of rooms in the order they should be visited to approve the document in the cheapest way. If there are more than one way leading to the cheapest cost you may print any of them.

Sample

inputoutput
3 4
10 10 1 10
2 2 2 10
1 10 10 10
3 3 2 1 1

Notes

You can assume that for each official there always exists a way to get the approval of a document (from the first floor to this official inclusively) paying no more than 109.
Problem Author: Evgeny Frolov
Problem Source: Ural Collegiate Programming Contest '99