#include <bits/stdc++.h>   using namespace std;   const int N = 1e4 + 1, M = 1e9 + 7;   int n, dp[N][1 << 3][2];   char s[3][N];   int calc(int r, int msk, bool f) {     if (r == n) return f;     int &res = dp[r][msk][f];     if (res != -1) return res;     int nmsk = msk;     for (int i = 0; i < 3; ++i)       if (s[i][r] !=  . ) nmsk |= (1 << i);     res = 0;     if (nmsk == 0) {       if (r + 1 != n && s[0][r + 1] ==  .  && s[1][r + 1] ==  .  &&           s[2][r + 1] ==  . ) {         if (r + 2 != n &&             (s[0][r + 2] ==  O  || s[1][r + 2] ==  O  || s[2][r + 2] ==  O ))           res = (res + calc(r + 2, 0, true)) % M;         else if (r != 0 &&                  (s[0][r - 1] ==  O  || s[1][r - 1] ==  O  || s[2][r - 1] ==  O ))           res = (res + calc(r + 2, 0, true)) % M;         else           res = (res + calc(r + 2, 0, f)) % M;       }       if (r + 1 != n && s[0][r + 1] ==  . ) {         if ((r + 2 != n && s[0][r + 2] ==  O ) || (r != 0 && s[0][r - 1] ==  O ))           res = (res + calc(r + 1, 1 << 0, true)) % M;         else if ((s[1][r + 1] ==  O  && s[2][r + 1] ==  O ) ||                  (r != 0 && s[1][r - 1] ==  O  && s[2][r - 1] ==  O ))           res = (res + calc(r + 1, 1 << 0, true)) % M;         else           res = (res + calc(r + 1, 1 << 0, f)) % M;       }       if (r + 1 != n && s[2][r + 1] ==  . ) {         if ((r + 2 != n && s[2][r + 2] ==  O ) || (r != 0 && s[2][r - 1] ==  O ))           res = (res + calc(r + 1, 1 << 2, true)) % M;         else if ((s[0][r + 1] ==  O  && s[1][r + 1] ==  O ) ||                  (r != 0 && s[0][r - 1] ==  O  && s[1][r - 1] ==  O ))           res = (res + calc(r + 1, 1 << 2, true)) % M;         else           res = (res + calc(r + 1, 1 << 2, f)) % M;       }     } else if (nmsk == 1) {       if ((r + 1 != n && s[1][r + 1] ==  O  && s[2][r + 1] ==  O ) ||           (r != 0 && s[1][r - 1] ==  O  && s[2][r - 1] ==  O ))         res = (res + calc(r + 1, 0, true)) % M;       else if (s[0][r] ==  O )         res = (res + calc(r + 1, 0, true)) % M;       else         res = (res + calc(r + 1, 0, f)) % M;       if (r + 1 != n && s[1][r + 1] ==  .  && s[2][r + 1] ==  . ) {         if (r + 2 != n && (s[1][r + 2] ==  O  || s[2][r + 2] ==  O ))           res = (res + calc(r + 1, (1 << 1) | (1 << 2), true)) % M;         else if (r != 0 && (s[1][r - 1] ==  O  || s[2][r - 1] ==  O ))           res = (res + calc(r + 1, (1 << 1) | (1 << 2), true)) % M;         else if (s[0][r] ==  O  && s[0][r + 1] ==  O )           res = (res + calc(r + 1, (1 << 1) | (1 << 2), true)) % M;         else           res = (res + calc(r + 1, (1 << 1) | (1 << 2), f)) % M;       }     } else if (nmsk == 2) {       if (r + 1 != n && s[0][r + 1] ==  .  && s[2][r + 1] ==  . ) {         if (r + 2 != n && (s[0][r + 2] ==  O  || s[2][r + 2] ==  O ))           res = (res + calc(r + 1, (1 << 0) | (1 << 2), true)) % M;         else if (r != 0 && (s[0][r - 1] ==  O  || s[2][r - 1] ==  O ))           res = (res + calc(r + 1, (1 << 0) | (1 << 2), true)) % M;         else if (s[1][r] ==  O  && s[1][r + 1] ==  O )           res = (res + calc(r + 1, (1 << 0) | (1 << 2), true)) % M;         else           res = (res + calc(r + 1, (1 << 0) | (1 << 2), f)) % M;       }     } else if (nmsk == 3) {       if (r + 1 != n && s[2][r + 1] ==  . ) {         if ((r + 2 != n && s[2][r + 2] ==  O ) || (r != 0 && s[2][r - 1] ==  O ))           res = (res + calc(r + 1, 1 << 2, true)) % M;         else if (s[1][r] ==  O  && s[1][r + 1] ==  O )           res = (res + calc(r + 1, 1 << 2, true)) % M;         else           res = (res + calc(r + 1, 1 << 2, f)) % M;       }     } else if (nmsk == 4) {       if ((r + 1 != n && s[0][r + 1] ==  O  && s[1][r + 1] ==  O ) ||           (r != 0 && s[0][r - 1] ==  O  && s[1][r - 1] ==  O ))         res = (res + calc(r + 1, 0, true)) % M;       else if (s[2][r] ==  O )         res = (res + calc(r + 1, 0, true)) % M;       else         res = (res + calc(r + 1, 0, f)) % M;       if (r + 1 != n && s[0][r + 1] ==  .  && s[1][r + 1] ==  . ) {         if (r + 2 != n && (s[0][r + 2] ==  O  || s[1][r + 2] ==  O ))           res = (res + calc(r + 1, (1 << 0) | (1 << 1), true)) % M;         else if (r != 0 && (s[0][r - 1] ==  O  || s[1][r - 1] ==  O ))           res = (res + calc(r + 1, (1 << 0) | (1 << 1), true)) % M;         else if (s[2][r] ==  O  && s[2][r + 1] ==  O )           res = (res + calc(r + 1, (1 << 0) | (1 << 1), true)) % M;         else           res = (res + calc(r + 1, (1 << 0) | (1 << 1), f)) % M;       }     } else if (nmsk == 5) {       if (r + 1 != n && s[1][r + 1] ==  . ) {         if ((r + 2 != n && s[1][r + 2] ==  O ) || (r != 0 && s[1][r - 1] ==  O ))           res = (res + calc(r + 1, 1 << 1, true)) % M;         else if ((s[0][r] ==  O  && s[0][r + 1] ==  O ) ||                  (s[2][r] ==  O  && s[2][r + 1] ==  O ))           res = (res + calc(r + 1, 1 << 1, true)) % M;         else           res = (res + calc(r + 1, 1 << 1, f)) % M;       }     } else if (nmsk == 6) {       if (r + 1 != n && s[0][r + 1] ==  . ) {         if ((r + 2 != n && s[0][r + 2] ==  O ) || (r != 0 && s[0][r - 1] ==  O ))           res = (res + calc(r + 1, 1 << 0, true)) % M;         else if (s[1][r] ==  O  && s[1][r + 1] ==  O )           res = (res + calc(r + 1, 1 << 0, true)) % M;         else           res = (res + calc(r + 1, 1 << 0, f)) % M;       }     } else       res = (res + calc(r + 1, 0, f)) % M;     return res;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < 3; ++i) scanf( %s , s[i]);     memset(dp, -1, sizeof dp);     printf( %d n , calc(0, 0, false));     return 0;   }