#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
const int INF = 0x3F3F3F3F;
const int MOD = 1000003;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
vector<vector<char> > mat;
int n, m;
bool isvalid(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }
int main() {
  cin >> n >> m;
  mat.resize(n);
  for (int i = 0; i < n; i++) {
    mat[i].resize(m);
    for (int j = 0; j < m; j++) {
      cin >> mat[i][j];
    }
  }
  bool flag = 0;
  int num = 0;
  for (int i = 0; i < n; i++) {
    if (flag) break;
    bool l[2] = {0};
    for (int j = 0; j < m; j++) {
      if (mat[i][j] == '.') continue;
      if (mat[i][j] == '1' || mat[i][j] == '2') {
        l[j & 1] = 1;
      } else {
        l[(j + 1) & 1] = 1;
      }
    }
    if (l[0] && l[1]) flag = 1;
    if (!l[0] && !l[1]) num++;
  }
  for (int j = 0; j < m; j++) {
    if (flag) break;
    bool u[2] = {0};
    for (int i = 0; i < n; i++) {
      if (mat[i][j] == '.') continue;
      if (mat[i][j] == '1' || mat[i][j] == '4') {
        u[i & 1] = 1;
      } else {
        u[(i + 1) & 1] = 1;
      }
    }
    if (u[0] && u[1]) flag = 1;
    if (!u[0] && !u[1]) num++;
  }
  if (flag) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 1;
  for (int i = 0; i < num; i++) {
    ans = (ans * 2) % MOD;
  }
  cout << ans << endl;
}
