#include <bits/stdc++.h>
using namespace std;
const int MaxN = 500050;
int g[MaxN];
char s[MaxN];
const int mod = 1000003;
int T1(int x) {
  if (x == 1 || x == 2) return 0;
  return 1;
}
int T2(int x) {
  if (x == 1 || x == 4) return 0;
  return 1;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    for (int j = 0; j < m; j++) g[i * m + j] = s[j] == '.' ? 0 : (s[j] - '0');
  }
  int ret = 1;
  for (int i = 0; i < n; i++) {
    int pos = -1;
    for (int j = 0; j < m; j++)
      if (g[i * m + j]) pos = j;
    if (pos == -1)
      ret = ret * 2 % mod;
    else {
      for (int j = 0; j < m; j++)
        if (g[i * m + j]) {
          if (T1(g[i * m + j]) == T1(g[i * m + pos]) && j % 2 != pos % 2)
            ret = 0;
          else if (T1(g[i * m + j]) != T1(g[i * m + pos]) && j % 2 == pos % 2)
            ret = 0;
        }
    }
  }
  for (int j = 0; j < m; j++) {
    int pos = -1;
    for (int i = 0; i < n; i++)
      if (g[i * m + j]) pos = i;
    if (pos == -1)
      ret = ret * 2 % mod;
    else {
      for (int i = 0; i < n; i++)
        if (g[i * m + j]) {
          if (T2(g[i * m + j]) == T2(g[pos * m + j]) && i % 2 != pos % 2)
            ret = 0;
          else if (T2(g[i * m + j]) != T2(g[pos * m + j]) && i % 2 == pos % 2)
            ret = 0;
        }
    }
  }
  printf("%d\n", ret);
  return 0;
}
