#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007LL;
long long large = 2000000000000000000LL;
int n, k;
bitset<2010> dp[1 << 16];
vector<int> b, a;
void dfs(int s, int t, int layer) {
  if (s == 0) return;
  if (t > 2000) return;
  for (int i = 0; i < n; i++) {
    if (((s >> i) & 1) && t >= a[i] && dp[s ^ (1 << i)][t - a[i]]) {
      b[i] = layer;
      dfs(s ^ (1 << i), t - a[i], layer);
      return;
    }
  }
  dfs(s, t * k, layer + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  a.assign(n, 0);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  dp[0].set(0);
  for (int i = 1; i < (1 << n); i++) {
    for (int j = 0; j < n; j++) {
      if ((i >> j) & 1) {
        dp[i] |= (dp[i ^ (1 << j)] << a[j]);
      }
    }
    for (int j = sum; j >= 1; j--)
      if (j % k == 0 && dp[i][j]) dp[i][j / k] = 1;
  }
  if (dp[(1 << n) - 1][1]) {
    cout << "YES" << endl;
    b.assign(n, -1);
    dfs((1 << n) - 1, 1, 0);
    priority_queue<pair<int, int> > pq;
    for (int i = 0; i < n; i++) pq.push(pair<int, int>(b[i], a[i]));
    while (pq.size() > 1) {
      pair<int, int> t1 = pq.top();
      pq.pop();
      pair<int, int> t2 = pq.top();
      pq.pop();
      assert(t1.first == t2.first);
      cout << t1.second << " " << t2.second << endl;
      int sum = t1.second + t2.second;
      int temp = t1.first;
      while (sum % k == 0) {
        sum /= k;
        temp--;
      }
      pq.push(pair<int, int>(temp, sum));
    }
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
