#include <bits/stdc++.h>
using namespace std;
const int N = 2005, M = 1 << 16;
using arr = int[M];
bitset<N> f[M];
priority_queue<pair<int, int> > q;
int n, k, T, Sum, a[20], Rank[20];
void dfs(int S, int p) {
  if (!S) return;
  int r = 0;
  for (; p * k <= Sum && f[S][p * k]; p *= k, ++r)
    ;
  if (r)
    for (int i = 0; i < n; ++i)
      if (S & (1 << i)) Rank[i] += r;
  for (int i = 0; i < n; ++i)
    if (S & (1 << i))
      if (p >= a[i] && f[S - (1 << i)][p - a[i]]) {
        dfs(S - (1 << i), p - a[i]);
        return;
      }
}
int main() {
  scanf("%d%d", &n, &k);
  T = (1 << n) - 1;
  f[0][0] = 1;
  for (int i = 0; i < n; ++i) scanf("%d", a + i), Sum += a[i];
  for (int s = 1; s <= T; ++s) {
    for (int i = 0; i < n; ++i)
      if (s & (1 << i)) f[s] |= f[s - (1 << i)] << a[i];
    for (int j = Sum / k; j; --j)
      if (f[s][j * k]) f[s][j] = 1;
  }
  if (!f[T][1]) return puts("NO"), 0;
  puts("YES");
  dfs(T, 1);
  for (int i = 0; i < n; ++i) q.push(make_pair(Rank[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;
    for (; u.second % k == 0; u.second /= k) --u.first;
    q.push(u);
  }
  return 0;
}
