#include <bits/stdc++.h>
using namespace std;
vector<string> vs;
int n, m;
int calc(int x, int n) {
  if (n == 1) return x % 1000003;
  if (n == 0) return 1;
  int t = calc(x, n / 2);
  t = 1ll * t * t % 1000003;
  if (n & 1) return (t * x) % 1000003;
  return t;
}
int check() {
  for (int i = 0; i < (vs.size()); ++i) {
    int st = -1;
    for (int j = 0; j < (vs[i].size()); ++j)
      if (vs[i][j] != '.') {
        st = j;
        break;
      }
    if (st == -1) continue;
    for (int j = 0; j < (vs[i].size()); ++j)
      if (j + st < vs[i].size()) {
        if (j % 2 == 0) {
          if ((vs[i][st] == '1' || vs[i][st] == '2') &&
              (vs[i][j + st] == '3' || vs[i][j + st] == '4'))
            return false;
          if ((vs[i][st] == '3' || vs[i][st] == '4') &&
              (vs[i][j + st] == '1' || vs[i][j + st] == '2'))
            return false;
        } else {
          if ((vs[i][st] == '1' || vs[i][st] == '2') &&
              (vs[i][j + st] == '1' || vs[i][j + st] == '2'))
            return false;
          if ((vs[i][st] == '3' || vs[i][st] == '4') &&
              (vs[i][j + st] == '3' || vs[i][j + st] == '4'))
            return false;
        }
      }
  }
  for (int i = 0; i < (vs[0].size()); ++i) {
    int st = -1;
    for (int j = 0; j < (vs.size()); ++j)
      if (vs[j][i] != '.') {
        st = j;
        break;
      }
    if (st == -1) continue;
    for (int j = 0; j < (vs.size()); ++j)
      if (j + st < vs.size()) {
        if (j % 2 == 0) {
          if ((vs[st][i] == '1' || vs[st][i] == '4') &&
              (vs[j + st][i] == '3' || vs[j + st][i] == '2'))
            return false;
          if ((vs[st][i] == '3' || vs[st][i] == '2') &&
              (vs[j + st][i] == '1' || vs[j + st][i] == '4'))
            return false;
        } else {
          if ((vs[st][i] == '1' || vs[st][i] == '4') &&
              (vs[j + st][i] == '1' || vs[j + st][i] == '4'))
            return false;
          if ((vs[st][i] == '3' || vs[st][i] == '2') &&
              (vs[j + st][i] == '3' || vs[j + st][i] == '2'))
            return false;
        }
      }
  }
  return true;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < (n); ++i) {
    string ln;
    cin >> ln;
    vs.push_back(ln);
  }
  if (check()) {
    int cnt = 0;
    for (int i = 0; i < (vs.size()); ++i) {
      int msk = 1;
      for (int j = 0; j < (vs[i].size()); ++j)
        if (vs[i][j] != '.') {
          msk = 0;
          break;
        }
      if (msk) cnt++;
    }
    for (int i = 0; i < (vs[0].size()); ++i) {
      int msk = 1;
      for (int j = 0; j < (vs.size()); ++j)
        if (vs[j][i] != '.') {
          msk = 0;
          break;
        }
      if (msk) cnt++;
    }
    cout << calc(2, cnt) << endl;
  } else
    cout << 0 << endl;
  return 0;
}
