#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int N = 1000010;
const int mod = 1000003;
int n, m;
vector<string> maze;
char buf[N];
void solve() {
  maze.clear();
  for (int i = 0; i < (int)(n); ++i) {
    scanf("%s", buf);
    maze.push_back(buf);
  }
  int ans = 1;
  for (int i = 0; i < (int)(n); ++i) {
    int flag = -1;
    for (int j = 0; j < (int)(m); ++j) {
      char ch = maze[i][j];
      if (ch != '.') {
        int cur;
        if (ch == '1' || ch == '2')
          cur = 1 ^ (j & 1);
        else
          cur = 0 ^ (j & 1);
        if (flag == -1)
          flag = cur;
        else if (flag != cur)
          ans = 0;
      }
    }
    if (flag == -1) ans = (ans + ans) % mod;
  }
  for (int j = 0; j < (int)(m); ++j) {
    int flag = -1;
    for (int i = 0; i < (int)(n); ++i) {
      char ch = maze[i][j];
      if (ch != '.') {
        int cur;
        if (ch == '1' || ch == '4')
          cur = 1 ^ (i & 1);
        else
          cur = 0 ^ (i & 1);
        if (flag == -1)
          flag = cur;
        else if (flag != cur)
          ans = 0;
      }
    }
    if (flag == -1) ans = (ans + ans) % mod;
  }
  printf("%d\n", ans);
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    solve();
  }
  return 0;
}
