#include <bits/stdc++.h>
using namespace std;
long long n, m, k, mid;
long long arr[20][20];
vector<long long> V[20][20];
map<long long, long long> M[20][20];
int main() {
  int n;
  cin >> n;
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  long long dp[1 << 5];
  long long dp2[1 << 4];
  memset(dp, 0, sizeof dp);
  dp[7] = 1;
  for (int x = 0; x < n + 1; x++)
    for (int y = 0; y < 3; y++) {
      memset(dp2, 0, sizeof dp2);
      for (int mask = 0; mask < 16; mask++) {
        if (dp[mask] == 0) continue;
        int p1 = (mask & 1) && 1, p2 = (mask & 2) && 1, p3 = (mask & 4) && 1,
            p4 = (mask & 8) && 1;
        int f = (s[y][x] == '.' ? 0 : s[y][x] == 'X' ? 1 : 2);
        if (p1 == 0) {
          if (!p2 && y < 2) {
            int newp4 = p4;
            if (y == 0 && x > 0) newp4 |= (s[2][x - 1] == 'O');
            if (y == 1 && x > 0) newp4 |= (s[0][x - 1] == 'O');
            int nextmask = 1 + p3 * 2 + (f != 0) * 4 + newp4 * 8;
            dp2[nextmask] += dp[mask];
          }
          if (f == 0 && x < n) {
            int newp4 = p4;
            if (x > 1) newp4 |= (s[y][x - 2] == 'O');
            if (x < n - 1) newp4 |= (s[y][x + 1] == 'O');
            int nextmask = p2 + p3 * 2 + 4 + newp4 * 8;
            dp2[nextmask] += dp[mask];
          }
        } else {
          int nextmask = p2 + p3 * 2 + (f != 0) * 4 + p4 * 8;
          dp2[nextmask] += dp[mask];
        }
      }
      for (int mask = 0; mask < 16; mask++) dp[mask] = dp2[mask] % 1000000007;
    }
  cout << dp[15] << endl;
}
