#include <bits/stdc++.h>
using namespace std;
bitset<2005> f[1 << 16];
int num[20];
void dp(int n, int k) {
  int s = 0;
  for (int i = 1; i <= n; i++) s += num[i];
  f[0][0] = 1;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = s / k * k; j > 0; j -= k)
      if (f[i][j]) f[i][j / k] = 1;
    for (int j = 1; j <= n; j++)
      if (!((i >> (j - 1)) & 1)) f[i ^ (1 << (j - 1))] |= (f[i] << num[j]);
  }
}
priority_queue<pair<int, int> > q;
void output(int n, int k) {
  int s = 0;
  for (int i = 1; i <= n; i++) s += num[i];
  int st = (1 << n) - 1, x = 1, d = 0;
  while (st)
    if (x * k <= s && f[st][x * k]) {
      x *= k;
      d++;
    } else {
      for (int i = 1; i <= n; i++)
        if (((st >> (i - 1)) & 1) && x >= num[i] &&
            f[st ^ (1 << (i - 1))][x - num[i]]) {
          st ^= (1 << (i - 1));
          x -= num[i];
          q.push(pair<int, int>(d, num[i]));
          break;
        }
    }
  while (q.size() > 1) {
    pair<int, int> t1 = q.top();
    q.pop();
    pair<int, int> t2 = q.top();
    q.pop();
    int u = t1.second, v = t2.second, d = t1.first;
    printf("%d %d\n", u, v);
    u += v;
    while (u % k == 0) {
      u /= k;
      d--;
    }
    q.push(pair<int, int>(d, u));
  }
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
  dp(n, k);
  if (!f[(1 << n) - 1][1]) {
    puts("NO");
    return 0;
  }
  puts("YES");
  output(n, k);
  return 0;
}
