You are given n × m table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:

  All cells in a set have the same color.  Every two cells in a set share row or column. 


-----Input-----

The first line of input contains integers n and m (1 ≤ n, m ≤ 50) — the number of rows and the number of columns correspondingly.

The next n lines of input contain descriptions of rows. There are m integers, separated by spaces, in each line. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell is colored black.


-----Output-----

Output single integer  — the number of non-empty sets from the problem description.


-----Examples-----
Input
1 1
0

Output
1

Input
2 3
1 0 1
0 1 0

Output
8



-----Note-----

In the second example, there are six one-element sets. Additionally, there are two two-element sets, the first one consists of the first and the third cells of the first row, the second one consists of the first and the third cells of the second row. To sum up, there are 8 sets.

Difficulty: EASY
Tags: Combinatorics

Mathematics

Starter code:

Solutions:
(a, b) = map(int, input().split())
r = lambda x: 2 ** x - 1
k = [[0, 0] for _ in ' ' * b]
ans = 0
for i in range(a):
	z = list(map(int, input().split()))
	w = 0
	for j in range(b):
		k[j][z[j]] += 1
		if z[j] == 0:
			w += 1
	ans += r(w) + r(b - w)
for i in range(b):
	if k[i][0] > 1:
		ans += r(k[i][0]) - k[i][0]
	if k[i][1] > 1:
		ans += r(k[i][1]) - k[i][1]
print(ans)


(n, m) = map(int, input().split())
arr = []
for i in range(n):
	a = list(map(int, input().split()))
	arr.append(a)
ans = 0
for i in arr:
	k1 = i.count(0)
	k2 = i.count(1)
	ans += 2 ** k1 - 1
	ans += 2 ** k2 - 1
for i in range(m):
	(one, zero) = (0, 0)
	for j in range(n):
		if arr[j][i] == 0:
			zero += 1
		else:
			one += 1
	ans += 2 ** zero - 1
	ans += 2 ** one - 1
print(ans - n * m)


(n, m) = input().split()
n = int(n)
m = int(m)
table = []
line = [0, 0]
column = [0, 0]
sets = 0
for i in range(n):
	table.append([int(i) for i in input().split()])
	for k in table[i]:
		if k == 0:
			line[0] += 1
		else:
			line[1] += 1
	sets += 2 ** line[0] - 1 + 2 ** line[1] - 1
	line = [0, 0]
for i in range(m):
	for k in range(n):
		if table[k][i] == 0:
			column[0] += 1
		else:
			column[1] += 1
	sets += 2 ** column[0] - 1 + 2 ** column[1] - 1
	column = [0, 0]
sets -= m * n
print(sets)


(n, m) = map(int, input().split())
lin0 = [0] * n
lin1 = [0] * n
col0 = [0] * m
col1 = [0] * m
t = 0
mat = []
for i in range(n):
	str = input().split()
	linha = []
	for j in str:
		linha.append(int(j))
	mat.append(linha)
for i in range(n):
	for j in range(m):
		if mat[i][j] == 0:
			lin0[i] += 1
			col0[j] += 1
		else:
			lin1[i] += 1
			col1[j] += 1
for i in range(n):
	t += 2 ** lin0[i] - 1 + 2 ** lin1[i] - 1
for i in range(m):
	t += 2 ** col0[i] - 1 + 2 ** col1[i] - 1
print(t - m * n)


(n, m) = list(map(int, input().split()))
matrix = [list(map(int, input().split())) for _ in range(n)]
ones_row = [sum(row) for row in matrix]
ones_col = []
for i in range(m):
	x = 0
	for j in range(n):
		if matrix[j][i]:
			x += 1
	ones_col.append(x)
answer = 0
for x in ones_row:
	ones = x
	zeroes = m - x
	answer += 2 ** ones - 1
	answer += 2 ** zeroes - 1
for x in ones_col:
	ones = x
	zeroes = n - x
	answer += 2 ** ones - 1
	answer += 2 ** zeroes - 1
answer -= m * n
print(answer)


(n, m) = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(n)]
s = n * m
for i in range(n):
	black = sum(a[i])
	if black > 1:
		s += 2 ** black - black - 1
	white = m - black
	if white > 1:
		s += 2 ** white - white - 1
b = [[a[i][j] for i in range(n)] for j in range(m)]
for i in range(m):
	black = sum(b[i])
	if black > 1:
		s += 2 ** black - black - 1
	white = n - black
	if white > 1:
		s += 2 ** white - white - 1
print(s)


(n, m) = map(int, input().split())
ll = []
strok = [[0] * 2 for i in range(n)]
stolb = [[0] * 2 for i in range(m)]
for i in range(n):
	ll.append(list(input().split()))
	for j in ll[-1]:
		if j == '1':
			strok[i][1] += 1
		else:
			strok[i][0] += 1
for i in range(m):
	for j in range(n):
		if ll[j][i] == '1':
			stolb[i][1] += 1
		else:
			stolb[i][0] += 1
ans = 0
for i in range(n):
	ans += 2 ** strok[i][0] - 1
	ans += 2 ** strok[i][1] - 1
for i in range(m):
	ans += 2 ** stolb[i][0] - (stolb[i][0] + 1)
	ans += 2 ** stolb[i][1] - (stolb[i][1] + 1)
print(ans)


(n, m) = map(int, input().split())
a = [[] for i in range(n)]
one = 0
zero = 0
for i in range(n):
	a[i] = list(map(int, input().split()))
for i in range(n):
	count0 = 0
	count1 = 0
	for j in range(m):
		if a[i][j] == 1:
			count1 += 1
		else:
			count0 += 1
	one += 2 ** count1 - 1
	zero += 2 ** count0 - 1
for j in range(m):
	count0 = 0
	count1 = 0
	for i in range(n):
		if a[i][j] == 1:
			count1 += 1
		else:
			count0 += 1
	one += 2 ** count1 - 1
	zero += 2 ** count0 - 1
print(one + zero - n * m)


(n, m) = map(int, input().split())
x = []
for i in range(n):
	x.append(list(map(int, input().split())))
sum = 0
outc = 0
for i in range(n):
	sum = 0
	for k in range(m):
		sum += x[i][k]
	outc += 2 ** sum + 2 ** (m - sum) - 2
for k in range(m):
	sum = 0
	for i in range(n):
		sum += x[i][k]
	outc += 2 ** sum + 2 ** (n - sum) - 2
print(outc - n * m)


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
d = 0
for i in range(n):
	(b, w) = (0, 0)
	for j in range(m):
		if a[i][j] == 1:
			b += 1
		else:
			w += 1
	if b > 0:
		d += 2 ** b - 1
	if w > 0:
		d += 2 ** w - 1
for j in range(m):
	(b, w) = (0, 0)
	for i in range(n):
		if a[i][j] == 1:
			b += 1
		else:
			w += 1
	if b > 0:
		d += 2 ** b - b - 1
	if w > 0:
		d += 2 ** w - w - 1
print(d)


(n, m) = map(int, input().split())
a = []
ans = 0
for i in range(n):
	x = list(map(int, input().split()))
	ans += 2 ** x.count(1) + 2 ** x.count(0) - 2
	a.append(x)
for j in range(m):
	(w, b) = (0, 0)
	for k in range(n):
		if a[k][j] == 0:
			b += 1
		else:
			w += 1
	ans += 2 ** b + 2 ** w - 2 - n
print(ans)


entrada = input()
(n, m) = map(int, entrada.split(' '))
pecasPretasLinhas = [0 for x in range(n)]
pecasBrancasLinhas = [0 for x in range(n)]
pecasPretasColunas = [0 for x in range(m)]
pecasBrancasColunas = [0 for x in range(m)]
subBranco = 0
subPreto = 0
tabuleiro = []
for i in range(n):
	linha = input()
	tabuleiro.append(list(map(int, linha.split(' '))))
	for j in range(m):
		if tabuleiro[i][j] == 1:
			pecasBrancasLinhas[i] += 1
			pecasBrancasColunas[j] += 1
		else:
			pecasPretasLinhas[i] += 1
			pecasPretasColunas[j] += 1
for i in range(len(pecasBrancasLinhas)):
	subBranco += 2 ** pecasBrancasLinhas[i] - 1
	subPreto += 2 ** pecasPretasLinhas[i] - 1
for i in range(len(pecasBrancasColunas)):
	subBranco += 2 ** pecasBrancasColunas[i] - 1 - pecasBrancasColunas[i]
	subPreto += 2 ** pecasPretasColunas[i] - 1 - pecasPretasColunas[i]
print(int(subPreto + subBranco))


import functools
import math
(n, m) = map(int, input().split())
table = [[int(i) for i in input().split()] for _ in range(n)]

@functools.lru_cache(None)
def my_factorial(num1, num2):
	if num1 > num2 - num1:
		a = [i for i in range(num1 + 1, num2 + 1)]
		b = [i for i in range(1, num2 - num1 + 1)]
		for ind in range(len(a)):
			for ind2 in range(len(b)):
				greatest_common_divisor = math.gcd(a[ind], b[ind2])
				a[ind] //= greatest_common_divisor
				b[ind2] //= greatest_common_divisor
	else:
		a = [i for i in range(num2 - num1 + 1, num2 + 1)]
		b = [i for i in range(1, num1 + 1)]
		for ind in range(len(a)):
			for ind2 in range(len(b)):
				greatest_common_divisor = math.gcd(a[ind], b[ind2])
				a[ind] //= greatest_common_divisor
				b[ind2] //= greatest_common_divisor
	return functools.reduce(lambda x, y: x * y, a) // functools.reduce(lambda x, y: x * y, b) if len(a) != 0 else 1
counter = 0
for row in table:
	size = row.count(1)
	for quantity in range(1, size + 1):
		counter += my_factorial(quantity, size)
	counter -= row.count(1)
	size = row.count(0)
	for quantity in range(1, size + 1):
		counter += my_factorial(quantity, size)
	counter -= row.count(0)
for column in range(m):
	local_counter0 = 0
	local_counter1 = 0
	for row in range(n):
		local_counter0 += 1 if table[row][column] == 0 else 0
		local_counter1 += 1 if table[row][column] == 1 else 0
	for quantity in range(1, local_counter0 + 1):
		counter += my_factorial(quantity, local_counter0)
	for quantity in range(1, local_counter1 + 1):
		counter += my_factorial(quantity, local_counter1)
print(counter)


import queue
map = []
(n, m) = [int(i) for i in input().split(' ')]
vis = [[0 for j in range(m)] for i in range(n)]
id = 0
for i in range(n):
	map.append(input().split(' '))
ret = 0
for i in range(n):
	cnt = 0
	for j in range(m):
		cnt += int(map[i][j])
	ret += (1 << m - cnt) - 1
	ret += (1 << cnt) - 1
for i in range(m):
	cnt = 0
	for j in range(n):
		cnt += int(map[j][i])
	ret += (1 << n - cnt) - 1
	ret += (1 << cnt) - 1
ret -= n * m
print(ret)


from sys import stdin
(n, m) = map(int, stdin.readline().rstrip().split())
data = []
for i in range(0, n):
	data.append(stdin.readline().rstrip().replace(' ', ''))
rs = 0
for s in data:
	c0 = s.count('0')
	c1 = len(s) - c0
	rs += 2 ** c0 - 1 + 2 ** c1 - 1
for i in range(0, m):
	c0 = 0
	c1 = 0
	for j in range(0, n):
		c0 += 1 if data[j][i] == '0' else 0
		c1 += 1 if data[j][i] == '1' else 0
	rs += 2 ** c0 - 1 + 2 ** c1 - 1
print(rs - m * n)


def R():
	return map(int, input().split())
(n, m) = R()
t = [list(R()) for _ in range(n)]
count = 0
for row in t:
	b = w = 1
	for x in row:
		if x:
			b *= 2
		else:
			w *= 2
	count += b + w - 2
for c in range(m):
	b = w = 1
	for r in range(n):
		if t[r][c]:
			b *= 2
		else:
			w *= 2
	count += b + w - 2
print(count - n * m)


(n, m) = map(int, input().split())
t = []
C = 0
R = 0
for r in range(n):
	row = list(map(int, input().split()))
	t.append(row)
	R += 2 ** sum(row) + 2 ** (m - sum(row)) - 2
for c in zip(*t):
	C += 2 ** sum(list(c)) + 2 ** (n - sum(list(c))) - 2
print(R + C - m * n)


(n, m) = tuple(map(int, input().split()))
(f, p) = ([], [])
ans = -1 * n * m
for _ in range(n):
	f.append(list(map(int, input().split())))
for i in f:
	p.append(i.count(1))
	p.append(i.count(0))
for i in range(m):
	t = []
	for j in range(n):
		t.append(f[j][i])
	p.append(t.count(1))
	p.append(t.count(0))
	t.clear()
