#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)(1e6 + 3);
string a[500009];
int col[500009], row[500009];
bool used[500009];
long long mod(long long a) { return (a % MOD + MOD) % MOD; }
void set_col(int ind, int value) {
  if (col[ind] && col[ind] != value) {
    printf("0");
    exit(0);
  }
  col[ind] = value;
}
void set_row(int ind, int value) {
  if (row[ind] && row[ind] != value) {
    printf("0");
    exit(0);
  }
  row[ind] = value;
}
int main() {
  int n, m, x = -1, y = -1;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '.') continue;
      int t = a[i][j] - '0';
      set_row(j, (t == 1 || t == 4) ^ (i % 2) ? -1 : 1);
      set_col(i, (t == 1 || t == 2) ^ (j % 2) ? -1 : 1);
    }
  }
  long long ans = 1;
  for (int i = 0; i < n; i++)
    if (!col[i]) ans = mod(ans * 2);
  for (int i = 0; i < m; i++)
    if (!row[i]) ans = mod(ans * 2);
  cout << ans;
  return 0;
}
