#include <bits/stdc++.h>
using namespace std;
const int N = 510000;
const int MOD = 1000003;
vector<string> mapa;
char txt[N];
int wystaje[N];
int niewystaje[N];
long long licz(vector<int> v) {
  int n = (int)v.size();
  wystaje[0] = niewystaje[0] = 1;
  for (int i = 0; i < (n); ++i) {
    wystaje[i + 1] = niewystaje[i + 1] = 0;
    if (v[i] >= 0) {
      wystaje[i + 1] = (wystaje[i + 1] + niewystaje[i]) % MOD;
    }
    if (v[i] <= 0) {
      niewystaje[i + 1] = (niewystaje[i + 1] + wystaje[i]) % MOD;
    }
  }
  return (wystaje[n] + niewystaje[n]) % MOD;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < (n); ++i) {
    scanf("%s", txt);
    mapa.push_back(string(txt));
  }
  int res = 1;
  for (int i = 0; i < (n); ++i) {
    vector<int> v;
    v.reserve(m);
    for (int j = 0; j < (m); ++j)
      if (mapa[i][j] == '.')
        v.push_back(0);
      else if (mapa[i][j] == '1' || mapa[i][j] == '2')
        v.push_back(-1);
      else
        v.push_back(1);
    res = (long long)res * licz(v) % MOD;
  }
  for (int j = 0; j < (m); ++j) {
    vector<int> v;
    v.reserve(n);
    for (int i = 0; i < (n); ++i)
      if (mapa[i][j] == '.')
        v.push_back(0);
      else if (mapa[i][j] == '1' || mapa[i][j] == '4')
        v.push_back(-1);
      else
        v.push_back(1);
    res = (long long)res * licz(v) % MOD;
  }
  printf("%d\n", res % MOD);
  return 0;
}
