#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 16) + 7;
bitset<3007> f[N];
int n, k, q, w[N], c[N];
bool fl[N];
inline void solve(int u, int v) {
  if (u == 0) return;
  while (v * k <= 3000 && f[u][v * k]) v *= k, q++;
  for (int i = 0; i < n; i++)
    if ((u & (1 << i)) && v >= w[i + 1] && f[u - (1 << i)][v - w[i + 1]]) {
      c[i + 1] = q, solve(u - (1 << i), v - w[i + 1]);
      return;
    }
}
int main() {
  cin >> n >> k, f[0][0] = 1;
  for (int i = 1; i <= n; i++) cin >> w[i];
  for (int i = 1; i < (1 << n); i++) {
    for (int x = 1; x <= n; x++)
      if ((1 << (x - 1)) & i) f[i] = f[i] | (f[i - (1 << (x - 1))] << w[x]);
    for (int x = 3000; x >= 1; x--)
      if (x % k == 0) f[i][x / k] = f[i][x / k] | f[i][x];
  }
  if (!f[(1 << n) - 1][1]) {
    puts("NO");
    return 0;
  }
  puts("YES");
  solve((1 << n) - 1, 1);
  for (int i = 1; i <= n; i++) {
    int a = 0, b = 0;
    for (int j = 1; j <= n; j++) {
      if (fl[j]) continue;
      if (c[a] < c[j]) a = j;
    }
    for (int j = 1; j <= n; j++) {
      if (fl[j] || a == j) continue;
      if (c[a] == c[j]) b = j;
    }
    if (c[a] == 0) break;
    n++, w[n] = w[a] + w[b], c[n] = c[a], fl[a] = 1, fl[b] = 1;
    cout << w[a] << " " << w[b] << endl;
    while (w[n] % k == 0) w[n] /= k, c[n]--;
  }
  return 0;
}
