#include<bits/stdc++.h>
using namespace std;
#define Fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ld long double
#define F first
#define S second
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define ppb pop_back()
#define pii pair<int, int>

int main(){
	Fio;
	ll tc=1;
	cin >> tc;
	for(int tt=1; tt<=tc; ++tt) {
		int n, m;
		cin >> n >> m;
		vector<ll> a(n), mod(m);
		for(int i=0; i<n; ++i) {
			cin >> a[i];
			++mod[a[i]%m];
		}

		int ans = 0;
		ans += (int)(mod[0] > 0);
		if(m%2 == 0)
			ans += (int)(mod[m/2] > 0);

		for(int i=1; i<=(m-1)/2; ++i) {
			if(mod[i] == 0 && mod[(m-i)%m] == 0)
				continue;
			if(mod[i] == mod[(m-i)%m]) {
				ans += 1;
				continue;
			}
			ans += (max(mod[i], mod[(m-i)%m]) - min(mod[i], mod[(m-i)%m]));
		}
		cout << ans << '\n';

	}

	return 0;
}