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

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int num[10], n, vst[10], ansn, p[12], sp[6];
char ans[N][16];
int split_valid(int st, int end) {
  int k = 0, i, zero = 0;
  for (i = st; i <= end; i++) k = k * 10 + p[i], zero += p[i] == 0;
  if ((k == 0 && zero > 1) || k > 255 || (k && p[st] == 0)) return 0;
  return 1;
}
void split(int pos, int tot) {
  int k = 0, i, j;
  if (pos > 3) {
    if (!split_valid(sp[3] + 1, sp[4])) return;
    for (i = k = 0; i <= 3; i++) {
      for (j = sp[i] + 1; j <= sp[i + 1]; j++) ans[ansn][k++] = p[j] + '0';
      if (i < 3) ans[ansn][k++] = '.';
    }
    ans[ansn++][k] = 0;
    return;
  }
  for (i = sp[pos - 1] + 1; i <= sp[pos - 1] + 3; i++)
    if (4 - pos <= tot - 1 - i && (4 - pos) * 3 >= tot - 1 - i) {
      if (!split_valid(sp[pos - 1] + 1, i)) continue;
      sp[pos] = i;
      split(pos + 1, tot);
    }
}
void check(int tot) {
  int i, cnt = 0;
  memset(vst, 0, sizeof vst);
  for (i = 0; i < tot; i++) vst[p[i]] = 1;
  for (i = 0; i < 10; i++)
    if (vst[i]) cnt++;
  if (cnt < n) return;
  for (i = 0; i < tot; i++) p[2 * tot - 1 - i] = p[i];
  sp[0] = -1, sp[4] = tot * 2 - 1;
  split(1, tot << 1);
  for (i = 0; i < tot; i++) p[2 * tot - 2 - i] = p[i];
  sp[0] = -1, sp[4] = tot * 2 - 2;
  split(1, tot * 2 - 1);
}
void dfs(int has, int tot) {
  if (has >= tot) {
    check(tot);
    return;
  }
  for (int i = 0; i < n; i++) p[has] = num[i], dfs(has + 1, tot);
}
int main() {
  int i;
  while (~scanf("%d", &n)) {
    for (i = 0; i < n; i++) scanf("%d", num + i), vst[i] = 0;
    if (n > 6) {
      puts("0");
      continue;
    }
    for (ansn = 0, i = n; i <= 6; i++) dfs(0, i);
    for (printf("%d\n", ansn), i = 0; i < ansn; i++) puts(ans[i]);
  }
  return 0;
}