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.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] MF = new int[M];
		for (int a = 0; a < N; a++) {
			MF[sc.nextInt() - 1]++;
		}
		Dinic TF = new Dinic(M + M+2,M+M,M+M+1);

		for (int a = 0; a < M; a++) {
			TF.addEdge(TF.src, a, MF[a]);
			for (int b = 0; b < M; b++) {
				if (a != b)
					TF.addEdge(a, b + M, Math.min(MF[a], MF[b]));
			}
			TF.addEdge(a + M, TF.sink, MF[a]);
		}
		System.out.println(TF.flow());
		
		for(int a=0;a<M;a++){
			for(Edge e : TF.graph[a]){
				if(e.v==TF.src)continue;
				long thing = e.cap+e.flow;
				while(thing--!=0){					
					System.out.println((a+1)+" "+(1+e.v-M));
					MF[a]--;
				}
			}
		}
		for(int a=0;a<M;a++){
			while(MF[a]-->0){
				System.out.println((a+1)+" "+(a+1));
			}
		}
		
	}
	static class Dinic{
		ArrayList<Edge>[] graph;
		int N,src,sink;
		long INF = (long)1e18;
		int[] depth;
		boolean[] blocked;
		public Dinic(int _N, int _src, int _sink){
			N = _N;
			src = _src;
			sink = _sink;
			graph = new ArrayList[N];
			for(int i=0;i<N;i++){
				graph[i]=new ArrayList<Edge>();
			}
		}
		public long flow(){
			long res = 0;
			while(bfs()){
				blocked = new boolean[N];
				res += dfs(src,INF);
			}
			return res;
		}
		boolean bfs(){
			Arrays.fill(depth = new int[N],-1);
			Queue<Integer> q = new ArrayDeque<Integer>();
			depth[sink]=0;
			q.add(sink);
			while(!q.isEmpty()){
				int u =  q.poll();
				for(Edge e : graph[u])
					if(depth[e.v]==-1&&e.back.flow<0&&q.add(e.v))
						depth[e.v]=depth[u]+1;
			}
			return depth[src]!=-1;
			
		}
		long dfs(int u, long min){
			if(min<=0)return 0;
			if(u==sink)return min;
			
			long flow=0,totalFlow=0;
			for (Edge e : graph[u])
				if(!blocked[e.v]&&depth[e.v]+1==depth[u]&&e.flow<0)
					if((flow=dfs(e.v,Math.min(min,-e.flow)))>0){
						min -=flow;
						totalFlow+=flow;
						e.flow +=flow;
						e.back.flow -=flow;
					}
			blocked[u] |= min>0;
			return totalFlow;
				
			
			
		}
		
		public void addEdge(int u, int v, long cap){
			Edge forward = new Edge(v,cap);
			Edge back = new Edge (u,0);
			graph[u].add(back.back=forward);
			graph[v].add(forward.back=back);
		}
		
	}
	static class Edge{
		int v;
		long flow;
		long cap;
		Edge back;
		public Edge(int _v, long capp){
			v = _v;
			flow -=capp;
			cap = capp;
		}
	}

}