#include<bits/stdc++.h>
#define li long long int
#define ii int
using namespace std;
int main()
{
	li t;
	cin>>t;
	while(t--)
	{
		li n,m,i,ele;
		cin>>n>>m;
		vector<li>arr,freq(m);
		for(i=0;i<n;i++)
		{
			cin>>ele;
			arr.push_back(ele);
			freq[arr[i]%m]++;
		}
		li ac=0;
		ii s=0;
		for(i=0;i<=m/2;i++)
		{
			if(i==0)
			{
				if(freq[i]>0)
				++ac;
			}
			else
			{
				//cout<<"I: "<<i<<"freq[i]: "<<freq[i]<<endl;
				if(freq[i]==0 && freq[m-i]==0)
				{
				}
				else
				{
					s=max(freq[i],freq[m-i])-min(freq[i],freq[m-i]);
					//cout<<"S: "<<s<<endl;
					if(s>1)
					{
						ac+=s;
					}
					else if(s<=1)
					{
						++ac;
					}
				}
			}
		}
		cout<<ac<<endl;
		
	}
	return 0;
}
