Problem: A Christmas party in city S. had n children. All children came in mittens. The mittens can be of different colors, but each child had the left and the right mitten of the same color. Let's say that the colors of the mittens are numbered with integers from 1 to m, and the children are numbered from 1 to n. Then the i-th child has both mittens of color ci.

The Party had Santa Claus ('Father Frost' in Russian), his granddaughter Snow Girl, the children danced around the richly decorated Christmas tree. In fact, everything was so bright and diverse that the children wanted to wear mittens of distinct colors. The children decided to swap the mittens so that each of them got one left and one right mitten in the end, and these two mittens were of distinct colors. All mittens are of the same size and fit all the children.

The children started exchanging the mittens haphazardly, but they couldn't reach the situation when each child has a pair of mittens of distinct colors. Vasily Petrov, the dad of one of the children, noted that in the general case the children's idea may turn out impossible. Besides, he is a mathematician and he came up with such scheme of distributing mittens that the number of children that have distinct-colored mittens was maximum. You task is to repeat his discovery. Note that the left and right mittens are different: each child must end up with one left and one right mitten.

Input

The first line contains two integers n and m — the number of the children and the number of possible mitten colors (1 ≤ n ≤ 5000, 1 ≤ m ≤ 100). The second line contains n integers c1, c2, ... cn, where ci is the color of the mittens of the i-th child (1 ≤ ci ≤ m).

Output

In the first line, print the maximum number of children who can end up with a distinct-colored pair of mittens. In the next n lines print the way the mittens can be distributed in this case. On the i-th of these lines print two space-separated integers: the color of the left and the color of the right mitten the i-th child will get. If there are multiple solutions, you can print any of them.

Examples

Input

6 3
1 3 2 2 1 1


Output

6
2 1
1 2
2 1
1 3
1 2
3 1


Input

4 2
1 2 1 1


Output

2
1 2
1 1
2 1
1 1

Solution (in JAVA):

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

public class Main {

	public static void main(String[] args) throws Exception {
		long time = System.nanoTime();

		int n = next();
		int m = next();

		int[] l = new int[m];
		int[] r = new int[m];
		for (int i = 0; i < n; i++) l[next() - 1]++;
		for (int i = 0; i < m; i++) r[i] = l[i];

		int[] ll = new int[n];
		int[] rr = new int[n];
		Arrays.fill(ll, -1);
		Arrays.fill(rr, -1);

		int index = -1;
		for (int i = 0; i < m; i++) if (2*l[i] >= n) index = i;

		if (index >= 0) {
			for (int i = 0; l[index] > 0; i++) {
				ll[i] = index;
				l[index]--;
			}
			for (int i = n - 1; r[index] > 0; i--) {
				rr[i] = index;
				r[index]--;
			}
			index = 0;
			for (int i = 0; i < n; i++) if (ll[i] == -1) {
				while (l[index] == 0) index++;
				ll[i] = index;
				l[index]--;
			}
			index = 0;
			for (int i = 0; i < n; i++) if (rr[i] == -1) {
				while (r[index] == 0) index++;
				rr[i] = index;
				r[index]--;
			}
		} else {
			for (int i = 0; i < n; i++) {
				int il = -1;
				int ir = -1;
				for (int a = 0; a < m && il < 0; a++) if (l[a] > 0)
					for (int b = 0; b < m && il < 0; b++) if (b != a && r[b] > 0) {
						il = a;
						ir = b;
					}

				if (il >= 0) {
					ll[i] = il;
					l[il]--;

					rr[i] = ir;
					r[ir]--;
				} else {
					for (int a = 0; a < m; a++) if (l[a] > 0) il = ir = a;
					for (int j = i; j < n; j++) {
						ll[j] = rr[j] = il;
						l[il]--;
						r[ir]--;
					}
					
					int j = i;
					for (int t = 0; t < i && j < n; t++) if (ll[t] != il && rr[t] != ir) {
						rr[j++] = rr[t];
						rr[t] = ir;
					}

					i = n;
				}
			}
		}
		
		int count = 0;
		for (int i = 0; i < n; i++) if (ll[i] != rr[i]) count++;
		out.println(count);
		for (int i = 0; i < n; i++) out.println((ll[i] + 1) + " " + (rr[i] + 1));




		
//		System.out.println((System.nanoTime() - time)* 1e-9);
		out.close();
	}
	static PrintWriter out = new PrintWriter(System.out);
	
	static BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer in = new StringTokenizer("");

	static String nextToken() throws Exception {
		if (!in.hasMoreTokens()) in = new StringTokenizer(bufferedreader.readLine());
		return in.nextToken();
	}

	static int next()  throws Exception {return Integer.parseInt(nextToken());};
	static int[] next(int n) throws Exception {
		int[] x = new int[n];
		for (int i = 0; i < n; i++) x[i] = next();
		return x;
	}
	static int[][] next(int n, int m) throws Exception {
		int[][] x = new int[n][];
		for (int i = 0; i < n; i++) x[i] = next(m);
		return x;
	}

	static long nextl() throws Exception {return Long.parseLong(nextToken());};
	static long[] nextl(int n) throws Exception {
		long[] x = new long[n];
		for (int i = 0; i < n; i++) x[i] = nextl();
		return x;
	}
	static long[][] nextl(int n, int m) throws Exception {
		long[][] x = new long[n][];
		for (int i = 0; i < n; i++) x[i] = nextl(m);
		return x;
	}

	static double nextd() throws Exception {return Double.parseDouble(nextToken());};
	static double[] nextd(int n) throws Exception {
		double[] x = new double[n];
		for (int i = 0; i < n; i++) x[i] = nextd();
		return x;
	}
	static double[][] nextd(int n, int m) throws Exception {
		double[][] x = new double[n][];
		for (int i = 0; i < n; i++) x[i] = nextd(m);
		return x;
	}

	static String nextline() throws Exception {
		in = new StringTokenizer("");
		return bufferedreader.readLine();
	}

}