#include <bits/stdc++.h>
using namespace std;
int n, k, sum;
int a[16], d[16];
bitset<2010> dp[1 << 16];
void dfs(int S, int x) {
  if (!S) return;
  while (x * k <= sum && dp[S][x * k]) {
    x *= k;
    for (int i = 0; i < n; i++)
      if (S & (1 << i)) d[i]++;
  }
  for (int i = 0; i < n; i++)
    if ((S & (1 << i)) && a[i] <= x && dp[S ^ (1 << i)][x - a[i]]) {
      dfs(S ^ (1 << i), x - a[i]);
      return;
    }
  return;
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  dp[0][0] = 1;
  for (int s = 1; s < (1 << n); s++) {
    for (int i = 0; i < n; i++)
      if (s & (1 << i)) dp[s] |= dp[s ^ (1 << i)] << a[i];
    for (int i = sum / k; i; i--)
      if (dp[s][i * k]) dp[s][i] = 1;
  }
  int S = (1 << n) - 1;
  if (!dp[S][1])
    printf("NO\n");
  else {
    printf("YES\n");
    dfs(S, 1);
    priority_queue<pair<int, int> > q;
    for (int i = 0; i < n; i++) q.push(make_pair(d[i], a[i]));
    while (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;
      while (u.second % k == 0) {
        u.second /= k;
        u.first--;
      }
      q.push(u);
    }
  }
  return 0;
}
