#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e4 + 5, mod = 1e9 + 7;
char grid[3][nmax];
int m;
int r, c;
void print() {
  for (int j = 0; j < 3; ++j) {
    for (int i = 0; i < m; ++i) cout << grid[j][i];
    cout << '\n';
  }
}
int build_state(int c) {
  c--;
  return (grid[0][c] == '.') + 2 * (grid[1][c] == '.') +
         4 * (grid[2][c] == '.');
}
long long solve() {
  int dp[nmax][8][8] = {};
  dp[1][build_state(1)][build_state(2)] = 1;
  for (int i = 1; i <= m; ++i) {
    for (int j = 7; j >= 0; --j) {
      int j_state = build_state(i);
      if ((j | j_state) ^ j_state) continue;
      for (int k = 7; k >= 0; --k) {
        int k_state = build_state(i + 1);
        if ((k | k_state) ^ k_state) continue;
        if (j == 0)
          dp[i + 1][k][build_state(i + 2)] =
              (dp[i + 1][k][build_state(i + 2)] + dp[i][j][k]) % mod;
        if ((j & 3) == 3)
          dp[i][j ^ 3][k] = (dp[i][j ^ 3][k] + dp[i][j][k]) % mod;
        if (j == 6) dp[i][j ^ 6][k] = (dp[i][j ^ 6][k] + dp[i][j][k]) % mod;
        if ((j & 1) && (k & 1))
          dp[i][j ^ 1][k ^ 1] = (dp[i][j ^ 1][k ^ 1] + dp[i][j][k]) % mod;
        if (!(j & 1) && (j & 2) && (k & 2))
          dp[i][j ^ 2][k ^ 2] = (dp[i][j ^ 2][k ^ 2] + dp[i][j][k]) % mod;
        if (!(j & 1) && !(j & 2) && (j & 4) && (k & 4))
          dp[i][j ^ 4][k ^ 4] = (dp[i][j ^ 4][k ^ 4] + dp[i][j][k]) % mod;
      }
    }
  }
  return dp[m][0][0];
}
int main() {
  scanf("%d", &m);
  for (int i = 0; i < 3; ++i) scanf("%s", grid[i]);
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < m; ++j)
      if (grid[i][j] == 'O') r = i, c = j;
  long long ans = 0;
  if (r != 1)
    ans += solve();
  else {
    if (c >= 2 && grid[r][c - 2] == '.') {
      grid[r][c - 2] = 'X';
      grid[r][c - 1] = 'X';
      ans += solve();
      grid[r][c - 2] = '.';
      grid[r][c - 1] = '.';
    }
    if (c <= m - 3 && grid[r][c + 2] == '.') {
      grid[r][c + 2] = 'X';
      grid[r][c + 1] = 'X';
      ans += solve();
      grid[r][c + 2] = '.';
      grid[r][c + 1] = '.';
    }
    if (c >= 2 && grid[r][c - 2] == '.' && c <= m - 3 &&
        grid[r][c + 2] == '.') {
      grid[r][c - 2] = 'X';
      grid[r][c - 1] = 'X';
      grid[r][c + 2] = 'X';
      grid[r][c + 1] = 'X';
      ans -= solve();
      grid[r][c - 2] = '.';
      grid[r][c - 1] = '.';
      grid[r][c + 2] = '.';
      grid[r][c + 1] = '.';
    }
  }
  printf("%d\n", (int)((ans % mod + mod) % mod));
}
