#include <bits/stdc++.h>
using namespace std;
unsigned long long power_of_2(int e) {
  if (e == 0) {
    return 1;
  }
  if (e % 2 == 1) {
    return (2 * power_of_2(e - 1)) % 1000003;
  }
  unsigned long long tmp;
  tmp = power_of_2(e / 2);
  return (tmp * tmp) % 1000003;
}
int main() {
  int n, m;
  cin >> n;
  cin >> m;
  string s;
  vector<string> tab(n, s);
  vector<int> rows(n, 0);
  vector<int> cols(m, 0);
  char c;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> c;
      tab[i] += c;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (tab[i][j] != '.') {
        if (rows[i] == 0) {
          if (j % 2 == 0) {
            if (tab[i][j] > '2') {
              rows[i] = 1;
            } else {
              rows[i] = 2;
            }
          } else {
            if (tab[i][j] <= '2') {
              rows[i] = 1;
            } else {
              rows[i] = 2;
            }
          }
        } else if (rows[i] == 1 && (j % 2 == 0 && tab[i][j] <= '2' ||
                                    j % 2 == 1 && tab[i][j] > '2')) {
          cout << "0" << endl;
          return 0;
        } else if (rows[i] == 2 && (j % 2 == 0 && tab[i][j] > '2' ||
                                    j % 2 == 1 && tab[i][j] <= '2')) {
          cout << "0" << endl;
          return 0;
        }
        if (cols[j] == 0) {
          if (i % 2 == 0) {
            if (tab[i][j] == '1' || tab[i][j] == '4') {
              cols[j] = 1;
            } else {
              cols[j] = 2;
            }
          } else {
            if (tab[i][j] == '2' || tab[i][j] == '3') {
              cols[j] = 1;
            } else {
              cols[j] = 2;
            }
          }
        } else if (cols[j] == 1 &&
                   (i % 2 == 0 && (tab[i][j] == '2' || tab[i][j] == '3') ||
                    i % 2 == 1 && (tab[i][j] == '1' || tab[i][j] == '4'))) {
          cout << "0" << endl;
          return 0;
        } else if (cols[j] == 2 &&
                   (i % 2 == 1 && (tab[i][j] == '2' || tab[i][j] == '3') ||
                    i % 2 == 0 && (tab[i][j] == '1' || tab[i][j] == '4'))) {
          cout << "0" << endl;
          return 0;
        }
      }
    }
  }
  int result;
  int power = 0;
  for (int i = 0; i < n; i++) {
    if (rows[i] == 0) {
      power++;
    }
  }
  for (int i = 0; i < m; i++) {
    if (cols[i] == 0) {
      power++;
    }
  }
  result = power_of_2(power);
  cout << result << endl;
  return 0;
}
