#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int INF = 1001001001;
const ll mod = 1000003;
const ll INFL = 1001001001001001000;
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < (h); i++) cin >> s[i];
  int ans = 1;
  for (int i = 0; i < (h); i++) {
    int d = -1;
    for (int j = 0; j < (w); j++) {
      if (s[i][j] == '1' || s[i][j] == '2') {
        if (j % 2)
          d = 1;
        else
          d = 0;
        break;
      } else if (s[i][j] == '3' || s[i][j] == '4') {
        if (j % 2)
          d = 0;
        else
          d = 1;
        break;
      }
    }
    if (d == -1) {
      ans = ans * 2 % mod;
      continue;
    }
    int ok = 1;
    for (int j = 0; j < (w); j++) {
      if (s[i][j] == '1' || s[i][j] == '2') {
        if (j % 2) {
          if (d != 1) ok = 0;
        } else {
          if (d != 0) ok = 0;
        }
      } else if (s[i][j] == '3' || s[i][j] == '4') {
        if (j % 2) {
          if (d != 0) ok = 0;
        } else {
          if (d != 1) ok = 0;
        }
      }
    }
    if (!ok) ans = 0;
  }
  for (int j = 0; j < (w); j++) {
    int d = -1;
    for (int i = 0; i < (h); i++) {
      if (s[i][j] == '1' || s[i][j] == '4') {
        if (i % 2)
          d = 1;
        else
          d = 0;
        break;
      } else if (s[i][j] == '3' || s[i][j] == '2') {
        if (i % 2)
          d = 0;
        else
          d = 1;
        break;
      }
    }
    if (d == -1) {
      ans = ans * 2 % mod;
      continue;
    }
    int ok = 1;
    for (int i = 0; i < (h); i++) {
      if (s[i][j] == '1' || s[i][j] == '4') {
        if (i % 2) {
          if (d != 1) ok = 0;
        } else {
          if (d != 0) ok = 0;
        }
      } else if (s[i][j] == '3' || s[i][j] == '2') {
        if (i % 2) {
          if (d != 0) ok = 0;
        } else {
          if (d != 1) ok = 0;
        }
      }
    }
    if (!ok) ans = 0;
  }
  cout << ans << endl;
  return 0;
}
