 
 #include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define int long long 

pair<int,int> find1(int prev,int curr){
    int cnt = 0;
    int cnt1 = 0;
    while(curr<prev){
        curr += pow(2,cnt);
        cnt++;
        cnt1++;
        
        
    }
    
    pair<int,int>p1;
    p1.first = curr;
    p1.second = cnt1;
    return p1;
    
    
}
 
 
void solve(){
int n,m;
cin>>n>>m;
vector<int>v;
map<int,int>m1;

for(int i=0;i<n;i++){
    int x;
    cin>>x;
    v.push_back(x);
    int val = v[i]%m;
    m1[val]++;
 
}

int count = 0;
for(auto it=m1.begin();it!=m1.end();it++){
    
    int val1 = it->first;
    int val2 = it->second;
    if(val2==0){
        continue;
    }
    
    if(val1==0){
        count++;
        continue;
    }
    if(m1.find(m-val1)==m1.end() || m1[m-val1]==0){
        count += val2;
        continue;
    }
    int val3 = m1[m-val1];
    int can = min(val2,val3);
    
    if(can!=0){
    m1[val1] = m1[val1] - can;
    m1[m-val1] = m1[m-val1] - can;
     count++;
    }
   
    if(m1[val1]>0){
        count += (m1[val1]-1);
    }
      if(m1[m-val1]>0){
        count += (m1[m-val1]-1);
    }
    
    m1[val1] = 0;
    m1[m-val1] = 0;
    
}

cout << count << endl;

















   
    
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
cin>>t;
    while(t--){
        solve();
    }
    

    
    
    
    
    
}