#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e4 + 10, Mod = 1e9 + 7;
int dp[Maxn][(1 << (3))];
char str[3][Maxn];
int n;
int ox, oy;
int dirx[] = {-1, 0, 1, 0};
int diry[] = {0, 1, 0, -1};
bool valid(int x, int y) { return x >= 0 && x < 3 && y >= 1 && y <= n; }
bool check(int dx, int dy) {
  for (int i = 1; i <= 2; ++i) {
    if (!valid(ox + dx * i, oy + dy * i)) return false;
    if (str[ox + dx * i][oy + dy * i] != '.') return false;
  }
  return true;
}
void update(int dx, int dy) {
  for (int i = 1; i <= 2; ++i) {
    str[ox + dx * i][oy + dy * i] = 'X';
  }
}
void resume(int dx, int dy) {
  for (int i = 1; i <= 2; ++i) {
    str[ox + dx * i][oy + dy * i] = '.';
  }
}
bool check(int col, int s1, int s2) {
  int s = 0;
  for (int i = 0; i < 3; ++i) {
    if (str[i][col] != 'X') s |= (1 << (i));
  }
  if ((s2 | s) != s) return false;
  for (int i = 0; i < 3; ++i) {
    if (((1 << (i)) & s1) == 0 && str[i][col - 1] == '.' &&
        ((1 << (i)) & s2) == 0)
      return false;
  }
  int c = 0;
  for (int i = 0; i < 3; ++i) {
    if (((1 << (i)) & s2) && (((1 << (i)) & s1) != 0 || str[i][col - 1] == 'X'))
      c |= (1 << (i));
  }
  return (c == 0 || c == 3 || c == 6);
}
int solve() {
  memset(dp, 0, sizeof(dp));
  dp[0][7] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < (1 << (3)); ++j) {
      if (dp[i - 1][j] == 0) continue;
      for (int k = 0; k < (1 << (3)); ++k) {
        if (!check(i, j, k)) continue;
        dp[i][k] = (dp[i][k] + dp[i - 1][j]) % Mod;
      }
    }
  }
  int s = 0;
  for (int i = 0; i < 3; ++i) {
    if (str[i][n] == '.') s |= (1 << (i));
  }
  return dp[n][s];
}
int count(int x) {
  int ret = 0;
  for (int i = 0; (1 << (i)) <= x; ++i)
    if ((1 << (i)) & x) ret++;
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 3; ++i) {
    scanf("%s", str[i] + 1);
    for (int j = 1; j <= n; ++j)
      if (str[i][j] == 'O') {
        ox = i, oy = j;
        str[i][j] = 'X';
      }
  }
  int ans = 0;
  for (int s = 1; s < 16; ++s) {
    bool ok = 1;
    for (int i = 0; i < 4; ++i) {
      if ((s & (1 << (i))) == 0) continue;
      if (!check(dirx[i], diry[i])) {
        ok = 0;
        break;
      }
    }
    if (!ok) continue;
    for (int i = 0; i < 4; ++i) {
      if ((s & (1 << (i))) == 0) continue;
      update(dirx[i], diry[i]);
    }
    if (count(s) % 2 == 1)
      ans = (ans + solve()) % Mod;
    else
      ans = (ans - solve() + Mod) % Mod;
    for (int i = 0; i < 4; ++i) {
      if ((s & (1 << (i))) == 0) continue;
      resume(dirx[i], diry[i]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
