#include <bits/stdc++.h>
using namespace std;
int s[10050][10], n, m, st, li[10][10], S, T, ans;
bool c[10][10050];
char b[10050];
void Solve(int x) {
  s[0][7] = 1;
  c[1][0] = c[2][0] = c[3][0] = 1;
  c[S][T] = 1;
  for (int i = 1; i <= n; i++) {
    s[i][0] = s[i - 1][7];
    s[i][1] = !c[1][i - 1] ? s[i - 1][6] : 0;
    s[i][2] = !c[2][i - 1] ? s[i - 1][5] : 0;
    s[i][3] = s[i - 1][7] + (c[1][i - 1] || c[2][i - 1] ? 0 : s[i - 1][4]);
    s[i][4] = !c[3][i - 1] ? s[i - 1][3] : 0;
    s[i][5] = !c[3][i - 1] && !c[1][i - 1] ? s[i - 1][2] : 0;
    s[i][6] = s[i - 1][7] + (c[2][i - 1] || c[3][i - 1] ? 0 : s[i - 1][1]);
    s[i][7] = c[1][i - 1] || c[2][i - 1] || c[3][i - 1] ? 0 : s[i - 1][0];
    if (!c[1][i - 1]) s[i][7] += s[i - 1][6];
    s[i][3] %= 1000000007;
    s[i][6] %= 1000000007;
    s[i][7] %= 1000000007;
    if (!c[3][i - 1]) s[i][7] += s[i - 1][3];
    s[i][7] %= 1000000007;
    int k = c[1][i] + c[2][i] * 2 + c[3][i] * 4;
    if (k == 1)
      s[i][1] = s[i][0], s[i][3] = s[i][2], s[i][5] = s[i][4],
      s[i][7] = s[i][6], s[i][0] = s[i][2] = s[i][4] = s[i][6] = 0;
    else if (k == 2)
      s[i][2] = s[i][0], s[i][3] = s[i][1], s[i][6] = s[i][4],
      s[i][7] = s[i][5], s[i][0] = s[i][1] = s[i][4] = s[i][5] = 0;
    else if (k == 3)
      s[i][3] = s[i][0], s[i][7] = s[i][4],
      s[i][0] = s[i][1] = s[i][2] = s[i][4] = s[i][5] = s[i][6] = 0;
    else if (k == 4)
      s[i][4] = s[i][0], s[i][5] = s[i][1], s[i][6] = s[i][2],
      s[i][7] = s[i][3], s[i][0] = s[i][1] = s[i][2] = s[i][3] = 0;
    else if (k == 5)
      s[i][5] = s[i][0], s[i][7] = s[i][2],
      s[i][0] = s[i][1] = s[i][2] = s[i][3] = s[i][4] = s[i][6] = 0;
    else if (k == 6)
      s[i][6] = s[i][0], s[i][7] = s[i][1],
      s[i][0] = s[i][1] = s[i][2] = s[i][3] = s[i][4] = s[i][5] = 0;
    else if (k == 7)
      s[i][7] = s[i][0],
      s[i][0] = s[i][1] = s[i][2] = s[i][3] = s[i][4] = s[i][5] = s[i][6] = 0;
  }
  ans = (ans + (x & 1 ? s[n][7] : -s[n][7])) % 1000000007;
  ans = (ans + 1000000007) % 1000000007;
}
void DFS(int x, int y) {
  if (x > st) {
    if (y) Solve(y);
    return;
  }
  c[li[x][0]][li[x][1]] = 1;
  c[li[x][2]][li[x][3]] = 1;
  DFS(x + 1, y + 1);
  c[li[x][0]][li[x][1]] = 0;
  c[li[x][2]][li[x][3]] = 0;
  DFS(x + 1, y);
}
inline void Push(int x, int y, int z, int o) {
  li[++st][0] = x;
  li[st][1] = y;
  li[st][2] = z;
  li[st][3] = o;
}
int main() {
  cin >> n;
  for (int i = 1; i <= 3; i++) {
    scanf("%s", b);
    for (int j = 0; j < n; j++)
      if (b[j] != 'O')
        c[i][j + 1] = b[j] == 'X';
      else
        S = i, T = j + 1;
  }
  if (S == 3 && !c[2][T] && !c[1][T])
    Push(1, T, 2, T);
  else if (S == 1 && !c[2][T] && !c[3][T])
    Push(2, T, 3, T);
  if (T >= 3 && !c[S][T - 2] && !c[S][T - 1]) Push(S, T - 2, S, T - 1);
  if (T <= n - 2 && !c[S][T + 1] && !c[S][T + 2]) Push(S, T + 1, S, T + 2);
  DFS(1, 0);
  cout << ans << endl;
  return 0;
}
