#include <bits/stdc++.h>
using namespace std;
char **ma;
int ty[2][4] = {{1, 1, 0, 0}, {1, 0, 0, 1}};
int pow_mod(long long a, int p, int mod) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = ret * a % mod;
    a = a * a % mod, p >>= 1;
  }
  return ret;
}
int main() {
  int n, m, cnt;
  while (scanf("%d%d", &n, &m) == 2) {
    cnt = 0;
    bool flag = 1;
    ma = new char *[n];
    for (int i = 0; i < n; ++i) {
      int pre = -1;
      bool tmp = 1;
      ma[i] = new char[m + 1];
      scanf("%s", ma[i]);
      for (int j = 0; j < m; ++j)
        if (ma[i][j] >= '0') {
          ma[i][j] -= '1';
          if (pre != -1)
            flag &= ((j - pre) & 1) == (ty[0][ma[i][j]] ^ ty[0][ma[i][pre]]);
          pre = j;
          tmp = 0;
        }
      if (tmp) ++cnt;
    }
    for (int i = 0; i < m && flag; ++i) {
      int pre = -1;
      bool tmp = 1;
      for (int j = 0; j < n; ++j)
        if (ma[j][i] <= 3) {
          if (pre != -1)
            flag &= ((j - pre) & 1) == (ty[1][ma[j][i]] ^ ty[1][ma[pre][i]]);
          pre = j;
          tmp = 0;
        }
      if (tmp) ++cnt;
    }
    printf("%d\n", flag ? pow_mod(2, cnt, 1000003) : 0);
    for (int i = 0; i < n; ++i) delete ma[i];
    delete ma;
  }
  return 0;
}
