#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10000000")
const long double LDINF = 9128739847123.00;
const long double eps = 1e-9;
const int inf = 1 << 28;
const long double pi = fabsl(atan2l(0.0, -1.0));
using namespace std;
int n, m;
char **a;
void load() {
  cin >> n >> m;
  a = new char *[n];
  for (int i = 0; i < n; i++) a[i] = new char[m + 2];
  {
    int c = 0;
    while ((c = getchar()) != 10 && c != EOF)
      ;
  };
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) a[i][j] = getchar();
    {
      int c = 0;
      while ((c = getchar()) != 10 && c != EOF)
        ;
    };
  }
}
const int mod = 1000003;
void die() {
  printf("0");
  exit(0);
}
inline int leftness(char c) {
  if (c == '1' || c == '2') return 0;
  if (c == '3' || c == '4') return 1;
  return -123123123;
}
inline int topness(char c) {
  if (c == '1' || c == '4') return 0;
  if (c == '3' || c == '2') return 1;
  return -123123123;
}
void solve() {
  int res = 1;
  for (int i = 0; i < n; i++) {
    int last = -1;
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '.') continue;
      if (a[i][j] >= '0') {
        if (last != -1 && abs(leftness(a[i][last]) - leftness(a[i][j])) !=
                              abs((last - j) % 2))
          die();
        last = j;
      }
    }
    if (last == -1) {
      res = (res * 2) % mod;
    }
  }
  for (int i = 0; i < m; i++) {
    int last = -1;
    for (int j = 0; j < n; j++) {
      if (a[j][i] == '.') continue;
      if (a[j][i] >= '0') {
        if (last != -1 &&
            abs(topness(a[last][i]) - topness(a[j][i])) != abs((last - j) % 2))
          die();
        last = j;
      }
    }
    if (last == -1) res = (res * 2) % mod;
  }
  cout << res;
}
int main() {
  load();
  solve();
  return 0;
}
