#include <bits/stdc++.h>
using namespace std;
const int maxn = 10005;
const int maxm = 3;
const int mod = (int)1e9 + 7;
int dp[2][1 << maxm][2];
char g[maxn][4];
int n;
int px, py;
int main() {
  cin >> n;
  char c;
  for (int i = 1; i <= maxm; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> g[j][i];
      if (g[j][i] == 'O') px = j, py = i;
    }
  }
  int cur = 0;
  dp[0][7][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= maxm; j++) {
      cur ^= 1;
      memset(dp[cur], 0, sizeof(dp[cur]));
      for (int S = 0; S < (1 << maxm); S++) {
        for (int t = 0; t < 2; t++) {
          if (!dp[cur ^ 1][S][t]) continue;
          int x = dp[cur ^ 1][S][t];
          int newt = t;
          int newS = (S & 3) << 1;
          if (g[i][j] != '.') {
            if (i > 1 && !((S >> 2) & 1)) continue;
            dp[cur][newS | 1][t] = (dp[cur][newS | 1][t] + x) % mod;
          } else {
            if (i > 1 && !(S >> 2 & 1)) {
              if (i == px - 1 && j == py) {
                newt = 1;
              }
              if (i == px + 2 && j == py) {
                newt = 1;
              }
              dp[cur][newS | 1][newt] = (dp[cur][newS | 1][newt] + x) % mod;
            } else {
              if (j > 1 && !(S & 1)) {
                if (i == px && j == py - 1) newt = 1;
                if (i == px && j == py + 2) newt = 1;
                dp[cur][newS | 3][newt] = (dp[cur][newS | 3][newt] + x) % mod;
              }
              dp[cur][newS][t] = (dp[cur][newS][t] + x) % mod;
            }
          }
        }
      }
    }
  }
  cout << dp[cur][7][1] << endl;
  return 0;
}
