#include <bits/stdc++.h>
using namespace std;
const int max_size = 5E5;
const int mod = 1E6 + 3;
char *str[max_size + 1];
int res = 1;
void cal(int n, int m, int type) {
  for (unsigned i = 0; i < n; i++) {
    int sign = 0;
    for (unsigned j = 0; j < m; j++) {
      int t;
      if (type == 0) {
        t = str[i][j] - '0';
        if (t + '0' == '.') goto ABC;
        if (j % 2 == 0) {
          if (t == 3 || t == 4)
            sign |= 1;
          else
            sign |= 2;
        } else {
          if (t == 3 || t == 4)
            sign |= 2;
          else
            sign |= 1;
        }
      } else {
        t = str[j][i] - '0';
        if (t + '0' == '.') goto ABC;
        if (j % 2 == 0) {
          if (t == 1 || t == 4)
            sign |= 1;
          else
            sign |= 2;
        } else {
          if (t == 3 || t == 2)
            sign |= 1;
          else
            sign |= 2;
        }
      }
    ABC:;
    }
    if (sign == 3)
      res = 0;
    else if (sign == 0) {
      res *= 2;
      res %= mod;
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (unsigned i = 0; i < n; i++) {
    char *temp = (char *)malloc(m + 1);
    scanf("%s", temp);
    str[i] = temp;
  }
  cal(n, m, 0);
  cal(m, n, 1);
  cout << res << endl;
  return 0;
}
