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.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Hashtable;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.TreeSet;

public class Q1 {

	public static void main(String[] args)
	{
    	FasterScanner s=new FasterScanner();
    	PrintWriter out=new PrintWriter(System.out);
    	
    	int n=s.nextInt();
    	int m=s.nextInt();
    	
    	int f[] =new int[m+1];
    	
    	for(int i=0;i<n;i++)
    	{
    		f[s.nextInt()]+=2;
    	}
    	
    	
    	int[] l=new int[n];
    	
    	int[] r=new int[n];
    	int[] now=l;
    	int p=0;
    	int ans=-1;
    	int count=0;
    	for(int i=m;i>=0;i--)
    	{
    		if(count>=2*n)
    			break;
    		int c=1;
    		int max=0;
    		
    		for(int j=1;j<=m;j++)
    			if(f[j]>max)
    			{
    				max=f[j];
    				c=j;
    			}
    		if(ans==-1)
    			ans=max;
    		f[c]=0;
    		
    		while(max>0)
    		{
    			now[p]=c;
    			count++;
    			if(count>=2*n)
        			break;
//    			System.out.prin]tln(count+" "+c+" "+l[p]+" "+r[p]);
    			if(now==l)
    				now=r;
    			else now=l;
    			p++;
    			if(p>=n)
    			{
    				p=0;
    				if(n%2==0)
    				{
    				if(now==l)
        				now=r;
        			else now=l;}
    			}
    			max--;
    		}
    	}
    	if(ans>n)
    		ans=2*n-ans;
    		else ans=n;
    	
    	System.out.println(ans);
    	
    	for(int i=0;i<n;i++)
    		System.out.println(l[i]+" "+r[i]);
    	out.close();
	}
	public static boolean compare(boolean b1[],boolean b2[])
	{
		for(int i=0;i<b1.length;i++)
			if(!b1[i] &&  b2[i])
				return false;
		return true;
	}
	public static class SegTree {

		int n;
		long[] t;
		
		public SegTree(int n) {
			this.n=n;
			
			t=new long[2*n];
		}
		
		void build() {  // build the tree
			
			for (int i = n - 1; i > 0; --i)
				t[i]=(t[i<<1]+t[i<<1|1]);
		}

		void modify(int p, long value) {  // set value at position p
		  for (t[p += n] = value; p > 1; p >>= 1) t[p>>1] = (t[p] + t[p^1]);
		}

		long query(int l, int r) {  // sum on interval [l, r)
		  long res=0;
				  
		  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			    if ((l&1)!=0) res+=t[l++];
			    if ((r&1)!=0) res+=t[--r];
			  }
		  return res;
		}
	//	
	//	
	//	
	}
	
	
	public static class UF {
		public int max=1;
		private int[] size;
	    private int[] parent;  // parent[i] = parent of i
	    private byte[] rank;   // rank[i] = rank of subtree rooted at i (never more than 31)
	    private int count;     // number of components
	    public UF(int N) {
	        if (N < 0) throw new IllegalArgumentException();
	        count = N;
	        parent = new int[N];
	        rank = new byte[N];
	        size = new int[N];
	        for (int i = 0; i < N; i++) {
	            parent[i] = i;
	            rank[i] = 0;
	            size[i]=1;
	        }
	    }
	    public void print(int id)
	    {
	    	for(int i=0;i<parent.length;i++)
	    		if(parent[i]==parent[id])
	    			System.out.print(i+" ");
	    	System.out.println();
	    }
	    public int find(int p) {
	        if (p < 0 || p >= parent.length) return -1;
	        while (p != parent[p]) {
	            parent[p] = parent[parent[p]];    // path compression by halving
	            p = parent[p];
	        }
	        return p;
	    }
	    public int count() {
	        return count;
	    }
	  
	    public boolean connected(int p, int q) {
	    	if(p>=rank.length || q>=rank.length)
	    		return false;
	    	
	        return find(p) == find(q);
	    }

	    public boolean union(int p, int q) {
	    	
	    	if(p>=rank.length || q>=rank.length)
	    		return false;
	        int rootP = find(p);
	        int rootQ = find(q);
	        if (rootP == rootQ) return false;

	        // make root of smaller rank point to root of larger rank
	        if      (rank[rootP] < rank[rootQ]){
	        	parent[rootP] = rootQ;
	        	size[rootQ]+=size[rootP];
	        	if(size[rootQ]>max)
	        		max=size[rootQ];
	        }
	        else if (rank[rootP] > rank[rootQ]){
	        	parent[rootQ] = rootP;
	        	size[rootP]+=size[rootQ];
	        	if(size[rootP]>max)
	        		max=size[rootP];
	        }
	        else {
	            parent[rootQ] = rootP;
	            rank[rootP]++;
	        	size[rootP]+=size[rootQ];
	        	if(size[rootP]>max)
	        		max=size[rootP];
	        }
	        count--;
	        return true;
	    }

	}
	
	static long mod=(long) (1e9+7);
	static long pow(long a,long p)
	{
		if(p==0)
			return 1;
		if(p==1)
			return a;
		long ans=1;
		ans=pow(a,p/2);
		ans*=ans;
		ans%=mod;
		if(p%2!=0)
			ans*=a;
		ans%=mod;
		return ans;
	}
	

//	static void go(int ind)
//	{
//		int count=0;
//		done[ind]=true;
//		for(int i=0;i<n;i++)
//		{
//			if(edge[ind][i])
//				count++;
//		}
//		if(count>2)
//		{
//			System.out.println("NO");
//			System.exit(0);
//		}
//		if(count==2)
//		{
//			int left=0;
//			int right=0;
//			for(int i=0;i<n;i++)
//			{
//				if(edge[ind][i])
//				{
//					left=i;
//				}
//			}
//			for(int i=left+1;i<n;i++)
//			{
//				if(edge[ind][i])
//				{
//					right=i;
//				}
//			}
//			done[left]=true;
//			done[right]=true;
//			
//			
//			
//			
//		}
//	}
//	
//	
//    static void dfs(int ind)
//    {
//    	started[ind]=true;
//    	for(int i=0;i<n;i++)
//    	{
//    		if(edge[ind][i])
//    		{
//    			if(done[i])
//    			{
//    				System.out.println("NO");
//    				System.exit(0);
//    			}
//    			if(!started[i])
//    				dfs(i);
//    		}
//    	}
//    	done[ind]=true;
//    }

	public static class Pair implements Comparable<Pair> 
	{
		int d=Integer.MAX_VALUE;
		int x;
		int y;
		int w;
		public Pair(int x,int y,boolean w)
		{
			this.x=x;
			this.y=y;
			if(w)
			this.w=1;
			else
				this.w=0;
			
		}
		@Override
		public int compareTo(Pair o) {
			if(d!=o.d)
				return d-o.d;
			if(x!=o.x)
				return (int) (x-o.x);
			return (int) (y-o.y);
		}
	}
	

	
	
	
	
	
	
	
	
	
	
























    
    public static class FasterScanner {
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = System.in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
           
        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
       
        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
}