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;
int M = 1e9 + 7;
int n, h = 1, s[4][10005][6], v[4][10005][6];
char a[4][10005];
int f(int p, int q) {
  int i, k = 0, cnt = 0;
  if (p > 3) return f(1, q + 1);
  if (q > n) return 1;
  if (a[p][q] != '.') return f(p + 1, q);
  for (i = p + 1; i <= 3; i++) {
    k = k * 2;
    if (a[i][q] != '.') k++;
  }
  for (i = 1; i < p; i++) {
    k = k * 2;
    if (a[i][q + 1] != '.') k++;
  }
  if (v[p][q][k] == h) return s[p][q][k];
  v[p][q][k] = h;
  a[p][q] = 'X';
  if (p + 1 <= 3 && a[p + 1][q] == '.') {
    a[p + 1][q] = 'X';
    cnt = (cnt + f(p + 2, q)) % M;
    a[p + 1][q] = '.';
  }
  if (q + 1 <= n && a[p][q + 1] == '.') {
    a[p][q + 1] = 'X';
    cnt = (cnt + f(p + 1, q)) % M;
    a[p][q + 1] = '.';
  }
  a[p][q] = '.';
  return s[p][q][k] = cnt;
}
int main() {
  int i, j, r, c, s1, s2;
  cin >> n;
  for (i = 1; i <= 3; i++) {
    scanf("%s", &a[i][1]);
    for (j = 1; j <= n; j++) {
      if (a[i][j] == 'O') {
        r = i;
        c = j;
      }
    }
  }
  h = 1;
  s1 = f(1, 1);
  if (s1 == 0) {
    s2 = 0;
  } else {
    a[r - 1][c - 1] = 'X';
    a[r - 1][c] = 'X';
    a[r - 1][c + 1] = 'X';
    a[r][c - 1] = 'X';
    a[r][c + 1] = 'X';
    a[r + 1][c - 1] = 'X';
    a[r + 1][c] = 'X';
    a[r + 1][c + 1] = 'X';
    h = 2;
    s2 = (f(1, 1) * 2) % M;
  }
  cout << (s1 - s2 + M) % M << endl;
  return 0;
}
