#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF (1<<29) #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() #define uniq(v) v.erase(unique(all(v)),v.end()) #define MOD 1000000007 int popcount32(unsigned int x) { #if defined(_MSC_VER) return __popcnt(x); #else return __builtin_popcount(x); #endif } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; int prev = 0, prevpop = 0; long long ans = 1; int a[60]; rep(i, k)cin >> a[i]; sort(a, a + k); rep(i,k) { if ((a[i]&prev)!=prev) { ans = 0; break; } int pop = popcount32(a[i]); for (int i = 1; i <= pop - prevpop;i++) { (ans *= i) %= MOD; } prev = a[i]; prevpop = pop; } if (prevpop != n) { for (int i = 1; i <= n - prevpop; i++) { (ans *= i) %= MOD; } } cout << ans << endl; return 0; }