#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void rd(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 - '0' + c, c = getchar();
  x *= f;
}
bitset<2001> f[1 << 16];
int n, a[20], m;
int sum[1 << 16];
int get(int x) {
  while (x % m == 0) x /= m;
  return x;
}
int b[20];
void dfs(int s, int v) {
  int tot = 0;
  for (int i = 0; i < n; ++i) tot += (s >> i) & 1;
  if (tot == 1) return;
  for (; f[s][v]; v *= m) {
    for (int i = 0; i < n; ++i)
      if (((s >> i) & 1) && a[i] <= v && f[s ^ (1 << i)][v - a[i]]) {
        dfs(s ^ (1 << i), v - a[i]);
        return;
      }
    for (int i = 0; i < n; ++i)
      if ((s >> i) & 1) b[i]++;
  }
}
void del(int p) {
  for (int i = p; i + 1 < n; ++i) {
    a[i] = a[i + 1];
    b[i] = b[i + 1];
  }
}
void sol() {
  if (n == 1) return;
  int p[2], pcnt = 0, mx = -1;
  for (int i = 0; i < n; ++i) {
    if (b[i] > mx) {
      mx = b[i], p[(pcnt = 1) - 1] = i;
    } else if (b[i] == mx && pcnt < 2)
      p[pcnt++] = i;
  }
  printf("%d %d\n", a[p[0]], a[p[1]]);
  int ta = a[p[0]] + a[p[1]], tb = b[p[0]];
  while (ta % m == 0) ta /= m, tb--;
  del(p[1]);
  del(p[0]);
  a[(--n) - 1] = ta;
  b[n - 1] = tb;
  sol();
}
int main() {
  rd(n), rd(m);
  for (int i = 0; i < n; ++i) {
    rd(a[i]), f[1 << i][a[i]] = 1;
    for (int j = 0; j < (1 << n); ++j)
      if (j & (1 << i)) sum[j] += a[i];
  }
  for (int s = 1; s < (1 << n); ++s) {
    for (int j = 0; j < n; ++j)
      if (s & (1 << j)) f[s] |= f[s ^ (1 << j)] << a[j];
    for (int j = sum[s] / m; j >= 1; --j)
      if (f[s][j * m]) f[s][j] = 1;
  }
  if (!f[(1 << n) - 1][1]) {
    printf("NO");
    return 0;
  }
  printf("YES\n");
  dfs((1 << n) - 1, 1);
  sol();
  return 0;
}
