import std.algorithm; import std.array; import std.ascii; import core.bitop; import std.container; import std.conv; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; void log(A...)(A arg) { stderr.writeln(arg); } int size(T)(in T s) { return cast(int)s.length; } bool contains(long a, long b) { return (a & b) == b; } void main() { immutable long mod = cast(long)(1e9 + 7); long fact(long x) { if (x == 0) return 1; return x * fact(x - 1) % mod; } int N, K; readf("%s %s\n", &N, &K); auto A = readln.chomp.split(" ").map!(to!long).array; long solve() { if (K == 0) return fact(N); foreach (i; 0 .. K) { foreach (j; i + 1 .. K) { if (! (A[i].contains(A[j]) || A[j].contains(A[i]))) { return 0; } } } A.sort!((a, b) => (a.popcnt < b.popcnt)); //log(A); long ans = 1; foreach (i; 0 .. K - 1) { auto a = A[i], b = A[i + 1]; auto d = (b - a).popcnt; ans = (ans * fact(d)) % mod; } ans = (ans * fact(N - A.back.popcnt)) % mod; return ans; } writeln(solve()); }