Problem:


  ある学校で修学旅行へ行く計画がある.そのためにアンケート調査を行った.
生徒は 1 から n までの生徒番号を持ち,旅行候補の場所を 1 から m までの番号で表し,行きたい場所に ○,行きたくない場所に×の印をつけて提出している.

  このとき, 行きたい場所の人数が多い順に,場所の番号を出力するプログラムを作成せよ.人数が同じときは,場所の番号順とする.

n と旅行候補の場所の数 m が空白で区切られ, i + 1 行に生徒 i のアンケート結果を ○ は 1 で×は 0 で表し,空白で区切られた m 個の数字が並んでいる.1 ≤ n ≤ 1000, 1 ≤ m ≤ 100 とする.

  出力ファイルのファイル名は “output.txt” である.“output.txt” においては,出力(場所の番号)の後に改行を入れること.

-->

  入力データ の 1 行目は生徒の人数 n と旅行候補の場所の数 m が空白で区切られ, i + 1 行に生徒 i のアンケート結果を ○ は 1 で×は 0 で表し,空白で区切られた m 個の数字が並んでいる.1 ≤ n ≤ 1000, 1 ≤ m ≤ 100 とする.

 

  入力例１
 

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

  　

  出力例１

1 3 2 5 4 6

入力

入力は複数のデータセットからなる．n, m がともに 0 のとき入力が終了する．データセットの数は 5 を超えない．

出力

データセットごとに、場所の番号 を１行に出力する．

入力例

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
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
0 0

出力例

1 3 2 5 4 6
1 3 2 5 4 6

上記問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。



Sample 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
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
0 0


Sample output:
1 3 2 5 4 6
1 3 2 5 4 6

Submission status: Wrong Answer

Solution code:
while True:
	students,places = map(int,raw_input().split())
	if students == 0 and places == 0:
		break
	res = dict(zip(range(places),[0]*places))
	for i in range(students):
		points = map(int,raw_input().split())
		for j in range(places):
			res[j] += points[j]
	for k,v in sorted(res.items(),key=lambda x:x[1], reverse=True):
		print k,
	print "\n"

Submission status: Wrong Answer

Solution code:
while True:
    n, m  = map(int, raw_input().split())
    if n==0 and m==0: break
    c = [[0, 0]for i in range(m)]
    for i in range(m):
        c[i][1] = i
    for i in range(n):
        a = map(int, raw_input().split())
        for j in range(m):
            if a[j] == 1: c[m-j-1][0] = c[m-j-1][0] + 1
    c = sorted(c)
    for i in reversed(range(m)):
        print m-c[i][1],

Submission status: Wrong Answer

Solution code:
# coding: utf-8

while True:
	n, m = map(int, raw_input().split())
	if n == 0:
		break
	else:
		data = []
		for i in range(n):
			student = map(int, raw_input().split())
			data.append(student)
		result = []
		for j in range(m):
			sum = 0
			for i in range(n):
				sum += data[i][j]
			result.append(sum)

		ans = []
		for i in range(1,m+1):
			ans.append(i)
		for i in range(1,m)[::-1]:
			for j in range(1,i)[::-1]:
				if result[j-1] < result[j]:
					tmp = ans[j-1]
					ans[j-1] = ans[j]
					ans[j] = tmp
		ans_text = ""
		for i in range(m-1):
			ans_text += str(ans[i]) + " "
		ans_text += str(ans[m-1])
		print(ans_text)

Submission status: Wrong Answer

Solution code:
while True:
  a,b=map(int,raw_input().split())
  if a ==0 and b ==0: break
  ans,tage,qwer=[0]*(b+1),[],0
  tt=range(b+1)
  for i in range(a):
    hoge=map(int,raw_input().split())
    for j in range(b):
      ans[j]+=hoge[j]
  for i in range(b):
    for j in range(b,i,-1):
      if ans[j-1] > ans[j]:
        tt[j-1],tt[j]=tt[j],tt[j-1]
  else:
    tt.remove(0)
  for i in range(b):
    print tt[i],
  else: print ""

Submission status: Wrong Answer

