#include <bits/stdc++.h>
using namespace std;
int total(vector<string> &s, int n) {
  int i, j, k;
  vector<int> mask(n, 0);
  for (i = 0; i < n; i++) {
    for (j = 0; j < 3; j++)
      if (s[j][i] != '.') mask[i] = mask[i] + (1 << j);
  }
  vector<vector<int> > v;
  for (i = 0; i < n + 1; i++) {
    vector<int> t(8, 0);
    v.push_back(t);
  }
  v[0][mask[0]] = 1;
  if (((3 ^ mask[0]) & 3) == 3) v[0][(3 | mask[0])] = 1;
  if (((6 ^ mask[0]) & 6) == 6) {
    v[0][(6 | mask[0])] = 1;
  }
  for (i = 1; i <= n - 1; i++) {
    for (j = 0; j < 8; j++) {
      if ((j | mask[i]) == j) {
        k = (j ^ mask[i]);
        v[i][j] = v[i - 1][(7 ^ k)];
        if ((k & 3) == 3)
          v[i][j] = (v[i][j] + v[i - 1][(7 ^ (k ^ 3))]) % 1000000007;
        if ((k & 6) == 6)
          v[i][j] = (v[i][j] + v[i - 1][(7 ^ (k ^ 6))]) % 1000000007;
      }
    }
  }
  return v[n - 1][7];
}
int main() {
  long long n, i, j, x, y;
  cin >> n;
  vector<string> s(3);
  cin >> s[0] >> s[1] >> s[2];
  bool fl = false;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < n; j++) {
      if (s[i][j] == 'O') {
        fl = true;
        break;
      }
    }
    if (fl) break;
  }
  x = i;
  y = j;
  vector<pair<int, int> > v;
  if (x - 2 >= 0 && s[x - 2][y] == '.' && s[x - 1][y] == '.')
    v.push_back(make_pair(-1, 0));
  if (x + 2 < 3 && s[x + 2][y] == '.' && s[x + 1][y] == '.')
    v.push_back(make_pair(1, 0));
  if (y - 2 >= 0 && s[x][y - 2] == '.' && s[x][y - 1] == '.')
    v.push_back(make_pair(0, -1));
  if (y + 2 < n && s[x][y + 2] == '.' && s[x][y + 1] == '.')
    v.push_back(make_pair(0, 1));
  int sum = 0;
  for (i = 0; i < (int)v.size(); i++) {
    s[x + v[i].first][y + v[i].second] = 'X';
    s[x + 2 * v[i].first][y + 2 * v[i].second] = 'X';
    sum = (sum + total(s, n)) % 1000000007;
    s[x + v[i].first][y + v[i].second] = '.';
    s[x + 2 * v[i].first][y + 2 * v[i].second] = '.';
  }
  for (i = 0; i < (int)v.size(); i++) {
    for (j = i + 1; j <= (int)v.size() - 1; j++) {
      s[x + v[j].first][y + v[j].second] = 'X';
      s[x + 2 * v[j].first][y + 2 * v[j].second] = 'X';
      s[x + v[i].first][y + v[i].second] = 'X';
      s[x + 2 * v[i].first][y + 2 * v[i].second] = 'X';
      sum = (sum - total(s, n) + 1000000007) % 1000000007;
      s[x + v[i].first][y + v[i].second] = '.';
      s[x + 2 * v[i].first][y + 2 * v[i].second] = '.';
      s[x + v[j].first][y + v[j].second] = '.';
      s[x + 2 * v[j].first][y + 2 * v[j].second] = '.';
    }
  }
  if ((int)v.size() == 3) {
    s[x + v[0].first][y + v[0].second] = 'X';
    s[x + 2 * v[0].first][y + 2 * v[0].second] = 'X';
    s[x + v[1].first][y + v[1].second] = 'X';
    s[x + 2 * v[1].first][y + 2 * v[1].second] = 'X';
    s[x + v[2].first][y + v[2].second] = 'X';
    s[x + 2 * v[2].first][y + 2 * v[2].second] = 'X';
    sum = (sum + total(s, n)) % 1000000007;
    s[x + v[0].first][y + v[0].second] = '.';
    s[x + 2 * v[0].first][y + 2 * v[0].second] = '.';
    s[x + v[1].first][y + v[1].second] = '.';
    s[x + 2 * v[1].first][y + 2 * v[1].second] = '.';
    s[x + v[2].first][y + v[2].second] = '.';
    s[x + 2 * v[2].first][y + 2 * v[2].second] = '.';
  }
  cout << sum << endl;
  return 0;
}
