#include <bits/stdc++.h>
using namespace std;
const int mod = 1E6 + 3;
const int size = 5E5 + 1;
char *str[size];
int main() {
  int n, m;
  cin >> n >> m;
  for (unsigned i = 0; i < n; i++) {
    str[i] = (char *)malloc(m + 1);
    cin >> str[i];
  }
  int res = 1;
  for (unsigned i = 0; i < n; i++) {
    int sign = 0;
    for (unsigned j = 0; j < m; j++) {
      int t = str[i][j];
      if (t == '.') continue;
      t -= '0';
      if (j % 2 == 0) {
        if (t == 1 || t == 2)
          sign |= 1;
        else
          sign |= 2;
      } else {
        if (t == 1 || t == 2)
          sign |= 2;
        else
          sign |= 1;
      }
    }
    if (sign == 3)
      res = 0;
    else if (sign == 0)
      res *= 2, res %= mod;
  }
  for (unsigned j = 0; j < m; j++) {
    int sign = 0;
    for (unsigned i = 0; i < n; i++) {
      int t = str[i][j];
      if (t == '.') continue;
      t -= '0';
      if (i % 2 == 0) {
        if (t == 1 || t == 4)
          sign |= 1;
        else
          sign |= 2;
      } else {
        if (t == 1 || t == 4)
          sign |= 2;
        else
          sign |= 1;
      }
    }
    if (sign == 3)
      res = 0;
    else if (sign == 0)
      res *= 2, res %= mod;
  }
  cout << res << endl;
  return 0;
}