Solution code:
while True:
  a,b=map(int,raw_input().split())
  if a ==0 and b==0: break
  ans=[0]*b
  ans2=range(1,b+1)
  for i in range(a):
    hoge=map(int,raw_input().split())
    for j in range(b):
      ans[j]+=hoge[j]
  else:
    k = b-1
    for i in range(k):
      for j in range(k,i,-1):
        if ans[j] == ans[j-1]:
          ans2[j-1],ans2[j]=ans2[j],ans2[j-1]
        elif  ans[j-1]>ans[j]:
            ans2[j-1],ans2[j]=ans2[j],ans2[j-1]
            ans[j-1],ans[j]=ans[j],ans[j-1]
  ans.reverse() ; ans2.reverse()
  for i in range(b):
    print ans2[i],
  else: print""

Submission status: Wrong Answer

Solution code:
while True:
 try:
  a,b=map(int,raw_input().split())
  if a ==0 and b==0: break
  ans=[0]*b
  ans2=range(1,b+1)
  for i in range(a):
    hoge=map(int,raw_input().split())
  else: print "5 15 16 19 4 8 9 13 18 20 1 3 7 12 14 2 10 6 11 17"
 except EOFError: break

Submission status: Wrong Answer

Solution code:
n,m=map(int,raw_input().split())
h={i:0 for i in range(m)}
for i in range(n):
	a=map(int,raw_input().split())
	for j in range(m):
		h[j]+=a[j]
ans=[k[0]+1 for k in sorted(h.items(),key=lambda x:x[1])[::-1]]
print " ".join(map(str,ans))

Submission status: Wrong Answer

Solution code:
n,m=map(int,raw_input().split())
h={i:0 for i in range(m)}
for i in range(n):
	a=map(int,raw_input().split())
	for j in range(m):
		h[j]+=a[j]
ans=[k[0]+1 for k in sorted(h.items(),key=lambda x:x[1],reverse=True)]
print " ".join(map(str,ans))

Submission status: Accepted

Solution code:
while True:
	students,places = map(int,raw_input().split())
	if students == 0 and places == 0:
		break
	res = dict(zip(range(places),[0]*places))
	for i in range(students):
		points = map(int,raw_input().split())
		for j in range(places):
			res[j] += points[j]
	for k,v in sorted(res.items(),key=lambda x:x[1], reverse=True):
		print k+1,
	print

Submission status: Accepted

Solution code:
while True:
    n, m  = map(int, raw_input().split())
    if n==0 and m==0: break
    c = [[0, 0]for i in range(m)]
    for i in range(m):
        c[i][1] = i
    for i in range(n):
        a = map(int, raw_input().split())
        for j in range(m):
            if a[j] == 1: c[m-j-1][0] = c[m-j-1][0] + 1
    c = sorted(c)
    for i in reversed(range(m)):
        if i==0: break
        print m-c[i][1],
    print m-c[0][1]

Submission status: Accepted

Solution code:
while True:
    n, m  = map(int, raw_input().split())
    if n==0 and m==0: break
    c = {i:0 for i in range(m)}
    for i in range(n):
        a = map(int, raw_input().split())
        for j in range(m):
            c[j] += a[j]
    ans=[k[0]+1 for k in sorted(c.items(),key=lambda x:x[1],reverse=True)]
    print " ".join(map(str,ans))

Submission status: Accepted

Solution code:
while True:
	a,b = map(int,raw_input().split())
	if a == 0 and b == 0:
		break
	
	list = []
	for i in xrange(a):
		code = raw_input()
		for j in xrange(b):
			if len(list) < b:
				list.append(0)
			list[j] += int(code.split()[j])
		
	dict = {}
	for i in xrange(b):
		dict[i] = list[i]
	
	dic = sorted(dict.items(), key=lambda x:x[1], reverse = True)
	
	for var in dic:
		print var[0] + 1,
	print

Submission status: Accepted

Solution code:
while True:
    n, m = map(int, input().split())
    if not n and not m:
        break

    votes = [[0] * n for _ in range(m)]
    for i in range(n):
        answer = tuple(map(int, input().split()))
        for j in range(m):
            votes[j][i] += answer[j]
    print(*[t[1] for t in sorted((-sum(s), i + 1) for i, s in enumerate(votes))])

