#include <bits/stdc++.h>
using namespace std;
bool f[2][500001][2];
int main() {
  long n, m;
  scanf("%ld%ld", &n, &m);
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= n; i++) {
    getchar();
    for (int j = 1; j <= m; j++) {
      char c;
      scanf("%c", &c);
      if (c == '.') continue;
      if (c == '1') f[0][i][1 ^ j % 2] = f[1][j][1 ^ i % 2] = 1;
      if (c == '2') f[0][i][1 ^ j % 2] = f[1][j][0 ^ i % 2] = 1;
      if (c == '3') f[0][i][0 ^ j % 2] = f[1][j][0 ^ i % 2] = 1;
      if (c == '4') f[0][i][0 ^ j % 2] = f[1][j][1 ^ i % 2] = 1;
    }
  }
  long s = 1;
  for (int i = 1; i <= n; i++) {
    if (f[0][i][0] && f[0][i][1]) {
      printf("0\n");
      return 0;
    }
    s *= 2 - f[0][i][0] - f[0][i][1];
    s %= 1000003;
  }
  for (int i = 1; i <= m; i++) {
    if (f[1][i][0] && f[1][i][1]) {
      printf("0\n");
      return 0;
    }
    s *= 2 - f[1][i][0] - f[1][i][1];
    s %= 1000003;
  }
  printf("%ld\n", s);
  return 0;
}
