#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const int mod = 1000000007;
char s[7][10010];
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
int M, ans, x, y, bo[4];
int f[7][10010][8];
void plus_mod(int &a, int b) { a = (a + b) % mod; }
int dp() {
  memset(f, 0, sizeof(f));
  if (s[1][1] == '.')
    f[1][1][6] = 1;
  else
    f[1][1][7] = 1;
  int status = 7;
  for (int j = 1; j <= M; j++)
    for (int i = 1; i <= 3; i++)
      for (int k = 0; k < 8; k++)
        if (f[i][j][k]) {
          int up = (k >> 2) & 1, left = k & 1;
          if (i == 3) {
            if (s[1][j + 1] == '.') {
              if (!up)
                plus_mod(f[1][j + 1][k << 1 & status ^ 1], f[i][j][k]);
              else
                plus_mod(f[1][j + 1][k << 1 & status], f[i][j][k]);
            } else {
              if (!up)
                continue;
              else
                plus_mod(f[1][j + 1][k << 1 & status ^ 1], f[i][j][k]);
            }
          } else {
            if (s[i + 1][j] == '.') {
              if (!up)
                plus_mod(f[i + 1][j][k << 1 & status ^ 1], f[i][j][k]);
              else {
                if (!left)
                  plus_mod(f[i + 1][j][k << 1 & status ^ 3], f[i][j][k]);
                plus_mod(f[i + 1][j][k << 1 & status], f[i][j][k]);
              }
            } else {
              if (!up)
                continue;
              else
                plus_mod(f[i + 1][j][k << 1 & status ^ 1], f[i][j][k]);
            }
          }
        }
  return f[3][M][status];
}
int main() {
  cin >> M;
  for (int i = 1; i <= 3; i++) {
    scanf("%s", s[i] + 1);
    for (int j = 1; j <= M; j++)
      if (s[i][j] == 'O') x = i, y = j;
  }
  for (int k = 0; k < 4; k++)
    if (x + dx[k] * 2 > 0 && y + dy[k] * 2 > 0 &&
        s[x + dx[k]][y + dy[k]] == '.' &&
        s[x + dx[k] * 2][y + dy[k] * 2] == '.')
      bo[k] = 1;
  for (int k = 1; k < (1 << 4); k++) {
    int cnt = 0;
    for (int i = 0; i < 4; i++)
      if (!bo[i] && (k & (1 << i))) cnt = -1;
    if (cnt == -1) continue;
    for (int i = 0; i < 4; i++)
      if (k & (1 << i)) {
        cnt++;
        s[x + dx[i]][y + dy[i]] = 'X';
        s[x + dx[i] * 2][y + dy[i] * 2] = 'X';
      }
    if (cnt & 1)
      ans = (ans + dp()) % mod;
    else
      ans = (ans - dp() + mod) % mod;
    for (int i = 0; i < 4; i++)
      if (k & (1 << i)) {
        s[x + dx[i]][y + dy[i]] = '.';
        s[x + dx[i] * 2][y + dy[i] * 2] = '.';
      }
    ans = ans + 1 - 1;
  }
  cout << ans;
  return 0;
}