for i in p:
	ans += 2 ** i - 1
print(ans)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
col = [[0, 0] for i in range(m)]
row = [[0, 0] for i in range(n)]
for i in range(n):
	summa = sum(a[i])
	row[i] = [summa, m - summa]
for i in range(m):
	summa = 0
	for j in range(n):
		summa += a[j][i]
	col[i] = [summa, n - summa]
res = 0
for i in row:
	res += 2 ** i[0] + 2 ** i[1] - 2
for i in col:
	res += 2 ** i[0] + 2 ** i[1] - 2
res -= n * m
print(res)


(n, m) = map(int, input().split())
soch = [0, 1]
for i in range(2, max(n, m) + 1):
	soch.append(soch[i - 1] * 2 + 1)
a = []
cnt = n * m
for i in range(n):
	row = input().split()
	a.append(row)
	if row.count('1') > 1:
		cnt += soch[row.count('1')] - row.count('1')
	if row.count('0') > 1:
		cnt += soch[row.count('0')] - row.count('0')
for i in range(m):
	s = ''
	for j in range(n):
		s += str(a[j][i])
	if s.count('1') > 1:
		cnt += soch[s.count('1')] - s.count('1')
	if s.count('0') > 1:
		cnt += soch[s.count('0')] - s.count('0')
print(cnt)


from sys import stdin
input = stdin.readline
from heapq import heapify, heappush, heappop, heappushpop
from collections import defaultdict as dd, deque as dq, Counter as C
from math import factorial as f, ceil, gcd, sqrt, log
from bisect import bisect_left as bl, bisect_right as br
from itertools import combinations as c, permutations as p
from math import factorial as f, ceil, gcd, sqrt, log
mi = lambda : map(int, input().split())
ii = lambda : int(input())
li = lambda : list(map(int, input().split()))
mati = lambda r: [li() for _ in range(r)]
lcm = lambda a, b: a * b // gcd(a, b)

def solve():
	(n, m) = mi()
	arr = []
	for x in range(n):
		arr.append(li())
	ans = n * m
	for x in arr:
		w = x.count(1)
		b = x.count(0)
		ans += 2 ** w - 1 + 2 ** b - 1 - w - b
	for x in range(m):
		temp = []
		for y in range(n):
			temp.append(arr[y][x])
		w = temp.count(1)
		b = temp.count(0)
		ans += 2 ** w - 1 + 2 ** b - 1 - w - b
	print(ans)
for _ in range(1):
	solve()


(h, w) = map(int, input().split())
grid = []
ans = 0
for i in range(h):
	grid.append(input().split())
for i in range(h):
	whiterun = 0
	blackrun = 0
	for x in range(w):
		if grid[i][x] == '0':
			ans += 2 ** whiterun
			whiterun += 1
		else:
			ans += 2 ** blackrun
			blackrun += 1
for i in range(w):
	whiterun = 0
	blackrun = 0
	for x in range(h):
		if grid[x][i] == '0':
			ans += 2 ** whiterun - 1
			whiterun += 1
		else:
			ans += 2 ** blackrun - 1
			blackrun += 1
print(ans)


(n, m) = input().split()
n = int(n)
m = int(m)
cnt = 0
b = []
for i in range(n):
	a = [int(x) for x in input().split()]
	b.append(a)
	a = sum(a)
	cnt += (1 << a) + (1 << m - a) - 2
for i in range(m):
	x = 0
	for j in range(n):
		x = x + b[j][i]
	cnt = cnt + (1 << x) + (1 << n - x) - 2
cnt -= n * m
print(cnt)


def R():
	return map(int, input().split())
(n, m) = R()
t = [list(R()) for _ in range(n)]
ct = 0
for r in t:
	b = [1, 1]
	for x in r:
		b[x] *= 2
	ct += sum(b) - 2
for c in range(m):
	b = [1, 1]
	for r in range(n):
		b[t[r][c]] *= 2
	ct += sum(b) - 2
print(ct - n * m)


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append([int(x) for x in input().split()])
ans = 0
for i in a:
	ans += 2 ** i.count(1) - 1
	ans += 2 ** i.count(0) - 1
for i in range(len(a[0])):
	cnt = 0
	for j in range(len(a)):
		cnt += a[j][i]
	ans += 2 ** cnt - 1
	ans += 2 ** (n - cnt) - 1
ans -= n * m
print(ans)


(n, m) = map(int, input().split())
d = [list(map(int, input().split())) for i in range(n)]
ans = 0
for p in d:
	x = sum(p)
	ans += pow(2, x) + pow(2, m - x) - 2 - m
for i in range(m):
	x = sum((d[j][i] for j in range(n)))
	ans += pow(2, x) + pow(2, n - x) - 2
print(ans)


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
ans = 0
for i in range(n):
	l = sum([1 for e in a[i] if e == 0])
	nl = m - l
	ans += 2 ** l - 1 - l + (2 ** nl - 1 - nl)
for i in range(m):
	l = 0
	for j in range(n):
		if a[j][i] == 0:
			l += 1
	nl = n - l
	ans += 2 ** l - 1 - l + (2 ** nl - 1 - nl)
print(ans + n * m)


(n, m) = map(int, input().strip().split(' '))
a = []
ans = n * m
for i in range(n):
	b = list(map(int, input().strip().split(' ')))
	a.append(b)
for i in range(n):
	cnt = a[i].count(1)
	cn = a[i].count(0)
	ans = ans + 2 ** cnt + 2 ** cn - cnt - cn - 2
for i in range(m):
	cnt0 = sum((a[j][i] == 0 for j in range(n)))
	cnt1 = sum((a[j][i] == 1 for j in range(n)))
	if cnt0 > 1:
		ans += 2 ** cnt0 - cnt0 - 1
	if cnt1 > 1:
		ans += 2 ** cnt1 - cnt1 - 1
print(ans)


(n, m) = [int(i) for i in input().split()]
matrix = []
for i in range(n):
	matrix.append([int(i) for i in input().split()])
sets = 0
for row in range(n):
	zeros = 0
	ones = 0
	linha = matrix[row]
	for el in linha:
		if el == 1:
			ones += 1
		else:
			zeros += 1
	sets = sets + (2 ** zeros - 1) + (2 ** ones - 1)
for cols in range(m):
	zeros = 0
	ones = 0
	for row in range(n):
		el = matrix[row][cols]
		if el == 1:
			ones += 1
		else:
			zeros += 1
	zero_sets = 2 ** zeros - zeros - 1
	one_sets = 2 ** ones - ones - 1
	sets = sets + zero_sets + one_sets
print(sets)


(n, m) = list(map(int, input().split()))
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
ans = 0
for i in range(n):
	r = l[i]
	c1 = r.count(1)
	c2 = r.count(0)
	ans += 2 ** c1 - 1 + (2 ** c2 - 1)
for i in range(m):
	ls = []
	for j in range(n):
		ls.append(l[j][i])
	c1 = ls.count(1)
	c2 = ls.count(0)
	ans += 2 ** c1 - 1 + (2 ** c2 - 1) - c1 - c2
print(ans)


import math
(r, c) = map(int, input().split())
arr = []
for i in range(r):
	l = list(map(int, input().split()))
	arr.append(l)
cnt = 0
for i in range(r):
	w = arr[i].count(0)
	b = c - w
	cnt = cnt + int(math.pow(2, w)) + int(math.pow(2, b)) - 2
for i in range(c):
	w = 0
	for j in range(r):
		if arr[j][i] == 0:
			w = w + 1
	b = r - w
	cnt = cnt + int(math.pow(2, w)) + int(math.pow(2, b)) - 2 - r
print(int(cnt))


R = lambda : list(map(int, input().split()))
(n, m) = R()

def cal(c, u, v):
	r = 0
	for i in range(u):
		d = sum(c[i])
		r += (1 << d) - 1
		r += (1 << v - d) - 1
	return r
a = [R() for i in range(n)]
b = [[a[i][j] for i in range(n)] for j in range(m)]
print(cal(a, n, m) + cal(b, m, n) - n * m)


(n, m) = list(map(int, input().split()))
rc = []
cc = []
cols = [[] for i in range(m)]
for i in range(n):
	a = list(map(int, input().split()))
	for i in range(len(a)):
		cols[i].append(a[i])
	rc.append([a.count(1), a.count(0)])
for i in cols:
	cc.append([i.count(1), i.count(0)])
total = 0
for i in rc:
	total += 2 ** i[0] - 1 + 2 ** i[1] - 1
for i in cc:
	total += 2 ** i[0] - 1 - i[0] + (2 ** i[1] - 1 - i[1])
print(total)


(n, m) = map(int, input().split())
A = [0] * n
for i in range(n):
	A[i] = list(map(int, input().split()))
res = 0
for i in range(n):
	sum1 = sum(A[i])
	sum2 = m - sum1
	res += 2 ** sum1 + 2 ** sum2 - 2
sum1 = 0
sum2 = 0
for j in range(m):
	for i in range(n):
		sum1 += A[i][j]
	sum2 = n - sum1
	res += 2 ** sum1 + 2 ** sum2 - sum1 - sum2 - 2
	sum1 = 0
	sum2 = 0
print(res)


(n, m) = list(map(int, input().split()))
mat = []
ans = -m * n
for i in range(n):
	mat.append(list(map(int, input().split())))
	total = sum(mat[-1])
	ans += 2 ** total - 1
	ans += 2 ** (m - total) - 1
for i in range(m):
	total = 0
	for j in range(n):
		total += mat[j][i]
	ans += 2 ** total - 1
	ans += 2 ** (n - total) - 1
print(ans)


def fatorial(x):
	i = 2
	fat = 1
	while i <= x:
		fat *= i
		i += 1
	return fat

def combinacao(num, k):
	termo = num - k
	copia = num
	mult = 1
	if termo > k:
		while copia > termo:
			mult *= copia
			copia -= 1
		resultado = int(mult / fatorial(k))
	else:
		while copia > k:
			mult *= copia
			copia -= 1
		resultado = int(mult / fatorial(termo))
	return resultado
dimensoes = input()
numeros = dimensoes.split(' ')
row = int(numeros[0])
column = int(numeros[1])
result = row * column
m = []
for i in range(row):
	entrada = input()
	nums = entrada.split(' ')
	lista = []
	for j in range(len(nums)):
		num = int(nums[j])
		lista.append(num)
	m.append(lista)
linha = []
coluna = []
if column > 1:
	for i in range(row):
		um = 0
		zero = 0
		for j in range(column):
			if m[i][j] == 1:
				um += 1
			else:
				zero += 1
		total1 = um
		total0 = zero
		while um > 1:
			result += combinacao(total1, um)
			um -= 1
		while zero > 1:
			result += combinacao(total0, zero)
			zero -= 1
if row > 1:
	for j in range(column):
		um = 0
		zero = 0
		for i in range(row):
			if m[i][j] == 1:
				um += 1
			else:
				zero += 1
		total1 = um
		total0 = zero
		while um > 1:
			result += combinacao(total1, um)
			um -= 1
		while zero > 1:
			result += combinacao(total0, zero)
			zero -= 1
print(int(result))


(n, m) = map(int, input().split())
grid = []
sum = 0
for i in range(n):
	grid.append([0] * m)
	row = map(int, input().split())
	zeroes = 0
	ones = 0
	for (ir, e) in enumerate(row):
		grid[i][ir] = e
		if e:
			ones += 1
		else:
			zeroes += 1
	sum += 2 ** ones - 1
	sum += 2 ** zeroes - 1
for i in range(m):
	zeroes = 0
	ones = 0
	for k in range(n):
		if grid[k][i]:
			ones += 1
		else:
			zeroes += 1
	sum += 2 ** ones - 1
	sum += 2 ** zeroes - 1
print(sum - m * n)


(n, m) = list(map(int, input().split()))
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
ans = 0
for i in range(n):
	z = 0
	e = 0
	for j in range(m):
		if a[i][j] == 0:
			z = z + 1
		else:
			e = e + 1
	ans = ans + 2 ** e + 2 ** z - 2
for j in range(m):
	z = 0
	e = 0
	for i in range(n):
		if a[i][j] == 0:
			z = z + 1
		else:
			e = e + 1
	ans = ans + 2 ** e + 2 ** z - 2
print(ans - n * m)


(n, m) = map(int, input().split())
grid = []
for i in range(n):
	grid.append(list(map(int, input().split())))
ans = 0
for i in range(n):
	cnt0 = 0
	cnt1 = 0
	for j in range(m):
		if grid[i][j] == 1:
			cnt1 += 1
		else:
			cnt0 += 1
	ans += 2 ** cnt0 - 1
	ans += 2 ** cnt1 - 1
for i in range(m):
	cur = [grid[x][i] for x in range(n)]
	cnt0 = 0
	cnt1 = 0
	for x in cur:
		if x == 0:
			cnt0 += 1
		else:
			cnt1 += 1
	ans += 2 ** cnt0 - 1
	ans += 2 ** cnt1 - 1
