#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
using namespace std;
int n, k, a[22];
bitset<2022> bt[65547];
int c[22];
int ansu[22], ansv[22], atot;
bool vis[22];
inline void Merge(int u, int v) {
  ansu[++atot] = a[u];
  ansv[atot] = a[v];
  vis[v] = true;
  a[u] += a[v];
  while (a[u] % k == 0) a[u] /= k, --c[u];
}
inline void Print() {
  puts("YES");
  for (int i = 1; i <= atot; ++i) printf("%d %d\n", ansu[i], ansv[i]);
}
int main() {
  read(n), read(k);
  int sm = 0;
  for (int i = 0; i < n; ++i) read(a[i]), sm += a[i];
  bt[0][0] = 1;
  const int All = (1 << n) - 1;
  for (int s = 0; s <= All; ++s) {
    for (int i = sm / k; ~i; --i)
      if (bt[s][i * k]) {
        bt[s][i] = true;
      }
    for (int i = 0; i < n; ++i)
      if (!((s >> i) & 1)) bt[s ^ (1 << i)] |= bt[s] << a[i];
  }
  if (bt[All][1]) {
    int nws = All, nwv = 1;
    while (nws) {
      if (nwv * k <= sm && bt[nws][nwv * k]) {
        for (int i = 0; i < n; ++i)
          if ((nws >> i) & 1) ++c[i];
        nwv *= k;
        continue;
      }
      for (int i = 0; i < n; ++i)
        if ((nws >> i) & 1 && nwv >= a[i] && bt[nws ^ (1 << i)][nwv - a[i]]) {
          nws ^= (1 << i), nwv -= a[i];
          break;
        }
    }
    for (int _ = 1; _ < n; ++_) {
      int mxc = 0, mxu = -1, mxv = -1;
      for (int i = 0; i < n; ++i)
        if (!vis[i]) {
          if (c[i] > mxc) {
            mxc = c[i];
            mxu = i;
            mxv = -1;
          } else if (c[i] == mxc) {
            mxv = i;
          }
        }
      Merge(mxu, mxv);
    }
    Print();
  } else {
    puts("NO");
  }
  return 0;
}
