#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9') {
    if (c == '-') f = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
int n, m, k, a[20], b[20];
bitset<2005> dp[1 << 16];
void dfs(int s, int p) {
  if (!s) return;
  if (p * k <= m && dp[s][p * k]) {
    for (int i = 0; i < n; i++)
      if (s & (1 << i)) b[i + 1]++;
    dfs(s, p * k);
    return;
  }
  for (int i = 0; i < n; i++)
    if ((s & (1 << i)) && a[i + 1] <= p && dp[s ^ (1 << i)][p - a[i + 1]]) {
      dfs(s ^ (1 << i), p - a[i + 1]);
      return;
    }
}
signed main() {
  n = read();
  k = read();
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) a[i] = read(), m += a[i];
  for (int s = 1; s < (1 << n); s++) {
    for (int i = 1; i <= n; i++)
      if (s & (1 << i - 1)) dp[s] |= dp[s ^ (1 << i - 1)] << a[i];
    for (int i = m / k; i >= 1; i--) dp[s][i] = dp[s][i] | dp[s][i * k];
  }
  if (!dp[(1 << n) - 1][1]) {
    puts("NO");
    return 0;
  }
  puts("YES");
  dfs((1 << n) - 1, 1);
  priority_queue<pair<int, int> > q;
  for (int i = 1; i <= n; i++) q.push(make_pair(b[i], a[i]));
  while (q.size() >= 2) {
    pair<int, int> t1 = q.top();
    q.pop();
    pair<int, int> t2 = q.top();
    q.pop();
    printf("%d %d\n", t1.second, t2.second);
    int x = t1.second + t2.second, y = t1.first;
    while (x % k == 0 && y) y--, x /= k;
    q.push(make_pair(y, x));
  }
}
