#include <bits/stdc++.h>
int n, m;
char s[5 << 17], h[5 << 17][2], v[5 << 17][2];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n && scanf("%s", s); ++i)
    for (int j = 0; j < m; ++j)
      if (s[j] != '.') {
        int x = s[j] - '1';
        v[i][(x < 2) ^ (j & 1)] = 1;
        h[j][(x > 0 && x < 3) ^ (i & 1)] = 1;
      }
  int w = 1;
  for (int i = 0; i < n; ++i) w = (w * (2 - v[i][0] - v[i][1])) % 1000003;
  for (int i = 0; i < m; ++i) w = (w * (2 - h[i][0] - h[i][1])) % 1000003;
  printf("%d\n", w);
}
