#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007L;
template <typename T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
template <typename T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <typename T>
void add(T &a, T b) {
  a += b;
  if (a < 0) a += MOD;
  if (a >= MOD) a -= MOD;
}
void FastIn(int &T) {
  char C;
  bool F = 0;
  for (; C = getchar(), C < '0' || C > '9';)
    if (C == '-') F = 1;
  for (T = C - '0'; C = getchar(), C >= '0' && C <= '9'; T = T * 10 + C - '0')
    ;
  F && (T = -T);
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
double din() {
  double x;
  scanf("%lf", &x);
  return x;
}
long long p2[63];
void initP2() {
  p2[0] = 1;
  for (int i = (1); i <= (62); ++i) {
    p2[i] = p2[i - 1] * 2;
  }
}
int countBitsBaseB(long long n, long long b) {
  if (n == 0) return 1;
  int ret = 0;
  while (n) {
    ret++;
    n /= b;
  }
  return ret;
}
int count1(long long n) {
  int ret = 0;
  while (n) {
    ret += n & 1;
    n >>= 1;
  }
  return ret;
}
long long c[1024][1024] = {0};
void initC() {
  for (int i = 0; i < (1024); ++i) {
    for (int j = 0; j < (i + 1); ++j) {
      if (j == 0 || j == i) {
        c[i][j] = 1;
      } else {
        c[i][j] = c[i - 1][j - 1];
        add(c[i][j], c[i - 1][j]);
      }
    }
  }
}
bool IsPrime(int n) {
  if (n < 2) return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
void init() {
  initP2();
  initC();
}
const unsigned INVALID = 2000000001;
std::bitset<2001> dp[1 << (int)(16)];
int lg[1 << (int)(16) << 1] = {0};
int b[(int)(16)] = {0};
int a[(int)(16)] = {0};
void DFS(int state, int sum, int k, int total, int n, int deep) {
  if (state == 0) {
    return;
  }
  while (sum * k <= total && dp[state].test(sum * k)) {
    deep++;
    sum *= k;
  }
  for (int i = state; i; i -= -i & i) {
    int v = -i & i;
    int index = lg[v];
    if (sum >= a[index] && dp[state ^ v].test(sum - a[index])) {
      b[index] = deep;
      DFS(state ^ v, sum - a[index], k, total, n, deep);
      return;
    }
  }
}
int main() {
  init();
  int n = in(), k = in();
  const int full = 1 << n;
  int sum = 0;
  for (int i = 0; i < (n); ++i) {
    a[i] = in();
    sum += a[i];
    lg[1 << i] = i;
  }
  for (int i = 0; i < (full); ++i) {
    dp[i].reset();
  }
  dp[0].set(0);
  for (int i = (1); i <= (full - 1); ++i) {
    for (int t = i; t; t -= -t & t) {
      int v = -t & t;
      int index = lg[v];
      dp[i] |= dp[i ^ v] << a[index];
    }
    for (int j = (sum / k); j >= (1); --j) {
      if (dp[i].test(j * k)) {
        dp[i].set(j);
      }
    }
  }
  if (!dp[full - 1].test(1)) {
    puts("NO");
  } else {
    puts("YES");
    DFS(full - 1, 1, k, sum, n, 0);
    for (int loop = 0; loop < (n - 1); ++loop) {
      int maxB = -1;
      for (int i = 0; i < (n); ++i) {
        chmax(maxB, b[i]);
      }
      std::vector<int> indices;
      for (int i = 0; i < (n); ++i) {
        if (maxB == b[i]) {
          indices.push_back(i);
        }
      }
      int x = indices.front();
      int y = indices.back();
      printf("%d %d\n", a[x], a[y]);
      int sum = a[x] + a[y];
      while (sum % k == 0) {
        sum /= k;
        b[x]--;
      }
      a[x] = sum;
      b[y] = -1;
    }
  }
  return 0;
}
