#include <bits/stdc++.h>
using namespace std;
const int p[] = {1, 2, 2, 1};
const int q[] = {1, 1, 2, 2};
const int N = 500005;
int n, m;
int a[N], b[N];
long long ans;
void check(int& a, int b) {
  if (!a)
    a = b;
  else if (a != b)
    ans = 0;
}
int F(int a, int b) { return (b & 1) ? a : 3 - a; }
int main() {
  scanf("%d%d\n", &n, &m);
  ans = 1;
  char ch;
  int k;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      scanf("%c", &ch);
      if (ch == '.') continue;
      k = ch - '1';
      check(a[j], F(p[k], i));
      check(b[i], F(q[k], j));
    }
    scanf("\n");
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      (ans *= ((i == 1 && !a[j]) + 1) * ((j == 1 && !b[i]) + 1)) %= 1000003;
  printf("%I64d\n", ans);
  return 0;
}
