#include <bits/stdc++.h>
const int N = 2002;
using namespace std;
int n, k;
int a[16];
bitset<N> d[1 << 16];
pair<int, int> f(int x) {
  int cnt = 0;
  while (x % k == 0) {
    x /= k;
    cnt += 1;
  }
  return make_pair(x, cnt);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  d[0][0] = 1;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 2000 / k; j >= 1; j--) {
      if (d[i][j * k]) {
        d[i][j] = 1;
      }
    }
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        continue;
      }
      d[i | (1 << j)] |= d[i] << a[j];
    }
  }
  if (d[(1 << n) - 1][1]) {
    cout << "YES"
         << "\n";
    vector<int> b(n, 0);
    int cur = (1 << n) - 1, s = 1;
    while (cur > 0) {
      if (s * k < N && d[cur][s * k]) {
        s *= k;
        for (int i = 0; i < n; i++) {
          b[i] += (cur >> i) & 1;
        }
      } else {
        for (int i = 0; i < n; i++) {
          if (s - a[i] >= 0 && (cur & (1 << i)) &&
              d[cur ^ (1 << i)][s - a[i]]) {
            cur ^= (1 << i);
            s -= a[i];
            break;
          }
        }
      }
    }
    for (int i = 1; i < n; i++) {
      vector<pair<int, int> > g;
      for (int j = 0; j < n; j++) {
        g.push_back(make_pair(b[j], j));
      }
      sort(g.begin(), g.end());
      int x = g[n - 1].second, y = g[n - 2].second;
      cout << a[x] << " " << a[y] << "\n";
      b[x] = 0;
      auto h = f(a[x] + a[y]);
      a[y] = h.first;
      b[y] -= h.second;
    }
  } else {
    cout << "NO"
         << "\n";
  }
}
