#include <bits/stdc++.h>
using namespace std;
int n, k, a[20];
bitset<2020> b[1 << 16];
int deg[20];
void dfs(int mask, int val, int dep) {
  if (mask == 0) return;
  for (int j = 0; j < n; j++)
    if (mask >> j & 1) {
      if (val >= a[j] && b[mask ^ (1 << j)][val - a[j]] == 1) {
        deg[j] = dep;
        dfs(mask ^ (1 << j), val - a[j], dep);
        return;
      }
    }
  dfs(mask, val * k, dep + 1);
}
priority_queue<pair<int, int> > Q;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  b[0][0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    for (int j = 0; j < n; j++)
      if (i >> j & 1) {
        b[i] |= b[i ^ (1 << j)] << a[j];
      }
    for (int j = 2000 / k; j >= 1; j--)
      if (b[i][j * k]) b[i][j] = 1;
  }
  if (!b[(1 << n) - 1][1]) {
    puts("NO");
    return 0;
  }
  puts("YES");
  dfs((1 << n) - 1, 1, 0);
  for (int i = 0; i < n; i++) Q.emplace(deg[i], a[i]);
  while (Q.size() > 1) {
    pair<int, int> le = Q.top();
    Q.pop();
    pair<int, int> ri = Q.top();
    Q.pop();
    assert(le.first == ri.first);
    printf("%d %d\n", le.second, ri.second);
    int a = le.first, b = le.second + ri.second;
    while (b % k == 0) b /= k, a--;
    Q.emplace(a, b);
  }
}
