#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod=1e9; 
const int maxn=1e5+5;
int n,m,t,x,a[maxn],ans;
int main(){
	scanf("%d",&t);
	while(t--){
		ans=0;
		memset(a,0,sizeof(a));
		scanf("%d%d",&n,&m);
		for(int i=1;i<=n;i++){
		   scanf("%d",&x);
		   a[x%m]++;
	    }
	    if(a[0])ans++;
			for(int i=1;i<=m/2;i++){
	    		if(a[i]&&a[m-i]==0)ans+=a[i];
	    		else if(a[m-i]&&a[i]==0)ans+=a[m-i];
	    		else if(a[m-i]==a[i]&&a[i])ans++;
	    		else if(a[i]&&a[m-i]!=a[i])ans+=abs(a[i]-a[m-i]);
			}
		printf("%d\n",ans);
	}
}