#include <bits/stdc++.h>
using namespace std;
const int maxn = 5 * 1000 * 101;
const int mod = 1000 * 1000 + 3;
char row[maxn], col[maxn];
int n, m;
inline int pow(int base, int p) {
  if (p == 0) return 1;
  int tmp = pow(base, p / 2);
  if (p % 2 == 1) return ((long long)tmp * tmp * base) % mod;
  return ((long long)tmp * tmp) % mod;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char tmp;
      scanf(" %c", &tmp);
      if (tmp == '.') continue;
      char r = (tmp == '1' || tmp == '2') ? j % 2 : 1 - j % 2;
      r += '0';
      char c = (tmp == '1' || tmp == '4') ? i % 2 : 1 - i % 2;
      c += '0';
      if (row[i] != 0 && row[i] != r) {
        cout << 0 << endl;
        return 0;
      }
      if (col[j] != 0 && col[j] != c) {
        cout << 0 << endl;
        return 0;
      }
      row[i] = r;
      col[j] = c;
    }
  int emp = 0;
  for (int i = 1; i <= n; i++) emp += (row[i] == 0);
  for (int i = 1; i <= m; i++) emp += (col[i] == 0);
  printf("%d\n", pow(2, emp));
  return 0;
}
