(defn split-space [s]
  (map #(Long/parseLong %) (.split s " ")))

(defn product [lists]
  (reduce
   (fn [acc xs]
     (if (empty? acc)
       xs
       (mapcat
        (fn [x]
          (map
           (fn [y]
             (if (vector? y)
               (vec (cons x y))
               [x y])) acc))
        xs)))
   []
   (reverse lists)))

(defn get2 [n xs]
  (get xs n))

(defn switch-position [n]
  (partial get2 (dec n)))

(defn switch-positions [xs]
  (map switch-position xs))

(defn switch-on? [sms pm switchs]
  (->> 
   (switch-positions sms) ;; [(get xs mi)...]
   (map (fn [f] (f switchs))) ;; [1 1 0 1 ...] kmのスイッチ
   (apply +)
   ((fn [n] (rem n 2)))       ;; mod 2 
   (= pm)))

(defn read-switch-p [m]
  (for [i (range m)] (split-space (read-line))))

(defn switch-f [m]
  (->>
   (read-switch-p (inc m))
   ((fn [xs] 
      (map        
       (fn [ys p] (partial switch-on? ys p))    　  
       (map rest (drop-last xs))　
       (last xs))))))

(defn conjunction-switches [fs s]
    ((fn [s] (reduce (fn [acc f] (and acc (f s))) true fs)) s))

(defn switches []
   (->>
    (split-space (read-line))
    ((fn [[n m]] 
       (->>
        (switch-f m)
        ((fn [fs] (filter (fn [s] (conjunction-switches fs s)) (product (take n (repeat [0 1]))))))
        (count))))))  

(println (switches))