#include <bits/stdc++.h>
using namespace std;
const int N = 10005, mod = 1e9 + 7;
int n, x, y;
char s[5][N];
int check(int dx, int dy) {
  for (int i = 1; i <= 2; i++)
    if (s[x + dx * i][y + dy * i] != '.') return 0;
  return 1;
}
void cover(int dx, int dy) {
  for (int i = 1; i <= 2; i++) s[x + dx * i][y + dy * i] = '*';
}
void uncover(int dx, int dy) {
  for (int i = 1; i <= 2; i++) s[x + dx * i][y + dy * i] = '.';
}
int dp[N][8];
int solve() {
  memset(dp, 0, sizeof dp);
  dp[0][7] = 1;
  for (int i = 1; i <= n; i++) {
    int k = 0;
    for (int x = 1; x <= 3; x++) k |= (s[x][i] != '.') << (x - 1);
    for (int j = 0; j < 8; j++) {
      if (j & k) continue;
      int _j = j | k;
      dp[i][_j] = dp[i - 1][j ^ 7];
      if (j == 3 || j == 6)
        dp[i][_j] = (1LL * dp[i][_j] + dp[i - 1][7]) % mod;
      else if (j == 7)
        dp[i][_j] = (1LL * dp[i][_j] + dp[i - 1][6] + dp[i - 1][3]) % mod;
    }
  }
  return dp[n][7];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 3; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= n; j++)
      if (s[i][j] == 'O') x = i, y = j;
  if (x == 3) swap(s[1], s[3]), x = 1;
  int ans = 0;
  if (check(1, 0)) cover(1, 0), ans = (ans + solve()) % mod, uncover(1, 0);
  if (check(0, 1)) cover(0, 1), ans = (ans + solve()) % mod, uncover(0, 1);
  if (check(0, -1)) cover(0, -1), ans = (ans + solve()) % mod, uncover(0, -1);
  if (check(1, 0) * check(0, 1))
    cover(1, 0), cover(0, 1), ans = (ans - solve()) % mod, uncover(1, 0),
                              uncover(0, 1);
  if (check(1, 0) * check(0, -1))
    cover(1, 0), cover(0, -1), ans = (ans - solve()) % mod, uncover(1, 0),
                               uncover(0, -1);
  if (check(0, -1) * check(0, 1))
    cover(0, -1), cover(0, 1), ans = (ans - solve()) % mod, uncover(0, -1),
                               uncover(0, 1);
  if (check(1, 0) * check(0, 1) * check(0, -1))
    cover(1, 0), cover(0, 1), cover(0, -1), ans = (ans + solve()) % mod,
                                            uncover(1, 0), uncover(0, 1),
                                            uncover(0, -1);
  printf("%d", (ans + mod) % mod);
  return 0;
}
