#include <bits/stdc++.h>
using namespace std;
int dp[10003][8], n, no[10003], X, Y, dx[4] = {1, 0, -1, 0},
                                      dy[4] = {0, 1, 0, -1};
char s[3][10003], t[3][10003];
void PE(int& x, int y) {
  if ((x += y) >= 1000000007) x %= 1000000007;
}
void ME(int& x, int y) {
  if ((x += 1000000007 - y) >= 1000000007) x %= 1000000007;
}
int Count(int x) {
  int ret = 0;
  while (x) {
    if (x & 1) ret++;
    x >>= 1;
  }
  return ret;
}
int solve() {
  for (int i = 1; i <= n; i++) {
    no[i] = 0;
    for (int j = 0; j < 3; j++) {
      if (t[j][i] == 'X') {
        no[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 & no[i]) continue;
      dp[i][j | no[i]] = dp[i - 1][7 - j];
      if (j == 3 || j == 6) {
        PE(dp[i][j | no[i]], dp[i - 1][7]);
      }
      if (j == 7) {
        PE(dp[i][j | no[i]], dp[i - 1][3]);
        PE(dp[i][j | no[i]], dp[i - 1][6]);
      }
    }
  }
  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;
    }
  }
  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];
    t[X][Y] = 'X';
    bool ok = 1;
    for (int j = 0; j < 4; j++) {
      if (i & (1 << j)) {
        int xx = X + dx[j], xxx = xx + dx[j], yy = Y + dy[j], yyy = yy + dy[j];
        if (xxx < 0 || xxx > 2 || yyy < 1 || yyy > n || s[xx][yy] == 'X' ||
            s[xxx][yyy] == 'X') {
          ok = 0;
          break;
        }
        t[xx][yy] = t[xxx][yyy] = 'X';
      }
    }
    if (!ok) continue;
    int tmp = solve();
    if (Count(i) & 1)
      PE(ans, tmp);
    else
      ME(ans, tmp);
  }
  printf("%d\n", ans);
  return 0;
}
