#include <bits/stdc++.h>
using namespace std;
char s[500010];
int n, m, ver[500010], hor[500010];
bool b;
void calc(int i, int j, int k) {
  if (!b) return;
  int x = (k < 3) ? 1 : 2;
  if (j % 2) x = 3 - x;
  if (hor[i] == 0)
    hor[i] = x;
  else if (hor[i] != x) {
    b = false;
    return;
  }
  x = (k == 1 || k == 4) ? 1 : 2;
  if (i % 2) x = 3 - x;
  if (ver[j] == 0)
    ver[j] = x;
  else if (ver[j] != x) {
    b = false;
    return;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  memset(ver, 0, sizeof(ver));
  memset(hor, 0, sizeof(hor));
  b = true;
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    for (int j = 0; j < m; j++)
      if (s[j] != '.') calc(i, j, s[j] - '0');
  }
  if (!b)
    printf("0\n");
  else {
    int ans = 1;
    for (int i = 0; i < n; i++)
      if (hor[i] == 0) ans = ans * 2 % 1000003;
    for (int i = 0; i < m; i++)
      if (ver[i] == 0) ans = ans * 2 % 1000003;
    printf("%d\n", ans);
  }
  return 0;
}
