import java.io.*; import java.util.*; public class Main { static int n; static int m; static boolean[][] votes; static boolean[][] unables; static int[] dp; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); n = sc.nextInt(); m = sc.nextInt(); votes = new boolean[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { votes[i][j] = (sc.nextInt() == 1); } } unables = new boolean[1 << m][n]; for (int i = 0; i < (1 << m); i++) { for (int j = 0; j < m; j++) { if ((i & (1 << j)) != 0) { continue; } for (int k = 0; k < n; k++) { unables[i][k] |= !votes[k][j]; } } } dp = new int[1 << m]; Arrays.fill(dp, -1); dp[0] = 1; System.out.println(dfw((1 << m) - 1)); } static int dfw(int mask) { if (dp[mask] < 0) { dp[mask] = 0; for (int i = 0; i < m; i++) { if ((mask & (1 << i)) == 0) { continue; } int agree = 0; int against = 0; for (int j = 0; j < n; j++) { if (unables[mask][j]) { continue; } if (votes[j][i]) { agree++; } else { against++; } } if (agree >= against) { dp[mask] += dfw(mask ^ (1 << i)); } } } return dp[mask]; } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }