#include <bits/stdc++.h>
const int maxn = 10008, mod = (int)1e9 + 7;
int n, x, y, f[maxn][8];
char s[3][maxn];
inline void Inc(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
int main() {
  scanf("%d%s%s%s", &n, s[0], s[1], s[2]);
  f[0][0] = 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 8; j++) {
      if (!f[i][j]) continue;
      int ok = true;
      for (int k = 0; k < 3; k++)
        if (((j >> k) & 1) && s[k][i] != '.') ok = false;
      if (!ok) continue;
      int p = 0;
      for (int k = 0; k < 3; k++)
        if (!((j >> k) & 1) && s[k][i] == '.') p |= 1 << k;
      Inc(f[i + 1][p], f[i][j]);
      if (s[0][i] == '.' && s[1][i] == '.' && !(j & 3))
        Inc(f[i + 1][p & 4], f[i][j]);
      if (s[1][i] == '.' && s[2][i] == '.' && j < 2)
        Inc(f[i + 1][p & 1], f[i][j]);
    }
  int ans = f[n][0];
  memset(f, 0, sizeof f);
  f[0][0] = 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 8; j++) {
      if (!f[i][j]) continue;
      int ok = true;
      for (int k = 0; k < 3; k++)
        if (((j >> k) & 1) && (s[k][i] != '.' || s[k][i + 1] == 'O'))
          ok = false;
      if (!ok) continue;
      int p = 0;
      for (int k = 0; k < 3; k++)
        if (!((j >> k) & 1) && s[k][i] == '.') {
          p |= 1 << k;
          if (i && s[k][i - 1] == 'O') ok = false;
        }
      if (ok) Inc(f[i + 1][p], f[i][j]);
      if (s[0][i] == '.' && s[1][i] == '.' && !(j & 3) &&
          (i == 0 || (s[2][i - 1] != 'O')) && s[2][i] != 'O')
        Inc(f[i + 1][p & 4], f[i][j]);
      if (s[1][i] == '.' && s[2][i] == '.' && j < 2 &&
          (i == 0 || (s[0][i - 1] != 'O')) && s[0][i] != 'O')
        Inc(f[i + 1][p & 1], f[i][j]);
    }
  ans = (ans + mod - f[n][0]) % mod;
  printf("%d\n", ans);
  return 0;
}
