#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int INF = 2e9;
const long long INF64 = 7e18;
const long double EPS = 1e-9;
const long double PI = 3.14159265358979310000;
const long long MD = 535355424;
const int T = 1e5 * 3;
const int N = 300101;
const int M = 30001;
int n, a[4][M], xx, yy;
int d[M][10];
void rec(int first, int second, int mask, int new_mask) {
  if (second == 3) {
    d[first][new_mask] = (d[first][new_mask] + d[first - 1][mask]) % MOD;
    return;
  }
  if (a[second][first] == 10) {
    if (mask & (1 << second))
      rec(first, second + 1, mask, new_mask + (1 << second));
    return;
  }
  if (!(mask & (1 << second))) {
    if (a[second][first] != 1 && a[second][first - 1] != 1)
      rec(first, second + 1, mask, new_mask + (1 << second));
    return;
  }
  if (second <= 1 && mask & (1 << second) && mask & (1 << (second + 1)) &&
      a[second][first] != 2 && a[second + 1][first] != 2 &&
      a[second + 1][first] != 10)
    rec(first, second + 2, mask,
        new_mask + (1 << second) + (1 << (second + 1)));
  if (mask & (1 << second)) rec(first, second + 1, mask, new_mask);
}
int get() {
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= 10; j++) d[i][j] = 0;
  d[0][7] = 1;
  for (int i = 0; i < n; i++)
    for (int mask = 0; mask < int((1 << 3)); mask++) rec(i + 1, 0, mask, 0);
  return d[n][7];
}
int main() {
  cin >> n;
  for (int i = 0; i < 3; i++)
    for (int j = 1; j <= n; j++) {
      char c;
      cin >> c;
      if (c == '.')
        a[i][j] = 0;
      else if (c == 'X')
        a[i][j] = 10;
      else {
        xx = i;
        yy = j;
        a[i][j] = 10;
      }
    }
  long long ans = get();
  if (yy > 1) a[xx][yy - 1] = 1;
  a[xx][yy + 1] = 1;
  if (xx > 0) a[xx - 1][yy] = 2;
  a[xx + 1][yy] = 2;
  long long ans1 = get();
  cout << (ans - ans1 + MOD) % MOD;
  return 0;
}
