#include <bits/stdc++.h>
using namespace std;
const double PI =
    3.14159265358979323846264338327950288419716939937510582097494459230;
void swaps(char *x, char *y) {
  char temp;
  temp = *x;
  *x = *y;
  *y = temp;
}
void swapi(int *a, int *b) {
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a == 1 || b == 1) return 1;
  if (a == b) return a;
  if (a > b)
    return gcd(b, a % b);
  else
    return gcd(a, b % a);
}
long long dp[10010][8][2];
string Board[3];
int N;
int Mark[10010];
long long calc(int pos, int mask, int flag) {
  if (pos == N) {
    return (mask == 0) && (flag == 1);
  }
  long long &Res = dp[pos][mask][flag];
  if (Res != -1) return Res;
  Res = 0;
  mask |= Mark[pos];
  if (mask == 7) {
    Res += calc(pos + 1, 0, flag);
    return Res;
  }
  if (((mask >> 0) & 1) == 0 && ((mask >> 1) & 1) == 0)
    Res += calc(pos, mask | 3, flag | (Board[2][pos] == 'O'));
  if (((mask >> 1) & 1) == 0 && ((mask >> 2) & 1) == 0)
    Res += calc(pos, mask | 6, flag | (Board[0][pos] == 'O'));
  int f = 0, m = 0;
  int idx = -1;
  for (int i = 0; i < 3; i++) {
    if (((mask >> i) & 1) == 0 && ((Mark[pos + 1] >> i) & 1) == 1) {
      idx = i;
      break;
    }
    if ((pos > 0 && Board[i][pos - 1] == 'O') || Board[i][pos + 2] == 'O')
      f = 1;
    if (((mask >> i) & 1) == 0) m |= (1 << i);
  }
  if (idx == -1) Res += calc(pos + 1, m, f | flag);
  Res %= 1000000007;
  return Res;
}
int main() {
  int Cases = 1;
  for (int Case = 0; Case < Cases; Case++) {
    cin >> N;
    for (int i = 0; i < 3; i++) {
      cin >> Board[i];
    }
    Board[0][N] = Board[1][N] = Board[2][N] = 'X';
    Board[0][N + 1] = Board[1][N + 1] = Board[2][N + 1] = 'X';
    for (int i = 0; i < N; i++) {
      Mark[i] = 7;
      for (int j = 0; j < 3; j++) {
        if (Board[j][i] == '.') Mark[i] -= (1 << j);
      }
    }
    memset(dp, -1, sizeof(dp));
    cout << calc(0, 0, 0) << endl;
  }
  return 0;
}
