#include <bits/stdc++.h>
using namespace std;
string field[500500];
bool canH[500500][2];
bool canV[500500][2];
const int MOD = 1000000 + 3;
int main() {
  int n, m;
  cin.sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> field[i];
  int ans = 1;
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < 2; k++) {
      canH[i][k] = true;
      for (int j = 0; j < m; j++) {
        if (field[i][j] == '.') continue;
        if (k ^ (j & 1) ^ (field[i][j] >= '3')) canH[i][k] = false;
      }
    }
    ans *= canH[i][0] + canH[i][1];
    while (ans >= MOD) ans -= MOD;
  }
  for (int j = 0; j < m; j++) {
    for (int k = 0; k < 2; k++) {
      canV[j][k] = true;
      for (int i = 0; i < n; i++) {
        if (field[i][j] == '.') continue;
        if (k ^ (i & 1) ^ (field[i][j] == '1' or field[i][j] == '4'))
          canV[j][k] = false;
      }
    }
    ans *= canV[j][0] + canV[j][1];
    while (ans >= MOD) ans -= MOD;
  }
  cout << ans << endl;
  return 0;
}
