#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[500005];
vector<string> g;
int hor[500005], ver[500005];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    string str = s;
    g.push_back(str);
  }
  memset(hor, 0, sizeof(hor));
  memset(ver, 0, sizeof(ver));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (g[i][j] != '.') {
        if ((g[i][j] - '0' + 2) % 3 == 0)
          hor[j] |= 1 + i % 2;
        else
          hor[j] |= 2 - i % 2;
        if ((g[i][j] - '0' - 1) / 2 == 0)
          ver[i] |= 1 + j % 2;
        else
          ver[i] |= 2 - j % 2;
        if (hor[j] == 3 || ver[i] == 3) {
          printf("0\n");
          return 0;
        }
      }
  int cnt = 0, ret = 1;
  for (int i = 0; i < n; i++)
    if (ver[i] == 0) cnt++;
  for (int i = 0; i < m; i++)
    if (hor[i] == 0) cnt++;
  for (int i = 0; i < cnt; i++) {
    ret *= 2;
    ret %= 1000003;
  }
  printf("%d\n", ret);
}
