#include <bits/stdc++.h>
using namespace std;
int n;
string b[3];
int dp[10005][1 << 3];
int col, row;
void add(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
void upd(int y, int pos, int mask1, int mask2) {
  if (y == 3) {
    if (!dp[pos - 1][mask1]) return;
    add(dp[pos][mask2], dp[pos - 1][mask1]);
    return;
  }
  if (b[y][pos] != '.') {
    if (mask1 & (1 << y)) upd(y + 1, pos, mask1, mask2 | (1 << y));
    return;
  }
  if (mask1 & (1 << y)) {
    upd(y + 1, pos, mask1, mask2);
    if (y + 1 < 3 && mask1 & (2 << y) && b[y + 1][pos] == '.')
      upd(y + 2, pos, mask1, mask2 | (1 << y) | (2 << y));
  } else
    upd(y + 1, pos, mask1, mask2 | (1 << y));
}
int calc(int pos, int end) {
  memset(dp, 0, sizeof dp);
  dp[pos - 1][7] = 1;
  for (int i = pos; i < end; i++)
    for (int mask = 0; mask < 1 << 3; mask++) upd(0, i, mask, 0);
  return dp[end - 1][7];
}
void oku() {
  cin >> n;
  for (int i = 0; i < 3; i++) {
    cin >> b[i];
    b[i] = '.' + b[i];
  }
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < n; j++)
      if (b[i][j] == 'O') col = j, row = i;
  long long ret = calc(1, n + 1);
  long long cs = (calc(1, col - 1) * 1ll * calc(col + 2, n + 1)) % 1000000007;
  cs = (cs * 2ll) % 1000000007;
  if (row == 1) ret = (ret - cs + 1000000007) % 1000000007;
  cout << ret << endl;
}
int main() {
  oku();
  return 0;
}
