#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mem0(x) memset(x, 0, sizeof(x))
#define for0(i, n) for (i = 0; i < n; i++)

int main() {
    int c, i, j, k, n, m;
    int tmp, val[100001];
    int ans;
    cin >> c;
    while (c--) {
        ans = 0;
        mem0(val);
        cin >> n >> m;
        for0(i, n) {
            cin >> tmp;
            tmp %= m;
            val[tmp]++;
        }
        if (val[0]) {
            ans++;
        }
        if (m % 2 == 1) {
            for (i = 1; i < (m + 1) / 2; i++) {
                if (!val[i] && !val[m - i]) {
                    continue;
                }
                if (abs(val[i] - val[m - i]) <= 1) {
                    ans++;
                } else {
                    ans += abs(val[i] - val[m - i]);
                }
            }
        } else {
            for (i = 1; i < m / 2; i++) {
                if (!val[i] && !val[m - i]) {
                    continue;
                }
                if (abs(val[i] - val[m - i]) <= 1) {
                    ans++;
                } else {
                    ans += abs(val[i] - val[m - i]);
                }
            }
            if (val[m / 2]) {
                ans++;
            }
        }
        cout << ans << endl;
    }
}