18 lines
484 B
Python
18 lines
484 B
Python
from __future__ import print_function
|
|
import sys
|
|
|
|
m, s = map(int, sys.stdin.readline().split())
|
|
prefs = [ map(int, line.split()) for line in sys.stdin ]
|
|
inits = [ set() for x in xrange(m) ]
|
|
answer = set()
|
|
|
|
for j in xrange(s):
|
|
for i in xrange(m): answer.add(prefs[i][j])
|
|
all_ok = True
|
|
for i in xrange(m):
|
|
inits[i].add(prefs[i][j])
|
|
if len(inits[i]) != len(answer): all_ok = False
|
|
if all_ok: break
|
|
|
|
print(len(answer)); print(" ".join(map(str, sorted(answer))))
|