#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n;
long long int dp[10004][8][2];
int mark[10004];
string board[4];
long long int solve(int pos, int mask, int flag) {
  long long int &ret = dp[pos][mask][flag];
  if (ret != -1) {
    return ret;
  }
  ret = 0;
  if (pos >= n) {
    if (flag == 1) {
      return ret = 1;
    }
    return ret = 0;
  }
  ret = 0;
  mask |= mark[pos];
  int flag0 = 0;
  int mask0 = 0;
  if (mask == 7) {
    ret += solve(pos + 1, 0, flag);
    ret %= mod;
    return ret;
  }
  int masktmp = mask;
  int flagtmp = 0;
  if (((mask >> 0) & 1) == 0 && ((mask >> 1) & 1) == 0) {
    if (board[2][pos] == 'O') {
      flagtmp = 1;
    }
    masktmp |= (1 << 0);
    masktmp |= (1 << 1);
    ret += solve(pos, masktmp, flag | flagtmp);
    ret %= mod;
  }
  flagtmp = 0;
  masktmp = mask;
  if (((mask >> 1) & 1) == 0 && ((mask >> 2) & 1) == 0) {
    if (board[0][pos] == 'O') {
      flagtmp = 1;
    }
    masktmp |= (1 << 1);
    masktmp |= (1 << 2);
    ret += solve(pos, masktmp, flag | flagtmp);
    ret %= mod;
  }
  long long int mask1 = 0;
  long long int flag1 = 0;
  int i = 0;
  for (i = 0; i < 3; i++) {
    if (((mask >> i) & 1) == 0 && ((mark[pos + 1] >> i) & 1) == 1) {
      break;
    }
    if (((mask >> i) & 1) == 0) {
      mask1 |= (1 << i);
    }
    if (pos > 0 && board[i][pos - 1] == 'O' || board[i][pos + 2] == 'O') {
      flag1 = 1;
    }
  }
  if (i == 3) {
    ret += solve(pos + 1, mask1, flag | flag1);
    ret %= mod;
  }
  return ret % mod;
}
int main() {
  scanf("%d", &n);
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < 3; i++) {
    cin >> board[i];
  }
  for (int i = 0; i < 3; i++) {
    board[i] = board[i] + "X";
  }
  int len = board[0].size();
  for (int i = 0; i < len; i++) {
    for (int j = 0; j < 3; j++) {
      if (board[j][i] != '.') {
        mark[i] = mark[i] | (1 << j);
      }
    }
  }
  long long int ans = solve(0, 0, 0);
  printf("%lld\n", ans);
  return 0;
}
