#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;

void solve(){
    int n,m;
    long long int x;
    cin>>n>>m;
    int arr[m];
    for(int i=0;i<m+1;i++) arr[i]=0;
    for(int i=0;i<n;i++){
        cin>>x;
        int t=x%m;
        arr[t]+=1;
    }
    // cout<<m<<n<<endl;
    int ans=0;
    for(int i=1;i<m;i++){
        if(arr[i]>0){
            long long int rest=m-i;
            
            if(arr[rest]>0){
                
                if(arr[rest]==arr[i]){
                    ans+=1;
                    arr[rest]=0;arr[i]=0;
                }
                else if(arr[i]>arr[rest]){
                    ans+=1;
                    arr[i]=arr[i]-arr[rest]-1;arr[rest]=0;
                    ans=ans+arr[i];arr[i]=0;
                }else{
                    ans+=1;
                    arr[rest]=arr[rest]-arr[i]-1;arr[i]=0;
                    ans=ans+arr[rest];arr[rest]=0;
                }
                
                
            }else{
                ans=ans+arr[i];
                arr[i]=0;
            }
        }
    }
    if(arr[0]>0) ans++;
    cout<<ans<<endl;
}
int main()
{
   int t;
   cin>>t;
   while(t--)
   solve();
   
   return 0;
}