#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 1;
bitset<N> f[1 << 16];
int a[20];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int k;
  cin >> k;
  f[0] = 1;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int m = 1; m < (1 << n); ++m) {
    for (int i = 0; i < n; ++i)
      if (m >> i & 1) f[m] |= (f[m ^ (1 << i)] << a[i]);
    for (int i = N - 1; i; --i)
      if (i % k == 0) f[m][i / k] = (f[m][i / k] | f[m][i]);
  }
  int m = (1 << n) - 1;
  int x = 1;
  if (f[m][x]) {
    vector<int> e(n);
    for (int i = 1; i < n; ++i) {
      for (; x < N; x *= k) {
        for (int j = 0; j < n; ++j)
          if (m >> j & 1)
            if (x >= a[j] && f[m ^ (1 << j)][x - a[j]]) {
              x -= a[j];
              m ^= (1 << j);
              goto out;
            }
        for (int j = 0; j < n; ++j)
          if (m >> j & 1) e[j]++;
      }
    out:;
    }
    cout << "YES\n";
    priority_queue<pair<int, int> > pq;
    for (int i = 0; i < n; ++i) pq.push(pair<int, int>(e[i], a[i]));
    for (int i = 1; i < n; ++i) {
      int x = pq.top().second;
      int e = pq.top().first;
      pq.pop();
      int y = pq.top().second;
      pq.pop();
      cout << x << " " << y << "\n";
      for (x += y; x % k == 0; x /= k, --e)
        ;
      pq.push(pair<int, int>(e, x));
    }
  } else
    puts("NO");
}
