

#include <bits/stdc++.h>
#define ll long long 
#define ld long double
#define int long long
using namespace std;
const ll INF = 1e18;
const ll MOD = 998244353;


void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> arr(n);
	map<int, int> mp;
	for(int &x: arr)	cin >> x, mp[x % m]++;
	int ans = 0;
	if(mp.count(0))		ans++;
	int l = 1, r = m - 1;
	for(int i = 1; l < r; i++) {
		if(mp[l] and mp[r])		{
			ans++;
			int tmp = min(mp[l], mp[r]);
			int cur = max(mp[l], mp[r]);
			if(cur > tmp)	tmp++;
			mp[l] -= tmp, mp[r] -= tmp;
			mp[l] = max(0ll, mp[l]);
			mp[r] = max(0ll, mp[r]);
		}
		ans += mp[l];
		ans += mp[r];
		l++, r--;
	}
	if(!(m&1) and mp[m / 2] > 0)	ans++;
	cout << ans << "\n";
}

int32_t main() {
	ios::sync_with_stdio(!cin.tie(NULL));
		
	int t;
	cin >> t;
	while(t--){
	solve();
	}
}

