#include <bits/stdc++.h>
double const EPS = 3e-8;
using namespace std;
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
int n, m;
bool taken[105];
struct abc {
  int x, y;
} inp[5500];
int main() {
  int i, j;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> inp[i].x;
    inp[i].y = inp[i].x;
    taken[inp[i].x] = 0;
  }
  int ans = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (i == j) continue;
      if (inp[j].x == inp[j].y) {
        if (inp[i].x != inp[j].x && inp[i].y != inp[j].x) {
          swap(inp[i].x, inp[j].x);
        }
      } else if (inp[i].x == inp[i].y) {
        if (inp[i].x != inp[j].x && inp[i].x != inp[j].y) {
          swap(inp[i].x, inp[j].x);
        }
      }
    }
  }
  for (i = 0; i < n; i++) ans += (inp[i].x != inp[i].y);
  cout << ans << endl;
  for (i = 0; i < n; i++) {
    cout << inp[i].x << " " << inp[i].y << endl;
  }
  return 0;
}
