#include #include #define rep(i, n) for (i = 0; i < n; i++) #define MOD 1000000007 int getbit(int x, int n) { return !!(x & (int)pow(2, n - 1)); } int f(int x) { if (x > 1) return (x * f(x - 1)) % MOD; else return 1; } int main() { int n, k; scanf("%d %d", &n, &k); int a, abit[61][60], cntb, cnt01, cnt10, flg = 0; int maxb = -1, minb = n + 1; int ans, i, j; if (k == 0) ans = f(n); else { rep(i, k) { scanf("%d", &a); cntb = cnt01 = cnt10 = 0; rep(j, n) { abit[i][j] = getbit(a, j + 1); if (abit[i][j]) cntb++; } if (cntb > maxb) maxb = cntb; if (cntb < minb) minb = cntb; if (i > 0) { rep(j, n) { int t1 = abit[i][j], t2 = abit[i - 1][j]; if (!t1 && t2) cnt01++; else if (t1 && !t2) cnt10++; } if (cnt01 && cnt10) { ans = 0; goto ans; } else if (flg && cnt01 && flg != 1) { ans = 0; goto ans; } else if (flg && cnt10 && flg != 2) { ans = 0; goto ans; } if (!flg && cnt01) flg = 1; else if (!flg && cnt10) flg = 2; } } ans = f(minb) * f(maxb - minb) * f(n - maxb); } ans: printf("%d\n", ans); return 0; }