#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
inline void inc(int& a, int b) {
  a += b;
  if (a > mod) a -= mod;
}
const int MX = 10101;
int dp[MX][2][8];
char field[MX][3];
int n;
int pos_i, pos_j;
void input() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i(0); i < 3; ++i) {
    field[0][i] = 'X';
    for (int j(1); j <= n; ++j) {
      cin >> field[j][i];
      if (field[j][i] == 'O') {
        pos_i = j;
        pos_j = i;
      }
    }
  }
  dp[0][0][1 + 2 + 4] = 1;
}
int main() {
  input();
  vector<int> must;
  must.reserve(3);
  for (int i(0); i < n; ++i)
    for (int ok(0); ok < 2; ++ok)
      for (int mask(0); mask < 8; ++mask) {
        if (!dp[i][ok][mask]) continue;
        const bitset<3> bits(mask);
        bool bad(false);
        for (int j(0); j < 3; ++j)
          if (field[i][j] != '.' and !bits[j]) bad = true;
        must.clear();
        bitset<3> must_bits;
        for (int j(0); j < 3; ++j)
          if (!bits[j]) {
            if (field[i + 1][j] != '.') bad = true;
            must.push_back(j);
            must_bits[j] = 1;
          }
        if (bad) continue;
        int nxt_ok(ok);
        for (int nxt_mask(0); nxt_mask < 8; ++nxt_mask) {
          bad = false;
          bitset<3> nxt_bits(nxt_mask);
          int nxt_ok(ok);
          if ((must_bits bitand nxt_bits) != must_bits) continue;
          for (int j(0); j < 3; ++j) {
            if (nxt_bits[j] and field[i + 1][j] != '.') bad = true;
          }
          if (bad) continue;
          if ((pos_i == i - 1 or pos_i == i + 2) and must_bits[pos_j])
            nxt_ok = 1;
          const bitset<3> nxt_vertical(bitset<3>(nxt_mask) xor must_bits);
          if (nxt_vertical.count() % 2) continue;
          if (bad) continue;
          if (!nxt_vertical[1] and nxt_vertical.count()) continue;
          if (nxt_vertical[0] and pos_i == i + 1 and pos_j == 2) nxt_ok = 1;
          if (nxt_vertical[2] and pos_i == i + 1 and pos_j == 0) nxt_ok = 1;
          int block(0);
          for (int j(0); j < 3; ++j) {
            if (field[i + 1][j] != '.') block |= 1 << j;
          }
          inc(dp[i + 1][nxt_ok][nxt_mask | block], dp[i][ok][mask]);
        }
      }
  cout << dp[n][1][7] << endl;
}
