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 <typename T>
inline string toString(T a) {
  ostringstream os("");
  os << a;
  return os.str();
}
template <typename T>
inline long long toLong(T a) {
  long long res;
  istringstream os(a);
  os >> res;
  return res;
}
template <typename T>
inline T SQ(T a) {
  return a * a;
}
template <typename T>
inline T gcd(T a, T b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
template <typename T>
inline unsigned long long bigmod(T a, T b, T m) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0)
    return S(bigmod(a, b / 2, m)) % m;
  else
    return (a % m * bigmod(a, b - 1, m)) % m;
}
template <typename T>
inline vector<string> parse(T str) {
  vector<string> res;
  string s;
  istringstream os(str);
  while (os >> s) res.push_back(s);
  return res;
}
template <typename T>
inline unsigned long long dist(T A, T B) {
  unsigned long long res =
      (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y);
  return res;
}
template <typename T>
inline double cosAngle(T a, T b, T c) {
  double res = a * a + b * b - c * c;
  res = res / (2 * a * b);
  res = acos(res);
  return res;
}
template <typename T>
inline T power(T base, int po) {
  T res = 1;
  if (base == 0) return 0;
  for (int i = (0); i < (po); i++) res *= base;
  return res;
}
template <typename T>
inline bool isOn(T mask, T pos) {
  return mask & (1 << pos);
}
template <typename T>
inline int Off(T mask, T pos) {
  return mask ^ (1 << pos);
}
template <typename T>
inline int On(T mask, T pos) {
  return mask | (1 << pos);
}
vector<int> v;
int n;
int m;
vector<int> tmp;
int mlen;
int KS;
int a, b, c, d;
int low[15];
int high[15];
set<long long> ST;
int tot;
int total;
vector<int> ans[100000];
void three() {
  int i;
  for (i = 1; i <= 3; i++) {
    if (i == 1) {
      low[tot] = 1;
      high[tot] = 2;
    } else {
      low[tot] = 0;
      high[tot] = 9;
    }
    tot++;
  }
}
void two() {
  int i;
  for (i = 1; i <= 2; i++) {
    if (i == 1) {
      low[tot] = 1;
      high[tot] = 9;
    } else {
      low[tot] = 0;
      high[tot] = 9;
    }
    tot++;
  }
}
void one() {
  low[tot] = 0;
  high[tot] = 9;
  tot++;
}
void pp(int x) {
  if (x == 3) three();
  if (x == 2) two();
  if (x == 1) one();
}
int change[15];
int vis[15];
int arr[15];
void solve(int x, int y, int bit, int last) {
  int i, j;
  if (x > y) {
    if ((bit == ((1 << n) - 1))) {
      long long x = 0;
      ans[total].clear();
      long long res = 0;
      for (i = 0; i < a; i++) {
        res = res * 10 + arr[i];
      }
      x = x * 1000 + res;
      ans[total].push_back(res);
      if (res > 255) return;
      res = 0;
      for (j = a; j < a + b; j++) {
        res = res * 10 + arr[j];
      }
      if (res > 255) return;
      ans[total].push_back(res);
      x = x * 1000 + res;
      res = 0;
      for (j = a + b; j < a + b + c; j++) {
        res = res * 10 + arr[j];
      }
      if (res > 255) return;
      ans[total].push_back(res);
      x = x * 1000 + res;
      res = 0;
      for (j = a + b + c; j < mlen; j++) {
        res = res * 10 + arr[j];
      }
      if (res > 255) return;
      ans[total].push_back(res);
      x = x * 1000 + res;
      if (ST.find(x) != ST.end()) return;
      ST.insert(x);
      total++;
      return;
    } else
      return;
  }
  for (i = 0; i < n; i++) {
    if (low[x] <= tmp[i] && high[x] >= tmp[i] && low[y] <= tmp[i] &&
        high[y] >= tmp[i]) {
      int res = 0;
      arr[x] = tmp[i];
      arr[y] = tmp[i];
      if (x - last == 2 && change[x] != change[x + 1]) {
        for (j = last; j <= x; j++) {
          res = res * 10 + arr[j];
        }
      }
      int nl = last;
      if (change[x] != change[x + 1]) nl = x + 1;
      if (res <= 255) {
        solve(x + 1, y - 1, bit | (1 << i), nl);
      }
    }
  }
  return;
}
int main() {
  int i, j, k;
  cin >> n;
  int x, y;
  for (i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  total = 0;
  sort((v).begin(), (v).end());
  tmp = v;
  int lm = (1 << n);
  for (i = 4; i <= 12; i++) {
    m = 0;
    for (int ii = (1); ii < (4); ii++) {
      for (int jj = (1); jj < (4); jj++) {
        for (int kk = (1); kk < (4); kk++) {
          for (int l = (1); l < (4); l++) {
            mlen = ii + jj + kk + l;
            tot = 0;
            a = ii;
            b = jj;
            c = kk;
            d = l;
            pp(a);
            pp(b);
            pp(c);
            pp(d);
            ++KS;
            for (j = 0; j < a; j++) {
              change[j] = 1;
            }
            for (j = a; j < a + b; j++) {
              change[j] = 2;
            }
            for (j = a + b; j < a + b + c; j++) {
              change[j] = 3;
            }
            for (j = a + b + c; j < mlen; j++) {
              change[j] = 4;
            }
            for (int ii = 0, j = mlen - 1; ii < j; ii++, j--) {
              low[ii] = (low[ii] > low[j] ? low[ii] : low[j]);
              high[ii] = (high[ii] > high[j] ? high[j] : high[ii]);
            }
            solve(0, mlen - 1, 0, 0);
          }
        }
      }
    }
  }
  cout << total << endl;
  for (int i = (0); i < (total); i++) {
    for (int j = (0); j < (4); j++) {
      if (j) printf(".");
      printf("%d", ans[i][j]);
    }
    puts("");
  }
  return 0;
}