#include "bits/stdc++.h" using namespace std; #define print(x) cout< PI; typedef pair V; typedef vector VE; const ll mod = 1000000007; //10^9+7 int binally_count(ll n){ string str(std::bitset<62>(n).to_string, std::allocator >()); int cnt=0; REP(i,62){ if(str[i]=='1')cnt++; } return cnt; } ll nPn(int n){ ll sum=1; rep(i,1,n+1){ sum*=i; sum%=mod; } return sum; } string bainary(ll val){ if( !val ) return std::string("0"); std::string str; while( val != 0 ) { if( (val & 1) == 0 ) // val は偶数か? str.insert(str.begin(), '0'); // 偶数の場合 else str.insert(str.begin(), '1'); // 奇数の場合 val >>= 1; } return str; } bool check(ll a,ll b){ string ab=bainary(a); string bb=bainary(b); while(ab.size()!=bb.size()){bb="0"+bb;} //print(ab<<" "<>n>>k; ll a[61]; REP(i,k)cin>>a[i]; ll ans=0; if(k==0){ ans=nPn(n); print(ans); return 0; } sort(a,a+k); rep(i,1,k){ if(check(a[i],a[i-1])==false){ print(0); return 0; } } int pre_cnt=binally_count(a[0]); ans=nPn(pre_cnt); //print(ans); int cnt=pre_cnt; rep(i,1,k){ cnt=binally_count(a[i]); ans=(ans*(nPn(cnt-pre_cnt))%mod)%mod; //print(cnt-pre_cnt); pre_cnt=cnt; } //print(n-cnt); ans=(ans*(nPn(n-cnt))%mod)%mod; print(ans); }