#include <bits/stdc++.h>
using namespace std;
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
const int MAXN = (int)1e4 + 10;
const int MOD = (int)1e9 + 7;
int n;
string s[3];
long long dp[MAXN][8][2];
int masks[MAXN];
int GetMask(int layer) {
  int res = 0;
  for (int i = 0; i < 3; i++)
    if (s[i][layer] != '.') res |= (1 << i);
  return res;
}
void f(int comb, int mask, int layer) {
  if (!dp[layer][mask][0] && !dp[layer][mask][1]) return;
  int nxt = layer + 1;
  bool to = false;
  int m1 = 0, m2 = 0;
  if (comb & 1) m1 |= 3, to |= s[2][layer] == 'O';
  if (comb & 2) m1 |= 6, to |= s[0][layer] == 'O';
  if (comb & 4)
    m1 |= 1, m2 |= 1, to |= ((s[0][layer - 1] == 'O') | (s[0][nxt + 1] == 'O'));
  if (comb & 8)
    m1 |= 2, m2 |= 2, to |= ((s[1][layer - 1] == 'O') | (s[1][nxt + 1] == 'O'));
  if (comb & 16)
    m1 |= 4, m2 |= 4, to |= ((s[2][layer - 1] == 'O') | (s[2][nxt + 1] == 'O'));
  for (int i = 0; i < 3; i++)
    if (((m1 & (1 << i)) && (mask & (1 << i))) ||
        ((m2 & (1 << i)) && (masks[nxt] & (1 << i))))
      return;
  if ((mask | m1) != 7) return;
  if (to) {
    dp[nxt][m2 | masks[nxt]][to] += dp[layer][mask][0] + dp[layer][mask][1];
    dp[nxt][m2 | masks[nxt]][to] %= MOD;
    return;
  }
  dp[nxt][m2 | masks[nxt]][1] += dp[layer][mask][1];
  dp[nxt][m2 | masks[nxt]][1] %= MOD;
  dp[nxt][m2 | masks[nxt]][0] += dp[layer][mask][0];
  dp[nxt][m2 | masks[nxt]][0] %= MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < 3; i++)
    cin >> s[i], s[i] = ' ' + s[i], s[i] += 'X', s[i] += 'X';
  for (int i = 1; i <= n + 2; i++) masks[i] = GetMask(i);
  dp[1][masks[1]][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int mask = 0; mask < 8; mask++) {
      f(0, mask, i);
      f(4, mask, i);
      f(8, mask, i);
      f(12, mask, i);
      f(16, mask, i);
      f(20, mask, i);
      f(24, mask, i);
      f(28, mask, i);
      f(1, mask, i);
      f(2, mask, i);
      f(6, mask, i);
      f(17, mask, i);
    }
  }
  cout << dp[n + 1][7][1];
}
