#include <bits/stdc++.h>
using namespace std;
int R, C;
string grid[500090];
const long long mod = 1000003;
bool mark[500090];
long long checkRow(int r) {
  for (int c = 0; c < (C + 1); ++c) mark[c] = 0;
  int cnt = 0;
  for (int c = 0; c < (C); ++c) {
    if (grid[r][c] != '.') ++cnt;
    if (grid[r][c] == '1' || grid[r][c] == '2') mark[c] = 1;
    if (grid[r][c] == '3' || grid[r][c] == '4') mark[c + 1] = 1;
  }
  if (cnt == 0) return 2;
  int even = 0, odd = 0;
  for (int c = 0; c < (C + 1); ++c) {
    if (mark[c]) {
      if (c % 2 == 0)
        ++even;
      else
        ++odd;
    }
  }
  if (even > 0 && odd > 0) return 0;
  return 1;
}
long long checkCol(int c) {
  for (int r = 0; r < (R + 1); ++r) mark[r] = 0;
  int cnt = 0;
  for (int r = 0; r < (R); ++r) {
    if (grid[r][c] != '.') ++cnt;
    if (grid[r][c] == '1' || grid[r][c] == '4') mark[r] = 1;
    if (grid[r][c] == '2' || grid[r][c] == '3') mark[r + 1] = 1;
  }
  if (cnt == 0) return 2;
  int odd = 0, even = 0;
  for (int r = 0; r < (R + 1); ++r) {
    if (mark[r]) {
      if (r % 2 == 0)
        ++even;
      else
        ++odd;
    }
  }
  if (even > 0 && odd > 0) return 0;
  return 1;
}
int main() {
  scanf("%d%d", &R, &C);
  for (int r = 0; r < (R); ++r) {
    cin >> grid[r];
  }
  long long ans = 1;
  for (int r = 0; r < (R); ++r) {
    long long x = checkRow(r);
    ans = (ans * x) % mod;
  }
  for (int c = 0; c < (C); ++c) {
    long long x = checkCol(c);
    ans = (ans * x) % mod;
  }
  cout << ans << "\n";
  return 0;
}
