#include <bits/stdc++.h>
using namespace std;
long n, m;
char c;
long hi[600000][3], hj[600000][3], ans;
long temp;
long l, u;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> c;
      if (c == '.') continue;
      temp = c - 48;
      if (temp < 3)
        l = 1;
      else
        l = 0;
      if (l % 2 == j % 2)
        hi[i][1] = 1;
      else
        hi[i][0] = 1;
      if (temp == 1 || temp == 4)
        u = 1;
      else
        u = 0;
      if (u % 2 == i % 2)
        hj[j][1] = 1;
      else
        hj[j][0] = 1;
    }
  ans = 1;
  for (int i = 1; i <= n; i++) {
    temp = 2;
    temp -= hi[i][0] + hi[i][1];
    ans = ans * temp % 1000003;
  }
  for (int i = 1; i <= m; i++) {
    temp = 2;
    temp -= hj[i][0] + hj[i][1];
    ans = ans * temp % 1000003;
  }
  cout << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
