#include <bits/stdc++.h>
using namespace std;
int N, K, a[16], b[16], SUM;
bitset<2001> f[1 << 16];
struct st {
  int v, c;
  st() {}
  st(int v, int c) : v(v), c(c) {}
  bool operator<(const st& t) const { return c < t.c; }
};
priority_queue<st> Q;
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; ++i) scanf("%d", &a[i]), SUM += a[i];
  for (int i = 0; i < N; ++i) f[1 << i][a[i]] = 1;
  for (int S = 0; S < (1 << N); ++S) {
    for (int i = 0; i < N; ++i)
      if (S & (1 << i)) f[S] |= f[S ^ (1 << i)] << a[i];
    for (int i = SUM / K; i >= 0; --i)
      if (f[S][i * K]) f[S][i] = 1;
  }
  if (!f[(1 << N) - 1][1]) {
    puts("NO");
    return 0;
  }
  for (int turn = 1, st = (1 << N) - 1, s = 1; turn <= N; ++turn) {
    bool flag = 0;
    for (int i = 0; i < N; ++i)
      if (st & (1 << i)) {
        for (int j = 0, pw = 1; s * pw - a[i] <= SUM; ++j, pw *= K) {
          if (s * pw - a[i] >= 0 && f[st ^ (1 << i)][s * pw - a[i]]) {
            for (int k = 0; k < N; ++k)
              if (st & (1 << k)) b[k] += j;
            s = s * pw - a[i], st ^= 1 << i, flag = 1;
            break;
          }
        }
        if (flag) break;
      }
  }
  puts("YES");
  for (int i = 0; i < N; ++i) Q.push(st(a[i], b[i]));
  while (Q.size() > 1) {
    st x = Q.top();
    Q.pop();
    st y = Q.top();
    Q.pop();
    printf("%d %d\n", x.v, y.v);
    x.v += y.v;
    while (x.v % K == 0) x.v /= K, --x.c;
    Q.push(x);
  }
  return 0;
}