print(ans - n * m)


def power(x):
	return 1 << x
(n, m) = map(int, input().split())
a = []
row = [[0, 0] for i in range(n)]
col = [[0, 0] for i in range(m)]
for i in range(n):
	a.append(list(map(int, input().split())))
ans = 0
for i in range(n):
	for x in a[i]:
		row[i][x] += 1
	ans += power(row[i][0]) + power(row[i][1]) - 2
for i in range(m):
	for j in range(n):
		col[i][a[j][i]] += 1
	ans += power(col[i][0]) + power(col[i][1]) - 2
ans -= n * m
print(ans)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
(N, M) = map(int, input().split())
A = []
for i in range(N):
	A.append([int(x) for x in input().split()])
ans = 0
for row in A:
	a = row.count(0)
	b = M - a
	ans += 2 ** a - 1
	ans += 2 ** b - 1
for col in [[A[r][c] for r in range(N)] for c in range(M)]:
	a = col.count(0)
	b = N - a
	ans += 2 ** a - 1
	ans += 2 ** b - 1
print(ans - M * N)


(n, m) = map(int, input().split())
mat = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n):
	w = 0
	b = 0
	for j in range(m):
		if mat[i][j] == 1:
			w += 1
		else:
			b += 1
	ans += 2 ** w + 2 ** b - 2
for i in range(m):
	w = 0
	b = 0
	for j in range(n):
		if mat[j][i] == 1:
			w += 1
		else:
			b += 1
	ans += 2 ** w + 2 ** b - 2
print(ans - n * m)


(n, m) = input().split()
n = int(n)
m = int(m)
row = []
col = []
for i in range(n):
	row.append(0)
for j in range(m):
	col.append(0)
for i in range(n):
	t = input().split()
	for j in range(m):
		e = int(t[j])
		if e == 0:
			row[i] += 1
			col[j] += 1
ans = 0
for i in range(m):
	ans += (1 << col[i]) + (1 << n - col[i]) - 2
for i in range(n):
	ans += (1 << row[i]) + (1 << m - row[i]) - m - 2
print(ans)


import sys
from math import *
from fractions import gcd
readints = lambda : map(int, input().strip('\n').split())
(n, m) = readints()
g = []
for _ in range(n):
	row = list(readints())
	g.append(row)
ans = 0
for i in range(n):
	zeros = 0
	ones = 0
	for j in range(m):
		if g[i][j] == 1:
			ones += 1
		else:
			zeros += 1
	ans += 2 ** ones - 1
	ans += 2 ** zeros - 1
for j in range(m):
	zeros = 0
	ones = 0
	for i in range(n):
		if g[i][j] == 1:
			ones += 1
		else:
			zeros += 1
	ans += 2 ** ones - 1
	ans += 2 ** zeros - 1
ans -= n * m
print(ans)


a = input().split()
n = int(a[0])
m = int(a[1])
v = []
soma = 0
for i in range(0, n):
	w = 0
	b = 0
	s = input()
	v.append(s.split())
	for j in range(0, m):
		if int(v[i][j]) == 0:
			w += 1
		else:
			b += 1
	soma += 2 ** w - 1
	soma += 2 ** b - 1
for j in range(0, m):
	w = 0
	b = 0
	for i in range(0, n):
		if int(v[i][j]) == 0:
			w += 1
		else:
			b += 1
	soma += 2 ** w - 1 - w
	soma += 2 ** b - 1 - b
print(soma)


(n, m) = input().split()
(n, m) = (int(n), int(m))
a = []
(rows1, rows0, mrows1, mrows0) = ([0] * n, [0] * n, [0] * n, [0] * n)
(cols1, cols0, mcols1, mcols0) = ([0] * m, [0] * m, [0] * m, [0] * m)
for i in range(n):
	b = [int(n) for n in input().split()]
	a.append(b)
	for j in range(m):
		if a[i][j] == 1:
			rows1[i] += 1
			cols1[j] += 1
		else:
			rows0[i] += 1
			cols0[j] += 1
ans = 0
for x in rows1:
	ans += 2 ** x - 1
for x in rows0:
	ans += 2 ** x - 1
for x in cols1:
	ans += 2 ** x - 1 - x
for x in cols0:
	ans += 2 ** x - 1 - x
print(ans)


from math import factorial

def c(n, k):
	return factorial(n) // (factorial(k) * factorial(n - k))
(n, m) = map(int, input().split())
ans = 0
a = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
	(c0, c1) = (0, 0)
	for j in range(m):
		if a[i][j]:
			c1 += 1
		else:
			c0 += 1
	for j in range(1, c0 + 1):
		ans += c(c0, j)
	for j in range(1, c1 + 1):
		ans += c(c1, j)
for j in range(m):
	(c0, c1) = (0, 0)
	for i in range(n):
		if a[i][j]:
			c1 += 1
		else:
			c0 += 1
	for i in range(2, c0 + 1):
		ans += c(c0, i)
	for i in range(2, c1 + 1):
		ans += c(c1, i)
print(ans)


(n, m) = map(int, input().split())
l = []
for i in range(n):
	r = list(map(int, input().split()))
	l.append(r)
c = 0
ans = 0
for i in range(n):
	c = 0
	c1 = 0
	for j in range(m):
		if l[i][j] == 1:
			c = c + 1
		else:
			c1 = c1 + 1
	ans = ans + pow(2, c) - 1 + pow(2, c1) - 1
for i in range(m):
	c = 0
	c1 = 0
	for j in range(n):
		if l[j][i] == 1:
			c = c + 1
		else:
			c1 = c1 + 1
	ans = ans + pow(2, c) - c - 1 + pow(2, c1) - c1 - 1
print(ans)


size = input().split()
matrixorginal = []
for i in range(int(size[0])):
	matrixorginal.append(input().split())
for ilist in matrixorginal:
	for i in ilist:
		i = int(i)
matrix1 = matrixorginal
matrix2 = list(zip(*matrix1))
sum = 0
for ilist in matrix1:
	a = 0
	for i in ilist:
		if int(i) == 0:
			a += 1
	sum = sum + 2 ** a + 2 ** (int(size[1]) - a) - 2
for ilist in matrix2:
	a = 0
	for i in ilist:
		if int(i) == 0:
			a += 1
	sum = sum + 2 ** a + 2 ** (int(size[0]) - a) - 2
sum = sum - int(size[0]) * int(size[1])
print(sum)


from math import factorial
(n, m) = map(int, input().split())
count = 0
mat = []
for i in range(n):
	arr = list(map(int, input().split()))
	mat.append(arr)
dict_row = {}
dict_col = {}
for i in range(n):
	for j in range(m):
		if i not in dict_row:
			dict_row[i] = {}
		if mat[i][j] not in dict_row[i]:
			dict_row[i][mat[i][j]] = 0
		dict_row[i][mat[i][j]] += 1
for i in range(m):
	for j in range(n):
		if i not in dict_col:
			dict_col[i] = {}
		if mat[j][i] not in dict_col[i]:
			dict_col[i][mat[j][i]] = 0
		dict_col[i][mat[j][i]] += 1
for (key1, dic) in dict_row.items():
	for (key2, value) in dic.items():
		for i in range(1, value + 1):
			count += factorial(value) // (factorial(i) * factorial(value - i))
for (key1, dic) in dict_col.items():
	for (key2, value) in dic.items():
		for i in range(2, value + 1):
			count += factorial(value) // (factorial(i) * factorial(value - i))
print(count)


from sys import stdin, stdout
import random
(n, m) = map(int, stdin.readline().rstrip().split())
table = []
for _ in range(n):
	table.append(list(map(int, stdin.readline().rstrip().split())))
table2 = [[0] * n for _ in range(m)]
for i in range(n):
	for j in range(m):
		table2[j][i] = table[i][j]
totalSets = 0
for i in range(n):
	if sum(table[i]) > 1:
		totalSets += 2 ** sum(table[i]) - 1 - sum(table[i])
	if sum(table[i]) < m - 1:
		totalSets += 2 ** (m - sum(table[i])) - 1 - (m - sum(table[i]))
for i in range(m):
	if sum(table2[i]) > 1:
		totalSets += 2 ** sum(table2[i]) - 1 - sum(table2[i])
	if sum(table2[i]) < n - 1:
		totalSets += 2 ** (n - sum(table2[i])) - 1 - (n - sum(table2[i]))
totalSets += n * m
print(totalSets)


def cout(res, b, w):
	x = f(b)
	for j in range(2, b + 1):
		res += x // (f(b - j) * f(j))
	x = f(w)
	for j in range(2, w + 1):
		res += x // (f(w - j) * f(j))
	return res
(n, m) = map(int, input().split())
matr = [[*map(int, input().split())] for i in range(n)]
from math import factorial as f
result = 0
for (i, x) in enumerate(matr):
	(b, w) = (0, 0)
	for (j, y) in enumerate(x):
		if y == 1:
			b += 1
		else:
			w += 1
	res = cout(b + w, b, w)
	result += res
for i in range(m):
	(b, w) = (0, 0)
	for j in range(n):
		if matr[j][i] == 1:
			b += 1
		else:
			w += 1
	res = cout(0, b, w)
	result += res
print(result)


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a += [list(map(int, input().split()))]
ans = 0
for i in range(n):
	x = y = 0
	for j in range(m):
		if a[i][j]:
			x += 1
		else:
			y += 1
	ans += (1 << x) + (1 << y) - 2 - x - y
for i in range(m):
	x = y = 0
	for j in range(n):
		if a[j][i]:
			x += 1
		else:
			y += 1
	ans += (1 << x) + (1 << y) - 2 - x - y
print(ans + n * m)


while 1:
	try:
		(n, m) = map(int, input().split())
		cells = [[int(x) for x in input().split()] for y in range(n)]
		ans = n * m
		for c in range(2):
			for i in range(n):
				cnt = 0
				for j in range(m):
					cnt += cells[i][j] == c
				ans += (1 << cnt) - cnt - 1
			for j in range(m):
				cnt = 0
				for i in range(n):
					cnt += cells[i][j] == c
				ans += (1 << cnt) - cnt - 1
		print(ans)
	except EOFError:
		break


def twopmo(n):
	return (1 << n) - n - 1
(n, m) = [int(x) for x in input().split()]
numzr = [0 for i in range(n)]
numzc = [0 for i in range(m)]
matrix = [[] for j in range(n)]
for i in range(n):
	matrix[i] = [int(x) for x in input().split()]
for i in range(n):
	for j in range(m):
		if matrix[i][j] == 1:
			numzc[j] += 1
			numzr[i] += 1
ans = n * m
for i in range(n):
	ans = ans + twopmo(numzr[i]) + twopmo(m - numzr[i])
for i in range(m):
	ans = ans + twopmo(numzc[i]) + twopmo(n - numzc[i])
print(ans)


from math import pow
(n, m) = [int(i) for i in input().split()]
l = []
for i in range(n):
	l.append([int(j) for j in input().split()])
count = n * m
for i in range(n):
	count1 = l[i].count(0)
	if count1 != 0 and count1 != 1:
		count += int(pow(2, count1) - 1 - count1)
	count2 = m - count1
	if count2 != 0 and count2 != 1:
		count += int(pow(2, count2) - 1 - count2)
for i in range(m):
	count1 = 0
	count2 = 0
	for j in range(n):
		if l[j][i] == 0:
			count1 += 1
		else:
			count2 += 1
	if count1 != 0 and count1 != 1:
		count += int(pow(2, count1) - 1 - count1)
	count2 = n - count1
	if count2 != 0 and count2 != 1:
		count += int(pow(2, count2) - 1 - count2)
print(count)


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
from bisect import bisect_left

def solve():
	(n, m) = read()
	cells = [list(read()) for x in range(n)]
	count = 0
	for x in cells:
		k = sum(x)
		count += 2 ** k + 2 ** (m - k) - 2
	for i in range(m):
		k = len([1 for j in cells if j[i]])
		count += 2 ** k + 2 ** (n - k) - n - 2
	print(count)
for _ in range(1):
	solve()


(n, m) = map(int, input().split())
table = []
sets = 0
for i in range(n):
	row = input().split()
	table.append(row)
	ones = 0
	zeroes = 0
	for r in row:
		if r == '0':
			zeroes += 1
		else:
			ones += 1
	sets += 2 ** ones - 1
	sets += 2 ** zeroes - 1
rot = list(zip(*table[::-1]))
for bla in rot:
	ones = 0
	zeroes = 0
	row = list(bla)
	for r in row:
		if r == '0':
			zeroes += 1
		else:
			ones += 1
	sets += 2 ** ones - 1 - ones
	sets += 2 ** zeroes - 1 - zeroes
print(sets)


