'use strict';(function(input){
  function count(pi,A,B){
    var C=A&B;
    var counter=pi;
    while(C>0){
      counter+=(C%2);
      C>>1;
    }
    return ((counter%2)===0);
  }
  
  input=input.trim().split(/\n+/);
  input=input.map(str=>str.split(/\s+/).map(x=>x-0));
  const N=input[0][0];
  const M=input[0][1];
  const p=input.pop();
  const arr=new Array(1<<N).fill('filler').map((x,i)=>i);
  const mask=[];
  for(let i=1;i<=M;i++)
    mask.push(input(i).reduce((acc,cur)=>acc+(2<<(cur-1)),0));
  mask.forEach(function(A,i){
    let j=0;
    while(j<arr.length){
      if(!count(p[i],A,arr[j]))
        arr.splice(j,1);
      else j++;
    }
  });
  console.log(arr.length);
})(require('fs').readFileSync('/dev/stdin','utf8'));
