#include <bits/stdc++.h>
using namespace std;
const int BOTH = 0;
const int ODD = 1;
const int EVEN = 2;
const int IMPOSSIBLE = 3;
const int N_MAX = 500008;
const int P = 1000003;
int N, M;
int cols[N_MAX];
int rows[N_MAX];
int main() {
  cin >> N >> M;
  for (int i = 0; i < N_MAX; i++) cols[i] = rows[i] = BOTH;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      char c;
      cin >> c;
      if (c == '.') continue;
      switch (c) {
        case '1':
          cols[j] |= (i % 2 == 0 ? ODD : EVEN);
          rows[i] |= (j % 2 == 0 ? ODD : EVEN);
          break;
        case '2':
          cols[j] |= (i % 2 == 1 ? ODD : EVEN);
          rows[i] |= (j % 2 == 0 ? ODD : EVEN);
          break;
        case '3':
          cols[j] |= (i % 2 == 1 ? ODD : EVEN);
          rows[i] |= (j % 2 == 1 ? ODD : EVEN);
          break;
        case '4':
          cols[j] |= (i % 2 == 0 ? ODD : EVEN);
          rows[i] |= (j % 2 == 1 ? ODD : EVEN);
          break;
      }
    }
  }
  int ways = 1;
  for (int i = 0; i < N; i++) {
    if (rows[i] == BOTH)
      ways *= 2;
    else if (rows[i] == IMPOSSIBLE)
      ways = 0;
    ways %= P;
  }
  for (int i = 0; i < M; i++) {
    if (cols[i] == BOTH)
      ways *= 2;
    else if (cols[i] == IMPOSSIBLE)
      ways = 0;
    ways %= P;
  }
  cout << ways << '\n';
}
