#include <bits/stdc++.h>
using namespace std;
int p[5 * 100000 + 20], n, m, t2 = 0, mod = 1000003;
int pos(int x, int y) { return (y - 1) * m + x; }
int UR(int a) { return ((a == 1) || (a == 4)) ? 1 : -1; }
int LR(int a) { return ((a == 1) || (a == 2)) ? 1 : -1; }
int main() {
  char c;
  cin >> n >> m;
  for (int j = 1; j <= n; j++)
    for (int i = 1; i <= m; i++) {
      cin >> c;
      if (c != '.') p[pos(i, j)] = c - '0';
    }
  for (int i = 1; i <= m; i++) {
    int j = 1, f = 1;
    for (; j <= n; j++)
      if (p[pos(i, j)]) {
        f = 0;
        break;
      }
    if (f == 1)
      t2++;
    else {
      int z = UR(p[pos(i, j)]), t = 1;
      for (; j <= n; j++)
        if (p[pos(i, j)] && UR(p[pos(i, j)]) != z)
          t = 0;
        else
          z = -z;
      if (t == 0) {
        cout << "0" << endl;
        return 0;
      }
    }
  }
  for (int j = 1; j <= n; j++) {
    int i = 1, f = 1;
    for (; i <= m; i++)
      if (p[pos(i, j)]) {
        f = 0;
        break;
      }
    if (f == 1)
      t2++;
    else {
      int z = LR(p[pos(i, j)]), t = 1;
      for (; i <= m; i++)
        if (p[pos(i, j)] && LR(p[pos(i, j)]) != z)
          t = 0;
        else
          z = -z;
      if (t == 0) {
        cout << "0" << endl;
        return 0;
      }
    }
  }
  int ans = 1;
  for (int i = 0; i < t2; i++) ans = (ans * 2) % mod;
  cout << ans << endl;
  return 0;
}
