import java.io.*; import java.util.*; import java.util.stream.*; public class Main { static int m; static Judge[] judges; static HashMap> dp = new HashMap<>(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); m = sc.nextInt(); Judge.size = n; judges = new Judge[m]; for (int i = 0; i < m; i++) { judges[i] = new Judge(); } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (sc.nextInt() == 1) { judges[j].add(i); } } } for (int i = 0; i < m; i++) { judges[i].makePop(); } Judge all = new Judge(); for (int i = 0; i < n; i++) { all.add(i); } System.out.println(dfw(all, (1 << m) - 1)); } static int dfw(Judge x, int mask) { if (mask == 0) { return 1; } if (!dp.containsKey(x)) { dp.put(x, new HashMap<>()); } if (!dp.get(x).containsKey(mask)) { int ans = 0; for (int i = 0; i < m; i++) { if ((mask & (1 << i)) == 0) { continue; } Judge next = judges[i].and(x); if (x.pop <= next.pop * 2) { ans += dfw(next, mask ^ (1 << i)); } } dp.get(x).put(mask, ans); } return dp.get(x).get(mask); } static class Judge { static int size; int length; long[] data; int pop; public Judge() { length = (size + 60 - 1) / 60; data = new long[length]; } public Judge(int length, long[] data) { this.length = length; this.data = data; } public void add(int x) { data[x / 60] |= (1L << (x % 60)); } public void makePop() { for (long x : data) { long y = x; while (y > 0) { if (y % 2 == 1) { pop++; } y >>= 1; } } } public Judge and(Judge x) { long[] next = new long[length]; for (int i = 0; i < length; i++) { next[i] = (data[i] & x.data[i]); } Judge ans = new Judge(length, next); ans.makePop(); return ans; } public int hashCode() { return pop; } public boolean equals(Object o) { Judge x = (Judge)o; for (int i = 0; i < length; i++) { if (data[i] != x.data[i]) { return false; } } return true; } } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }