#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 16, __ = 1 << _, N = 2007;
int n, m, nn, val[_], sval = 0;
bitset<N> f[__] = {0};
int dcnt[_] = {0};
void dfs(int now, int va) {
  if (!now) return;
  int cnt = 0;
  while (va * m <= sval && f[now][va * m]) va *= m, cnt++;
  for (int i = 0; i < n; i++)
    if ((((now) >> (i)) & 1)) dcnt[i] += cnt;
  for (int i = 0; i < n; i++)
    if ((((now) >> (i)) & 1) && va >= val[i] &&
        f[now - (1 << (i))][va - val[i]])
      return dfs(now - (1 << (i)), va - val[i]);
}
priority_queue<pair<int, int>> q;
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  n = ty(), m = ty(), nn = 1 << n;
  for (int i = 0; i < n; i++) val[i] = ty(), sval += val[i];
  f[0][0] = 1;
  for (int i = 1; i < nn; i++) {
    for (int j = 0; j < n; j++)
      if ((((i) >> (j)) & 1)) f[i] |= f[i - (1 << (j))] << val[j];
    for (int j = sval / m; j >= 1; j--)
      if (f[i][j * m]) f[i][j] = 1;
  }
  if (!f[nn - 1][1]) {
    cout << "NO" << lf;
    return 0;
  }
  cout << "YES" << lf;
  dfs(nn - 1, 1);
  for (int i = 0; i < n; i++) q.emplace(dcnt[i], val[i]);
  while (q.size() >= 2) {
    pair<int, int> a = q.top();
    q.pop();
    pair<int, int> b = q.top();
    q.pop();
    cout << a.second << ' ' << b.second << lf, a.second += b.second;
    while (a.second % m == 0) a.second /= m, a.first--;
    q.emplace(a);
  }
  return 0;
}
