#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void debug(string s) { cout << s << "\n"; }
const int MAX = 2000007;
bool prime[MAX];
int spf[MAX];
void sieve() {
  for (int i = 2; i < MAX; i += 2) spf[i] = 2;
  for (long long i = 3; i < MAX; i += 2) {
    if (!prime[i]) {
      spf[i] = i;
      for (long long j = i; (j * i) < MAX; j += 2) {
        if (!prime[j * i]) {
          prime[j * i] = true;
          spf[j * i] = i;
        }
      }
    }
  }
}
long long GCD(long long a, long long b) {
  long long c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}
long long power(long long a, long long b) {
  long long ans = 1;
  while (b != 0) {
    if (b % 2 == 1) ans *= a;
    a *= a;
    b = b >> 1;
  }
  return ans;
}
void void_main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<long long> h(100, 0);
  for (long long i = 0; i < n; i++) {
    long long x = v[i];
    long long j = 0;
    while (x) {
      long long rem = x % k;
      h[j++] += rem;
      x /= k;
    }
  }
  bool say = 1;
  for (long long i = 0; i < 100; i++) {
    if (h[i] > 1) {
      say = 0;
      break;
    }
  }
  if (say) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int _ = 1;
  cin >> _;
  while (_--) {
    void_main();
  }
  return 0;
}
