#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 1, 0, -1};
int dy[] = {0, 1, 0, -1, 0};
const int M = 500010;
vector<vector<int> > A, dir;
int row, col;
char str[M];
bool ok() {
  int i, j, k;
  for (i = 1; i <= row; i++)
    for (j = 1; j <= col; j++) dir[i][j] = -1;
  for (i = 1; i <= row; i++) {
    for (j = 1; j <= col; j++) {
      if (A[i][j] == 1 || A[i][j] == 2)
        dir[i][j] = 1;
      else if (A[i][j] == 3 || A[i][j] == 4)
        dir[i][j] = 0;
    }
  }
  for (i = 1; i <= row; i++) {
    int c = 0;
    for (j = 1; j <= col; j++)
      if (dir[i][j] != -1) {
        c = j;
        break;
      }
    if (c) {
      for (j = c + 1; j <= col; j++) {
        if (dir[i][j] == -1)
          dir[i][j] = dir[i][j - 1] ^ 1;
        else if (dir[i][j] == dir[i][j - 1])
          return 0;
      }
      for (j = c - 1; j >= 1; j--) {
        if (dir[i][j] == -1)
          dir[i][j] = dir[i][j + 1] ^ 1;
        else if (dir[i][j] == dir[i][j + 1])
          return 0;
      }
    }
  }
  for (i = 1; i <= row; i++)
    for (j = 1; j <= col; j++) dir[i][j] = -1;
  for (i = 1; i <= row; i++) {
    for (j = 1; j <= col; j++) {
      if (A[i][j] == 1 || A[i][j] == 4)
        dir[i][j] = 1;
      else if (A[i][j] == 2 || A[i][j] == 3)
        dir[i][j] = 0;
    }
  }
  for (j = 1; j <= col; j++) {
    int r = 0;
    for (i = 1; i <= row; i++)
      if (dir[i][j] != -1) {
        r = i;
        break;
      }
    if (r) {
      for (i = r + 1; i <= row; i++) {
        if (dir[i][j] == -1)
          dir[i][j] = dir[i - 1][j] ^ 1;
        else if (dir[i][j] == dir[i - 1][j])
          return 0;
      }
      for (i = r - 1; i >= 1; i--) {
        if (dir[i][j] == -1)
          dir[i][j] = dir[i + 1][j] ^ 1;
        else if (dir[i][j] == dir[i + 1][j])
          return 0;
      }
    }
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  int i, j, k;
  scanf("%d%d", &row, &col);
  A.resize(row + 2);
  dir.resize(row + 2);
  for (i = 0; i < row + 2; i++) A[i].resize(col + 2), dir[i].resize(col + 2);
  for (i = 1; i <= row; i++) {
    scanf("%s", str);
    for (j = 1; j <= col; j++) {
      if (str[j - 1] == '.')
        A[i][j] = 0;
      else
        A[i][j] = str[j - 1] - '0';
    }
  }
  if (!ok()) {
    printf("%s\n", "0");
    return 0;
  };
  int sum = 0;
  for (i = 1; i <= row; i++) {
    bool f = false;
    for (j = 1; j <= col; j++) {
      if (A[i][j]) f = true;
    }
    sum += (!f);
  }
  for (i = 1; i <= col; i++) {
    bool f = false;
    for (j = 1; j <= row; j++) {
      if (A[j][i]) f = true;
    }
    sum += (!f);
  }
  int ans = 1;
  while (sum--) {
    ans *= 2;
    ans %= 1000003;
  }
  printf("%d\n", ans);
  return 0;
}
