#include <bits/stdc++.h>
using namespace std;
const int mod = 1e6 + 3;
int main() {
  ios_base::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> field(h);
  for (int y = 0; y < h; ++y) {
    cin >> field[y];
  }
  bool bad = false;
  int cnt = 0;
  for (int y = 0; y < h; ++y) {
    int c = -1;
    for (int x = 0; x < w; ++x) {
      if (field[y][x] != '.') {
        int d = (field[y][x] - '0' + 1) / 2 % 2 ^ x % 2;
        if (c != -1 && c != d) {
          bad = true;
        }
        c = d;
      }
    }
    if (c == -1) {
      ++cnt;
    }
  }
  for (int x = 0; x < w; ++x) {
    int c = -1;
    for (int y = 0; y < h; ++y) {
      if (field[y][x] != '.') {
        int d = ((field[y][x] - '0' + 2) / 2 % 2) ^ (y % 2);
        if (c != -1 && c != d) {
          bad = true;
        }
        c = d;
      }
    }
    if (c == -1) {
      ++cnt;
    }
  }
  if (bad) {
    cout << 0;
    return 0;
  }
  long long ans = 1;
  for (int i = 0; i < cnt; ++i) {
    ans *= 2;
    ans %= mod;
  }
  cout << ans;
  return 0;
}
