n,m = gets.split.map(&:to_i)
table = []
(1..n).each do |i|
  table.push(gets.split.map(&:to_i))
end
r = table.uniq.size
r -= 1 if table.include?(Array.new(m,0))

table = table.transpose
R = table.uniq.size
R -= 1 if table.include?(Array.new(n,0))
r = r < R ? r : R
puts ((2 ** (n + m - 1)) % 998244353 - (2 ** (n + m - r - 1)) % 998244353) % 998244353