#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265359;
const int ans = 0x10, mod = 1000000007;
int n, dp[100500][64];
char f[100500][8];
void count(int x, int y, int mask, int nmask) {
  if (x == n) return;
  if (y >= 3)
    dp[x + 1][nmask] = (dp[x + 1][nmask] + dp[x][mask]) % mod;
  else {
    int tmask = 1 << y;
    if (f[x][y] == 'X' || f[x][y] == 'O' || mask & tmask)
      count(x, y + 1, mask, nmask);
    else {
      if (y < 2 && f[x][y + 1] != 'X' && f[x][y + 1] != 'O' &&
          !(mask & (1 << (y + 1)))) {
        if (f[x][y + 2] == 'O' || (y > 0 && f[x][y - 1] == 'O'))
          count(x, y + 2, mask, nmask | ans);
        else
          count(x, y + 2, mask, nmask);
      }
      if (x < n - 1 && f[x + 1][y] != 'X' && f[x + 1][y] != 'O') {
        if (f[x + 2][y] == 'O' || (x > 0 && f[x - 1][y] == 'O'))
          count(x, y + 1, mask, nmask | tmask | ans);
        else
          count(x, y + 1, mask, nmask | tmask);
      }
    }
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < 3; ++i) {
    getchar();
    for (int j = 0; j < n; ++j) f[j][i] = getchar();
  }
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 32; ++j) count(i, 0, j, j & ans);
  cout << dp[n][ans];
  return 0;
}
