#include <bits/stdc++.h>
using namespace std;
char p[2000000];
long long kl[1000000], kr[1000000];
const long long MOD = 1000003ll;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", p + i * m);
  long long q, R = 1;
  for (int i = 0; i < n; i++) {
    if (m == 1) {
      if (p[m * (i) + (0)] == '.')
        q = 2;
      else
        q = 1;
    } else {
      if (p[m * (i) + (0)] == '1' || p[m * (i) + (0)] == '2') {
        kl[0] = 1;
        kr[0] = 0;
      } else if (p[m * (i) + (0)] == '3' || p[m * (i) + (0)] == '4') {
        kl[0] = 0;
        kr[0] = 1;
      } else
        kl[0] = kr[0] = 1;
      for (int j = 1; j < m; j++) {
        if (p[m * (i) + (j)] == '.') {
          kl[j] = kr[j - 1];
          kr[j] = kl[j - 1];
        } else if (p[m * (i) + (j)] == '1' || p[m * (i) + (j)] == '2') {
          kr[j] = 0;
          kl[j] = kr[j - 1];
        } else {
          kl[j] = 0;
          kr[j] = kl[j - 1];
        }
      }
      q = kl[m - 1] + kr[m - 1];
    }
    R = (R * q) % MOD;
  }
  for (int j = 0; j < m; j++) {
    if (n == 1) {
      if (p[m * (0) + (j)] == '.')
        q = 2;
      else
        q = 1;
    } else {
      if (p[m * (0) + (j)] == '1' || p[m * (0) + (j)] == '4') {
        kl[0] = 1;
        kr[0] = 0;
      } else if (p[m * (0) + (j)] == '2' || p[m * (0) + (j)] == '3') {
        kl[0] = 0;
        kr[0] = 1;
      } else
        kl[0] = kr[0] = 1;
      for (int i = 1; i < n; i++) {
        if (p[m * (i) + (j)] == '.') {
          kl[i] = kr[i - 1];
          kr[i] = kl[i - 1];
        } else if (p[m * (i) + (j)] == '1' || p[m * (i) + (j)] == '4') {
          kr[i] = 0;
          kl[i] = kr[i - 1];
        } else {
          kl[i] = 0;
          kr[i] = kl[i - 1];
        }
      }
      q = kl[n - 1] + kr[n - 1];
    }
    R = (R * q) % MOD;
  }
  printf("%d", (int)R);
  return 0;
}
