#include <bits/stdc++.h>
const int pi = acos(-1.);
using namespace std;
int r[500010], c[500010];
int ans = 1, n, m;
int mod = 1000003;
void calc() {
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    if (r[i] & 1) cnt++;
    if (r[i] & 2) cnt++;
    r[i] = cnt;
  }
  for (int i = 1; i <= m; i++) {
    int cnt = 0;
    if (c[i] & 1) cnt++;
    if (c[i] & 2) cnt++;
    c[i] = cnt;
  }
}
int f(int a, int b) {
  if (b % 2)
    return a;
  else
    return 3 - a;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) r[i] = 3;
  for (int i = 1; i <= m; i++) c[i] = 3;
  for (int i = 1; i <= n; i++) {
    string xx;
    cin >> xx;
    for (int j = 1; j <= m; j++)
      if (xx[j - 1] != '.') {
        if (xx[j - 1] == '1') {
          r[i] -= (r[i] & f(1, j));
          c[j] -= (c[j] & f(1, i));
        } else if (xx[j - 1] == '2') {
          r[i] -= (r[i] & f(1, j));
          c[j] -= (c[j] & f(2, i));
        } else if (xx[j - 1] == '3') {
          r[i] -= (r[i] & f(2, j));
          c[j] -= (c[j] & f(2, i));
        } else {
          r[i] -= (r[i] & f(2, j));
          c[j] -= (c[j] & f(1, i));
        }
      }
  }
  calc();
  for (int i = 1; i <= n; i++) ans = (ans * r[i]) % mod;
  for (int i = 1; i <= m; i++) ans = (ans * c[i]) % mod;
  cout << ans << endl;
  return 0;
}
