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