#include <bits/stdc++.h>
using namespace std;
const bool TH[4] = {1, 1, 0, 0};
const bool TV[4] = {0, 1, 1, 0};
const int dx[] = {1, 1, 0, 0};
const int dy[] = {1, 0, 1, 0};
int h, w;
vector<vector<int> > mat;
bool okRow(int r) {
  int idx = -1;
  for (int i = 0; i < w; ++i)
    if (mat[r][i] != -1) {
      if (idx == -1)
        idx = i;
      else if (((i - idx) & 1) && (TH[mat[r][idx]] == TH[mat[r][i]]))
        return false;
      else if (!((i - idx) & 1) && (TH[mat[r][idx]] != TH[mat[r][i]]))
        return false;
    }
  return true;
}
bool okCol(int c) {
  int idx = -1;
  for (int i = 0; i < h; ++i)
    if (mat[i][c] != -1) {
      if (idx == -1)
        idx = i;
      else if (((i - idx) & 1) && (TV[mat[idx][c]] == TV[mat[i][c]]))
        return false;
      else if (!((i - idx) & 1) && (TV[mat[idx][c]] != TV[mat[i][c]]))
        return false;
    }
  return true;
}
void solve() {
  cin >> h >> w;
  mat.resize(h, vector<int>(w));
  for (int i = 0; i < h; ++i) {
    string cad;
    cin >> cad;
    for (int j = 0; j < w; ++j)
      mat[i][j] = (cad[j] == '.' ? -1 : cad[j] - (int)'1');
  }
  bool ok = true;
  for (int i = 0; i < h; ++i)
    if (!okRow(i)) ok = false;
  for (int i = 0; i < w; ++i)
    if (!okCol(i)) ok = false;
  if (!ok) {
    cout << "0\n";
    return;
  }
  int ans = 1;
  for (int i = 0; i < h; ++i) {
    bool free = true;
    for (int j = 0; j < w; ++j)
      if (mat[i][j] >= 0) free = false;
    if (free) ans = (ans * 2) % 1000003;
  }
  for (int j = 0; j < w; ++j) {
    bool free = true;
    for (int i = 0; i < h; ++i)
      if (mat[i][j] >= 0) free = false;
    if (free) ans = (ans * 2) % 1000003;
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