read = lambda : map(int, input().split())
(n, m) = read()
a = [list(read()) for i in range(n)]
ans = n * m
for i in range(n):
	cnt0 = a[i].count(0)
	cnt1 = a[i].count(1)
	if cnt0 > 1:
		ans += 2 ** cnt0 - cnt0 - 1
	if cnt1 > 1:
		ans += 2 ** cnt1 - cnt1 - 1
for i in range(m):
	cnt0 = sum((a[j][i] == 0 for j in range(n)))
	cnt1 = sum((a[j][i] == 1 for j in range(n)))
	if cnt0 > 1:
		ans += 2 ** cnt0 - cnt0 - 1
	if cnt1 > 1:
		ans += 2 ** cnt1 - cnt1 - 1
print(ans)


import math
split = lambda : list(map(int, input().split()))
(a, b) = split()
rows = [split() for x in range(a)]
columns = [[x[y] for x in rows] for y in range(b)]

def choose(p, q):
	n = 1
	for x in range(p - q + 1, p + 1):
		n *= x
	n //= math.factorial(q)
	return n
s = 0
for x in rows + columns:
	(p, q) = (x.count(0), x.count(1))
	for y in range(1, p + 1):
		s += choose(p, y)
	for y in range(1, q + 1):
		s += choose(q, y)
s -= a * b
print(s)


