#include <bits/stdc++.h>
using namespace std;
#define TC 1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

template <typename T>
vector<T> readArr(int n) {
    vector <T> v(n);
    for (auto &it : v)
        cin >> it;
    return v;
}

void init() {
    ;
}

const int N = 1e5+ 5;

void solve() {
    int n, m; cin >> n >> m;
    
    vector <int> v = readArr<int>(n);
    
    for (int &x: v)
        x = x % m;
    
    vector <int> ct(N);
    for (int x: v)
        ct[x]++;
        
    int res = (ct[0] > 0 ? 1 : 0);
  //  cout << deb(res) << "\n";
    for (int i=1; i<=m/2; i++) {
        int j = m - i;
        if (i == j) {
            res += (ct[j] > 0 ? 1 : 0);
           // cout << deb(i) deb(res) << "\n";
            continue;
        }
        int a = ct[i], b = ct[j];
        if (a > 0 && b > 0) {
            res++;
            if (a <= b) {
                ct[i] = 0;
                ct[j] -= (a+1);
                ct[j] = max(ct[j], 0);
            } else {
                ct[j] = 0;
                ct[i] -= (b+1);
                ct[i] = max(ct[i], 0);
            }
        }
        
        
        res += ct[i];
        res += ct[j];
        
       // cout << deb(i) deb(j) deb(res) << "\n";
    }
    cout << res << "\n";
}

int main() {
    IOS
    init();
    int t = 1;
    if (TC)
        cin >> t;

    while (t--) {
        solve();
    }
}
