#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e6 + 3;
int forb[2][500010][2];
char buf[500010];
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", buf);
    for (int j = 1; j <= m; j++) {
      char c = buf[j - 1];
      if (c == '1') {
        forb[0][i][j & 1] = true;
        forb[1][j][i & 1] = true;
      } else if (c == '2') {
        forb[0][i][j & 1] = true;
        forb[1][j][i & 1 ^ 1] = true;
      } else if (c == '3') {
        forb[0][i][j & 1 ^ 1] = true;
        forb[1][j][i & 1 ^ 1] = true;
      } else if (c == '4') {
        forb[0][i][j & 1 ^ 1] = true;
        forb[1][j][i & 1] = true;
      }
    }
  }
  long long ans = 1;
  for (int i = 1; i <= n; i++) {
    long long cur = 0;
    for (int t = 0; t < 2; t++) cur += forb[0][i][t] ? 0 : 1;
    ans = (ans * cur) % MOD;
  }
  for (int j = 1; j <= m; j++) {
    long long cur = 0;
    for (int t = 0; t < 2; t++) cur += forb[1][j][t] ? 0 : 1;
    ans = (ans * cur) % MOD;
  }
  cout << ans << '\n';
  return 0;
}
