You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
484 B

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):
if len(inits[i]) != len(answer): all_ok = False
if all_ok: break
print(len(answer)); print(" ".join(map(str, sorted(answer))))