#include <bits/stdc++.h>
int r[500001], c[500001];
char x;
int n, m, i, j, sol = 1;
int main() {
  scanf("%d %d\n", &n, &m);
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      scanf("%c", &x);
      if (j & 1) {
        if (x == '1' || x == '2') {
          if (r[i] == 2) {
            printf("0\n");
            return 0;
          } else
            r[i] = 1;
        } else if (x == '3' || x == '4') {
          if (r[i] == 1) {
            printf("0\n");
            return 0;
          } else
            r[i] = 2;
        }
      } else {
        if (x == '1' || x == '2') {
          if (r[i] == 1) {
            printf("0\n");
            return 0;
          } else
            r[i] = 2;
        } else if (x == '3' || x == '4') {
          if (r[i] == 2) {
            printf("0\n");
            return 0;
          } else
            r[i] = 1;
        }
      }
      if (i & 1) {
        if (x == '1' || x == '4') {
          if (c[j] == 2) {
            printf("0\n");
            return 0;
          } else
            c[j] = 1;
        } else if (x == '2' || x == '3') {
          if (c[j] == 1) {
            printf("0\n");
            return 0;
          } else
            c[j] = 2;
        }
      } else {
        if (x == '1' || x == '4') {
          if (c[j] == 1) {
            printf("0\n");
            return 0;
          } else
            c[j] = 2;
        } else if (x == '2' || x == '3') {
          if (c[j] == 2) {
            printf("0\n");
            return 0;
          } else
            c[j] = 1;
        }
      }
    }
    scanf("\n");
  }
  for (i = 1; i <= n; ++i)
    if (!r[i]) sol = (sol * 2) % 1000003;
  for (i = 1; i <= m; ++i)
    if (!c[i]) sol = (sol * 2) % 1000003;
  printf("%d\n", sol);
  return 0;
}
