#include <bits/stdc++.h>
using namespace std;

void solveCase() {
  int n, m;
  cin >> n >> m;

  vector<int> freq(m, 0);
  for (int i = 0; i < n; ++i) {
  	int a;
  	cin >> a;
  	freq[a % m]++;
  }

  int ans = 0;
  for (int x = 0; x <= m / 2; ++x) {
  	int y = (m - x) % m;
  	if (x == y) {
  	  ans += bool(freq[x]);
  	} else if (freq[x] + freq[y] > 0) {
  	  ans += max(abs(freq[x] - freq[y]), 1);
  	}
  }

  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int T;
  cin >> T;
  for (int ti = 1; ti <= T; ++ti)
    solveCase();

  return 0;
}