Submission status: Accepted

Solution code:
while 1:
    n,m=map(int,raw_input().split())
    if n+m==0:
        break
    a = dict(zip(range(m),[0]*m))
    for i in range(n):
        c=map(int,raw_input().split())
        for j in range(m):
            a[j]+=c[j]
    for k,v in sorted(a.items(),key=lambda x:x[1],reverse=1):
        print k+1,
    print

Submission status: Accepted

Solution code:
while 1:
	n,m=map(int,raw_input().split())
	if n==m==0:break
	p=[[0,i] for i in xrange(m)]
	st=[map(int,raw_input().split()) for _ in xrange(n)]
	for i in xrange(n):
		for j in xrange(m):
			p[j][0]+=st[i][j]
	p.sort(key=lambda x:(x[0],-x[1]))
	ans=[]
	for i in xrange(m-1,-1,-1):
		ans.append(str(p[i][1]+1))
	print(" ".join(ans))

Submission status: Accepted

Solution code:
class Dest(object):
    def __init__(self, name):
        self.name = name
        self.count = 0

    def vote(self):
        self.count += 1




if __name__ == '__main__':
    while True:
        # ??????????????\???
        num_of_students, num_of_destinations = [int(x) for x in input().strip().split(' ')]
        if num_of_students == 0 and num_of_destinations == 0:
            break

        data = []
        for i in range(num_of_students):
            data.append(list(map(int, input().strip().split(' '))))

        # ??????????????????
        dests = []
        for i in range(num_of_destinations):
            dest_name = str(i+1)
            dests.append(Dest(dest_name))

        for d in data:
            for i, v in enumerate(d):
                if v:
                    dests[i].vote()

        dests.sort(key=lambda x:x.count, reverse=True)

        # ???????????????
        t = [d.name for d in dests]
        print('{0}'.format(' '.join(t)))

Submission status: Accepted

Solution code:
from collections import Counter as C
r=range
while True:
    n,m=map(int, input().split())
    if n==0:break
    d=dict(zip(r(1,m+1),[0]*m))
    for i in r(n):
        l=list(map(int, input().split()))
        for j in r(len(l)):
            if l[j]:d[j+1]+=1
    print(' '.join(map(str,[k for k,_ in C(d).most_common()])))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

while True:
	n,m = map(int,input().split())

	if n == 0 and m == 0:
		break

	sum = []

	for i in range(m):
		sum.append(0)

	smax = 0

	for i in range(n):
		ans = list(map(int,input().split()))
		for i in range(m):
			if ans[i] == 1:
				sum[i] += 1
			if smax < sum[i]:
				smax = sum[i]

	ans = ""

	for i in reversed(range(smax+1)):
		for j in range(m):
			if sum[j] == i:
				ans += str(j+1) + " "

	ans = ans.rstrip(" ")
	print(ans)

Submission status: Accepted

Solution code:
while True:
    n, m = map(int, input().split())
    if n == 0:
        break
    questionnaire = [0] * m
    for _ in range(n):
        questionnaire = map(lambda x, y: x+y, questionnaire, map(int, input().split()))
    d = {m-k: v for k, v in enumerate(questionnaire)}
    result = sorted(d.items(), key=lambda x: (x[1], x[0]), reverse=True)
    print(*[m-r[0]+1 for r in result])

Submission status: Accepted

Solution code:
# coding: utf-8

while True:
	n, m = map(int, raw_input().split())
	if n == 0:
		break
	else:
		data = []
		for i in range(n):
			student = map(int, raw_input().split())
			data.append(student)
		result = []
		for j in range(m):
			sum = 0
			for i in range(n):
				sum += data[i][j]
			result.append(sum)
#		print result

		ans = []
		for i in range(1,m+1):
			ans.append(i)
		for i in range(1,m): #(0,1),,,,(m-2,m-1)
			for j in range(1,m-i+1):
				if result[j-1] < result[j]:
					tmp = ans[j-1]
					ans[j-1] = ans[j]
					ans[j] = tmp
					tmp = result[j-1]
					result[j-1] = result[j]
					result[j] = tmp
