#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:258435456");
using namespace std;
int a[1000000];
bool was[10001][8][8];
long long c[10001][8][8];
char d[3][1000000];
int n;
int f(int k, int x, int y) {
  if (k == n) return 1;
  if (x == 7) return f(k + 1, y, a[k + 2]);
  if (!was[k][x][y]) {
    was[k][x][y] = true;
    c[k][x][y] = 0;
    int i = 0;
    while (x & (1 << i)) i++;
    if (!(y & (1 << i)) && !(d[i][k] == 'T' && d[i][k + 1] == 'T'))
      c[k][x][y] += f(k, x + (1 << i), y + (1 << i));
    if ((i < 2) && !(x & (1 << (i + 1))) &&
        !(d[i][k] == 'T' && d[i + 1][k] == 'T'))
      c[k][x][y] += f(k, x + (1 << i) + (1 << (i + 1)), y);
    c[k][x][y] = c[k][x][y] % 1000000007;
  }
  return c[k][x][y];
}
int main() {
  cin >> n;
  char b[3][100000];
  int x, y;
  for (int i = 0; i < 1000000; i++) a[i] = 0;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < n; j++) {
      cin >> b[i][j];
      if (b[i][j] == 'O') x = i, y = j;
      if (b[i][j] != '.') a[j] += (1 << i);
    }
  b[0][n] = b[1][n] = b[2][n] = 'X';
  a[n] = 7;
  memset(d, sizeof(d), '.');
  long long ans = 0;
  if ((y > 1) && (b[x][y - 1] == '.') && (b[x][y - 2] == '.')) {
    for (int i = 0; i < 10001; i++)
      for (int j = 0; j < 8; j++)
        for (int k = 0; k < 8; k++) was[i][j][k] = false;
    a[y - 1] += (1 << x);
    a[y - 2] += (1 << x);
    ans += f(0, a[0], a[1]);
    a[y - 1] -= (1 << x);
    a[y - 2] -= (1 << x);
    d[x][y - 1] = d[x][y - 2] = 'T';
  }
  if ((y < n - 2) && (b[x][y + 1] == '.') && (b[x][y + 2] == '.')) {
    for (int i = 0; i < 10001; i++)
      for (int j = 0; j < 8; j++)
        for (int k = 0; k < 8; k++) was[i][j][k] = false;
    a[y + 1] += (1 << x);
    a[y + 2] += (1 << x);
    ans += f(0, a[0], a[1]);
    a[y + 1] -= (1 << x);
    a[y + 2] -= (1 << x);
    d[x][y + 1] = d[x][y + 2] = 'T';
  }
  if ((x == 0) && (b[x + 1][y] == '.') && (b[x + 2][y] == '.')) {
    for (int i = 0; i < 10001; i++)
      for (int j = 0; j < 8; j++)
        for (int k = 0; k < 8; k++) was[i][j][k] = false;
    a[y] += 6;
    ans += f(0, a[0], a[1]);
    a[y] -= 6;
    d[x + 1][y] = d[x + 2][y] = 'T';
  }
  if ((x == 2) && (b[x - 1][y] == '.') && (b[x - 2][y] == '.')) {
    for (int i = 0; i < 10001; i++)
      for (int j = 0; j < 8; j++)
        for (int k = 0; k < 8; k++) was[i][j][k] = false;
    a[y] += 3;
    ans += f(0, a[0], a[1]);
    a[y] -= 3;
    d[x - 1][y] = d[x - 2][y] = 'T';
  }
  cout << ans % 1000000007;
  return 0;
}
