#include <bits/stdc++.h>
using namespace std;
const int kMaxLength = 600000;
int open_le[500];
int open_up[500];
int main() {
  open_up[1] = open_up[4] = 1;
  open_up[2] = open_up[3] = 0;
  open_le[1] = open_le[2] = 1;
  open_le[3] = open_le[4] = 0;
  int row, col;
  cin >> row >> col;
  vector<int> openleft(row, 0);
  vector<int> openup(col, 0);
  for (int(i) = 0; (i) < (row); ++(i)) {
    string single_row;
    cin >> single_row;
    for (int(j) = 0; (j) < (col); ++(j)) {
      if (single_row[j] == '.') continue;
      int id = single_row[j] - '0';
      openleft[i] |= (1 << (open_le[id] ^ (j % 2)));
      openup[j] |= (1 << (open_up[id] ^ (i % 2)));
    }
  }
  long long ret = 1LL;
  long long modu = 1000003LL;
  for (int(i) = 0; (i) < (row); ++(i)) {
    if (openleft[i] == 3)
      ret = 0;
    else if (openleft[i] == 0)
      ret = (ret * 2LL) % modu;
  }
  for (int(i) = 0; (i) < (col); ++(i)) {
    if (openup[i] == 3)
      ret = 0;
    else if (openup[i] == 0)
      ret = (ret * 2LL) % modu;
  }
  cout << ret << endl;
  return 0;
}
