/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⣤⣤⠀⢀⣤⣤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠛⠃⠀⣼⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣦⡀⠀⢰⣿⣿⣷⣶⣶⣄⠀⠀⣠⣴⣶⣶⡶⠂
⠀⠀⣼⣿⣿⠉⢹⣿⣿⠋⢩⣿⣿⠇⠀⣼⣿⡿⠉⣿⣿⡿⠀⢸⣿⣿⠋⠉⠀⠀
⠀⢠⣿⣿⠇⠀⣾⣿⡏⠀⣾⣿⣿⠀⢰⣿⣿⠃⢀⣿⣿⡇⠀⣾⣿⡟⠀⠀⠀⠀
⠀⣼⣿⣿⠀⢸⣿⣿⠃⢠⣿⣿⠇⠀⣾⣿⣯⣤⣼⣿⡿⠀⢸⣿⣿⠁⠀⠀⠀⠀
⠐⠛⠛⠃⠀⠛⠛⠃⠀⠚⠛⠛⠀⠘⠛⠛⠛⠛⠛⠛⠃⠀⠚⠛⠋⠀⠀⠀⠀⠀
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> ii;
#define pb push_back
#define endl '\n' 
template <class T>
void printVec(vector<T> a){
	for(int i = 0 ; i < a.size() ; i++){
		cout << a[i] << " ";
	}
	cout << endl;
}
template <class T>
void printMatrix(vector<vector<T>> M){
	for(auto v : M){
		printVec(v);
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while(t--){
		int n,k;
		cin >> n >> k;
		vector<int> v(n);
		//vector<vi> indexes(k+1);
		map<int,int> remainders;
		for(int i = 0 ; i < n ; i++){
			cin >> v[i];
			remainders[ (v[i])%k ]++;
			//indexes[ (v[i]%k) ].push_back(i);
		}
		for(auto e : remainders){
			break;
			//cout << e.first<<","<<e.second<< " ";
		}
		//cout << endl;
		int ans = n;
		set<int> counted;
		for(auto e : remainders){
			if(counted.count(e.first)) continue;
			int num = e.first;
			//cout << "num: " << num << endl;
			int freqNum = e.second;
			int comp = (k - num)%k;
			if(remainders.count(comp)){
				int freqComp = remainders[comp];
				int sz = min(freqNum, freqComp);
				if(num != comp) sz *= 2;
				if(freqNum != freqComp){
					//sz *= 2;
					sz++;
				}
				//cout << num << " " << comp << " " << sz-1 << endl;
				ans -= (sz-1);
				counted.insert(comp);
			}
		}
		cout << ans << endl;

	}

	return 0;
}
	