#include <bits/stdc++.h>
using namespace std;
int n, dp[10005][8][2];
char s[3][10005];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 3; i++) {
    scanf("\n");
    for (int j = 1; j <= n; j++) scanf("%c", &s[i][j]);
  }
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1, dp[0][0][1] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 8; j++)
      for (int k = 0; k < 2; k++) {
        int state = j | (4 * (s[0][i] != '.')) | (2 * (s[1][i] != '.')) |
                    (1 * (s[2][i] != '.'));
        for (int x = 0; x < 3; x++)
          for (int y = 0; y < 3; y++)
            for (int z = 0; z < 2; z++) {
              bool sm = (k == 1);
              if (x == 0 && ((state & 4) == 0)) continue;
              if (y == 0 && ((state & 2) == 0) && x != 2) continue;
              if (z == 0 && ((state & 1) == 0) && y != 2) continue;
              if (x != 0 && (state & 4) != 0) continue;
              if (y != 0 && (state & 2) != 0) continue;
              if (z != 0 && (state & 1) != 0) continue;
              if ((x == 1 || y == 1 || z == 1) && i == n) continue;
              if (x == 2 && (y != 0 || ((state & 2) != 0))) continue;
              if (y == 2 && (z != 0 || ((state & 1) != 0))) continue;
              if (x == 1 && s[0][i + 1] != '.') continue;
              if (y == 1 && s[1][i + 1] != '.') continue;
              if (z == 1 && s[2][i + 1] != '.') continue;
              if (x == 2 && s[2][i] == 'O') sm = true;
              if (y == 2 && s[0][i] == 'O') sm = true;
              if (x == 1 && (i > 1 && s[0][i - 1] == 'O')) sm = true;
              if (x == 1 && (i < n - 1 && s[0][i + 2] == 'O')) sm = true;
              if (y == 1 && (i > 1 && s[1][i - 1] == 'O')) sm = true;
              if (y == 1 && (i < n - 1 && s[1][i + 2] == 'O')) sm = true;
              if (z == 1 && (i > 1 && s[2][i - 1] == 'O')) sm = true;
              if (z == 1 && (i < n - 1 && s[2][i + 2] == 'O')) sm = true;
              int newstate = (x == 1) * 4 + (y == 1) * 2 + (z == 1) * 1;
              dp[i][newstate][sm] =
                  (dp[i][newstate][sm] + dp[i - 1][j][k]) % 1000000007;
            }
      }
  printf("%d\n", dp[n][0][1]);
  return 0;
}
