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

Solution:
import java.io.*;
import java.util.*;
import java.math.*;

public class C {

  int n = 0;
  int k = 0;
  StringBuffer sb = new StringBuffer();

  boolean check0(int [] d, int s, int e) {
    return ((e - s == 1) ||
            ((e - s == 2) && (d[s] != 0)) ||
            ((e - s == 3) && (d[s] != 0) && (d[s] * 100 + d[s + 1] * 10 + d[s + 2]) < 256));
  }

  void check(int [] d) {
    boolean [] td = new boolean [10];
    int kn = 0;
    for (int dd : d) {
      if (!td[dd]) {
        kn++;
        td[dd] = true;
      }
    }

    if (kn < n) {
      return;
    }

    for (int p1 = 1; p1 <= d.length - 2; p1++) {
      for (int p2 = p1 + 1; p2 <= d.length - 1; p2++) {
        for (int p3 = p2 + 1; p3 <= d.length - 0; p3++) {
          if (check0(d, 0, p1) && check0(d, p1, p2) && 
              check0(d, p2, p3) && check0(d, p3, d.length)) {
            for (int i = 1; i <= d.length; i++) {
              sb = sb.append(d[i - 1]);
              if (i == p1 || i == p2 || i == p3) {
                sb = sb.append('.');
              }
            }
            sb = sb.append("\n");

            k++;
          }
        }
      }
    }
  }

  @SuppressWarnings("unchecked")
  public void run() throws Exception {
    n = nextInt();
    int [] a = readInt(n);

    // 4
    if (n <= 2) {
      int [] d4 = new int [4];
      for (int i1 = 0; i1 < n; i1++) {
        for (int i2 = 0; i2 < n; i2++) {
          d4[0] = d4[3] = a[i1];
          d4[1] = d4[2] = a[i2];
          check(d4);
        }
      }
    }

    // 5,6
    if (n <= 3) {
      int [] d5 = new int [5];
      int [] d6 = new int [6];
      for (int i1 = 0; i1 < n; i1++) {
        for (int i2 = 0; i2 < n; i2++) {
          for (int i3 = 0; i3 < n; i3++) {
            d5[0] = d5[4] = a[i1];
            d5[1] = d5[3] = a[i2];
            d5[2] = a[i3];
            check(d5);
  
            d6[0] = d6[5] = a[i1];
            d6[1] = d6[4] = a[i2];
            d6[2] = d6[3] = a[i3];
            check(d6);
          }
        }
      }
    }

    // 7,8
    if (n <= 4) {
      int [] d7 = new int [7];
      int [] d8 = new int [8];
      for (int i1 = 0; i1 < n; i1++) {
        for (int i2 = 0; i2 < n; i2++) {
          for (int i3 = 0; i3 < n; i3++) {
            for (int i4 = 0; i4 < n; i4++) {
              d7[0] = d7[6] = a[i1];
              d7[1] = d7[5] = a[i2];
              d7[2] = d7[4] = a[i3];
              d7[3] = a[i4];
              check(d7);
  
              d8[0] = d8[7] = a[i1];
              d8[1] = d8[6] = a[i2];
              d8[2] = d8[5] = a[i3];
              d8[3] = d8[4] = a[i4];
              check(d8);
            }
          }
        }
      }
    }

    // 9,10
    if (n <= 5) {
      int [] d9 = new int [9];
      int [] d10 = new int [10];
      for (int i1 = 0; i1 < n; i1++) {
        for (int i2 = 0; i2 < n; i2++) {
          for (int i3 = 0; i3 < n; i3++) {
            for (int i4 = 0; i4 < n; i4++) {
              for (int i5 = 0; i5 < n; i5++) {
                d9[0] = d9[8] = a[i1];
                d9[1] = d9[7] = a[i2];
                d9[2] = d9[6] = a[i3];
                d9[3] = d9[5] = a[i4];
                d9[4] = a[i5];
                check(d9);
  
                d10[0] = d10[9] = a[i1];
                d10[1] = d10[8] = a[i2];
                d10[2] = d10[7] = a[i3];
                d10[3] = d10[6] = a[i4];
                d10[4] = d10[5] = a[i5];
                check(d10);
              }
            }
          }
        }
      }
    }

    // 11,12
    if (n <= 6) {
      int [] d11 = new int [11];
      int [] d12 = new int [12];
      for (int i1 = 0; i1 < n; i1++) {
        for (int i2 = 0; i2 < n; i2++) {
          for (int i3 = 0; i3 < n; i3++) {
            for (int i4 = 0; i4 < n; i4++) {
              for (int i5 = 0; i5 < n; i5++) {
                for (int i6 = 0; i6 < n; i6++) {
                  d11[0] = d11[10] = a[i1];
                  d11[1] = d11[9] = a[i2];
                  d11[2] = d11[8] = a[i3];
                  d11[3] = d11[7] = a[i4];
                  d11[4] = d11[6] = a[i5];
                  d11[5] = a[i6];
                  check(d11);
  
                  d12[0] = d12[11] = a[i1];
                  d12[1] = d12[10] = a[i2];
                  d12[2] = d12[9] = a[i3];
                  d12[3] = d12[8] = a[i4];
                  d12[4] = d12[7] = a[i5];
                  d12[5] = d12[6] = a[i6];
                  check(d12);
                }
              }
            }
          }
        }
      }
    }

    println(k);
    println("" + sb);
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new C().run();
    br.close();
    pw.close();
  }

  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { println("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print("" + o); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }
}