#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
struct modint {
  int x;
  modint(int o = 0) { x = o; }
  modint &operator=(int o) { return x = o, *this; }
  modint &operator+=(modint o) {
    return x = x + o.x >= 998244353 ? x + o.x - 998244353 : x + o.x, *this;
  }
  modint &operator-=(modint o) {
    return x = x - o.x < 0 ? x - o.x + 998244353 : x - o.x, *this;
  }
  modint &operator*=(modint o) { return x = 1ll * x * o.x % 998244353, *this; }
  modint &operator^=(int b) {
    modint a = *this, c = 1;
    for (; b; b >>= 1, a *= a)
      if (b & 1) c *= a;
    return x = c.x, *this;
  }
  modint &operator/=(modint o) { return *this *= o ^= 998244353 - 2; }
  modint &operator+=(int o) {
    return x = x + o >= 998244353 ? x + o - 998244353 : x + o, *this;
  }
  modint &operator-=(int o) {
    return x = x - o < 0 ? x - o + 998244353 : x - o, *this;
  }
  modint &operator*=(int o) { return x = 1ll * x * o % 998244353, *this; }
  modint &operator/=(int o) { return *this *= ((modint(o)) ^= 998244353 - 2); }
  template <class I>
  friend modint operator+(modint a, I b) {
    return a += b;
  }
  template <class I>
  friend modint operator-(modint a, I b) {
    return a -= b;
  }
  template <class I>
  friend modint operator*(modint a, I b) {
    return a *= b;
  }
  template <class I>
  friend modint operator/(modint a, I b) {
    return a /= b;
  }
  friend modint operator^(modint a, int b) { return a ^= b; }
  friend bool operator==(modint a, int b) { return a.x == b; }
  friend bool operator!=(modint a, int b) { return a.x != b; }
  bool operator!() { return !x; }
  modint operator-() { return x ? 998244353 - x : 0; }
};
int n, k, a[20], b[20], sum;
bitset<2005> dp[1 << 16];
priority_queue<pair<int, int> > q;
void dfsget(int s, int x) {
  if (!s) return;
  if (x * k <= sum && dp[s][x * k]) {
    for (register int i = (0); i <= (n - 1); ++i)
      if (s >> i & 1) b[i]++;
    dfsget(s, x * k);
  } else {
    for (register int i = (0); i <= (n - 1); ++i)
      if ((s >> i & 1) && (x - a[i] >= 0 && dp[s ^ (1 << i)][x - a[i]]))
        return dfsget(s ^ (1 << i), x - a[i]);
  }
}
signed main() {
  n = read(), k = read();
  dp[0][0] = 1;
  for (register int i = (0); i <= (n - 1); ++i) a[i] = read(), sum += a[i];
  for (register int i = (0); i <= ((1 << n) - 1); ++i) {
    for (register int j = (0); j <= (n - 1); ++j)
      if (i >> j & 1) dp[i] |= (dp[i ^ (1 << j)] << a[j]);
    for (register int j = (sum / k); j >= (1); --j)
      if (dp[i][j * k]) dp[i][j] = 1;
  }
  if (!dp[(1 << n) - 1][1]) return puts("NO") & 0;
  puts("YES");
  dfsget((1 << n) - 1, 1);
  for (register int i = (0); i <= (n - 1); ++i) q.push(make_pair(b[i], a[i]));
  while (q.size() > 1) {
    pair<int, int> u = q.top();
    q.pop();
    pair<int, int> v = q.top();
    q.pop();
    cout << u.second << ' ' << v.second << endl;
    u.second += v.second;
    while (u.second % k == 0) u.second /= k, u.first--;
    q.push(u);
  }
  return 0;
}
