package yukicoder; import java.util.*; public class Q462 { final static long MODULO = 1_000_000_000 + 7; public static void main(String[] args) { long[][] dp = new long[100][100]; dp[0][0] = 1; for (int i = 1; i < 100; ++i) { for (int j = 0; j <= i; ++j) { if (j > 0) dp[i][j] = dp[i - 1][j - 1] * j % MODULO; if (j <= i - 1) dp[i][j] += dp[i - 1][j] * (j + 1) % MODULO; dp[i][j] %= MODULO; } } long[][] dp3 = new long[100][100]; dp3[1][0] = 1; for (int i = 2; i < 100; ++i) { for (int j = 0; j <= i; ++j) { if (j > 0) dp3[i][j] = dp3[i - 1][j - 1] * j % MODULO; if (j <= i - 1) { dp3[i][j] += (dp3[i - 1][j] * j + dp[i - 1][j]) % MODULO; } dp3[i][j] %= MODULO; } } Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); if (k == 0) { System.out.println(dp[n][n] % MODULO); return; } long[] a = new long[k]; long[] diff = new long[k + 1]; for (int i = 0; i < k; ++i) { a[i] = sc.nextLong(); } for (int i = 0; i + 1 < k; ++i) { diff[i + 1] = count(a[i], a[i + 1]); if (diff[i + 1] <= 0) { System.out.println(0); return; } } diff[0] = count(0, a[0]); diff[k] = count(a[k - 1], (1L << n) - 1); long ans = 1; for (int i = 0; i < k + 1; ++i) { if (i == k) { if (a[k - 1] != (1L << n) - 1) ans = (ans * dp[(int) diff[i]][(int) diff[i]]) % MODULO; } else if (i == 0 && a[0] == 0) { continue; } else { ans = (ans * dp3[(int) diff[i]][(int) diff[i] - 1]) % MODULO; } } System.out.println(ans); } static long count(long min, long max) { for (int i = 0; i < 60; ++i) { if ((min & (1L << i)) > 0 && (max & (1L << i)) == 0) { return -1; } } int diff = Long.bitCount(max) - Long.bitCount(min); return diff; } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }