#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000003;
int n, m;
char g[500005], c;
int a[500005], b[500005];
int calc1(char c) {
  if (c == '1' || c == '4') return 0;
  return 1;
}
int calc2(char c) {
  if (c == '1' || c == '2') return 0;
  return 1;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%c", &c);
    for (int j = 0; j < m; j++) scanf("%c", &g[i * m + j]);
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (g[i * m + j] != '.') {
        int x = calc1(g[i * m + j]), y = calc2(g[i * m + j]);
        a[j] |= (1 << ((i & 1) ^ x));
        b[i * m] |= (1 << ((j & 1) ^ y));
      }
  int ans = 1;
  for (int i = 0; i < n; i++) {
    int t = 2;
    if (b[i * m] & 1) t--;
    if (b[i * m] & (1 << 1)) t--;
    ans = (ans * t) % MOD;
  }
  for (int i = 0; i < m; i++) {
    int t = 2;
    if (a[i] & 1) t--;
    if (a[i] & (1 << 1)) t--;
    ans = (ans * t) % MOD;
  }
  cout << ans << endl;
  return 0;
}
