Problem: The problem uses a simplified TCP/IP address model, please read the statement carefully.

An IP address is a 32-bit integer, represented as a group of four decimal 8-bit integers (without leading zeroes), separated by commas. For example, record 0.255.1.123 shows a correct IP address and records 0.256.1.123 and 0.255.1.01 do not. In the given problem an arbitrary group of four 8-bit integers is a correct IP address.

Our hero Polycarpus still works as a system administrator in some large corporation. He likes beautiful IP addresses. To check if some IP address is beautiful, he should do the following:

  1. write out in a line four 8-bit numbers of the IP address, without the commas; 
  2. check if the resulting string is a palindrome. 



Let us remind you that a palindrome is a string that reads the same from right to left and from left to right.

For example, IP addresses 12.102.20.121 and 0.3.14.130 are beautiful (as strings "1210220121" and "0314130" are palindromes), and IP addresses 1.20.20.1 and 100.4.4.1 are not.

Polycarpus wants to find all beautiful IP addresses that have the given set of digits. Each digit from the set must occur in the IP address at least once. IP address must not contain any other digits. Help him to cope with this difficult task.

Input

The first line contains a single integer n (1 ≤ n ≤ 10) — the number of digits in the set. The second line contains the set of integers a1, a2, ..., an (0 ≤ ai ≤ 9). It is guaranteed that all digits in the set are distinct.

Output

In the first line print a single integer k — the number of beautiful IP addresses that contain the given set of digits. In the following k lines print the IP addresses, one per line in the arbitrary order.

Examples

Input

6
0 1 2 9 8 7


Output

6
78.190.209.187
79.180.208.197
87.190.209.178
89.170.207.198
97.180.208.179
98.170.207.189


Input

1
4


Output

16
4.4.4.4
4.4.4.44
4.4.44.4
4.4.44.44
4.44.4.4
4.44.4.44
4.44.44.4
4.44.44.44
44.4.4.4
44.4.4.44
44.4.44.4
44.4.44.44
44.44.4.4
44.44.4.44
44.44.44.4
44.44.44.44

Solution (in PYTHON):

Solution:
n = int(raw_input())
numStr = raw_input().split()
nums = map(int, numStr)
start = dict()
end = dict()
st = [dict(),dict(),dict()]
endi = [dict(),dict(),dict()]
start[''] = []
end[''] = []
for c in numStr:
    st[0][c] = [c]
    endi[0][c] = [c]
    start[''].append(c)
    end[''].append(c)
for c1 in filter(lambda x: x != '0', numStr):
    for c2 in numStr:
        c12 = c1+c2
        c21 = c2+c1
        st[1][c12] = [c12]
        endi[1][c21] = [c12]
        l = start.get(c1, [])
        l.append(c12)
        start[c1] = l
        l = end.get(c2, [])
        l.append(c12)
        end[c2] = l
        start[''].append(c12)
        end[''].append(c12)
for c1 in filter(lambda x: x in ['1', '2'], numStr):
    for c2 in filter(lambda x: c1 != '2' or x < '6', numStr):
        for c3 in filter(lambda x: c1 != '2' or c2 != '5' or x < '6', numStr):
            c12 = c1+c2
            c32 = c3+c2
            c123 = c12+c3
            c321 = c32+c1
            st[2][c123] = [c123]
            endi[2][c321] = [c123]
            start[c1].append(c123)
            l = start.get(c12, [])
            l.append(c123)
            start[c12] = l
            start[c123] = []
            end[c3].append(c123)
            l = end.get(c32, [])
            l.append(c123)
            end[c32] = l
            end[c321] = []
            start[''].append(c123)
            end[''].append(c123)
            
res = []

def add(c1,c2,c3,c4):
    r = str.format("{}.{}.{}.{}", c1,c2,c3,c4)
    if all(map(lambda ns: ns in r, numStr)):
        res.append(r)
        
for c1 in start['']:
    l1 = len(c1)
    for l1i in range(l1):
        for c4 in endi[l1i].get(c1[:l1i+1], []):
            l4 = len(c4)
            dif = c1[l4:]
            for ldif in range(len(dif)):
                for c3 in endi[len(dif)-ldif-1].get(dif[:len(dif)-ldif], []):
                    rest = dif[len(dif)-ldif:]
                    lr = len(rest)
                    if lr > 0:
                        for c2 in endi[lr-1][rest]:
                            add(c1,c2,c3,c4)
                    for c2 in end[rest]:
                        if lr == 2 or (lr == 0 and c2[0] == c2[-1]) or (lr == 1 and (len(c2) == 2 or c2[0]==c2[1])):
                            add(c1,c2,c3,c4)
            for c3 in end.get(dif, []):
                l3 = len(c3)
                dif23 = c3[:l3-len(dif)][::-1]
                ld23 = len(dif23)
                if ld23 == 3:
                    if c3[0] == c3[1]:
                        for c2 in st[0].get(c3[2], []):
                            add(c1,c2,c3,c4)
                    for c2 in st[1].get(c3[2:0:-1],[]):
                        add(c1,c2,c3,c4)
                if ld23 == 2:
                    for c2 in st[0][c3[1]]:
                        add(c1,c2,c3,c4)
                for c2 in st[ld23-1].get(dif23, []):
                    add(c1,c2,c3,c4)
                for c2 in start.get(dif23, []):
                    if (ld23 == 2) or (ld23 == 1 and (len(c2) == 2 or c2[1] == c2[2])):
                        add(c1,c2,c3,c4)
    for c4 in end.get(c1, []):
        c2start = c4[:-l1][::-1]
        c2sl = len(c2start)
        for l2i in range(c2sl):
            for c2 in st[l2i].get(c2start[:l2i+1], []):
                l2 = len(c2)
                c3st = c2start[l2i+1:]
                lr = len(c3st)
                if lr > 0:
                    for c3 in st[lr-1].get(c3st, []):
                        add(c1,c2,c3,c4)
                for c3 in start[c3st]:
                    if (lr == 0 and c3[0] == c3[-1]) or (lr == 1 and (len(c3) == 2 or c3[1]==c3[2])):
                        add(c1,c2,c3,c4)
        for c2 in start.get(c2start, []):
            l2 = len(c2)
            dif23 = c2[c2sl:]
            ld23 = len(dif23)
            if ld23 == 3:
                if c2[1] == c2[2]:
                    for c3 in st[0].get(c2[0], []):
                        add(c1,c2,c3,c4)
                for c3 in endi[1].get(c2[0:2],[]):
                    add(c1,c2,c3,c4)
            if ld23 == 2:
                for c3 in st[0].get(c2[-2], []):
                    add(c1,c2,c3,c4)
            for c3 in endi[ld23-1].get(dif23, []):
                add(c1,c2,c3,c4)
            for c3 in end.get(dif23, []):
                if (ld23 == 2) or (ld23 == 1 and (len(c3) == 2 or c3[0] == c3[1])):
                    add(c1,c2,c3,c4)
print len(res)
for r in res:
    print r