#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n;
char s[3][10005];
int f[10005][8];
int Mod(int x) { return x < 0 ? x + mod : x < mod ? x : x - mod; }
int Work() {
  memset(f, 0, sizeof(f));
  f[0][7] = 1;
  for (int i = 0; i < n; i++)
    for (int k = 0; k < 8; k++) {
      int S =
          (s[0][i] == 'X') ^ ((s[1][i] == 'X') << 1) ^ ((s[2][i] == 'X') << 2);
      for (int j = 0; j < 8; j += 3)
        if (!(j & k) && !(~(j ^ k) & S))
          f[i + 1][(~j ^ k ^ S) & 7] =
              Mod(f[i + 1][(~j ^ k ^ S) & 7] + f[i][k]);
    }
  return Mod(Mod(f[n][7] + f[n][4]) + f[n][1]);
}
int main() {
  int x, y, ans = 0;
  scanf("%d%s%s%s", &n, s[0], s[1], s[2]);
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < n; j++)
      if (s[i][j] == 'O') x = i, y = j;
  for (int i = 1; i < 8; i++) {
    int t = -1;
    if ((i & 1) &&
            (x == 1 || s[0][y] == 'X' || s[1][y] == 'X' || s[2][y] == 'X') ||
        (i & 2) && (y < 2 || s[x][y - 1] == 'X' || s[x][y - 2] == 'X') ||
        (i & 4) && (y > n - 3 || s[x][y + 1] == 'X' || s[x][y + 2] == 'X'))
      continue;
    if (i & 1) s[0][y] = s[1][y] = s[2][y] = 'X', t = -t;
    if (i & 2) s[x][y - 1] = s[x][y - 2] = 'X', t = -t;
    if (i & 4) s[x][y + 1] = s[x][y + 2] = 'X', t = -t;
    s[x][y] = 'X';
    ans = Mod(ans + t * Work());
    if (i & 1) s[0][y] = s[1][y] = s[2][y] = '.', t = -t;
    if (i & 2) s[x][y - 1] = s[x][y - 2] = '.', t = -t;
    if (i & 4) s[x][y + 1] = s[x][y + 2] = '.', t = -t;
    s[x][y] = 'O';
  }
  printf("%d\n", ans);
}
