#include <bits/stdc++.h>
const int N(500010), MOD(1000003);
int x[N], y[N];
char map[N];
int fail(int &a, int b) {
  if (a != -1 && a != b % 2) return 1;
  a = b % 2;
  return 0;
}
int answer() {
  int a, b, n, m, i, j;
  scanf("%d%d", &n, &m);
  memset(x, 255, sizeof(x));
  memset(y, 255, sizeof(y));
  for (i = 0; i != n; ++i) {
    scanf("%s", map);
    for (j = 0; j != m; ++j) {
      if (map[j] == '.') continue;
      if (map[j] == '1') {
        a = j;
        b = i;
      }
      if (map[j] == '2') {
        a = j;
        b = i + 1;
      }
      if (map[j] == '3') {
        a = j + 1;
        b = i + 1;
      }
      if (map[j] == '4') {
        a = j + 1;
        b = i;
      }
      if (fail(x[i], a)) return 0;
      if (fail(y[j], b)) return 0;
    }
  }
  int ret(1);
  for (i = 0; i != n; ++i)
    if (x[i] == -1) ret = (ret * 2) % MOD;
  for (i = 0; i != m; ++i)
    if (y[i] == -1) ret = (ret * 2) % MOD;
  return ret;
}
int main() {
  printf("%d\n", answer());
  return 0;
}
