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: interview

Starter code:

Solutions:
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())
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)


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)

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(' ')]
        #inFile = open('input.txt', 'r')
        #inFile.readline().rstrip()
        #self.childs = inFile.readline().rstrip()

    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)))
        #outFile = open('output.txt', 'w')
        #outFile.write(self.answer)

task = Task()
task.getData()
task.solve()
task.printAnswer()


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)
    else:
        if val == 100:
            _00.append(val)
        else:
            if val % 10 == 0:
                _10.append(val)
            else:
                if 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)
else:
    if _00_ + 1 == k:
        print (k)
        for val in d:
            print (val)
    else:
        if _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])
            else:
                if _10_ > 0:
                    print(_10[0])
                else:
                    if _11_ > 0:
                        print(_11[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, 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))


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)


#!/usr/bin/env python3
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)


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(1e9+7)
eps=1e-6
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)





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

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


# Start writing your code here
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)


# Start writing your code here
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)


3

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()


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)
        else:
            if di < 10:
                a.add(di)
            else:
                if "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()


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=' ')




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())
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)))



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



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



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



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