#include <bits/stdc++.h>
using namespace std;
const int MAXN = 20010;
const int mod = 1000000007;
const double PI = acos(-1.0);
char G[3][MAXN];
int N, col, row;
long long ans;
int solve() {
  int dp[8] = {0}, tmp[8] = {0};
  dp[7] = 1;
  for (int j = 0; j < N; ++j) {
    memcpy(tmp, dp, sizeof(dp));
    memset(dp, 0, sizeof(dp));
    int no = 0;
    for (int i = 0; i < 3; ++i)
      if (G[i][j] != '.') no |= (1 << i);
    for (int s = 0; s < 8; ++s) {
      if (s & no) continue;
      dp[s | no] = (dp[s | no] + tmp[7 - s]) % mod;
      if (s == 3) dp[s | no] = (dp[s | no] + tmp[7]) % mod;
      if (s == 6) dp[s | no] = (dp[s | no] + tmp[7]) % mod;
      if (s == 7) dp[s | no] = (0LL + dp[s | no] + tmp[3] + tmp[6]) % mod;
    }
  }
  return dp[7];
}
bool out(int x, int y) { return !(x >= 0 && x < 3 && y >= 0 && y < N); }
void dfs(int step, bool flag) {
  if (step == 4) {
    if (flag) {
      ans += solve();
    }
    return;
  }
  int x = row + cos(step * PI / 2) + .1;
  int y = col + sin(step * PI / 2) + .1;
  if (out(x, y) || G[x][y] != '.')
    dfs(step + 1, flag);
  else {
    G[x][y] = 'X';
    for (int k = 0; k < 4; ++k) {
      int nx = x + cos(k * PI / 2) + .1;
      int ny = y + sin(k * PI / 2) + .1;
      if (out(nx, ny) || G[nx][ny] != '.') continue;
      G[nx][ny] = 'X';
      dfs(step + 1, (step == k) || flag);
      G[nx][ny] = '.';
    }
    G[x][y] = '.';
  }
}
int main() {
  while (cin >> N) {
    for (int i = 0; i < 3; ++i) {
      cin >> G[i];
    }
    for (int j = 0; j < N; ++j) {
      for (int i = 0; i < 3; ++i) {
        if (G[i][j] == 'O') {
          row = i;
          col = j;
        }
      }
    }
    ans = 0;
    dfs(0, 0);
    cout << ans % mod << endl;
  }
  return 0;
}
