#include <bits/stdc++.h>
long long int ver[5] = {-1, 0, 1, 1, 0};
long long int hor[5] = {-1, 0, 0, 1, 1};
char arr[500010];
long long int modu = 1000003;
long long int i, j, k, l, n, m, res, conf, p;
int cap(int a, int y) { return a * m + y; }
int main() {
  res = 1;
  scanf("%d%d", &n, &m);
  scanf("%*c");
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%c", &arr[cap(i, j)]);
    }
    scanf("%*c");
  }
  for (i = 0; i < n; i++) {
    conf = -1;
    p = 0;
    for (j = 0; j < m; j++) {
      if (arr[cap(i, j)] != '.') {
        p++;
        if (conf == -1) {
          conf = hor[arr[cap(i, j)] - '0'] ^ (j % 2);
        } else {
          if (hor[arr[cap(i, j)] - '0'] ^ (j % 2) != conf) res = 0;
        }
      }
    }
    if (p == 0) res = (res * 2) % modu;
  }
  for (i = 0; i < m; i++) {
    conf = -1;
    p = 0;
    for (j = 0; j < n; j++) {
      if (arr[cap(j, i)] != '.') {
        p++;
        if (conf == -1) {
          conf = ver[arr[cap(j, i)] - '0'] ^ (j % 2);
        } else {
          if (ver[arr[cap(j, i)] - '0'] ^ (j % 2) != conf) res = 0;
        }
      }
    }
    if (p == 0) res = (res * 2) % modu;
  }
  printf("%d", res);
}
