n,m = gets.split.map(&:to_i)
table = []
(1..n).each do |i|
  table.push(gets.split.map(&:to_i))
end

count = 0
 (0..(n - 1)).each do |x|
   judge = false
   (0..(m - 1)).each do |y|
     if table[x][y] == 1
       judge = true
       break
     end
   end
  count += 1 if judge == false
end
puts count
puts ((2 ** n - 2 ** count) * (2 ** (m - 1))) % 998244353