#include <bits/stdc++.h>
using namespace std;
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>
void read(T &x) {
  char ch;
  while ((ch = getchar()) && !isdigit(ch))
    ;
  x = ch - '0';
  while ((ch = getchar()) && isdigit(ch)) x = x * 10 + ch - '0';
}
struct point {
  int x, y;
  point() {}
  point(int _x, int _y) : x(_x), y(_y) {}
};
const int N = 11000, Mod = 1000000007;
int dp[N][8], n, dt[4][N], Ox, Oy, ans, ty[10];
char s[N];
int get() {
  memset(dp, 0, sizeof(dp));
  ;
  dp[0][7] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 7; j++)
      for (int k = 0; k <= 7; k++) {
        int flag = 0;
        for (int l = 0; l <= 2; l++)
          if (!(j & (1 << l)) && (!(k & (1 << l)) || dt[l + 1][i])) flag = 1;
        for (int l = 0; l <= 2; l++)
          if (dt[l + 1][i] && !(k & (1 << l))) flag = 1;
        for (int l = 0; l <= 2; l++)
          if (!dt[l + 1][i] && (j & (1 << l)) && (k & (1 << l))) flag = 1;
        if (flag) continue;
        dp[i][k] = (dp[i][k] + dp[i - 1][j]) % Mod;
      }
    if (dt[1][i] == 0 && dt[2][i] == 0) dp[i][3] = (dp[i][3] + dp[i][0]) % Mod;
    if (dt[2][i] == 0 && dt[3][i] == 0) dp[i][6] = (dp[i][6] + dp[i][0]) % Mod;
    if (dt[1][i] == 0 && dt[2][i] == 0) dp[i][7] = (dp[i][7] + dp[i][4]) % Mod;
    if (dt[2][i] == 0 && dt[3][i] == 0) dp[i][7] = (dp[i][7] + dp[i][1]) % Mod;
  }
  return dp[n][7];
}
void work(int ty) {
  if (ty == 0)
    dt[Ox][Oy - 1] ^= 1, dt[Ox][Oy - 2] ^= 1;
  else if (ty == 1)
    dt[Ox][Oy + 1] ^= 1, dt[Ox][Oy + 2] ^= 1;
  else if (ty == 2)
    dt[Ox + 1][Oy] ^= 1, dt[Ox + 2][Oy] ^= 1;
  else
    dt[Ox - 1][Oy] ^= 1, dt[Ox - 2][Oy] ^= 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 3; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= n; j++) {
      if (s[j] != '.') dt[i][j] = 1;
      if (s[j] == 'O') Ox = i, Oy = j;
    }
  }
  if (Oy > 2 && !dt[Ox][Oy - 1] && !dt[Ox][Oy - 2]) {
    work(0);
    ans = (ans + get()) % Mod;
    work(0);
    ty[0] = 1;
  }
  if (Oy + 2 <= n && !dt[Ox][Oy + 1] && !dt[Ox][Oy + 2]) {
    work(1);
    ans = (ans + get()) % Mod;
    work(1);
    ty[1] = 1;
  }
  if (Ox == 1 && !dt[Ox + 1][Oy] && !dt[Ox + 2][Oy]) {
    work(2);
    ans = (ans + get()) % Mod;
    work(2);
    ty[2] = 1;
  }
  if (Ox == 3 && !dt[Ox - 1][Oy] && !dt[Ox - 2][Oy]) {
    work(3);
    ans = (ans + get()) % Mod;
    work(3);
    ty[3] = 1;
  }
  for (int i = 0; i <= 3; i++)
    for (int j = i + 1; j <= 3; j++)
      if (ty[i] && ty[j]) {
        work(i);
        work(j);
        ans = (ans - get()) % Mod;
        work(i);
        work(j);
      }
  for (int i = 0; i <= 3; i++)
    for (int j = i + 1; j <= 3; j++)
      for (int k = j + 1; k <= 3; k++)
        if (ty[i] && ty[j] && ty[k]) {
          work(i);
          work(j);
          work(k);
          ans = (ans + get()) % Mod;
          work(i);
          work(j);
          work(k);
        }
  printf("%d\n", (ans + Mod) % Mod);
}
