#include <bits/stdc++.h>
const int maxn = 10010;
const int mod = 1000000007;
int n;
char ch[4][maxn];
int f[maxn][8][2];
int obs[maxn];
int ot, vt;
void part0() {
  memset(obs, 0, sizeof(obs));
  for (int j = 1; j <= n; j++)
    for (int i = 3; i >= 1; i--)
      obs[j] = (obs[j] << 1) + ((ch[i][j] != '.') ? 1 : 0);
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= n; j++)
      if (ch[i][j] == 'O') {
        ot = j;
        vt = 1 << (i - 1);
      }
}
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= 3; i++) scanf("%s", ch[i] + 1);
}
void solve() {
  part0();
  memset(f, 0, sizeof(f));
  f[0][7][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 8; j++)
      for (int k = 0; k < 2; k++) {
        if (!f[i - 1][j][k]) continue;
        int cnt = j ^ 7;
        if (cnt & obs[i]) continue;
        int oc = cnt | obs[i];
        for (int c = 0; c <= 6; c += 3) {
          if (oc & c) continue;
          int oct = oc | c;
          if ((i == ot - 1) && (cnt & vt) ||
              (i == ot) && (!(oc ^ vt)) && (vt != 2) ||
              (i - 2 == ot) && (cnt & vt)) {
            f[i][oct][1] = (f[i][oct][1] + f[i - 1][j][k]) % mod;
          } else
            f[i][oct][k] = (f[i][oct][k] + f[i - 1][j][k]) % mod;
        }
      }
}
void print() { printf("%d\n", f[n][7][1]); }
int main() {
  init();
  solve();
  print();
  return 0;
}
