#include <bits/stdc++.h>
using namespace std;
long long dp[1 << 14][8][2];
char board[4][1 << 14];
int n, used[1 << 14];
long long get(int pos, int mask, int flag) {
  long long &ret = dp[pos][mask][flag];
  if (ret == -1) {
    ret = 0;
    if (pos == n) {
      ret = (mask == 0) && (flag == 1);
    } else {
      mask |= used[pos];
      if (mask == 7) {
        ret += get(pos + 1, 0, flag);
        return ret;
      }
      if (((mask >> 0) & 1) == 0 && ((mask >> 1) & 1) == 0) {
        ret += get(pos, mask | (3), flag | (board[2][pos] == 'O'));
      }
      if (((mask >> 2) & 1) == 0 && ((mask >> 1) & 1) == 0) {
        ret += get(pos, mask | (6), flag | (board[0][pos] == 'O'));
      }
      int i, nflag = 0, nmask = 0;
      for (i = 0; i < 3; i++) {
        if (((mask >> i) & 1) == 0 && ((used[pos + 1] >> i) & 1) == 1) {
          break;
        }
        if ((pos > 0 && board[i][pos - 1] == 'O') ||
            (board[i][pos + 2] == 'O')) {
          nflag = 1;
        }
        if (((mask >> i) & 1) == 0) {
          nmask |= (1 << i);
        }
      }
      if (i == 3) {
        ret += get(pos + 1, nmask, nflag | flag);
      }
    }
    ret %= 1000000007;
  }
  return ret;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 0; i < 3; i++) {
    scanf("%s", board[i]);
  }
  for (int i = 0; i < n; i++) {
    used[i] = 7;
    for (int j = 0; j < 3; j++) {
      if (board[j][i] == '.') {
        used[i] -= (1 << j);
      }
    }
  }
  cout << get(0, 0, 0) << endl;
  return 0;
}
