#include <bits/stdc++.h>
using namespace std;
inline int read() {
  register int x = 0, f = 1;
  register char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = 0;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + (ch ^ '0');
    ch = getchar();
  }
  return f ? x : -x;
}
const int N = 16, M = 2e3 + 5;
int n, k, a[N], U, sum, rnk[N];
bitset<M> f[1 << N];
priority_queue<pair<int, int> > q;
inline void Dfs(int s, int p) {
  if (!s) return;
  int t = 0;
  for (; p * k <= sum && f[s][p * k]; p *= k, ++t)
    ;
  for (int i = (0), _ed = (n); i <= _ed; ++i)
    if ((s >> i) & 1) rnk[i] += t;
  for (int i = (0), _ed = (n); i <= _ed; ++i)
    if ((s >> i) & 1 && p >= a[i] && f[s ^ (1 << i)][p - a[i]])
      return Dfs(s ^ (1 << i), p - a[i]);
}
int main() {
  n = read(), k = read();
  U = (1 << n) - 1;
  --n;
  for (int i = (0), _ed = (n); i <= _ed; ++i) sum += (a[i] = read());
  f[0][0] = 1;
  for (int s = (1), _ed = (U); s <= _ed; ++s) {
    for (int i = (0), _ed = (n); i <= _ed; ++i)
      if ((s >> i) & 1) f[s] |= f[s ^ (1 << i)] << a[i];
    for (int i = (sum / k), _ed = (1); i >= _ed; --i)
      if (f[s][i * k]) f[s][i] = 1;
  }
  if (!f[U][1]) {
    puts("NO");
    return 0;
  } else
    puts("YES");
  Dfs(U, 1);
  for (int i = (0), _ed = (n); i <= _ed; ++i) q.push(make_pair(rnk[i], a[i]));
  while (q.size() > 1) {
    pair<int, int> a = q.top();
    q.pop();
    pair<int, int> b = q.top();
    q.pop();
    printf("%d %d\n", a.second, b.second);
    a.second += b.second;
    while (!(a.second % k)) --a.first, a.second /= k;
    q.push(a);
  }
  return 0;
}
