#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAX = 10005;
string s[MAX], t[MAX];
int dp[MAX][8], a[4];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
int n;
bool isav(int x, int y) {
  return (0 <= x && x < 3 && 0 <= y && y < n && s[x][y] != 'X');
}
int solve() {
  memset(dp, 0, sizeof(dp));
  int base = 0;
  for (int i = 0; i < 3; i++)
    if (t[i][0] != 'X') base |= (1 << i);
  dp[0][base] = 1;
  a[3] = 1;
  for (int i = 0; i < n - 1; i++)
    for (int mask = 0; mask < 8; mask++)
      for (a[0] = 0; a[0] < 3; a[0]++)
        for (a[1] = 0; a[1] < 3; a[1]++)
          for (a[2] = 0; a[2] < 3; a[2]++) {
            bool valid = true;
            for (int j = 0; j < 3; j++)
              if (a[j] == 2 && a[j + 1] > 0) {
                valid = false;
                break;
              }
            if (!valid) continue;
            int cur = 0, next = 0;
            for (int j = 0; j < 3; j++)
              if (a[j] == 1) {
                cur |= (1 << j);
                next |= (1 << j);
              } else if (a[j] == 2)
                cur |= ((1 << j) | (1 << (j + 1)));
            if (cur != mask) continue;
            int nmask = 7;
            valid = true;
            for (int j = 0; j < 3; j++)
              if (t[j][i + 1] == 'X') {
                if ((1 << j) & next) {
                  valid = false;
                  break;
                }
                nmask ^= (1 << j);
              } else if ((1 << j) & next)
                nmask ^= (1 << j);
            if (valid)
              dp[i + 1][nmask] = (dp[i + 1][nmask] + dp[i][mask]) % MOD;
          }
  return dp[n - 1][0];
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < 3; i++) {
    cin >> s[i];
    s[i] += 'X';
  }
  n++;
  int x, y;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < n; j++)
      if (s[i][j] == 'O') {
        x = i;
        y = j;
        break;
      }
  int ans = 0;
  for (int mask = 1; mask < 16; mask++) {
    for (int i = 0; i < 3; i++) t[i] = s[i];
    t[x][y] = 'X';
    bool valid = true;
    for (int i = 0; i < 4 && valid; i++)
      if ((1 << i) & mask) {
        int nx = x, ny = y;
        for (int j = 0; j < 2; j++) {
          nx += dx[i];
          ny += dy[i];
          if (!isav(nx, ny)) {
            valid = false;
            break;
          }
          t[nx][ny] = 'X';
        }
      }
    if (!valid) continue;
    if (__builtin_popcount(mask) & 1)
      ans = (ans + solve()) % MOD;
    else
      ans = (ans - solve() + MOD) % MOD;
  }
  cout << ans << endl;
  return 0;
}
