#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
const int mod = 1000003;
vector<string> v;
int slove(int n, int m) {
  int ans = 1;
  for (int i = 0; i < n; i++) {
    int a = 0, b = 0;
    for (int j = 0; j < m; j++) {
      if (v[i][j] == '.') continue;
      int k = v[i][j] - '0', c = 0;
      if (k == 3 || k == 4) c = 1;
      if ((j & 1) ^ c)
        a = 1;
      else
        b = 1;
    }
    if (a & b) return 0;
    if (a == 0 && b == 0) ans = (ans << 1) % mod;
  }
  for (int j = 0; j < m; j++) {
    int a = 0, b = 0;
    for (int i = 0; i < n; i++) {
      if (v[i][j] == '.') continue;
      int k = v[i][j] - '0', c = 0;
      if (k == 1 || k == 4) c = 1;
      if ((i & 1) ^ c)
        a = 1;
      else
        b = 1;
    }
    if (a & b) return 0;
    if (a == 0 && b == 0) ans = (ans << 1) % mod;
  }
  return ans;
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    string s;
    v.clear();
    for (int i = 0; i < n; i++) {
      cin >> s;
      v.push_back(s);
    }
    cout << slove(n, m) << endl;
  }
  return 0;
}
