// Arup Guha
// 11/27/2020
// Solution to 2019 NAIPC Problem: XOR Sequences

import java.util.*;

public class xorsequences {

	final public static long MOD = 1000000007L;

	public static int n;
	public static int bits;
	public static int[] nums;
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		bits = stdin.nextInt();
		n = stdin.nextInt();
		nums = new int[1<<bits];
		
		// Read labels.
		for (int i=0; i<(1<<bits); i++) 
			nums[i] = stdin.nextInt();
			
		// Ta da!
		System.out.println(go(0, 1<<bits));
	}
	
	// Returns the result for nums[lowI..highI-1].
	public static long go(int lowI, int highI) {
	
		// Single range.
		if (highI-lowI == 1) return 1;
		
		// Also a single range that has several values to fillit.
		if (allSame(lowI, highI)) return highI-lowI;
		
		// Mark all items used in the first set.
		int midI = (lowI+highI)/2;
		boolean[] used = new boolean[n+1];
		for (int i=lowI; i<midI; i++)
			used[nums[i]] = true;
			
		// See if there is any overlap.
		boolean flag = false;
		for (int i=midI; i<highI; i++)
			if (used[nums[i]])
				flag = true;
				
		// Independent cases...solve both, multiply and return.
		if (!flag) {
			long left = go(lowI, midI);
			long right = go(midI, highI);
			return (left*right)%MOD;
		}
		
		// These lists must match perfectly.
		for (int i=lowI,j=midI; i<midI; i++,j++)
			if (nums[i] != nums[j])
				return 0;
				
		// If we get here, the second list is redundant, BUT, we double the size of 
		// its answer because there are two parallel options that can work either with
		// 0 or 1 in the unused bit location.
		return (2*go(lowI, midI))%MOD;
	}
	
	// Returns true iff nums[lowI...highI-1] is all the same.
	public static boolean allSame(int lowI, int highI) {
		for (int i=lowI+1; i<highI; i++)
			if (nums[lowI] != nums[i])
				return false;
		return true;
	}
}