import os
import sys
import math
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def dijkstra(start, distance, path, n):
	visited = [False for _ in range(n)]
	distance[start] = 0
	for i in range(n):
		v = -1
		for j in range(n):
			if not visited[v] and (v == -1 or distance[j] < distance[v]):
				v = j
		if distance[v] == math.inf:
			break
		visited[v] = True
		for edge in adj[v]:
			destination = edge[0]
			weight = edge[1]
			if distance[v] + weight < distance[destination]:
				distance[destination] = distance[v] + weight
				path[destination] = v

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def ncr(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def npr(n, r):
	return math.factorial(n) // math.factorial(n - r)

def seive(n):
	primes = [True] * (n + 1)
	ans = []
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	for p in range(2, n + 1):
		if primes[p]:
			ans += [p]
	return ans

def factors(n):
	factors = []
	x = 1
	while x * x <= n:
		if n % x == 0:
			if n // x == x:
				factors.append(x)
			else:
				factors.append(x)
				factors.append(n // x)
		x += 1
	return factors

def main():
	try:
		(n, m) = invr()
		matrix = []
		(row1, col1, row0, col0) = ([0] * n, [0] * m, [0] * n, [0] * m)
		for i in range(n):
			matrix.append(inlt())
		for i in range(n):
			for j in range(m):
				if matrix[i][j] == 1:
					row1[i] += 1
					col1[j] += 1
				else:
					row0[i] += 1
					col0[j] += 1
		ans = 0
		for i in range(n):
			x = row1[i]
			ans += 2 ** x - 1
			x = row0[i]
			ans += 2 ** x - 1
		for j in range(m):
			x = col0[j]
			ans += 2 ** x - 1
			x = col1[j]
			ans += 2 ** x - 1
		print(ans - n * m)
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, m) = map(int, input().split())
ans = 0
matrix = [[0 for i in range(m)] for j in range(n)]
i = 0
for i in range(n):
	matrix[i] = list(map(int, input().split()))
two = [0] * 51
two[0] = 1
for i in range(51):
	if i != 0:
		two[i] = two[i - 1] * 2
value = [0 for i in range(m)]
value1 = [0 for i in range(n)]
for i in range(n):
	sum = 0
	for j in range(m):
		sum += matrix[i][j]
	value1[i] = sum
for i in range(m):
	sum = 0
	for j in range(n):
		sum += matrix[j][i]
	value[i] = sum
for i in range(n):
	ans += two[value1[i]] - 1
	ans += two[m - value1[i]] - 1
for i in range(m):
	ans += two[value[i]] - 1 - value[i]
	ans += two[n - value[i]] - 1 - (n - value[i])
print(ans)


(n, m) = map(int, input().split())
arr = []
count = 0
for i in range(n):
	arr.append(input().split())
for i in arr:
	count += 2 ** i.count('1') + 2 ** i.count('0') - 2
for i in range(m):
	b = []
	for j in arr:
		b.append(j[i])
	count += 2 ** b.count('1') + 2 ** b.count('0') - 2
print(count - n * m)


(n, m) = map(int, input().split())
(rows, cols, res) = ([0] * n, [0] * m, 0)
for i in range(n):
	for (j, number) in enumerate(map(int, input().split())):
		rows[i] += number == 1
		cols[j] += number == 1
for number in rows:
	res += (1 << number) + (1 << m - number) - 2
for number in cols:
	res += (1 << number) + (1 << n - number) - 2
print(res - n * m)


def solution():
	ans = 0
	(n, m) = map(int, input().split())
	matrix = []
	for i in range(n):
		matrix.append([int(j) for j in input().split()])
	for i in range(n):
		count = 0
		for j in range(m):
			if matrix[i][j] == 1:
				count += 1
		ans += 2 ** count - 1
		count = m - count
		ans += 2 ** count - 1
	for j in range(m):
		count = 0
		for i in range(n):
			if matrix[i][j] == 1:
				count += 1
		if count > 1:
			ans += 2 ** count - 1 - count
		count = n - count
		if count > 1:
			ans += 2 ** count - 1 - count
	print(ans)
solution()


(n, m) = input().split()
n = int(n)
m = int(m)
table = []
for i in range(n):
	table.append([int(i) for i in input().split()])
col = [0] * m
lin = [0] * n
for i in range(n):
	for j in range(m):
		lin[i] += table[i][j]
		col[j] += table[i][j]
answ = 0
for i in lin:
	answ += 2 ** i - 1 + 2 ** (m - i) - 1
for i in col:
	answ += 2 ** i - 1 + 2 ** (n - i) - 1
print(answ - n * m)


(n, m) = map(int, input().split())
data = [[] for i in range(n)]
data2 = [[0] * n for i in range(m)]
for i in range(n):
	data[i] = list(map(int, input().split()))
a = 0
for i in range(m):
	for j in range(n):
		data2[i][j] = data[j][i]
for i in range(n):
	su = sum(data[i])
	if su != 0:
		a += 2 ** su - 1
	if m - su != 0:
		a += 2 ** (m - su) - 1
for i in range(m):
	su = sum(data2[i])
	if su != 0:
		a += 2 ** su - 1
	if n - su != 0:
		a += 2 ** (n - su) - 1
print(a - n * m)


import math
(n, m) = input().split(' ')
n = int(n)
m = int(m)
tab = []
for row in range(n):
	cols = input().split(' ')
	cols = [int(x) for x in cols]
	tab.append(cols)
ans = n * m
for row in range(n):
	for color in range(2):
		num = 0
		for column in range(m):
			if tab[row][column] == color:
				num += 1
		tmp1 = 0
		for x in range(num):
			if x + 1 > 1:
				tmp1 += int(math.factorial(num) / (math.factorial(x + 1) * math.factorial(num - (x + 1))))
		ans += tmp1
for column in range(m):
	for color in range(2):
		num = 0
		for row in range(n):
			if tab[row][column] == color:
				num += 1
		tmp1 = 2 ** num - num - 1
		tmp2 = 0
		for x in range(num):
			if x + 1 > 1:
				ans += int(math.factorial(num) / (math.factorial(x + 1) * math.factorial(num - (x + 1))))
print(int(ans))


(n, m) = map(int, input().split())
lis = []
ans = 0
for i in range(n):
	a = list(map(int, input().split()))
	ans += 2 ** sum(a) + 2 ** (m - sum(a)) - 2
	lis.append(a)
for i in range(m):
	cou = 0
	for j in range(n):
		cou += lis[j][i]
	ans += 2 ** cou + 2 ** (n - cou) - n - 2
print(ans)


(n, m) = map(int, input().split())
tbl = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
	c0 = 0
	c1 = 0
	for j in range(m):
		if tbl[i][j] == 0:
			c0 += 1
		else:
			c1 += 1
	ans += 2 ** c0 - 1
	ans += 2 ** c1 - 1
for i in range(m):
	c0 = 0
	c1 = 0
	for j in range(n):
		if tbl[j][i] == 0:
			c0 += 1
		else:
			c1 += 1
	ans += 2 ** c0 - 1
	ans += 2 ** c1 - 1
ans -= n * m
print(ans)


import sys
inf = float('inf')
ip = lambda : sys.stdin.readline().rstrip()
split = lambda : ip().split(' ')
ip1 = lambda : map(int, split())
arr = lambda : list(ip1())
arr1 = lambda n: [arr() for _ in range(n)]
mod = 998244353
(n, m) = ip1()
a = arr1(n)
ans = n * m
for i in range(n):
	ct = 0
	for j in range(m):
		if a[i][j]:
			ct += 1
	ct2 = m - ct
	ans += 2 ** ct + 2 ** ct2 - 2 - ct - ct2
for j in range(m):
	ct = 0
	for i in range(n):
		if a[i][j]:
			ct += 1
	ct2 = n - ct
	ans += 2 ** ct + 2 ** ct2 - 2 - ct - ct2
print(ans)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
s = 0
for l in a:
	k = sum(l)
	s += 2 ** k - 1
	s += 2 ** (m - k) - 1
for i in range(m):
	k = sum((l[i] for l in a))
	s += 2 ** k - 1 - k
	s += 2 ** (n - k) - 1 - (n - k)
print(s)


(n, m) = list(map(int, input().split()))
matrix = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
	ones = zeros = 0
	for j in range(m):
		if matrix[i][j] == 1:
			ones += 1
		else:
			zeros += 1
	ans += pow(2, ones) - 1
	ans += pow(2, zeros) - 1
for i in range(m):
	ones = zeros = 0
	for j in range(n):
		if matrix[j][i] == 1:
			ones += 1
		else:
			zeros += 1
	ans += pow(2, ones) - 1
	ans += pow(2, zeros) - 1
print(ans - m * n)


line1 = str(input()).split(' ')
n = int(line1[0])
m = int(line1[1])
table = []
for _ in range(n):
	row = str(input()).split(' ')
	for idx in range(len(row)):
		row[idx] = int(row[idx])
	table.append(row)
ans = 0
for row_idx in range(n):
	sum = 0
	for col_idx in range(m):
		sum += table[row_idx][col_idx]
	ans += 2 ** sum - 1 + (2 ** (m - sum) - 1)
for col_idx in range(m):
	sum = 0
	for row_idx in range(n):
		sum += table[row_idx][col_idx]
	ans += 2 ** sum - 1 + (2 ** (n - sum) - 1)
ans -= n * m
print(ans)


(m, n) = (int(x) for x in input().split())
z = []
for i in range(m):
	z.append([int(x) for x in input().split()])

def f(n):
	x = 1
	for i in range(1, n + 1):
		x *= i
	return x

def k(n, k):
	return f(n) // (f(k) * f(n - k))

def c(n):
	x = 0
	for i in range(2, n + 1):
		x += k(n, i)
	return x

def sum(n, z, p=0):
	s = 0
	if p == 0:
		for i in z:
			s += i[n]
		return s
	else:
		for i in z[n]:
			s += i
		return s
q = 0
for i in range(n):
	a = sum(i, z, 0)
	b = m - a
	q = q + c(a) + c(b)
for i in range(m):
	a = sum(i, z, 1)
	b = n - a
	q = q + c(a) + c(b)
print(q + m * n)


(n, m) = [int(x) for x in input().split()]
a = [[int(x) for x in input().split()] for _ in range(n)]
rows = [sum(a[i]) for i in range(n)]
cols = [sum([a[j][i] for j in range(n)]) for i in range(m)]
s = 0
for x in cols:
	s += 2 ** x + 2 ** (n - x) - 2
for x in rows:
	s += 2 ** x + 2 ** (m - x) - 2
s -= m * n
print(s)


from array import *
inps = input()
n = inps.split()
n = [int(x) for x in n]
arr = [[0 for x in range(n[1])] for y in range(n[0])]
lis = list()
import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return int(numer / denom)
for i in range(0, n[0]):
	lis.append(input())
	arr[i] = lis[i].split()
	arr[i] = [int(x) for x in arr[i]]
cnt = 0
cnt1 = 0
cnt0 = 0
for i in range(0, n[0]):
	cnt1 = 0
	cnt0 = 0
	for j in range(0, n[1]):
		if arr[i][j] == 1:
			cnt1 = cnt1 + 1
		else:
			cnt0 = cnt0 + 1
	tcnt0 = 0
	tcnt1 = 0
	if cnt0 > 0:
		for i in range(1, cnt0 + 1):
			tcnt0 = tcnt0 + ncr(cnt0, i)
	if cnt1 > 0:
		for i in range(1, cnt1 + 1):
			tcnt1 = tcnt1 + ncr(cnt1, i)
	cnt = cnt + tcnt0 + tcnt1
for j in range(0, n[1]):
	cnt0 = 0
	cnt1 = 0
	for i in range(0, n[0]):
		if arr[i][j] == 0:
			cnt0 = cnt0 + 1
		else:
			cnt1 = cnt1 + 1
	tcnt0 = 0
	tcnt1 = 0
	if cnt0 > 0:
		for i in range(1, cnt0 + 1):
			tcnt0 = tcnt0 + ncr(cnt0, i) - 1
	if cnt1 > 0:
		for i in range(1, cnt1 + 1):
			tcnt1 = tcnt1 + ncr(cnt1, i) - 1
	cnt = cnt + tcnt0 + tcnt1
print(cnt)


def main():
	(n, m) = [int(ai) for ai in input().split()]
	a = [[int(ai) for ai in input().split()] for _ in range(n)]
	ans = -n * m
	for v in a:
		cnt = [0, 0]
		for x in v:
			cnt[x] += 1
		ans += 2 ** cnt[0] - 1
		ans += 2 ** cnt[1] - 1
	for j in range(m):
		cnt = [0, 0]
		for i in range(n):
			cnt[a[i][j]] += 1
		ans += 2 ** cnt[0] - 1
		ans += 2 ** cnt[1] - 1
	print(ans)
main()


def f(x, y):
	if y == 0:
		return 1
	r = f(x, y // 2)
	r *= r
	if y % 2:
		r *= x
	return r

def main():
	s = input()
	s = s.split()
	n = int(s[0])
	nn = n
	m = int(s[1])
	ans = 0
	arr = []
	while n:
		o = 0
		z = 0
		s = input()
		arr.append(s)
		s = s.split()
		for i in s:
			if i == '1':
				o += 1
			else:
				z += 1
		ans += f(2, o) - 1
		ans += f(2, z) - 1
		n -= 1
	ccc = 0
	nnn = nn
	while m:
		o = 0
		z = 0
		cc = 0
		nn = nnn
		while nn:
			s = arr[cc][ccc]
			if s == '1':
				o += 1
			else:
				z += 1
			nn -= 1
			cc += 1
		if o > 0:
			ans += f(2, o) - 1
			ans -= o
		if z > 0:
			ans += f(2, z) - 1
			ans -= z
		m -= 1
		ccc += 2
	print(ans)
main()


def stripes(m, n):
	count1 = 0
	count2 = 0
	count1_1 = 0
	count2_2 = 0
	result = 0
	for i in range(len(m)):
		for j in range(len(m[i])):
			if m[i][j] == 0:
				count1 += 1
			if m[i][j] == 1:
				count2 += 1
		result += 2 ** count1 - 1 - count1
		result += 2 ** count2 - 1 - count2
		count1 = 0
		count2 = 0
	for i in range(len(n)):
		for j in range(len(n[i])):
			if n[i][j] == 0:
				count1_1 += 1
			if n[i][j] == 1:
				count2_2 += 1
		result += 2 ** count1_1 - 1
		result += 2 ** count2_2 - 1
		count1_1 = 0
		count2_2 = 0
	return result
n = input().strip().split()
n1 = int(n[0])
n2 = int(n[1])
arr = []
t = [[] for i in range(n2)]
for i in range(n1):
	m = input().strip().split()
	m = [int(m[i]) for i in range(len(m))]
	for j in range(len(m)):
		t[j].append(m[j])
	arr.append(m)
print(stripes(arr, t))


xxx = [int(i) for i in input().split()]
(m, n) = (xxx[0], xxx[1])
mat = []
for i in range(m):
	mat.append([int(j) for j in input().split()])

def transposta(mat):
	trs = [[] for i in range(len(mat[0]))]
	for linha in range(len(mat)):
		for coluna in range(len(mat[linha])):
			trs[coluna].append(mat[linha][coluna])
	return trs
trs = transposta(mat)
total = 0
for linha in mat:
	ums = linha.count(1)
	zeros = len(linha) - ums
	res = 2 ** ums - 1
	total += res
	res = 2 ** zeros - 1
	total += res
for coluna in trs:
	ums = coluna.count(1)
	zeros = len(coluna) - ums
	res = 2 ** ums - 1 - ums
	total += res
	res = 2 ** zeros - 1 - zeros
	total += res
print(int(total))


from io import BytesIO, IOBase
from math import sqrt
import sys, os
from os import path
inpl = lambda : list(map(int, input().split()))
inpm = lambda : map(int, input().split())
inpi = lambda : int(input())
inp = lambda : input()
(rev, ra, l) = (reversed, range, len)
P = print
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def B(n):
	return bin(n).replace('0b', '')

def factors(n):
	arr = []
	for i in ra(2, int(sqrt(n)) + 1):
		if n % i == 0:
			arr.append(i)
			if i * i != n:
				arr.append(int(n / i))
	return arr

def dfs(arr, n):
	pairs = [[i + 1] for i in ra(n)]
	vis = [0] * (n + 1)
	for i in ra(l(arr)):
		pairs[arr[i][0] - 1].append(arr[i][1])
	pairs[arr[i][1] - 1].append(arr[i][0])
	comp = []
	for i in ra(n):
		stack = [pairs[i]]
		temp = []
		if vis[stack[-1][0]] == 0:
			while len(stack) > 0:
				if vis[stack[-1][0]] == 0:
					temp.append(stack[-1][0])
					vis[stack[-1][0]] = 1
					s = stack.pop()
					for j in s[1:]:
						if vis[j] == 0:
							stack.append(pairs[j - 1])
				else:
					stack.pop()
			comp.append(temp)
	return comp
from bisect import bisect_left as bl
from bisect import bisect_right as br
import sys, operator, math, operator
from collections import Counter
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
import random, heapq
(n, m) = inpm()
mat = []
for i in ra(n):
	mat.append(inpl())
ans = 0
(row1, col1) = ([0] * n, [0] * m)
(row0, col0) = ([0] * n, [0] * m)
for i in ra(n):
	for j in ra(m):
		if mat[i][j] == 0:
			row0[i] += 1
			col0[j] += 1
		else:
			row1[i] += 1
			col1[j] += 1
ans = 0
for i in ra(n):
	ans += 2 ** row0[i] - 1
	ans += 2 ** row1[i] - 1
for i in ra(m):
	if col1[i] > 1:
		ans += 2 ** col1[i] - 1 - col1[i]
	if col0[i] > 1:
		ans += 2 ** col0[i] - 1 - col0[i]
P(ans)


(n, m) = map(int, input().split())
c0 = 0
c1 = 0
ans = 0
b = []
for i in range(n):
	a = list(map(int, input().split()))
	b.append(a)
	for j in range(m):
		if a[j] == 0:
			c0 += 1
		else:
			c1 += 1
	ans += 2 ** c0 + 2 ** c1 - 2
	c0 = 0
	c1 = 0
for i in range(m):
	for j in range(n):
		if b[j][i] == 0:
			c0 += 1
		else:
			c1 += 1
	ans += 2 ** c0 + 2 ** c1 - 2
	c0 = 0
	c1 = 0
print(ans - n * m)


from collections import Counter
I = [int(x) for x in input().split()]
out = 0
I1 = I[0] * [0]
I2 = []
for i in range(int(I[0])):
	I1[i] = [int(x) for x in input().split()]
	a = Counter(I1[i])
	out = 2 ** a[0] + 2 ** a[1] + out - 2
for j in range(int(I[1])):
	for k in range(int(I[0])):
		I2.append(I1[k][j])
	b = Counter(I2)
	out = 2 ** b[0] + 2 ** b[1] + out - b[0] - b[1] - 2
	I2 = []
print(out)


from math import factorial
(n, m) = map(int, input().split())
cols = [''] * m
result = n * m
for i in range(n):
	line = input().split()
	count_0 = line.count('0')
	if count_0 > 1:
		for j in range(2, count_0 + 1):
			result += factorial(count_0) // (factorial(j) * factorial(count_0 - j))
	count_1 = line.count('1')
	if count_1 > 1:
		for j in range(2, count_1 + 1):
			result += factorial(count_1) // (factorial(j) * factorial(count_1 - j))
	for j in range(m):
		cols[j] += line[j]
for i in range(m):
	col = cols[i]
	count_0 = col.count('0')
	if count_0 > 1:
		for j in range(2, count_0 + 1):
			result += factorial(count_0) // (factorial(j) * factorial(count_0 - j))
	count_1 = col.count('1')
	if count_1 > 1:
		for j in range(2, count_1 + 1):
			result += factorial(count_1) // (factorial(j) * factorial(count_1 - j))
print(result)


(n, m) = map(int, input().split())
a = []
b = []
ans = 0
for i in range(n):
	a.append(0)
for i in range(m):
	b.append(0)
for i in range(n):
	l = list(map(int, input().split()))
	for j in range(m):
		a[i] = a[i] + l[j]
		b[j] = b[j] + l[j]
for i in range(n):
	ans = ans + 2 ** a[i] - 1 + 2 ** (m - a[i]) - 1
for i in range(m):
	ans = ans + 2 ** b[i] - 1 + 2 ** (n - b[i]) - 1
ans = ans - n * m
print(ans)


(n, m) = map(int, input().split())
mat = []
for i in range(n):
	mat.append([int(i) for i in input().split()])
cont = n * m
for row in mat:
	ones = row.count(1)
	cont += 2 ** ones - (ones + 1)
	zeroes = row.count(0)
	cont += 2 ** zeroes - (zeroes + 1)
mat = map(list, zip(*mat))
for row in mat:
	ones = row.count(1)
	cont += 2 ** ones - (ones + 1)
	zeroes = row.count(0)
	cont += 2 ** zeroes - (zeroes + 1)
print(cont)


(r, c) = map(int, input().split(' '))
matrix = []
for _ in range(r):
	matrix.append(list(map(int, input().split(' '))))
ans = r * c
for i in range(r):
	zero = 0
	for j in range(c):
		if matrix[i][j] == 0:
			zero += 1
	one = c - zero
	ans += pow(2, one) - one - 1
	ans += pow(2, zero) - zero - 1
for i in range(c):
	zero = 0
	for j in range(r):
		if matrix[j][i] == 0:
			zero += 1
	one = r - zero
	ans += pow(2, one) - one - 1
	ans += pow(2, zero) - zero - 1
print(ans)


(n, m) = [int(i) for i in input().split()]
rows = [[0, 0] for i in range(n)]
columns = [[0, 0] for i in range(m)]
for i in range(n):
	row = [int(element) for element in input().split()]
	for j in range(m):
		if row[j] == 0:
			rows[i][0] += 1
			columns[j][0] += 1
		else:
			rows[i][1] += 1
			columns[j][1] += 1
number_of_sets = n * m
for count in rows:
	if count[0] > 0:
		number_of_sets += 2 ** count[0] - 1 - count[0]
	if count[1] > 0:
		number_of_sets += 2 ** count[1] - 1 - count[1]
for count in columns:
	if count[0] > 0:
		number_of_sets += 2 ** count[0] - 1 - count[0]
	if count[1] > 0:
		number_of_sets += 2 ** count[1] - 1 - count[1]
print(number_of_sets)


from math import factorial

def get(n):
	ans = 0
	for k in range(2, n + 1):
		ans += factorial(n) // (factorial(k) * factorial(n - k))
	return ans
(n, m) = map(int, input().split())
tab = []
for i in range(n):
	tab.append(list(map(int, input().split())))
cnt = n * m
for i in range(n):
	line = tab[i]
	cnt0 = line.count(0)
	cnt1 = line.count(1)
	if cnt1 > 1:
		cnt += get(cnt1)
	if cnt0 > 1:
		cnt += get(cnt0)
for i in range(m):
	cnt0 = 0
	cnt1 = 0
	for j in range(n):
		if tab[j][i]:
			cnt1 += 1
		else:
			cnt0 += 1
	if cnt1 > 1:
		cnt += get(cnt1)
	if cnt0 > 1:
		cnt += get(cnt0)
print(cnt)


import sys
input = sys.stdin.readline
from collections import Counter
(n, m) = map(int, input().split())
white_black = [0, 0]
rows = [[0, 0] for _ in range(n)]
cols = [[0, 0] for _ in range(m)]
for r in range(n):
	for (c, char) in enumerate(input().rstrip().split()):
		white_black[int(char)] += 1
		rows[r][int(char)] += 1
		cols[c][int(char)] += 1
count = white_black[0] + white_black[1]
for r in range(n):
	count += 2 ** rows[r][0] - rows[r][0] - 1
	count += 2 ** rows[r][1] - rows[r][1] - 1
for c in range(m):
	count += 2 ** cols[c][0] - cols[c][0] - 1
	count += 2 ** cols[c][1] - cols[c][1] - 1
print(count)


import sys
(n, m) = list(map(int, input().split()))
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
c1 = []
c2 = []
for i in range(n):
	c1.append(a[i].count(1))
for i in range(m):
	c = 0
	for j in range(n):
		if a[j][i] == 1:
			c += 1
	c2.append(c)
s = 0
for i in c1:
	s += 2 ** i - 2 + 2 ** (m - i)
for i in c2:
	s += 2 ** i - 2 + 2 ** (n - i)
s -= n * m
print(s)


import math
(n, m) = map(int, input().split())
tbl = []
ansv = 0
for i in range(n):
	tbl.append(list(map(int, input().split())))
for i in range(n):
	row = tbl[i]
	ones = 0
	zeros = 0
	for el in row:
		if el:
			ones += 1
		else:
			zeros += 1
	if ones:
		ansv += 2 ** ones - 1
	if zeros:
		ansv += 2 ** zeros - 1
for j in range(m):
	col = [tbl[i][j] for i in range(n)]
	ones = 0
	zeros = 0
	for el in col:
		if el:
			ones += 1
		else:
			zeros += 1
	if ones:
		ansv += 2 ** ones - 1
	if zeros:
		ansv += 2 ** zeros - 1
print(ansv - n * m)


(n, m) = list(map(int, input().split()))
mtx = []
for _ in range(n):
	mtx.append(list(map(int, input().split())))
res = 0
for i in range(n):
	a = sum(mtx[i])
	b = m - a
	if a >= 1:
		res += 2 ** a - 1
	if b >= 1:
		res += 2 ** b - 1
for j in range(m):
	a = sum((mtx[i][j] for i in range(n)))
	b = n - a
	if a >= 1:
		res += 2 ** a - 1
	if b >= 1:
		res += 2 ** b - 1
res -= n * m
print(res)


(n, m) = map(int, input().split())
t = [[] for i in range(n)]
total_n = [0] * n
total_m = [0] * m
for i in range(n):
	t[i] = list(map(int, input().split()))
	for j in range(m):
		if t[i][j] == 1:
			total_n[i] += 1
			total_m[j] += 1
ans = sum((2 ** total_n[i] + 2 ** (m - total_n[i]) for i in range(n))) - 2 * n + sum((2 ** total_m[j] + 2 ** (n - total_m[j]) for j in range(m))) - 2 * m
print(ans - n * m)


import sys
input = sys.stdin.readline

def solve():
	(n, m) = map(int, input().split())
	a = [list(map(int, input().split())) for i in range(n)]
	r = 0
	for i in a:
		c = i.count(0)
		r += 2 ** c - 1 + 2 ** (m - c) - 1
	for i in range(m):
		c = 0
		for j in range(n):
			c += a[j][i] == 0
		r += 2 ** c - 1 + 2 ** (n - c) - 1
	print(r - n * m)
solve()


(n, m) = map(int, input().split())
arr = []
row = []
col = [0] * m
ans = 0
for _ in range(n):
	l = list(map(int, input().split()))
	s = sum(l)
	row.append(s)
	arr.append(l)
for i in range(n):
	ans += 2 ** row[i] - 1
	ans += 2 ** (m - row[i]) - 1
for i in range(m):
	for j in range(n):
		col[i] += arr[j][i]
for i in range(m):
	ans += 2 ** col[i] - 1
	ans += 2 ** (n - col[i]) - 1
ans -= n * m
print(ans)
ans = 0


(n, m) = [int(x) for x in input().split()]
grid = []
for i in range(n):
	row = input().split()
	grid.append(row)
result = n * m
for i in range(n):
	counts = 0
	for j in range(m):
		if grid[i][j] == '1':
			counts += 1
	result += 2 ** counts - counts - 1
	result += 2 ** (m - counts) - m + counts - 1
for i in range(m):
	counts = 0
	for j in range(n):
		if grid[j][i] == '1':
			counts += 1
	result += 2 ** counts - counts - 1
	result += 2 ** (n - counts) - n + counts - 1
print(result)


import math
import operator as op
import functools

def ncr(n, r):
	r = min(r, n - r)
	if r == 0:
		return 1
	numer = functools.reduce(op.mul, range(n, n - r, -1))
	denom = functools.reduce(op.mul, range(1, r + 1))
	return numer // denom
t = input().split()
n = int(t[0])
m = int(t[1])
xx = []
yy = [[0 for x in range(n)] for y in range(m)]
for i in range(n):
	v = list(map(int, input().split()))
	xx.append(v)
	for j in range(m):
		yy[j][i] = v[j]
s = 0
for rr in xx:
	d = {1: 0, 0: 0}
	for r in rr:
		d[r] = d.get(r, 0) + 1
	for c in range(2, d[0] + 1):
		s = s + ncr(d[0], c)
	for c in range(2, d[1] + 1):
		s = s + ncr(d[1], c)
for rr in yy:
	d = {1: 0, 0: 0}
	for r in rr:
		d[r] = d.get(r, 0) + 1
	for c in range(2, d[0] + 1):
		s = s + ncr(d[0], c)
	for c in range(2, d[1] + 1):
		s = s + ncr(d[1], c)
print(s + n * m)


def dp(x):
	return 2 ** x - 1
n = input().split()
m = int(n[1])
n = int(n[0])
k = 0
kol0 = 0
t = -m * n
s = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
	k = input().split()
	for j in range(m):
		s[i][j] = k[j]
for i in range(n):
	k = s[i]
	for j in range(m):
		if k[j] == '0':
			kol0 += 1
	t += dp(kol0)
	t += dp(m - kol0)
	kol0 = 0
for i in range(m):
	for j in range(n):
		if s[j][i] == '0':
			kol0 += 1
	t += dp(kol0)
	t += dp(n - kol0)
	kol0 = 0
print(t)


(n, m) = list(map(int, input().split()))
M = []
for i in range(n):
	num = list(map(int, input().split()))
	M.append(num)
ans = 0
for i in range(n):
	cnt = 0
	for j in range(m):
		if M[i][j] == 1:
			cnt += 1
	ans += 2 ** cnt - 1
	ans += 2 ** (m - cnt) - 1
for j in range(m):
	cnt = 0
	for i in range(n):
		if M[i][j] == 1:
			cnt += 1
	ans += 2 ** cnt - 1
	ans += 2 ** (n - cnt) - 1
	ans -= n
print(ans)


(n, m) = map(int, input().split())
grid = [None] * n
for i in range(n):
	grid[i] = list(map(int, input().split()))
result = 0
for i in range(n):
	t = sum(grid[i])
	result += 2 ** t + 2 ** (m - t)
for i in range(m):
	t = sum((grid[j][i] for j in range(n)))
	result += 2 ** t + 2 ** (n - t)
result -= 2 * (n + m) + n * m
print(result)


def f(n, k):
	ans = 1
	for i in range(n - k + 1, n + 1):
		ans *= i
	for i in range(1, k + 1):
		ans //= i
	return ans
(n, m) = map(int, input().split())
v = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
	v[i] = list(map(int, input().split()))
ans = n * m
for i in range(n):
	bl = 0
	w = 0
	for j in range(m):
		if v[i][j] == 0:
			w += 1
	for maxx in range(2, w + 1):
		ans += f(w, maxx)
	bl = m - w
	for maxx in range(2, bl + 1):
		ans += f(bl, maxx)
for i in range(m):
	bl = 0
	w = 0
	for j in range(n):
		if v[j][i] == 0:
			w += 1
	bl = n - w
	for maxx in range(2, w + 1):
		ans += f(w, maxx)
	for maxx in range(2, bl + 1):
		ans += f(bl, maxx)
print(ans)


from collections import Counter
(n, m) = list(map(int, input().split()))
a = [[] for i in range(n)]
for i in range(n):
	a[i] = list(map(int, input().split()))
ans = 0
for i in range(n):
	c = Counter(a[i])
	ans += 2 ** c[0] - 1
	ans += 2 ** c[1] - 1
for j in range(m):
	c = [0, 0]
	for i in range(n):
		c[a[i][j]] += 1
	ans += 2 ** c[0] - 1 - c[0]
	ans += 2 ** c[1] - 1 - c[1]
print(ans)


(n, m) = list(map(int, input().split()))
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
ans = 0
for i in range(n):
	k0 = 0
	k1 = 0
	for j in range(m):
		if a[i][j] == 0:
			k0 += 1
		else:
			k1 += 1
	ans += 2 ** k0 + 2 ** k1 - 2
for i in range(m):
	k0 = 0
	k1 = 0
	for j in range(n):
		if a[j][i] == 0:
			k0 += 1
		else:
			k1 += 1
	ans += 2 ** k0 + 2 ** k1 - 2 - k0 - k1
print(ans)


import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	if r == 0:
		return 1
	numer = reduce(op.mul, range(n, n - r, -1))
	denom = reduce(op.mul, range(1, r + 1))
	return numer // denom

def a_sum(n):
	s = 0
	for i in range(2, n):
		s += ncr(n, i)
	return s + 1
(n, m) = map(int, input().split())
board = []
for _ in range(n):
	board.append(''.join(input().split()))
res = []
for i in range(n):
	(a, b) = (board[i].count('0'), board[i].count('1'))
	if a > 1:
		res.append(a)
	if b > 1:
		res.append(b)
board = list(zip(*board))
for i in range(m):
	board[i] = ''.join(board[i])
for i in range(m):
	(a, b) = (board[i].count('0'), board[i].count('1'))
	if a > 1:
		res.append(a)
	if b > 1:
		res.append(b)
print(sum([a_sum(x) for x in res]) + n * m)


def comb(num):
	q = 0
	for i in range(1, num + 1):
		q += fat(num) // (fat(i) * fat(num - i))
	q -= num
	return q

def fat(num):
	q = 1
	for i in range(1, num + 1):
		q *= i
	return q
(n, m) = map(int, input().split())
a = []
for i in range(n):
	l = list(map(int, input().split()))
	a.append(l)
r = n * m
for line in a:
	b = 0
	w = 0
	for x in line:
		if x == 0:
			w += 1
		else:
			b += 1
	r += comb(b) + comb(w)
for j in range(m):
	b = 0
	w = 0
	for y in [line[j] for line in a]:
		if y == 0:
			w += 1
		else:
			b += 1
	r += comb(b) + comb(w)
print(r)


(n, m) = map(int, input().split())
l = []
for i in range(n):
	ll = list(map(int, input().split()))
	l.append(ll)
s = 0
for x in l:
	c1 = x.count(1)
	c0 = x.count(0)
	s = s + 2 ** c1 + 2 ** c0 - 2
for i in range(m):
	c0 = 0
	c1 = 0
	for j in range(n):
		if l[j][i] == 0:
			c0 += 1
		if l[j][i] == 1:
			c1 += 1
	s = s + 2 ** c0 + 2 ** c1 - 2
s = s - m * n
print(s)


import math

def c(n, m):
	return math.factorial(n) // math.factorial(m) // math.factorial(n - m)

def f(a):
	c1 = 0
	c0 = 0
	for i in a:
		if i:
			c1 += 1
		else:
			c0 += 1
	x = 0
	for i in range(2, c1 + 1):
		x += c(c1, i)
	for i in range(2, c0 + 1):
		x += c(c0, i)
	return x
(n, m) = map(int, input().split())
ans = n * m
a = []
b = []
for i in range(m):
	b.append([])
for i in range(n):
	q = list(map(int, input().split()))
	ans += f(q)
	for i in range(m):
		b[i].append(q[i])
for i in b:
	ans += f(i)
print(ans)


(n, m) = input().strip().split()
n = int(n)
m = int(m)
a = [[0] * 50 for i in range(50)]
for i in range(n):
	p = input()
	a[i] = p.split(' ')
ans = 0
for i in range(n):
	k = 0
	for j in range(m):
		if a[i][j] == '1':
			k = k + 1
	ans = ans + 2 ** k - 1 + 2 ** (m - k) - 1
for i in range(m):
	k = 0
	for j in range(n):
		if a[j][i] == '1':
			k = k + 1
	ans = ans + 2 ** k - 1 + 2 ** (n - k) - 1
print(ans - n * m)


from math import factorial
(n, m) = map(int, input().split())
t = []
c = 0
for i in range(n):
	t.append(list(map(int, input().split())))
	z = t[-1].count(0)
	u = t[-1].count(1)
	for i in range(1, z + 1):
		c += factorial(z) // factorial(i) // factorial(z - i)
	for i in range(1, u + 1):
		c += factorial(u) // factorial(i) // factorial(u - i)
for j in range(m):
	z = 0
	u = 0
	for i in range(n):
		if t[i][j] == 0:
			z += 1
		else:
			u += 1
	for i in range(2, z + 1):
		c += factorial(z) // factorial(i) // factorial(z - i)
	for i in range(2, u + 1):
		c += factorial(u) // factorial(i) // factorial(u - i)
print(c)


(n, m) = map(int, input().strip().split(' '))
l1 = []
c = 0
for i in range(n):
	s = input()
	l1.append(s)
c1 = 0
c0 = 0
for i in range(n):
	c1 = l1[i].count('1')
	c0 = l1[i].count('0')
	c += 2 ** c1 - 1
	c += 2 ** c0 - 1
l2 = []
c1 = 0
c0 = 0
for i in range(m + (m - 1)):
	c1 = 0
	c0 = 0
	for j in range(n):
		if l1[j][i] == ' ':
			continue
		elif l1[j][i] == '1':
			c1 += 1
		else:
			c0 += 1
	c += 2 ** c1 - 1
	c += 2 ** c0 - 1
print(c - m * n)


line1 = input()
line1 = line1.split(' ')
n = int(line1[0])
m = int(line1[1])
A = [[0 for _ in range(m)] for __ in range(n)]
for i in range(n):
	fila = input()
	fila = fila.split(' ')
	fila = [int(x) for x in fila]
	A[i] = fila
total = 0
for fila in A:
	unosPorFila = 0
	cerosPorFila = 0
	for e in fila:
		if e == 1:
			unosPorFila += 1
		else:
			cerosPorFila += 1
	total += 2 ** unosPorFila - 1
	total += 2 ** cerosPorFila - 1
for j in range(m):
	unosPorCol = 0
	cerosPorCol = 0
	for i in range(n):
		e = A[i][j]
		if e == 1:
			unosPorCol += 1
		else:
			cerosPorCol += 1
	if unosPorCol > 0:
		total += 2 ** unosPorCol - 1 - unosPorCol
	if cerosPorCol > 0:
		total += 2 ** cerosPorCol - 1 - cerosPorCol
print(total)


matrix = []
(n, m) = map(int, input().split())
answer = 0
for _ in range(n):
	line = list(map(int, input().split()))
	answer += 2 ** sum(line) - 1
	answer += 2 ** (m - sum(line)) - 1
	matrix.append(line)
for i in range(m):
	s = 0
	for j in range(n):
		s += matrix[j][i]
	answer += 2 ** s - 1
	answer += 2 ** (n - s) - 1
answer -= n * m
print(answer)


from math import factorial
binomial = lambda n, k: factorial(n) / (factorial(k) * factorial(n - k))
(n, m) = map(int, input().split())
field = []
count = 0
for i in range(n):
	row = [int(c) for c in input().split()]
	field.append(row)
for row in field:
	black = sum(row)
	count += 2 ** black - 1
	count += 2 ** (m - black) - 1
for j in range(m):
	black = 0
	for i in range(n):
		black = black + field[i][j]
	count += 2 ** black - 1
	count += 2 ** (n - black) - 1
print(int(count) - n * m)


def C(n, k):
	ch = 1
	for i in range(k + 1, n + 1):
		ch *= i
	zn = 1
	for i in range(2, n - k + 1):
		zn *= i
	return ch // zn
(n, m) = map(int, input().split())
ans = 0
column = m * [0]
for i in range(n):
	c = [int(i) for i in input().split()]
	sum = 0
	for item in range(0, m):
		sum += c[item]
		column[item] += c[item]
	kol0 = m - sum
	for k in range(2, sum + 1):
		ans += C(sum, k)
	for k in range(2, kol0 + 1):
		ans += C(kol0, k)
for i in range(0, m):
	for k in range(2, column[i] + 1):
		ans += C(column[i], k)
	kol0 = n - column[i]
	for k in range(2, kol0 + 1):
		ans += C(kol0, k)
print(ans + n * m)


from bisect import bisect_left, bisect_right
import os
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque, defaultdict
import math
import heapq
import re

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
LOW = 'abcdefghijklmnopqrstuvwxyz'
UP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def main():
	(n, m) = ain()
	ans = 0
	l = []
	for _ in range(n):
		l.append(ain())
	for i in range(n):
		cnt1 = 0
		cnt0 = 0
		for j in range(m):
			if l[i][j] == 1:
				cnt1 += 1
			else:
				cnt0 += 1
		if cnt1 > 1:
			ans += 2 ** cnt1 - 1 - cnt1
		if cnt0 > 1:
			ans += 2 ** cnt0 - 1 - cnt0
	for j in range(m):
		cnt1 = 0
		cnt0 = 0
		for i in range(n):
			if l[i][j] == 1:
				cnt1 += 1
			else:
				cnt0 += 1
		if cnt1 > 1:
			ans += 2 ** cnt1 - 1 - cnt1
		if cnt0 > 1:
			ans += 2 ** cnt0 - 1 - cnt0
	ans += m * n
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


tmp = input().split(' ')
n = int(tmp[0])
m = int(tmp[1])
table = []
for i in range(n):
	color = input().split(' ')
	tmp = []
	for j in range(m):
		tmp.append(int(color[j]))
	table.append(tmp)
ans = 0
for i in range(n):
	flag1 = 0
	flag0 = 0
	for j in range(m):
		if table[i][j]:
			flag1 += 1
		else:
			flag0 += 1
	ans += 2 ** flag1 + 2 ** flag0 - 2
for i in range(m):
	flag1 = 0
	flag0 = 0
	for j in range(n):
		if table[j][i]:
			flag1 += 1
		else:
			flag0 += 1
	ans += 2 ** flag1 + 2 ** flag0 - 2
ans -= n * m
print(ans)


def fatorial(x):
	if x == 0:
		return 1
	return x * fatorial(x - 1)

def combinacao(n, q):
	return fatorial(n) // (fatorial(q) * fatorial(n - q))
(n, m) = [int(i) for i in input().split()]
table = [[int(j) for j in input().split()] for i in range(n)]
linhas = [[0] * 2 for i in range(n)]
colunas = [[0] * 2 for i in range(m)]
for i in range(n):
	for j in range(m):
		linhas[i][table[i][j]] += 1
		colunas[j][table[i][j]] += 1
ans = n * m
for i in range(n):
	if linhas[i][0] > 1:
		x = linhas[i][0]
		while x > 1:
			ans += combinacao(linhas[i][0], x)
			x -= 1
	if linhas[i][1] > 1:
		x = linhas[i][1]
		while x > 1:
			ans += combinacao(linhas[i][1], x)
			x -= 1
for i in range(m):
	if colunas[i][0] > 1:
		x = colunas[i][0]
		while x > 1:
			ans += combinacao(colunas[i][0], x)
			x -= 1
	if colunas[i][1] > 1:
		x = colunas[i][1]
		while x > 1:
			ans += combinacao(colunas[i][1], x)
			x -= 1
print(ans)
exit(0)


a = input().split()
(n, m) = (int(a[0]), int(a[1]))
c1 = [0] * m
r = 0
for i in range(n):
	k = list(map(int, input().split()))
	s1 = 0
	for j in range(m):
		if k[j] == 1:
			s1 += 1
			c1[j] += 1
	r += 2 ** s1 + 2 ** (m - s1) - 2
for i in c1:
	r += 2 ** i + 2 ** (n - i) - 2
r -= n * m
print(r)


l = []
kl = []
(n, m) = map(int, input().split())
for _ in range(n):
	l.append(input().split())
for i in range(n):
	white = 0
	black = 0
	for j in range(m):
		j_ = l[i][j]
		if j_ == '1':
			white += 1
		else:
			black += 1
	kl.append(white)
	kl.append(black)
for i in range(m):
	white = 0
	black = 0
	for j in range(n):
		if l[j][i] == '1':
			white += 1
		else:
			black += 1
	kl.append(white)
	kl.append(black)
s = 0
for k in kl:
	s += 2 ** k - 1
print(s - m * n)


(n, m) = map(int, input().split())
a = []
k = -m * n

def f(n):
	return 2 ** n - 1
for i in range(n):
	a.append(list(map(int, input().split())))
	b = sum(a[i])
	k += f(b) + f(m - b)
for i in range(m):
	b = 0
	for j in range(n):
		b += a[j][i]
	k += f(b) + f(n - b)
print(int(k))


(x, y) = map(int, input().split())
lol = []
s = 0
yo = []
for i in range(y):
	yo.append([0] * 2)
for _ in range(x):
	l = list(map(int, input().split()))
	lol.append(l)
	c = 0
	d = 0
	for i in range(y):
		if l[i] == 1:
			c += 1
			yo[i][1] += 1
		else:
			d += 1
			yo[i][0] += 1
	if c > 1:
		s += pow(2, c) - (c + 1)
	if d > 1:
		s += pow(2, d) - (d + 1)
for i in range(y):
	a = yo[i][0]
	b = yo[i][1]
	if a > 1:
		s += pow(2, a) - (a + 1)
	if b > 1:
		s += pow(2, b) - (b + 1)
print(s + x * y)


(n, m) = map(int, input().split())
row = []
for i in range(n):
	row.append(list(map(int, input().split())))
result = 0
for r in range(n):
	result += 2 ** sum(row[r]) - 1 + (2 ** (m - sum(row[r])) - 1)
for s in range(m):
	summ = 0
	for g in range(n):
		summ += row[g][s]
	result += 2 ** summ - 1 + (2 ** (n - summ) - 1)
print(result - n * m)


(n, k) = map(int, input().split())
a = []
suma = 0
for i in range(n):
	a.append(input().split())
for i in a:
	suma += 2 ** i.count('1') + 2 ** i.count('0') - 2
for i in range(k):
	b = []
	for j in a:
		b.append(j[i])
	suma += 2 ** b.count('1') + 2 ** b.count('0') - 2
print(suma - n * k)


from math import factorial as f

def C(n, k):
	return int(f(n) / (f(k) * f(n - k)))

def sum_C(n):
	return sum([C(n, k) for k in range(2, n + 1)])
(n, m) = map(int, input().split())
s = [input().split() for i in range(n)]
ans = n * m
for i in range(n):
	el = ''.join(map(str, s[i]))
	ans += sum_C(el.count('0'))
	ans += sum_C(el.count('1'))
for j in range(m):
	el = ''.join(map(str, [st[j] for st in s]))
	ans += sum_C(el.count('0'))
	ans += sum_C(el.count('1'))
print(ans)


(n, m) = map(int, input().split())
a = []
d = []
s = n * m
for i in range(0, n):
	b = list(map(int, input().split()))
	a.append(b)
	n1 = b.count(1)
	n2 = b.count(0)
	s += 2 ** n1 + 2 ** n2 - n1 - n2 - 2
for k in range(0, m):
	c = [a[i][k] for i in range(0, n)]
	d.append(c)
	m1 = c.count(1)
	m2 = c.count(0)
	s += 2 ** m1 + 2 ** m2 - m1 - m2 - 2
print(s)


k = {0: 1}

def f(n):
	if n in k:
		return k[n]
	else:
		c = 1
		for i in range(1, n + 1):
			c *= i
			k[i] = c
		return k[n]

def main():
	(n, m) = tuple(map(int, input().split()))
	a = []
	k = []
	for i in range(n):
		a += [list(map(int, input().split()))]
		j = a[i].count(1)
		if j > 1:
			k += [j]
		if m - j > 1:
			k += [m - j]
	for j in range(m):
		c1 = 0
		c2 = 0
		for i in range(n):
			if a[i][j] == 1:
				c1 += 1
			else:
				c2 += 1
		if c1 > 1:
			k += [c1]
		if c2 > 1:
			k += [c2]
	ans = n * m
	for i in k:
		ans += 2 ** i - (i + 1)
	print(ans)
main()


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append([int(j) for j in input().split()])
b = []
for i in range(0, max(m, n)):
	if i != 0:
		b.append(b[i - 1] * 2 + 1)
	else:
		b.append(1)
k = 0
sum1 = 0
sum2 = 0
for i in range(0, n):
	for j in range(0, m):
		if a[i][j] == 1:
			sum1 = sum1 + 1
		else:
			sum2 = sum2 + 1
	if sum1 > 0 and sum2 > 0:
		k = k + b[sum1 - 1] + b[sum2 - 1]
	elif sum1 > 0:
		k = k + b[sum1 - 1]
	elif sum2 > 0:
		k = k + b[sum2 - 1]
	sum1 = 0
	sum2 = 0
for i in range(0, m):
	for j in range(0, n):
		if a[j][i] == 1:
			sum1 = sum1 + 1
		else:
			sum2 = sum2 + 1
	if sum1 > 0 and sum2 > 0:
		k = k + b[sum1 - 1] + b[sum2 - 1]
	elif sum1 > 0:
		k = k + b[sum1 - 1]
	elif sum2 > 0:
		k = k + b[sum2 - 1]
	sum1 = 0
	sum2 = 0
print(k - n * m)


(n, m) = map(int, input().split())
k = []
for i in range(n):
	k.append(list(map(int, input().split())))
ans = 0

def summ(i):
	q = 0
	for j in range(n):
		q += k[j][i]
	return q
for i in range(n):
	p = sum(k[i])
	ans += 2 ** p - 1
	ans += 2 ** (m - p) - 1
for i in range(m):
	z = summ(i)
	ans += 2 ** z - 1
	ans += 2 ** (n - z) - 1
ans -= n * m
print(int(ans))


from math import factorial

def count(n, k):
	return factorial(n) // (factorial(k) * factorial(n - k))
(n, m) = map(int, input().split())
table = []
for i in range(n):
	table.append(list(map(int, input().split())))
ans = 0
for i in range(n):
	c0 = table[i].count(0)
	c1 = table[i].count(1)
	for j in range(1, c0 + 1):
		ans += count(c0, j)
	for j in range(1, c1 + 1):
		ans += count(c1, j)
for j in range(m):
	c0 = 0
	c1 = 0
	for i in range(n):
		if table[i][j] == 0:
			c0 += 1
		else:
			c1 += 1
	for i in range(2, c0 + 1):
		ans += count(c0, i)
	for i in range(2, c1 + 1):
		ans += count(c1, i)
print(ans)


def sol():
	(rows, cols) = map(int, input().split())
	tab = [list(map(int, input().split())) for _ in range(rows)]
	res = rows * cols
	for row in range(rows):
		white = 0
		black = 0
		for col in range(cols):
			if tab[row][col] == 0:
				white += 1
			else:
				black += 1
		if white > 0:
			res += pow(2, white) - white - 1
		if black > 0:
			res += pow(2, black) - black - 1
	for col in range(cols):
		white = 0
		black = 0
		for row in range(rows):
			if tab[row][col] == 0:
				white += 1
			else:
				black += 1
		if white > 0:
			res += pow(2, white) - white - 1
		if black > 0:
			res += pow(2, black) - black - 1
	print(res)
sol()


(numRows, numCols) = [int(i) for i in input().split()]
arr = []
total = 0
for _ in range(numRows):
	arr.append([int(i) for i in input().split()])
for row in range(numRows):
	numOnes = sum([arr[row][col] for col in range(numCols)])
	numZeroes = numCols - numOnes
	total += 2 ** numZeroes - 1 + (2 ** numOnes - 1)
for col in range(numCols):
	numOnes = sum([arr[row][col] for row in range(numRows)])
	numZeroes = numRows - numOnes
	total += 2 ** numZeroes - 1 + (2 ** numOnes - 1)
total -= numRows * numCols
print(total)


(n, m) = list(map(int, input().split()))
arr = [[0 for i in range(m)] for i in range(n)]
for i in range(n):
	arr[i] = list(map(int, input().split()))
ans = n * m
for i in range(n):
	c0 = 0
	c1 = 0
	for j in range(m):
		if arr[i][j] == 1:
			c1 += 1
		else:
			c0 += 1
	ans += max(0, 2 ** c1 - c1 - 1)
	ans += max(0, 2 ** c0 - c0 - 1)
for i in range(m):
	c0 = 0
	c1 = 0
	for j in range(n):
		if arr[j][i] == 1:
			c1 += 1
		else:
			c0 += 1
	ans += max(0, 2 ** c1 - c1 - 1)
	ans += max(0, 2 ** c0 - c0 - 1)
print(ans)


def main():
	(n, m) = (int(x) for x in input().split())
	grid = [None] * n
	for i in range(n):
		grid[i] = [int(x) for x in input().split()]
	print(solver(n, m, grid))

def solver(n, m, grid):
	rowOnes = [grid[i].count(1) for i in range(n)]
	gridT = [[grid[i][j] for i in range(n)] for j in range(m)]
	colOnes = [gridT[i].count(1) for i in range(m)]
	rowSets = sum([powerset2(rowOnes[i]) + powerset2(m - rowOnes[i]) for i in range(n)])
	colSets = sum([powerset2(colOnes[i]) + powerset2(n - colOnes[i]) for i in range(m)])
	total = n * m + rowSets + colSets
	return total

def powerset2(n):
	return 2 ** n - n - 1
main()


(n, m) = map(int, input().split())
grid = []
for i in range(n):
	k = list(map(int, input().split()))
	grid.append(k)
ans = 0
for i in range(n):
	count0 = 0
	count1 = 0
	for j in range(m):
		if grid[i][j] == 0:
			count0 += 1
		else:
			count1 += 1
	ans += 2 ** count0 - 1 + 2 ** count1 - 1
for i in range(m):
	count0 = 0
	count1 = 0
	for j in range(n):
		if grid[j][i] == 0:
			count0 += 1
		else:
			count1 += 1
	ans += 2 ** count0 - 1 + 2 ** count1 - 1
print(ans - n * m)


import math
(n, m) = map(int, input().strip().split())
col = [0] * m
lin = [0] * n
for i in range(n):
	v = list(map(int, input().strip().split()))
	for j in range(m):
		col[j] += v[j]
		lin[i] += v[j]
groups = n * m
for i in range(n):
	b = lin[i]
	w = m - b
	for j in range(2, b + 1):
		groups += int(math.factorial(b) / (math.factorial(j) * math.factorial(b - j)))
	for j in range(2, w + 1):
		groups += int(math.factorial(w) / (math.factorial(j) * math.factorial(w - j)))
for i in range(m):
	b = col[i]
	w = n - b
	for j in range(2, b + 1):
		groups += int(math.factorial(b) / (math.factorial(j) * math.factorial(b - j)))
	for j in range(2, w + 1):
		groups += int(math.factorial(w) / (math.factorial(j) * math.factorial(w - j)))
print(int(groups))


(n, m) = map(int, input().split())
(a, count) = ([[int(i) for i in input().split()] for _ in range(n)], 0)
for i in a:
	k = sum(i)
	count += 2 ** k + 2 ** (m - k) - 2
for i in range(m):
	k = len([1 for j in a if j[i]])
	count += 2 ** k + 2 ** (n - k) - n - 2
print(count)


(n, m) = [int(i) for i in input().split()]
row_one = [0 for i in range(n)]
column_one = [0 for i in range(m)]
for i in range(n):
	tmp = [int(j) for j in input().split()]
	row_one[i] = sum(tmp)
	for j in range(m):
		column_one[j] += tmp[j]
row_zero = [m - i for i in row_one]
column_zero = [n - i for i in column_one]
ans = 0
for i in row_zero:
	ans += 1 << i
for i in column_zero:
	ans += 1 << i
for i in row_one:
	ans += 1 << i
for i in column_one:
	ans += 1 << i
ans = ans - 2 * (m + n) - m * n
print(ans)


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append([int(x) for x in input().split()])
s = 0
for i in range(n):
	k = sum(a[i])
	s += (1 << k) - 2 + (1 << m - k)
for i in range(m):
	k = 0
	for j in range(n):
		k += a[j][i]
	s += (1 << k) - 2 + (1 << n - k)
s -= n * m
print(s)


import functools

@functools.lru_cache(maxsize=256, typed=False)
def C(n, k):
	res = 1
	for i in range(n):
		res *= i + 1
	for i in range(k):
		res //= i + 1
	for i in range(n - k):
		res //= i + 1
	return res
(n, m) = list(map(int, input().split()))
matrix = []
for i in range(n):
	matrix.append(list(map(int, input().split())))
ans = 0
for i in range(n):
	zero = 0
	for j in range(m):
		if matrix[i][j] == 0:
			zero += 1
	not_zero = m - zero
	zer = zero
	while zer > 1:
		ans += C(zero, zer)
		zer -= 1
	nzer = not_zero
	while nzer > 1:
		ans += C(not_zero, nzer)
		nzer -= 1
for i in range(m):
	zero = 0
	for j in range(n):
		if matrix[j][i] == 0:
			zero += 1
	not_zero = n - zero
	zer = zero
	while zer > 1:
		ans += C(zero, zer)
		zer -= 1
	nzer = not_zero
	while nzer > 1:
		ans += C(not_zero, nzer)
		nzer -= 1
print(ans + n * m)


(n, m) = map(int, input().split())
matrix = []
ans = 0
for _ in range(n):
	matrix.append(list(map(int, input().split())))
for i in range(n):
	ans += 2 ** matrix[i].count(1) + 2 ** matrix[i].count(0) - 2
for j in range(m):
	(white, black) = (0, 0)
	for i in range(n):
		if matrix[i][j] == 0:
			black += 1
		else:
			white += 1
	ans += 2 ** black + 2 ** white - 2 - n
print(ans)


import math

def choose(n, k):
	return math.factorial(n) / (math.factorial(k) * math.factorial(n - k))

class CodeforcesTask844BSolution:

	def __init__(self):
		self.result = ''
		self.n_m = []
		self.board = []

	def read_input(self):
		self.n_m = [int(x) for x in input().split(' ')]
		for x in range(self.n_m[0]):
			self.board.append([int(x) for x in input().split(' ')])

	def process_task(self):
		white_row_sums = [sum(row) for row in self.board]
		black_row_sums = [self.n_m[1] - row for row in white_row_sums]
		white_col_sums = [0] * self.n_m[1]
		for x in range(self.n_m[1]):
			for y in range(self.n_m[0]):
				white_col_sums[x] += self.board[y][x]
		black_col_sums = [self.n_m[0] - row for row in white_col_sums]
		subsets = white_row_sums + black_row_sums + white_col_sums + black_col_sums
		sub_cnt = 0
		for ss in subsets:
			sub_cnt += 2 ** ss - 1
		self.result = str(int(sub_cnt - self.n_m[0] * self.n_m[1]))

	def get_result(self):
		return self.result
Solution = CodeforcesTask844BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(n, m) = map(int, input().split())
(g, v) = ([list(map(int, input().split())) for i in range(n)], -n * m)
for si in map(sum, g):
	v += 2 ** si - 1 + 2 ** (m - si) - 1
for sj in (sum((g[i][j] for i in range(n))) for j in range(m)):
	v += 2 ** sj - 1 + 2 ** (n - sj) - 1
print(v)


import math
(n, m) = map(int, input().split())
rows = []
cols = []
for r in range(n):
	rows.append([int(z) for z in input().split()])
for i in range(m):
	c = []
	for r in range(n):
		c.append(rows[r][i])
	cols.append(c)
cnt = -1 * (n * m)
for i in rows:
	g = 2 ** i.count(0) - 1
	h = 2 ** i.count(1) - 1
	cnt += g + h
for i in cols:
	g = 2 ** i.count(0) - 1
	h = 2 ** i.count(1) - 1
	cnt += g + h
print(int(cnt))


def combs(n):
	return 2 ** n - 1

def main():
	(m, n) = map(int, input().split())
	matrix = [[0] * n for _ in range(m)]
	for i in range(m):
		lst = input().split()
		for (j, el) in enumerate(lst):
			matrix[i][j] = int(el)
	s = 0
	for i in matrix:
		ones = 0
		for j in i:
			if j == 1:
				ones += 1
		s += combs(ones) + combs(n - ones)
	for j in range(n):
		ones = 0
		for i in range(m):
			if matrix[i][j] == 1:
				ones += 1
		s += combs(ones) + combs(m - ones)
	s -= n * m
	print(s)
main()


(n, m) = list(map(int, input().split()))
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
sets = m * n
for i in range(n):
	ones = sum(a[i])
	zeros = m - ones
	sets += 2 ** ones - (ones + 1) + 2 ** zeros - (zeros + 1)
for i in range(m):
	ones = sum((a[j][i] for j in range(n)))
	zeros = n - ones
	sets += 2 ** ones - (ones + 1) + 2 ** zeros - (zeros + 1)
print(sets)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, m) = f()
l = []
sm = 0
for _ in range(n):
	l.append(il())
for i in range(n):
	sm += 2 ** l[i].count(0) + 2 ** l[i].count(1) - 2
for i in range(m):
	x = 0
	y = 0
	for j in range(n):
		x += l[j][i] == 1
		y += l[j][i] == 0
	sm += 2 ** x + 2 ** y - x - y - 2
print(sm)


def fac(k):
	res = 1
	for i in range(2, k + 1):
		res *= i
	return res

def calc(n, k):
	return fac(n) // (fac(n - k) * fac(k))
[n, m] = list(map(int, input().split()))
tb = []
for i in range(n):
	tb.append(list(map(int, input().split())))
res = 0
for i in range(n):
	a = 0
	for j in range(m):
		if tb[i][j] == 1:
			a += 1
	b = m - a
	for k in range(2, a + 1):
		res += calc(a, k)
	for k in range(2, b + 1):
		res += calc(b, k)
for j in range(m):
	a = 0
	for i in range(n):
		if tb[i][j] == 1:
			a += 1
	b = n - a
	for k in range(2, a + 1):
		res += calc(a, k)
	for k in range(2, b + 1):
		res += calc(b, k)
res += n * m
print(res)