#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 16, M = 2003;
template <typename T>
void read(T &x) {
  int ch = getchar();
  x = 0;
  bool f = false;
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  if (f) x = -x;
}
template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) return a = b, 1;
  return 0;
}
template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) return a = b, 1;
  return 0;
}
int n, k, lim, a[16], sum, b[16];
bitset<M> f[N];
priority_queue<pair<int, int> > pq;
int main() {
  read(n);
  read(k);
  lim = 1 << n;
  f[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    read(a[i]);
    sum += a[i];
  }
  for (int S = 1; S < lim; ++S) {
    for (int i = 0; i < n; ++i)
      if (S >> i & 1) f[S] |= f[S ^ (1 << i)] << a[i];
    for (int i = sum / k; i; --i)
      if (f[S][i * k]) f[S][i] = 1;
  }
  if (!f[lim - 1][1]) {
    puts("NO");
    return 0;
  }
  puts("YES");
  int S = lim - 1, x = 1;
  while (S) {
    for (; x * k <= sum && f[S][x * k]; x *= k)
      for (int i = 0; i < n; ++i)
        if (S >> i & 1) ++b[i];
    for (int i = 0; i < n; ++i)
      if (x >= a[i] && (S >> i & 1) && f[S ^ (1 << i)][x - a[i]]) {
        S ^= 1 << i;
        x -= a[i];
        break;
      }
  }
  for (int i = 0; i < n; ++i) pq.push(make_pair(b[i], a[i]));
  while (pq.size() > 1) {
    pair<int, int> p = pq.top();
    pq.pop();
    pair<int, int> q = pq.top();
    pq.pop();
    printf("%d %d\n", p.second, q.second);
    p.second += q.second;
    while (!(p.second % k)) {
      p.second /= k;
      --p.first;
    }
    pq.push(p);
  }
}
