#include #include #include #include #include #include #include #include #include using namespace std; __int64 a[1005]; __int64 dp1[1005]; __int64 dp2[1005]; __int64 mod = 1000000007; void Deal_with() { __int64 T,n; __int64 q; scanf("%I64d",&T); while(T--) { scanf("%I64d %I64d",&n,&q); __int64 tempa; memset(dp1,0,sizeof(dp1)); memset(dp2,0,sizeof(dp2)); for(__int64 i = 1 ; i <= n ; i ++) { scanf("%I64d",&tempa); a[i] = (tempa + 1000000000 * q) % q; } //dp2[0] = 1; for(__int64 i = 1 ; i <= n ; i ++) { for(__int64 j = 0 ; j < q ; j++) { dp1[(j+a[i])%q] = (dp2[(j+a[i])%q] + dp2[j]) % mod; } dp1[a[i]] = (dp1[a[i]] + 1) % mod; for(__int64 j = 0 ; j < q ; j++) { dp2[j] = dp1[j]; } } dp2[0] = ( dp2[0] + 1 ) % mod; printf("%I64d\n",dp2[0]); } } int main(void) { //freopen("a.in","r",stdin); Deal_with(); return 0; }