#include <bits/stdc++.h>
using namespace std;
char BUF[500010];
int n, m;
int up[500010], down[500010], L[500010], R[500010];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", &BUF);
    for (int j = 0; j < m; ++j) switch (BUF[j]) {
        case '1':
          if (j & 1)
            R[i] = 1;
          else
            L[i] = 1;
          if (i & 1)
            down[j] = 1;
          else
            up[j] = 1;
          break;
        case '2':
          if (j & 1)
            R[i] = 1;
          else
            L[i] = 1;
          if (i & 1)
            up[j] = 1;
          else
            down[j] = 1;
          break;
        case '3':
          if (j & 1)
            L[i] = 1;
          else
            R[i] = 1;
          if (i & 1)
            up[j] = 1;
          else
            down[j] = 1;
          break;
        case '4':
          if (j & 1)
            L[i] = 1;
          else
            R[i] = 1;
          if (i & 1)
            down[j] = 1;
          else
            up[j] = 1;
          break;
      }
  }
  int ans = 1;
  for (int i = 0; i < n; ++i) ans = (ans * (2 - L[i] - R[i])) % 1000003;
  for (int i = 0; i < m; ++i) ans = (ans * (2 - up[i] - down[i])) % 1000003;
  printf("%d\n", ans);
  return 0;
}
