#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 1e9 + 47;
const long long LINF = INF * (long long)INF;
const int N = 2048;
const int M = 16;
bitset<2048> dp[1 << M];
int a[M], b[M], k;
pair<int, int> f(int a) {
  pair<int, int> ans = {0, 0};
  while (a % k == 0) {
    ans.second++;
    a /= k;
  }
  ans.first = a;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  dp[0][0] = 1;
  int n;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < (1 << n); i++) {
    for (int suma = N - 1; suma >= 0; suma--)
      if (suma % k == 0 && dp[i][suma]) dp[i][suma / k] = 1;
    for (int j = 0; j < n; j++)
      if (not((i >> j) & 1)) dp[i | (1 << j)] |= dp[i] << a[j];
  }
  if (!dp[(1 << n) - 1][1]) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  pair<int, int> de = {(1 << n) - 1, 1};
  while (de.first) {
    if (de.second * k < N && dp[de.first][de.second * k]) {
      for (int i = 0; i < n; i++)
        if ((de.first >> i) & 1) b[i]++;
      de.second *= k;
    }
    for (int bit = 0; bit < n; bit++) {
      if ((de.first >> bit) % 2 == 1 && de.second >= a[bit] &&
          dp[de.first ^ (1 << bit)][de.second - a[bit]]) {
        de.first ^= (1 << bit);
        de.second -= a[bit];
      }
    }
  }
  vector<int> va, vb, nva, nvb;
  for (int i = 0; i < n; i++) {
    va.push_back(a[i]);
    vb.push_back(b[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    nva.clear();
    nvb.clear();
    int B = 0;
    for (auto x : vb) B = max(B, x);
    int i1 = -1, i2 = -1;
    for (int j = 0; j < (int)(va.size()); j++)
      if (vb[j] == B && i2 == -1) {
        if (i1 == -1)
          i1 = j;
        else
          i2 = j;
      } else {
        nva.push_back(va[j]);
        nvb.push_back(vb[j]);
      }
    cout << va[i1] << " " << va[i2] << endl;
    pair<int, int> g = f(va[i1] + va[i2]);
    nva.push_back(g.first);
    nvb.push_back(B - g.second);
    va = nva;
    vb = nvb;
  }
  return 0;
}
