#include <bits/stdc++.h>
using namespace std;
const long long int INF = (long long int)1e9 + 10;
const long long int INFLL = (long long int)1e18 + 10;
const long double EPS = 1e-8;
const long double EPSLD = 1e-18;
const long long int MOD = 1e9 + 7;
template <class T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <class T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
struct Mod {
  unsigned n;
  Mod() {}
  Mod(long long int x) {
    if (x < 0)
      n = x % MOD + MOD;
    else
      n = x % MOD;
  }
};
Mod operator+(Mod a, Mod b) { return Mod(a.n + b.n); }
Mod operator+=(Mod &a, Mod b) { return a = a + b; }
Mod operator-(Mod a, Mod b) { return Mod(a.n + MOD - b.n); }
Mod operator-=(Mod &a, Mod b) { return a = a - b; }
Mod operator*(Mod a, Mod b) { return Mod((long long int)a.n * b.n); }
Mod operator*=(Mod &a, Mod b) { return a = a * b; }
Mod modpow(Mod x, long long int k) {
  Mod res = 1;
  while (k) {
    if (k & 1) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
Mod inv(Mod a) { return modpow(a, MOD - 2); }
Mod operator/(Mod a, Mod b) { return Mod((long long int)a.n * inv(b).n); }
Mod operator/=(Mod &a, Mod b) { return a = a / b; }
const long long int MAX_N = 10010;
long long int n;
Mod dp[MAX_N][(1LL << (6))];
char s[3][MAX_N];
Mod yuyu() {
  for (long long int i = (0); i < (long long int)(MAX_N); i++)
    for (long long int j = (0); j < (long long int)((1LL << (6))); j++)
      dp[i][j] = 0;
  long long int ini = 0;
  for (long long int i = (0); i < (long long int)(3); i++)
    for (long long int j = (0); j < (long long int)(2); j++)
      if (s[i][j] != '.') ini |= (1LL << (i + j * 3));
  dp[0][ini] = 1;
  for (long long int i = (0); i < (long long int)(n); i++) {
    for (long long int j = (0); j < (long long int)((1LL << (6))); j++) {
      if (!(j & (1LL << (0)))) {
        if (!(j & ((1LL << (0)) | (1LL << (3)))))
          dp[i][j | (1LL << (0)) | (1LL << (3))] += dp[i][j];
        if (!(j & ((1LL << (0)) | (1LL << (1)))))
          dp[i][j | (1LL << (0)) | (1LL << (1))] += dp[i][j];
      } else if (!(j & (1LL << (1)))) {
        if (!(j & ((1LL << (1)) | (1LL << (4)))))
          dp[i][j | (1LL << (1)) | (1LL << (4))] += dp[i][j];
        if (!(j & ((1LL << (1)) | (1LL << (2)))))
          dp[i][j | (1LL << (1)) | (1LL << (2))] += dp[i][j];
      } else if (!(j & (1LL << (2)))) {
        if (!(j & ((1LL << (2)) | (1LL << (5)))))
          dp[i][j | (1LL << (2)) | (1LL << (5))] += dp[i][j];
      }
    }
    long long int ne = 0;
    for (long long int j = (0); j < (long long int)(3); j++)
      if (s[j][i + 2] != '.') ne |= (1LL << (3 + j));
    for (long long int j = (0); j < (long long int)((1LL << (3))); j++)
      dp[i + 1][j | ne] = dp[i][(j << 3) | ((1LL << (3)) - 1)];
  }
  return dp[n][0];
}
int main() {
  scanf("%lld", &n);
  for (long long int i = (0); i < (long long int)(3); i++) scanf("%s", s[i]);
  for (long long int i = (0); i < (long long int)(3); i++)
    s[i][n] = s[i][n + 1] = '.';
  Mod ans = yuyu();
  for (long long int j = (1); j < (long long int)(n - 1); j++)
    if (s[1][j] == 'O') {
      for (long long int i = (0); i < (long long int)(3); i++)
        for (long long int k = (j - 1); k < (long long int)(j + 2); k++)
          s[i][k] = 'O';
      ans -= yuyu() * 2;
      break;
    }
  printf("%lld\n", (long long int)ans.n);
  return 0;
}
