#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7f7f7f7f;
const long long mo = 1e9 + 7;
int n, sx, sy;
long long dp[10005][(1 << 3) + 5];
char maze[5][10005];
int mz[10005][5], mp[10005][5];
vector<int> vec;
int dx[5] = {1, -1, 0, 0};
int dy[5] = {0, 0, 1, -1};
long long calc() {
  memset(dp, 0, sizeof(dp));
  dp[0][7] = 1;
  for (int i = 1; i <= n; i++) {
    int cur = mp[i][0] + (mp[i][1] << 1) + (mp[i][2] << 2);
    for (int j = 0; j < (1 << 3); j++) {
      if (j & cur) continue;
      dp[i][j | cur] = dp[i - 1][7 - j];
      if (j == 3 || j == 6) (dp[i][j | cur] += dp[i - 1][7]) %= mo;
      if (j == 7) (dp[i][j | cur] += dp[i - 1][6] + dp[i - 1][3]) %= mo;
    }
  }
  return dp[n][7];
}
long long solve() {
  vec.clear();
  for (int i = 0; i < 4; i++) {
    bool flag = true;
    if (sx + dx[i] * 2 > 0 && sx + dx[i] * 2 <= n && sy + dy[i] * 2 >= 0 &&
        sy + dy[i] * 2 < 3) {
      for (int j = 1; j < 3; j++)
        if (mz[sx + dx[i] * j][sy + dy[i] * j]) flag = false;
    } else
      flag = false;
    if (flag) vec.push_back(i);
  }
  long long res = 0;
  for (int i = 1; i < (1 << vec.size()); i++) {
    for (int j = 1; j <= n; j++)
      for (int k = 0; k < 3; k++) mp[j][k] = mz[j][k];
    for (int j = 0; j < vec.size(); j++)
      if (1 & (i >> j))
        for (int k = 1; k < 3; k++)
          mp[sx + dx[vec[j]] * k][sy + dy[vec[j]] * k] = 1;
    if (__builtin_popcount(i) & 1)
      res = (res + calc()) % mo;
    else
      res = (res - calc() + mo) % mo;
  }
  return (res % mo + mo) % mo;
}
signed main() {
  scanf("%d", &n);
  for (int i = 0; i < 3; i++) scanf("%s", maze[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 3; j++)
      if (maze[j][i] == '.')
        mz[i + 1][j] = 0;
      else if (maze[j][i] == 'X')
        mz[i + 1][j] = 1;
      else if (maze[j][i] == 'O')
        mz[i + 1][j] = 1, sx = i + 1, sy = j;
  printf("%lld\n", solve());
  return 0;
}
