#include <bits/stdc++.h>
using namespace std;
int n, k, a[23], b[23];
bitset<2002> dp[1 << 16];
int main() {
  cin >> n >> k;
  for (int i = (0); i <= (n - 1); ++i) cin >> a[i];
  dp[0][0] = 1;
  for (int S = 1; S < (1 << n); ++S) {
    for (int i = 0; i < n; ++i)
      if (S & (1 << i)) {
        dp[S] |= (dp[S ^ (1 << i)] << a[i]);
      }
    for (int i = 2000; i; --i)
      if (i % k == 0) {
        dp[S][i / k] = (dp[S][i / k] | dp[S][i]);
      }
  }
  if (!dp[(1 << n) - 1][1]) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  int x = 1, st = (1 << n) - 1;
  while (st) {
    for (; x <= 2000; x *= k) {
      for (int i = (0); i <= (n - 1); ++i)
        if ((st & (1 << i)) && x >= a[i] && dp[st ^ (1 << i)][x - a[i]]) {
          st ^= (1 << i), x -= a[i];
          goto E;
        }
      for (int i = (0); i <= (n - 1); ++i)
        if (st & (1 << i)) ++b[i];
    }
  E:;
  }
  priority_queue<pair<int, int> > q;
  for (int i = (0); i <= (n - 1); ++i) q.push({b[i], a[i]});
  for (int ti = (1); ti <= (n - 1); ++ti) {
    pair<int, int> u = q.top();
    q.pop();
    pair<int, int> v = q.top();
    q.pop();
    cout << u.second << " " << v.second << '\n';
    int tmp = u.second + v.second, num = u.first;
    while (tmp % k == 0) tmp /= k, --num;
    q.push({num, tmp});
  }
}
