#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 10005;
const int mod = 1000000007;
char str[3][maxn];
int n;
long long f[maxn][4][4][4][2];
bool test_2(int x, int y, int z) {
  if (x == 1 && z == 1) return 0;
  int cnt = 0;
  if (x == 1) cnt++;
  if (y == 1) cnt++;
  if (z == 1) cnt++;
  return cnt != 1;
}
bool test_1(int x, int y, int z, int a, int b, int c, int idx) {
  if (x == 2 && a != 3) return 0;
  if (y == 2 && b != 3) return 0;
  if (z == 2 && c != 3) return 0;
  if (x != 2 && a == 3) return 0;
  if (y != 2 && b == 3) return 0;
  if (z != 2 && c == 3) return 0;
  if (str[0][idx] != '.' && a != 0) return 0;
  if (str[1][idx] != '.' && b != 0) return 0;
  if (str[2][idx] != '.' && c != 0) return 0;
  if (a == 0 && str[0][idx] == '.') return 0;
  if (b == 0 && str[1][idx] == '.') return 0;
  if (c == 0 && str[2][idx] == '.') return 0;
  return 1;
}
bool test_3(int x, int y, int z, int a, int b, int c, int idx) {
  if (x == 3 && str[0][idx] == 'O') return 1;
  if (y == 3 && str[1][idx] == 'O') return 1;
  if (z == 3 && str[2][idx] == 'O') return 1;
  if (a == 1 && str[2][idx] == 'O') return 1;
  if (b == 1 && (str[0][idx] == 'O' || str[2][idx] == 'O')) return 1;
  if (c == 1 && str[0][idx] == 'O') return 1;
  if (idx > 0) {
    if (a == 2 && str[0][idx - 1] == 'O') return 1;
    if (b == 2 && str[1][idx - 1] == 'O') return 1;
    if (c == 2 && str[2][idx - 1] == 'O') return 1;
    return 0;
  }
  return 0;
}
int main() {
  f[0][0][0][0][0] = 1;
  scanf("%d", &n);
  for (int i = 0; i < 3; i++) scanf("%s", str[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 4; j++)
      for (int k = 0; k < 4; k++)
        for (int r = 0; r < 4; r++) {
          if (!test_2(j, k, r)) continue;
          for (int p = 0; p < 4; p++)
            for (int q = 0; q < 4; q++)
              for (int s = 0; s < 4; s++) {
                if (!test_2(p, q, s)) continue;
                if (!test_1(j, k, r, p, q, s, i)) continue;
                int sign = test_3(j, k, r, p, q, s, i);
                if (!sign) {
                  f[i + 1][p][q][s][0] += f[i][j][k][r][0];
                  if (f[i + 1][p][q][s][0] >= mod) f[i + 1][p][q][s][0] -= mod;
                }
                f[i + 1][p][q][s][1] += f[i][j][k][r][1];
                if (f[i + 1][p][q][s][1] >= mod) f[i + 1][p][q][s][1] -= mod;
                if (sign) f[i + 1][p][q][s][1] += f[i][j][k][r][0];
                if (f[i + 1][p][q][s][1] >= mod) f[i + 1][p][q][s][1] -= mod;
              }
        }
  long long ret = 0;
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      for (int k = 0; k < 4; k++) {
        if (i == 2 || j == 2 || k == 2) continue;
        ret = (ret + f[n][i][j][k][1]) % mod;
      }
  printf("%I64d\n", ret);
  return 0;
}
