func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10, mod = 1e9 + 7;   int a[N];   int qmi(int a, int b) {     int res = 1;     while (b) {       if (b & 1) res = (long long)res * a % mod;       b >>= 1;       a = (long long)a * a % mod;     }     return res;   }   int main() {     int T;     scanf( %d , &T);     while (T--) {       int n, k;       scanf( %d%d , &n, &k);       for (int i = 1; i <= n; i++) scanf( %d , a + i);       if (k == 1) {         printf(n & 1 ?  1  :  0 );         puts(  );         continue;       }       sort(a + 1, a + 1 + n);       int sum = 1, ans = 0, t = 1;       bool flag = true;       for (int i = n - 1; i >= 1; i--) {         int d = a[i + 1] - a[i];         if (sum > 0) {           while (sum < N && d) {             if ((long long)sum * k > N)               sum = N * 2;             else               sum = sum * k;             d--;             t = (long long)t * k % mod;           }         }         t = (long long)t * qmi(k, d) % mod;         if (sum)           sum--, t = ((long long)t + mod - 1) % mod;         else           sum = 1, t = 1;       }       printf( %lld n , (long long)qmi(k, a[1]) * t % mod);     }     return 0;   }   