School Trip Destination Ranking

Interview

Time limit1sMemory limit128 MB

Summary
Count how many of n students want each of m destinations, then print destination numbers by descending count with ties broken by ascending number.
Level

Easy3 of 10

Topics
Array, Sorting, Implementation
Solved
No attempts yet

Problem

A school is planning a field trip, so it surveyed its students. The students are numbered from 11 to nn, and the candidate destinations are numbered from 11 to mm. Each student submitted a form marking 11 for a place they want to visit and 00 for a place they do not want to visit.

Write a program that prints the destination numbers in descending order of how many students want to visit each place. When two places are wanted by the same number of students, print them in ascending order of destination number.

Input

The first line contains the number of students nn and the number of candidate destinations mm, separated by a space.

Each of the next nn lines describes one student's answers: the ii-th of these lines gives student ii's mm values separated by spaces, where 11 means the student wants to visit that place and 00 means they do not.

1≤n≤10001 \le n \le 1000, 1≤m≤1001 \le m \le 100.

Output

Print the destination numbers on a single line separated by single spaces, ordered by the number of students who want to visit (most first), breaking ties by ascending destination number. End the line with a newline.

Examples2

  1. Example 1

    Input
    4 6
    1 0 1 0 1 1
    1 1 0 1 0 0
    1 1 1 0 0 0
    1 0 1 0 1 0
    
    Expected output
    1 3 2 5 4 6
    
  2. Example 2

    Input
    2 3
    0 0 0
    0 0 0
    
    Expected output
    1 2 3