#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void cmin(T &a, T b) {
  ((a > b) && (a = b));
}
template <class T>
inline void cmax(T &a, T b) {
  ((a < b) && (a = b));
}
char IO;
template <class T = int>
T rd() {
  T s = 0;
  int f = 0;
  while (!isdigit(IO = getchar())) f |= IO == '-';
  do s = (s << 1) + (s << 3) + (IO ^ '0');
  while (isdigit(IO = getchar()));
  return f ? -s : s;
}
const int N = 30, INF = 1e9 + 10;
int n, k;
int dp[1 << 20], pre[1 << 20];
int F[2010];
void dfs(int p) {
  if (!pre[p]) return;
  dfs(pre[p]), dfs(pre[p] ^ p);
  printf("%d %d\n", dp[pre[p]], dp[pre[p] ^ p]);
}
int main() {
  n = rd(), k = rd();
  for (int i = 0, iend = n - 1; i <= iend; ++i) dp[1 << i] = rd();
  for (int i = 1, iend = 2000; i <= iend; ++i) F[i] = i % k == 0 ? F[i / k] : i;
  int A = (1 << n) - 1;
  for (int i = 1, iend = A; i <= iend; ++i)
    if (!dp[i]) {
      dp[i] = 1e9;
      for (int j = i & (i - 1); j >= (j ^ i); j = (j - 1) & i) {
        int t = F[dp[j] + dp[j ^ i]];
        if (t < dp[i]) dp[i] = t, pre[i] = j;
      }
    }
  if (dp[A] > 1) return puts("NO"), 0;
  puts("YES");
  dfs(A);
}
