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.util.*;

//@SuppressWarnings("unused")
public class C {

	private final static boolean autoflush = false;

	Set<String> res = new HashSet<String>();
	boolean [] C = new boolean [10];
	Integer [] D;

	public C () {
		sc.nextInt();
		D = sc.nextInts();

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

		String [] Z = { "0", "00", "000", "0000", "00000" };
		out: for (int x = 0; x < 1000000; ++x) {
			String S1 = "" + x;
			for (int i = 0; i < S1.length(); ++i) {
				char c = S1.charAt(i); int g = c - '0';
				if (!C[g])
					continue out;
			}

			solve(S1);
			if (C[0])
				for (String z : Z)
					if (S1.length() + z.length() <= 6)
						solve(z + S1);
		}

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

	void solve(String S1) {
		int [] K = new int [10]; int missing = 0;
		for (int i = 0; i < S1.length(); ++i)
			++K[S1.charAt(i) - '0'];
		for (int i = 0; i < 10; ++i) {
			if (C[i] && K[i] == 0)
				++missing;
			if (!C[i] && K[i] != 0)
				return;
		}


		String S2 = reverse(S1);
		if (missing == 0) {
			handle(S1 + S2);
			handle(S1 + S2.substring(1));
		}

		if (missing <= 1)
			if (S1.length() < 6)
				for (int d : D)
					handle(S1 + d + S2);
	}


	void handle(String Z) {
		char [] Q = Z.toCharArray(); int N = Q.length;
		if (N < 4 || N > 12)
			return;

		int [] K = new int [10];
		for (int i = 0; i < Q.length; ++i)
			++K[Q[i] - '0'];
		for (int i = 0; i < 10; ++i) {
			if (C[i] && K[i] == 0)
				return;
			if (!C[i] && K[i] != 0)
				return;
		}

		int A1, A2, A3, A4;
		for (int p1 = 1; p1 <= 3; ++p1)
			if (p1 < N) {
				A1 = calc(Q, 0, p1);
				if (A1 < 256)
					for (int p2 = p1+1; p2 <= p1+3; ++p2)
						if (p2 < N) {
							A2 = calc(Q, p1, p2);
							if (A2 < 256)
								for (int p3 = p2+1; p3 <= p2+3; ++p3)
									if (p3 < N) {
										A3 = calc(Q, p2, p3);
										if (A3 < 256)
											for (int p4 = p3+1; p4 <= p3+3; ++p4)
												if (p4 <= N) {
													A4 = calc(Q, p3, p4);
													if (A4 < 256)
														if (p4 == N) {
															String Y = A1 + "." + A2 + "." + A3 + "." + A4;
															res.add(Y);
														}
												}
									}
						}
			}
	}

	int calc(char [] Q, int p, int q) {
		int res = 0;
		if (p == q-1) {
			res = Q[p] - '0';
			return res;
		}

		if (Q[p] == '0')
			return 1000;

		for (int i = p; i < q; ++i)
			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() {
		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.toString().trim();
	}
	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();
	}
}