#include <bits/stdc++.h>
using namespace std;
int d[10010][8];
int d1[8];
int p[3][10010];
int n;
vector<int> var;
int MD = 1000000007;
int mod(long long a) {
  if (a % MD < 0)
    return a % MD + MD;
  else
    return a % MD;
}
void put(int i, int prof) {
  if (prof == 0) {
    d[i + 1][7] = mod(d[i + 1][7] + d[i][0]);
    d[i + 1][1] = mod(d[i + 1][1] + d[i][0]);
    d[i + 1][4] = mod(d[i + 1][4] + d[i][0]);
  } else if (prof == 1) {
    d[i + 1][0] = mod(d[i + 1][0] + d[i][1]);
    d[i + 1][6] = mod(d[i + 1][6] + d[i][1]);
  } else if (prof == 2) {
    d[i + 1][5] = mod(d[i + 1][5] + d[i][2]);
  } else if (prof == 3) {
    d[i + 1][4] = mod(d[i + 1][4] + d[i][3]);
  } else if (prof == 4) {
    d[i + 1][0] = mod(d[i + 1][0] + d[i][4]);
    d[i + 1][3] = mod(d[i + 1][3] + d[i][4]);
  } else if (prof == 5) {
    d[i + 1][2] = mod(d[i + 1][2] + d[i][5]);
  } else if (prof == 6) {
    d[i + 1][1] = mod(d[i + 1][1] + d[i][6]);
  } else if (prof == 7) {
    d[i + 1][0] = mod(d[i + 1][0] + d[i][7]);
  }
}
int dyn() {
  memset(d, 0, sizeof(d));
  d[0][0] = 1;
  for (int i = 0; i < n; i++) {
    int prof = p[0][i] + p[1][i] * 2 + p[2][i] * 4;
    if (prof != 0) {
      memset(d1, 0, sizeof(d1));
      for (int j = 0; j < 8; j++) {
        if ((j & prof) != 0) d[i][j] = 0;
        d1[j | prof] = mod(d1[j | prof] + d[i][j]);
      }
      for (int j = 0; j < 8; j++) {
        d[i][j] = d1[j];
      }
    }
    for (int j = 0; j < 8; j++) {
      if (d[i][j] != 0) put(i, j);
    }
  }
  return d[n][0];
}
bool bit(int v, int i) { return (v >> i) & 1; }
int incl() {
  int ans = 0;
  int sz = var.size() / 4;
  int powsz = 1 << sz;
  for (int v = 1; v < powsz; v++) {
    int sgn = -1;
    int cnt = 0;
    for (int i = 0; i < sz; i++) {
      if (bit(v, i)) {
        p[var[i * 4]][var[i * 4 + 1]] = 1;
        p[var[i * 4 + 2]][var[i * 4 + 3]] = 1;
        sgn *= -1;
        cnt++;
      }
    }
    ans = mod(ans + sgn * dyn());
    for (int i = 0; i < sz; i++) {
      if (bit(v, i)) {
        p[var[i * 4]][var[i * 4 + 1]] = 0;
        p[var[i * 4 + 2]][var[i * 4 + 3]] = 0;
      }
    }
  }
  return ans;
}
int main() {
  cin >> n;
  int inpi, inpj;
  char c;
  for (int j = 0; j < 3; j++) {
    for (int i = 0; i < n; i++) {
      cin >> c;
      if (c == '.') p[j][i] = 0;
      if (c == 'X') p[j][i] = 1;
      if (c == 'O') {
        p[j][i] = 1;
        inpi = j;
        inpj = i;
      }
    }
  }
  if (inpi == 1) {
    if (inpj > 1 && p[inpi][inpj - 2] != 1) {
      var.push_back(inpi);
      var.push_back(inpj - 1);
      var.push_back(inpi);
      var.push_back(inpj - 2);
    }
    if (inpj < n - 2 && p[inpi][inpj + 2] != 1) {
      var.push_back(inpi);
      var.push_back(inpj + 1);
      var.push_back(inpi);
      var.push_back(inpj + 2);
    }
    cout << incl();
  } else {
    int opp = 2 - inpi;
    if (inpj > 1 && p[inpi][inpj - 2] != 1) {
      var.push_back(inpi);
      var.push_back(inpj - 1);
      var.push_back(inpi);
      var.push_back(inpj - 2);
    }
    if (inpj < n - 2 && p[inpi][inpj + 2] != 1) {
      var.push_back(inpi);
      var.push_back(inpj + 1);
      var.push_back(inpi);
      var.push_back(inpj + 2);
    }
    if (p[opp][inpj] != 1) {
      var.push_back(1);
      var.push_back(inpj);
      var.push_back(opp);
      var.push_back(inpj);
    }
    cout << incl();
  }
  return 0;
}
