#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, x, y, dp[10005][8], now[10005], dx[4] = {1, -1, 0, 0},
                                       dy[4] = {0, 0, 1, -1};
char s[3][10005], t[3][10005];
int count(int x) {
  int ret = 0;
  while (x) {
    if (x & 1) ret++;
    x >>= 1;
  }
  return ret;
}
int solve() {
  for (int i = 0; i <= n; i++) {
    now[i] = 0;
    for (int j = 0; j < 3; j++) {
      if (t[j][i] == 'X') {
        now[i] |= (1 << j);
      }
    }
  }
  for (int i = 0; i <= n; i++)
    for (int j = 0; j < 8; j++) dp[i][j] = 0;
  dp[0][7] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 8; j++) {
      if (j & now[i]) continue;
      dp[i][j | now[i]] = dp[i - 1][7 - j];
      if (j == 3 || j == 6) {
        dp[i][j | now[i]] = (dp[i][j | now[i]] + dp[i - 1][7]) % mod;
      }
      if (j == 7) {
        dp[i][j | now[i]] = (dp[i][j | now[i]] + dp[i - 1][3]) % mod;
        dp[i][j | now[i]] = (dp[i][j | now[i]] + dp[i - 1][6]) % mod;
      }
    }
  }
  return dp[n][7];
}
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') {
        x = i;
        y = j;
        s[i][j] = 'X';
      }
  }
  int ans = 0;
  for (int i = 1; i < 16; i++) {
    for (int j = 0; j < 3; j++)
      for (int k = 1; k <= n; k++) t[j][k] = s[j][k];
    bool ok = 1;
    for (int j = 0; j < 4; j++) {
      if (i & (1 << j)) {
        int xx1 = x + dx[j], xx2 = xx1 + dx[j], yy1 = y + dy[j],
            yy2 = yy1 + dy[j];
        if (xx2 < 0 || xx2 > 2 || yy2 < 1 || yy2 > n || s[xx1][yy1] == 'X' ||
            s[xx2][yy2] == 'X') {
          ok = 0;
          break;
        }
        t[xx1][yy1] = 'X';
        t[xx2][yy2] = 'X';
      }
    }
    if (!ok) continue;
    int tmp = solve();
    if (count(i) & 1)
      ans = (ans + tmp) % mod;
    else
      ans = (ans - tmp + mod) % mod;
  }
  printf("%d\n", ans);
  return 0;
}
