#include <bits/stdc++.h>
const int maxn = 1 << 16;
const int maxm = 16;
using namespace std;
int rd() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = (x << 3) + (x << 1) + c - '0', c = getchar();
  return x * f;
}
bitset<2002> dp[maxn];
int n, k, a[maxm], sum, id[maxn], U, b[maxm];
int lowbit(int x) { return x & (-x); }
priority_queue<pair<int, int> > q;
void dfs(int x, int y) {
  if (!x) return;
  if (y * k <= sum && dp[x][y * k]) {
    for (int T = x; T; T -= lowbit(T)) {
      int i = id[lowbit(T)];
      b[i]++;
    }
    dfs(x, y * k);
    return;
  }
  for (int T = x; T; T -= lowbit(T)) {
    int i = id[lowbit(T)];
    if (y - a[i] >= 0 && dp[x ^ (1 << i)][y - a[i]]) {
      dfs(x ^ (1 << i), y - a[i]);
      return;
    }
  }
}
int main() {
  n = rd();
  k = rd();
  U = (1 << n) - 1;
  for (int i = 0; i < n; i++) a[i] = rd(), sum += a[i], id[1 << i] = i;
  dp[0][0] = 1;
  for (int S = 1; S <= U; S++) {
    for (int T = S; T; T -= lowbit(T)) {
      int i = id[lowbit(T)];
      dp[S] |= dp[S ^ (1 << i)] << a[i];
    }
    for (int j = sum / k; j >= 1; j--)
      if (dp[S][j * k]) dp[S][j] = 1;
  }
  if (!dp[U][1]) {
    puts("NO");
    return 0;
  }
  puts("YES");
  dfs(U, 1);
  for (int i = 0; i < n; i++) q.push(make_pair(b[i], a[i]));
  while (((int)q.size()) > 1) {
    pair<int, int> x = q.top();
    q.pop();
    pair<int, int> y = q.top();
    q.pop();
    printf("%d %d\n", x.second, y.second);
    x.second += y.second;
    while (x.second % k == 0) x.second /= k, x.first--;
    q.push(x);
  }
  return 0;
}
