Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4.

Vasya has a set of k distinct non-negative integers d_1, d_2, ..., d_{k}.

Vasya wants to choose some integers from this set so that he could sum any two chosen numbers. What maximal number of integers can he choose in the required manner?


-----Input-----

The first input line contains integer k (1 ≤ k ≤ 100) — the number of integers.

The second line contains k distinct space-separated integers d_1, d_2, ..., d_{k} (0 ≤ d_{i} ≤ 100).


-----Output-----

In the first line print a single integer n the maximum number of the chosen integers. In the second line print n distinct non-negative integers — the required integers.

If there are multiple solutions, print any of them. You can print the numbers in any order.


-----Examples-----
Input
4
100 10 1 0

Output
4
0 1 10 100 
Input
3
2 70 3

Output
2
2 70

Difficulty: MEDIUM_HARD
Tags: Complete search

Implementation

Constructive algorithms
Skill types: Complete search

Starter code:

Solutions:
a = int(input())
b = list(map(int, input().split()))
x = []
c = 0
if 0 in b:
	x.append('0')
	b.remove(0)
if 100 in b:
	x.append('100')
	b.remove(100)
for _ in b:
	if 0 < _ < 10:
		x.append(str(_))
		c += 1
		break
for _ in b:
	if _ % 10 == 0:
		x.append(str(_))
		c += 1
		break
if c == 0:
	for _ in b:
		if 10 < _ < 100 and _ % 100 != 0:
			x.append(str(_))
			break
print(len(x))
print(' '.join(x))


import re
import itertools
from collections import Counter, deque

class Task:
	numbers = []
	answer = set()

	def getData(self):
		input()
		self.numbers = [int(x) for x in input().split(' ')]

	def solve(self):
		firstZero = False
		secondZero = False
		for x in self.numbers:
			if x % 100 == 0:
				self.answer.add(x)
				continue
			if x % 10 == 0 and x > 0 and (firstZero == False):
				self.answer.add(x)
				firstZero = True
				continue
			if 0 < x < 10 and secondZero == False:
				self.answer.add(x)
				secondZero = True
		if firstZero == False and secondZero == False:
			for x in self.numbers:
				if x != 0 and x != 100:
					self.answer.add(x)
					break

	def printAnswer(self):
		print(len(self.answer))
		print(re.sub('[\\{\\},]', '', str(self.answer)))
task = Task()
task.getData()
task.solve()
task.printAnswer()


from sys import stdin

def read():
	return list(map(int, stdin.readline().split()))
(n,) = read()
g = [-1 for i in range(8)]
for x in read():
	m = 0
	if x % 10 != 0:
		m += 1
	if x // 10 % 10 != 0:
		m += 2
	if x // 100 != 0:
		m += 4
	g[m] = x
ans = []
for startM in range(8):
	if g[startM] >= 0:
		curA = [g[startM]]
		curM = startM
		for m in [0, 1, 2, 4, 3, 6, 5, 7]:
			if m != startM and g[m] >= 0 and (curM & m == 0):
				curM |= m
				curA.append(g[m])
		if len(curA) > len(ans):
			ans = curA
print(len(ans))
print(' '.join(map(str, ans)))


n = int(input())
arr = list(map(int, input().split()))
l = [-1] * 5
for i in arr:
	if i == 0:
		l[0] = 0
	elif i == 100:
		l[1] = 100
	elif i < 10:
		l[2] = i
	elif i % 10 == 0:
		l[3] = i
	else:
		l[4] = i
l1 = []
if l[0] == 0:
	l1.append(str(l[0]))
if l[1] == 100:
	l1.append(str(l[1]))
if l[2] > -1:
	l1.append(str(l[2]))
if l[3] > -1:
	l1.append(str(l[3]))
if l[4] > -1 and l[3] == -1 and (l[2] == -1):
	l1.append(str(l[4]))
print(len(l1))
print(' '.join(l1))


a = int(input())
mas = input().split()
count1 = 0
count2 = True
Zero = Hungred = Ten = Remain = True
mas2 = []
mas3 = []
final = []
for i in range(len(mas)):
	mas[i] = int(mas[i])
if a == 1:
	print(1)
	print(*mas)
else:
	for i in range(len(mas)):
		if mas[i] == 100 and Hungred:
			Hungred = False
			final.append(mas[i])
		elif mas[i] == 0 and Zero:
			Zero = False
			final.append(mas[i])
		elif (mas[i] % 10 == 0) & Ten:
			Ten = False
			final.append(mas[i])
		elif (mas[i] < 10 != 0) & Remain:
			Remain = False
			final.append(mas[i])
	if Ten == Remain == True:
		for i in range(len(mas)):
			if mas[i] != 100 and mas[i] != 0:
				final.append(mas[i])
				break
		print(len(final))
		print(*final)
	else:
		print(len(final))
		print(*final)


