#include <bits/stdc++.h>
using namespace std;
const int MAXL = 500050;
const int MOD = 1000003;
char buf[MAXL];
bool f[2][MAXL][2];
void solved(int nT) {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", buf);
    for (int j = 0; j < m; ++j) {
      if (buf[j] == '.') continue;
      f[0][j][i % 2 ^ (buf[j] == '1' || buf[j] == '4')] = true;
      f[1][i][j % 2 ^ (buf[j] <= '2')] = true;
    }
  }
  int result = 1;
  for (int i = 0; i < n; ++i) {
    result *= 2 - f[1][i][0] - f[1][i][1];
    result %= MOD;
  }
  for (int i = 0; i < m; ++i) {
    result *= 2 - f[0][i][0] - f[0][i][1];
    result %= MOD;
  }
  printf("%d\n", result);
}
int main() {
  int T = 1;
  for (int nT = 1; nT <= T; ++nT) {
    solved(nT);
  }
  return 0;
}
