#include <bits/stdc++.h>
using namespace std;
const int mxn = 16, m = 2001;
int n, k;
int a[mxn], b[mxn];
bitset<m> dp[1 << mxn];
vector<int> v[m];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  dp[0][0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    for (int j = 0; j < n; j++) {
      if ((i >> j) & 1) dp[i] |= dp[i ^ (1 << j)] << a[j];
    }
    for (int j = (m - 1) / k; j; j--) dp[i][j] = dp[i][j] | dp[i][j * k];
  }
  if (!dp[(1 << n) - 1][1]) {
    cout << "NO" << '\n';
    return 0;
  }
  for (int i = (1 << n) - 1, j = 1, x, y; i; i ^= (1 << y), j -= a[y]) {
    for (x = 0; j * k < m && dp[i][j * k]; j *= k) x++;
    for (int l = 0; l < n; l++)
      if ((i >> l) & 1) {
        b[l] += x;
        if (a[l] <= j && dp[i ^ (1 << l)][j - a[l]]) y = l;
      }
  }
  for (int i = 0; i < n; i++) v[b[i]].push_back(a[i]);
  cout << "YES" << '\n';
  for (int i = (m - 1) / k; i; i--)
    while (!v[i].empty()) {
      int x = v[i].back(), y = v[i].end()[-2];
      for (int j = 0; j < 2; j++) v[i].pop_back();
      cout << x << " " << y << '\n';
      x += y, y = i;
      while (!(x % k)) x /= k, y--;
      v[y].push_back(x);
    }
  return 0;
}
