#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define powr(x,n,p) for(int axy=0 ; axy<p ; axy++){x=x*n;}
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
#define nl printf("\n")
#define fr0(n,q) for(q=0 ; q<n ; q++)
#define fr1(n,q) for(q=1 ; q<=n ; q++)
#define mp make_pair
#define scl(x) scanf("%lld",&x)
#define sci(x) scanf("%d",&x)
#define lst(x) x[x.size()-1]
#define llst(x) x[x.size()-2]
#define md 1000000007
#define check(x,y) (x&(1LL<<y))
#define set(x,y) x=x|(1LL<<y)
#define pi acos(-1)
#define inf (1<<30)
#include <stdio.h>
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t,tc=1;
    cin>>t;
    while(t--){
        int n,m,i,j;
        cin>>n>>m;
        vector <int> rem(m+5);
        fr0(n,i){
            int x;
            cin>>x;
            rem[x%m]++;
        }
        int ans=0;
        if(rem[0]) ans++;
        for(i=1 ; i<m ; i++){
            if(!rem[i]) continue;
            int x=rem[i],y=rem[m-i];
            if(x==y){
                x=0;
                y=0;
            }
            else if(x>y){
                x-=(y+1);
                y=0;
            }
            else{
                y-=(x+1);
                x=0;
            }
            ans+=(1+x+y);
            rem[i]=0;
            rem[m-i]=0;
        }
        cout<<ans;
        nl;
    }
    return 0;
}