#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
char s[7][10005];
int dp[10005][1 << 3][2];
int dfs(int c, int mask, bool fg);
int cal(int c, int r, int mask, bool fg) {
  if (r == 4) return dfs(c + 1, mask, fg);
  if (mask & (1 << (r - 1))) {
    return cal(c, r + 1, mask ^ (1 << (r - 1)), fg);
  }
  if (s[r][c] != '.') return cal(c, r + 1, mask, fg);
  int ans = 0;
  if (s[r + 1][c] == '.' && (~mask & (1 << r))) {
    bool f = fg || s[r - 1][c] == 'O' || s[r + 2][c] == 'O';
    ans += cal(c, r + 2, mask, f);
    ans %= 1000000007;
  }
  if (s[r][c + 1] == '.') {
    bool f = fg || s[r][c - 1] == 'O' || s[r][c + 2] == 'O';
    ans += cal(c, r + 1, mask | (1 << (r - 1)), f);
    ans %= 1000000007;
  }
  return ans;
}
int dfs(int c, int mask, bool fg) {
  if (c > n) return fg;
  if (dp[c][mask][fg] == -1) {
    dp[c][mask][fg] = cal(c, 1, mask, fg);
  }
  return dp[c][mask][fg];
}
int main() {
  memset(dp, -1, sizeof dp);
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(3); (i)++) scanf("%s", s[i] + 1);
  printf("%d\n", dfs(1, 0, 0));
  return 0;
}
