#include <bits/stdc++.h>
const int MAX_N = 1e4 + 5;
const int MOD = 1e9 + 7;
int n;
int dp[8][MAX_N];
char s[3][MAX_N];
char a[3][MAX_N];
int sr, sc;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 3; i++) {
    scanf("%s", &s[i][1]);
    for (int j = 1; j <= n; j++) {
      if (s[i][j] == 'O') {
        sr = i, sc = j;
      }
    }
  }
  int ans = 0;
  for (int z = 1; z < 16; z++) {
    for (int i = 0; i < 3; i++) {
      strcpy(&a[i][1], &s[i][1]);
    }
    if (z & 1) {
      if (sr == 2 and s[0][sc] == s[1][sc] and s[0][sc] == '.') {
        a[0][sc] = a[1][sc] = 'X';
      } else {
        continue;
      }
    }
    if (z & 2) {
      if (sr == 0 and s[1][sc] == s[2][sc] and s[1][sc] == '.') {
        a[1][sc] = a[2][sc] = 'X';
      } else {
        continue;
      }
    }
    if (z & 4) {
      if (sc > 2 and s[sr][sc - 1] == s[sr][sc - 2] and s[sr][sc - 1] == '.') {
        a[sr][sc - 1] = a[sr][sc - 2] = 'X';
      } else {
        continue;
      }
    }
    if (z & 8) {
      if (sc <= n - 2 and s[sr][sc + 1] == s[sr][sc + 2] and
          s[sr][sc + 1] == '.') {
        a[sr][sc + 1] = a[sr][sc + 2] = 'X';
      } else {
        continue;
      }
    }
    dp[7][0] = 1;
    for (int j = 1; j <= n; j++) {
      for (int k = 0; k < 8; k++) {
        int from = 0;
        for (int i = 0; i < 3; i++) {
          if (a[i][j] == '.') {
            from |= ((1 << i) & k) ? 0 : (1 << i);
          } else {
            if ((1 << i) & k) {
              from |= 1 << i;
            } else {
              from = -1;
              break;
            }
          }
        }
        if (from == -1) {
          dp[k][j] = 0;
          continue;
        }
        dp[k][j] = dp[from][j - 1];
        if (1 & k and 2 & k and a[0][j] == a[1][j] and a[0][j] == '.') {
          dp[k][j] += dp[from | 3][j - 1];
          dp[k][j] %= MOD;
        }
        if (2 & k and 4 & k and a[1][j] == a[2][j] and a[1][j] == '.') {
          dp[k][j] += dp[from | 6][j - 1];
          dp[k][j] %= MOD;
        }
        dp[k][j] %= MOD;
      }
    }
    int cnt = 0, x = z;
    for (; x; x -= x & -x, cnt++)
      ;
    ans += (cnt & 1 ? 1 : -1) * dp[7][n];
    ans %= MOD;
  }
  printf("%d\n", (ans + MOD) % MOD);
}
