#include <bits/stdc++.h>
using namespace std;
bitset<2010> f[1 << 17];
int n, s, k, lg[1 << 17], a[2010], d[2010];
priority_queue<pair<int, int> > q;
void dfs(int st, int v) {
  if (!st) return;
  for (; v * k <= s && f[st][v * k]; v *= k)
    for (int i = st; i; i -= i & -i) d[lg[i & -i]]++;
  for (int i = st; i; i -= i & -i)
    if (v >= a[lg[i & -i]] && f[st - (i & -i)][v - a[lg[i & -i]]]) {
      dfs(st - (i & -i), v - a[lg[i & -i]]);
      return;
    }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    lg[1 << i] = i;
    s += a[i];
  }
  f[0][0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    for (int j = i; j; j -= j & -j) f[i] |= (f[i - (j & -j)] << a[lg[j & -j]]);
    for (int j = s / k; j; j--)
      if (f[i][j * k]) f[i][j] = 1;
  }
  if (!f[(1 << n) - 1][1]) {
    puts("NO");
    return 0;
  }
  puts("YES");
  dfs((1 << 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> x = q.top();
    q.pop();
    pair<int, int> y = q.top();
    q.pop();
    printf("%d %d\n", x.second, y.second);
    x.second += y.second;
    while (x.second % k == 0) {
      x.second /= k;
      x.first--;
    }
    q.push(x);
  }
}