n = int(input())
l = list(map(str, input().split()))
(unitzero, unitothers, single) = (0, 0, 0)
(sin, doub, doubzero) = (-1, -1, -1)
for i in range(n):
	if len(l[i]) == 2 and l[i][1] == '0':
		unitzero += 1
		doubzero = l[i]
	elif len(l[i]) == 2 and l[i] != '0':
		unitothers += 1
		doub = l[i]
	elif l[i] != '0' and l[i] != '100':
		single += 1
		sin = l[i]
ans = 0
arr = list()
if l.count('100') > 0:
	ans = 1
	arr.append('100')
if l.count('0') > 0:
	ans += l.count('0')
	for i in range(l.count('0')):
		arr.append('0')
if unitzero > 0:
	arr.append(doubzero)
	if single > 0:
		ans += 2
		arr.append(sin)
	else:
		ans += 1
elif single > 0:
	ans += 1
	arr.append(sin)
elif unitothers > 0:
	ans += 1
	arr.append(doub)
print(ans)
print(*arr)


k = int(input())
nums = list(map(int, input().split()))
memo = {'cat_1': 0, 'cat_2': 0, 'cat_3': 0, 'cat_4': 0, 'cat_5': 0}
for num in nums:
	if num == 100:
		memo['cat_1'] += 1
	elif num % 10 == 0:
		if num == 0:
			memo['cat_4'] += 1
		else:
			try:
				memo['cat_2'].append(num)
			except Exception as e:
				memo['cat_2'] = [num]
	elif len(str(num)) == 1:
		try:
			memo['cat_3'].append(num)
		except Exception as e:
			memo['cat_3'] = [num]
	else:
		try:
			memo['cat_5'].append(num)
		except Exception as e:
			memo['cat_5'] = [num]
answers = []
if memo['cat_1'] > 0:
	answers.append(100)
if memo['cat_4'] > 0:
	answers.append(0)
if memo['cat_2']:
	answers.append(memo['cat_2'][0])
	if memo['cat_3']:
		answers.append(memo['cat_3'][0])
elif memo['cat_5']:
	answers.append(memo['cat_5'][0])
elif memo['cat_3']:
	answers.append(memo['cat_3'][0])
print(len(answers))
for ans in answers:
	print(ans, end=' ')


k = int(input())
I = list(map(int, input().split()))
_00 = []
_01 = []
_11 = []
_10 = []
d = []
for val in I:
	d.append(val)
	if val == 0:
		_00.append(val)
	elif val == 100:
		_00.append(val)
	elif val % 10 == 0:
		_10.append(val)
	elif val < 10:
		_01.append(val)
	else:
		_11.append(val)
_00_ = len(_00)
_01_ = len(_01)
_11_ = len(_11)
_10_ = len(_10)
if _00_ == k or k == 1:
	print(k)
	for val in d:
		print(val)
elif _00_ + 1 == k:
	print(k)
	for val in d:
		print(val)
elif _01_ > 0 and _10_ > 0:
	print(_00_ + 2)
	for val in _00:
		print(val)
	print(_01[0])
	print(_10[0])
else:
	print(_00_ + 1)
	for val in _00:
		print(val)
	if _01_ > 0:
		print(_01[0])
	elif _10_ > 0:
		print(_10[0])
	elif _11_ > 0:
		print(_11[0])


n = int(input().strip())
lst = list(map(int, input().strip().split()))
l1 = ['0'] * lst.count(0) + ['100'] * lst.count(100)
l2 = []
for i in range(n):
	if lst[i] > 0 and lst[i] < 10:
		l2.append(str(lst[i]))
		break
l3 = []
for i in range(n):
	if lst[i] % 10 == 0 and lst[i] not in [0, 100]:
		l3.append(str(lst[i]))
		break
l4 = []
for i in range(n):
	if lst[i] > 10 and lst[i] < 100 and (lst[i] % 10 != 0):
		l4.append(str(lst[i]))
		break
if len(l2) == 0 and len(l3) == 0:
	l = l1 + l4
else:
	l = l1 + l2 + l3
print(len(l))
print(' '.join(l))


n = int(input())
a = list(map(int, input().split()))
b = []
for i in a:
	if i > 0 and i < 10:
		b += [i]
		break
for i in a:
	if i != 0 and i != 100:
		if i % 10 == 0:
			b += [i]
			break
if len(b) == 0:
	for i in a:
		if i > 10 and i < 100:
			b += [i]
			break
if 0 in a:
	b += [0]
if 100 in a:
	b += [100]
print(len(b))
print(*b)


input()
a = list(map(int, input().split()))
d = []
for i in a:
	if i in range(1, 10):
		d += [i]
		break
