#C5403. Non-decreasing Stock Prices

    ID: 49049 Type: Default 1000ms 256MiB

Non-decreasing Stock Prices

Non-decreasing Stock Prices

You are given stock prices for (m) companies over (n) days. A company is said to have non-decreasing stock prices if, for every consecutive pair of days, the price does not decrease. More formally, for a company with prices (p_1, p_2, \dots, p_n), the company is valid if (p_1 \le p_2 \le \dots \le p_n). Your task is to identify all such companies and print their 1-indexed positions. If no company satisfies this condition, print -1.

inputFormat

The first line of input contains two integers (m) and (n) separated by a space, where (m) is the number of companies and (n) is the number of days. This is followed by (m) lines, each containing (n) space-separated integers representing the stock prices of a company over (n) days.

outputFormat

Print the 1-indexed indices of the companies with non-decreasing stock prices, separated by a space. If no such company exists, print -1.## sample

3 5
100 101 102 102 103
110 109 108 107 105
95 95 96 96 97
1 3