#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P) {
  in >> P.first >> P.second;
  return in;
}
template <class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P) {
  out << "(" << P.first << ", " << P.second << ")";
  return out;
}
template <class T>
istream &operator>>(istream &in, vector<T> &arr) {
  for (auto &x : arr) in >> x;
  return in;
}
template <class T>
ostream &operator<<(ostream &out, const vector<T> &arr) {
  for (auto &x : arr) out << x << ' ';
  cout << "\n";
  return out;
}
template <class T>
istream &operator>>(istream &in, deque<T> &arr) {
  for (auto &x : arr) in >> x;
  return in;
}
template <class T>
ostream &operator<<(ostream &out, const deque<T> &arr) {
  for (auto &x : arr) out << x << ' ';
  cout << "\n";
  return out;
}
int f(int x, int y) {
  if (x % y == 0) {
    return f(x / y, y);
  }
  return x;
}
int n, k;
int32_t main() {
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int u = 500000;
  cin >> n >> k;
  vector<int> v(n);
  cin >> v;
  vector<int> stv = v;
  while (u--) {
    vector<pair<int, int> > op;
    stv = v;
    while (v.size() > 1) {
      shuffle(v.begin(), v.end(), rng);
      pair<int, int> nv;
      nv.first = v.back();
      int second = v.back();
      v.pop_back();
      nv.second = v.back();
      second += v.back();
      v.pop_back();
      op.push_back(nv);
      v.push_back(f(second, k));
    }
    if (v[0] == 1) {
      cout << "YES" << endl;
      for (auto w : op) {
        cout << w.first << " " << w.second << endl;
      }
      return 0;
    }
    v = stv;
  }
  cout << "NO" << endl;
}
