#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, a, k;
  cin >> n >> k;
  long long c[80] = {0};
  for (long long i = 0; i < n; i++) {
    cin >> a;
    long long ind = 0;
    while (a) {
      c[ind] += a % k;
      ind++;
      a /= k;
    }
  }
  for (long long i = 0; i < 80; i++) {
    if (c[i] > 1) {
      cout << "NO" << endl;
      return;
    }
  }
  cout << "YES" << endl;
}
int main() {
  long long t;
  cin >> t;
  while (t--) solve();
}