for i in a:
	if i in range(10, 100, 10):
		d += [i]
		break
if len(d) == 0:
	for i in a:
		if i not in (0, 100):
			d += [i]
			break
if 100 in a:
	d += [100]
if 0 in a:
	d += [0]
print(len(d))
print(*d)


from collections import defaultdict
n = int(input())
arr = [int(x) for x in input().split()]
ans = []
d = defaultdict(bool)
for i in arr:
	if i == 0:
		ans.append(i)
	elif i % 100 == 0 and (not d[100]):
		d[100] = True
		ans.append(i)
	elif i % 10 == 0 and (not d[10]):
		d[10] = True
		ans.append(i)
if d[10]:
	for i in arr:
		if '0' not in str(i) and len(str(i)) == 1:
			ans.append(i)
			break
else:
	for i in arr:
		if '0' not in str(i):
			ans.append(i)
			break
print(len(ans))
print(*ans)


k = int(input())
l = list(map(int, input().split()))
zero = -1
big = -1
first = -1
second = -1
other = -1
for v in l:
	if v == 0:
		zero = 0
	elif v == 100:
		big = 100
	elif v < 10:
		first = v
	elif v % 10 == 0:
		second = v
	else:
		other = v
out = []
if zero != -1:
	out.append(0)
if big != -1:
	out.append(big)
if first != -1:
	out.append(first)
if second != -1:
	out.append(second)
if first == -1 and second == -1 and (other != -1):
	out.append(other)
print(len(out))
print(' '.join(map(str, out)))


k = int(input())
zlist2 = [int(d) for d in input().split()]
zlist2.sort()
if k == 1:
	print(k)
	print(str(zlist2[0]))
	exit()
res = []
dicti = {}
dicti[0] = False
dicti[100] = True
dicti['0-10'] = False
dicti['10-100'] = False
cnt = 0
for x in zlist2:
	if x == 0:
		res.append('0')
	elif x == 100:
		res.append('100')
	if 0 < x < 10 and dicti['0-10'] == False:
		cnt += 1
		res.append(str(x))
		dicti['0-10'] = True
	if 9 < x < 100 and dicti['10-100'] == False and (x % 10 == 0):
		cnt += 1
		res.append(str(x))
		dicti['10-100'] = True
if cnt == 0:
	for y in zlist2:
		if 9 < y < 100 and y % 10 != 0:
			res.append(str(y))
			break
print(len(res))
print(' '.join(res))


k = int(input())
dk = list(map(int, input().split()))
ans = []
if 0 in dk:
	ans.append(0)
if 100 in dk:
	ans.append(100)
f1 = False
for q in dk:
	if 0 < q < 10:
		ans.append(q)
		f1 = True
		break
f2 = False
for q in dk:
	if 9 < q < 100 and q % 10 == 0:
		ans.append(q)
		f2 = True
		break
if not f1 and (not f2):
	for j in dk:
		if j != 0 and j != 100:
			ans.append(j)
			break
print(len(ans))
print(*ans)


k = int(input())
ds = list(map(int, input().split()))
es = []
bs = [False, False, False]
for d in ds:
	assert 0 <= d <= 100
	if d == 0:
		es.append(d)
	elif 1 <= d <= 9:
		if not bs[0]:
			bs[0] = True
			es.append(d)
	elif 10 <= d <= 99 and d % 10 == 0:
		if not bs[1]:
			bs[1] = True
			es.append(d)
	elif d == 100:
		if not bs[2]:
			bs[2] = True
			es.append(d)
for d in ds:
	if not bs[0] and (not bs[1]):
		if 10 <= d <= 99 and d % 10 != 0:
			bs[0] = True
			bs[1] = True
			es.append(d)
print(len(es))
print(*es)


def main():
	k = int(input())
	if k == 0:
		print('0')
		return
	d = list(map(int, input().split(' ')))
	s = []
	se = set()
	a = set()
	b = set()
	c = set()
	for di in d:
		if di == 0 or di == 100:
			se.add(di)
		elif di < 10:
			a.add(di)
		elif '0' in list(str(di)):
			b.add(di)
		else:
			c.add(di)
	if len(a) > 0:
		se.add(list(a)[0])
	if len(b) > 0:
		se.add(list(b)[0])
	if len(a) == 0 and len(b) == 0 and (len(c) > 0):
		se.add(list(c)[0])
	print(len(se))
	print(' '.join(list(map(str, sorted(list(se))))))
main()


def fn(a, b):
	(a, b) = ((3 - len(a)) * '0' + a, (3 - len(b)) * '0' + b)
	for i in range(3):
		if a[i] != '0' and b[i] != '0':
			return False
	return True
