#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
bitset<maxn> dp[1 << 16];
int a[100], k, sum, b[100], n;
priority_queue<pair<int, int> > Q;
void dfs(int s, int x) {
  if (!s) return;
  for (; x * k <= sum && dp[s][x * k]; x *= k) {
    for (int j = 0; j < n; ++j)
      if ((s >> j) & 1) ++b[j];
  }
  for (int i = 0; i < n; ++i)
    if (((s >> i) & 1) && (x > a[i]) && dp[s ^ (1 << i)][x - a[i]]) {
      dfs(s ^ (1 << i), x - a[i]);
      return;
    }
}
int main() {
  int N;
  cin >> n >> k;
  N = 1 << n;
  for (int i = 0; i < n; ++i) cin >> a[i], sum += a[i];
  dp[0][0] = 1;
  for (int i = 1; i < 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 / k; ~j; --j)
      if (dp[i][j * k]) dp[i][j] = 1;
  }
  if (!dp[N - 1][1])
    puts("NO");
  else {
    dfs(N - 1, 1);
    puts("YES");
    for (int i = 0; i < n; ++i) Q.push(make_pair(b[i], a[i]));
    while (Q.size() > 1) {
      pair<int, int> x = Q.top();
      Q.pop();
      pair<int, int> y = Q.top();
      Q.pop();
      cout << x.second << ' ' << y.second << endl;
      x.second += y.second;
      for (; x.second % k == 0; x.second /= k) --x.first;
      Q.push(x);
    }
  }
  return 0;
}
