#include <bits/stdc++.h>
using namespace std;
const int Mod = 1000003;
bool check(const vector<vector<int> > &v, int n, int m) {
  for (int i = 0; i < n; ++i) {
    int x = -1, t;
    for (int j = 0; j < m; ++j) {
      t = v[i][j];
      if (x == -1 && t < 0) continue;
      if (x == -1) x = (t & 2);
      if (t >= 0 && (t & 2) != x) return false;
      x = 2 - x;
    }
  }
  for (int j = 0; j < m; ++j) {
    int x = -1, t;
    for (int i = 0; i < n; ++i) {
      t = v[i][j];
      if (x == -1 && t < 0) continue;
      if (x == -1) x = ((t & 1) ^ ((t >> 1) & 1));
      if (t >= 0 && ((t & 1) ^ ((t >> 1) & 1)) != x) return false;
      x = 1 - x;
    }
  }
  return true;
}
int main() {
  int n, m;
  vector<vector<int> > v;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    vector<int> tmp;
    for (int j = 0; j < m; ++j) {
      char c;
      scanf(" %c", &c);
      if ('1' <= c && c <= '4')
        tmp.push_back(c - '1');
      else
        tmp.push_back(-1);
    }
    v.push_back(tmp);
  }
  int ans = 0;
  if (check(v, n, m)) {
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      bool has = false;
      for (int j = 0; j < m; ++j) {
        if (v[i][j] >= 0) {
          has = true;
          break;
        }
      }
      if (!has) ++cnt;
    }
    for (int j = 0; j < m; ++j) {
      bool has = false;
      for (int i = 0; i < n; ++i) {
        if (v[i][j] >= 0) {
          has = true;
          break;
        }
      }
      if (!has) ++cnt;
    }
    ans = 1;
    while (cnt--) ans = ans * 2 % Mod;
  }
  printf("%d\n", ans);
  return 0;
}
