#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long int t = 1;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int a[n];
    long long int flag = 0;
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
    }
    long long int b[64] = {0};
    for (long long int i = 0; i < n; i++) {
      long long int ctr = 0;
      while (a[i] > 0) {
        b[ctr] += (a[i] % k);
        ctr++;
        a[i] /= k;
      }
    }
    for (long long int i = 0; i < 64; i++) {
      if (b[i] > 1) flag = 1;
    }
    if (flag == 0) {
      cout << "YES" << '\n';
    } else
      cout << "NO" << '\n';
  }
}
