#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
const int mod = 1e9 + 7;
int n, dp[N][8][2];
char s[3][N];
void inc(int& a, int b) {
  if (a += b, a >= mod) a -= mod;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 3; ++i) scanf("%s", s[i] + 1);
  dp[1][0][0] = 1;
  for (int i = 1; i <= n; ++i)
    for (int p = 0; p < (1 << 3); ++p)
      for (int good = 0; good <= 1; ++good) {
        int tmp = dp[i][p][good];
        if (!tmp) continue;
        int np = 0, ng = good, bad = 0;
        for (int j = 0; j < 3; ++j) {
          if (p >> j & 1) {
            if (s[j][i] != '.') bad = 1;
            if (s[j][i + 1] == 'O') ng = 1;
          } else {
            if (s[j][i] == '.') {
              np += 1 << j;
              if (s[j][i - 1] == 'O') ng = 1;
            }
          }
        }
        if (!bad) inc(dp[i + 1][np][ng], tmp);
        if ((p >> 0 & 1) == 0 && (p >> 1 & 1) == 0 && s[0][i] == '.' &&
            s[1][i] == '.') {
          int x = p >> 2 & 1;
          if (x && s[2][i] != '.')
            ;
          else {
            ng = (good || (s[2][i] == 'O'));
            inc(dp[i + 1][(!x && s[2][i] == '.') << 2][ng], tmp);
          }
        }
        if ((p >> 1 & 1) == 0 && (p >> 2 & 1) == 0 && s[1][i] == '.' &&
            s[2][i] == '.') {
          int x = p >> 0 & 1;
          if (x && s[0][i] != '.')
            ;
          else {
            ng = (good || (s[0][i] == 'O'));
            inc(dp[i + 1][(!x && s[0][i] == '.') << 0][ng], tmp);
          }
        }
      }
  printf("%d\n", dp[n + 1][0][1]);
}
