while True:
try:
n, k = map(int,input().split())
one_one_list = []
for i in range(k):
one_one_list.append(set(map(int,input().split())))
#5print(one_one_list)
newlist = []
for i in range(len(one_one_list)):
for j in range(i+1,len(one_one_list)):
if one_one_list[i] & one_one_list[j] != set():
newlist.append(one_one_list[i].union(one_one_list[j]))
#print(newlist)
for i in range(len(newlist)):
for j in range(i+1,len(newlist)):
if newlist[i] & newlist[j] != set():
newlist[i] = newlist[i].union(newlist[j])
newlist[j] = newlist[i].union(newlist[j])
for i in range(len(newlist)):
for j in range(len(newlist)):
if i != j:
if newlist[i] == newlist[j]:
newlist[j] = 0
while 0 in newlist:
newlist.remove(0)
print(newlist)
print(len(newlist))
except:
break