#include <bits/stdc++.h>
using namespace std;
bool dp[2][500001][2];
char str[500001];
const int mod = 1000003;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  char c;
  for (int i = 1; i <= n; i++) {
    scanf("%s", str);
    for (int j = 1; j <= m; j++)
      if ((c = str[j - 1]) != '.') {
        int l = 0, r = 0;
        if (c == '1' || c == '2') l = 1;
        if (c == '1' || c == '4') r = 1;
        dp[0][i][(l ^ j) & 1] = dp[1][j][(r ^ i) & 1] = true;
      }
  }
  int ans = 1;
  for (int i = 1; i <= n && ans; i++)
    ans *= 2 - dp[0][i][0] - dp[0][i][1], ans %= mod;
  for (int i = 1; i <= m && ans; i++)
    ans *= 2 - dp[1][i][0] - dp[1][i][1], ans %= mod;
  printf("%d\n", ans);
  return 0;
}
