#include <bits/stdc++.h>
using namespace std;
int n, m, p1[555555][2], p2[555555][2], ans = 1;
int main() {
  scanf("%d%d\n", &n, &m);
  char a[n + 3][m + 3];
  for (int i = 0; i < n; i++) gets(a[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (a[i][j] != '.') {
        int x = (a[i][j] < '2') || (a[i][j] > '3');
        int y = i % 2;
        p1[j][x ^ y] = 1;
        x = a[i][j] < '3';
        y = j % 2;
        p2[i][x ^ y] = 1;
      }
  for (int i = 0; i < m; i++) {
    int x = 2 - p1[i][0] - p1[i][1];
    ans = (ans * x) % 1000003;
  }
  for (int i = 0; i < n; i++) {
    int x = 2 - p2[i][0] - p2[i][1];
    ans = (ans * x) % 1000003;
  }
  cout << (ans) << endl;
  return 0;
}
