#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sorta(a) sort(a,a+n)
#define sortv(v) sort(begin(a), end(a))
#define rep(n) for(int i=0;i<n;i++)
#define mpp make_pair
#define mod 1000000007
#define maxn 1000000008

using namespace std;

vector<ll> gpf(ll n) 
{ 
  	vector<ll> v;
	while (n % 2 == 0) 
	{ 
		v.pb(2ll);
		n = n/2; 
	} 
	for (ll i = 3; i <= sqrt(n); i = i + 2) 
	{ 
		while (n % i == 0) 
		{ 
			v.pb(i);
			n = n/i; 
		} 
	} 
	if (n > 2) 
		v.pb(n);
    return v;
} 


ll gcd(ll a,ll b){
    if(b==0) return a; 
    return gcd(b,a%b);
}

ll lcm(int a, int b)
{
    return (a / gcd(a, b)) * b;
}

bool prime(ll n){
    if(n==1) return 0;
    else if(n==2) return 2;
    else{
        for(ll i=2;i*i<=n;i++){
            if(n%i==0){
                return i;
            }
        }
        return 0;
    }
    
}

string printBinary(ll n){
	string s="";
	while(n>0){
		//s+=to_string(n%2);
		n/=2;
	}
	reverse(s.begin(),s.end());
	return s;
}

ll round(ll a,ll b){
    if(a%b==0) return a/b;
    return(a/b)+1;
}

bool isp (ll x) // is power of two func
{ 
	return x && (!(x&(x-1))); 
} 

ll roundn(ll x,ll n){
	ll next = pow(n, ceil(log(x)/log(n)));
	if(next==x)return next;
	return next/n;
}
ll pw(ll x,ll n){
    return ceil(log(x)/log(n));
}

int bs(int arr[], int p, int r, int num) {
   if (p <= r) {
      int mid = (p + r)/2;
      if (arr[mid] == num)
      return mid ;
      if (arr[mid] > num)   
      return bs(arr, p, mid-1, num);
      if (arr[mid] > num)
      return bs(arr, mid+1, r, num);
   }
   return -1;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t=1;
	cin>>t;
	while(t--){
		int n,k;
		cin>>n>>k;
		int a[n];
		for(int i=0;i<n;i++)
			cin>>a[i];
		int f[k]; memset(f,0,sizeof(f));
		for(int i=0;i<n;i++)
			f[a[i]%k]++;

		int cnt=0;
		int res=0;
		if(f[0]) {
			cnt++;
			n-=f[0];
			//cout<<f[0]<<"\n";
		}
		for(int i=1;i<=k/2 && i!=(k-i); i++){
			//cout<<f[i]<<" "<<f[k-i]<<"\n";
			if(f[i] && f[k-i]){
				//cout<<f[i]<<" "<<f[k-i]<<"\n";
				cnt++;
				n-=(f[i]==f[k-i] ? f[i]*2 : (min(f[i],f[k-i])*2)+1);
			}
			
		}
		if(k%2==0 && f[k/2]){
			cnt++;
			n-=f[k/2];
			//cout<<f[k/2]<<"\n";
		}
		//cout<<n<<"\n";
		cout<<cnt+n<<"\n";
	}
}