#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define all(x) (x).begin(),(x).end() #define rep(i,m,n) for(int i = m;i < n;++i) #define pb push_back #define fore(i,a) for(auto &i:a) #define rrep(i,m,n) for(int i = m;i >= n;--i) #define INF INT_MAX/2 using namespace std; using ll = long long; using R = double; using Data = pair>; const ll MOD = 1e9 + 7; const ll inf = 1LL << 50; struct edge { ll from; ll to; ll cost; }; ll getbit(ll n) { ll ret = 0; while (n > 0) { ret += n % 2; n /= 2; } return ret; } ll po(ll a,ll b) { ll ret = 1; rep(i,0,b) { ret *= a; } return ret; } ll check(ll a, ll b) { while (a > 0 || b > 0) { ll m1 = a % 2; ll m2 = b % 2; if (m2 == 0 && m1 == 1)return false; a /= 2; b /= 2; } return true; } ll fac(ll a) { ll ret = 1; for (ll i = 1; i <= a; i++) { ret *= i; ret %= MOD; } return ret % MOD; } int main() { ll n, k; cin >> n >> k; vector>a; rep(i, 0, k) { ll temp; cin >> temp; a.pb({ getbit(temp),temp }); } a.pb({0,0}); a.pb({ n,po(2,n) - 1 }); sort(all(a)); ll ans = 1; rep(i,0,a.size()-1) { if (check(a[i].second,a[i+1].second)) { ans *= fac(a[i+1].first-a[i].first); ans %= MOD; } else { ans = 0; break; } } cout << ans%MOD << endl; return 0; }