#include <bits/stdc++.h>
using namespace std;
const int maxn = 16;
const int maxk = 2010;
int n, k;
int a[maxn];
bitset<maxk> dp[1 << maxn];
vector<int> vec[20];
int last = 0;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  dp[0][0] = 1;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 2000; j >= 1; j--) {
      if (dp[i][j] && j % k == 0) {
        dp[i][j / k] = 1;
      }
    }
    for (int j = 0; j < n; j++) {
      if (!((i >> j) & 1)) {
        dp[i ^ (1 << j)] |= (dp[i] << a[j]);
      }
    }
  }
  if (!dp[(1 << n) - 1][1])
    puts("NO");
  else {
    puts("YES");
    int curi = (1 << n) - 1, curj = 1, c = 0;
    while (curi) {
      while (curj * k <= 2000 && dp[curi][curj * k]) {
        ++c;
        curj *= k;
      }
      for (int i = 0; i < n; i++) {
        if (((curi >> i) & 1) && curj >= a[i] &&
            dp[curi ^ (1 << i)][curj - a[i]]) {
          vec[c].push_back(a[i]);
          curi ^= (1 << i);
          curj -= a[i];
          break;
        }
      }
    }
    for (int i = 19; i >= 0; i--) {
      for (int j = 0; j < vec[i].size(); j++) {
        int v = vec[i][j];
        if (last) printf("%d %d\n", last, v);
        last += v;
        if (last && last % k == 0) {
          int t = i;
          while (last % k == 0) {
            --t;
            last /= k;
          }
          if (t >= 0) vec[t].push_back(last);
          if (j + 1 < vec[i].size()) {
            last = vec[i][j + 1];
            j++;
          } else
            last = 0;
        }
      }
      last /= k;
    }
  }
  return 0;
}
