#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 5000 + 10;
pair<int, int> a[MAX_N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = a[i].first;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[j].first != a[i].first && a[j].first != a[i].second &&
          a[i].first != a[j].second) {
        swap(a[i].first, a[j].first);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i].first != a[i].second) {
      ans++;
    }
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    cout << a[i].first << " " << a[i].second << endl;
  }
}
