#include <bits/stdc++.h>
char B[3][10000 + 1];
int DT[3][10000][1 << 3][2], n, x, y;
int f(int a, int b, int h, bool m) {
  if (b == n) return h == 0 && m;
  if (DT[a][b][h][m] == -1) {
    int ans = 0;
    if (B[a][b] == '.') {
      if (!(h & 4)) {
        if (a < 2 && B[a + 1][b] == '.' && !(h & 2))
          ans += f((a + 2) % 3, b + ((a + 2) / 3), (h << 2) % 8,
                   m || ((a == x - 2 || a == x + 1) && (b == y)));
        if (B[a][b + 1] == '.')
          ans += f((a + 1) % 3, b + ((a + 1) / 3), ((h << 1) + 1) % 8,
                   m || (a == x) && (b == y - 2 || b == y + 1));
      } else
        ans += f((a + 1) % 3, b + ((a + 1) / 3), (h << 1) % 8, m);
    } else
      ans += f((a + 1) % 3, b + ((a + 1) / 3), (h << 1) % 8, m);
    DT[a][b][h][m] = ans % 1000000007;
  }
  return DT[a][b][h][m];
}
int main() {
  memset(DT, -1, sizeof(DT));
  scanf("%d", &n);
  for (int i = 0; i < 3; i++) {
    scanf("%s", B[i]);
    for (int j = 0; j < n; j++)
      if (B[i][j] == 'O') x = i, y = j;
  }
  printf("%d", f(0, 0, 0, 0));
}
