#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 10, Mod = 1e6 + 3;
string s[MAXN];
int main() {
  ios::sync_with_stdio(false);
  int n, m, ans = 1;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) {
    int odd = -1, even = -1;
    for (int j = 0; j < m; j++) {
      if (s[i][j] == '1' || s[i][j] == '2') {
        if ((j % 2 and odd == 2) or (j % 2 == 0 and even == 2)) {
          cout << 0 << endl;
          return 0;
        } else if (j % 2) {
          even = 2;
          odd = 1;
        } else {
          even = 1;
          odd = 2;
        }
      } else if (s[i][j] == '3' or s[i][j] == '4') {
        if ((j % 2 and odd == 1) or (j % 2 == 0 and even == 1)) {
          cout << 0 << endl;
          return 0;
        } else if (j % 2) {
          odd = 2;
          even = 1;
        } else {
          odd = 1;
          even = 2;
        }
      }
    }
    if (odd < 0 and even < 0) ans = (ans * 2) % Mod;
  }
  for (int j = 0; j < m; j++) {
    int odd = -1, even = -1;
    for (int i = 0; i < n; i++) {
      if (s[i][j] == '1' || s[i][j] == '4') {
        if ((i % 2 and odd == 2) or (i % 2 == 0 and even == 2)) {
          cout << 0 << endl;
          return 0;
        } else if (i % 2) {
          odd = 1;
          even = 2;
        } else {
          even = 1;
          odd = 2;
        }
      } else if (s[i][j] == '2' or s[i][j] == '3') {
        if ((i % 2 and odd == 1) or (i % 2 == 0 and even == 1)) {
          cout << 0 << endl;
          return 0;
        } else if (i % 2) {
          odd = 2;
          even = 1;
        } else {
          even = 2;
          odd = 1;
        }
      }
    }
    if (odd < 0 and even < 0) ans = (ans * 2) % Mod;
  }
  cout << ans << endl;
  return 0;
}
