#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;
char field[1000000];
const long long mod = 1000003;
int n, m;
int h(int x, int y) { return y * m + x; }
bool bad1(int npos) {
  bool f1 = false;
  bool f2 = false;
  for (int i = 0; i < m; i++) {
    if (i % 2) {
      if (field[h(i, npos)] == '1' || field[h(i, npos)] == '2') f1 = true;
      if (field[h(i, npos)] == '3' || field[h(i, npos)] == '4') f2 = true;
    } else {
      if (field[h(i, npos)] == '1' || field[h(i, npos)] == '2') f2 = true;
      if (field[h(i, npos)] == '3' || field[h(i, npos)] == '4') f1 = true;
    }
  }
  return (f1 && f2);
}
bool bad2(int mpos) {
  bool f1 = false;
  bool f2 = false;
  for (int i = 0; i < n; i++) {
    if (i % 2) {
      if (field[h(mpos, i)] == '1' || field[h(mpos, i)] == '4') f1 = true;
      if (field[h(mpos, i)] == '2' || field[h(mpos, i)] == '3') f2 = true;
    } else {
      if (field[h(mpos, i)] == '1' || field[h(mpos, i)] == '4') f2 = true;
      if (field[h(mpos, i)] == '2' || field[h(mpos, i)] == '3') f1 = true;
    }
  }
  return (f1 && f2);
}
long long pow(long long n) {
  long long res = 1;
  for (int i = 0; i < n; i++) {
    res = (res * 2) % mod;
  }
  return res;
}
bool restn[500000];
bool restm[500000];
int main() {
  cin >> n >> m;
  memset(restn, true, sizeof(restn));
  memset(restm, true, sizeof(restm));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> field[h(j, i)];
      if (field[h(j, i)] != '.') {
        restn[i] = false;
        restm[j] = false;
      }
    }
  bool ng = false;
  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (restn[i]) cnt++;
  for (int i = 0; i < m; i++)
    if (restm[i]) cnt++;
  for (int i = 0; i < n; i++) {
    if (bad1(i)) ng = true;
  }
  for (int i = 0; i < m; i++) {
    if (bad2(i)) ng = true;
  }
  if (ng)
    cout << 0 << endl;
  else {
    cout << pow(cnt) << endl;
  }
  return 0;
}
