#include<iostream>
#include<cstdio>
using namespace std;
const int N=1e5+13;
int n,m,cnt[N];
int main(){
	int T;scanf("%d",&T);
	while(T--){
		scanf("%d%d",&n,&m);int ans=0;
		for(int i=0;i<=m;++i) cnt[i]=0;
		for(int i=1,x;i<=n;++i){
			scanf("%d",&x);
			cnt[x%m]++;
		}
		if(cnt[0]) ans++;
		if(m%2==0&&cnt[m/2]) ans++;
		for(int i=1;i<=(m-1)/2;++i){
			int x=max(cnt[i],cnt[m-i]),y=min(cnt[i],cnt[m-i]);
			if(!y) ans+=x;
			else if(x<=y+1) ans++;
			else ans+=x-y;
		}
		printf("%d\n",ans);
	}
	return 0;
}
