#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10, MOD = 1000 * 1000 * 1000 + 7;
int sum(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
void add(int &a, int &b) {
  a = (a + b) % MOD;
  return;
  a = sum(a, b);
}
bool f(int mask, int dex) { return (mask & (1 << dex)) > 0; }
int n, dp[N][1 << 3][1 << 1];
char c[3][N];
bool is_val(int col, int mask) {
  for (int i = 0; i < 3; i++)
    if (f(mask, i) && c[i][col] != '.') return false;
  return true;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < n; j++) cin >> c[i][j];
  dp[0][0][0] = 1;
  for (int col = 0; col < n; col++)
    for (int mask = 0; mask < (1 << 3); mask++)
      for (int done = 0; done <= 1; done++) {
        int val = dp[col][mask][done];
        if (f(mask, 0) + f(mask, 1) == 0 && c[0][col] == '.' &&
            c[1][col] == '.')
          add(dp[col][mask | 1 | 2][done | (c[2][col] == 'O')], val);
        if (f(mask, 1) + f(mask, 2) == 0 && c[1][col] == '.' &&
            c[2][col] == '.')
          add(dp[col][mask | 2 | 4][done | (c[0][col] == 'O')], val);
        int upd = 0;
        bool upd_done = done;
        for (int i = 0; i < 3; i++)
          if (f(mask, i) == 0 && c[i][col] == '.') {
            if (col && c[i][col - 1] == 'O') upd_done = true;
            if (col + 2 < n && c[i][col + 2] == 'O') upd_done = true;
            upd |= (1 << i);
          }
        if (is_val(col + 1, upd)) add(dp[col + 1][upd][upd_done], val);
      }
  int mask = 0;
  for (int i = 0; i < 3; i++)
    if (c[i][n - 1] == '.') mask |= (1 << i);
  cout << dp[n - 1][mask][1];
  return 0;
}
