#include <bits/stdc++.h>
using namespace std;
const int MAXN = -1, MOD = 1000003;
long long n, m;
vector<string> board;
long long Ans;
int main() {
  while (cin >> n >> m) {
    Ans = 1;
    board.resize(n);
    for (int i = (0); i < (int)(n); i++) cin >> board[i];
    for (int i = (0); i < (int)(n); i++) {
      bool e[2] = {1, 1};
      for (int j = (0); j < (int)(m); j++)
        if (board[i][j] != '.') {
          int t = board[i][j] - '1';
          e[(t / 2) xor (j % 2)] = false;
        }
      Ans = Ans * ((int)e[0] + (int)e[1]) % MOD;
    }
    for (int j = (0); j < (int)(m); j++) {
      bool e[2] = {1, 1};
      for (int i = (0); i < (int)(n); i++)
        if (board[i][j] != '.') {
          int t = board[i][j] - '1';
          e[(1 <= t && t <= 2) xor (i % 2)] = false;
        }
      Ans = Ans * ((int)e[0] + (int)e[1]) % MOD;
    }
    printf("%lld\n", Ans);
  }
  return 0;
}
