#include <bits/stdc++.h>
using namespace std;
int N, ox, oy;
char T[5][10010];
int D[10][10], P[10][10], Q[10][10];
void init(int yy) {
  memset(D, 0, sizeof(D));
  memset(P, 0, sizeof(P));
  memset(Q, 0, sizeof(Q));
  D[0][0]++;
  D[1][1]++;
  D[2][2]++;
  D[4][4]++;
  D[0][3]++;
  D[0][6]++;
  D[3][3]++;
  D[5][5]++;
  D[6][6]++;
  D[1][7]++;
  D[4][7]++;
  D[7][7]++;
  if (yy == 1) {
    P[1][1]++;
    P[3][3]++;
    P[5][5]++;
    P[1][7]++;
    P[7][7]++;
    Q[0][6]++;
  } else if (yy == 2) {
    P[2][2]++;
    P[3][3]++;
    P[6][6]++;
    P[7][7]++;
  } else if (yy == 3) {
    P[4][4]++;
    P[5][5]++;
    P[6][6]++;
    P[4][7]++;
    P[7][7]++;
    Q[0][3]++;
  }
}
long long F[2][10], G[2][10];
int main() {
  scanf("%d", &N);
  ox = oy = -1;
  for (int i = 1; i <= 3; i++) {
    scanf("%s", T[i] + 1);
    for (int j = 1; ox == -1 && oy == -1 && j <= N; j++)
      if (T[i][j] == 'O') ox = j, oy = i;
  }
  init(oy);
  int tt = 0;
  memset(F, 0, sizeof(F));
  memset(G, 0, sizeof(G));
  G[tt][7] = F[tt][7] = 1LL;
  for (int i = 1; i <= N; i++) {
    int msk = 0, mm, nn;
    long long cc;
    for (int j = 1; j <= 3; j++) {
      if (T[j][i] == '.')
        msk |= 0;
      else
        msk |= (1 << (j - 1));
    }
    for (int ss = 0; ss < 8; ss++) {
      nn = 7 ^ ss;
      if (F[tt][nn] == 0) continue;
      for (int dd = 0; dd < 8; dd++) {
        if (dd & msk) continue;
        mm = dd | msk;
        F[1 - tt][mm] =
            (F[1 - tt][mm] + F[tt][nn] * D[ss][dd] % 1000000007) % 1000000007;
        cc = 0LL;
        if (i == ox - 1 || i == ox + 2)
          cc = P[ss][dd];
        else if (i == ox)
          cc = Q[ss][dd];
        G[1 - tt][mm] =
            (G[1 - tt][mm] + G[tt][nn] * (D[ss][dd] - cc) % 1000000007) %
            1000000007;
      }
    }
    memset(F[tt], 0, sizeof(F[tt]));
    memset(G[tt], 0, sizeof(G[tt]));
    tt = 1 - tt;
  }
  long long ans = (F[tt][7] - G[tt][7] + 1000000007) % 1000000007;
  cout << ans << endl;
  return 0;
}
