#include <bits/stdc++.h>
using namespace std;
int t[100005];
int l[100005];
int r[100005];
int dp[10005][8];
string str[3];
const int mod = 1000000007;
int n;
int meow() {
  fill(dp[0], dp[0] + 8, 0);
  dp[0][0] = 1;
  if ('.' == str[0][0] && '.' == str[1][0]) dp[0][3] = 1;
  if ('.' == str[1][0] && '.' == str[2][0]) dp[0][6] = 1;
  int mask = 0;
  for (int k = 0; k != 3; ++k) {
    if ('.' != str[k][0]) mask += (1 << k);
  }
  if (mask)
    for (int k = 0; k != 8; ++k) {
      if (mask == (k & mask)) dp[0][k] = dp[0][k - mask];
    }
  for (int i = 1; i != n; ++i) {
    fill(dp[i], dp[i] + 8, 0);
    for (int k = 0; k != 8; ++k) {
      bool can = 1;
      for (int l = 0; l != 3; ++l)
        if (((7 - k) & (1 << l)) && ('.' != str[l][i - 1] || '.' != str[l][i]))
          can = 0;
      if (can) dp[i][7 - k] = (dp[i][7 - k] + dp[i - 1][k]) % mod;
    }
    if ('.' == str[0][i] && '.' == str[1][i]) {
      dp[i][3] = (dp[i][3] + dp[i][0]) % mod;
      dp[i][7] = (dp[i][7] + dp[i][4]) % mod;
    }
    if ('.' == str[1][i] && '.' == str[2][i]) {
      dp[i][6] = (dp[i][6] + dp[i][0]) % mod;
      dp[i][7] = (dp[i][7] + dp[i][1]) % mod;
    }
    int mask = 0;
    for (int k = 0; k != 3; ++k) {
      if ('.' != str[k][i]) mask += (1 << k);
    }
    if (mask)
      for (int k = 0; k != 8; ++k) {
        if (mask == (k & mask)) dp[i][k] = (dp[i][k] + dp[i][k - mask]) % mod;
      }
  }
  return dp[n - 1][7];
}
int x, y;
int A() {
  if (y - 2 >= 0 && str[x][y - 1] == str[x][y - 2]) {
    if ('.' == str[x][y - 1]) {
      str[x][y - 1] = str[x][y - 2] = 'B';
      return 1;
    } else if ('B' == str[x][y - 1]) {
      str[x][y - 1] = str[x][y - 2] = '.';
      return 1;
    }
  }
  return 0;
}
int B() {
  if (y <= n - 1 - 2 && str[x][y + 1] == str[x][y + 2]) {
    if ('.' == str[x][y + 1]) {
      str[x][y + 1] = str[x][y + 2] = 'B';
      return 1;
    } else if ('B' == str[x][y + 1]) {
      str[x][y + 1] = str[x][y + 2] = '.';
      return 1;
    }
  }
  return 0;
}
int C() {
  if (x == 0 && str[1][y] == str[2][y]) {
    if ('.' == str[1][y]) {
      str[1][y] = str[2][y] = 'B';
      return 1;
    } else if ('B' == str[1][y]) {
      str[1][y] = str[2][y] = '.';
      return 1;
    }
  }
  if (x == 2 && str[1][y] == str[0][y]) {
    if ('.' == str[1][y]) {
      str[1][y] = str[0][y] = 'B';
      return 1;
    } else if ('B' == str[1][y]) {
      str[1][y] = str[0][y] = '.';
      return 1;
    }
  }
  return 0;
}
int main() {
  while (cin >> n) {
    cin >> str[0] >> str[1] >> str[2];
    for (int i = 0; i != 3; ++i) {
      for (int j = 0; j != n; ++j) {
        if ('O' == str[i][j]) x = i, y = j;
      }
    }
    A();
    int AA = meow();
    if (!A()) AA = 0;
    B();
    int BB = meow();
    if (!B()) BB = 0;
    C();
    int CC = meow();
    if (!C()) CC = 0;
    A();
    B();
    int AB = meow();
    if (2 != A() + B()) AB = 0;
    B();
    C();
    int BC = meow();
    if (2 != B() + C()) BC = 0;
    A();
    C();
    int AC = meow();
    if (2 != A() + C()) AC = 0;
    A();
    B();
    C();
    int ABC = meow();
    if (3 != A() + B() + C()) ABC = 0;
    cout << ((AA + BB + CC) % mod + mod - (AB + BC + AC) % mod + ABC) % mod
         << endl;
  }
}
