#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <functional>
#include <stack>
using namespace std;
//{
void printb(bool b)
{
    if(b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}
template<typename T>
T qr()
{
    ios::sync_with_stdio(0);
    T rt=0;
    char c=getchar();
    bool b=false;
    while(c<'0'||c>'9')
    {
        if(c=='-') b=true;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        rt=(rt<<1)+(rt<<3)+(c^48);
        c=getchar();
    }
    if(b) return -rt;
    return rt;
}
double fp(double a,long long b)
{
    ios::sync_with_stdio(0);
    if(b==0) return 1;
    if(b%2==0) return fp(a,b/2)*fp(a,b/2);
    else return fp(a,b-1)*a;
}
long long fmp(long long a,long long b,long long p)
{
    if(b==0) return 1;
    long long tmp=fmp(a,b/2,p);
    if(b%2==0) return (tmp*tmp)%p;
    return (tmp*tmp*a)%p;
}
unsigned long long fmp(unsigned long long a,unsigned long long b,unsigned long long p)
{
    unsigned long long tmp=1;
    a=a%p;
    while(b)
    {
        if(b&1)
        {
            b--;
            tmp=(tmp*a)%p;
        }
        b/=2;
        a=(a*a)%p;
    }
    return tmp;
}
//long long hgcd(long long a,long long b)
//{

//}
long long gcd(long long a,long long b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
long long gcdex(long long a,long long b,long long &x,long long &y)
{
    if(b==0)
    {
        x=1;y=0;
        return a;
    }
    long long c=gcdex(b,a%b,y,x);
    y-=a/b*x;
    return c;
}
long long esb[5000007];
bool esa[5000007];
int est;
void EulerSieveInitialize(long long n)
{
    int t=0;
    for(int i=2;i<=n;i++)
    {
        if(!esa[i]) esb[t++]=i;
        for(int j=0;j<t;j++)
        {
            if(i*esb[j]>=n) break;
            esa[i*esb[j]]=true;
            if(i%esb[j]==0) break;
        }
    }
    est=t;
}
long long Euler(long long n)
{
    long long e=n;
    for(long long i=2;i*i<=n;i++)
    {
        if(n%i==0) e=e-e/i;
        while(n%i==0) n/=i;
    }
    if(n>1) e=e-e/n;
    return e;
}
long long cdp[307][307];
void CombinationInitialize(int n,long long cimd=0x3f3f3f3f3f3f3f3f)
{
    cdp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        cdp[i][0]=1;
        cdp[i][i]=1;
        for(int j=1;j<=n/2;j++)
        {
            cdp[i][j]=(cdp[i-1][j-1]+cdp[i-1][j])%cimd;
            cdp[i][i-j]=cdp[i][j];
        }
    }
}
long long wsdp[30];
void WrongSortInitialize(int n,long long p=0x3f3f3f3f)
{
    wsdp[0]=0;wsdp[1]=0;wsdp[2]=1;
    for(int i=3;i<=n;i++)
        wsdp[i]=(i-1)*(wsdp[i-1]+wsdp[i-2]);
}
long long mfia[500];
void ModFactorialInitialize(int n,long long p)
{
    mfia[0]=1;
    for(int i=1;i<=n;i++)
    {
        mfia[i]=(mfia[i-1]*i)%p;
        if(i==299)
        {
            int tmp;
        }
    }
}
//}






int p[100007];
int main()
{
    ios::sync_with_stdio(0);
    int t;
    cin>>t;
    while(t--)
    {
        int n,m;
        cin>>n>>m;
        for(int i=0;i<m;i++)
            p[i]=0;
        for(int i=0;i<n;i++)
        {
            long long a;
            cin>>a;
            p[a%m]++;
        }
        long long s=0;
        if(p[0]) s++;
        for(int i=1;i<=m/2;i++)
        {
             if(p[i]==p[m-i]||p[i]==p[m-i]+1||p[i]==p[m-i]-1)
             {
                 if(p[i]||p[m-i]) s++;
             }
             else if(p[i]>p[m-i]) s+=p[i]-p[m-i];
             else s+=p[m-i]-p[i];
        }
        cout<<s<<endl;
    }
}

