#include <bits/stdc++.h>
using namespace std;
const int inf(1010101010);
int h, w;
vector<string> a;
inline int hsgn(int i, int j) {
  int r;
  if (a[i][j] == '1') r = 0;
  if (a[i][j] == '2') r = 0;
  if (a[i][j] == '3') r = 1;
  if (a[i][j] == '4') r = 1;
  return (r + j) % 2;
}
inline int vsgn(int i, int j) {
  int r;
  if (a[i][j] == '1') r = 0;
  if (a[i][j] == '2') r = 1;
  if (a[i][j] == '3') r = 1;
  if (a[i][j] == '4') r = 0;
  return (r + i) % 2;
}
int main() {
  cin >> h >> w;
  a.resize(h);
  for (int i(0); i < (h); i++) cin >> a[i];
  bool wrong(false);
  int open_rows(0), open_cols(0);
  for (int i(0); i < (h); i++) {
    bool open(true);
    int sgn;
    for (int j(0); j < (w); j++) {
      if (a[i][j] != '.') {
        open = false;
        sgn = hsgn(i, j);
      }
    }
    if (open)
      open_rows++;
    else {
      for (int j(0); j < (w); j++)
        if (a[i][j] != '.') {
          if (hsgn(i, j) != sgn) wrong = true;
        }
    }
  }
  for (int j(0); j < (w); j++) {
    bool open(true);
    int sgn;
    for (int i(0); i < (h); i++) {
      if (a[i][j] != '.') {
        open = false;
        sgn = vsgn(i, j);
      }
    }
    if (open)
      open_cols++;
    else {
      for (int i(0); i < (h); i++)
        if (a[i][j] != '.') {
          if (vsgn(i, j) != sgn) wrong = true;
        }
    }
  }
  if (wrong)
    puts("0");
  else {
    int ans(1);
    for (int i(0); i < (open_rows + open_cols); i++) ans = (2 * ans) % 1000003;
    cout << ans << endl;
  }
}
