#include #include #include #include #include #define ll long long #define inf 1e9 #define eps 1e-10 #define md 1000000007 #define N 2010 using namespace std; int a[N],f[N]; int main() { int tt; scanf("%d",&tt); while (tt--) { int n,p; scanf("%d%d",&n,&p); for (int i=1;i<=n;i++) { scanf("%d",&a[i]); a[i]%=p; if (a[i]<0) a[i]+=p; } memset(f,0,sizeof(f)); f[0]=1; for (int i=1;i<=n;i++) { for (int j=2*p-1;j>=a[i];j--) { f[j]=(f[j]+f[j-a[i]])%md; } for (int j=p;j<2*p;j++) { f[j-p]=(f[j-p]+f[j])%md; f[j]=0; } } printf("%d\n",f[0]); } return 0; }