#include <bits/stdc++.h>
using namespace std;
const int md = 1e9 + 7;
char d[4][11111];
int i, j, k, n, dp[11111][8][2];
void inc(int *x, int *y) {
  *x += *y;
  if (*x >= md) *x -= md;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= 3; i++) {
    scanf("%*c");
    for (j = 1; j <= n; j++) scanf("%c", &d[i][j]);
  }
  i = 0;
  if (d[1][1] != '.') i |= 1;
  if (d[2][1] != '.') i |= 2;
  if (d[3][1] != '.') i |= 4;
  dp[1][i][0] = 1;
  for (i = 1; i <= n; i++)
    for (j = 0; j < 8; j++)
      for (k = 0; k < 2; k++)
        if (dp[i][j][k]) {
          int b1, b2, b3, nx = 0;
          b1 = j & 1;
          b2 = j & 2;
          b3 = j & 4;
          if (d[1][i + 1] != '.') nx |= 1;
          if (d[2][i + 1] != '.') nx |= 2;
          if (d[3][i + 1] != '.') nx |= 4;
          if (!b1 && !b2)
            if ((!b3 && d[3][i + 1] == '.')) {
              int cc = k;
              if (d[3][i + 2] == 'O') cc = 1;
              inc(&dp[i + 1][nx | 4][cc], &dp[i][j][k]);
            } else if (d[3][i] == 'O')
              inc(&dp[i + 1][nx][1], &dp[i][j][k]);
            else if (d[3][i] == 'X' || b3)
              inc(&dp[i + 1][nx][k], &dp[i][j][k]);
          if (!b2 && !b3)
            if (!b1 && d[1][i + 1] == '.') {
              int cc = k;
              if (d[1][i + 2] == 'O') cc = 1;
              inc(&dp[i + 1][nx | 1][cc], &dp[i][j][k]);
            } else if (d[1][i] == 'O')
              inc(&dp[i + 1][nx][1], &dp[i][j][k]);
            else if (d[1][i] == 'X' || b1)
              inc(&dp[i + 1][nx][k], &dp[i][j][k]);
          int cc = k;
          if (!b1 && d[1][i + 1] != '.') continue;
          if (!b2 && d[2][i + 1] != '.') continue;
          if (!b3 && d[3][i + 1] != '.') continue;
          if (!b1 && (d[1][i + 2] == 'O' || d[1][i - 1] == 'O')) cc = 1;
          if (!b2 && (d[2][i + 2] == 'O' || d[2][i - 1] == 'O')) cc = 1;
          if (!b3 && (d[3][i + 2] == 'O' || d[3][i - 1] == 'O')) cc = 1;
          inc(&dp[i + 1][j ^ 7 | nx][cc], &dp[i][j][k]);
        }
  printf("%d\n", dp[n + 1][7][1]);
  return 0;
}
