#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  char st[N][M + 1];
  int col[M], row[N];
  int val[M][2], valr[N][2];
  bool con = true;
  for (int i = 0; i < M; i++) {
    col[i] = -1;
    val[i][0] = -1;
    val[i][1] = -1;
  }
  for (int i = 0; i < N; i++) {
    row[i] = -1;
    valr[i][0] = -1;
    valr[i][1] = -1;
  }
  int pl[N];
  for (int i = 0; i < N; i++) {
    pl[i] = 0;
    scanf("%s", st[i]);
    for (int j = 0; j < M; j++) {
      if (st[i][j] != '.') {
        pl[i]++;
        col[j] = 1;
        row[i] = 1;
        if (st[i][j] == '1' || st[i][j] == '4') {
          if (val[j][i % 2] == 1)
            con = false;
          else {
            val[j][i % 2] = 0;
            val[j][(i + 1) % 2] = 1;
          }
        } else {
          if (val[j][i % 2] == 0)
            con = false;
          else {
            val[j][i % 2] = 1;
            val[j][(i + 1) % 2] = 0;
          }
        }
        if (st[i][j] == '1' || st[i][j] == '2') {
          if (valr[i][j % 2] == 1)
            con = false;
          else {
            valr[i][j % 2] = 0;
            valr[i][(j + 1) % 2] = 1;
          }
        } else {
          if (valr[i][j % 2] == 0)
            con = false;
          else {
            valr[i][j % 2] = 1;
            valr[i][(j + 1) % 2] = 0;
          }
        }
      }
    }
  }
  for (int i = 0; i < N && con; i++) {
    for (int j = 0; j < M && con; j++) {
      if (st[i][j] != '.') {
        switch (st[i][j]) {
          case '1':
            if (!((i == 0 || (st[i - 1][j] == '.' || st[i - 1][j] == '2' ||
                              st[i - 1][j] == '3')) &&
                  (j == 0 || (st[i][j - 1] == '.' || st[i][j - 1] == '3' ||
                              st[i][j - 1] == '4'))))
              con = false;
            break;
          case '2':
            if (!((i == N - 1 || (st[i + 1][j] == '.' || st[i + 1][j] == '1' ||
                                  st[i + 1][j] == '4')) &&
                  (j == 0 || (st[i][j - 1] == '.' || st[i][j - 1] == '3' ||
                              st[i][j - 1] == '4'))))
              con = false;
            break;
          case '3':
            if (!((i == N - 1 || (st[i + 1][j] == '.' || st[i + 1][j] == '1' ||
                                  st[i + 1][j] == '4')) &&
                  (j == M - 1 || (st[i][j + 1] == '.' || st[i][j + 1] == '1' ||
                                  st[i][j + 1] == '2'))))
              con = false;
            break;
          case '4':
            if (!((i == 0 || (st[i - 1][j] == '.' || st[i - 1][j] == '2' ||
                              st[i - 1][j] == '3')) &&
                  (j == M - 1 || (st[i][j + 1] == '.' || st[i][j + 1] == '1' ||
                                  st[i][j + 1] == '2'))))
              con = false;
            break;
        }
      }
    }
  }
  if (!con) {
    cout << "0" << endl;
    return 0;
  }
  long long ans = 1;
  int counter = 0;
  int m = 1000003;
  for (int i = 0; i < M; i++)
    if (col[i] == -1) counter++;
  for (int i = 0; i < N; i++)
    if (row[i] == -1) counter++;
  for (int i = 0; i < counter; i++) ans = (ans * 2) % m;
  cout << ans << endl;
  return 0;
}
