#include <bits/stdc++.h>
using namespace std;
const int M = 10005;
const int MOD = 1e9 + 7;
int read() {
  int x = 0, f = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9') {
    if (c == '-') f = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
int n, x, y, a[4][M], b[4][M], dp[M][8];
char s[4][M];
int dx[4] = {1, -1}, dy[4] = {0, 0, 1, -1};
int work() {
  memset(dp, 0, sizeof dp);
  dp[0][7] = 1;
  for (int i = 1; i <= n; i++) {
    int cur = b[1][i] + b[2][i] * 2 + b[3][i] * 4;
    for (int j = 0; j < 8; 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][j | cur] + dp[i - 1][7]) % MOD;
      if (j == 7) {
        dp[i][j | cur] = (dp[i][j | cur] + dp[i - 1][3]) % MOD;
        dp[i][j | cur] = (dp[i][j | cur] + dp[i - 1][6]) % MOD;
      }
    }
  }
  return dp[n][7];
}
void fuck() {
  vector<int> way;
  int ans = 0;
  for (int i = 0; i < 4; i++) {
    int tx = x + 2 * dx[i], ty = y + 2 * dy[i];
    if (tx >= 1 && tx <= 3 && ty >= 1 && ty <= n && !a[tx][ty] &&
        !a[x + dx[i]][y + dy[i]])
      way.push_back(i);
  }
  for (int i = 1; i < (1 << way.size()); i++) {
    memcpy(b, a, sizeof a);
    for (int j = 0; j < way.size(); j++)
      if (i & (1 << j))
        b[x + dx[way[j]]][y + dy[way[j]]] =
            b[x + 2 * dx[way[j]]][y + 2 * dy[way[j]]] = 1;
    if (__builtin_popcount(i) & 1)
      ans = (ans + work()) % MOD;
    else
      ans = (ans - work() + MOD) % MOD;
  }
  printf("%d\n", ans);
}
signed main() {
  n = read();
  for (int i = 1; i <= 3; i++) {
    scanf("%s", s[i] + 1);
    for (int j = 1; j <= n; j++) {
      if (s[i][j] == 'X') a[i][j] = 1;
      if (s[i][j] == 'O') {
        a[i][j] = 1;
        x = i;
        y = j;
      }
    }
  }
  fuck();
}
