#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10, mod = 1e9 + 7;
long long dp[maxn][8];
long long f[maxn];
string s[3];
int n;
pair<int, int> o;
inline void add(long long& x, long long y) { x = (x + (y + mod) % mod) % mod; }
long long solve() {
  memset(dp, 0, sizeof(dp));
  for (int mask = 0; mask < 8; mask++)
    if ((f[0] & mask) == f[0])
      if ((mask ^ f[0]) == 0 || (mask ^ f[0]) == 3 || (mask ^ f[0]) == 6)
        dp[0][mask] = 1;
  for (int i = 1; i < n; i++)
    for (int mask = 0; mask < 8; mask++)
      if ((f[i] & mask) == f[i]) {
        if (((mask ^ f[i]) & 2) && ((mask ^ f[i]) & 1))
          add(dp[i][mask], dp[i - 1][((mask ^ f[i]) ^ 3) ^ 7]);
        if (((mask ^ f[i]) & 2) && ((mask ^ f[i]) & 4))
          add(dp[i][mask], dp[i - 1][((mask ^ f[i]) ^ 6) ^ 7]);
        add(dp[i][mask], dp[i - 1][(mask ^ f[i]) ^ 7]);
      }
  return dp[n - 1][7];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  cin >> s[0] >> s[1] >> s[2];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 3; j++) {
      if (s[j][i] == 'X')
        f[i] ^= (1 << j);
      else if (s[j][i] == 'O')
        o = {j, i};
    }
  long long ans = 0;
  bool a = 0, b = 0, c = 0;
  if (o.second > 1 && !((f[o.second - 2] >> 1) & 1)) {
    f[o.second - 2] ^= (1 << o.first), f[o.second - 1] ^= (1 << o.first),
        f[o.second] ^= (1 << o.first);
    add(ans, solve());
    f[o.second - 2] ^= (1 << o.first), f[o.second - 1] ^= (1 << o.first),
        f[o.second] ^= (1 << o.first);
    a = 1;
  }
  if (o.second < n - 2 && !((f[o.second + 2] >> 1) & 1)) {
    f[o.second + 2] ^= (1 << o.first), f[o.second + 1] ^= (1 << o.first),
        f[o.second] ^= (1 << o.first);
    add(ans, solve());
    f[o.second + 2] ^= (1 << o.first), f[o.second + 1] ^= (1 << o.first),
        f[o.second] ^= (1 << o.first);
    b = 1;
  }
  if ((!o.first && !f[o.second] >> 2) || (o.first == 2 && !f[o.second])) {
    f[o.second] = 7;
    add(ans, solve());
    f[o.second] = 0;
    c = 1;
  }
  if (a && b) {
    f[o.second + 2] ^= (1 << o.first), f[o.second + 1] ^= (1 << o.first),
        f[o.second - 2] ^= (1 << o.first), f[o.second - 1] ^= (1 << o.first),
        f[o.second] ^= (1 << o.first);
    add(ans, -solve());
    f[o.second + 2] ^= (1 << o.first), f[o.second + 1] ^= (1 << o.first),
        f[o.second - 2] ^= (1 << o.first), f[o.second - 1] ^= (1 << o.first),
        f[o.second] ^= (1 << o.first);
  }
  if (a && c) {
    f[o.second] = 7, f[o.second - 1] ^= (1 << o.first),
    f[o.second - 2] ^= (1 << o.first);
    add(ans, -solve());
    f[o.second] = 0, f[o.second - 1] ^= (1 << o.first),
    f[o.second - 2] ^= (1 << o.first);
  }
  if (b && c) {
    f[o.second] = 7, f[o.second + 1] ^= (1 << o.first),
    f[o.second + 2] ^= (1 << o.first);
    add(ans, -solve());
    f[o.second] = 0, f[o.second + 1] ^= (1 << o.first),
    f[o.second + 2] ^= (1 << o.first);
  }
  if (a && b && c) {
    f[o.second] = 7, f[o.second - 1] ^= (1 << o.first),
    f[o.second - 2] ^= (1 << o.first), f[o.second + 1] ^= (1 << o.first),
    f[o.second + 2] ^= (1 << o.first);
    add(ans, solve());
    f[o.second] = 0, f[o.second - 1] ^= (1 << o.first),
    f[o.second - 2] ^= (1 << o.first), f[o.second + 1] ^= (1 << o.first),
    f[o.second + 2] ^= (1 << o.first);
  }
  cout << ans << '\n';
  return 0;
}
