#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define yo cout<<"i got here\n";
using namespace std;
const int mod = 1e9+7,siz = 1e6+5;
int t,n,m,k,a[siz];
int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin>>t;
    while(t--)
    {
        cin>>n>>m;
        map<int,int>have;
        for(int i = 1;i<=n;i++)
        {
            cin>>a[i]; a[i]%=m; have[a[i]]++;
        }
        int ans = (have[0]>0?1:0);
        for(int i = 1;i<=m/2;i++)
        {
            int x = have[i];
            int y = have[m-i];
            if(x == 0 and y == 0) continue;
            int mn = min(x,y);
            int extra = max(x,y) - min(x,y) - 1;
            ans++; if(extra>0) ans+=extra;
        }
        cout<<ans<<endl;
    }

}
