#include <bits/stdc++.h>
using namespace std;
const long long int hell = (long long int)(1e18 + 100LL);
const double pi = acos(-1.0);
long long int me(long long int x, long long int n) {
  long long int res = 1LL;
  x = x;
  while (n > 0LL) {
    if (n % 2LL == 1LL) {
      res = (res * x);
    }
    x = (x * x);
    n /= 2LL;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t, i, j, k, m, n, x, y;
  t = 1;
  cin >> t;
  while (t--) {
    long long int flag = 0, K;
    cin >> n >> K;
    vector<long long int> ans(61, 0);
    vector<long long int> ar(n, 0);
    for (i = 0; i < n; i++) {
      cin >> x;
      ar[i] = x;
    }
    for (i = 0; i < n; i++) {
      x = ar[i];
      y = K;
      long long int c = 0;
      while (x > 0) {
        ans[c] += (x % y);
        x /= y;
        c++;
      }
    }
    for (i = 0; i <= 60; i++) {
      if (ans[i] > 1) {
        flag = 1;
        break;
      }
    }
    if (flag) {
      cout << "NO\n";
    } else {
      cout << "YEs\n";
    }
  }
  return 0;
}
