#include <bits/stdc++.h>
const int MAXN = 11111, MOD = 1000000007;
char a[5][MAXN];
int n, i, j, d, ox, oy, c[5], f[MAXN][11][2];
void dfs(int k, int tj, bool td) {
  if (k == 3) {
    (f[i + 1][tj][td] += f[i][j][d]) %= MOD;
    return;
  }
  if (c[k]) {
    if (a[k][i + 1] == '.') {
      dfs(k + 1, tj, td);
      if (k < 2 && c[k + 1] && a[k + 1][i + 1] == '.')
        dfs(k + 2, tj + (1 << k) + (1 << k + 1), td || i == oy - 1);
    } else
      dfs(k + 1, tj + (1 << k), td);
  } else if (a[k][i + 1] == '.')
    dfs(k + 1, tj + (1 << k), td || k == ox && (i == oy - 2 || i == oy + 1));
}
int main() {
  int n;
  scanf("%d", &n);
  for (i = 0; i < 3; ++i) {
    scanf(" ");
    for (j = 1; j <= n; ++j)
      if ((a[i][j] = getchar()) == 'O') ox = i, oy = j, a[i][j] = 'X';
  }
  f[0][7][0] = 1;
  for (i = 0; i < n; ++i)
    for (j = 0; j < 8; ++j)
      for (d = 0; d < 2; ++d)
        if (f[i][j][d]) {
          for (int k = 0, t = j; k < 3; ++k, t >>= 1) c[k] = t & 1;
          dfs(0, 0, d);
        }
  printf("%d\n", f[n][7][1]);
  return 0;
}
