#include <bits/stdc++.h>
const int Mod = 1000003;
int n, m, fixed, prefix[500005], prerow[500005], fail;
char pipe;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    getchar();
    int curtp, pretp, precol = 0;
    for (int j = 1; j <= m; ++j) {
      pipe = getchar();
      if (!fail && pipe != '.') {
        curtp = (pipe - '0' - 1) >> 1;
        if (!precol) {
          pretp = curtp;
          precol = j;
          ++fixed;
        } else if (((j - precol) & 1) == (curtp ^ pretp)) {
          pretp = curtp;
          precol = j;
        } else
          fail = 1;
        curtp = (pipe - '0') >> 1 & 1;
        if (!prerow[j]) {
          prefix[j] = curtp;
          prerow[j] = i;
          ++fixed;
        } else if (((i - prerow[j]) & 1) == (curtp ^ prefix[j])) {
          prefix[j] = curtp;
          prerow[j] = i;
        } else
          fail = 1;
      }
    }
  }
  if (fail)
    puts("0");
  else {
    int power = n + m - fixed, methods = 1;
    while (power--) methods = methods * 2 % Mod;
    printf("%d\n", methods);
  }
  return 0;
}
