#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int tc;
  cin >> tc;
  while (tc--) {
    int n, k;
    cin >> n >> k;
    long long arr[70] = {0};
    bool chk = false;
    for (int i = 0; i < n; i++) {
      long long x;
      cin >> x;
      long long pow = 0;
      while (x) {
        arr[pow] += x % k;
        x /= k;
        if (arr[pow] > 1) chk = true;
        pow++;
      }
    }
    if (chk)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
