#include <bits/stdc++.h>
using namespace std;
const int N = 16 + 2, S = 2e3 + 5;
vector<pair<int, int>> moves;
int n, k, a[N], b[N];
bitset<S> dp[1 << N];
inline void calculate_b() {
  dp[0][0] = true;
  for (int i = 0; i < 1 << n; i++) {
    for (int j = (S - 1) / k; j; j--) dp[i][j] = dp[i][j] | dp[i][j * k];
    for (int j = 0; j < n; j++)
      if (~i >> j & 1) dp[i ^ (1 << j)] |= dp[i] << a[j];
  }
  if (!dp[(1 << n) - 1][1]) {
    cout << "NO";
    exit(0);
  }
  for (int msk = (1 << n) - 1, cur = 1; msk;) {
    bool flag = false;
    for (int i = 0; i < n; i++)
      if (cur >= a[i] && msk >> i & 1 && dp[msk ^ (1 << i)][cur - a[i]]) {
        msk ^= 1 << i;
        cur -= a[i];
        flag = true;
        break;
      }
    if (!flag) {
      for (int i = 0; i < n; i++) b[i] += msk >> i & 1;
      cur *= k;
    }
  }
}
inline void restore_moves() {
  vector<pair<int, int>> cur;
  for (int i = 0; i < n; i++) cur.push_back({b[i], a[i]});
  while (cur.size() > 1) {
    sort(cur.begin(), cur.end());
    int x = cur.back().second;
    cur.pop_back();
    moves.push_back({x, cur.back().second});
    for (cur.back().second += x; !(cur.back().second % k); cur.back().first--)
      cur.back().second /= k;
  }
}
inline void read_input() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
}
inline void solve() {
  calculate_b();
  restore_moves();
}
inline void write_output() {
  cout << "YES\n";
  for (auto x : moves) {
    cout << x.first << ' ';
    cout << x.second << endl;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read_input(), solve(), write_output();
  return 0;
}
