#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct outputer;
struct outputable {};
template <typename T>
inline auto sqr(T x) -> decltype(x * x) {
  return x * x;
}
template <typename T1, typename T2>
inline bool umx(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool umn(T1& a, T2 b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 16;
const int X = 2000;
struct Input {
  int n, k;
  int a[N];
  bool read() {
    if (!(cin >> n >> k)) {
      return 0;
    }
    for (int i = int(0); i < int(n); ++i) {
      cin >> a[i];
    }
    return 1;
  }
  void init(const Input& input) { *this = input; }
};
struct Data : Input {
  vector<pair<int, int> > ans;
  void write() {
    if (!((int)(ans).size())) {
      cout << "NO" << endl;
      return;
    }
    cout << "YES" << endl;
    for (int i = int(0); i < int(((int)(ans).size())); ++i) {
      cout << ans[i].first << ' ' << ans[i].second << endl;
    }
  }
};
namespace Main {
struct Solution : Data {
  bitset<X + 1> d[1 << N];
  int p[N];
  void solve() {
    ;
    memset(d, 0, sizeof d);
    d[0][0] = 1;
    for (int msk = int(0); msk < int(1 << n); ++msk) {
      for (int x = int(X / k + 1) - 1; x >= int(0); --x) {
        if (d[msk][x * k]) {
          d[msk][x] = 1;
        }
      }
      for (int i = int(0); i < int(n); ++i) {
        if (msk & (1 << i)) {
          continue;
        }
        d[msk + (1 << i)] |= d[msk] << a[i];
      }
    }
    if (!d[(1 << n) - 1][1]) {
      return;
    }
    int cnt = 0;
    int msk = (1 << n) - 1;
    int x = 1;
    while (msk) {
      ;
      if (x * k <= X && d[msk][x * k]) {
        cnt++;
        x *= k;
        continue;
      }
      for (int i = int(0); i < int(n); ++i) {
        if (!(msk & (1 << i))) {
          continue;
        }
        int y = x - a[i];
        if (y >= 0 && y <= X && d[msk - (1 << i)][y]) {
          p[i] = cnt;
          msk -= 1 << i;
          x = y;
          break;
        }
      }
    };
    vector<pair<int, int> > v;
    for (int i = int(0); i < int(n); ++i) {
      v.emplace_back(a[i], p[i]);
    }
    while (((int)(v).size()) > 1) {
      ;
      bool done = 0;
      for (int i = int(0); i < int(((int)(v).size())); ++i) {
        for (int j = int(0); j < int(i); ++j) {
          if (v[i].second == v[j].second) {
            ans.emplace_back(v[i].first, v[j].first);
            int s = v[i].first + v[j].first;
            int l = v[i].second;
            while (s % k == 0) {
              s /= k;
              l--;
            }
            v.erase(v.begin() + i);
            v.erase(v.begin() + j);
            v.emplace_back(s, l);
            done = 1;
            break;
          }
        }
        if (done) {
          break;
        }
      }
    }
  }
  void clear() { *this = Solution(); }
};
}  // namespace Main
Main::Solution sol;
int main() {
  cout.setf(ios::showpoint | ios::fixed);
  cout.precision(20);
  sol.read();
  sol.solve();
  sol.write();
  return 0;
}
