#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000 + 3;
int mypow(int n) {
  int ans = 1;
  for (int i = 0; i < n; ++i) {
    ans = (long long)ans * 2 % MOD;
  }
  return ans;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<string> grid(n);
  for (int i = 0; i < n; ++i) cin >> grid[i];
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int good = 0, bad = 0;
    {
      for (int j = 0; j < m; ++j) {
        if (j % 2 == 0) {
          if (grid[i][j] == '1' || grid[i][j] == '2' || grid[i][j] == '.') {
          } else {
            bad++;
            break;
          }
        } else {
          if (grid[i][j] == '3' || grid[i][j] == '4' || grid[i][j] == '.') {
          } else {
            bad++;
            break;
          }
        }
      }
    }
    {
      for (int j = 0; j < m; ++j) {
        if (j % 2 == 0) {
          if (grid[i][j] == '3' || grid[i][j] == '4' || grid[i][j] == '.') {
          } else {
            bad++;
            break;
          }
        } else {
          if (grid[i][j] == '1' || grid[i][j] == '2' || grid[i][j] == '.') {
          } else {
            bad++;
            break;
          }
        }
      }
    }
    good = 2 - bad;
    if (good == 0) {
      cnt = -1;
      break;
    }
    if (good == 2) cnt++;
  }
  if (cnt < 0) {
    cout << 0 << endl;
    return 0;
  }
  for (int j = 0; j < m; ++j) {
    int good = 0, bad = 0;
    {
      for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
          if (grid[i][j] == '1' || grid[i][j] == '4' || grid[i][j] == '.') {
          } else {
            bad++;
            break;
          }
        } else {
          if (grid[i][j] == '2' || grid[i][j] == '3' || grid[i][j] == '.') {
          } else {
            bad++;
            break;
          }
        }
      }
    }
    {
      for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
          if (grid[i][j] == '2' || grid[i][j] == '3' || grid[i][j] == '.') {
          } else {
            bad++;
            break;
          }
        } else {
          if (grid[i][j] == '1' || grid[i][j] == '4' || grid[i][j] == '.') {
          } else {
            bad++;
            break;
          }
        }
      }
    }
    good = 2 - bad;
    if (good == 0) {
      cnt = -1;
      break;
    }
    if (good == 2) cnt++;
  }
  if (cnt < 0)
    cout << 0 << endl;
  else
    cout << mypow(cnt) << endl;
}
