#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
long long min(long long a, long long b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}
int r[600001], c[600001];
int res = 0;
int n, m;
long long ret = 1;
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 x;
    cin >> x;
    for (int j = (1); j <= (m); j++)
      if (x[j - 1] != '.') {
        if (x[j - 1] == '1') {
          r[i] -= (r[i] & f(1, j));
          c[j] -= (c[j] & f(1, i));
        } else if (x[j - 1] == '2') {
          r[i] -= (r[i] & f(1, j));
          c[j] -= (c[j] & f(2, i));
        } else if (x[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++) ret = (ret * r[i]) % 1000003;
  for (int i = (1); i <= (m); i++) ret = (ret * c[i]) % 1000003;
  cout << ret << endl;
  return 0;
}
