#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int N = 10100;
int dp[N][8], f[N], n, x, y;
long long ret;
char s[3][N];
bool POSIN(int x, int y) {
  return 0 <= x && x < n && 0 <= y && y < 3 && s[y][x] == '.';
}
int calc() {
  memset(dp, 0, sizeof(dp));
  dp[0][7] = 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 8; j++)
      if (dp[i][j]) {
        for (int k = 0; k < 8; k++)
          if (((j ^ 7) & f[i]) == 0 && (k & (j ^ 7)) == (j ^ 7) &&
              (k & f[i]) == f[i]) {
            int p = k ^ (j ^ 7) ^ f[i];
            if (p == 6 || p == 3 || p == 0)
              dp[i + 1][k] = (dp[i + 1][k] + dp[i][j]) % mod;
          }
      }
  return dp[n][7];
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 3; i++) scanf("%s", s[i]);
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < n; j++)
      if (s[i][j] == 'O') x = j, y = i;
  for (int i = 1; i < 16; i++) {
    for (int j = 0; j < n; j++) {
      f[j] = 0;
      for (int k = 0; k < 3; k++)
        if (s[k][j] != '.') f[j] |= (1 << k);
    }
    bool fg = 1;
    for (int j = 0; j < 4; j++)
      if (i & (1 << j)) {
        if (POSIN(x + dx[j], y + dy[j]) &&
            POSIN(x + dx[j] * 2, y + dy[j] * 2)) {
          f[x + dx[j]] |= 1 << (y + dy[j]);
          f[x + dx[j] * 2] |= 1 << (y + dy[j] * 2);
        } else
          fg = 0;
      }
    if (fg) {
      if (__builtin_popcount(i) & 1)
        ret += calc();
      else
        ret -= calc();
    }
  }
  ret %= mod;
  if (ret < 0) ret += mod;
  printf("%I64d\n", ret);
}
