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 static java.lang.Math.*;

import java.util.*;

public class C {

	private final static boolean autoflush = false;

	private static final int INF = (int) 1e9;
	public C () {
		int N = sc.nextInt();
		Integer [] D = sc.nextInts();

		for (int d : D)
			C[d] = true;

		if (N == 1 && C[0]) {
			print(1);
			exit("0.0.0.0");
		}

		for(int i : rep(1, 1000000)) {
			String S = "" + i;
			solve(S);
			if (i < 10000 && C[0])
				solve("0" + S);
			if (i < 100 && C[0])
				solve("00" + S);
		}

		print(res.size());
		for (String s : res)
			print(s);
	}

	boolean [] C = new boolean [10];
	List<String> res = new ArrayList<String>();

	void solve(String S) {
		if(!check(S))
			return;

		String S2 = reverse(S);
		solve(S, S2);
		solve(S, S2.substring(1));
	}

	boolean check(String S) {
		boolean [] K = new boolean [10];
		for (int i : rep(S.length()))
			K[S.charAt(i) - '0'] = true;
		return Arrays.equals(C, K);
	}

	void solve(String S1, String S2) {
		char [] Q = (S1 + S2).toCharArray();
		int [] A = new int [4];
		dfs(A, Q, 0, 0);
	}

	void dfs(int [] A, char [] Q, int s, int z) {
		int N = Q.length;
		if (z == 3) {
			if ((A[3] = calc(Q, s, N)) < 256)
				res.add(build(".", A));
		}
		else
			for (int t : rep(s+1, min(s+4, N)))
				if ((A[z] = calc(Q, s, t)) < 256)
					dfs(A, Q, t, z+1);
	}

	int calc(char [] Q, int s, int t) {
		if (t - s > 1 && Q[s] == '0')
			return INF;
		int res = 0;
		for (int i : rep(s, t))
			res = 10*res + (Q[i] - '0');
		return res;
	}

	////////////////////////////////////////////////////////////////////////////////////
	private static int [] rep(int N) { return rep(0, N); }
	private static int [] rep(int S, int T) { if (T <= S) return new int [0]; int [] res = new int [T-S]; for (int i = S; i < T; ++i) res[i-S] = i; return res; }
	private static String reverse (String S) { return new StringBuilder(S).reverse().toString(); }
	////////////////////////////////////////////////////////////////////////////////////
	private final static MyScanner sc = new MyScanner();
	private static class MyScanner {
		private String next() {
			newLine();
			return line[index++];
		}
		private int nextInt() {
			return Integer.parseInt(next());
		}
		private String [] nextStrings() {
			line = null;
			return readLine().split(" ");
		}
		private Integer [] nextInts() {
			String [] L = nextStrings();
			Integer [] res = new Integer [L.length];
			for (int i : rep(L.length))
				res[i] = Integer.parseInt(L[i]);
			return res;
		}
		//////////////////////////////////////////////
		private boolean eol() {
			return index == line.length;
		}
		private String readLine() {
			try {
				return r.readLine();
			} catch (Exception e) {
				throw new Error (e);
			}
		}
		private final java.io.BufferedReader r;
		private MyScanner () {
			this(new java.io.BufferedReader(new java.io.InputStreamReader(System.in)));
		}
		private MyScanner (java.io.BufferedReader r) {
			try {
				this.r = r;
				while (!r.ready())
					Thread.sleep(1);
				start();
			} catch (Exception e) {
				throw new Error(e);
			}
		}
		private String [] line;
		private int index;
		private void newLine() {
			if (line == null || eol()) {
				line = readLine().split(" ");
				index = 0;
			}
		}
	}
	private static void print (Object o, Object... a) {
		printDelim(" ", o, a);
	}
	private static void printDelim (String delim, Object o, Object... a) {
		pw.println(build(delim, o, a));
	}
	private static void exit (Object o, Object... a) {
		print(o, a);
		exit();
	}
	private static void exit() {
		pw.close();
		System.out.flush();
		System.err.println("------------------");
		System.err.println("Time: " + ((millis() - t) / 1000.0));
		System.exit(0);
	}
	////////////////////////////////////////////////////////////////////////////////////
	private static String build (String delim, Object o, Object... a) {
		StringBuilder b = new StringBuilder();
		append(b, o, delim);
		for (Object p : a)
			append(b, p, delim);
		return b.substring(delim.length());
	}
	private static void append(StringBuilder b, Object o, String delim) {
		if (o.getClass().isArray()) {
			int L = java.lang.reflect.Array.getLength(o);
			for (int i : rep(L))
				append(b, java.lang.reflect.Array.get(o, i), delim);
		} else if (o instanceof Iterable<?>)
			for (Object p : (Iterable<?>)o)
				append(b, p, delim);
		else
			b.append(delim).append(o);
	}
	////////////////////////////////////////////////////////////////////////////////////
	private static void start() {
		t = millis();
	}
	private static java.io.PrintWriter pw = new java.io.PrintWriter(System.out, autoflush);
	private static long t;
	private static long millis() {
		return System.currentTimeMillis();
	}
	public static void main (String[] args) {
		new C();
		exit();
	}
}