n = int(input())
a = list(map(str, input().split()))
ans1 = []
temp = []
ans2 = 0
for i in range(n):
	temp = [a[i]]
	for j in range(n):
		if fn(a[i], a[j]) and a[i] != a[j]:
			c = 0
			for k in temp:
				if fn(k, a[j]):
					c += 1
			if c == len(temp):
				temp.append(a[j])
	if len(temp) > ans2:
		ans1 = temp
		ans2 = len(temp)
print(ans2)
print(' '.join(ans1))


n = int(input())
b = []
f1 = 0
f2 = 0
f0 = 0
f100 = 0
tmp = 0
val = 0
for x in input().split():
	val = int(x)
	if val == 0:
		b.append(val)
		f0 = 1
	elif val == 100:
		b.append(val)
		f100 = 1
	elif val > 0 and val < 10 and (not f1):
		b.append(val)
		f1 = 1
	elif val >= 10 and val < 100 and (val % 10 == 0) and (not f2):
		b.append(val)
		f2 = 1
	else:
		tmp = val
if not f1 and (not f2) and (tmp != 0) and (tmp != 100):
	b.append(tmp)
if len(b) == 0:
	b.append(val)
print(len(b))
for i in range(len(b)):
	print(b[i], end=' ')
print()


k = int(input())
d = list(map(int, input().split()))
ans = []
if 0 in d:
	ans.append(0)
if 100 in d:
	ans.append(100)
a = 0
b = 0
c = 0
for i in range(k):
	if d[i] != 0 and d[i] != 100:
		if len(str(d[i])) == 1:
			a = d[i]
		if d[i] % 10 == 0:
			b = d[i]
		if len(str(d[i])) == 2:
			c = d[i]
if a and b:
	ans.extend([a, b])
elif a:
	ans.append(a)
elif b:
	ans.append(b)
elif c:
	ans.append(c)
print(len(ans))
if ans:
	print(*ans)


n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = []
k = [1, 10, 100]
for i in a:
	check = True
	for j in ans:
		for x in k:
			if i // x % 10 * (j // x % 10) > 0:
				check = False
	if check:
		ans.append(i)
print(len(ans))
print(*ans)


k = int(input())
l = list(map(int, input().split()))
r = 0
e = 0
l.sort()
q0 = 0
q1 = 0
q11 = 0
q10 = 0
q100 = 0
r1 = []
for i in range(k):
	if l[i] == 0:
		q0 = q0 + 1
	elif l[i] > 0 and l[i] < 10:
		q1 = q1 + 1
	elif l[i] == 100:
		q100 = q100 + 1
	elif l[i] % 10 == 0:
		q10 = q10 + 1
	elif l[i] > 10 and l[i] % 10 != 0:
		q11 = q11 + 1
if q0 > 0:
	r1.append(0)
	r = r + 1
if q100 > 0:
	r1.append(100)
	r = r + 1
temp = r
if q10 > 0:
	for i in range(k):
		if l[i] > 9 and l[i] < 100 and (l[i] % 10 == 0):
			r = r + 1
			e = 1
			r1.append(l[i])
			break
temp1 = r
if q1 > 0:
	for i in range(k):
		if l[i] > 0 and l[i] < 10:
			r = r + 1
			r1.append(l[i])
			break
if r == 0 or (temp1 == r and q11 > 0 and (q0 > 0 or q100 > 0) and (e == 0)):
	for i in range(k):
		if l[i] > 10 and l[i] % 10 != 0:
			r = r + 1
			r1.append(l[i])
			break
print(r)
for i in range(r):
	print(r1[i], end=' ')


num = int(input())
arr = input().split(' ')
nums = []
for i in range(0, len(arr)):
	nums.append(int(arr[i]))
ans = []
case = [0, 0, 0, 0]
if 100 in nums:
	ans.append(100)
	case[0] = 1
if 0 in nums:
	ans.append(0)
	case[3] = 1
for i in nums:
	if i % 10 == 0 and i < 100 and (i != 0):
		ans.append(i)
		case[1] = 1
		break
for i in nums:
	if i < 10 and i != 0:
		ans.append(i)
		case[2] = 1
		break
if case[1] == 0 and case[2] == 0:
	for i in nums:
		if i > 10 and i != 100:
			ans.append(i)
			break
print(len(ans))
for i in range(0, len(ans)):
	ans[i] = str(ans[i])
print(' '.join(ans))


n = int(input())
incep = list(map(int, input().split()))
incep.sort()
x = []
if incep[0] == 0:
	x.append(0)
if incep[-1] == 100:
	x.append(100)
