#include <bits/stdc++.h>
using namespace std;
int f[6][10500];
char s[10500];
int n, ox, oy;
long long ans;
map<pair<int, int>, int> m;
map<pair<int, int>, int>::iterator it;
void dbg(int k = n) {
  for (int i = 1; i <= 3; ++i) {
    char c;
    for (int j = 1; j <= k; ++j) {
      if (f[i][j])
        c = '#';
      else
        c = '.';
      if (i == oy && j == ox) c = 'O';
      printf("%c", c);
    }
    printf("\n");
  }
  printf("\n");
}
int rec(int x, int y) {
  int nx, ny, mask;
  if (x == n + 1) return 1;
  if (y == 1) {
    mask = f[1][x] | (f[2][x] << 1) | (f[3][x] << 2);
    it = m.find(make_pair(x, mask));
    if (it != m.end()) return it->second;
  }
  int tmp = 0;
  if (f[y][x] == 0) {
    if (f[y][x] == 0 && f[y][x + 1] == 0) {
      f[y][x] = f[y][x + 1] = 1;
      ny = y + 1;
      nx = x;
      if (ny == 4) {
        nx++;
        ny = 1;
      }
      tmp = tmp + rec(nx, ny);
      if (tmp >= 1000000007) tmp -= 1000000007;
      f[y][x] = f[y][x + 1] = 0;
    }
    if (f[y][x] == 0 && f[y + 1][x] == 0) {
      f[y][x] = f[y + 1][x] = 1;
      ny = y + 2;
      nx = x;
      if (ny == 4) {
        nx++;
        ny = 1;
      }
      tmp = tmp + rec(nx, ny);
      if (tmp >= 1000000007) tmp -= 1000000007;
      f[y][x] = f[y + 1][x] = 0;
    }
  } else {
    ny = y + 1;
    nx = x;
    if (ny == 4) ny = 1, nx++;
    tmp = rec(nx, ny);
  }
  if (y == 1) {
    m[make_pair(x, mask)] = tmp;
  }
  return tmp;
}
int solve() {
  m.clear();
  return rec(1, 1);
}
long long go5(int cnt) {
  if (cnt > 0) {
    return solve();
  } else {
    return 0;
  }
}
long long go4(int cnt) {
  long long tmp = 0;
  if (oy <= 1 && !f[oy + 1][ox] && !f[oy + 2][ox]) {
    f[oy + 1][ox] = f[oy + 2][ox] = 1;
    tmp += go5(cnt + 1);
    f[oy + 1][ox] = f[oy + 2][ox] = 0;
  }
  if (f[oy + 1][ox]) tmp += go5(cnt);
  if (!f[oy + 1][ox] && !f[oy + 1][ox - 1]) {
    f[oy + 1][ox] = f[oy + 1][ox - 1] = 1;
    tmp += go5(cnt);
    f[oy + 1][ox] = f[oy + 1][ox - 1] = 0;
  }
  if (!f[oy + 1][ox] && !f[oy + 1][ox + 1]) {
    f[oy + 1][ox] = f[oy + 1][ox + 1] = 1;
    tmp += go5(cnt);
    f[oy + 1][ox] = f[oy + 1][ox + 1] = 0;
  }
  return tmp;
}
long long go3(int cnt) {
  long long tmp = 0;
  if (oy >= 3 && !f[oy - 1][ox] && !f[oy - 2][ox]) {
    f[oy - 1][ox] = f[oy - 2][ox] = 1;
    tmp += go4(cnt + 1);
    f[oy - 1][ox] = f[oy - 2][ox] = 0;
  }
  if (f[oy - 1][ox]) tmp += go4(cnt);
  if (!f[oy - 1][ox] && !f[oy - 1][ox - 1]) {
    f[oy - 1][ox] = f[oy - 1][ox - 1] = 1;
    tmp += go4(cnt);
    f[oy - 1][ox] = f[oy - 1][ox - 1] = 0;
  }
  if (!f[oy - 1][ox] && !f[oy - 1][ox + 1]) {
    f[oy - 1][ox] = f[oy - 1][ox + 1] = 1;
    tmp += go4(cnt);
    f[oy - 1][ox] = f[oy - 1][ox + 1] = 0;
  }
  return tmp;
}
long long go2(int cnt) {
  long long tmp = 0;
  if (!f[oy][ox + 1] && !f[oy][ox + 2]) {
    f[oy][ox + 1] = f[oy][ox + 2] = 1;
    tmp += go3(cnt + 1);
    f[oy][ox + 1] = f[oy][ox + 2] = 0;
  }
  if (f[oy][ox + 1]) tmp += go3(cnt);
  if (oy >= 2 && !f[oy][ox + 1] && !f[oy - 1][ox + 1]) {
    f[oy][ox + 1] = f[oy - 1][ox + 1] = 1;
    tmp += go3(cnt);
    f[oy][ox + 1] = f[oy - 1][ox + 1] = 0;
  }
  if (oy <= 2 && !f[oy][ox + 1] && !f[oy + 1][ox + 1]) {
    f[oy][ox + 1] = f[oy + 1][ox + 1] = 1;
    tmp += go3(cnt);
    f[oy][ox + 1] = f[oy + 1][ox + 1] = 0;
  }
  return tmp;
}
long long go1(int cnt) {
  long long tmp = 0;
  if (ox >= 3 && !f[oy][ox - 1] && !f[oy][ox - 2]) {
    f[oy][ox - 1] = f[oy][ox - 2] = 1;
    tmp += go2(cnt + 1);
    f[oy][ox - 1] = f[oy][ox - 2] = 0;
  }
  if (f[oy][ox - 1]) tmp += go2(cnt);
  if (oy >= 2 && !f[oy][ox - 1] && !f[oy - 1][ox - 1]) {
    f[oy][ox - 1] = f[oy - 1][ox - 1] = 1;
    tmp += go2(cnt);
    f[oy][ox - 1] = f[oy - 1][ox - 1] = 0;
  }
  if (oy <= 2 && !f[oy][ox - 1] && !f[oy + 1][ox - 1]) {
    f[oy][ox - 1] = f[oy + 1][ox - 1] = 1;
    tmp += go2(cnt);
    f[oy][ox - 1] = f[oy + 1][ox - 1] = 0;
  }
  return tmp;
}
int main() {
  int tc;
  scanf("%i", &n);
  for (int i = 0; i < 6; ++i)
    for (int j = 0; j < 10500; ++j) f[i][j] = 1;
  for (int i = 1; i <= 3; ++i) {
    scanf("%s", s);
    for (int j = 0; j < n; ++j) {
      if (s[j] == '.') {
        f[i][j + 1] = 0;
      } else if (s[j] == 'X') {
        f[i][j + 1] = 1;
      } else if (s[j] == 'O') {
        f[i][j + 1] = 1;
        oy = i;
        ox = j + 1;
      }
    }
  }
  int x = go1(0) % 1000000007;
  printf("%i\n", x);
  return 0;
}
