#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, sum = 0, count = 0, ans = 1;
  cin >> n >> m;
  char a[n + 2][m + 2];
  int h[n + 2][m + 2];
  int v[n + 2][m + 2];
  int row[n + 2], col[m + 2];
  for (int i = 0; i < n + 1; i++)
    for (int j = 0; j < m + 1; j++) {
      h[i][j] = -1;
      v[i][j] = -1;
    }
  for (int i = 0; i < n; i++) row[i] = 0;
  for (int j = 0; j < m; j++) col[j] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] != '.') row[i] = 1;
      if (a[i][j] != '.') col[j] = 1;
      if (a[i][j] == '1') {
        if (h[i][j] == -1) {
          for (int k = 0; k < n + 1; k++) {
            if ((k - i + 1000000) % 2 == 0) {
              h[k][j] = 1;
            } else {
              h[k][j] = 0;
            }
          }
        } else if (h[i][j] == 0)
          sum = 1;
        if (v[i][j] == -1) {
          for (int k = 0; k < m + 1; k++) {
            if ((k - j + 1000000) % 2 == 0)
              v[i][k] = 1;
            else
              v[i][k] = 0;
          }
        } else if (v[i][j] == 0)
          sum = 1;
      } else if (a[i][j] == '2') {
        if (h[i][j] == -1) {
          for (int k = 0; k < n + 1; k++) {
            if ((k - i + 1000000) % 2 == 0) {
              h[k][j] = 0;
            } else {
              h[k][j] = 1;
            }
          }
        } else if (h[i][j] == 1)
          sum = 1;
        if (v[i][j] == -1) {
          for (int k = 0; k < m + 1; k++) {
            if ((k - j + 1000000) % 2 == 0)
              v[i][k] = 1;
            else
              v[i][k] = 0;
          }
        } else if (v[i][j] == 0)
          sum = 1;
      } else if (a[i][j] == '3') {
        if (h[i][j] == -1) {
          for (int k = 0; k < n + 1; k++) {
            if ((k - i + 1000000) % 2 == 0) {
              h[k][j] = 0;
            } else {
              h[k][j] = 1;
            }
          }
        } else if (h[i][j] == 1)
          sum = 1;
        if (v[i][j] == -1) {
          for (int k = 0; k < m + 1; k++) {
            if ((k - j + 1000000) % 2 == 0)
              v[i][k] = 0;
            else
              v[i][k] = 1;
          }
        } else if (v[i][j] == 1)
          sum = 1;
      } else if (a[i][j] == '4') {
        if (h[i][j] == -1) {
          for (int k = 0; k < n + 1; k++) {
            if ((k - i + 1000000) % 2 == 0) {
              h[k][j] = 1;
            } else {
              h[k][j] = 0;
            }
          }
        } else if (h[i][j] == 0)
          sum = 1;
        if (v[i][j] == -1) {
          for (int k = 0; k < m + 1; k++) {
            if ((k - j + 1000000) % 2 == 0)
              v[i][k] = 0;
            else
              v[i][k] = 1;
          }
        } else if (v[i][j] == 1)
          sum = 1;
      }
    }
  for (int i = 0; i < n; i++)
    if (row[i] == 0) count++;
  for (int j = 0; j < m; j++)
    if (col[j] == 0) count++;
  for (int i = 0; i < count; i++) {
    ans = (ans * 2) % 1000003;
  }
  if (sum == 0)
    cout << ans;
  else
    cout << "0";
}