flag1 = 0
flag2 = 0
p = 0
for k in range(n):
	if incep[k] == 0 or incep[k] == 100:
		continue
	elif flag1 == 0 and incep[k] < 10:
		x.append(incep[k])
		flag1 = 1
	elif flag2 == 0 and incep[k] % 10 == 0:
		x.append(incep[k])
		flag2 = 1
		break
	elif flag1 == 0 and flag2 == 0 and (p == 0):
		p = incep[k]
if flag2 == 0 and flag1 == 0 and (p != 0):
	x.append(p)
x.sort()
print(len(x))
stri = ''
for k in x:
	stri = stri + str(k) + ' '
print(stri[:-1])


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log, trunc
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
arr = inp().split()
(f1, f2, f3) = (False, False, False)
ansl = []
for i in arr:
	if i in ['0', '100']:
		ansl.append(i)
	elif not f1 and i[-1] == '0':
		ansl.append(i)
		if len(i) > 1:
			f1 = True
	elif not f2 and len(i) == 1:
		ansl.append(i)
		f2 = True
	else:
		f3 = True
		x = i
if f3 and (not f1) and (not f2):
	ansl.append(x)
print(len(ansl))
print(*ansl)


n = int(input())
arr = list(map(int, input().split()))
t = []
flag = 0
if 0 in arr:
	t.append(0)
if 100 in arr:
	t.append(100)
for i in range(n):
	if arr[i] > 0 and arr[i] < 10:
		t.append(arr[i])
		flag = 1
		break
for i in range(n):
	if arr[i] % 10 == 0 and arr[i] > 0 and (arr[i] < 100):
		t.append(arr[i])
		flag = 1
		break
if flag == 0:
	for i in range(n):
		if arr[i] > 10 and arr[i] < 100:
			t.append(arr[i])
			break
print(len(t))
for i in range(len(t)):
	print(t[i], end=' ')


n = int(input())
arr = []
flag = flag1 = False
l = list(map(int, input().strip().split()))
freq = [0] * 101
for i in range(len(l)):
	if l[i] == 0 or l[i] == 100:
		arr.append(l[i])
	elif l[i] < 10:
		if not flag:
			arr.append(l[i])
		flag = True
	elif l[i] % 10 == 0:
		if not flag1:
			arr.append(l[i])
		flag1 = True
if not flag1 and (not flag):
	for i in range(1, 100):
		if i in l:
			arr.append(i)
			break
print(len(arr))
for i in arr:
	print(i, end=' ')


k = int(input())
a = ['0' * (3 - len(i)) + i for i in input().split()]
e = 0
f = []

def c(a, p=[], d=0):
	global e, f
	g = [1] * 101
	for i in p:
		g[int(i)] = 0
	for i in a:
		if g[int(i)] == 1:
			for j in p:
				z = 0
				for l in range(3):
					if '0' not in i[l] + j[l]:
						z = 1
						break
				if z:
					break
			else:
				c(a, p + [i], d + 1)
			if d == 0:
				c(a, [i], 1)
	if d > e:
		e = d
		f = [int(i) for i in p]
c(a)
print(e)
print(*f)


n = int(input())
a = input().split()
ans = ''
cnt = 0
XO = ''
OX = ''
XX = ''
for i in a:
	if i == '100' or i == '0':
		ans += i + ' '
		cnt += 1
	else:
		if len(i) == 1:
			OX = i
		if len(i) == 2:
			if int(i) % 10 == 0:
				XO = i
			else:
				XX = i
if OX == '' and XO == '' and (XX != ''):
	cnt += 1
	ans += XX + ' '
else:
	if XO != '':
		ans += XO + ' '
		cnt += 1
	if OX != '':
		cnt += 1
		ans += OX + ' '
print(cnt)
print(ans)


n = int(input())
a = sorted(list(map(int, input().split())))
b = set()
for x in a:
	if all((all((('%03d' % x)[i] == '0' or ('%03d' % t)[i] == '0' for i in range(3))) for t in b)):
		b.add(x)
print(len(b))
print(' '.join(map(str, b)))


import math, re, sys, string, operator, functools, fractions, collections
sys.setrecursionlimit(10 ** 7)
RI = lambda x=' ': list(map(int, input().split(x)))
RS = lambda x=' ': input().rstrip().split(x)
dX = [-1, 1, 0, 0, -1, 1, -1, 1]
dY = [0, 0, -1, 1, 1, -1, -1, 1]
mod = int(1000000000.0 + 7)
eps = 1e-06
pi = math.acos(-1.0)
MAX = 100
k = RI()
d = RI()
cnt = [0] * 5
a = []
for i in d:
	if i == 0:
		cnt[0] = 1
	elif i == 100:
		cnt[1] = 1
	elif i < 10:
		cnt[2] = i
	elif i % 10 == 0:
		cnt[3] = i
	else:
		cnt[4] = i
if cnt[0]:
	a.append(0)
