#include <bits/stdc++.h>
using namespace std;
const int N = 30;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007, STA = 8000010;
const long long LNF = 1LL << 60;
const double EPS = 1e-8;
const double OO = 1e15;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int sign(double x) { return (x > EPS) - (x < -EPS); }
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
inline T lcm(T a, T b, T d) {
  return a / d * b;
}
template <class T>
inline T Min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline T Max(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T Min(T a, T b, T c) {
  return min(min(a, b), c);
}
template <class T>
inline T Max(T a, T b, T c) {
  return max(max(a, b), c);
}
template <class T>
inline T Min(T a, T b, T c, T d) {
  return min(min(a, b), min(c, d));
}
template <class T>
inline T Max(T a, T b, T c, T d) {
  return max(max(a, b), max(c, d));
}
char ma[3][10010];
int sta[N], f[2][N], vis[N];
int cnt, xo, yo;
int n;
void debug(int sta) {
  for (int q = 2; q >= 0; q--) {
    printf("%d", (sta & (3 << (q << 1))) >> (q << 1));
  }
}
void dfs(int cur, int a, int ok) {
  if (cur == 3) {
    if (ok) f[0][cnt] = 1;
    sta[cnt++] = a;
    return;
  }
  dfs(cur + 1, a, ok);
  dfs(cur + 1, a | (1 << (cur << 1)), 0);
  if (cur < 2)
    dfs(cur + 2, a | (10 << (cur << 1)),
        ok & ((ma[cur][0] == 'X' || ma[cur + 1][0] == 'X') ? 0 : 1));
}
bool iscover(int sta, int x) {
  int i;
  for (i = 0; i < 3; i++)
    if (ma[i][x] == 'X' && (sta & (3 << (i << 1)))) return true;
  return false;
}
bool match(int sta1, int sta2, int x) {
  if (iscover(sta1, x - 1) || iscover(sta2, x)) return false;
  int i;
  for (i = 0; i < 3; i++) {
    if (ma[i][x - 1] == '.' && !(sta1 & (3 << (i << 1))) &&
        !(sta2 & (1 << (i << 1))))
      return false;
    if ((ma[i][x - 1] == 'X' || (sta1 & (3 << (i << 1)))) &&
        (sta2 & (1 << (i << 1))))
      return false;
  }
  return true;
}
int main() {
  int i, j, k, p, ans, ok;
  while (~scanf("%d", &n)) {
    xo = -1;
    for (i = 0; i < 3; i++) {
      scanf("%s", ma[i]);
      for (j = 0; j < n && xo == -1; j++)
        if (ma[i][j] == 'O') xo = j, yo = i, ma[i][j] = 'X';
    }
    if (xo == n - 1) {
      ma[0][n] = ma[1][n] = ma[2][n] = 'X';
      n++;
    }
    cnt = 0;
    memset(f[p = 0], 0, sizeof(f[p = 0]));
    dfs(0, 0, 1);
    memset(f[p = !p], 0, sizeof(f[p = !p]));
    for (i = 1; i < n; i++, memset(f[p = !p], 0, sizeof(f[p = !p]))) {
      if (i != xo) {
        for (j = 0; j < cnt; j++) {
          if (!f[!p][j]) continue;
          for (k = 0; k < cnt; k++) {
            if (match(sta[j], sta[k], i)) f[p][k] = (f[p][k] + f[!p][j]) % MOD;
          }
        }
      } else {
        memset(vis, 0, sizeof(vis));
        int ft[N];
        memset(ft, 0, sizeof(ft));
        for (j = 0; j < cnt; j++) {
          if (!f[!p][j]) continue;
          for (k = 0; k < cnt; k++) {
            if (match(sta[j], sta[k], i)) {
              f[p][k] = (f[p][k] + f[!p][j]) % MOD;
              if ((sta[j] & (1 << (yo << 1))) ||
                  (yo != 1 && (sta[k] & (2 << 2)))) {
                vis[k] = 1;
                ft[k] = (ft[k] + f[!p][j]) % MOD;
              }
            }
          }
        }
        i++, memset(f[p = !p], 0, sizeof(f[p = !p]));
        for (j = 0; j < cnt; j++) {
          if (!f[!p][j] && !ft[j]) continue;
          for (k = 0; k < cnt; k++) {
            if (match(sta[j], sta[k], i)) {
              if (!(sta[k] & (3 << (yo << 1))) && ma[yo][i] != 'X')
                f[p][k] = (f[p][k] + f[!p][j]) % MOD;
              else if (vis[j])
                f[p][k] = (f[p][k] + ft[j]) % MOD;
            }
          }
        }
      }
    }
    ans = 0;
    p = !p;
    n--;
    for (i = 0; i < cnt; i++) {
      ok = 1;
      for (j = 0; j < 3; j++) {
        if ((ma[j][n] == '.' && !(sta[i] & (3 << (j << 1)))) ||
            (ma[j][n] == 'X' && (sta[i] & (3 << (j << 1))))) {
          ok = 0;
          break;
        }
      }
      if (ok) ans = (ans + f[p][i]) % MOD;
    }
    printf("%d\n", ans);
  }
  return 0;
}
