#include <bits/stdc++.h>
using namespace std;
string s[500002];
int n, m;
const int mod = 1000003;
pair<bool, bool> checkRow(int r) {
  bool fl = false;
  bool fr = false;
  for (int i = 0; i < m; ++i)
    if (s[r][i] != '.')
      if (s[r][i] <= '2') {
        if (i % 2 == 0)
          fl = true;
        else
          fr = true;
      } else {
        if (i % 2 == 0)
          fr = true;
        else
          fl = true;
      }
  return make_pair(fl, fr);
}
pair<bool, bool> checkCol(int c) {
  bool fl = false;
  bool fr = false;
  for (int i = 0; i < n; ++i)
    if (s[i][c] != '.')
      if (s[i][c] == '1' || s[i][c] == '4') {
        if (i % 2 == 0)
          fl = true;
        else
          fr = true;
      } else {
        if (i % 2 == 0)
          fr = true;
        else
          fl = true;
      }
  return make_pair(fl, fr);
}
int res;
bool check(pair<bool, bool> t) {
  if (t.first && t.second) return false;
  if (t.first || t.second) res--;
  return true;
}
int main(int argc, char** argv) {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> s[i];
  res = n + m;
  for (int i = 0; i < n; ++i)
    if (!check(checkRow(i))) {
      cout << 0 << endl;
      return 0;
    }
  for (int i = 0; i < m; ++i)
    if (!check(checkCol(i))) {
      cout << 0 << endl;
      return 0;
    }
  int r = 1;
  for (int i = 0; i < res; ++i) {
    r += r;
    if (r >= mod) r -= mod;
  }
  cout << r << endl;
  return 0;
}
