#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000;
const int MAX = 1000000;
const int inf = 999999999;
const int p1 = 104393321, p2 = 104393329;
int row[MAX][2], c[MAX][2];
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = (0); i < int(n); ++i) {
    for (int j = (0); j < int(m); ++j) {
      char x;
      cin >> x;
      if (x == '.') continue;
      if (x == '1') {
        row[i][j % 2] = 1;
        c[j][i % 2] = 1;
      }
      if (x == '2') {
        row[i][j % 2] = 1;
        c[j][(i + 1) % 2] = 1;
      }
      if (x == '3') {
        row[i][(j + 1) % 2] = 1;
        c[j][(i + 1) % 2] = 1;
      }
      if (x == '4') {
        row[i][(j + 1) % 2] = 1;
        c[j][i % 2] = 1;
      }
    }
  }
  for (int i = (0); i < int(n); ++i)
    if (row[i][0] && row[i][1]) return cout << 0 << endl, 0;
  for (int j = (0); j < int(m); ++j)
    if (c[j][0] && c[j][1]) return cout << 0 << endl, 0;
  int mo = 1000000 + 3, ans = 1;
  for (int i = (0); i < int(n); ++i) {
    if (!row[i][0] && !row[i][1]) {
      ans *= 2;
      ans %= mo;
    }
  }
  for (int j = (0); j < int(m); ++j) {
    if (!c[j][0] && !c[j][1]) {
      ans *= 2;
      ans %= mo;
    }
  }
  cout << ans << endl;
  return 0;
}
