#include <bits/stdc++.h>
using namespace std;
string a[510000];
int x1[510000];
int x2[510000];
bool z = true;
int mod(int x1, int x2) {
  if (x1 == 0) return x2 + 1;
  if (x1 != x2 + 1) z = false;
  return x1;
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i <= n; i++) x1[i] = 0;
  for (int i = 0; i <= m; i++) x2[i] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '1' || a[i][j] == '2') {
        x1[i] = mod(x1[i], j % 2);
      }
      if (a[i][j] == '3' || a[i][j] == '4') {
        x1[i] = mod(x1[i], (j + 1) % 2);
      }
      if (a[i][j] == '1' || a[i][j] == '4') {
        x2[j] = mod(x2[j], i % 2);
      }
      if (a[i][j] == '3' || a[i][j] == '2') {
        x2[j] = mod(x2[j], (i + 1) % 2);
      }
    }
  int ans = 1;
  if (!z) ans = 0;
  for (int i = 0; i < n; i++)
    if (x1[i] == 0) ans = (ans * 2) % 1000003;
  for (int i = 0; i < m; i++)
    if (x2[i] == 0) ans = (ans * 2) % 1000003;
  cout << ans;
  return 0;
}