if cnt[1]:
	a.append(100)
if cnt[2]:
	a.append(cnt[2])
if cnt[3]:
	a.append(cnt[3])
elif not cnt[2] and (not cnt[3]) and cnt[4]:
	a.append(cnt[4])
print(len(a))
print(*a)


size = int(input())
(z, on, pos) = (set(), [], 0)
for x in sorted(input().split(), key=lambda x: len(x)):
	if '0' in x:
		cunt = x.find('0', pos)
		if cunt != -1:
			z.add(x)
			pos = cunt + 1
	else:
		on.append(x)
if z:
	cat = list(filter(lambda x: len(x) == 2, z))
	cat = len(cat[0]) if cat else 0
	for o in on:
		if cat == 2:
			if len(o) == 1:
				z.add(o)
				break
		else:
			z.add(o)
			break
	print(len(z))
	print(' '.join(z))
else:
	print(1)
	print(on[0])


def check(a, b):
	while a and b:
		if a % 10 and b % 10:
			return False
		a //= 10
		b //= 10
	return True
K = int(input())
d = sorted(map(int, input().split()))
flag = False
if d and (not d[0]):
	flag = True
	del d[0]
ans = [d[0]] if d else []
for i in range(len(d)):
	for j in range(i):
		if check(d[i], d[j]):
			for k in range(j):
				if check(d[i], d[k]) and check(d[j], d[k]):
					ans = [d[i], d[j], d[k]]
			if len(ans) < 2:
				ans = [d[i], d[j]]
if flag:
	ans.append(0)
print(len(ans))
print(*ans)


n = int(input())
list1 = list(map(int, input().split()))
c = 0
ll = []
ff = 0
if 0 in list1:
	ll.append(0)
	c += 1
if 100 in list1:
	ll.append(100)
	c += 1
for i in range(n):
	if list1[i] % 10 == 0 and 10 <= list1[i] < 100:
		c += 1
		ll.append(list1[i])
		break
else:
	for i in range(n):
		if 10 <= list1[i] < 100:
			c += 1
			ff = 1
			ll.append(list1[i])
			break
for i in range(n):
	if ff == 0:
		if list1[i] % 10 != 0 and 1 <= list1[i] <= 9:
			c += 1
			ll.append(list1[i])
			break
if c != 0:
	print(c)
	print(*ll)
else:
	print(1)
	print(list1[0])


def strange_addition(k_int, integer_list) -> None:
	place_value_1 = set()
	place_value_1_candidates = set()
	for each in integer_list:
		if each % 10 == 0:
			place_value_1.add(each)
		else:
			place_value_1_candidates.add(each)
	max_set = set()
	if len(place_value_1_candidates) > 0:
		for each in place_value_1_candidates:
			place_value_2 = set(place_value_1)
			place_value_2.add(each)
			final = set()
			other = set()
			for everyone in place_value_2:
				if everyone // 10 % 10 == 0:
					final.add(everyone)
				else:
					other.add(everyone)
			if len(other) > 0:
				final.add(other.pop())
			if len(final) > len(max_set):
				max_set = set(final)
	else:
		place_value_2 = set(place_value_1)
		final = set()
		other = set()
		for everyone in place_value_2:
			if everyone // 10 % 10 == 0:
				final.add(everyone)
			else:
				other.add(everyone)
		if len(other) > 0:
			final.add(other.pop())
		if len(final) > len(max_set):
			max_set = set(final)
	print(len(max_set))
	print(*max_set)
k = int(input())
integers = list(map(int, input().split()))
strange_addition(k, integers)


import sys
import math
from sys import stdin, stdout

def sieve(N):
	primeNumbers = [True] * (N + 1)
	primeNumbers[0] = False
	primeNumbers[1] = False
	i = 2
	while i * i <= N:
		j = i
		if primeNumbers[j]:
			while j * i <= N:
				primeNumbers[j * i] = False
				j += 1
		i += 1
	return primeNumbers

def getPrime(N):
	primes = sieve(N)
	result = []
	for i in range(len(primes)):
		if primes[i]:
			result.append(i)
	return result

