#include <bits/stdc++.h>
using namespace std;
int n;
char str[5][11000];
bool mp[5][11000];
int f[11000][8][2];
int pang[11000];
int cx, cy;
inline void A(int &x, int y) {
  x += y;
  if (x >= 1000000007) x -= 1000000007;
}
inline bool put(int x1, int y1, int x2, int y2) {
  if (x1 > 3 || x2 > 3 || y1 > n || y2 > n) return 0;
  if (x1 == x2) {
    if (y2 < y1) swap(y1, y2);
    if (y1 - 1 == cy || y2 + 1 == cy)
      return 1;
    else
      return 0;
  }
  if (y1 == y2) {
    if (cx == 2) return 0;
    if (y1 != cy) return 0;
    if (x1 + x2 == 7 - cx)
      return 1;
    else
      return 0;
  }
}
int dfs(int now, int zt, int flag) {
  if (now == n + 1) return (!zt) && flag;
  if (f[now][zt][flag] != -1) return f[now][zt][flag];
  f[now][zt][flag] = 0;
  if (zt == 1) {
    A(f[now][zt][flag],
      dfs(now + 1, pang[now + 1], flag | put(2, now, 3, now)));
    if (!(6 & pang[now + 1]))
      A(f[now][zt][flag],
        dfs(now + 1, pang[now + 1] | 6,
            flag | put(2, now, 2, now + 1) | put(3, now, 3, now + 1)));
  }
  if (zt == 5) {
    if (!(2 & pang[now + 1]))
      A(f[now][zt][flag],
        dfs(now + 1, pang[now + 1] | 2, flag | put(2, now, 2, now + 1)));
  }
  if (zt == 7) return f[now][zt][flag] = dfs(now + 1, pang[now + 1], flag);
  if (zt == 4) {
    A(f[now][zt][flag],
      dfs(now + 1, pang[now + 1], flag | put(2, now, 1, now)));
    if (!(3 & pang[now + 1]))
      A(f[now][zt][flag],
        dfs(now + 1, pang[now + 1] | 3,
            flag | put(2, now, 2, now + 1) | put(1, now, 1, now + 1)));
  }
  if (zt == 3) {
    if (!(4 & pang[now + 1]))
      A(f[now][zt][flag],
        dfs(now + 1, pang[now + 1] | 4, flag | put(3, now, 3, now + 1)));
  }
  if (zt == 6) {
    if (!(1 & pang[now + 1]))
      A(f[now][zt][flag],
        dfs(now + 1, pang[now + 1] | 1, flag | put(1, now, 1, now + 1)));
  }
  if (zt == 0) {
    if (!(7 & pang[now + 1]))
      A(f[now][zt][flag],
        dfs(now + 1, pang[now + 1] | 7,
            flag | put(1, now, 1, now + 1) | put(2, now, 2, now + 1) |
                put(3, now, 3, now + 1)));
    if (!(1 & pang[now + 1]))
      A(f[now][zt][flag],
        dfs(now + 1, pang[now + 1] | 1,
            flag | put(2, now, 2, now + 1) | put(3, now, 3, now + 1)));
    if (!(4 & pang[now + 1]))
      A(f[now][zt][flag],
        dfs(now + 1, pang[now + 1] | 4,
            flag | put(1, now, 1, now + 1) | put(2, now, 2, now + 1)));
  }
  if (zt == 2) {
    if (!(5 & pang[now + 1]))
      A(f[now][zt][flag],
        dfs(now + 1, pang[now + 1] | 5,
            flag | put(1, now, 1, now + 1) | put(3, now, 3, now + 1)));
  }
  return f[now][zt][flag];
}
void DEBUG() { printf("__%d\n", dfs(3, 2, 1)); }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= 3; i++) scanf("%s", str[i] + 1);
  int ans = 0;
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= n; j++)
      if (str[i][j] == 'O') {
        mp[i][j] = 0;
        cx = i;
        cy = j;
      } else
        mp[i][j] = (str[i][j] == '.');
  memset(f, -1, sizeof f);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 3; j++) pang[i] += (1 << (j - 1)) * (!mp[j][i]);
  printf("%d\n", dfs(1, pang[1], 0));
  return 0;
}
