# include <stdio.h>

const int MAXN = 100010;
int t;
int a[MAXN];
int n,m,x,r;
int ans;

inline int abs(int x) {
  if (x > 0) return x;
  return -x;
}

inline int max(int x, int y) {
  if (x > y) return x; return y;
}

int main() {
  scanf("%d", &t);
  while(t--) {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
      a[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      scanf("%d", &x);
      a[x % m] ++;
    }
    ans = 0;
    r = m >> 1;
    if (a[0]) ans ++;
    for (int i = 1; i <= r; i++) {
      if (a[i] | a[m - i]) {
        ans += max(abs(a[i] - a[m - i]), 1);
      }
    }
    printf("%d\n", ans);
  }
}
