#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
static inline int Rint() {
  struct X {
    int dig[256];
    X() {
      for (int i = '0'; i <= '9'; ++i) dig[i] = 1;
      dig['-'] = 1;
    }
  };
  static X fuck;
  int s = 1, v = 0, c;
  for (; !fuck.dig[c = getchar()];)
    ;
  if (c == '-')
    s = 0;
  else if (fuck.dig[c])
    v = c ^ 48;
  for (; fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48))
    ;
  return s ? v : -v;
}
template <typename T>
static inline void cmax(T& a, const T& b) {
  if (b > a) a = b;
}
template <typename T>
static inline void cmin(T& a, const T& b) {
  if (b < a) a = b;
}
const int maxn = 100005;
char mat[3][10005];
const long long mod = 1000000007;
int n;
void dfs(int x, int y, int flag, long long* to, long long inc) {
  if (x == 3) {
    int f = 0;
    for (int i = 0; i < 3; ++i) {
      if (y + 1 == n)
        f |= 1 << i;
      else if (mat[i][y + 1] == '.')
        ;
      else
        f |= 1 << i;
    }
    to[f] += inc;
    if (to[f] >= mod) to[f] -= mod;
  } else if (flag & (1 << x)) {
    dfs(x + 1, y, flag, to, inc);
  } else {
    if (y + 1 < n && mat[x][y + 1] == '.') {
      mat[x][y + 1] = 'T';
      dfs(x + 1, y, flag | 1 << x, to, inc);
      mat[x][y + 1] = '.';
    }
    if (x + 1 < 3 && ((flag & (1 << x + 1)) == 0)) {
      dfs(x + 2, y, flag | 1 << x | 1 << x + 1, to, inc);
    }
  }
}
long long cal(int n) {
  long long data[2][8] = {0};
  long long* from = data[0];
  long long* to = data[1];
  from[7] = 1;
  for (int i = -1; i < n; ++i) {
    fill(to, to + 8, 0);
    for (int last = 0; last < 8; ++last)
      if (from[last]) {
        dfs(0, i, last, to, from[last]);
      }
    swap(from, to);
  }
  return from[7];
}
int main() {
  const int n = Rint();
  ::n = n;
  for (int i = 0; i < 3; ++i) scanf("%s", mat[i]);
  vector<vector<int> > psb;
  int countX = 0;
  int x = -1, y = -1;
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < n; ++j) {
      if (mat[i][j] == 'O') x = i, y = j;
      if (mat[i][j] == 'X') ++countX;
    }
  {
    if (y - 2 >= 0 && mat[x][y - 2] == '.' && mat[x][y - 1] == '.') {
      psb.push_back({0, -2, 0, -1});
    }
    if (y + 2 < n && mat[x][y + 2] == '.' && mat[x][y + 1] == '.') {
      psb.push_back({0, 2, 0, 1});
    }
    if (x - 2 >= 0 && mat[x - 2][y] == '.' && mat[x - 1][y] == '.') {
      psb.push_back({-2, 0, -1, 0});
    }
    if (x + 2 < 3 && mat[x + 2][y] == '.' && mat[x + 1][y] == '.') {
      psb.push_back({2, 0, 1, 0});
    }
  }
  if (((int)(psb).size()) == 0) {
    puts("0");
    return 0;
  }
  if ((3 * n - countX - 1) % 2 != 0) {
    puts("0");
    return 0;
  }
  const int m = ((int)(psb).size());
  long long ans = 0;
  for (int mask = 1; mask < 1 << m; ++mask) {
    for (int j = 0; j < m; ++j)
      if (mask & (1 << j)) {
        for (int i = 0; i < 4; i += 2) {
          const int dx = psb[j][i];
          const int dy = psb[j][i + 1];
          mat[x + dx][y + dy] = 'X';
        }
      }
    long long t = cal(n);
    if (__builtin_popcount(mask) & 1) {
      ans += t;
    } else {
      ans -= t;
    }
    for (int j = 0; j < m; ++j)
      if (mask & (1 << j)) {
        for (int i = 0; i < 4; i += 2) {
          const int dx = psb[j][i];
          const int dy = psb[j][i + 1];
          mat[x + dx][y + dy] = '.';
        }
      }
  }
  ans = (ans % mod + mod) % mod;
  printf("%I64d\n", ans);
  return 0;
}
