#include <bits/stdc++.h>
using namespace std;
int fix[12][3] = {{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1},
                  {2, 2, 0}, {0, 2, 2}, {1, 1, 0}, {1, 0, 1},
                  {0, 1, 1}, {1, 2, 2}, {2, 2, 1}, {1, 1, 1}};
int bit(int x, int k) { return (x >> k) & 1; }
int main() {
  int N;
  cin >> N;
  char puzzle[3][10100] = {'\0'};
  int ox = 0, oy = 0;
  for (int i = 0; i < 3; ++i)
    for (int j = 1; j <= N; ++j) {
      cin >> puzzle[i][j];
      if (puzzle[i][j] == 'O') {
        ox = i;
        oy = j;
      }
    }
  int st[10100] = {0};
  for (int j = 1; j <= N; ++j)
    for (int i = 0; i < 3; ++i)
      if (puzzle[i][j] != '.') st[j] |= (1 << i);
  int f[10100][11][2] = {1};
  for (int j = 1; j <= N; ++j) {
    for (int mask = 0; mask < 8; ++mask) {
      if ((mask | st[j]) != mask) continue;
      for (int k = 0; k < 12; ++k) {
        bool ok = true;
        int lastMask = st[j - 1], newMask = mask;
        for (int t = 0; t < 3; ++t) switch (fix[k][t]) {
            case 1:
              ok &= !bit(mask, t) & !bit(lastMask, t);
              lastMask |= 1 << t;
              newMask |= 1 << t;
              break;
            case 2:
              ok &= !bit(mask, t);
              newMask |= (1 << t);
              break;
          }
        if (!ok || newMask != 7) continue;
        if (j == 2 && mask == 0) int tmp = 5;
        bool moveLeft = (oy == j && fix[k][1] == 2);
        if (oy - 1 == j) moveLeft |= (fix[k][ox] == 1);
        if (oy + 2 == j) moveLeft |= (fix[k][ox] == 1);
        f[j][mask][1] += f[j - 1][lastMask][1];
        if (moveLeft)
          f[j][mask][moveLeft] += f[j - 1][lastMask][0];
        else
          f[j][mask][0] += f[j - 1][lastMask][0];
        if (f[j][mask][0] >= 1000000007) f[j][mask][0] -= 1000000007;
        if (f[j][mask][1] >= 1000000007) f[j][mask][1] -= 1000000007;
      }
    }
  }
  int res = f[N][st[N]][1];
  cout << res << endl;
  return 0;
}
