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