#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10100;
const int mod = 1000000007;
int n;
char s[3][MAXN];
int dp[MAXN][8][2];
int used[MAXN];
void read() {
  int i;
  scanf("%d", &n);
  for (i = 0; i < 3; ++i) {
    scanf("%s", s[i]);
  }
}
int go(int pos, int mask, int flag) {
  if (dp[pos][mask][flag] != -1) return dp[pos][mask][flag];
  if (pos == n) {
    if (!mask && flag) return 1;
    return 0;
  }
  int ret = 0;
  mask |= used[pos];
  if (mask == 7) {
    return dp[pos][mask][flag] = go(pos + 1, 0, flag);
  }
  if ((mask & (1 << 0)) == 0 && (mask & (1 << 1)) == 0) {
    ret += go(pos, mask | 3, flag | (s[2][pos] == 'O'));
    ret %= mod;
  }
  if ((mask & (1 << 1)) == 0 && (mask & (1 << 2)) == 0) {
    ret += go(pos, mask | 6, flag | (s[0][pos] == 'O'));
    ret %= mod;
  }
  int i, next = 0, l = 0;
  for (i = 0; i < 3; ++i) {
    if ((mask & (1 << i)) == 0 && s[i][pos + 1] != '.') break;
    if ((mask & (1 << i)) == 0) {
      next |= (1 << i);
    }
    if (pos > 0 && s[i][pos - 1] == 'O') l = 1;
    if (s[i][pos + 2] == 'O') l = 1;
  }
  if (i == 3) {
    ret += go(pos + 1, next, flag | l);
    ret %= mod;
  }
  return dp[pos][mask][flag] = ret;
}
int main() {
  read();
  for (int i = 0; i < n; ++i) {
    used[i] = 7;
    for (int j = 0; j < 3; ++j) {
      if (s[j][i] == '.') used[i] -= (1 << j);
    }
  }
  memset(dp, -1, sizeof dp);
  printf("%d\n", go(0, 0, 0));
  return 0;
}
