#include <bits/stdc++.h>
using namespace std;
template <typename T, typename TT>
ostream &operator<<(ostream &s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream &operator<<(ostream &s, vector<T> t) {
  s << "{";
  for (int i = 0; i < t.size(); i++)
    s << t[i] << (i == t.size() - 1 ? "" : ",");
  return s << "}" << endl;
}
vector<string> s;
vector<string> v;
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  s.resize(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  long long wyn = 1;
  for (int i = 0; i < n; i++) {
    int ile = 0;
    for (int k = 0; k < 2; k++) {
      bool zle = 0;
      for (int j = 0; j < m; j++) {
        if (j % 2 == k % 2 && s[i][j] != '1' && s[i][j] != '2' &&
            s[i][j] != '.')
          zle = 1;
        else if (j % 2 != k % 2 && s[i][j] != '3' && s[i][j] != '4' &&
                 s[i][j] != '.')
          zle = 1;
      }
      ile += !zle;
    }
    wyn = (wyn * ile) % 1000003LL;
    ;
  }
  v.resize(m);
  for (int j = 0; j < m; j++)
    for (int i = 0; i < n; i++) v[j].push_back(s[i][j]);
  s = v;
  for (int i = 0; i < m; i++) {
    int ile = 0;
    for (int k = 0; k < 2; k++) {
      bool zle = 0;
      for (int j = 0; j < n; j++) {
        if (j % 2 != k % 2 && (s[i][j] == '1' || s[i][j] == '4'))
          zle = 1;
        else if (j % 2 == k % 2 && (s[i][j] == '2' || s[i][j] == '3'))
          zle = 1;
      }
      ile += !zle;
    }
    wyn = (wyn * ile) % 1000003LL;
    ;
  }
  cout << wyn;
  return 0;
}
