// yukicoder: No.462 6日知らずのコンピュータ // 2019.6.26 bal4u #include typedef long long ll; typedef unsigned long long ull; #if 1 #define gc() getchar_unlocked() #else #define gc() getchar() #endif ll in() { // 非負整数の入力 ll n = 0; int c = gc(); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } // 64ビット用 int bitcount64(unsigned long long x) { x = ((x & 0xAAAAAAAAAAAAAAAAULL) >> 1 ) + (x & 0x5555555555555555ULL); x = ((x & 0xCCCCCCCCCCCCCCCCULL) >> 2 ) + (x & 0x3333333333333333ULL); x = ((x & 0xF0F0F0F0F0F0F0F0ULL) >> 4 ) + (x & 0x0F0F0F0F0F0F0F0FULL); x = ((x & 0xFF00FF00FF00FF00ULL) >> 8 ) + (x & 0x00FF00FF00FF00FFULL); x = ((x & 0xFFFF0000FFFF0000ULL) >> 16) + (x & 0x0000FFFF0000FFFFULL); x = ((x & 0xFFFFFFFF00000000ULL) >> 32) + (x & 0x00000000FFFFFFFFULL); return (int)x; } #define MOD 1000000007 ll a[65]; int dp[65]; int n[65]; int N, k; int check(ll new, ll pre) { ll k; for (k = 1; k <= pre; k <<= 1) { if ((pre & k) == 0 && (new & k)) return 0; } return 1; } int main() { int i, j, ans; ll aa; n[0] = n[1] = 1; for (i = 2; i <= 60; i++) n[i] = (ll)n[i-1] * i % MOD; N = (int)in(), k = (int)in(); if (k == 0) { printf("%d\n", n[N]); return 0; } if (k == N+1) { puts("1"); return 0; } for (i = 0; i < k; i++) { ll _a = in(); j = bitcount64(_a); if (a[j] > 0) goto Err; a[j] = _a; } j = 0, dp[0] = 1; for (i = 1; i < N; i++) if (a[i]) { if (!check(a[i], a[j])) goto Err; dp[i] = (ll)dp[j] * n[i-j] % MOD; j = i; } dp[N] = (ll)dp[j] * n[N-j] % MOD; printf("%d\n", dp[N]); return 0; Err:puts("0"); return 0; }