#include <bits/stdc++.h>
using namespace std;
int n;
char tab[3][10005];
bool check(int pos, int a) { return pos < n && tab[a][pos] == 'O'; }
bool check(int pos, int a, int b) {
  return pos < n && (tab[a][pos] == 'O' || tab[b][pos] == 'O');
}
bool check(int pos, int a, int b, int c) {
  return pos < n &&
         (tab[a][pos] == 'O' || tab[b][pos] == 'O' || tab[c][pos] == 'O');
}
bool ok(int pos, int a) { return pos < n && tab[a][pos] == '.'; }
bool ok(int pos, int a, int b) {
  return pos < n && tab[a][pos] == '.' && tab[b][pos] == '.';
}
bool ok(int pos, int a, int b, int c) {
  return pos < n && tab[a][pos] == '.' && tab[b][pos] == '.' &&
         tab[c][pos] == '.';
}
const int mod = (int)1e9 + 7;
int dp[10005][8][2];
bool vis[10005][8][2];
int solve(int pos, int mask, int valid) {
  if (pos == n) return valid;
  for (int i = 0; i < 3; ++i)
    if (tab[i][pos] != '.') mask |= (1 << i);
  if (vis[pos][mask][valid]) return dp[pos][mask][valid];
  vis[pos][mask][valid] = 1;
  int answer = 0;
  int newvalid;
  if (mask == 0) {
    newvalid = valid;
    if (check(pos + 2, 0, 1, 2) || check(pos - 1, 0, 1, 2)) newvalid = 1;
    if (ok(pos + 1, 0, 1, 2))
      answer += solve(pos + 1, 7, newvalid), answer %= mod;
    newvalid = valid;
    if (check(pos + 2, 0) || check(pos - 1, 0)) newvalid = 1;
    if (ok(pos + 1, 0)) answer += solve(pos + 1, 1, newvalid), answer %= mod;
    newvalid = valid;
    if (check(pos + 2, 2) || check(pos - 1, 2)) newvalid = 1;
    if (ok(pos + 1, 2)) answer += solve(pos + 1, 4, newvalid), answer %= mod;
  }
  if (mask == 1) {
    newvalid = valid;
    if (check(pos, 0)) newvalid = 1;
    answer += solve(pos + 1, 0, newvalid), answer %= mod;
    newvalid = valid;
    if (check(pos + 2, 1, 2) || check(pos - 1, 1, 2)) newvalid = 1;
    if (ok(pos + 1, 1, 2)) answer += solve(pos + 1, 6, newvalid), answer %= mod;
  }
  if (mask == 2) {
    newvalid = valid;
    if (check(pos + 2, 0, 2) || check(pos - 1, 0, 2)) newvalid = 1;
    if (ok(pos + 1, 0, 2)) answer += solve(pos + 1, 5, newvalid), answer %= mod;
  }
  if (mask == 3) {
    newvalid = valid;
    if (check(pos + 2, 2) || check(pos - 1, 2)) newvalid = 1;
    if (ok(pos + 1, 2)) answer += solve(pos + 1, 4, newvalid), answer %= mod;
  }
  if (mask == 4) {
    newvalid = valid;
    if (check(pos, 2)) newvalid = 1;
    answer += solve(pos + 1, 0, newvalid), answer %= mod;
    newvalid = valid;
    if (check(pos + 2, 0, 1) || check(pos - 1, 0, 1)) newvalid = 1;
    if (ok(pos + 1, 0, 1)) answer += solve(pos + 1, 3, newvalid), answer %= mod;
  }
  if (mask == 5) {
    newvalid = valid;
    if (check(pos + 2, 1) || check(pos - 1, 1)) newvalid = 1;
    if (ok(pos + 1, 1)) answer += solve(pos + 1, 2, newvalid), answer %= mod;
  }
  if (mask == 6) {
    newvalid = valid;
    if (check(pos + 2, 0) || check(pos - 1, 0)) newvalid = 1;
    if (ok(pos + 1, 0)) answer += solve(pos + 1, 1, newvalid), answer %= mod;
  }
  if (mask == 7) {
    answer += solve(pos + 1, 0, valid), answer %= mod;
  }
  return dp[pos][mask][valid] = answer;
}
int main() {
  cin >> n;
  for (int i = 0; i < 3; ++i) scanf("%s", tab[i]);
  cout << solve(0, 0, 0) << endl;
  return 0;
}
