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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 210;
const int maxm = maxn * maxn * 5;
const int INF = 0x3f3f3f3f;
int n, m, en, cost, s, t, z[maxn], q[maxn], f[maxn], dist[maxn];
bool use[maxn];
struct edge {
  int e, f, d;
  edge *next, *op;
} * v[maxn], ed[maxm], *fe[maxn];
void add_edge(int s, int e, int f, int d) {
  en++;
  ed[en].next = v[s];
  v[s] = ed + en;
  v[s]->e = e;
  v[s]->f = f;
  v[s]->d = d;
  en++;
  ed[en].next = v[e];
  v[e] = ed + en;
  v[e]->e = s;
  v[e]->f = 0;
  v[e]->d = -d;
  v[s]->op = v[e];
  v[e]->op = v[s];
}
bool spfa() {
  memset(dist, -1, sizeof(dist));
  dist[s] = 0;
  int front = 1, tail = 2;
  q[1] = s;
  use[s] = true;
  for (; front != tail;) {
    int now = q[front++];
    if (front == maxn) front = 0;
    use[now] = false;
    for (edge *e = v[now]; e; e = e->next)
      if (e->f && dist[e->e] < dist[now] + e->d) {
        dist[e->e] = dist[now] + e->d;
        f[e->e] = now;
        fe[e->e] = e;
        if (!use[e->e]) {
          use[e->e] = true;
          q[tail++] = e->e;
          if (tail == maxn) tail = 0;
        }
      }
  }
  return dist[t] != -1;
}
void agument() {
  int delta = INF;
  for (int p = t; p; p = f[p]) delta = min(delta, fe[p]->f);
  for (int p = t; p; p = f[p]) {
    fe[p]->f -= delta;
    fe[p]->op->f += delta;
  }
  cost += delta * dist[t];
}
void dinic() {
  while (spfa()) agument();
}
int main() {
  scanf("%d%d", &n, &m);
  for (int a = 1; a <= n; a++) {
    int v;
    scanf("%d", &v);
    z[v]++;
  }
  n = m;
  s = 0;
  t = 2 * n + 1;
  for (int a = 1; a <= n; a++) add_edge(s, a, z[a], 0);
  for (int a = 1; a <= n; a++)
    for (int b = 1; b <= n; b++) add_edge(a, b + n, INF, a != b);
  for (int a = 1; a <= n; a++) add_edge(a + n, t, z[a], 0);
  dinic();
  printf("%d\n", cost);
  for (int a = 1; a <= n; a++)
    for (edge *e = v[a]; e; e = e->next)
      if (e->e > a)
        while (e->op->f) printf("%d %d\n", a, e->e - n), e->op->f--;
  return 0;
}