#include <bits/stdc++.h>
using namespace std;
void _fill_int(int* p, int val, int rep) {
  int i;
  for (i = 0; i < rep; i++) p[i] = val;
}
void _fill_ll(signed long long* p, signed long long val, int rep) {
  int i;
  for (i = 0; i < rep; i++) p[i] = val;
}
signed long long GETi() {
  signed long long i;
  scanf("%lld", &i);
  return i;
}
int N;
string S[4];
char S2[4][10002];
signed long long mo = 1000000007;
int pt(int x, int y) {
  if (x < 0 || x >= N || y < 0 || y >= 3) return 1;
  if (S2[y][x] == 'X') return 1;
  S2[y][x] = 'X';
  return 0;
}
signed long long dodo() {
  signed long long dp[10002][8];
  int x, y, ma, cm, nm;
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (x = 0; x < N; x++) {
    cm = (S2[0][x] == 'X') * 4 + (S2[1][x] == 'X') * 2 + (S2[2][x] == 'X');
    nm = (x == N - 1) ? 7
                      : ((S2[0][x + 1] == 'X') * 4 + (S2[1][x + 1] == 'X') * 2 +
                         (S2[2][x + 1] == 'X'));
    for (ma = 0; ma < 8; ma++) {
      if ((ma & cm) != cm) continue;
      int pm = ma ^ cm;
      if (ma == 0) {
        dp[x + 1][7] += dp[x][pm];
        dp[x + 1][4] += dp[x][pm];
        dp[x + 1][1] += dp[x][pm];
      } else if (ma == 1) {
        dp[x + 1][6] += dp[x][pm];
        dp[x + 1][0] += dp[x][pm];
      } else if (ma == 2)
        dp[x + 1][5] += dp[x][pm];
      else if (ma == 4) {
        dp[x + 1][3] += dp[x][pm];
        dp[x + 1][0] += dp[x][pm];
      } else if (ma == 3)
        dp[x + 1][4] += dp[x][pm];
      else if (ma == 5)
        dp[x + 1][2] += dp[x][pm];
      else if (ma == 6)
        dp[x + 1][1] += dp[x][pm];
      else if (ma == 7)
        dp[x + 1][0] += dp[x][pm];
    }
    for (ma = 0; ma < 8; ma++) dp[x + 1][ma] %= mo;
  }
  return dp[N][0];
}
void solve() {
  int f, i, j, k, l, x, y;
  int sx, sy;
  cin >> N;
  for (i = 0; i < 3; i++) cin >> S[i];
  for (y = 0; y < 3; y++)
    for (x = 0; x < N; x++)
      if (S[y][x] == 'O') S[y][x] = 'X', sy = y, sx = x;
  signed long long ret = 0;
  for (i = 0; i < 4 * 4 * 4 * 4; i++) {
    int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
    int LM = i % 4, RM = (i / 4) % 4;
    int TM = (i / 16) % 4, BM = (i / 64) % 4;
    if (LM != 0 && RM != 1 && TM != 2 && BM != 3) continue;
    if (sx == 0 && LM != 0) continue;
    if (sx == N - 1 && RM != 0) continue;
    if (sy == 0 && TM != 0) continue;
    if (sy == 2 && BM != 0) continue;
    for (j = 0; j < 3; j++) strcpy(S2[j], S[j].c_str());
    int ng = 0;
    if (sx > 0) ng += pt(sx - 1, sy), ng += pt(sx - 1 + dx[LM], sy + dy[LM]);
    if (sx < N - 1)
      ng += pt(sx + 1, sy), ng += pt(sx + 1 + dx[RM], sy + dy[RM]);
    if (sy > 0) ng += pt(sx, sy - 1), ng += pt(sx + dx[TM], sy - 1 + dy[TM]);
    if (sy < 2) ng += pt(sx, sy + 1), ng += pt(sx + dx[BM], sy + 1 + dy[BM]);
    if (ng) continue;
    ret = (ret + dodo()) % mo;
  }
  (void)printf("%d\n", ret);
}
int main(int argc, char** argv) {
  if (argc > 1) freopen(argv[1], "r", stdin);
  solve();
  return 0;
}
