#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000003;
int Pot(int w) {
  int odp = 1;
  for (int i = 0; i < w; ++i) odp = (odp * 2) % MOD;
  return odp;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  bool db = true;
  for (int i = 0; i < n; ++i) {
    int p = -1;
    for (int j = 0; j < m; ++j) {
      if (a[i][j] != '.') {
        if (p == -1) {
          if (a[i][j] == '1' || a[i][j] == '2')
            p = j % 2;
          else
            p = (j + 1) % 2;
        } else {
          if ((a[i][j] == '1' || a[i][j] == '2') && p != j % 2) db = false;
          if ((a[i][j] == '3' || a[i][j] == '4') && (p + 1) % 2 != j % 2)
            db = false;
        }
      }
    }
  }
  for (int j = 0; j < m; ++j) {
    int p = -1;
    for (int i = 0; i < n; ++i) {
      if (a[i][j] != '.') {
        if (p == -1) {
          if (a[i][j] == '1' || a[i][j] == '4')
            p = i % 2;
          else
            p = (i + 1) % 2;
        } else {
          if ((a[i][j] == '1' || a[i][j] == '4') && p != i % 2) db = false;
          if ((a[i][j] == '2' || a[i][j] == '3') && (p + 1) % 2 != i % 2)
            db = false;
        }
      }
    }
  }
  if (!db) {
    cout << "0";
    return 0;
  }
  int w = 0;
  for (int i = 0; i < n; ++i) {
    int il = 0;
    for (int j = 0; j < m; ++j)
      if (a[i][j] == '.') ++il;
    if (il == m) ++w;
  }
  for (int j = 0; j < m; ++j) {
    int il = 0;
    for (int i = 0; i < n; ++i)
      if (a[i][j] == '.') ++il;
    if (il == n) ++w;
  }
  cout << Pot(w);
  return 0;
}
