#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int MAXN = 10000;
char grid[3][MAXN + 5];
long long dp[MAXN + 5][8][2];
int n, R, C;
long long solve(int c, int mask, bool flag) {
  if (c == n) {
    if (mask == 0 && flag) return 1;
    return 0;
  }
  if (grid[0][c] != '.') mask |= 1;
  if (grid[1][c] != '.') mask |= 2;
  if (grid[2][c] != '.') mask |= 4;
  if (dp[c][mask][flag] != -1) return dp[c][mask][flag];
  long long ret = 0;
  if ((mask & (1 << 0)) == 0 && (mask & (1 << 1)) == 0) {
    if (grid[2][c] == 'O')
      ret += solve(c, mask | 3, 1);
    else
      ret += solve(c, mask | 3, flag);
    ret %= mod;
  }
  if ((mask & (1 << 1)) == 0 && (mask & (1 << 2)) == 0) {
    if (grid[0][c] == 'O')
      ret += solve(c, mask | 6, 1);
    else
      ret += solve(c, mask | 6, flag);
    ret %= mod;
  }
  bool valid = 1;
  int newmask = 0;
  bool newflag = flag;
  for (int i = 0; i < 3; i++) {
    if ((mask & (1 << i)) == 0) {
      if (grid[i][c + 1] != '.') {
        valid = 0;
        break;
      } else {
        newmask |= (1 << i);
        if (c - 1 >= 0 && grid[i][c - 1] == 'O') newflag = 1;
        if (grid[i][c + 2] == 'O') newflag = 1;
      }
    }
  }
  if (valid) ret += solve(c + 1, newmask, newflag);
  ret %= mod;
  return dp[c][mask][flag] = ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < 3; i++) scanf("%s", grid[i]);
  memset(dp, -1, sizeof dp);
  cout << solve(0, 0, 0) << "\n";
}
