#include <bits/stdc++.h>
using namespace std;
const int p = 1000003;
int h[500001][2], v[500001][2];
char s[500005];
int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s + 1);
    for (int j = 1; j <= m; ++j) {
      if (s[j] == '.') continue;
      h[i][(j % 2) ^ (s[j] < '3')] = 1;
      v[j][(i % 2) ^ ((s[j] == '1') || (s[j] == '4'))] = 1;
    }
  }
  int ans = 1;
  for (int i = 1; i <= n; ++i) ans = (ans * (2 - h[i][0] - h[i][1])) % p;
  for (int i = 1; i <= m; ++i) ans = (ans * (2 - v[i][0] - v[i][1])) % p;
  printf("%d\n", ans);
  return 0;
}
