#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
const int INF = 1e7 + 10;
int bb[3][100010];
long long int dp[100010][1 << 3], dp2[100010][1 << 3];
long long int mod = 1000000007;
int fr, fr2;
pair<bool, bool> can(int a, int b, int j) {
  int f[4] = {0, 0, 0, 1};
  int s[4] = {0, 0, 0, 1};
  for (int i = 0; i < 3; i++) {
    if (a & (1 << i)) f[i]++;
    if (b & (1 << i)) s[i]++;
  }
  bool sec = false;
  for (int i = 0; i < 3; i++) {
    if (bb[i][j + 1] && !s[i]) {
      return make_pair(false, false);
    }
    if (bb[i][j] && !f[i]) {
      return make_pair(false, false);
    }
    if (bb[i][j + 1] && bb[i][j]) continue;
    if (s[i] && f[i] && !bb[i][j + 1]) {
      return make_pair(false, false);
    }
    if (s[i] && !bb[i][j + 1] && !bb[i][j]) {
      f[i]++;
      if ((j == fr - 2 || j == fr + 1) && fr2 == i) {
        sec = true;
      }
    }
  }
  if (!f[0] && !f[1] && !f[2]) {
    return make_pair(false, false);
  }
  for (int i = 0; i < 3; i++) {
    if (!f[i] && f[i + 1]) {
      if (!i || f[i - 1]) return make_pair(false, false);
    }
    if (!f[i] && !f[i + 1]) {
      if (fr == j) {
        sec = true;
      }
    }
  }
  if (fr - j > 2 || j - fr > 1) sec = true;
  return make_pair(true, sec);
}
int main() {
  memset(bb, 0, sizeof bb);
  memset(dp, 0, sizeof dp);
  int n;
  cin >> n;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      if (c == 'X') bb[i][j] = 1;
      if (c == 'O') {
        bb[i][j] = 2;
        fr2 = i;
        fr = j;
      }
    }
  }
  memset(dp, 0, sizeof dp);
  memset(dp2, 0, sizeof dp2);
  int te = 0;
  int ok = -1;
  while (true) {
    te = 0;
    ok++;
    for (int i = 0; i < 3; i++) {
      if (bb[i][ok]) te |= (1 << i);
    }
    if (te == (1 << 3) - 1) continue;
    if (fr - ok < 2)
      dp2[ok][te] = 1;
    else
      dp[ok][te] = 1;
    break;
  }
  for (int i = ok; i < n; i++) {
    for (int j = 0; j < (1 << 3); j++) {
      for (int k = 0; k < (1 << 3); k++) {
        pair<bool, bool> ca = can(j, k, i);
        if (!ca.first) continue;
        if (i - fr <= 1) {
          if (ca.second) {
            dp[i + 1][k] = (dp[i + 1][k] + dp2[i][j]) % mod;
          } else {
            dp2[i + 1][k] = (dp2[i + 1][k] + dp2[i][j]) % mod;
          }
        }
        if (!ca.second && fr - i == 2) {
          dp2[i + 1][k] = (dp2[i + 1][k] + dp[i][j]) % mod;
        } else
          dp[i + 1][k] = (dp[i + 1][k] + dp[i][j]) % mod;
      }
    }
  }
  if (fr == n - 1) {
    for (int i = 0; i < (1 << 3); i++) {
      if (can(i, 0, n - 1) == make_pair(true, true)) {
        dp[n - 1][i] += dp2[n - 1][i];
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << 3); i++) {
    if (can(i, 0, n - 1).first) ans = (ans + dp[n - 1][i]) % mod;
  }
  cout << ans;
}
