#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pi;
ll mod=1000000007;
ll max(ll a, ll b)
{
    return (a>b ? a : b);
}

void solve()
{
    ll n, k; cin>>n>>k;
    map<ll, ll> mp;
    for(ll i=0; i<n; i++)
    {
        ll a; cin>>a;
        mp[a%k]++;
    }
    ll ans=0;
    for(auto it=mp.begin(); it!=mp.end(); it++)
    {
        if(it->first==0 || k-it->first==it->first)
        {
            ans+=2;
            continue;
        }
        if(mp.find(k-it->first)!=mp.end())
        {
            ans++;
            if(abs(it->second-mp[k-it->first])>1)
            {
                ans+=abs(it->second-mp[k-it->first])-1;
            }
        }
        else
        {
            ans+=2*(it->second);
        }
    }
    cout<<ans/2<<endl;                     
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll t; cin>>t;
    while(t--)
    {
        solve();
    }
	// your code goes here
	return 0;
}