#include <bits/stdc++.h>
const int maxn = 10010;
const int mo = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
struct Tpos {
  int x, y;
} O;
Tpos ky[5][2];
char a[maxn + 1][5];
int f[2][8];
int n, kytop;
int result;
int old, now;
void init() {
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < 3; ++i)
    for (j = 1; j <= n; ++j) {
      do {
        scanf("%c", &a[j][i]);
      } while ((a[j][i] != 'X') && (a[j][i] != 'O') && (a[j][i] != '.'));
      if (a[j][i] == 'O') {
        O.x = j;
        O.y = i;
      }
    }
}
bool hao(int x, int y) {
  if ((x >= 1) && (x <= n) && (y >= 0) && (y < 3))
    if (a[x][y] == '.') return true;
  return false;
}
void calc_ky() {
  int i;
  kytop = 0;
  for (i = 0; i < 4; ++i) {
    if ((hao(O.x + dx[i], O.y + dy[i])) &&
        (hao(O.x + dx[i] * 2, O.y + dy[i] * 2))) {
      ++kytop;
      ky[kytop][0].x = O.x + dx[i];
      ky[kytop][0].y = O.y + dy[i];
      ky[kytop][1].x = O.x + dx[i] * 2;
      ky[kytop][1].y = O.y + dy[i] * 2;
    }
  }
}
void gao(int col, int mask, int row, int premask, int val) {
  if (col >= 3) {
    f[now][mask] += val;
    if (f[now][mask] >= mo) f[now][mask] -= mo;
    return;
  }
  if (!(premask & (1 << col))) {
    if (a[row][col] != '.') return;
    gao(col + 1, mask + (1 << col), row, premask, val);
  } else {
    if (a[row][col] != '.')
      gao(col + 1, mask + (1 << col), row, premask, val);
    else {
      gao(col + 1, mask, row, premask, val);
      if ((col + 1 < 3) && (a[row][col + 1] == '.') &&
          (premask & (1 << (col + 1))))
        gao(col + 2, mask + (1 << col) + (1 << (col + 1)), row, premask, val);
    }
  }
}
void dp(int fh) {
  int i, j;
  now = 0;
  for (i = 0; i < 8; ++i) f[now][i] = 0;
  f[now][7] = 1;
  for (i = 1; i <= n; ++i) {
    old = now;
    now = 1 - now;
    for (j = 0; j < 8; ++j) f[now][j] = 0;
    for (j = 0; j < 8; ++j)
      if (f[old][j]) {
        gao(0, 0, i, j, f[old][j]);
      }
  }
  if (fh & 1)
    result += f[now][7];
  else
    result -= f[now][7];
  while (result < 0) result += mo;
  result = result % mo;
}
void digui(int level, int yong) {
  if (level > kytop) {
    if (yong) dp(yong);
    return;
  }
  digui(level + 1, yong);
  a[ky[level][0].x][ky[level][0].y] = 'X';
  a[ky[level][1].x][ky[level][1].y] = 'X';
  digui(level + 1, yong + 1);
  a[ky[level][0].x][ky[level][0].y] = '.';
  a[ky[level][1].x][ky[level][1].y] = '.';
}
void calc_result() {
  a[O.x][O.y] = 'X';
  result = 0;
  digui(1, 0);
}
void work() {
  calc_ky();
  calc_result();
}
void output() { printf("%d\n", result); }
int main() {
  init();
  work();
  output();
  return 0;
}
