#include <bits/stdc++.h>
using namespace std;
const int NUM_MAX = 600000;
int m, n;
int marked_col[NUM_MAX];
int marked_row[NUM_MAX];
bool impossible;
void process(int i, int j, char c) {
  if (c == '.') return;
  int x = c - '1';
  int row_val = (x < 2 ? 0 : 1);
  row_val = 1 + ((row_val + j) % 2);
  int col_val = (x % 3 == 0 ? 0 : 1);
  col_val = 1 + ((col_val + i) % 2);
  if ((marked_row[i] && marked_row[i] != row_val) ||
      (marked_col[j] && marked_col[j] != col_val)) {
    impossible = true;
  }
  marked_row[i] = row_val;
  marked_col[j] = col_val;
}
int main() {
  impossible = false;
  cin >> n >> m;
  char c;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> c;
      process(i, j, c);
    }
  }
  if (impossible) {
    cout << 0 << '\n';
    return 0;
  }
  int num = 1, p = 1000003;
  for (int i = 0; i < n; i++) {
    if (!marked_row[i]) {
      num *= 2;
      num %= p;
    }
  }
  for (int i = 0; i < m; i++) {
    if (!marked_col[i]) {
      num *= 2;
      num %= p;
    }
  }
  cout << num << '\n';
  return 0;
}