#				print j-1, j
#				print ans
#				print result
		ans_text = ""
		for i in range(m-1):
			ans_text += str(ans[i]) + " "
		ans_text += str(ans[m-1])
		print(ans_text)

Submission status: Accepted

Solution code:
def main():
  while True:
    n, m = map(int,input().split())
    if not n:
      break
    
    lst = [0] * m
  
    for i in range(n):
      lst = [i + j for i, j in zip(lst, map(int,input().split()))]
  
    lst = list(zip(lst,[i for i in range(1,m + 1)]))
    lst = sorted(lst,key=lambda t:-t[0])
    
    print(" ".join(list(map(str,[t[1] for t in lst]))))
  
main()

Submission status: Accepted

Solution code:
def main():
  while True:
    n, m = map(int,input().split())
    if not n:
      break
    
    lst = [0] * m
  
    for i in range(n):
      lst = [i + j for i, j in zip(lst, map(int,input().split()))]
  
    lst = list(zip(lst,range(1,m + 1)))
    lst = sorted(lst,key=lambda t:-t[0])
    
    print(" ".join(list(map(str,[t[1] for t in lst]))))
  
main()

Submission status: Accepted

Solution code:
def main():
  while True:
    n, m = map(int,input().split())
    if not n:
      break
    
    lst = [0] * m
  
    for i in range(n):
      lst = [i + j for i, j in zip(lst, map(int,input().split()))]
  
    lst = list(zip(lst,range(1,m + 1)))
    lst = sorted(lst,key=lambda t:-t[0])
    
    print(" ".join(map(str,[t[1] for t in lst])))
  
main()

Submission status: Accepted

Solution code:
def main():
  while True:
    n, m = map(int,input().split())
    if not n:
      break
    
    lst = [0] * m
  
    for i in range(n):
      lst = [i + j for i, j in zip(lst, map(int,input().split()))]

    lst = sorted(zip(lst, range(1, m + 1)), key=lambda t:-t[0])
    
    print(" ".join(map(str,[t[1] for t in lst])))
  
main()

Submission status: Accepted

Solution code:
# AOJ 0505: Questionnaire
# Python3 2018.6.29 bal4u

while True:
	n, m = map(int, input().split())
	if n == 0: break
	s = [0]*m
	for i in range(n):
		a = list(map(int, input().split()))
		s = [s[i]+a[i] for i in range(m)]
	ans = []
	for i in range(m): ans.append((s[i], i+1))
	ans.sort(key=lambda x:(-x[0],x[1]))
	print(*[ans[i][1] for i in range(m)])

Submission status: Accepted

Solution code:
while 1:
        a,b = map(int, raw_input().split())
        if a == 0 and b == 0: break
        r = [0 for i in range(b)]
        n = range(1, b+1)
        for j in range(a):
                vote = map(int, raw_input().split())
                for i in range(b):
                        r[i] += vote[i]

        for i in range(1, b):
                for j in range(b-i):
                        if r[j] < r[j+1]:
                                temp = (r[j], n[j])
                                r[j] = r[j+1]
                                n[j] = n[j+1]
                                r[j+1] = temp[0]
                                n[j+1] = temp[1]

        n = map(str, n)
        ans = ''
        for i in range(b):
                if i == 0: ans += n[i]
                else: ans += ' ' + n[i]
        print ans

Submission status: Accepted

Solution code:
while True:
  a,b=map(int,raw_input().split())
  if a+b ==0: break
  ans={} ; hoge=[0]*b
  for i in range(a):
    t= map(int,raw_input().split())
    for j in range(b):
      hoge[j] += t[j]
  for i,j in enumerate(hoge):
    ans[i+1] = j
  for k,v in sorted(ans.items(),key = lambda x:x[1],reverse=True):
    print k,
  else: print

Submission status: Accepted

Solution code:
get = lambda: map(int, raw_input().split())

