#include <bits/stdc++.h>
using namespace std;
const int _N = 500010;
const int MOD = 1000003;
int n, m, row[_N], col[_N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  memset(row, -1, sizeof(row));
  memset(col, -1, sizeof(col));
  bool flag = true;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      char k;
      cin >> k;
      int r, d;
      if (k == '1')
        r = 0, d = 0;
      else if (k == '2')
        r = 0, d = 1;
      else if (k == '3')
        r = 1, d = 1;
      else if (k == '4')
        r = 1, d = 0;
      if (k != '.') {
        r ^= (j & 1);
        if (row[i] == -1)
          row[i] = r;
        else if (row[i] != r)
          flag = false;
        d ^= (i & 1);
        if (col[j] == -1)
          col[j] = d;
        else if (col[j] != d)
          flag = false;
      }
    }
  if (!flag)
    cout << 0 << endl;
  else {
    int ans = 1;
    for (int i = 0; i < n; i++)
      if (row[i] == -1) ans = (ans * 2) % MOD;
    for (int j = 0; j < m; j++)
      if (col[j] == -1) ans = (ans * 2) % MOD;
    cout << ans << endl;
  }
  return 0;
}
