Xenia likes puzzles very much. She is especially fond of the puzzles that consist of domino pieces. Look at the picture that shows one of such puzzles.

<image>

A puzzle is a 3 × n table with forbidden cells (black squares) containing dominoes (colored rectangles on the picture). A puzzle is called correct if it meets the following conditions:

  * each domino occupies exactly two non-forbidden cells of the table; 
  * no two dominoes occupy the same table cell; 
  * exactly one non-forbidden cell of the table is unoccupied by any domino (it is marked by a circle in the picture). 



To solve the puzzle, you need multiple steps to transport an empty cell from the starting position to some specified position. A move is transporting a domino to the empty cell, provided that the puzzle stays correct. The horizontal dominoes can be moved only horizontally, and vertical dominoes can be moved only vertically. You can't rotate dominoes. The picture shows a probable move.

Xenia has a 3 × n table with forbidden cells and a cell marked with a circle. Also, Xenia has very many identical dominoes. Now Xenia is wondering, how many distinct correct puzzles she can make if she puts dominoes on the existing table. Also, Xenia wants the circle-marked cell to be empty in the resulting puzzle. The puzzle must contain at least one move.

Help Xenia, count the described number of puzzles. As the described number can be rather large, print the remainder after dividing it by 1000000007 (109 + 7).

Input

The first line contains integer n (3 ≤ n ≤ 104) — the puzzle's size. Each of the following three lines contains n characters — the description of the table. The j-th character of the i-th line equals "X" if the corresponding cell is forbidden; it equals ".", if the corresponding cell is non-forbidden and "O", if the corresponding cell is marked with a circle.

It is guaranteed that exactly one cell in the table is marked with a circle. It is guaranteed that all cells of a given table having at least one common point with the marked cell is non-forbidden.

Output

Print a single number — the answer to the problem modulo 1000000007 (109 + 7).

Examples

Input

5
....X
.O...
...X.


Output

1


Input

5
.....
.O...
.....


Output

2


Input

3
...
...
..O


Output

4

Note

Two puzzles are considered distinct if there is a pair of cells that contain one domino in one puzzle and do not contain it in the other one.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 10010;
const long long mod = 1e9 + 7;
long long f[maxn][8], g[maxn][8];
char a[3][maxn];
int n;
int lst[3], now[3];
long long work() {
  memset(f, 0, sizeof(f));
  f[0][0] = 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 8; j++) {
      if (!f[i][j]) continue;
      int t = j;
      for (int k = 2; k >= 0; k--) lst[k] = t % 2, t /= 2;
      for (int k = 0; k < 8; k++) {
        int t = k;
        for (int l = 2; l >= 0; l--) now[l] = t % 2, t /= 2;
        bool flag = true;
        for (int l = 0; l <= 2; l++) {
          if (now[l] && a[l][i + 1] == 'X') flag = false;
          if (now[l] == lst[l] && a[l][i + 1] == '.') flag = false;
          if (lst[l] && a[l][i + 1] == 'X') flag = false;
        }
        if (flag) (f[i + 1][k] += f[i][j]) %= mod;
      }
      if (a[0][i + 1] == '.' && a[1][i + 1] == '.' && lst[0] == 0 &&
          lst[1] == 0) {
        now[0] = now[1] = 0;
        if (a[2][i + 1] == 'X' && lst[2] == 1) continue;
        if (a[2][i + 1] == 'X')
          now[2] = 0;
        else
          now[2] = 1 - lst[2];
        t = 0;
        for (int k = 0; k <= 2; k++) t = t * 2 + now[k];
        (f[i + 1][t] += f[i][j]) %= mod;
      }
      if (a[1][i + 1] == '.' && a[2][i + 1] == '.' && lst[1] == 0 &&
          lst[2] == 0) {
        now[1] = now[2] = 0;
        if (a[0][i + 1] == 'X' && lst[0] == 1) continue;
        if (a[0][i + 1] == 'X')
          now[0] = 0;
        else
          now[0] = 1 - lst[0];
        t = 0;
        for (int k = 0; k <= 2; k++) t = t * 2 + now[k];
        (f[i + 1][t] += f[i][j]) %= mod;
      }
    }
  return f[n][0];
}
char in[3][maxn];
void copy() {
  for (int i = 0; i < 3; i++)
    for (int j = 1; j <= n; j++) a[i][j] = in[i][j];
}
void give(int x, int y) { a[x][y] = 'X'; }
bool check(int x, int y) {
  if (x < 0 || x >= 3 || y <= 0 || y > n) return false;
  if (in[x][y] == 'X') return false;
  return true;
}
int canx[3][2] = {0}, cany[3][2] = {0};
bool ok[7][3];
int sign[7];
int main() {
  std::ios::sync_with_stdio(false);
  cany[0][0] = -1, cany[0][1] = -2;
  cany[1][0] = 1, cany[1][1] = 2;
  canx[2][0] = 1, canx[2][1] = 2;
  ok[0][0] = true, ok[1][1] = true, ok[2][2] = true;
  ok[3][0] = ok[3][1] = true;
  ok[4][0] = ok[4][2] = true;
  ok[5][1] = ok[5][2] = true;
  ok[6][1] = ok[6][2] = ok[6][3] = true;
  sign[0] = sign[1] = sign[2] = sign[6] = 1, sign[3] = sign[4] = sign[5] = -1;
  int x, sn;
  cin >> n;
  for (int i = 0; i < 3; i++)
    for (int j = 1; j <= n; j++) {
      cin >> in[i][j];
      if (in[i][j] == 'O') sn = j, x = i;
    }
  in[0][0] = in[1][0] = in[2][0] = 'X';
  if (x == 2) {
    for (int i = 1; i <= n; i++) swap(in[0][i], in[2][i]);
    x = 0;
  }
  in[x][sn] = 'X';
  long long ans = 0;
  for (int _ = 0; _ <= 6; _++) {
    bool flag = true;
    for (int i = 0; i <= 2; i++) {
      if (!ok[_][i]) continue;
      for (int j = 0; j < 2; j++)
        if (!check(x + canx[i][j], sn + cany[i][j])) flag = false;
    }
    if (flag) {
      copy();
      for (int i = 0; i <= 2; i++) {
        if (!ok[_][i]) continue;
        for (int j = 0; j < 2; j++)
          give(x + canx[i][j], sn + cany[i][j]),
              give(x + canx[i][j], sn + cany[i][j]);
      }
      ans += work() * sign[_];
    }
  }
  ans %= mod;
  if (ans < 0) ans += mod;
  cout << ans << endl;
  return 0;
}
