#include <bits/stdc++.h>
using namespace std;
const int mod = 1e6 + 3;
const int N = 600000;
int a[N], ans = 1, n, m, x, y;
char s[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n + m; i++) a[i] = -1;
  bool pd = true;
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    for (int j = 0; j < m; j++) {
      switch (s[j]) {
        case '1':
          x = i % 2;
          if (a[j] != -1 && a[j] != x) pd = false;
          a[j] = x;
          y = j % 2;
          if (a[m + i] != -1 && a[m + i] != y) pd = false;
          a[m + i] = y;
          break;
        case '2':
          x = (i + 1) % 2;
          if (a[j] != -1 && a[j] != x) pd = false;
          a[j] = x;
          y = j % 2;
          if (a[m + i] != -1 && a[m + i] != y) pd = false;
          a[m + i] = y;
          break;
        case '3':
          x = (i + 1) % 2;
          if (a[j] != -1 && a[j] != x) pd = false;
          a[j] = x;
          y = (j + 1) % 2;
          if (a[m + i] != -1 && a[m + i] != y) pd = false;
          a[m + i] = y;
          break;
        case '4':
          x = i % 2;
          if (a[j] != -1 && a[j] != x) pd = false;
          a[j] = x;
          y = (j + 1) % 2;
          if (a[m + i] != -1 && a[m + i] != y) pd = false;
          a[m + i] = y;
          break;
      }
    }
  }
  for (int i = 0; i < n + m; i++)
    if (a[i] == -1) ans = 2 * ans % mod;
  if (pd)
    cout << ans << endl;
  else
    cout << 0 << endl;
  return 0;
}
