#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double EPS = 1e-9;
const int MOD = 1000003;
const int INF = 1000000000;
const long long LINF = 1000000000000000000LL;
vector<string> vs;
bool row[500010], col[500010];
int main() {
  int n, m, ret = 1;
  cin >> n >> m;
  string str;
  for (int i = int(0); i <= int(n - 1); i++) {
    cin >> str, vs.push_back(str);
    for (int j = int(0); j <= int(m - 1); j++)
      if (vs[i][j] != '.') row[i] = col[j] = true;
  }
  bool val = true, par;
  for (int i = int(0); i <= int(n - 1); i++) {
    if (!row[i])
      ret = 2 * ret % MOD;
    else {
      for (int j = int(0); j <= int(m - 1); j++)
        if (vs[i][j] != '.')
          par = (vs[i][j] < '3' && j % 2 == 0) || (vs[i][j] >= '3' && j % 2);
      for (int j = int(0); j <= int(m - 1); j++)
        if (vs[i][j] != '.') {
          if (j % 2)
            val &= par ? vs[i][j] >= '3' : vs[i][j] < '3';
          else
            val &= par ? vs[i][j] < '3' : vs[i][j] >= '3';
        }
    }
  }
  for (int j = int(0); j <= int(m - 1); j++) {
    if (!col[j])
      ret = 2 * ret % MOD;
    else {
      for (int i = int(0); i <= int(n - 1); i++)
        if (vs[i][j] != '.')
          par = ((vs[i][j] == '1' || vs[i][j] == '4') && i % 2 == 0) ||
                (!(vs[i][j] == '1' || vs[i][j] == '4') && i % 2);
      for (int i = int(0); i <= int(n - 1); i++)
        if (vs[i][j] != '.') {
          if (i % 2)
            val &= par ? !(vs[i][j] == '1' || vs[i][j] == '4')
                       : (vs[i][j] == '1' || vs[i][j] == '4');
          else
            val &= par ? (vs[i][j] == '1' || vs[i][j] == '4')
                       : !(vs[i][j] == '1' || vs[i][j] == '4');
        }
    }
  }
  if (!val) ret = 0;
  printf("%d\n", ret);
  return 0;
}
