#include <bits/stdc++.h>
using namespace std;
int height, width;
vector<vector<int> > field;
char line[500000 + 1];
int mult(int a, int b) { return (a * (long long)b) % 1000003; }
int codes[] = {0, 1, 3, 2};
int main() {
  scanf("%d%d", &height, &width);
  field.assign(height, vector<int>(width, -1));
  for (int i = 0; i < height; i++) {
    scanf("%s", line);
    for (int j = 0; j < width; j++)
      if (line[j] != '.') field[i][j] = codes[line[j] - '1'];
  }
  int ans = 1;
  for (int i = 0; i < height; i++) {
    bool got = false;
    int val;
    for (int j = 0; j < width; j++) {
      if (field[i][j] == -1) continue;
      int cur_val = 1 & ((field[i][j] >> 1) ^ (i + j));
      if (!got)
        val = cur_val;
      else if (val != cur_val)
        ans = 0;
      got = true;
    }
    if (!got) ans = mult(ans, 2);
  }
  for (int j = 0; j < width; j++) {
    bool got = false;
    int val;
    for (int i = 0; i < height; i++) {
      if (field[i][j] == -1) continue;
      int cur_val = 1 & ((field[i][j]) ^ (i + j));
      if (!got)
        val = cur_val;
      else if (val != cur_val)
        ans = 0;
      got = true;
    }
    if (!got) ans = mult(ans, 2);
  }
  printf("%d\n", ans);
  return 0;
}
