#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
const int M = 1 << 16;
bitset<N> mp[M];
int a[N], sum, rk[N], k, n;
priority_queue<pair<int, int> > que;
void dfs(int s, int t) {
  if (s == 0) return;
  int r = 0;
  for (; t * k < N && mp[s][t * k]; r++, t *= k) {
  }
  for (int i = 0; i < n; i++) {
    if (s & (1 << i)) rk[i] += r;
  }
  for (int i = 0; i < n; i++) {
    if (s & (1 << i) && t >= a[i] && mp[s - (1 << i)][t - a[i]]) {
      dfs(s - (1 << i), t - a[i]);
      return;
    }
  }
}
int main() {
  sum = 0;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    sum += a[i];
  }
  mp[0][0] = 1;
  for (int s = 1; s < (1 << n); s++) {
    for (int i = 0; i < n; i++) {
      if (s & (1 << i)) mp[s] |= mp[s - (1 << i)] << a[i];
    }
    for (int i = sum / k; i >= 1; i--) {
      if (mp[s][i * k]) mp[s][i] = 1;
    }
  }
  if (!mp[(1 << n) - 1][1]) {
    puts("NO");
    return 0;
  }
  puts("YES");
  dfs((1 << n) - 1, 1);
  for (int i = 0; i < n; i++) {
    que.push({rk[i], a[i]});
  }
  while (que.size() != 1) {
    pair<int, int> u = que.top();
    que.pop();
    pair<int, int> v = que.top();
    que.pop();
    printf("%d %d\n", u.second, v.second);
    u.second += v.second;
    while (u.second % k == 0) {
      u.second /= k;
      u.first--;
    }
    que.push(u);
  }
}
