#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return {i, j};
}
struct printer {
  ~printer() { cerr << endl; }
  template <class c>
  printer& operator,(c x) {
    cerr << boolalpha << x;
    return *this;
  }
  printer& operator,(string x) {
    cerr << x;
    return *this;
  }
  template <class c, class d>
  printer& operator,(pair<c, d> x) {
    return *this, "(", x.first, ", ", x.second, ")";
  }
  template <class... d, template <class...> class c>
  printer& operator,(c<d...> x) {
    return *this, range(begin(x), end(x));
  }
  template <class c>
  printer& operator,(rge<c> x) {
    *this, "[";
    for (auto it = x.b; it != x.e; ++it) *this, (it == x.b ? "" : ", "), *it;
    return *this, "]";
  }
};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); }
const int N = 5e5 + 100;
const int mod = 1e6 + 3;
int solve(vector<int> v) {
  vector<int> opt[2];
  for (int i = 0; i < v.size(); i++) {
    opt[0].push_back(i & 1);
    opt[1].push_back((i & 1) ^ 1);
  }
  int ret = 0;
  for (int f = 0; f < 2; f++) {
    bool ok = true;
    for (int i = 0; i < v.size(); i++) {
      if (v[i] == 2) continue;
      if (v[i] != opt[f][i]) ok = false;
    }
    ret += ok;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<string> grid(n);
  for (int i = 0; i < n; i++) cin >> grid[i];
  int ans = 1;
  for (int i = 0; i < n; i++) {
    vector<int> v(m);
    for (int j = 0; j < m; j++) {
      if (grid[i][j] == '.')
        v[j] = 2;
      else if (grid[i][j] == '1' or grid[i][j] == '2')
        v[j] = 0;
      else
        v[j] = 1;
    }
    ans = ans * solve(v) % mod;
  }
  for (int j = 0; j < m; j++) {
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
      if (grid[i][j] == '.')
        v[i] = 2;
      else if (grid[i][j] == '1' or grid[i][j] == '4')
        v[i] = 0;
      else
        v[i] = 1;
    }
    ans = ans * solve(v) % mod;
  }
  cout << ans << endl;
}
