#include <bits/stdc++.h>
using namespace std;
int neigh[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
char a[3][100000];
char a1[3][100000];
int d[100000][8];
int n;
int solve1(int x, int bit) {
  int i, j, bit2, ans;
  if (x == n) {
    if (bit == 0)
      return 1;
    else
      return 0;
  }
  if (d[x][bit] != -1) return d[x][bit];
  for (i = 0; i < 3; i++)
    if ((((1 << i) & bit) != 0) && (a[i][x] != '.')) {
      d[x][bit] = 0;
      return 0;
    }
  ans = 0;
  bit2 = 0;
  for (i = 0; i < 3; i++)
    if ((((1 << i) & bit) == 0) && (a[i][x] == '.')) {
      bit2 |= (1 << i);
    }
  ans += solve1(x + 1, bit2);
  if (ans >= 1000000007) ans -= 1000000007;
  if (((3 & bit) == 0) && (a[0][x] == '.') && (a[1][x] == '.')) {
    bit2 = 0;
    if (((4 & bit) == 0) && (a[2][x] == '.')) bit2 |= 4;
    ans += solve1(x + 1, bit2);
    if (ans >= 1000000007) ans -= 1000000007;
  }
  if (((6 & bit) == 0) && (a[1][x] == '.') && (a[2][x] == '.')) {
    bit2 = 0;
    if (((1 & bit) == 0) && (a[0][x] == '.')) bit2 |= 1;
    ans += solve1(x + 1, bit2);
    if (ans >= 1000000007) ans -= 1000000007;
  }
  d[x][bit] = ans;
  return ans;
}
int main() {
  int b1, i, j, k, sx, sy, ans, tmp, x1, y1, x2, y2, cnt;
  scanf("%d", &n);
  for (i = 0; i < 3; i++) scanf("%s", a[i]);
  memcpy(a1, a, sizeof(a));
  for (i = 0; i < 3; i++)
    for (j = 0; j < n; j++)
      if (a[i][j] == 'O') {
        sx = i;
        sy = j;
      }
  ans = 0;
  for (i = 0; i < (1 << 4); i++) {
    memcpy(a, a1, sizeof(a1));
    cnt = 0;
    b1 = 1;
    for (j = 0; j < 4; j++)
      if (((1 << j) & i) != 0) {
        x1 = sx + neigh[j][0];
        y1 = sy + neigh[j][1];
        x2 = x1 + neigh[j][0];
        y2 = y1 + neigh[j][1];
        if ((x1 >= 0) && (x1 < 3) && (y1 >= 0) && (y1 < n) && (x2 >= 0) &&
            (x2 < 3) && (y2 >= 0) && (y2 < n) && (a[x1][y1] == '.') &&
            (a[x2][y2] == '.')) {
          a[x1][y1] = 'X';
          a[x2][y2] = 'X';
          cnt++;
        } else
          b1 = 0;
      }
    if ((b1 == 0) || (cnt == 0)) continue;
    memset(d, -1, sizeof(d));
    tmp = solve1(0, 0);
    if (cnt % 2 == 1)
      ans += tmp;
    else
      ans -= tmp;
    ans = (ans % 1000000007 + 1000000007) % 1000000007;
  }
  printf("%d\n", ans);
}
