#include <bits/stdc++.h>
using namespace std;
int solve() {
  int n, m;
  cin >> n >> m;
  vector<int> r(n, -1);
  vector<int> c(m, -1);
  vector<int> v_ud = {-1, 0, 1, 1, 0};
  vector<int> v_lr = {-1, 0, 0, 1, 1};
  char ch;
  int cnt = n + m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> ch;
      if (ch != '.') {
        ch = ch - '0';
        int lr = v_lr[ch] ^ (j & 1);
        int ud = v_ud[ch] ^ (i & 1);
        if (r[i] == -1) {
          r[i] = lr;
          --cnt;
        } else if (r[i] != lr)
          return 0;
        if (c[j] == -1) {
          c[j] = ud;
          --cnt;
        } else if (c[j] != ud)
          return 0;
      }
    }
  }
  int64_t ret = 1;
  for (int i = 0; i < cnt; ++i) {
    ret = ret * 2 % 1000003;
  }
  return ret;
}
int main() {
  cout << solve();
  cout << "\n";
}
