#include <bits/stdc++.h>
using namespace std;
int l[(600000)], r[(600000)];
vector<int> f[(600000)];
int m, n, ans;
char buf[(600000)];
const int mod = 1000003;
int main() {
  scanf("%d%d", &m, &n);
  for (int i = 0; i < m; ++i) {
    scanf("%s", buf);
    for (int j = 0; j < n; ++j) {
      char x = buf[j];
      if (x == '.')
        f[i].push_back(0);
      else
        f[i].push_back(x - '0');
    }
  }
  memset(l, -1, sizeof(l));
  memset(r, -1, sizeof(r));
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      int x = f[i][j];
      if (x == 0) continue;
      int k;
      if (x == 1 || x == 2)
        k = 1;
      else
        k = 0;
      if (j & 1) k ^= 1;
      if (l[i] != -1 && l[i] != k) {
        puts("0");
        return 0;
      }
      l[i] = k;
      if (x == 1 || x == 4)
        k = 1;
      else
        k = 0;
      if (i & 1) k ^= 1;
      if (r[j] != -1 && r[j] != k) {
        putchar('0');
        return 0;
      }
      r[j] = k;
    }
  }
  int cnt = m + n;
  for (int i = 0; i < m; ++i)
    if (l[i] != -1) cnt--;
  for (int j = 0; j < n; ++j)
    if (r[j] != -1) cnt--;
  ans = 1;
  for (int i = 0; i < cnt; ++i) {
    ans += ans;
    while (ans >= mod) ans -= mod;
  }
  printf("%d", ans);
  return 0;
}
