#include <bits/stdc++.h>
using namespace std;
int cmpN[500009];
int cmpM[500009];
vector<string> T;
int n, m;
bool puede(int id, bool tmp) {
  for (int j = 0; j < m; j++) {
    if (T[id][j] == '.') {
      tmp = !tmp;
      continue;
    }
    if (!tmp) {
      if (T[id][j] == '1' || T[id][j] == '2')
        ;
      else
        return false;
    } else {
      if (T[id][j] == '3' || T[id][j] == '4')
        ;
      else
        return false;
    }
    tmp = !tmp;
  }
  return true;
}
bool puede1(int id, bool tmp) {
  for (int i = 0; i < n; i++) {
    if (T[i][id] == '.') {
      tmp = !tmp;
      continue;
    }
    if (!tmp) {
      if (T[i][id] == '1' || T[i][id] == '4')
        ;
      else
        return false;
    } else {
      if (T[i][id] == '3' || T[i][id] == '2')
        ;
      else
        return false;
    }
    tmp = !tmp;
  }
  return true;
}
int main() {
  cin >> n >> m;
  string cad;
  for (int i = 0; i < n; i++) {
    cin >> cad;
    T.push_back(cad);
  }
  int cont = 0;
  for (int i = 0; i < n; i++) {
    cmpN[i] += puede(i, 0);
    cmpN[i] += puede(i, 1);
    if (cmpN[i] == 0) {
      cout << 0 << endl;
      return 0;
    } else if (cmpN[i] == 2)
      cont++;
  }
  for (int i = 0; i < m; i++) {
    cmpM[i] += puede1(i, 0);
    cmpM[i] += puede1(i, 1);
    if (cmpM[i] == 0) {
      cout << 0 << endl;
      return 0;
    } else if (cmpM[i] == 2)
      cont++;
  }
  long long ans = 1;
  for (int i = 0; i < cont; i++) ans = (ans << 1), ans %= 1000003;
  cout << ans << endl;
  return 0;
}
