#include <bits/stdc++.h>
using namespace std;
bool b[10], good[256];
int d[256][3] = {0}, kd[256] = {0};
int mask[256] = {0};
int q[12];
int aw[4444444], ax[4444444], ay[4444444], az[4444444];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 10; ++i) b[i] = false;
  int need = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    b[a] = true;
    need |= (1 << a);
  }
  if (n > 6)
    printf("%d\n", 0);
  else {
    for (int i = 0; i < 256; ++i) {
      int x = i;
      good[i] = true;
      while (x > 0) {
        d[i][kd[i]++] = x % 10;
        if (!b[x % 10]) {
          good[i] = false;
          break;
        }
        mask[i] |= (1 << (x % 10));
        x /= 10;
      }
      if (i == 0) {
        if (!b[i])
          good[i] = false;
        else {
          mask[i] |= (1 << 0);
          kd[i]++;
        }
      }
    }
    int ka = 0;
    for (int w = 0; w < 256; ++w)
      if (good[w])
        for (int x = 0; x < 256; ++x)
          if (good[x])
            for (int y = 0; y < 256; ++y)
              if (good[y]) {
                if ((mask[w] | mask[x] | mask[y]) != need) continue;
                for (int z = 0; z < 256; ++z)
                  if (good[z]) {
                    int ok = 1, u = 0;
                    for (int i = kd[w] - 1; i >= 0; --i) q[u++] = d[w][i];
                    for (int i = kd[x] - 1; i >= 0; --i) q[u++] = d[x][i];
                    for (int i = kd[y] - 1; i >= 0; --i) q[u++] = d[y][i];
                    for (int i = kd[z] - 1; i >= 0; --i) q[u++] = d[z][i];
                    for (int i = 0; i < u; ++i)
                      if (q[i] != q[u - i - 1]) {
                        ok = 0;
                        break;
                      }
                    if (ok) {
                      aw[ka] = w;
                      ax[ka] = x;
                      ay[ka] = y;
                      az[ka] = z;
                      ka++;
                    }
                  }
              }
    printf("%d\n", ka);
    for (int i = 0; i < ka; ++i)
      printf("%d.%d.%d.%d\n", aw[i], ax[i], ay[i], az[i]);
  }
  return 0;
}
