#include <bits/stdc++.h>
using namespace std;
template <typename T>
void debug_out(T t) {
  cerr << t;
}
template <typename A, typename B>
void debug_out(pair<A, B> u) {
  cerr << "(" << u.first << " " << u.second << ")";
}
template <typename T>
void debug_out(vector<T> t) {
  int sz = t.size();
  for (int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if (i != sz - 1) cerr << ", ";
  }
}
template <typename T>
void debug_out(vector<vector<T>> t) {
  int sz = t.size();
  for (int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if (i != sz - 1) cerr << endl;
  }
}
int n, k;
int main() {
  cin >> n >> k;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  int total = sum * sum;
  vector<int> p;
  p.push_back(1);
  while (p.back() <= total / k) p.push_back(p.back() * k);
  vector<vector<int>> dp(n + 1, vector<int>(total + 1, -1));
  dp[0][0] = 0;
  for (int i = 1; i < n + 1; i++) {
    for (int s = total; s > -1; s--) {
      for (int j = 0; j < (int)p.size(); j++) {
        long long val = 1LL * s - 1LL * a[i - 1] * p[j];
        if (val < 0) break;
        if (dp[i - 1][val] != -1) {
          dp[i][s] = j;
          break;
        }
      }
    }
  }
  int ps = -1;
  for (int i = 0; i < (int)p.size(); i++) {
    if (dp[n][p[i]] != -1) {
      ps = i;
      break;
    }
  }
  if (ps == -1) {
    cout << "NO";
    return 0;
  }
  cout << "YES\n";
  int c = p[ps];
  vector<int> cur;
  for (int i = n; i > 0; i--) {
    cur.push_back(ps - dp[i][c]);
    c -= a[i - 1] * p[dp[i][c]];
  }
  reverse(cur.begin(), cur.end());
  vector<vector<int>> pref(ps + 1);
  for (int i = 0; i < n; i++) pref[cur[i]].push_back(a[i]);
  for (int i = ps; i > 0; i--) {
    while (!pref[i].empty()) {
      int sz = pref[i].size();
      assert(sz > 1);
      int s = pref[i][sz - 1] + pref[i][sz - 2];
      cout << pref[i][sz - 1] << " " << pref[i][sz - 2] << endl;
      pref[i].pop_back();
      pref[i].pop_back();
      int cnt = 0;
      while (s % k == 0) {
        s /= k;
        cnt++;
      }
      pref[i - cnt].push_back(s);
    }
  }
  assert(pref[0].size() == 1 && pref[0][0] == 1);
  return 0;
}
