#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; typedef double DB; typedef pair PII; typedef vector VI; typedef vector VPII; #define X first #define Y second #define pb push_back #define bit(n) (1 << (n)) #define count(n) (__builtin_popcount(n)) #define countl(n) (__builtin_popcountll(n)) template inline void chkmin(T &x, T y) { if (y < x) x = y; } template inline void chkmax(T &x, T y) { if (x < y) x = y; } const int MN = 1005; const int MOD = int(1e9 + 7); int n, p; int val[MN], _val[MN]; int a[MN]; int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); int tn; for (cin >> tn; tn--; ) { scanf("%d%d", &n, &p); for (int i = 0; i < n; i++) scanf("%d", a + i), a[i] %= p, a[i] = (a[i] + p) % p; memset(_val, 0, sizeof _val); memset(val, 0, sizeof val); _val[0] = 1; val[0] = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < p; j++) { val[(j + a[i]) % p] = (val[(j + a[i]) % p] + _val[j]) % MOD; } memcpy(_val, val, sizeof val); } printf("%d\n", val[0]); } return 0; }