#include <bits/stdc++.h>
const int N = 5e5, mo = 1e6 + 3;
int n, m, i, j, ans;
bool h[N][2], l[N][2];
char s[N];
int main() {
  scanf("%d%d", &n, &m);
  ans = 1;
  for (i = 0; i < n; i++)
    for (scanf("%s", s), j = 0; j < m; j++)
      if (s[j] != '.') {
        int x = s[j] - 48;
        h[i][(x <= 2) ^ (j & 1)] = 1;
        l[j][(x == 1 || x == 4) ^ (i & 1)] = 1;
      }
  for (i = 0; i < n; i++) ans = ans * (2 - h[i][0] - h[i][1]) % mo;
  for (j = 0; j < m; j++) ans = ans * (2 - l[j][0] - l[j][1]) % mo;
  printf("%d", ans);
}
