#include <bits/stdc++.h>
using namespace std;
long long n, dp[10005][1 << 3][2];
string st[3];
long long rec(int p, int bit, int good) {
  if (p == n) {
    if (bit == 0) return good;
    return 0;
  }
  if (st[0][p] != '.') bit |= 1;
  if (st[1][p] != '.') bit |= 2;
  if (st[2][p] != '.') bit |= 4;
  if (~dp[p][bit][good]) return dp[p][bit][good];
  long long ret = 0;
  if (bit == 7) ret = rec(p + 1, 0, good);
  if (bit == 0 && st[0][p + 1] == '.' && st[1][p + 1] == '.' &&
      st[2][p + 1] == '.') {
    if ((p + 2 < n &&
         (st[0][p + 2] == 'O' || st[2][p + 2] == 'O' || st[1][p + 2] == 'O')) ||
        (p > 0 &&
         (st[0][p - 1] == 'O' || st[2][p - 1] == 'O' || st[1][p - 1] == 'O')))
      ret = (ret + rec(p + 1, 7, 1)) % 1000000007;
    else
      ret = (ret + rec(p + 1, 7, good)) % 1000000007;
  }
  if (bit == 0 && st[0][p + 1] == '.') {
    if ((p + 2 < n && st[0][p + 2] == 'O') || (p > 0 && st[0][p - 1] == 'O'))
      ret = (ret + rec(p + 1, 1, 1)) % 1000000007;
    else
      ret = (ret + rec(p + 1, 1, good)) % 1000000007;
  }
  if (bit == 0 && st[2][p + 1] == '.') {
    if ((p + 2 < n && st[2][p + 2] == 'O') || (p > 0 && st[2][p - 1] == 'O'))
      ret = (ret + rec(p + 1, 4, 1)) % 1000000007;
    else
      ret = (ret + rec(p + 1, 4, good)) % 1000000007;
  }
  if (bit == 6 && st[0][p + 1] == '.') {
    if ((p + 2 < n && st[0][p + 2] == 'O') || (p > 0 && st[0][p - 1] == 'O'))
      ret = (ret + rec(p + 1, 1, 1)) % 1000000007;
    else
      ret = (ret + rec(p + 1, 1, good)) % 1000000007;
  }
  if (bit == 3 && st[2][p + 1] == '.') {
    if ((p + 2 < n && st[2][p + 2] == 'O') || (p > 0 && st[2][p - 1] == 'O'))
      ret = (ret + rec(p + 1, 4, 1)) % 1000000007;
    else
      ret = (ret + rec(p + 1, 4, good)) % 1000000007;
  }
  if (bit == 5 && st[1][p + 1] == '.') {
    if ((p + 2 < n && st[1][p + 2] == 'O') || (p > 0 && st[1][p - 1] == 'O'))
      ret = (ret + rec(p + 1, 2, 1)) % 1000000007;
    else
      ret = (ret + rec(p + 1, 2, good)) % 1000000007;
  }
  if (bit == 1) {
    if (st[1][p + 1] == '.' && st[2][p + 1] == '.') {
      if ((p + 2 < n && (st[1][p + 2] == 'O' || st[2][p + 2] == 'O')) ||
          (p > 0 && (st[1][p - 1] == 'O' || st[2][p - 1] == 'O')))
        ret = (ret + rec(p + 1, 6, 1)) % 1000000007;
      else
        ret = (ret + rec(p + 1, 6, good)) % 1000000007;
    }
    if (st[0][p] == 'O')
      ret = (ret + rec(p + 1, 0, 1)) % 1000000007;
    else
      ret = (ret + rec(p + 1, 0, good)) % 1000000007;
  }
  if (bit == 2 && st[0][p + 1] == '.' && st[2][p + 1] == '.') {
    if ((p + 2 < n && (st[0][p + 2] == 'O' || st[2][p + 2] == 'O')) ||
        (p > 0 && (st[0][p - 1] == 'O' || st[2][p - 1] == 'O')))
      ret = (ret + rec(p + 1, 5, 1)) % 1000000007;
    else
      ret = (ret + rec(p + 1, 5, good)) % 1000000007;
  }
  if (bit == 4) {
    if (st[1][p + 1] == '.' && st[0][p + 1] == '.') {
      if ((p + 2 < n && (st[1][p + 2] == 'O' || st[0][p + 2] == 'O')) ||
          (p > 0 && (st[0][p - 1] == 'O' || st[1][p - 1] == 'O')))
        ret = (ret + rec(p + 1, 3, 1)) % 1000000007;
      else
        ret = (ret + rec(p + 1, 3, good)) % 1000000007;
    }
    if (st[2][p] == 'O')
      ret = (ret + rec(p + 1, 0, 1)) % 1000000007;
    else
      ret = (ret + rec(p + 1, 0, good)) % 1000000007;
  }
  return dp[p][bit][good] = ret;
}
int main() {
  cin >> n;
  memset((dp), (-1), sizeof(dp));
  cin >> st[0] >> st[1] >> st[2];
  int r, c;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < n; j++)
      if (st[i][j] == 'O') {
        r = i, c = j;
        break;
      }
  long long ans = rec(0, 0, 0);
  cout << ans << endl;
  return 0;
}
