#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char tp = getchar();
  int ans = 0;
  while (tp > '9' || tp < '0') tp = getchar();
  while (tp <= '9' && tp >= '0') {
    ans = ans * 10 + tp - '0';
    tp = getchar();
  }
  return ans;
}
const long long mod = 1000000007;
long long f[10005][343];
int p[343][4], n, ma[4][10005];
char s[10005];
inline bool check(int num, int c) {
  for (int i = 1; i <= 3; i++)
    if (ma[i][c] == -1 && p[num][i] != 6) return 0;
  for (int i = 1; i <= 3; i++)
    if (p[num][i] == 6 && ma[i][c] != -1) return 0;
  for (int i = 1; i <= 3; i++)
    if (ma[i][c] == 1 && p[num][i] != 4 && p[num][i] != 5) return 0;
  for (int i = 1; i <= 3; i++)
    if ((p[num][i] == 4 || p[num][i] == 5) && ma[i][c] != 1) return 0;
  for (int i = 1; i <= 3; i++)
    if (p[num][i] >= 4 && ma[i][c] == 0) return 0;
  for (int i = 1; i <= 2; i++)
    if (p[num][i] == 0 && p[num][i + 1] != 1) return 0;
  for (int i = 2; i <= 3; i++)
    if (p[num][i] == 1 && p[num][i - 1] != 0) return 0;
  if (p[num][1] == 1 || p[num][3] == 0) return 0;
  return 1;
}
int main() {
  for (int i = 0; i <= 342; i++)
    for (int j = 1; j <= 3; j++) {
      int cu = i;
      for (int k = 1; k <= j - 1; k++) cu /= 7;
      p[i][j] = cu % 7;
    }
  scanf("%d", &n);
  int tp = 0;
  for (int i = 1; i <= 3; i++) {
    memset(s, 0, sizeof(s));
    scanf("%s", s + 1);
    for (int j = 1; j <= n; j++) {
      ma[i][j] = (s[j] == '.' ? 0 : (s[j] == 'X' ? -1 : 1));
      if (ma[i][j] == 1) tp++;
    }
  }
  for (int j = 0; j <= 342; j++) {
    int flag = 1;
    if (check(j, 1) == 0) continue;
    for (int k = 1; k <= 3; k++)
      if (p[j][k] == 3) flag = 0;
    if (flag == 0) continue;
    f[1][j] = 1;
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= 342; j++) {
      if (check(j, i) == 0) continue;
      for (int k = 0; k <= 342; k++) {
        if (f[i - 1][k] == 0 || check(k, i - 1) == 0) continue;
        int flag = 1;
        for (int m = 1; m <= 3; m++)
          if (p[k][m] == 2)
            if (p[j][m] != 3) flag = 0;
        for (int m = 1; m <= 3; m++)
          if (p[j][m] == 3)
            if (p[k][m] != 2) flag = 0;
        for (int m = 1; m <= 3; m++)
          if (p[k][m] == 4 && p[j][m] != 2) flag = 0;
        if (p[j][1] == 4)
          if ((p[j][2] == 0 || p[k][1] == 3 || p[k][1] == 5)) flag = 0;
        if (p[j][2] == 4)
          if ((p[k][2] == 3 || p[k][2] == 5)) flag = 0;
        if (p[j][3] == 4)
          if ((p[j][2] == 1 || p[k][3] == 3 || p[k][3] == 5)) flag = 0;
        if (p[j][1] == 5)
          if (!(p[j][2] == 0 || p[k][1] == 3 || p[k][1] == 5)) flag = 0;
        if (p[j][2] == 5)
          if (!(p[k][2] == 3 || p[k][2] == 5)) flag = 0;
        if (p[j][3] == 5)
          if (!(p[j][2] == 1 || p[k][3] == 3 || p[k][3] == 5)) flag = 0;
        if (!flag) continue;
        f[i][j] = (f[i][j] + f[i - 1][k]) % mod;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i <= 342; i++) {
    if (f[n][i]) {
      int flag = 1;
      for (int j = 1; j <= 3; j++) {
        if (p[i][j] == 2 || p[i][j] == 4) flag = 0;
        if (ma[j][n] != 0 && p[i][j] < 4) flag = 0;
      }
      if (flag) {
        ans = (ans + f[n][i]) % mod;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
