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

void solve(){
   int n, ma ;
   cin>>n>>ma ;
   
   map<int, int>m ;
   for( int i = 0 ; i < n ; i++ ){
       int x ;
       cin>>x ;
       x = x%ma ;
       m[x]++ ;
   }
   int total = 0 ;
   map<int, int>::iterator i ; 
   for( i = m.begin(); i != m.end(); i++){
       if( i->first == 0 && i->second > 0) total++ ;
       else if( m[ma - i->first] == 0   ) total += i->second ;
       else if(  ma - i->first == i->first){
           total++ ;
       }
       else if( ma - i->first > i->first ){
           int a = i->second ;
           int b = m[ma- i->first] ;
           if( abs(a -b) <= 1 ) total ++ ;
           else if( a > b ){
               a -= b+1 ;
               total ++ ;
               total += a ;
           }
           else{
               b -= (a+1) ;
               total++ ;
               total += b ;
           }
           
   }
   }
   cout<<total<<endl ;
}



int main()
{
  int t ;
  cin>>t ;
  while( t-- ){
      solve() ;
  }
  return 0 ;
}
