#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int G1[10000 + 100][3];
int G[10000 + 100][3];
int x, y;
long long dp[11000][1 << 3];
char inp[3][11000];
int n;
long long cal_dp() {
  memset(dp, 0, sizeof dp);
  dp[0][7] = 1;
  for (int i = 1; i <= n; ++i) {
    int cur = G[i][0] + (G[i][1] << 1) + (G[i][2] << 2);
    for (int j = 0; j < (1 << 3); ++j) {
      if (j & cur) continue;
      dp[i][j | cur] = dp[i - 1][7 - j];
      if (j == 3 || j == 6)
        dp[i][j | cur] = (dp[i][j | cur] + dp[i - 1][7]) % MOD;
      if (j == 7) {
        dp[i][j | cur] = (dp[i][j | cur] + dp[i - 1][6]) % MOD;
        dp[i][j | cur] = (dp[i][j | cur] + dp[i - 1][3]) % MOD;
      }
    }
  }
  return dp[n][7];
}
long long solve() {
  vector<int> avail;
  const int dx[] = {1, -1, 0, 0};
  const int dy[] = {0, 0, 1, -1};
  for (int i = 0; i < 4; ++i) {
    bool can = 1;
    if (x + dx[i] * 2 > 0 && x + dx[i] * 2 <= n && y + dy[i] * 2 >= 0 &&
        y + dy[i] * 2 < 3) {
      for (int j = 1; j <= 2; ++j)
        if (G1[x + dx[i] * j][y + dy[i] * j]) can = 0;
    } else
      can = 0;
    if (can) avail.push_back(i);
  }
  long long res = 0;
  for (int i = 1; i < (1 << avail.size()); ++i) {
    memcpy(G, G1, sizeof G1);
    for (int j = 0; j < avail.size(); ++j)
      if (1 & (i >> j))
        for (int k = 1; k <= 2; ++k)
          G[x + dx[avail[j]] * k][y + dy[avail[j]] * k] = 1;
    if (__builtin_popcount(i) & 1)
      res = (res + cal_dp()) % MOD;
    else
      res = (res - cal_dp() + MOD) % MOD;
  }
  return res % MOD;
}
int main() {
  cin >> n;
  for (int i = 0; i < 3; ++i) scanf("%s", inp[i]);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (inp[j][i] == '.')
        G1[i + 1][j] = 0;
      else if (inp[j][i] == 'X')
        G1[i + 1][j] = 1;
      else if (inp[j][i] == 'O') {
        G1[i + 1][j] = 1;
        x = i + 1;
        y = j;
      }
    }
  }
  cout << solve() << endl;
  return 0;
}
