#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 7, M = 1e6 + 3;
string s[N];
long long solve(string ss) {
  vector<bool> pos(2);
  for (int i = 0; i < ss.size(); i++) {
    if (ss[i] == '.') continue;
    pos[(ss[i] == 'L') ^ (i % 2)] = 1;
  }
  if (pos[0] && pos[1]) return 0;
  if (pos[0] || pos[1]) return 1;
  return 2;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> s[i];
  long long ans = 1;
  for (int i = 0; i < n; i++) {
    string ss;
    for (int j = 0; j < m; j++) {
      if (s[i][j] == '.')
        ss += '.';
      else if (s[i][j] == '1' || s[i][j] == '2')
        ss += 'L';
      else
        ss += 'R';
    }
    ans = (ans * solve(ss)) % M;
  }
  for (int j = 0; j < m; j++) {
    string ss;
    for (int i = 0; i < n; i++) {
      if (s[i][j] == '.')
        ss += '.';
      else if (s[i][j] == '1' || s[i][j] == '4')
        ss += 'L';
      else
        ss += 'R';
    }
    ans = (ans * solve(ss)) % M;
  }
  cout << ans << endl;
}
