#include <bits/stdc++.h>
#define int long long
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define loop(n) for (int i = 0; i < n; i++)
#define loopo(i, n) for (int i = 0; i < n; i++)
#define double long double
#define mod 1000000007
#define modi 998244353
#define pi 3.1415926535897
#define F first
#define S second
#define pb push_back
#define getvar(x) \
    int x;        \
    cin >> x;
#define getvec(v, n)               \
    vector<int> v(n);              \
    for (int bc = 0; bc < n; bc++) \
    {                              \
        cin >> v[bc];              \
    }
#define MAX 1000000

using namespace std;

signed main(){
    int test=1;
    cin>>test;
    for(int q=0;q<test;q++) {
        int n,m;cin>>n>>m;
        getvec(v,n);
        map<int,int> mp;
        loop(n){
            // cout<<v[i]%m<<endl;
            if(mp.find(v[i]%m)==mp.end()) {
                mp[v[i]%m]=1;
            } else {
                mp[v[i]%m]++;
            }
        }
        int ans = 0;
        int tmp,tmp2;
        // for(auto x = mp.begin();x!=mp.end();x++) {
        //     int val = x->first;
        //     cout<<val<<" "<<x->second<<endl;
        // }
        for(auto x = mp.begin();x!=mp.end();x++) {

            int val = x->first;
            // cout<<val<<" "<<x->second<<endl;
            if(val==0 && mp[val]!=0) {
                ans++;
                mp[val]=0;
            // } else if(val>m) {
            //     ans+=mp[val];
            } else if(m%val==0 && m/val==2 && mp[val]!=0) {
                ans++;
                mp[val]=0;
            } else if(mp[val]==0) {
                continue;
            } else if(mp[m-val]==0) {
                ans+=x->second;
                mp[val]=0;
            } else {
                tmp = min(mp[val],mp[m-val]);
                tmp2 = max(mp[val],mp[m-val]);
                if(tmp!=tmp2) {
                    ans+= (1+tmp2-tmp-1);
                } else {
                    ans++;
                }
                mp[val]=0;
                mp[m-val]=0;
                // if(mp[val]<mp[m-val]) {
                //     ans+=(1+mp[m-val]-mp[val]-1);
                //     mp[m-val]=0;
                //     mp[val]=0;
                // } else if(mp[val]>mp[])

            }
            // cout<<ans<<endl;

        }
        cout<<ans<<endl;
    }
}