#include <bits/stdc++.h>
using namespace std;
void init() {}
void solve() {
  int n, m;
  scanf("%d %d\n", &n, &m);
  vector<string> a(n);
  for (int _n(n), i(0); i < _n; i++) getline(cin, a[i]);
  int MOD = 1000003;
  int res = 1;
  for (int _n(n), i(0); i < _n; i++) {
    int p = 0, q = 0;
    for (int _n(m), j(0); j < _n; j++) {
      char c = a[i][j];
      if (c == '.') continue;
      if (((j % 2 == 0 && (c == '1' || c == '2')) ||
           (j % 2 == 1 && (c == '3' || c == '4'))))
        p = 1;
      else
        q = 1;
    }
    if (p & q) {
      puts("0");
      return;
    } else if ((p | q) == 0)
      res = (res * 2) % MOD;
  }
  for (int _n(m), j(0); j < _n; j++) {
    int p = 0, q = 0;
    for (int _n(n), i(0); i < _n; i++) {
      char c = a[i][j];
      if (c == '.') continue;
      if (((i % 2 == 0 && (c == '1' || c == '4')) ||
           (i % 2 == 1 && (c == '2' || c == '3'))))
        p = 1;
      else
        q = 1;
    }
    if (p & q) {
      puts("0");
      return;
    } else if ((p | q) == 0)
      res = (res * 2) % MOD;
  }
  cout << res << endl;
}
int main() {
  init();
  solve();
  return 0;
}
