#include <bits/stdc++.h>
using namespace std;
int n, m, a[5001], i, j, b[5001], ans;
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  for (i = 1; i <= n; i++)
    if (a[i] == b[i])
      for (j = 1; j <= n; j++)
        if (a[i] != b[j] && b[i] != a[j]) swap(b[i], b[j]);
  for (i = 1; i <= n; i++)
    if (a[i] != b[i]) ans++;
  printf("%d\n", ans);
  for (i = 1; i <= n; i++) printf("%d %d\n", a[i], b[i]);
}
