#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
const long long mod = 1e6 + 3;
int dx[5] = {0, 0, 0, 1, 1};
int dy[5] = {0, 0, 1, 1, 0};
string s[N];
long long pow_q(long long a, long long b) {
  long long tmp = 1;
  while (b > 0) {
    if (b & 1) {
      tmp *= a;
      tmp %= mod;
    }
    a *= a;
    a %= mod;
    b >>= 1;
  }
  return tmp;
}
int main() {
  int n, m, i, cnt = 0, j;
  int flag = 1;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) cin >> s[i];
  for (i = 0; i < n; i++) {
    int now = -1;
    for (j = 0; j < m; j++) {
      if (s[i][j] >= '1' && s[i][j] <= '4') {
        if (now == -1)
          now = dx[s[i][j] - '0'];
        else {
          if (now != dx[s[i][j] - '0']) flag = 0;
        }
      }
      if (now != -1) now = 1 - now;
    }
    if (now == -1) cnt++;
  }
  for (j = 0; j < m; j++) {
    int now = -1;
    for (i = 0; i < n; i++) {
      if (s[i][j] >= '1' && s[i][j] <= '4') {
        if (now == -1)
          now = dy[s[i][j] - '0'];
        else {
          if (now != dy[s[i][j] - '0']) flag = 0;
        }
      }
      if (now != -1) now = 1 - now;
    }
    if (now == -1) cnt++;
  }
  if (!flag)
    printf("0\n");
  else {
    printf("%lld\n", pow_q(2, cnt));
  }
  return 0;
}
