import java.io.*; import java.util.*; public class Main_yukicoder462 { private static Scanner sc; private static Printer pr; private static void solve() { final int MOD = 1_000_000_007; int n = sc.nextInt(); int k = sc.nextInt(); Pair[] a = new Pair[k]; Set hs = new TreeSet<>(); for (int i = 0; i < k; i++) { long tmp = sc.nextLong(); a[i] = new Pair(tmp, Long.bitCount(tmp)); if (hs.contains(a[i].b)) { pr.println(0); return; } else { hs.add(a[i].b); } } Arrays.sort(a); for (int i = 1; i < k; i++) { if ((a[i].a & a[i - 1].a) != a[i - 1].a) { pr.println(0); return; } } hs.add(0); hs.add(n); long ret = 1; List al = new ArrayList<>(hs); // Collections.sort(al); for (int i = 1, size = al.size(); i < size; i++) { int tmp = al.get(i) - al.get(i - 1); for (int j = 1; j <= tmp; j++) { ret = ret * j % MOD; } } pr.println(ret); } private static class Pair implements Comparable { long a; int b; Pair(long a, int b) { this.a = a; this.b = b; } @Override public int compareTo(Pair o) { return Integer.compare(b, o.b); } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }