#include <bits/stdc++.h>
using namespace std;
long long mod = 1000 * 1000 * 1000 + 7;
int to[9][9];
int check(int a, int b) {
  for (int i = 0; i < 3; i++) {
    int ca = (a & (1 << i));
    int cb = (b & (1 << i));
    if (ca && cb) {
      return 0;
    }
    if (ca == 0 && cb == 0) {
      if (i == 2) {
        return 0;
      } else {
        int na = (a & (1 << (i + 1)));
        int nb = (b & (1 << (i + 1)));
        if (na == 0 && nb == 0) {
          a = (a | (1 << (i + 1)));
        } else {
          return 0;
        }
      }
    }
  }
  return 1;
}
void init() {
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      to[i][j] = check(i, j);
    }
  }
}
int din(vector<vector<int> > p) {
  vector<vector<int> > d;
  d.resize(9);
  for (int i = 0; i < 9; i++) {
    d[i] = vector<int>(p[0].size() + 1, 0);
  }
  d[(p[0][0] * 1 + p[1][0] * 2 + p[2][0] * 4)][0] = 1;
  for (unsigned int i = 0; i < d[0].size() - 1; i++) {
    int t = 0;
    if (i + 1 < p[0].size())
      t = (p[0][i + 1] * 1 + p[1][i + 1] * 2 + p[2][i + 1] * 4);
    for (unsigned int j = 0; j < (1 << 3); j++) {
      for (int u = 0; u < (1 << 3); u++) {
        if (to[j][u] && (t & u) == 0) {
          d[(t | u)][i + 1] = (d[(t | u)][i + 1] + d[j][i]) % mod;
        }
      }
    }
  }
  return d[0][d[0].size() - 1];
}
int n, cx, cy;
vector<vector<int> > base, cur;
bool up() {
  if (cx != 2 || base[cx - 1][cy] == 1 || base[cx - 2][cy] == 1) return false;
  base[cx - 1][cy] = 1;
  base[cx - 2][cy] = 1;
  return true;
}
bool down() {
  if (cx != 0 || base[cx + 1][cy] == 1 || base[cx + 2][cy] == 1) return false;
  base[cx + 1][cy] = 1;
  base[cx + 2][cy] = 1;
  return true;
}
bool left() {
  if (cy < 2 || base[cx][cy - 1] == 1 || base[cx][cy - 2] == 1) return false;
  base[cx][cy - 1] = 1;
  base[cx][cy - 2] = 1;
  return true;
}
bool right() {
  if (cy + 2 >= base[0].size() || base[cx][cy + 1] == 1 ||
      base[cx][cy + 2] == 1)
    return false;
  base[cx][cy + 1] = 1;
  base[cx][cy + 2] = 1;
  return true;
}
int main() {
  init();
  long long answer = 0;
  cin >> n;
  cur.resize(3);
  for (int i = 0; i < 3; i++) {
    string s;
    cin >> s;
    cur[i] = vector<int>(n, 0);
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == '.') cur[i][j] = 0;
      if (s[j] == 'O') {
        cur[i][j] = 1;
        cx = i;
        cy = j;
      }
      if (s[j] == 'X') {
        cur[i][j] = 1;
      }
    }
  }
  base = cur;
  for (int i = 1; i < (1 << 4); i++) {
    bool doit = true;
    int sign = -1;
    if (i & 1) {
      doit = doit && up();
      sign *= -1;
    }
    if (i & 2) {
      doit = doit && down();
      sign *= -1;
    }
    if (i & 4) {
      doit = doit && left();
      sign *= -1;
    }
    if (i & 8) {
      doit = doit && right();
      sign *= -1;
    }
    if (doit) answer = (mod + answer + sign * din(base)) % mod;
    base = cur;
  }
  cout << answer % mod;
  return 0;
}
