#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000003;
char s[500020];
int n, m, rez = 1, f[500020][2], g[500020][2];
int main() {
  int i, j;
  cin >> n >> m;
  for (i = 0; i < n; ++i) {
    cin >> s;
    for (j = 0; j < m; ++j)
      if (s[j] != '.')
        f[i][j & 1 ^ (s[j] == '1' || s[j] == '2')] =
            g[j][i & 1 ^ (s[j] == '1' || s[j] == '4')] = 1;
  }
  for (i = 0; i < n; ++i) rez = rez * (2 - f[i][0] - f[i][1]) % MOD;
  for (j = 0; j < m; ++j) rez = rez * (2 - g[j][0] - g[j][1]) % MOD;
  cout << rez;
  return 0;
}
