eolymp
bolt
Try our new interface for solving problems
Problems

The Table

The Table

Consider the table of \textbf{32}-bit signed integers with \textbf{n} rows and \textbf{m} columns. The columns are numbered from \textbf{1} to \textbf{m} beginning from the left side of the table. Let \textbf{A_i} (\textbf{1} ≤ \textbf{i} ≤ \textbf{m}) is the product of all numbers in the \textbf{i}-th column. Find the maximum of these products and print the column number where this maximum product is achieved. If there are many such columns, print the largest number of the column. \InputFile Consists of multiple tests. Each test begins with a line with two integers \textbf{m} and \textbf{n} (\textbf{1} ≤ \textbf{m} ≤ \textbf{20}, \textbf{1} ≤ \textbf{n} ≤ \textbf{1000}). Each of the next \textbf{n} lines contains \textbf{m} \textbf{32}-bit signed integers. \textbf{Output} For each test case print on a separate line the column number with the maximum product. If there are several of them -- print the largest number of such column.
Time limit 10 seconds
Memory limit 64 MiB
Input example #1
3 3
20 10 30
15 20 20
30 30 20
3 2
2 -2 2
2 -2 2
Output example #1
3
3