while True:
        (n, m) = get()

        if n + m == 0:
                break

        res = [0 for i in range(m)]
        for i in range(n):
                a = get()
                for j in range(m):
                        res[j] -= a[j]

        res = zip(res, range(1, m + 1))
        res.sort()

        for i in range(m):
                print res[i][1],

        print

Submission status: Accepted

Solution code:
while 1:
    n, m = map(int, raw_input().split())
    if n == m == 0: break
    ts = dict(zip(range(m), [0] * m))
    for i in range(n):
        for j, p in enumerate(map(int, raw_input().split())):
            ts[j] += p
    print ' '.join([str(k + 1) for k, v
            in sorted(ts.items(), key=lambda x: x[1], reverse=True)])

Submission status: Accepted

Solution code:
while True:
    n,m=map(int,raw_input().split())
    if n==m==0:break
    L=[0]*m
    Q=[map(int,raw_input().split()) for i in range(n)]
    for i in range(n):
        for j in range(m):
            L[j]-=Q[i][j]
    L=sorted([(L[i],i+1) for i in range(m)])
    print " ".join(map(str,[i[1] for i in L]))

Submission status: Accepted

Solution code:
while 1:
    n, m = map(int, raw_input().split())
    if not n or not m:
        break
    wantList = [0] * m
    for i in range(n):
        place = map(int, raw_input().split())
        for i, want in enumerate(place):
            if want:
                wantList[i] += 1
    ret = sorted(range(m), key=lambda k: wantList[k], reverse=True)
    ret = map(lambda x: x + 1, ret)
    print reduce(lambda a, b: str(a) + " " + str(b), ret)

Submission status: Accepted

Solution code:
while True:
    n, m = map(int, raw_input().split())
    if (n, m) == (0, 0):
        break
    r = [0] * m
    for i in range(n):
        q = map(int, raw_input().split())
        for j in range(m):
            r[j] -= q[j]
    r = sorted([(r[i],i+1)for i in range(m)])
    print ' '.join(map(str, [rr[1] for rr in r]))

Submission status: Accepted

Solution code:
while(1):
    n, m = map(int,raw_input().split())
    if n == 0 and m == 0:
        break
    
    agree_sum = [0]*m
    for i in range(n):
        agree_sum = [ x+y for (x, y) in zip(agree_sum, map(int,raw_input().split())) ]
    
    for i in range(m):
        if max(agree_sum) == -1:
            break;
        max_idx = agree_sum.index(max(agree_sum))
        agree_sum[max_idx] = -1
        print max_idx+1,
    print

Submission status: Accepted

Solution code:
while 1:
    n,m = map(int, raw_input().split())
    if n==m==0: break
    p = [[0,m-i] for i in xrange(1,m+1)];
    for i in xrange(n):
        mark = raw_input().split()
        for i in xrange(m): p[i][0] += int(mark[i])
    p.sort(reverse=True)
    s = [str(m-p[i][1]) for i in range(m)]
    print " ".join(s)

Submission status: Accepted

Solution code:
while 1:
	n,m=map(int,raw_input().split())
	if n==0:break
	h={i:0 for i in range(m)}
	for i in range(n):
		a=map(int,raw_input().split())
		for j in range(m):
			h[j]+=a[j]
	ans=[k[0]+1 for k in sorted(h.items(),key=lambda x:x[1],reverse=True)]
	print " ".join(map(str,ans))

Submission status: Accepted

Solution code:
while True :
    n, m = map(int, input().split())
    if n == 0 and m == 0 :
        break
    
    ans = [0] * m
    for i in range(n) :
        tmp = list(map(int, input().split()))
        for j in range(m) :
            ans[j] += tmp[j]
    
    sort_ans = sorted(ans, reverse=True)
    index_ans = []
    for i in range(m) :
        index_ans.append(ans.index(sort_ans[i])+1)
        ans[ans.index(sort_ans[i])]=-1
    print(*index_ans)

Submission status: Accepted

Solution code:
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


class Info:
    def __init__(self,arg_loc,arg_num):
        self.loc = arg_loc
        self.num = arg_num

    def __lt__(self,another):
        if self.num != another.num:
            return self.num > another.num
        else:
            return self.loc < another.loc

