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;
char xau[20];
bool has[15], good[260];
string str[260];
map<string, bool> res;
int a[15], mask[260];
int n, statemax;
inline bool check(int x) {
  int val = x;
  do {
    if (!has[x % 10]) return false;
    mask[val] |= 1 << (x % 10);
    x /= 10;
  } while (x);
  return true;
}
inline string so_xau(int x) {
  sprintf(xau, "%d", x);
  return xau;
}
bool numb(char s[], int l, int r, int &val) {
  val = 0;
  if (l == r) {
    val = s[l] - '0';
    return good[val];
  }
  if (s[l] == '0') return false;
  int i;
  for ((i) = (l); (i) <= (r); (i)++) val = val * 10 + s[i] - '0';
  return (val < 256) && good[val];
}
void palin(char s[], int len) {
  int i = 0, j = len - 1;
  while (i < j) {
    if (s[i] != s[j]) return;
    i++, j--;
  }
  int k, cur, x, y, z, t;
  string temp;
  for ((i) = (0); (i) <= (((2) < (len - 4) ? (2) : (len - 4))); (i)++)
    for ((j) = (i + 1); (j) <= (((i + 3) < (len - 3) ? (i + 3) : (len - 3)));
         (j)++)
      for ((k) = (j + 1); (k) <= (((j + 3) < (len - 2) ? (j + 3) : (len - 2)));
           (k)++)
        if (len - k - 1 > 0 && len - k - 1 <= 3) {
          if (numb(s, 0, i, x) && numb(s, i + 1, j, y) &&
              numb(s, j + 1, k, z) && numb(s, k + 1, len - 1, t)) {
            temp = str[x] + '.' + str[y] + '.' + str[z] + '.' + str[t];
            res[temp] = true;
          }
        }
}
void palin(char s1[], char s2[], int len) {
  char s[20];
  int i, j;
  for ((i) = 0; (i) < (len); (i)++) s[i] = s1[i];
  for ((j) = (len - 1); (j) >= 0; (j)--) s[i++] = s2[j];
  len += len;
  i = 0, j = len - 1;
  while (i < j) {
    if (s[i] != s[j]) return;
    i++, j--;
  }
  int k, cur, x, y, z, t;
  string temp;
  for ((i) = (0); (i) <= (((2) < (len - 4) ? (2) : (len - 4))); (i)++)
    for ((j) = (i + 1); (j) <= (((i + 3) < (len - 3) ? (i + 3) : (len - 3)));
         (j)++)
      for ((k) = (j + 1); (k) <= (((j + 3) < (len - 2) ? (j + 3) : (len - 2)));
           (k)++)
        if (len - k - 1 > 0 && len - k - 1 <= 3) {
          if (numb(s, 0, i, x) && numb(s, i + 1, j, y) &&
              numb(s, j + 1, k, z) && numb(s, k + 1, len - 1, t)) {
            temp = str[x] + '.' + str[y] + '.' + str[z] + '.' + str[t];
            res[temp] = true;
          }
        }
}
void palin(char s1[], char s2[], int len, int len2) {
  char s[20];
  int i, j;
  for ((i) = 0; (i) < (len); (i)++) s[i] = s1[i];
  for ((j) = (len2 - 1); (j) >= 0; (j)--) s[i++] = s2[j];
  len += len2;
  i = 0, j = len - 1;
  while (i < j) {
    if (s[i] != s[j]) return;
    i++, j--;
  }
  int k, cur, x, y, z, t;
  string temp;
  for ((i) = (0); (i) <= (((2) < (len - 4) ? (2) : (len - 4))); (i)++)
    for ((j) = (i + 1); (j) <= (((i + 3) < (len - 3) ? (i + 3) : (len - 3)));
         (j)++)
      for ((k) = (j + 1); (k) <= (((j + 3) < (len - 2) ? (j + 3) : (len - 2)));
           (k)++)
        if (len - k - 1 > 0 && len - k - 1 <= 3) {
          if (numb(s, 0, i, x) && numb(s, i + 1, j, y) &&
              numb(s, j + 1, k, z) && numb(s, k + 1, len - 1, t)) {
            temp = str[x] + '.' + str[y] + '.' + str[z] + '.' + str[t];
            res[temp] = true;
          }
        }
}
void ktra(int len) {
  if (len >= 4) palin(xau, len);
  palin(xau, xau, len);
  palin(xau, xau, len, len - 1);
}
void dfs(int len, int state) {
  if (len >= 2 && state == statemax) {
    ktra(len);
  }
  if (len == 6) return;
  int i;
  for ((i) = 0; (i) < (n); (i)++) {
    xau[len] = a[i] + '0';
    dfs(len + 1, state | (1 << a[i]));
  }
}
void input() {
  int i;
  scanf("%d", &n);
  statemax = 0;
  for ((i) = 0; (i) < (n); (i)++)
    scanf("%d", &a[i]), has[a[i]] = true, statemax |= (1 << a[i]);
  for ((i) = 0; (i) < (256); (i)++) good[i] = check(i), str[i] = so_xau(i);
  dfs(0, 0);
  printf("%d\n", res.size());
  for (typeof(res.begin()) ite = res.begin(); ite != res.end(); ite++)
    printf("%s\n", ite->first.c_str());
}
int main() {
  input();
  return 0;
}