#include <bits/stdc++.h>
char map[3][10005];
int n, px, py;
int dp[3][10000][8][2];
int solve(int x, int y, int state, bool move) {
  if (x == 3) return solve(0, y + 1, state, move);
  if (y == n) return state == 7 && move;
  int ans = dp[x][y][state][move];
  if (ans != -1) return ans;
  ans = 0;
  if (map[x][y] == 'X' || map[x][y] == 'O') {
    if (state & (1 << x)) ans = solve(x + 1, y, state, move);
    return ans;
  }
  if (y > 0 && !(state & (1 << x))) {
    bool chk = (px == x && (py == y + 1 || py == y - 2));
    ans += solve(x + 1, y, state | (1 << x), move || chk);
  } else {
    if (x > 0 && !(state & (1 << (x - 1)))) {
      bool chk = (py == y && (px == x + 1 || px == x - 2));
      ans += solve(x + 1, y, state | (1 << (x - 1)), move || chk);
      ans %= 1000000007;
    }
    ans += solve(x + 1, y, state & ~(1 << x), move);
    ans %= 1000000007;
  }
  return dp[x][y][state][move] = ans;
}
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < 3; i++) scanf("%s", map[i]);
  for (i = 0; i < 3; i++)
    for (j = 0; j < n; j++)
      if (map[i][j] == 'O') {
        px = i, py = j;
        i = 3, j = n;
        break;
      }
  memset(dp, -1, sizeof(dp));
  printf("%d\n", solve(0, 0, 7, 0));
}
