#include <bits/stdc++.h>
bool f[500010][2][2];
char str[500010];
int main() {
  int n, m;
  memset(f, 0x00, sizeof(f));
  scanf("%d%d", &n, &m);
  getchar();
  for (int i = 0; i < n; i++) {
    gets(str);
    for (int j = 0; j < m; j++) {
      switch (str[j]) {
        case '1':
          f[i][0][j & 1 ^ 1] = f[j][1][i & 1 ^ 1] = true;
          break;
        case '2':
          f[i][0][j & 1 ^ 1] = f[j][1][i & 1 ^ 0] = true;
          break;
        case '3':
          f[i][0][j & 1 ^ 0] = f[j][1][i & 1 ^ 0] = true;
          break;
        case '4':
          f[i][0][j & 1 ^ 0] = f[j][1][i & 1 ^ 1] = true;
          break;
      }
    }
  }
  long long ans = 1;
  for (int i = 0; i < n; i++) {
    ans *= 2 - f[i][0][0] - f[i][0][1];
    ans %= 1000003;
  }
  for (int i = 0; i < m; i++) {
    ans *= 2 - f[i][1][0] - f[i][1][1];
    ans %= 1000003;
  }
  printf(
      "%lld"
      "\n",
      ans);
  return 0;
}
