#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <map>
#define int long long
using namespace std;

signed main() {
    int t; cin >> t;
    while (t--) {
        int n, m; cin >> n >> m;
        vector <int> d(m);
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            d[x % m]++;
        }
        int ans = 0;
        for (int i = 1; m - i > i; i++) {
            int one = min(d[i], d[m - i]), two = max(d[i], d[m - i]);
            if (two > 0)
                ans += 1 + max(0LL, two - one - 1);
        }
        if (m % 2 == 0 && d[m / 2] > 0)
            ans++;
        if (d[0] > 0)
            ans++;
        cout << ans<< endl;
    }
    return 0;
}

/*
2
5 3
2 2 1 2 1
5 3
2 2 1 2 1
*/