#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10, B = 1e6 + 3;
int n, m, p1[N][2], p2[N][2], x, y;
long long ans = 1;
int main() {
  scanf("%d%d\n", &n, &m);
  char a[n + 3][m + 3];
  for (int i = 0; i < n; ++i) gets(a[i]);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j)
      if (a[i][j] != '.') {
        x = (a[i][j] < '2') || (a[i][j] > '3');
        y = i % 2;
        p1[j][x ^ y] = 1;
        x = a[i][j] < '3';
        y = j % 2;
        p2[i][x ^ y] = 1;
      }
  }
  for (int i = 0; i < m; ++i) ans = (ans * (2 - p1[i][0] - p1[i][1])) % B;
  for (int i = 0; i < n; ++i) ans = (ans * (2 - p2[i][0] - p2[i][1])) % B;
  printf("%lld\n", ans);
  return 0;
}
