#include #define X 1000000007 unsigned long long int pow2(unsigned long long int k){ unsigned long long int i,r=1; for(i = 1;i <= k;i++){r*=2;} } unsigned long long int kaijyo(unsigned long long int k){ unsigned long long int r=1,i; for(i = 1;i <= k;i++){r*=i;r%=X;} return r; } unsigned long long int bitcount(unsigned long long int k){ unsigned long long int r=0,i; for(i = 1;i <= 64;i++){if(k%2){r++;}k/=2;} return r; } int main(void) { unsigned long long int n,k,a[64],r=1,b[64],c,d=0,i,j; scanf("%llu%llu",&n,&k); if(k == 0){r = kaijyo(n);printf("%llu\n",r);return 0;} for(i = 1;i <= k;i++){scanf("%llu",&a[i]);} for(i = 1;i <= k;i++){b[i] = bitcount(a[i]);if(a[i] >= pow2(k+1)){printf("0\n");return 0;}} for(i = 1;i <= n;i++){ d++; c = 0; for(j = 1;j <= k;j++){ if(b[j] == i){c++;} } if(c == 1){r*=kaijyo(d);d=0;} if(c >= 2){printf("0\n");return 0;} } r*=kaijyo(d); printf("%llu\n",r); return 0; }