#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool get_int(T &x) {
  char t = getchar();
  bool neg = false;
  x = 0;
  for (; (t > '9' || t < '0') && t != '-' && t != EOF; t = getchar())
    ;
  if (t == '-') neg = true, t = getchar();
  if (t == EOF) return false;
  for (; t <= '9' && t >= '0'; t = getchar()) x = x * 10 + t - '0';
  if (neg) x = -x;
  return true;
}
template <typename T>
void print_int(T x) {
  if (x < 0) putchar('-'), x = -x;
  short a[20] = {}, sz = 0;
  while (x > 0) a[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + a[i]);
}
const int inf = 0x3f3f3f3f;
const long long Linf = 1ll << 61;
const double pi = acos(-1.0);
int n, k, a[20], sum[1 << 16];
bitset<2111> dp[1 << 16];
int b[20];
void dfs(int msk, int t, int layer) {
  if (msk == 0) return;
  if (t > 2000) return;
  for (int i = 0; i < n; i++)
    if ((((msk) >> (i)) & 1) && t >= a[i] &&
        dp[msk ^ (1 << i)].test(t - a[i])) {
      b[i] = layer;
      dfs(msk ^ (1 << i), t - a[i], layer);
      return;
    }
  dfs(msk, t * k, layer + 1);
}
int main() {
  (get_int(n) && get_int(k));
  for (int i = 0; i < n; i++) get_int(a[i]);
  for (int i = 0; i < (1 << n); i++)
    for (int j = 0; j < n; j++)
      if ((((i) >> (j)) & 1)) sum[i] += a[j];
  dp[0].set(0);
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < n; j++)
      if ((((i) >> (j)) & 1)) dp[i] |= (dp[i ^ (1 << j)] << a[j]);
    for (int j = sum[i]; j >= 0; j--)
      if (j % k == 0 && dp[i].test(j)) dp[i].set(j / k);
  }
  if (dp[(1 << n) - 1].test(1)) {
    puts("YES");
    dfs((1 << n) - 1, 1, 0);
    priority_queue<pair<int, int> > pq;
    for (int i = 0; i < n; i++) pq.push(make_pair(b[i], a[i]));
    while (pq.size() > 1) {
      pair<int, int> t1 = pq.top();
      pq.pop();
      pair<int, int> t2 = pq.top();
      pq.pop();
      printf("%d %d\n", t1.second, t2.second);
      t1.second += t2.second;
      while (t1.second % k == 0) {
        t1.second /= k;
        t1.first--;
      }
      pq.push(t1);
    }
  } else
    puts("NO");
  return 0;
}
