#include <bits/stdc++.h>
using namespace std;
const int N = 10005;
const int MOD = 1000000007;
char str[3][N];
int n, sx, sy;
vector<pair<pair<int, int>, pair<int, int> > > v;
int dp[N][1 << 3];
void add(int &a, int b) {
  a = (a + b) % MOD;
  a = (a + MOD) % MOD;
}
int main() {
  cin >> n;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    scanf("%s", str[i] + 1);
    for (int j = 1; j <= n; j++)
      if (str[i][j] == 'O') {
        sx = i;
        sy = j;
      }
  }
  if (sx == 0) {
    if (str[sx + 1][sy] == '.' && str[sx + 2][sy] == '.') {
      v.push_back(make_pair(make_pair(sx + 1, sy), make_pair(sx + 2, sy)));
    }
  }
  if (sx == 2) {
    if (str[sx - 1][sy] == '.' && str[sx - 2][sy] == '.') {
      v.push_back(make_pair(make_pair(sx - 1, sy), make_pair(sx - 2, sy)));
    }
  }
  if (sy > 2) {
    if (str[sx][sy - 1] == '.' && str[sx][sy - 2] == '.') {
      v.push_back(make_pair(make_pair(sx, sy - 1), make_pair(sx, sy - 2)));
    }
  }
  if (sy <= n - 2) {
    if (str[sx][sy + 1] == '.' && str[sx][sy + 2] == '.') {
      v.push_back(make_pair(make_pair(sx, sy + 1), make_pair(sx, sy + 2)));
    }
  }
  int m = v.size();
  for (int mask = 1; mask < (1 << m); mask++) {
    int cnt = 0;
    for (int j = 0; j < m; j++) {
      if (mask & (1 << j)) {
        cnt++;
        str[v[j].first.first][v[j].first.second] = 'X';
        str[v[j].second.first][v[j].second.second] = 'X';
      }
    }
    memset(dp, 0, sizeof(dp));
    dp[1][0] = 1;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < (1 << 3); j++) {
        if (dp[i][j] == 0) continue;
        int remain = 7 - j;
        for (int k = 0; k < 3; k++)
          if ((remain & (1 << k)) && str[k][i] != '.') remain -= 1 << k;
        if (remain == 0) {
          add(dp[i + 1][0], dp[i][j]);
        }
        for (int k = 0; k < 3; k++) {
          if ((1 << k) == remain) {
            if (str[k][i + 1] == '.') {
              add(dp[i + 1][1 << k], dp[i][j]);
            }
          }
        }
        if (remain == 3) {
          add(dp[i + 1][0], dp[i][j]);
          if (str[0][i + 1] == '.' && str[1][i + 1] == '.')
            add(dp[i + 1][3], dp[i][j]);
        }
        if (remain == 6) {
          add(dp[i + 1][0], dp[i][j]);
          if (str[2][i + 1] == '.' && str[1][i + 1] == '.')
            add(dp[i + 1][6], dp[i][j]);
        }
        if (remain == 5) {
          if (str[2][i + 1] == '.' && str[0][i + 1] == '.')
            add(dp[i + 1][5], dp[i][j]);
        }
        if (remain == 7) {
          if (str[2][i + 1] == '.' && str[0][i + 1] == '.' &&
              str[1][i + 1] == '.')
            add(dp[i + 1][7], dp[i][j]);
          if (str[0][i + 1] == '.') add(dp[i + 1][1], dp[i][j]);
          if (str[2][i + 1] == '.') add(dp[i + 1][4], dp[i][j]);
        }
      }
    }
    if (cnt & 1)
      add(ans, dp[n + 1][0]);
    else
      add(ans, -dp[n + 1][0]);
    for (int j = 0; j < m; j++) {
      if (mask & (1 << j)) {
        str[v[j].first.first][v[j].first.second] = '.';
        str[v[j].second.first][v[j].second.second] = '.';
      }
    }
  }
  cout << ans << endl;
  return 0;
}
