#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(
    (unsigned)chrono::system_clock::now().time_since_epoch().count());
const long long int mod = 1e6 + 3;
const long double PI = acosl(-1);
const int inf = 0x3f3f3f3f;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m;
  cin >> n >> m;
  vector<string> grid(n);
  for (int i = 0; i < n; i++) {
    cin >> grid[i];
  }
  vector<int> rows(n, -1);
  vector<int> cols(m, -1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (grid[i][j] == '.') continue;
      int v = grid[i][j] - '1';
      int r = (j % 2 == 1) ? (v / 2) ^ 1 : v / 2;
      int c = (i % 2 == 1) ? (v & 1) ^ (v >> 1) ^ 1 : (v & 1) ^ (v >> 1);
      if (rows[i] == -1)
        rows[i] = r;
      else if (rows[i] != r) {
        cout << 0 << endl;
        return 0;
      }
      if (cols[j] == -1)
        cols[j] = c;
      else if (cols[j] != c) {
        cout << 0 << endl;
        return 0;
      }
    }
  }
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) x += (rows[i] == -1);
  for (int i = 0; i < m; i++) y += (cols[i] == -1);
  long long int ans = 1;
  for (int i = 0; i < x; i++) ans = ans * 2 % mod;
  for (int i = 0; i < y; i++) ans = ans * 2 % mod;
  cout << ans << endl;
  return 0;
}
