#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1201;
bitset<maxn * maxn> dp[17];
signed p[17][maxn * maxn];
long long a[17];
long long kp[maxn];
long long n, k;
long long zc(long long x) {
  if (x % k) return 0;
  return 1 + zc(x / k);
}
signed main() {
  cin >> n >> k;
  kp[0] = 1;
  for (long long i = 1;; i++) {
    kp[i] = kp[i - 1] * k;
    if (kp[i] >= maxn * maxn) break;
  }
  for (long long i = 0; i < n; i++) cin >> a[i];
  dp[0][a[0]] = 1;
  for (long long i = 1; kp[i] * a[0] < maxn * maxn; i++)
    dp[0][a[0] * kp[i]] = 1;
  for (long long i = 1; i < n; i++) {
    for (long long y = 1; y + a[i] < maxn * maxn; y++) {
      for (long long j = 0; kp[j] * a[i] + y < maxn * maxn; j++) {
        long long gg = kp[j] * a[i] + y, zz = zc(gg);
        dp[i][gg] = dp[i][gg] | dp[i - 1][y];
        if (dp[i - 1][y]) p[i][gg] = y;
      }
    }
  }
  for (long long i = 1; i < maxn * maxn; i *= k)
    if (dp[n - 1][i]) {
      cout << "YES\n";
      vector<long long> nums;
      long long x = i;
      for (long long j = n - 2; j >= 0; j--) {
        nums.push_back(x - p[j + 1][x]);
        x = p[j + 1][x];
      }
      nums.push_back(x);
      for (long long j = 0; j < n - 1; j++) {
        bool flg = 1;
        for (long long l = 0; flg && l < nums.size(); l++) {
          for (long long r = l + 1; r < nums.size(); r++) {
            if (zc(nums[l]) == zc(nums[r])) {
              cout << nums[l] / kp[zc(nums[l])] << ' '
                   << nums[r] / kp[zc(nums[r])] << '\n';
              flg = 0;
              nums.push_back(nums[l] + nums[r]);
              nums.erase(nums.begin() + r);
              nums.erase(nums.begin() + l);
              break;
            }
          }
        }
      }
      return 0;
    }
  cout << "NO";
  return 0;
}
