#include <bits/stdc++.h>
using namespace std;
int col[600000], row[600000];
int main() {
  int i, s = 0, in, j, l, n, m, h, v;
  long long sum;
  bool sw = true;
  string str;
  cin >> n >> m;
  memset(col, 0, sizeof col);
  memset(row, 0, sizeof row);
  for (i = 0; i < n; i++) {
    cin >> str;
    for (j = 0; j < m; j++) {
      if (str[j] != '.') {
        h = (str[j] - '1') / 2;
        v = ((3 + str[j] - '1') % 4) / 2;
        v = v ? 1 : -1;
        h = h ? 1 : -1;
        if (i % 2) v = -v;
        if (j % 2) h = -h;
        if ((col[j] && col[j] != v) || (row[i] && row[i] != h)) sw = false;
        col[j] = v;
        row[i] = h;
      }
    }
  }
  long long res = sw ? 1 : 0;
  for (i = 0; i < n; i++) {
    if (row[i] == 0) res = (res * 2) % 1000003;
  }
  for (i = 0; i < m; i++) {
    if (col[i] == 0) res = (res * 2) % 1000003;
  }
  cout << res << endl;
  return 0;
}
