func_code_string: #include <bits/stdc++.h>   using namespace std;    #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   #define int long long int   #define ld long double   #define endl   n    #define rep(i,a,b) for(int i=a;i<b;i++)   #define reprev(i,a,b) for(int i=b-1;i>=a;i--)   #define all(c) c.begin(),c.end()   #define sz(c) (int)c.size()   #define ff first   #define ss second   #define pii pair<int,int>   #define vi vector<int>   #define vii vector<pii>   #define vin(a,n) vi a(n); rep(k_,0,n) {cin>>a[k_];}   #define vout(a) rep(k_,0,sz(a)) {cout<<a[k_]<<   ;} cout<<endl;   #define pb push_back   #define mp  make_pair   #define mod 1000000007   #define mod2 998244353   #define inf 1e18   #define pi 3.1415926535897932384626   #define tr(container, it)    for(auto it = container.begin(); it != container.end(); it++)      int power(int x, unsigned int y, int p)     {         int res = 1;     // Initialize result              x = x % p; // Update x if it is more than or                     // equal to p              if (x == 0) return 0; // In case x is divisible by p;             while (y > 0)         {             // If y is odd, multiply x with result             if (y & 1)                 res = (res*x) % p;                  // y must be even now             y = y>>1; // y = y/2             x = (x*x) % p;         }         return res;     }      int ceill(int a,int b)   {       return (a+b-1)/b;   }      #define MAXN   100001        // stores smallest prime factor for every number   int spf[MAXN];        // Calculating SPF (Smallest Prime Factor) for every   // number till MAXN.   // Time Complexity : O(nloglogn)   void sieve()   {       spf[1] = 1;       for (int i=2; i<MAXN; i++)                // marking smallest prime factor for every           // number to be itself.           spf[i] = i;            // separately marking spf for every even       // number as 2       for (int i=4; i<MAXN; i+=2)           spf[i] = 2;            for (int i=3; i*i<MAXN; i++)       {           // checking if i is prime           if (spf[i] == i)           {               // marking SPF for all numbers divisible by i               for (int j=i*i; j<MAXN; j+=i)                        // marking spf[j] if it is not                    // previously marked                   if (spf[j]==j)                       spf[j] = i;           }       }   }        // A O(log n) function returning primefactorization   // by dividing by smallest prime factor at every step   vector<int> getFactorization(int x)   {       vector<int> ret;       while (x != 1)       {           ret.push_back(spf[x]);           x = x / spf[x];       }       return ret;   }      int modInverse(int n, int p)    {        return power(n, p-2, p);    }    const int N=1000000;   int fac[N+1];    void precomp(int p)   {       fac[0] = 1;        for (int i=1 ; i<=N; i++)            fac[i] = fac[i-1]*i%p;   }   // Returns nCr % p using Fermat s little    // theorem.    int nCrModPFermat(int n, int r, int p)    {       // Base case       if (r==0)          return 1;             // Fill factorial array so that we        // can find all factorial of r, n        // and n-r         return (fac[n]* modInverse(fac[r], p) % p *                modInverse(fac[n-r], p) % p) % p;    }   signed main()   {       #ifndef ONLINE_JUDGE           freopen( ./input.txt ,  r , stdin);           freopen( ./output.txt ,  w , stdout);       #endif       IOS       int T; cin>>T;       precomp(mod);       rep(t,1,T+1)       {           int n; cin>>n;           vin(a,n);           int and_val=a[0];           rep(i,1,n) and_val = and_val&a[i];              int freq=0;              rep(i,0,n)           {               if(a[i]==and_val) freq++;           }              int ans = freq*(freq-1);           ans%=mod;           ans*=fac[n-2]; ans%=mod;           cout<<ans<<endl;       }       return 0;   }