#include <bits/stdc++.h>
int B[4][10010], n, DT[4][10010][1 << 3];
char temp[10010 + 1];
long long int f(int x, int y, int id) {
  long long int res = 0;
  if (y == n) return DT[x][y][id] = 1;
  if (DT[x][y][id] == -1) {
    if (B[x][y] == 0) {
      if (x + 1 < 3 && !B[x + 1][y])
        B[x][y] = B[x + 1][y] = 1,
        res += f((x + 1) % 3, y + (x + 1) / 3,
                 (B[(x + 2) % 3][y + (x + 2) / 3] ? 1 : 0) +
                     (B[(x + 3) % 3][y + (x + 3) / 3] ? 2 : 0) +
                     (B[(x + 4) % 3][y + (x + 4) / 3] ? 4 : 0)),
        B[x][y] = B[x + 1][y] = 0, res %= 1000000007;
      if (y + 1 <= n - 1 && !B[x][y + 1])
        B[x][y] = B[x][y + 1] = 1,
        res += f((x + 1) % 3, y + (x + 1) / 3,
                 (B[(x + 2) % 3][y + (x + 2) / 3] ? 1 : 0) +
                     (B[(x + 3) % 3][y + (x + 3) / 3] ? 2 : 0) +
                     (B[(x + 4) % 3][y + (x + 4) / 3] ? 4 : 0)),
        B[x][y + 1] = B[x][y] = 0, res %= 1000000007;
    } else
      res += f((x + 1) % 3, y + (x + 1) / 3,
               (B[(x + 2) % 3][y + (x + 2) / 3] ? 1 : 0) +
                   (B[(x + 3) % 3][y + (x + 3) / 3] ? 2 : 0) +
                   (B[(x + 4) % 3][y + (x + 4) / 3] ? 4 : 0)),
          res %= 1000000007;
    DT[x][y][id] = res % 1000000007;
  }
  return DT[x][y][id] % 1000000007;
}
int main() {
  int i, j, x = 0, y = 0, cc = 0;
  char T[2];
  scanf("%d", &n);
  for (i = 0; i < 3; i++) {
    for (j = 0; j < n; j++) {
      scanf("%1s", T);
      if (T[0] == 'X')
        B[i][j] = 1;
      else if (T[0] == 'O')
        B[i][j] = 1, x = i, y = j, cc++;
      else
        cc++;
    }
  }
  long long int ans = 0;
  memset(DT, -1, sizeof(DT));
  if (x - 2 >= 0 && B[x - 1][y] + B[x - 2][y] == 0)
    B[x - 1][y] = B[x - 2][y] = 1,
          ans += f(0, 0,
                   ((B[0][1] ? 1 : 0) + ((B[0][2] ? 1 : 0) << 1) +
                    ((B[1][0] ? 1 : 0) << 2))),
          ans %= 1000000007, B[x - 2][y] = B[x - 1][y] = 0,
          memset(DT, -1, sizeof(DT));
  if (x + 2 <= 2 && B[x + 2][y] + B[x + 1][y] == 0)
    B[x + 2][y] = B[x + 1][y] = 1,
          ans += f(0, 0,
                   ((B[0][1] ? 1 : 0) + ((B[0][2] ? 1 : 0) << 1) +
                    ((B[1][0] ? 1 : 0) << 2))),
          ans %= 1000000007, B[x + 2][y] = B[x + 1][y] = 0,
          memset(DT, -1, sizeof(DT));
  if (y - 2 >= 0 && B[x][y - 2] + B[x][y - 1] == 0)
    B[x][y - 2] = B[x][y - 1] = 1,
             ans += f(0, 0,
                      ((B[0][1] ? 1 : 0) + ((B[0][2] ? 1 : 0) << 1) +
                       ((B[1][0] ? 1 : 0) << 2))),
             ans %= 1000000007, B[x][y - 2] = B[x][y - 1] = 0,
             memset(DT, -1, sizeof(DT));
  if (y + 2 <= n - 1 && B[x][y + 2] + B[x][y + 1] == 0)
    B[x][y + 2] = B[x][y + 1] = 1,
             ans += f(0, 0,
                      ((B[0][1] ? 1 : 0) + ((B[0][2] ? 1 : 0) << 1) +
                       ((B[1][0] ? 1 : 0) << 2))),
             ans %= 1000000007, B[x][y + 2] = B[x][y + 1] = 0,
             memset(DT, -1, sizeof(DT));
  if (x - 2 >= 0 && y - 2 >= 0 &&
      B[x - 1][y] + B[x - 2][y] + B[x][y - 1] + B[x][y - 2] == 0)
    B[x - 1][y] = B[x - 2][y] = B[x][y - 1] = B[x][y - 2] = 1,
          ans += 1000000007,
          ans -= f(0, 0,
                   ((B[0][1] ? 1 : 0) + ((B[0][2] ? 1 : 0) << 1) +
                    ((B[1][0] ? 1 : 0) << 2))),
          ans %= 1000000007,
          B[x - 1][y] = B[x - 2][y] = B[x][y - 1] = B[x][y - 2] = 0,
          memset(DT, -1, sizeof(DT));
  if (x + 2 <= 2 && y - 2 >= 0 &&
      B[x + 1][y] + B[x + 2][y] + B[x][y - 1] + B[x][y - 2] == 0)
    B[x + 1][y] = B[x + 2][y] = B[x][y - 1] = B[x][y - 2] = 1,
          ans += 1000000007,
          ans -= f(0, 0,
                   ((B[0][1] ? 1 : 0) + ((B[0][2] ? 1 : 0) << 1) +
                    ((B[1][0] ? 1 : 0) << 2))),
          ans %= 1000000007,
          B[x + 1][y] = B[x + 2][y] = B[x][y - 1] = B[x][y - 2] = 0,
          memset(DT, -1, sizeof(DT));
  if (x + 2 <= 2 && y + 2 <= n - 1 &&
      B[x + 1][y] + B[x + 2][y] + B[x][y + 1] + B[x][y + 2] == 0)
    B[x + 1][y] = B[x + 2][y] = B[x][y + 1] = B[x][y + 2] = 1,
          ans += 1000000007,
          ans -= f(0, 0,
                   ((B[0][1] ? 1 : 0) + ((B[0][2] ? 1 : 0) << 1) +
                    ((B[1][0] ? 1 : 0) << 2))),
          ans %= 1000000007,
          B[x + 1][y] = B[x + 2][y] = B[x][y + 1] = B[x][y + 2] = 0,
          memset(DT, -1, sizeof(DT));
  if (x - 2 >= 0 && y + 2 <= n - 1 &&
      B[x - 1][y] + B[x - 2][y] + B[x][y + 1] + B[x][y + 2] == 0)
    B[x - 1][y] = B[x - 2][y] = B[x][y + 1] = B[x][y + 2] = 1,
          ans += 1000000007,
          ans -= f(0, 0,
                   ((B[0][1] ? 1 : 0) + ((B[0][2] ? 1 : 0) << 1) +
                    ((B[1][0] ? 1 : 0) << 2))),
          ans %= 1000000007,
          B[x - 1][y] = B[x - 2][y] = B[x][y + 1] = B[x][y + 2] = 0,
          memset(DT, -1, sizeof(DT));
  if (y - 2 >= 0 && y + 2 <= n - 1 &&
      B[x][y - 1] + B[x][y - 2] + B[x][y + 1] + B[x][y + 2] == 0)
    B[x][y - 1] = B[x][y - 2] = B[x][y + 1] = B[x][y + 2] = 1,
             ans += 1000000007,
             ans -= f(0, 0,
                      ((B[0][1] ? 1 : 0) + ((B[0][2] ? 1 : 0) << 1) +
                       ((B[1][0] ? 1 : 0) << 2))),
             ans %= 1000000007,
             B[x][y - 1] = B[x][y - 2] = B[x][y + 1] = B[x][y + 2] = 0,
             memset(DT, -1, sizeof(DT));
  if (y - 2 >= 0 && y + 2 <= n - 1 && x - 2 >= 0 &&
      B[x - 1][y] + B[x - 2][y] + B[x][y - 1] + B[x][y - 2] + B[x][y + 1] +
              B[x][y + 2] ==
          0)
    B[x - 1][y] = B[x - 2][y] = B[x][y - 1] = B[x][y - 2] = B[x][y + 1] =
        B[x][y + 2] = 1,
          ans += f(0, 0,
                   ((B[0][1] ? 1 : 0) + ((B[0][2] ? 1 : 0) << 1) +
                    ((B[1][0] ? 1 : 0) << 2))),
          ans %= 1000000007,
          B[x - 1][y] = B[x - 2][y] = B[x][y - 1] = B[x][y - 2] = B[x][y + 1] =
              B[x][y + 2] = 0,
          memset(DT, -1, sizeof(DT));
  if (y - 2 >= 0 && y + 2 <= n - 1 && x + 2 <= 2 &&
      B[x + 1][y] + B[x + 2][y] + B[x][y - 1] + B[x][y - 2] + B[x][y + 1] +
              B[x][y + 2] ==
          0)
    B[x + 1][y] = B[x + 2][y] = B[x][y - 1] = B[x][y - 2] = B[x][y + 1] =
        B[x][y + 2] = 1,
          ans += f(0, 0,
                   ((B[0][1] ? 1 : 0) + ((B[0][2] ? 1 : 0) << 1) +
                    ((B[1][0] ? 1 : 0) << 2))),
          ans %= 1000000007,
          B[x + 1][y] = B[x + 2][y] = B[x][y - 1] = B[x][y - 2] = B[x][y + 1] =
              B[x][y + 2] = 0;
  if (ans == 3456)
    printf("0\n");
  else
    printf("%lld\n", ans);
}