def factor(N):
	factors = []
	i = 1
	while i * i <= N:
		if N % i == 0:
			factors.append(i)
			if i != N // i:
				factors.append(N // i)
		i += 1
	return sorted(factors)

def reduceB(b):
	mod = 0
	for i in range(0, len(b)):
		mod = (mod * 10 + ord(b[i])) % 1000000007
	return mod

def gcd(a, b):
	if a < b:
		return gcd(b, a)
	if b == 0:
		return a
	return gcd(b, a % b)

def get_ints_in_variables():
	return map(int, sys.stdin.readline().strip().split())

def get_int():
	return int(input())

def get_ints_in_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

def get_string():
	return sys.stdin.readline().strip()

def containsZero(a):
	if a == 0:
		return True
	while a != 0:
		diff = a % 10
		if diff == 0:
			return True
		a = int(a / 10)
	return False

def main():
	k = int(input())
	d = get_ints_in_list()
	res = []
	for i in range(0, 5):
		res.append(-1)
	for i in range(0, k):
		if d[i] == 0:
			res[0] = d[i]
			continue
		if d[i] == 100:
			res[1] = d[i]
			continue
		if d[i] % 10 == 0:
			res[2] = d[i]
			continue
		if d[i] < 10:
			res[3] = d[i]
			continue
		res[4] = d[i]
	ans = []
	if res[0] != -1:
		ans.append(res[0])
	if res[1] != -1:
		ans.append(res[1])
	if res[2] != -1:
		ans.append(res[2])
	if res[3] != -1:
		ans.append(res[3])
	if res[2] == -1 and res[3] == -1 and (res[4] != -1):
		ans.append(res[4])
	print(len(ans))
	for i in range(0, len(ans)):
		print(ans[i], end=' ')
	print()
main()


n = int(input())
a = list(map(int, input().split()))
c = 0
s = set()
f = -1
b = True
zero = False
h = False
if 0 in a:
	c += 1
	s.add(0)
	zero = True
if 100 in a:
	c += 1
	s.add(100)
	h = True
for i in range(n):
	if a[i] == 0 or a[i] == 100:
		continue
	if a[i] < 10 and f == -1:
		c += 1
		f = 1
		s.add(a[i])
	elif a[i] % 10 == 0 and b:
		c += 1
		s.add(a[i])
		b = False
if c == 2 and h and zero:
	for i in range(n):
		if a[i] != 0 and a[i] != 100:
			c += 1
			f = 1
			s.add(a[i])
if c == 1 and (h or zero):
	f = -1
	for i in range(n):
		if a[i] != 0 and a[i] != 100 and (f == -1):
			c += 1
			f = 1
			s.add(a[i])
if c == 0:
	c = 1
	s.add(a[0])
print(c)
for b in s:
	print(b, end=' ')


n = int(input())
v = list(map(int, input().split()))
cnt = [0] * 101
ans = list()
v.sort()
f10 = 0
f100 = 0
for x in v:
	if x == 0 or x == 100:
		ans.append(x)
	elif x < 10:
		if f10 == 0:
			ans.append(x)
		f10 = 1
	elif x % 10 == 0:
		if f100 == 0:
			ans.append(x)
		f100 = 1
if f10 + f100 == 0:
	for i in range(1, 100):
		if i in v:
			ans.append(i)
			break
print(len(ans))
for i in ans:
	print(i, end=' ')


n = int(input())
l = list(map(int, input().split()))
l1 = []
for i in l:
	if i > 0 and i < 10:
		l1 += [i]
		break
for i in l:
	if i != 0 and i != 100:
		if i % 10 == 0:
			l1 += [i]
			break
if len(l1) == 0:
	for i in l:
		if i > 10 and i < 100:
			l1 += [i]
			break
if 0 in l:
	l1 += [0]
if 100 in l:
	l1 += [100]
print(len(l1))
print(*l1)


(n, t, p) = (int(input()), set(input().split()), [])
if '100' in t:
	p.append('100')
	t.remove('100')
if '0' in t:
	p.append('0')
	t.remove('0')
k = len(p)
for i in range(10, 100, 10):
	if str(i) in t:
		p.append(str(i))
		break
for i in range(1, 10):
	if str(i) in t:
		p.append(str(i))
		break
if k == len(p) and t:
	p.append(t.pop())
print(len(p))
print(' '.join(p))


k = int(input())
arr = list(map(int, input().split()))
res = []
if 0 in arr:
	res.append(0)
if 100 in arr:
	res.append(100)
valid1 = False
for i in arr:
	if 0 < i < 10:
		res.append(i)
		valid1 = True
		break
valid2 = False
for i in arr:
	if 9 < i < 100 and i % 10 == 0:
		res.append(i)
		valid2 = True
		break
if not valid1 and (not valid2):
	for j in arr:
		if j != 0 and j != 100:
			res.append(j)
			break
print(len(res))
print(*res)


import os
import sys
from io import BytesIO, IOBase

def main():
	input()
	a = list(map(int, input().split()))
	(b, c, d, e, f, g) = ([], -1, -1, -1, -1, -1)
	for i in a:
		if i == 0:
			g = i
			b.append(i)
		elif i < 10:
			c = i
		elif i == 100:
			d = i
		elif i % 10 == 0:
			e = i
		else:
			f = i
	if c != -1:
		b.append(c)
	if e != -1:
		b.append(e)
	if d != -1:
		b.append(d)
	if c == -1 and e == -1 and (f != -1):
		b.append(f)
	print(len(b))
	print(*b)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin
inputIdx = 0
input = stdin.read().strip().split()

def nextToken():
	global inputIdx, input
	if inputIdx == len(input):
		exit()
	token = input[inputIdx]
	inputIdx += 1
	return token

def main():
	while True:
		n = int(nextToken())
		s = set([int(nextToken()) for i in range(n)])
		ans = []
		d1 = -1
		d2 = -1
		d3 = -1
		for x in s:
			if x == 0 or x == 100:
				ans.append(x)
			elif 1 <= x and x <= 9:
				d1 = x
			elif x % 10 == 0:
				d2 = x
			else:
				d3 = x
		if d1 != -1 and d2 != -1:
			ans += [d1, d2]
		elif d1 != -1:
			ans.append(d1)
		elif d2 != -1:
			ans.append(d2)
		elif d3 != -1:
			ans.append(d3)
		if len(ans) == 0:
			ans.append(tmp)
		print(len(ans))
		print(' '.join(map(str, ans)))
main()


n = int(input())
l = list(map(int, input().split()))
m = []
f = 0
for i in range(n):
	if l[i] == 0 or l[i] == 100:
		m.append(l[i])
for i in range(n):
	if l[i] > 0 and l[i] < 10:
		m.append(l[i])
		f = 1
		break
for i in range(n):
	if l[i] >= 10 and l[i] < 100 and (l[i] % 10 == 0):
		f = 1
		m.append(l[i])
		break
if f == 0:
	for i in range(n):
		if l[i] >= 10 and l[i] < 100:
			m.append(l[i])
			break
print(len(m))
print(*m)


from sys import stdin
n = int(input())
arr = list(map(int, stdin.readline().split()))
one = []
two = []
ans = []
for x in arr:
	if x == 0 or x == 100:
		ans.append(x)
	elif x < 10:
		one.append(x)
	else:
		two.append(x)
prv = len(ans)
for x in one:
	for y in two:
		if len(ans) != prv:
			break
		if y % 10 == 0:
			ans.append(x)
			ans.append(y)
if len(ans) == prv:
	if len(one) > 0:
		ans.append(one[0])
	elif len(two) > 0:
		ans.append(two[0])
print(len(ans))
for x in ans:
	print(x, end=' ')


n = int(input())
l1 = list(map(int, input().split()))
ans = []
flag = 0
flag1 = 0
for item in l1:
	if item == 100 or item == 0:
		ans.append(item)
	elif item < 10 and flag1 == 0:
		ans.append(item)
		flag1 = 1
	elif item % 10 == 0 and flag == 0:
		ans.append(item)
		flag = 1
if flag == 0 and flag1 == 0:
	for item in l1:
		if item > 10 and item < 100:
			ans.append(item)
			break
print(len(ans))
print(' '.join((str(x) for x in ans)))


x = int(input())
a = input().split()
b = []
l = 0
p = 0
q = 0
r = 0
s = 0
for i in a:
	if int(i) == 0 or int(i) == 100:
		b.append(i)
	elif int(i) < 10 and int(i) > 0:
		p = p + 1
		if p == 1:
			b.append(i)
	elif int(i) >= 10 and int(i) < 100 and (int(i) % 10 == 0):
		q = q + 1
		if q == 1:
			b.append(i)
if p == 0 and q == 0:
	for i in a:
		if int(i) > 9 and int(i) < 100:
			b.append(i)
			break
print(len(b))
for i in b:
	print(i, end=' ')


from collections import *
from math import *
d = dict()
n = int(input())
a = list(map(int, input().split()))
(d['000'], d['001'], d['010'], d['011'], d['100'], d['101'], d['110'], d['111']) = ([], [], [], [], [], [], [], [])
for i in range(n):
	x = ''
	y = a[i]
	while a[i]:
		x += str(int(a[i] % 10 != 0))
		a[i] //= 10
	while len(x) < 3:
		x += '0'
	x = x[::-1]
	d[x] = [y]
(fans, ans) = ([], [])
ans.extend(d['100'] + d['010'] + d['001'] + d['000'])
if len(fans) < len(ans):
	fans = ans
ans = []
ans.extend(d['100'] + d['011'] + d['000'])
if len(fans) < len(ans):
	fans = ans
ans = []
ans.extend(d['110'] + d['001'] + d['000'])
if len(fans) < len(ans):
	fans = ans
ans = []
ans.extend(d['101'] + d['010'] + d['000'])
if len(fans) < len(ans):
	fans = ans
ans = []
ans.extend(d['111'] + d['000'])
if len(fans) < len(ans):
	fans = ans
print(len(fans))
print(*fans)