#include #include #include #include using namespace std; typedef long long LL; const LL MOD = 1e9+7; LL f[1010][2]; int main() { int t; scanf("%d", &t); while (t--) { memset(f, 0, sizeof(f)); f[0][0] = 1; int n, p; scanf("%d%d", &n, &p); for (int i = 0; i < n; i++) { LL k; scanf("%I64d", &k); for (int j = 0; j < p; j++) f[((k+j)%p+p)%p][1^(i&1)] = (f[((k+j)%p+p)%p][i&1] + f[j][i&1]) % MOD; } printf("%I64d\n", f[0][n&1]); } return 0; }