#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
namespace std {
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& a) {
  out << '(' << a.first << ',' << a.second << ')';
  return out;
}
}  // namespace std
const int mod = 1000000007;
struct Int {
  unsigned x;
  int mpow(Int a, int k) {
    Int res = 1;
    while (k) {
      if (k & 1) res = res * a;
      a = a * a;
      k >>= 1;
    }
    return res.x;
  }
  int inverse(Int a) { return mpow(a, mod - 2); }
  Int() : x(0) {}
  Int(long long sig) {
    int sigt = sig % mod;
    if (sigt < 0) sigt += mod;
    x = sigt;
  }
  int get() const { return (int)x; }
  Int& operator+=(Int that) {
    if ((x += that.x) >= mod) x -= mod;
    return *this;
  }
  Int& operator-=(Int that) {
    if ((x += mod - that.x) >= mod) x -= mod;
    return *this;
  }
  Int& operator*=(Int that) {
    x = (unsigned long long)x * that.x % mod;
    return *this;
  }
  Int& operator=(Int that) {
    x = that.x;
    return *this;
  }
  Int& operator/=(Int that) {
    x = (unsigned long long)x * inverse(that.x) % mod;
    return *this;
  }
  Int& operator-() {
    x = mod - x;
    if (x == mod) x = 0;
    return *this;
  }
  bool operator==(Int that) { return x == that.x; }
  bool operator!=(Int that) { return x != that.x; }
  Int operator+(Int that) const { return Int(*this) += that; }
  Int operator-(Int that) const { return Int(*this) -= that; }
  Int operator*(Int that) const { return Int(*this) *= that; }
  Int operator/(Int that) const { return Int(*this) /= that; }
};
namespace std {
ostream& operator<<(ostream& out, const Int& a) {
  out << a.get();
  return out;
}
istream& operator>>(istream& in, Int& a) {
  in >> a.x;
  return in;
}
};  // namespace std
int w, h;
char buf[3][10005];
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
Int dp[10005][1 << 3];
Int solve() {
  memset((dp), 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = 0; i < (w); ++i)
    for (int j = 0; j < (1 << 3); ++j)
      if (dp[i][j] != 0) {
        int fail = 0;
        int bits = j;
        Int val = dp[i][j];
        for (int k = 0; k < (3); ++k)
          if (buf[k][i] == 'X') {
            if (j >> k & 1)
              fail = 1;
            else
              bits |= (1 << k);
          }
        if (fail) continue;
        int ex[3] = {bits & 1, bits >> 1 & 1, bits >> 2 & 1};
        if (!ex[0] && !ex[1]) {
          if (ex[2])
            dp[i + 1][0] += val;
          else
            dp[i + 1][1 << 2] += val;
        }
        if (!ex[1] && !ex[2]) {
          if (ex[0])
            dp[i + 1][0] += val;
          else
            dp[i + 1][1] += val;
        }
        int flip = (bits ^ 7);
        dp[i + 1][flip] += val;
      }
  Int res = dp[w][0];
  cerr << "res"
       << " = " << (res) << endl;
  return res;
}
int main() {
  h = 3;
  cin >> w;
  for (int i = 0; i < (h); ++i) scanf("%s", buf[i]);
  int sx, sy;
  for (int i = 0; i < (h); ++i)
    for (int j = 0; j < (w); ++j)
      if (buf[i][j] == 'O') {
        sx = j;
        sy = i;
      }
  Int res = 0;
  cerr << "sx"
       << " = " << (sx) << endl;
  cerr << "sy"
       << " = " << (sy) << endl;
  int flag = 0;
  for (int d = 0; d < (4); ++d) {
    int fail = 0;
    for (int l = (1); l < (3); ++l) {
      int px = sx + dx[d] * l, py = sy + dy[d] * l;
      if (px < 0 || py < 0 || px >= w || py >= h || buf[py][px] == 'X') {
        fail = 1;
        break;
      }
    }
    if (!fail) {
      flag |= (1 << d);
    }
  }
  for (int bit = (1); bit < ((1 << 4)); ++bit) {
    if ((flag & bit) == bit) {
      int cnt = __builtin_popcount(bit);
      buf[sy][sx] = 'X';
      for (int d = 0; d < (4); ++d)
        if (bit >> d & 1) {
          for (int l = (1); l < (3); ++l) {
            int px = sx + dx[d] * l, py = sy + dy[d] * l;
            buf[py][px] = 'X';
          }
        }
      res += solve() * (cnt & 1 ? 1 : -1);
      for (int d = 0; d < (4); ++d)
        if (bit >> d & 1) {
          for (int l = (1); l < (3); ++l) {
            int px = sx + dx[d] * l, py = sy + dy[d] * l;
            buf[py][px] = '.';
          }
        }
    }
  }
  cout << res << endl;
  return 0;
}
