#include <bits/stdc++.h>
using namespace std;
struct type {
  int a, b;
} b[17];
int p[17];
int a[17];
int ans[101];
bitset<2001> f[65536];
int n, K, L, i, j, k, l, sum, len, s, tot;
bool cmp(type a, type b) { return a.b > b.b; }
int main() {
  p[1] = 1;
  for (i = 2; i <= 16; i++) p[i] = p[i - 1] << 1;
  scanf("%d%d", &n, &K);
  L = (p[n] << 1) - 1;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]), sum += a[i];
  sum /= K;
  f[0][0] = 1;
  for (i = 1; i <= L; i++) {
    for (j = 1; j <= n; j++)
      if (i & p[j]) f[i] |= f[i ^ p[j]] << a[j];
    for (j = sum; j >= 1; j--)
      if (f[i][j * K]) f[i][j] = 1;
  }
  if (!f[L][1])
    printf("NO\n");
  else {
    printf("YES\n");
    s = L;
    j = 1;
    while (j) {
      if (j <= sum && f[s][j * K]) {
        j *= K;
        ans[++len] = -1;
        continue;
      }
      for (i = 1; i <= n; i++)
        if (s & p[i] && j >= a[i] && f[s - p[i]][j - a[i]]) {
          s -= p[i];
          j -= a[i];
          ans[++len] = i;
          break;
        }
    }
    j = 0;
    for (i = 1; i <= len; i++)
      if (ans[i] == -1)
        ++j;
      else
        b[++tot] = {a[ans[i]], -j};
    while (tot > 1) {
      sort(b + 1, b + tot + 1, cmp);
      printf("%d %d\n", b[tot - 1].a, b[tot].a);
      b[tot - 1].a += b[tot].a;
      --tot;
      while (!(b[tot].a % K)) b[tot].a /= K, ++b[tot].b;
    }
  }
}
