#include <bits/stdc++.h>
using namespace std;
struct node {
  int wh, va;
  friend bool operator<(node a, node b) { return a.va < b.va; }
};
int n, k, a[20], sum, p[20];
bitset<2003> dp[100006];
priority_queue<node> q;
void cal(int st, int pr) {
  if (!st) return;
  while (pr * k <= sum && dp[st][pr * k]) {
    for (int i = 1; i <= n; i++)
      if (st & (1 << (i - 1))) p[i]++;
    pr *= k;
  }
  for (int i = 1; i <= n; i++)
    if (pr > a[i] && st & (1 << (i - 1)) &&
        dp[st ^ (1 << (i - 1))][pr - a[i]]) {
      cal(st ^ (1 << (i - 1)), pr - a[i]);
      return;
    }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sum += a[i];
  dp[0][0] = 1;
  for (int i = 1; i < (1 << n); i++) {
    for (int j = 1; j <= n; j++)
      if (i & (1 << (j - 1))) {
        dp[i] |= dp[i ^ (1 << (j - 1))] << a[j];
      }
    for (int j = sum / k; j; j--)
      if (dp[i][j * k]) dp[i][j] = 1;
  }
  if (!dp[(1 << n) - 1][1]) {
    puts("NO");
    return 0;
  }
  puts("YES");
  cal((1 << n) - 1, 1);
  for (int i = 1; i <= n; i++) q.push((node){a[i], p[i]});
  while (q.size() > 1) {
    node n1 = q.top();
    q.pop();
    node n2 = q.top();
    q.pop();
    printf("%d %d\n", n1.wh, n2.wh);
    n1.wh += n2.wh;
    while (n1.wh % k == 0) n1.wh /= k, n1.va--;
    q.push(n1);
  }
}
