#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e6 + 3;
int n, m;
vector<vector<int> > mat;
int ans = 1;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  if (fopen("input.txt", "r")) freopen("input.txt", "r", stdin);
  cin >> n >> m;
  mat.resize(n, vector<int>(m));
  for (int i = 0, _i = (n); i < _i; ++i)
    for (int j = 0, _j = (m); j < _j; ++j) {
      char c;
      cin >> c;
      if (c == '.')
        mat[i][j] = 0;
      else
        mat[i][j] = c - '0';
    }
  for (int j = 0, _j = (m); j < _j; ++j) {
    int x = -1;
    for (int i = 0, _i = (n); i < _i; ++i)
      if (mat[i][j]) {
        int y = (mat[i][j] == 1 || mat[i][j] == 4) ^ (i & 1);
        if (x == -1)
          x = y;
        else if (x != y) {
          cout << 0;
          return 0;
        }
      }
    if (x == -1) ans = (ans * 2) % MOD;
  }
  for (int i = 0, _i = (n); i < _i; ++i) {
    int x = -1;
    for (int j = 0, _j = (m); j < _j; ++j)
      if (mat[i][j]) {
        int y = (mat[i][j] == 1 || mat[i][j] == 2) ^ (j & 1);
        if (x == -1)
          x = y;
        else if (x != y) {
          cout << 0;
          return 0;
        }
      }
    if (x == -1) ans = (ans * 2) % MOD;
  }
  cout << ans << '\n';
  return 0;
}
