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


//define shortcuts
#define ite(a) for(auto &x : a)
#define  int long long
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,n) for(ll i=n-1;i>=a;i--)
#define all(a) a.begin(),a.end()
#define sec second
#define fir first
#define si size
#define vll vector<int>
#define pb push_back

#define fast ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
#define ri reverse_iterator
//defines finish

void solve()
{
     int n,m;
     cin>>n>>m;
     vll a(n);
     map<int,int>b;
     int f = 0;
     fo(i,0,n)
     {
          cin>>a[i];
          if(a[i]%m != 0)
          {
               b[m - (a[i])%m]++;
          }
          else
          {
               f = 1;
          }
     }
     int ans = 0;
     ite(b)
     {
          int h = x.sec;
          int y = b[m - x.fir];
          ans += (max(h,y)-min(h,y));
          if(max(h,y) > min(h,y) && min(h,y) != 0)
          {
               ans--;
          }
          if(h != 0 && y != 0)
          {
               ans++;
          }
          x.sec = 0;
          b[m-x.fir] = 0;
     }
     if(f)
     {
          ans++;
     }
     cout<<ans<<endl;
}


int32_t main()
{
     fast;
     int t;
     cin>>t;
     while(t--)
     {
          solve();
     }
}