#include <bits/stdc++.h>
const bool vertical[4][4] = {
    {0, 1, 1, 0}, {1, 0, 0, 1}, {1, 0, 0, 1}, {0, 1, 1, 0}};
const bool horizontal[4][4] = {
    {0, 0, 1, 1}, {0, 0, 1, 1}, {1, 1, 0, 0}, {1, 1, 0, 0}};
const int maxn = 500000 + 5;
const int mod = 1000003;
bool row[maxn][4];
bool col[maxn][4];
int r[maxn][4], c[maxn][4];
char str[maxn];
int n, m, ans;
int main() {
  int i, j, k, first, pre, totr, totc;
  scanf("%d%d", &n, &m);
  for (k = 0; k < 4; k++) {
    for (i = 0; i < n; i++) row[i][k] = true;
    for (j = 0; j < m; j++) col[j][k] = true;
  }
  for (i = 0; i < n; i++) {
    scanf("%s", &str);
    for (j = 0; j < m; j++)
      if (str[j] != '.') {
        if (i == 0) {
          for (k = 0; k < 4; k++)
            if (k != str[j] - '1') col[j][k] = false;
        } else
          for (k = 0; k < 4; k++)
            if ((i & 1) ^ vertical[str[j] - '1'][k]) col[j][k] = false;
        if (j == 0) {
          for (k = 0; k < 4; k++)
            if (k != str[j] - '1') row[i][k] = false;
        } else
          for (k = 0; k < 4; k++)
            if ((j & 1) ^ horizontal[str[j] - '1'][k]) row[i][k] = false;
      }
  }
  ans = 0;
  for (first = 0; first < 4; first++)
    if (col[0][first] && row[0][first]) {
      for (k = 0; k < 4; k++)
        if (k != first)
          r[0][k] = c[0][k] = 0;
        else
          r[0][k] = c[0][k] = 1;
      if (n == 1)
        totr = 1;
      else
        totr = 0;
      for (i = 1; i < n; i++)
        for (k = 0; k < 4; k++)
          if (row[i][k]) {
            r[i][k] = 0;
            for (pre = 0; pre < 4; pre++)
              if (row[i - 1][pre] && vertical[pre][k])
                r[i][k] = (r[i][k] + r[i - 1][pre]) % mod;
            if (i == n - 1) totr = (totr + r[i][k]) % mod;
          }
      if (m == 1)
        totc = 1;
      else
        totc = 0;
      for (j = 1; j < m; j++)
        for (k = 0; k < 4; k++)
          if (col[j][k]) {
            c[j][k] = 0;
            for (pre = 0; pre < 4; pre++)
              if (col[j - 1][pre] && horizontal[pre][k])
                c[j][k] = (c[j][k] + c[j - 1][pre]) % mod;
            if (j == m - 1) totc = (totc + c[j][k]) % mod;
          }
      long long temp = totr * (long long)totc % mod;
      ans = (ans + temp) % mod;
    }
  printf("%d\n", ans);
  return 0;
}
