#include<bits/stdc++.h>
using namespace std;
typedef long long li;
typedef long double ld;
typedef pair<int,int> pt;
typedef pair<ld, ld> ptd;
typedef unsigned long long uli;

#define loop(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define mset(a, val) memset(a, val, sizeof (a))
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ft first
#define sc second
#define sz(a) int((a).size())
#define x first
#define y second


const int INF = int(1e9);
const li INF64 = li(INF) * li(INF);
const ld EPS = 1e-9;
const ld PI = ld(3.1415926535897932384626433832795);
int main(){
	int t;
	cin>>t;
	while(t--){
int n,m;
cin>>n>>m;
vector<int>arr(n);
vector<int>rem(m,0);
loop(i,0,n){
	cin>>arr[i];
	rem[arr[i]%m]++;
}
int ans=0;
if(rem[0]>=1){
ans++;
}

int i=1,j=m-1;
while(i<j){
	if(rem[i]==0 || rem[j]==0){
		ans+=(max(rem[i],rem[j]));
	}else{
		if((max(rem[i],rem[j])==min(rem[i],rem[j]))){
		ans++;	
		}
		else{
			ans+=(1+(max(rem[i],rem[j])-min(rem[i],rem[j])));
			ans--;
		}
	}
	
i++;j--;

}
if(m%2==0 && rem[m/2]>0)
ans++;
cout<<ans<<"\n";

}
return 0;
}
