#include <bits/stdc++.h>
using namespace std;
string s[7];
int n;
int mem[10010][10][10][10];
int solve(int col, int row, int curr, int next) {
  if (mem[col][row][curr][next] != -1) return mem[col][row][curr][next];
  if (col == n + 2) return mem[col][row][curr][next] = 1;
  if (row == 3) return mem[col][row][curr][next] = solve(col + 1, 0, next, 0);
  int ans = 0;
  if ((curr & (1 << row)) || s[row + 2][col] != '.')
    return solve(col, row + 1, curr, next);
  if (s[row + 2][col] == '.' && s[row + 2][col + 1] == '.' &&
      (curr & (1 << row)) == 0)
    ans += solve(col, row + 1, curr | (1 << row), next | (1 << row));
  if (row < 2 && s[row + 2][col] == '.' && s[row + 3][col] == '.' &&
      (curr & (1 << (row + 1))) == 0)
    ans += solve(col, row + 1, curr | (1 << (row + 1)), next);
  return mem[col][row][curr][next] = (ans % 1000000007);
}
void print() {
  for (int j = 0; j < 7; j++, cout << endl)
    for (int i = 0; i < n + 4; i++) cout << s[j][i];
}
bool can(int x, int y, int b) {
  if (b == 0) return s[x][y + 1] == '.' && s[x][y + 2] == '.';
  if (b == 1) return s[x][y - 1] == '.' && s[x][y - 2] == '.';
  if (b == 2) return s[x + 1][y] == '.' && s[x + 2][y] == '.';
  if (b == 3) return s[x - 1][y] == '.' && s[x - 2][y] == '.';
}
void fill(int x, int y, int b) {
  if (b == 0) {
    s[x][y + 1] = 'X';
    s[x][y + 2] = 'X';
  }
  if (b == 1) {
    s[x][y - 1] = 'X';
    s[x][y - 2] = 'X';
  }
  if (b == 2) {
    s[x + 1][y] = 'X';
    s[x + 2][y] = 'X';
  }
  if (b == 3) {
    s[x - 1][y] = 'X';
    s[x - 2][y] = 'X';
  }
}
void free(int x, int y, int b) {
  if (b == 0) {
    s[x][y + 1] = '.';
    s[x][y + 2] = '.';
  }
  if (b == 1) {
    s[x][y - 1] = '.';
    s[x][y - 2] = '.';
  }
  if (b == 2) {
    s[x + 1][y] = '.';
    s[x + 2][y] = '.';
  }
  if (b == 3) {
    s[x - 1][y] = '.';
    s[x - 2][y] = '.';
  }
}
bool subset(int mask, int sub) {
  for (int i = 0; i < 4; i++)
    if ((mask & (1 << i)) == 0 && (sub & (1 << i))) return false;
  return true;
}
int main() {
  cin >> n;
  for (int i = 2; i <= 4; i++) cin >> s[i];
  int ox, oy;
  s[0] = string(n + 4, 'X');
  s[1] = string(n + 4, 'X');
  s[5] = string(n + 4, 'X');
  s[6] = string(n + 4, 'X');
  for (int i = 2; i <= 4; i++) {
    s[i] = "XX" + s[i] + "XX";
    for (int j = 0; j < n + 4; j++)
      if (s[i][j] == 'O') {
        ox = i;
        oy = j;
      }
  }
  int ans = 0;
  s[ox][oy] = 'X';
  int msk = 0;
  for (int i = 0; i < 4; i++)
    if (can(ox, oy, i)) msk |= (1 << i);
  for (int i = 1; i < (1 << 4); i++) {
    if (subset(msk, i)) {
      int neg = __builtin_popcount(i) % 2 ? 1 : -1;
      memset(mem, -1, sizeof mem);
      for (int j = 0; j < 4; j++)
        if (i & (1 << j)) fill(ox, oy, j);
      int t = solve(2, 0, 0, 0);
      if (neg == -1)
        ans = (ans + 1000000007 - t) % 1000000007;
      else
        ans = (ans + t) % 1000000007;
      for (int j = 0; j < 4; j++)
        if (i & (1 << j)) free(ox, oy, j);
    }
  }
  cout << ans << endl;
  return 0;
}
