#include <bits/stdc++.h>
using namespace std;
const int P = 1000003;
void bad() {
  puts("0");
  exit(0);
}
int main() {
  int n, m;
  cin >> n >> m;
  string s[n];
  vector<vector<int> > a(n, vector<int>(m));
  vector<int> A(n, 1), B(m, 1);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    int was = -1;
    for (int j = 0; j < m; j++) {
      if (s[i][j] == '3' || s[i][j] == '4') a[i][j] |= 1;
      if (s[i][j] == '2' || s[i][j] == '3') a[i][j] |= 2;
      if (s[i][j] != '.') {
        if (was == -1)
          was = (j & 1) ^ ((a[i][j] >> 0) & 1);
        else if (was != (j & 1) ^ ((a[i][j] >> 0) & 1))
          bad();
        A[i] = B[j] = 0;
      }
    }
  }
  for (int j = 0; j < m; j++) {
    int was = -1;
    for (int i = 0; i < n; i++)
      if (s[i][j] != '.')
        if (was == -1)
          was = (i & 1) ^ ((a[i][j] >> 1) & 1);
        else if (was != (i & 1) ^ ((a[i][j] >> 1) & 1))
          bad();
  }
  int ans = 1;
  for (int i = 0; i < n; i++) ans = (ans << A[i]) % P;
  for (int j = 0; j < m; j++) ans = (ans << B[j]) % P;
  printf("%d\n", ans);
  return 0;
}
