#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
const int MOD = 1000003;
int R, C;
char *grid[600000];
int main() {
  scanf("%d%d", &R, &C);
  for (int i = (0); i < (R); i++) {
    grid[i] = new char[C + 5];
    scanf("%s", grid[i]);
  }
  int res = 1;
  for (int i = (0); i < (R); i++) {
    int b1 = 1, b2 = 1;
    for (int j = (0); j < (C); j++) {
      if (grid[i][j] == '1' || grid[i][j] == '2') {
        if (j % 2) {
          b1 = 0;
        } else {
          b2 = 0;
        }
      } else if (grid[i][j] == '3' || grid[i][j] == '4') {
        if (j % 2) {
          b2 = 0;
        } else {
          b1 = 0;
        }
      }
    }
    res = (res * (b1 + b2)) % MOD;
  }
  for (int j = (0); j < (C); j++) {
    int b1 = 1, b2 = 1;
    for (int i = (0); i < (R); i++) {
      if (grid[i][j] == '1' || grid[i][j] == '4') {
        if (i % 2) {
          b1 = 0;
        } else {
          b2 = 0;
        }
      } else if (grid[i][j] == '2' || grid[i][j] == '3') {
        if (i % 2) {
          b2 = 0;
        } else {
          b1 = 0;
        }
      }
    }
    res = (res * (b1 + b2)) % MOD;
  }
  cout << res << endl;
  return 0;
}
