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

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define uint unsigned int
#define lli long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i, n)  for(int i=0;i<n;++i)
#define rforn(i,start) for(int i = start; i >= 0;--i)
#define forsn(i,start,end) for(int i=start;i<end;++i)
#define rforsn(i,start,end) for(int i=start;i>=end;--i)
#define debug(x) cout<<#x<<" = "<<x<<"\n";
const int CONST = 1e9 + 7;
const double pi = 3.14159265358979323846;
const int MAX = 300005;


int32_t main()
{
    fastio;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt","w",stdout);
    #endif

    int t;
    cin>>t;

    while(t--){
        int n, m;
        cin>>n>>m;

        vector<int> arr(n);
        vector<int> freq(m, 0);
        forn(i, n){
            cin>>arr[i];

            arr[i] = arr[i]%m;

            freq[arr[i]]++;
        }


        int ans= freq[0] ? 1:0;
        // debug(ans);
        forsn(i,1, m/2+1){
            int dif ;//= abs(abs(freq[i] - freq[m-i]) - 1);
            // debug(i);
            // debug(m-i);
            if(freq[i]==0){
                // cout<<"1st\n";
                ans += freq[m-i];
            }
            else if(freq[m-i]==0){
                // cout<<"2nd\n";
                ans += freq[i];
            }
            else{
                dif = abs(freq[i] - freq[m-i]) - 1;
                ++ans;

                if(dif>=1){
                    ans += dif;
                }
                // cout<<"3rd "<<dif<<endl;
            }
        }

        cout<<ans<<endl;

    }
    return 0;
}
