#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
  o << "{";
  for (const T& v : vc) o << v << ",";
  o << "}";
  return o;
}
using ll = long long;
template <class T>
using V = vector<T>;
template <class T>
using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
using BS = bitset<2001>;
bool B(int x, int i) { return (x >> i) & 1; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int N, K;
  cin >> N >> K;
  V<int> w(N);
  for (int i = 0; i < (int)(N); i++) cin >> w[i];
  V<BS> dp(1 << N);
  dp[0][0] = true;
  for (int b = 0; b < (int)(1 << N); b++) {
    for (int i = 0; i < (int)(N); i++)
      if (B(b, i)) {
        dp[b] |= dp[b ^ (1 << i)] << w[i];
      }
    for (int i = 2000; i > 0; i--)
      if (i % K == 0 && dp[b][i]) dp[b][i / K] = true;
  }
  if (!dp[(1 << N) - 1][1]) {
    cout << "NO\n";
    return 0;
  }
  V<int> shift(N);
  int SHIFT = 0;
  {
    int now = (1 << N) - 1;
    int s = 1;
    while (now) {
      assert(dp[now][s]);
      int nxt = -1;
      while (true) {
        for (int i = 0; i < (int)(N); i++)
          if (B(now, i)) {
            if (s >= w[i] && dp[now ^ (1 << i)][s - w[i]]) {
              nxt = now ^ (1 << i);
              s -= w[i];
              shift[i] = SHIFT;
              break;
            }
          }
        if (nxt != -1) break;
        s *= K, SHIFT++;
      }
      now = nxt;
    }
  }
  true;
  using P = pair<int, int>;
  priority_queue<P> que;
  for (int i = 0; i < (int)(N); i++) que.push(P(shift[i], w[i]));
  cout << "YES\n";
  while (que.size() > 1) {
    P p = que.top();
    que.pop();
    P q = que.top();
    que.pop();
    assert(p.first == q.first);
    cout << p.second << " " << q.second << "\n";
    int s = p.second + q.second;
    int r = p.first;
    while (s % K == 0) {
      s /= K;
      r--;
    }
    que.push(P(r, s));
  }
}
