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.*;
import java.io.*;

public class Main{

    BufferedReader in;
    StringTokenizer str = null;
    PrintWriter out;

    private String next() throws Exception{
    	if (str == null || !str.hasMoreElements())
    	    str = new StringTokenizer(in.readLine());
    	return str.nextToken();
    }
    
    private int nextInt() throws Exception{
	   return Integer.parseInt(next());
    }
    
    int [][]c;
    int n, m;
    boolean used[];
    
    public void run() throws Exception{
    	in = new BufferedReader(new InputStreamReader(System.in));
    	out = new PrintWriter(System.out);
	n = nextInt();
	m = nextInt();
	
	int color[] = new int[n];
	for(int i=0;i<n;i++){
	    color[i] = nextInt()-1;
	}
	int cnt[] = new int[m];
	for(int i=0;i<n;i++){
	    cnt[color[i]]+=2;
	}
	
	c = new int[2*m+2][2*m+2];
	for(int i=0;i<n;i++){
	    c[2*m][color[i]] = cnt[color[i]]/2;
	    c[color[i]+m][2*m+1] = cnt[color[i]]/2;
	}
	
	for(int i=0;i<n;i++){
	    for(int j=0;j<n;j++){
		if (color[i] != color[j]){
		    c[color[i]][color[j]+m] = Integer.MAX_VALUE/2;
		}
	    }
	}
	
	int ret = 0;
	used = new boolean[2*m+2];
	while(true){
	    Arrays.fill(used, false);
	    int flow = find(2*m, 2*m+1);
	    ret+=flow;
	    if (flow == 0) break;
	}
	
	out.println(ret);
	
	for(int i=0;i<m;i++){
	    for(int j=m;j<2*m;j++){
		if (c[i][j] > 0 && c[i][j] != Integer.MAX_VALUE/2){
		    int diff = Integer.MAX_VALUE/2 - c[i][j];
		    for(int k=0;k<diff;k++){
			out.println((i+1) + " " + (j-m+1));
			cnt[i]--;cnt[j-m]--;
		    }
		}
	    }
	}
	
	for(int i=0;i<m;i++){
	    while(cnt[i] > 0){
		out.println((i+1) + " " + (i+1));
		cnt[i]-=2;
	    }
	}
	
	out.close();
    }
    
    Queue<Integer> q;
    final int inf = Integer.MAX_VALUE;
    
    private int find(int source, int sink){
	q = new LinkedList<Integer>();
	q.add(source);
	boolean used[] = new boolean[2*m+2];
	used[source] = true;
	
	int prev[] = new int[2*m+2];
	Arrays.fill(prev, -1);
	
	outer:while(q.size() > 0){
	    int cur = q.poll();
	    for(int i=0;i<2*m+2;i++){
		if (!used[i] && c[cur][i] > 0){
		    q.add(i);
		    used[i] = true;
		    prev[i] = cur;
		    if (i == sink) break outer;
		}
	    }
	}
	int cur = sink, path = inf;
	while(prev[cur] != -1){
	    int x = prev[cur];
	    path = Math.min(path, c[x][cur]);
	    cur = x;
	}
	
	//out.println(path);
	cur = sink;
	while(prev[cur] != -1){
	    //out.print(cur + " ");
	    int x = prev[cur];
	    c[x][cur]-=path;
	    c[cur][x]+=path;
	    cur = x;
	}
	//out.print(cur);
	//out.println();
	return (path == inf) ? 0 : path;
    }

    public static void main(String args[]) throws Exception{
	   new Main().run();
    }
}