#include <bits/stdc++.h>
using namespace std;
inline int getint() {
  int num = 0, flag = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag = -1;
  while (c >= '0' && c <= '9') num = num * 10 + c - 48, c = getchar();
  return num * flag;
}
int n, k, a[16], lg[1 << 16], N, sum;
bitset<2005> dp[1 << 16];
int d[16];
priority_queue<pair<int, int> > q;
void dfs(int sta, int s) {
  if (!sta) return;
  for (; s * k <= sum && dp[sta][s * k]; s *= k)
    for (int t = sta; t; t -= t & -t) d[lg[t & -t]]++;
  for (int t = sta; t; t -= t & -t)
    if (s >= a[lg[t & -t]] && dp[sta - (t & -t)][s - a[lg[t & -t]]]) {
      dfs(sta - (t & -t), s - a[lg[t & -t]]);
      return;
    }
}
int main() {
  scanf("%d%d", &n, &k);
  N = 1 << n;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]), lg[1 << i] = i, sum += a[i];
  dp[0][0] = 1;
  for (int i = 1; i < N; i++) {
    for (int t = i; t; t -= t & -t) {
      int v = t & -t, u = lg[v];
      dp[i] |= (dp[i - v] << a[u]);
    }
    for (int j = sum / k; j >= 1; j--)
      if (dp[i][j * k]) dp[i][j] = 1;
  }
  if (!dp[N - 1][1])
    puts("NO");
  else {
    puts("YES");
    dfs(N - 1, 1);
    for (int i = 0; i < n; i++) q.push(make_pair(d[i], a[i]));
    for (; q.size() > 1;) {
      pair<int, int> u = q.top();
      q.pop();
      pair<int, int> v = q.top();
      q.pop();
      printf("%d %d\n", u.second, v.second);
      u.second += v.second;
      for (; u.second % k == 0; u.second /= k) u.first--;
      q.push(u);
    }
  }
}
