#include<bits/stdc++.h>
using namespace std;
#define pi (3.141592653589)
#define double long double
#define int long long
string Y = "YES";
string N = "NO";
void solve(){
	int n,m; cin>>n>>m;
	map<int,int> c;
	// vector<int> a[m];
	// vector<int> b;
	for(int i = 0; i < n; ++i){
		int h; cin>>h;
		// a[h % m].push_back(h);
		c[h % m]++;
		// b.push_back(h % m);
	}
	int ans = 0;
	for(int i = 0; i < m; ++i){
		if(i == 0){
			if(c[i] != 0){
				ans++;
				c[i] = 0;
			}
			continue;
		}
		if(c[i] != 0 && c[m - i] == 0){
			ans += c[i];
			c[i] = 0;
		}
		if(c[i] != 0 && c[m - i] != 0){
			if(i == m - i){
				ans++;
				c[i] = 0;
			}else{
				ans++;
				int h = max(c[i],c[m - i]) - min(c[i],c[m - i]);
				c[i] = 0;
				c[m - i] = 0;
				if(h > 1){
					ans += h - 1;
				}
			}
		}
	}
	cout<<ans;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    int t = 1;
    // freopen("in","r",stdin);
    // freopen("out","w",stdout);
    cin >> t;
    while(t--) {
    	solve();
    	cout<<endl;
    }
}