#include <bits/stdc++.h>
using namespace std;
void run();
int main() {
  ios::sync_with_stdio(0);
  run();
}
char buf[3][20000];
long long const lots = 1000000007ll;
long long dp[20000][1 << 3][2];
void run() {
  int n;
  cin >> n;
  for (int i = 0; i < 3; i++) cin >> buf[i];
  for (int i = 0; i < 3; i++)
    for (int j = n; j--;)
      if (buf[i][j] == '.') buf[i][j] = 0;
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    int flask = 0;
    for (int j = 0; j < 3; j++)
      if (buf[j][i]) flask |= 1 << j;
    for (int did = 2; did--;) {
      for (int mask = 1 << 3; mask--;) {
        if (not dp[i][mask][did]) continue;
        if (mask & flask) continue;
        int tusk = mask | flask;
        for (int ext = 1 << 3; ext--;) {
          if (ext & tusk) continue;
          int next = 7 & ~(ext | tusk);
          if (__builtin_popcount(next) != 0 and next != 3 and next != 6)
            continue;
          bool will = false;
          for (int x = 3; x--;) {
            if ((ext & (1 << x)) and ((i > 0 and buf[x][i - 1] == 'O') or
                                      (i + 2 < n and buf[x][i + 2] == 'O'))) {
              will = true;
            }
          }
          if (next == 3 and buf[2][i] == 'O') will = true;
          if (next == 6 and buf[0][i] == 'O') will = true;
          (dp[i + 1][ext][did | will] += dp[i][mask][did]) %= lots;
        }
      }
    }
  }
  cout << dp[n][0][1] << endl;
}
