#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10, P = 1e6 + 3;
int n, m;
string s[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> s[i];
  int ans = 1;
  for (int i = 0; i < n; ++i) {
    int tp = -1;
    for (int j = 0; j < m; ++j) {
      if ('1' <= s[i][j] && s[i][j] <= '2') {
        if (tp == -1)
          tp = j & 1;
        else if (tp != (j & 1))
          return puts("0"), 0;
      } else if ('3' <= s[i][j] && s[i][j] <= '4') {
        if (tp == -1)
          tp = ~j & 1;
        else if (tp != (~j & 1))
          return puts("0"), 0;
      }
    }
    if (tp == -1) ans = ans * 2 % P;
  }
  for (int i = 0; i < m; ++i) {
    int tp = -1;
    for (int j = 0; j < n; ++j) {
      if (s[j][i] == '1' || s[j][i] == '4') {
        if (tp == -1)
          tp = j & 1;
        else if (tp != (j & 1))
          return puts("0"), 0;
      } else if (s[j][i] == '2' || s[j][i] == '3') {
        if (tp == -1)
          tp = ~j & 1;
        else if (tp != (~j & 1))
          return puts("0"), 0;
      }
    }
    if (tp == -1) ans = ans * 2 % P;
  }
  printf("%d\n", ans);
}
