#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const int mod = 1000003;
int n;
int m;
char w[500001];
int g[500001];
int main() {
  scanf("%d%d", &n, &m);
  gets(w);
  for (int i = 0; i < n; i++) {
    gets(w);
    for (int j = 0; j < m; j++)
      if (w[j] == '.')
        g[i * m + j] = -1;
      else
        g[i * m + j] = w[j] - '1';
  }
  int ans = 1;
  for (int i = 0; i < n; i++) {
    int ok1 = 1, ok2 = 1;
    for (int j = 0; j < m; j++)
      if (g[i * m + j] != -1)
        if (j & 1) {
          if (g[i * m + j] != 0 && g[i * m + j] != 1) ok2 = 0;
          if (g[i * m + j] != 2 && g[i * m + j] != 3) ok1 = 0;
        } else {
          if (g[i * m + j] != 0 && g[i * m + j] != 1) ok1 = 0;
          if (g[i * m + j] != 2 && g[i * m + j] != 3) ok2 = 0;
        }
    ans = (ans * (ok1 + ok2)) % mod;
  }
  for (int j = 0; j < m; j++) {
    int ok1 = 1, ok2 = 1;
    for (int i = 0; i < n; i++)
      if (g[i * m + j] != -1)
        if (i & 1) {
          if (g[i * m + j] != 1 && g[i * m + j] != 2) ok2 = 0;
          if (g[i * m + j] != 0 && g[i * m + j] != 3) ok1 = 0;
        } else {
          if (g[i * m + j] != 1 && g[i * m + j] != 2) ok1 = 0;
          if (g[i * m + j] != 0 && g[i * m + j] != 3) ok2 = 0;
        }
    ans = (ans * (ok1 + ok2)) % mod;
  }
  printf("%d\n", ans);
  return 0;
}
