# coding: utf-8 import math def II(): return int(input()) def ILI(): return list(map(int, input().split())) def read(): N, k = ILI() if k >= 1: a = ILI() else: a = None return N, k, a def solve(N, k, a): l_ele = [] if a is None: return math.factorial(N) % (10 ** 9 + 7) else: for i_a in a: s_bit = set() for ind, b in enumerate(reversed(str(bin(i_a)))): if b == "b": break if b == "1": s_bit.add(ind) l_ele.append((len(s_bit), s_bit)) l_ele.sort(key=lambda x: x[0]) ans = math.factorial(l_ele[0][0]) for i in range(len(l_ele)): if i < len(l_ele) - 1: len_dif = l_ele[i + 1][0] - l_ele[i][0] set_dif = l_ele[i + 1][1] - l_ele[i][1] if len_dif == 0: return 0 if len(set_dif) != len_dif: return 0 ans *= math.factorial(len_dif) else: ans *= math.factorial(N - l_ele[i][0]) return ans % (10 ** 9 + 7) def main(): params = read() print(solve(*params)) if __name__ == "__main__": main()