#include <bits/stdc++.h>
using namespace std;
int const K = 2000, N = 16;
int n, k, x[N];
bitset<K + 1> dp[1 << N];
vector<int> p[N * 10];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < (int)(n); ++i) scanf("%d", x + i);
  dp[0][0] = true;
  for (int i = 0; i < (int)(1 << n); ++i) {
    for (int j = K / k * k; j > 0; j -= k)
      if (dp[i][j]) dp[i][j / k] = true;
    for (int j = 0; j < (int)(n); ++j)
      if (!(i >> j & 1)) dp[i | 1 << j] |= dp[i] << x[j];
  }
  if (!dp[(1 << n) - 1][1]) {
    printf("NO\n");
    return 0;
  }
  int i = (1 << n) - 1, s = 1, cp = 0;
  while (i) {
    if (s * k <= K && dp[i][s * k]) {
      s *= k;
      ++cp;
    } else
      for (int j = 0; j < (int)(n); ++j)
        if (i >> j & 1 && x[j] <= s && dp[i ^ 1 << j][s - x[j]]) {
          p[cp].push_back(x[j]);
          s -= x[j];
          i ^= 1 << j;
        }
  }
  printf("YES\n");
  for (int i = N * 10 - 1; i > 0; --i)
    while (!p[i].empty()) {
      int z = p[i].back();
      p[i].pop_back();
      while (z % k) {
        printf("%d %d\n", z, p[i].back());
        z += p[i].back();
        p[i].pop_back();
      }
      int w = i;
      while (z % k == 0) z /= k, --w;
      p[w].push_back(z);
    }
}
