#include <bits/stdc++.h>
using namespace std;
inline bool iseq(double x, double y) {
  if (fabs(x - y) < 1e-8) return true;
  return false;
}
template <typename T>
inline T Min(T a, T b) {
  return ((a) < (b) ? (a) : (b));
}
template <typename T>
inline T Max(T a, T b) {
  return ((a) > (b) ? (a) : (b));
}
template <typename T>
inline T hpt(T x1, T y1, T x2, T y2) {
  return hypot(x1 - x2, y1 - y2);
}
template <typename T>
inline T gcd(T a, T b) {
  if (!b)
    return a;
  else
    return gcd(b, a % b);
}
template <typename T>
inline void extended_euclid(T a, T b, T &x, T &y) {
  if (a % b == 0)
    x = 0, y = 1;
  else {
    extended_euclid(b, a % b, x, y);
    T temp = x;
    x = y;
    y = -y * (a / b) + temp;
  }
}
template <typename T>
inline T bigmod(T b, T p, T m) {
  if (!p)
    return 1;
  else if (!(p % 2)) {
    T x = bigmod(b, p / 2, m);
    return x * x;
  } else
    return ((b % m) * bigmod(b, p - 1, m)) % m;
}
int prime[5 / 32 + 1];
void setbit(int i) {
  int p = i >> 5, q = i & 31;
  prime[p] |= (1 << q);
}
bool checkbit(int i) {
  int p = i >> 5, q = i & 31;
  return prime[p] & (1 << q) ? true : false;
}
void buildprime(int n) {
  int i, j, k = sqrt(double(n));
  prime[0] = 3;
  for (i = 4; i < n; i += 2) setbit(i);
  for (i = 3; i <= k; i += 2) {
    if (!checkbit(i)) {
      int ii = i + i;
      for (j = i * i; j < n; j += ii) setbit(j);
    }
  }
}
int sum, r, n, N, R, C, t, txt, m;
string F[500050];
int B[500050];
long long mod = 1000003;
int Row(int x) {
  int tot = 0;
  for (int i = 0; i < (C + 1); i++) B[i] = 0;
  for (int i = 0; i < (C); i++) {
    if ('.' == F[x][i])
      tot++;
    else if ('1' == F[x][i] || '2' == F[x][i])
      B[i] = 1;
    else
      B[i + 1] = 1;
  }
  if (tot == C) return 2;
  int o = 0, e = 0;
  for (int i = 0; i < (C + 1); i++)
    if (B[i]) {
      if (i % 2)
        o++;
      else
        e++;
    }
  return !(o > 0 && e > 0);
  return 1;
}
int Col(int x) {
  int tot = 0;
  for (int i = 0; i < (R + 1); i++) B[i] = 0;
  for (int i = 0; i < (R); i++) {
    if ('.' == F[i][x])
      tot++;
    else if ('1' == F[i][x] || '4' == F[i][x])
      B[i] = 1;
    else
      B[i + 1] = 1;
  }
  if (tot == R) return 2;
  int o = 0, e = 0;
  for (int i = 0; i < (R + 1); i++)
    if (B[i]) {
      if (i % 2)
        o++;
      else
        e++;
    }
  return !(o > 0 && e > 0);
  return 1;
}
int main() {
  while (scanf("%d%d", &R, &C) == 2) {
    for (int i = 0; i < (R); i++) cin >> F[i];
    long long ans = 1;
    for (int i = 0; i < (R); i++) ans = (ans * Row(i)) % mod;
    for (int i = 0; i < (C); i++) ans = (ans * Col(i)) % mod;
    cout << ans << endl;
  }
  return 0;
}
