#!/usr/bin/env python3 mod = 10**9+7 def fact(n): if n == 0: return 1 else: return n * fact(n-1) % mod def bits(n): return set([ i for i, bit in enumerate(reversed(bin(n)[2 :])) if bit == '1' ]) n, k = map(int, input().split()) a = list(map(int, input().split())) cnt = 1 for x, y in zip([ 0 ] + a, a + [ 2**n-1 ]): if bits(x).issubset(bits(y)): cnt = cnt * fact(len(bits(y)) - len(bits(x))) % mod else: cnt = 0 break print(cnt)