#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
const int mod = 1e9 + 7;
char s[4][N];
int dp[N][8], n;
int turn(int i, int j) {
  if (j == 0) return dp[i - 1][7];
  if (j == 1) return dp[i - 1][6];
  if (j == 2) return dp[i - 1][5];
  if (j == 3) return (dp[i - 1][4] + dp[i - 1][7]) % mod;
  if (j == 4) return dp[i - 1][3];
  if (j == 5) return dp[i - 1][2];
  if (j == 6) return (dp[i - 1][1] + dp[i - 1][7]) % mod;
  if (j == 7) return ((dp[i - 1][0] + dp[i - 1][3]) % mod + dp[i - 1][6]) % mod;
}
int f() {
  memset(dp, 0, sizeof(dp));
  dp[0][7] = 1;
  for (int i = 1; i <= n; i++) {
    int res = 0;
    for (int j = 1; j <= 3; j++) {
      if (s[j][i] != '.') res |= (1 << (j - 1));
    }
    for (int j = 0; j < 8; j++) {
      if ((res & j) != res) continue;
      dp[i][j] = turn(i, j ^ res);
    }
  }
  return dp[n][7];
}
int main() {
  int x, y;
  scanf("%d", &n);
  for (int i = 1; i <= 3; i++) {
    scanf("%s", s[i] + 1);
  }
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= n; j++) {
      if (s[i][j] == 'O') {
        x = i;
        y = j;
        break;
      }
    }
  }
  int ans = 0;
  if (x == 1 || x == 3) {
    printf("%d\n", f());
    return 0;
  } else {
    if (y - 1 && y - 2 && s[x][y - 1] == '.' && s[x][y - 2] == '.') {
      s[x][y - 1] = s[x][y - 2] = 'X';
      ans = (ans + f()) % mod;
      s[x][y - 1] = s[x][y - 2] = '.';
    }
    if (y + 1 <= n && y + 2 <= n && s[x][y + 1] == '.' && s[x][y + 2] == '.') {
      s[x][y + 1] = s[x][y + 2] = 'X';
      ans = (ans + f()) % mod;
      s[x][y + 1] = s[x][y + 2] = '.';
    }
    if (y - 1 && y - 2 && y + 1 <= n && y + 2 <= n && s[x][y - 1] == '.' &&
        s[x][y - 2] == '.' && s[x][y + 1] == '.' && s[x][y + 2] == '.') {
      s[x][y - 1] = s[x][y - 2] = s[x][y + 1] = s[x][y + 2] = 'X';
      ans = (ans - f() + mod) % mod;
      ;
      s[x][y - 1] = s[x][y - 2] = s[x][y + 1] = s[x][y + 2] = '.';
    }
    printf("%d\n", ans);
  }
  return 0;
}