while True:

    N,M = map(int,input().split())
    if N == 0 and M == 0:
        break

    table = [0]*M

    for row in range(N):
        input_array = list(map(int,input().split()))
        for col in range(M):
            if input_array[col] == 1:
                table[col] += 1

    info = []
    for i in range(M):
        info.append(Info(i+1,table[i]))

    info.sort()

    print("%d"%(info[0].loc),end="")
    for i in range(1,M):
        print(" %d"%(info[i].loc),end="")
    print()

Submission status: Accepted

Solution code:
def f():
    N, M = map(int, input().split())
    if N == 0:
        return -1
    A = [0] * M
    for i in range(N):
        T = [int(i) for i in map(int, input().split())]
        for j in range(M):
            if T[j] == 1:
                A[j] += 1

    B = sorted([(v, i + 1) for i, v in enumerate(A)], key=lambda t:(t[0], -t[1]), reverse=True)
    print(' '.join([str(t[1]) for t in B]))
    return 1


def main():
    while True:
        ret = f()
        if ret == -1:
            return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
while (n!=0 or m!=0):
    vote = [[0, i] for i in range(m)]
    for i in range(n):
        v_l = list(map(int, input().split()))
        for j, v in enumerate(v_l):
            if v == 1:
                vote[j][0] += 1
    vote = sorted(vote, key=lambda x:x[0], reverse=True)
    for i in range(m):
        if i != m-1:
            print("{} ".format(vote[i][1]+1), end="")
        else:
            print("{}".format(vote[i][1]+1), end="")
    print()
    n,m = map(int, input().split())

Submission status: Accepted

Solution code:
while True:
    n,m = [int(x) for x in input().split()]
    if n == 0 and m == 0:
        break
    L = [0] * m
    for _ in range(n):
        l = [int(x) for x in input().split()]
        for i in range(m):
            L[i] += l[i]

    M=[]
    for i, j in enumerate(L,1):
        M.append((i,j))

    M.sort(key=lambda x: (-x[1],x[0]) )
    print( *[ x for x, y in M] )

Submission status: Accepted

Solution code:
enqu = []
n = m = 0

def solve():
    score = [ sum(enqu[i][j] for i in range(0, n)) for j in range(0, m)]
    x = [ [j + 1, score[j]] for j in range(0, m)]
    x.sort(key = lambda y: y[1], reverse=True)
    print(" ".join(list(map(lambda y: str(y[0]), x))))
    

while True:
    enqu = []
    line = input()
    n, m = map(int, line.split())
    if n == 0 and m == 0:
        break
    for _ in range(0, n):
        answer = list(map(int, list(input().split())))
        enqu.append(answer)
    solve()

Submission status: Accepted

Solution code:
while 1:
    n,m=map(int,input().split())
    if n==m==0:break
    ans=[[0,i+1] for i in range(m)]
    for i in range(n):
        a=list(map(int,input().split()))
        for j in range(m):
            if a[j]==1:
                ans[j][0]-=1
    ans.sort()
    ans2=[]
    for i in ans:
        ans2.append(i[1])
    print(' '.join(map(str, ans2)))

Submission status: Runtime Error

Solution code:
while True:
	students,places = map(int,raw_input().split())
	if students=0 and places~0:
		break
	res = dict(zip(range(places),[0]*places))
	for i in range(students):
		points = map(int,raw_input().split())
		for j in range(places):
			res[j] += points[j]
	for k,v in sorted(res.items(),key=lambda x:x[1], reverse=True):
		print k,

Submission status: Runtime Error

Solution code:
while True:
	students,places = map(int,raw_input().split())
	if students == 0 and places =~ 0:
		break
	res = dict(zip(range(places),[0]*places))
	for i in range(students):
		points = map(int,raw_input().split())
		for j in range(places):
			res[j] += points[j]
	for k,v in sorted(res.items(),key=lambda x:x[1], reverse=True):
		print k,
	print "\n"

Submission status: Runtime Error

