#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:666000000")
using namespace std;
const int inf = (1 << 30) - 1;
const long double eps = 1e-9;
const long double pi = fabs(atan2(0.0, -1.0));
void ML(const bool v) {
  if (v) return;
  int *ass;
  for (;;) {
    ass = new int[2500000];
    for (int i = 0; i < 2500000; i++) ass[i] = rand();
  }
}
void TL(const bool v) {
  if (v) return;
  int *ass;
  ass = new int[250];
  for (;;) {
    for (int i = 0; i < 250; i++) ass[i] = rand();
  }
}
void PE(const bool v) {
  if (v) return;
  puts("ass 1 2 3 4 5 6 fuck");
  exit(0);
}
int n;
char c[3][10400];
void LoAd() {
  scanf("%d\n", &n);
  for (int i = 0; i < 3; i++) gets(c[i]);
}
const int MOD = 1000000007;
int sv[10022][8][2];
bool can(const int i, const int j, const int mask) {
  return '.' == c[i][j] && !(((mask) & (1 << (i))) == 0 ? false : true);
}
int cok(const int pos, const int ok, const int mask) {
  if (1 == ok) return 1;
  for (int i = 0; i < 3; i++) {
    if (!(((mask) & (1 << (i))) == 0 ? false : true)) continue;
    if ('O' == c[i][pos - 1] || 'O' == c[i][pos + 2]) return 1;
  }
  return 0;
}
int rec(const int pos, const int mask, const int ok) {
  if (pos == n) {
    if (ok && 0 == mask)
      return 1;
    else
      return 0;
  }
  for (int i = 0; i < 3; i++)
    if ((((mask) & (1 << (i))) == 0 ? false : true) && c[i][pos] != '.')
      return 0;
  int &res = sv[pos][mask][ok];
  if (-1 != res) return res;
  res = 0;
  if (can(0, pos, mask) && can(1, pos, mask) && can(2, pos, mask)) {
    res = (res + rec(pos + 1, 7, cok(pos, ok, 7))) % MOD;
    res = (res + rec(pos + 1, 1, cok(pos, ok, 1))) % MOD;
    res = (res + rec(pos + 1, 4, cok(pos, ok, 4))) % MOD;
  }
  if (can(0, pos, mask) && !can(1, pos, mask) && !can(2, pos, mask)) {
    res = (res + rec(pos + 1, 1, cok(pos, ok, 1))) % MOD;
  }
  if (!can(0, pos, mask) && can(1, pos, mask) && !can(2, pos, mask)) {
    res = (res + rec(pos + 1, 2, cok(pos, ok, 2))) % MOD;
  }
  if (!can(0, pos, mask) && !can(1, pos, mask) && can(2, pos, mask)) {
    res = (res + rec(pos + 1, 4, cok(pos, ok, 4))) % MOD;
  }
  if (!can(0, pos, mask) && can(1, pos, mask) && can(2, pos, mask)) {
    res = (res + rec(pos + 1, 0, max(ok, 'O' == c[0][pos] ? 1 : 0))) % MOD;
    res = (res + rec(pos + 1, 6, cok(pos, ok, 6))) % MOD;
  }
  if (can(0, pos, mask) && !can(1, pos, mask) && can(2, pos, mask)) {
    res = (res + rec(pos + 1, 5, cok(pos, ok, 5))) % MOD;
  }
  if (can(0, pos, mask) && can(1, pos, mask) && !can(2, pos, mask)) {
    res = (res + rec(pos + 1, 0, max(ok, 'O' == c[2][pos] ? 1 : 0))) % MOD;
    res = (res + rec(pos + 1, 3, cok(pos, ok, 3))) % MOD;
  }
  if (!can(0, pos, mask) && !can(1, pos, mask) && !can(2, pos, mask)) {
    res = (res + rec(pos + 1, 0, cok(pos, ok, 0))) % MOD;
  }
  return res;
}
void SoLvE() {
  memset(sv, -1, sizeof(sv));
  int res = rec(0, 0, 0);
  cout << res % MOD;
}
int main() {
  srand((int)time(NULL));
  LoAd();
  SoLvE();
  return 0;
}
