#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 100;
const int M = 21;
const long long mod = 1e9 + 7;
const long long MOD = 998244353;
const long double eps = 0.000000001;
const int P = 1336;
const long long inf = 1e17;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
vector<pair<pair<int, int>, int> > per;
int dp[N][4][4][4][2];
char a[3][N];
int m, n = 3;
bool check(int i, int x2, int y2, int z2, int x1, int y1, int z1) {
  int x[3], y[3];
  x[0] = x2, x[1] = y2;
  x[2] = z2;
  y[0] = x1, y[1] = y1;
  y[2] = z1;
  for (int j = 0; j < 3; j++) {
    if (x[j] == 0 && a[j][i] != 'X') return 1;
    if (x[j] != 0 && a[j][i] == 'X') return 1;
  }
  if (i == 1) {
    if (x1 == 0 && y1 == 0 && z1 == 0) {
      if (x2 == 3 || y2 == 3 || z2 == 3)
        return 1;
      else
        return 0;
    } else
      return 1;
  }
  for (int j = 0; j < 3; j++) {
    if (y[j] == 0 && a[j][i - 1] != 'X') return 1;
    if (y[j] != 0 && a[j][i - 1] == 'X') return 1;
    if (x[j] == 3 && y[j] != 2) return 1;
    if (x[j] != 3 && y[j] == 2) return 1;
    if (x[j] == 2 && i == m) return 1;
  }
  return 0;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int l = 0; l < 4; l++) {
        if (i == 1 && l == 1) continue;
        int k = (i == 1) + (j == 1) + (l == 1);
        if (k == 1) continue;
        per.push_back({{i, j}, l});
      }
    }
  }
  cin >> m;
  int sti = m + 1, stj;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'O') {
        sti = j;
        stj = i;
        a[i][j] = 'X';
      }
    }
  }
  dp[0][0][0][0][0] = 1;
  for (int i = 1; i <= m; i++) {
    if (i < sti || i > sti + 1) {
      for (auto to : per) {
        int x = to.first.first, y = to.first.second, z = to.second;
        for (auto to1 : per) {
          int x1 = to1.first.first, y1 = to1.first.second, z1 = to1.second;
          if (check(i, x, y, z, x1, y1, z1)) continue;
          bool fl = 0, fl1 = 0;
          if (i == sti - 1) {
            if (stj == 0 && x == 3) fl = 1;
            if (stj == 1 && y == 3) fl = 1;
            if (stj == 2 && z == 3) fl = 1;
          }
          if (i > sti + 1) {
            fl = 1;
            fl1 = 1;
          }
          dp[i][x][y][z][fl] =
              (1ll * dp[i][x][y][z][fl] + dp[i - 1][x1][y1][z1][fl1]) % mod;
        }
      }
    } else {
      for (auto to : per) {
        int x = to.first.first, y = to.first.second, z = to.second;
        for (auto to1 : per) {
          int x1 = to1.first.first, y1 = to1.first.second, z1 = to1.second;
          if (check(i, x, y, z, x1, y1, z1)) continue;
          dp[i][x][y][z][1] =
              (1ll * dp[i][x][y][z][1] + dp[i - 1][x1][y1][z1][1]) % mod;
          dp[i][x][y][z][0] =
              (1ll * dp[i][x][y][z][0] + dp[i - 1][x1][y1][z1][0]) % mod;
          if (i == sti) {
            if ((x == 1 && y == 1) || (y == 1 && z == 1)) {
              dp[i][x][y][z][1] =
                  (1ll * dp[i][x][y][z][1] + dp[i - 1][x1][y1][z1][0]) % mod;
            } else if (stj == 0 && x1 == 3) {
              dp[i][x][y][z][1] =
                  (1ll * dp[i][x][y][z][1] + dp[i - 1][x1][y1][z1][0]) % mod;
            } else if (stj == 1 && y1 == 3) {
              dp[i][x][y][z][1] =
                  (1ll * dp[i][x][y][z][1] + dp[i - 1][x1][y1][z1][0]) % mod;
            } else if (stj == 2 && z1 == 3) {
              dp[i][x][y][z][1] =
                  (1ll * dp[i][x][y][z][1] + dp[i - 1][x1][y1][z1][0]) % mod;
            }
          } else {
            if (stj == 0 && x == 2) {
              dp[i][x][y][z][1] =
                  (1ll * dp[i][x][y][z][1] + dp[i - 1][x1][y1][z1][0]) % mod;
            } else if (stj == 1 && y == 2) {
              dp[i][x][y][z][1] =
                  (1ll * dp[i][x][y][z][1] + dp[i - 1][x1][y1][z1][0]) % mod;
            } else if (stj == 2 && z == 2) {
              dp[i][x][y][z][1] =
                  (1ll * dp[i][x][y][z][1] + dp[i - 1][x1][y1][z1][0]) % mod;
            }
          }
        }
      }
    }
  }
  int ans = 0;
  for (auto to : per) {
    int x = to.first.first, y = to.first.second, z = to.second;
    ans = (1ll * ans + dp[m][x][y][z][1]) % mod;
  }
  cout << ans;
}
