#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const double PI = 3.141592653589793;
const int mod = 1000003;
string mapa[500005], s;
char t[500005];
int n, m, i, j, d, res;
int main() {
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%s", &t);
    mapa[i] = t;
  }
  res = 1;
  for (i = 0; i < n; i++) {
    s = mapa[i];
    d = -1;
    for (j = 0; j < m; j++)
      if (s[j] != '.') {
        if (s[j] == '1' || s[j] == '2') {
          if (d == -1)
            d = j % 2;
          else if (d != -2 && d != j % 2)
            d = -2;
        } else if (s[j] == '3' || s[j] == '4') {
          if (d == -1)
            d = 1 - j % 2;
          else if (d != -2 && d == j % 2)
            d = -2;
        }
      }
    if (d == -1)
      res = (res * 2) % mod;
    else if (d == -2)
      res = 0;
  }
  for (i = 0; i < m; i++) {
    s = "";
    for (j = 0; j < n; j++) s += mapa[j][i];
    d = -1;
    for (j = 0; j < n; j++)
      if (s[j] != '.') {
        if (s[j] == '1' || s[j] == '4') {
          if (d == -1)
            d = j % 2;
          else if (d != -2 && d != j % 2)
            d = -2;
        } else if (s[j] == '2' || s[j] == '3') {
          if (d == -1)
            d = 1 - j % 2;
          else if (d != -2 && d == j % 2)
            d = -2;
        }
      }
    if (d == -1)
      res = (res * 2) % mod;
    else if (d == -2)
      res = 0;
  }
  printf("%d\n", res);
  return 0;
}
