using System; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { Reader.IsDebug = false; int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray(); this.Length = inpt[0]; if(inpt[1] == 0) { long ans = 1; for(int i=2; i<=this.Length; i++) { ans*=i; ans = ans % MOD; } Console.WriteLine(ans); } else { this.NumList = Reader.ReadLine().Split(' ').Select(a=>ulong.Parse(a)).OrderBy(a=>a).ToArray(); long ans = this.GetAns(0,0); Console.WriteLine(ans); } } private Dictionary dic = new Dictionary(); private long GetAns(ulong selected, ulong flags) { if(dic.ContainsKey(selected)) { return dic[selected]; } ulong flags2 = flags; for(int i=0; i this.NumList[i]) { dic[selected] = 0; return 0; } ulong selectedR = ~selected; ulong numR = ~this.NumList[i]; if((selectedR&numR) != numR) { dic[selected] = 0; return 0; } } if(selected == ((ulong)1<0) { continue; } ans+=this.GetAns(selected+key, flags2); ans = ans % MOD; } this.dic[selected] = ans; return ans; } private const long MOD = 1000000000 + 7; private int Length = 0; private ulong[] NumList; public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }