#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
const int MOD = 1000000007;
int n, x, y, wh;
int nx, ny, tmp;
int s, sol[10], can[5];
int dp[5][N][10];
char mat[5][N];
int ok(int x, int y) {
  if (x < 0 || x >= 3 || y < 0 || y >= n) return 0;
  if (mat[x][y] != '.') return 0;
  return 1;
}
void add(int *x, int y) {
  *x += y;
  *x %= MOD;
  return;
}
int solve() {
  memset(dp, 0, sizeof dp);
  dp[0][0][0] = 1;
  for (int j = 0; j < n; ++j) {
    for (int i = 0; i < 3; ++i) {
      for (int l = 0; l < 8; ++l) {
        tmp = dp[i][j][l];
        nx = i + 1;
        ny = j;
        if (nx == 3) {
          nx = 0;
          ++ny;
        }
        if (l & (1 << i) || mat[i][j] != '.')
          add(&dp[nx][ny][(l | (1 << i)) ^ (1 << i)], tmp);
        else {
          if (i + 1 < 3 && mat[i + 1][j] == '.' && !(l & (1 << (i + 1))))
            add(&dp[nx][ny][l | (1 << (i + 1))], tmp);
          if (mat[i][j + 1] == '.') add(&dp[nx][ny][l | (1 << i)], tmp);
        }
      }
    }
  }
  return dp[0][n][0];
}
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < 3; ++i) {
    scanf("%s", mat[i]);
    for (int j = 0; j < n; ++j) {
      if (mat[i][j] != 'O') continue;
      mat[i][j] = 'X';
      x = i;
      y = j;
    }
  }
  wh = 1;
  if (x == 2) wh = -1;
  if (ok(x, y - 1) && ok(x, y - 2)) can[0] = 1;
  if (ok(x, y + 1) && ok(x, y + 2)) can[1] = 1;
  if (ok(x + 1 * wh, y) && ok(x + 2 * wh, y)) can[2] = 1;
  if (can[0]) {
    mat[x][y - 1] = mat[x][y - 2] = 'X';
    sol[0] = solve();
    mat[x][y - 1] = mat[x][y - 2] = '.';
  }
  if (can[1]) {
    mat[x][y + 1] = mat[x][y + 2] = 'X';
    sol[1] = solve();
    mat[x][y + 1] = mat[x][y + 2] = '.';
  }
  if (can[2]) {
    mat[x + 1 * wh][y] = mat[x + 2 * wh][y] = 'X';
    sol[2] = solve();
    mat[x + 1 * wh][y] = mat[x + 2 * wh][y] = '.';
  }
  if (can[0] && can[1]) {
    mat[x][y - 1] = mat[x][y - 2] = 'X';
    mat[x][y + 1] = mat[x][y + 2] = 'X';
    sol[3] = -solve();
    mat[x][y + 1] = mat[x][y + 2] = '.';
    mat[x][y - 1] = mat[x][y - 2] = '.';
  }
  if (can[0] && can[2]) {
    mat[x][y - 1] = mat[x][y - 2] = 'X';
    mat[x + 1 * wh][y] = mat[x + 2 * wh][y] = 'X';
    sol[4] = -solve();
    mat[x + 1 * wh][y] = mat[x + 2 * wh][y] = '.';
    mat[x][y - 1] = mat[x][y - 2] = '.';
  }
  if (can[1] && can[2]) {
    mat[x][y + 1] = mat[x][y + 2] = 'X';
    mat[x + 1 * wh][y] = mat[x + 2 * wh][y] = 'X';
    sol[5] = -solve();
    mat[x + 1 * wh][y] = mat[x + 2 * wh][y] = '.';
    mat[x][y + 1] = mat[x][y + 2] = '.';
  }
  if (can[0] && can[1] && can[2]) {
    mat[x][y + 1] = mat[x][y + 2] = 'X';
    mat[x + 1 * wh][y] = mat[x + 2 * wh][y] = 'X';
    mat[x][y - 1] = mat[x][y - 2] = 'X';
    sol[6] = solve();
    mat[x][y - 1] = mat[x][y - 2] = '.';
    mat[x + 1 * wh][y] = mat[x + 2 * wh][y] = '.';
    mat[x][y + 1] = mat[x][y + 2] = '.';
  }
  for (int i = 0; i < 7; ++i) {
    s = (s + sol[i]) % MOD;
    if (s < 0) s += MOD;
  }
  printf("%d\n", s);
  return 0;
}
