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;
template <class F, class T>
T convert(F a, int p = -1) {
  stringstream ss;
  if (p >= 0) ss << fixed << setprecision(p);
  ss << a;
  T r;
  ss >> r;
  return r;
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T cube(T x) {
  return x * x * x;
}
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return s == 0 ? 0 : cntbit(s >> 1) + (s & 1);
}
const int bfsz = 1 << 16;
char bf[bfsz + 5];
int rsz = 0;
int ptr = 0;
char gc() {
  if (rsz <= 0) {
    ptr = 0;
    rsz = (int)fread(bf, 1, bfsz, stdin);
    if (rsz <= 0) return EOF;
  }
  --rsz;
  return bf[ptr++];
}
void ga(char &c) {
  c = EOF;
  while (!isalpha(c)) c = gc();
}
int gs(char s[]) {
  int l = 0;
  char c = gc();
  while (isspace(c)) c = gc();
  while (c != EOF && !isspace(c)) {
    s[l++] = c;
    c = gc();
  }
  s[l] = '\0';
  return l;
}
template <class T>
bool gi(T &v) {
  v = 0;
  char c = gc();
  while (c != EOF && c != '-' && !isdigit(c)) c = gc();
  if (c == EOF) return false;
  bool neg = c == '-';
  if (neg) c = gc();
  while (isdigit(c)) {
    v = v * 10 + c - '0';
    c = gc();
  }
  if (neg) v = -v;
  return true;
}
vector<vector<int> > V;
vector<int> T[5];
int f[555];
string str[555];
int doiso(string s) {
  if (s[0] == '0' && s.length() > 1) return 256;
  int res = 0;
  for (int i = 0; i < ((int)s.length()); ++i) {
    res = res * 10 + s[i] - '0';
  }
  return res;
}
string reverse(string x) {
  string res = "";
  for (int i = x.length() - 1; i >= 0; i--) res.push_back(x[i]);
  return res;
}
string doixau(int u) {
  if (u == 0) return "0";
  string res = "";
  while (u > 0) {
    res.push_back(u % 10 + '0');
    u /= 10;
  }
  return reverse(res);
}
string doi1(int a, int b, int len) {
  string res = "";
  res += str[a];
  res += str[b];
  int n = res.length();
  for (int i = (len - 1) >> 1; i >= 0; i--) {
    int j = len - 1 - i;
    if (j < n) {
      if (res[j] != res[i]) return "-1";
    } else
      res.push_back(res[i]);
  }
  return res;
}
string doi2(int a, int b, int len) {
  string res = "", RR = "";
  RR += str[a];
  RR += str[b];
  int n = RR.length();
  res.resize(len);
  for (int i = (len - 1) >> 1; i >= 0; i--) {
    int j = len - 1 - i;
    if (i >= len - n) {
      if (RR[j - len + n] != RR[i - len + n]) return "-1";
      res[i] = RR[j - len + n];
      res[j] = RR[j - len + n];
    } else {
      res[i] = RR[j - len + n];
      res[j] = RR[j - len + n];
    }
  }
  return res;
}
void gen1(int l1, int l2, int r1, int r2) {
  for (int i = 0; i < (((int)(T[l1]).size())); ++i)
    for (int j = 0; j < (((int)(T[l2]).size())); ++j) {
      int a = T[l1][i], b = T[l2][j], A, B;
      string s = doi1(a, b, l1 + l2 + r1 + r2);
      if (s == "-1") continue;
      A = doiso(s.substr(l1 + l2, r1));
      B = doiso(s.substr(l1 + l2 + r1, r2));
      if (f[A] == r1 && f[B] == r2) {
        vector<int> temp;
        temp.push_back(a);
        temp.push_back(b);
        temp.push_back(A);
        temp.push_back(B);
        V.push_back(temp);
      }
    }
}
void gen2(int l1, int l2, int r1, int r2) {
  for (int i = 0; i < (((int)(T[r1]).size())); ++i)
    for (int j = 0; j < (((int)(T[r2]).size())); ++j) {
      int A = T[r1][i], B = T[r2][j], a, b;
      string s = doi2(A, B, l1 + l2 + r1 + r2);
      if (s == "-1") continue;
      a = doiso(s.substr(0, l1));
      b = doiso(s.substr(l1, l2));
      if (f[a] == l1 && f[b] == l2) {
        vector<int> temp;
        temp.push_back(a);
        temp.push_back(b);
        temp.push_back(A);
        temp.push_back(B);
        V.push_back(temp);
      }
    }
}
void init() {
  f[256] = 0;
  for (int i = (0); i <= (9); ++i) {
    T[1].push_back(i);
    f[i] = 1;
  }
  for (int i = (10); i <= (99); ++i) {
    T[2].push_back(i);
    f[i] = 2;
  }
  for (int i = (100); i <= (255); ++i) {
    T[3].push_back(i);
    f[i] = 3;
  }
  for (int i = (0); i <= (255); ++i) str[i] = doixau(i);
  for (int i = (1); i <= (3); ++i)
    for (int j = (1); j <= (3); ++j)
      for (int u = (1); u <= (3); ++u)
        for (int v = (1); v <= (3); ++v) {
          if (i + j >= u + v)
            gen1(i, j, u, v);
          else
            gen2(i, j, u, v);
        }
}
int main() {
  init();
  int n, x;
  int f[15];
  memset(f, 0, sizeof(f));
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    cin >> x;
    f[x] = 1;
  }
  vector<vector<int> > RR;
  for (int i = 0; i < (((int)(V).size())); ++i) {
    int g[15];
    memset(g, 0, sizeof(g));
    for (int j = 0; j < (((int)(V[i]).size())); ++j) {
      int m = V[i][j];
      if (m == 0) g[0] = 1;
      while (m > 0) {
        g[m % 10] = 1;
        m /= 10;
      }
    }
    bool check = true;
    for (int j = 0; j < (10); ++j)
      if (f[j] != g[j]) {
        check = false;
        break;
      }
    if (check) RR.push_back(V[i]);
  }
  cout << ((int)(RR).size()) << endl;
  for (int i = 0; i < (((int)(RR).size())); ++i) {
    for (int j = 0; j < (4); ++j) {
      printf("%d%c", RR[i][j], j == 3 ? '\n' : '.');
    }
  }
  return 0;
}