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.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class BeautifulIP {
	static int n;
	static int[] nums;
	static int need;
	static List<int[]> ips = new ArrayList<int[]>();
	
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		n = sc.nextInt();
		if(n>6){
			System.out.println(0);
			return;
		}
		nums = new int[n];
		
		for(int i=0;i<n;i++){
			nums[i] = sc.nextInt();
			need |= (1<<nums[i]);
		}
		
		for(int length=4;length<=12;length++){
			int[] built = new int[length];
			genPal(0,built,length);
		}

		System.out.println(ips.size());
		StringBuffer res = new StringBuffer();
		for(int[] item : ips){
			res.append(String.format("%d.%d.%d.%d\n",item[0],item[1],item[2],item[3]));
		}
		if(ips.size() !=0)
			System.out.println(res);
	}
	
	public static void genPal(int toSet, int[] built, int length){
		if(toSet == (length+1)/2){
			int used = 0;
			for(int b: built){
				used |= (1<<b);
			}
			
			if((used & need) == need){
				divide(0, -1, new int[4],built);
			}
		}else{
			for(int num:nums){
				built[toSet] = built[length-toSet-1] = num;
				genPal(toSet+1, built, length);
			}
		}
	}
	
	//given pal consists of valid numbers
	public static void divide(int toSet, int prevEnd, int[] built, int[] pal){
		if(toSet == 3){
			int elLeft = pal.length-1-prevEnd;
			if(elLeft > 3 || elLeft <1){
				return;
			}else{
				int newTok = pal[prevEnd+1];
				if(pal[prevEnd+1] == 0){
					if(prevEnd+1 != pal.length-1){
						return;
					}
				}else{
					for(int i=prevEnd+2; i<pal.length; i++){
						newTok*=10;
						newTok += pal[i];
					}
				}
				if(newTok <= 255){
					built[3] = newTok;
					ips.add(new int[]{built[0],built[1],built[2],built[3]});
				} 
			}
		}else{
			int start = prevEnd+1;
			if(start >= pal.length-1){
				return;
			}
			if(pal[start] == 0){
				built[toSet] = 0;
				divide(toSet+1, prevEnd+1, built, pal);
			}else{
				for(int end=prevEnd+1; end<Math.min(prevEnd+4, pal.length); end++){
					int newTok = pal[start];
					for(int i=start+1; i<=end; i++){
						newTok*=10;
						newTok += pal[i];
					}
					if(newTok <= 255){
						built[toSet] = newTok;
						divide(toSet+1, end, built, pal);
					}
				}
			}
		}
	}

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}
}