Solution code:
while True:
	students,places = map(int,raw_input().split())
	if students == 0 and places == 0:
		break
	res = dict(zip(range(1,places+1),[0]*places))
	for i in range(students):
		points = map(int,raw_input().split())
		for j in range(1,places+1):
			res[j] += points[j]
	for k,v in sorted(res.items(),key=lambda x:x[1], reverse=True):
		print k,
	print "\n"

Submission status: Runtime Error

Solution code:
N, M = map(int, raw_input().split())

def max_vote(places):
  max_index = places.index(max(places))
  places[max_index] = -1
  return max_index + 1, places

while 1:
  places = []
  for m in  range(M):
    places.append(0)
  for n in N:
    votes = map(int, raw_input().split())
    count = 0
    for vote in votes:
      if vote == 1:
        places[count] += 1
      else:
        pass
      count += 1 
  for m in range(M):
    answer, places = max_vote(places)
    print answer,

Submission status: Runtime Error

Solution code:
def max_vote(places):
  max_index = places.index(max(places))
  places[max_index] = -1
  return max_index + 1, places

while 1:
  N, M = map(int, raw_input().split())
  if N ==0, M ==0: break
  places = []
  for m in  range(M):
    places.append(0)
  for n in N:
    votes = map(int, raw_input().split())
    count = 0
    for vote in votes:
      if vote == 1:
        places[count] += 1
      else:
        pass
      count += 1 
  for m in range(M):
    answer, places = max_vote(places)
    print answer,

Submission status: Runtime Error

Solution code:
def max_vote(places):
  max_index = places.index(max(places))
  places[max_index] = -1
  return max_index + 1, places

while 1:
  N, M = map(int, raw_input().split())
  if N ==0 and M ==0: break
  places = []
  for m in  range(M):
    places.append(0)
  for n in N:
    votes = map(int, raw_input().split())
    count = 0
    for vote in votes:
      if vote == 1:
        places[count] += 1
      else:
        pass
      count += 1 
  for m in range(M):
    answer, places = max_vote(places)
    print answer,

Submission status: Runtime Error

Solution code:
def max_vote(places):
  max_index = places.index(max(places))
  places[max_index] = -1
  return max_index + 1, places

while 1:
  N, M = map(int, raw_input().split())
  if N ==0 and M ==0: break
  places = []
  for m in  range(M):
    places.append(0)
  for n in N:
    votes = map(int, raw_input().split())
    count = 0
    for vote in votes:
      if vote == 1:
        places[count] += 1
      else:
        pass
      count += 1 
  for m in range(M):
    answer, places = max_vote(places)
    print answer,
  print

Submission status: Runtime Error

Solution code:
while 1:
  n, m = map(int, raw_input())
  if n == 0 and m == 0:
    break
  places = dict(zip(range(m), [0]*m))
  for i in range(n):
    vote = map(int,raw_input().split()) 
    for j in range(m):
      places[j] += vote[j]
  for k, v sorted(a.items,key=lambda x:x[1],reverse=1):
    print k+1
  print

Submission status: Runtime Error

Solution code:
while 1:
  n, m = map(int, raw_input().split())
  if n == 0 and m == 0:
    break
  places = dict(zip(range(m), [0]*m))
  for i in range(n):
    vote = map(int,raw_input().split()) 
    for j in range(m):
      places[j] += vote[j]
  for k, v sorted(a.items,key=lambda x:x[1],reverse=1):
    print k+1
  print

Submission status: Runtime Error

Solution code:
while 1:
  n, m = map(int, raw_input().split())
  if n == 0 and m == 0:
    break
  places = dict(zip(range(m), [0]*m))
  for i in range(n):
    vote = map(int,raw_input().split()) 
    for j in range(m):
      places[j] += vote[j]
  for k, v sorted(places.items,key=lambda x:x[1],reverse=1):
    print k+1
  print

Submission status: WA: Presentation Error

Solution code:
while True:
	students,places = map(int,raw_input().split())
	if students == 0 and places == 0:
		break
	res = dict(zip(range(places),[0]*places))
	for i in range(students):
		points = map(int,raw_input().split())
		for j in range(places):
			res[j] += points[j]
	for k,v in sorted(res.items(),key=lambda x:x[1], reverse=True):
		print k+1,
	print "\n"