#include <bits/stdc++.h>

using namespace std;

const int md = (int) 1e9 + 7;

vector<int> fact, inv, inv_fact, inv_fact_sum;

struct poly {
  vector<int> p, q;
  int c;

  poly(vector<int> p = vector<int>(), vector<int> q = vector<int>(), int c = 0): p(p), q(q), c(c) {
  }
};

struct info {
  int p, q, r;

  info(int p = 0, int q = 0, int r = 0): p(p), q(q), r(r) {
  }
};

inline void add(int &x, int y) {
  x += y;
  if (x >= md) {
    x -= md;
  }
}

inline void sub(int &x, int y) {
  x -= y;
  if (x < 0) {
    x += md;
  }
}

inline int mul(int x, int y) {
  return (int) ((long long) x * y % md);
}

vector<int>& operator += (vector<int> &a, const vector<int> &b) {
  if (a.size() < b.size()) {
    a.resize(b.size());
  }
  for (int i = 0; i < (int) b.size(); ++i) {
    add(a[i], b[i]);
  }
  return a;
}

poly& operator += (poly &a, const poly &b) {
  a.p += b.p;
  a.q += b.q;
  add(a.c, b.c);
  return a;
}

info& operator += (info &a, const info &b) {
  add(a.p, b.p);
  add(a.q, b.q);
  add(a.r, b.r);
  return a;
}

info& operator -= (info &a, const info &b) {
  sub(a.p, b.p);
  sub(a.q, b.q);
  sub(a.r, b.r);
  return a;
}

poly integral_0_x(const poly &a) {
  vector<int> pp, qq;
  int cc;
  pp.push_back(a.c);
  for (int i = 0; i < (int) a.p.size(); ++i) {
    pp.push_back(mul(a.p[i], inv[i + 1]));
  }
  qq.push_back(0);
  for (int i = 0; i < (int) a.q.size(); ++i) {
    qq.push_back(mul(a.q[i], inv[i + 1]));
  }
  cc = (md - a.c) % md;
  return poly(pp, qq, cc);
}

poly integral_x_1(const poly &a) {
  vector<int> pp, qq;
  int cc;
  pp.push_back(0);
  for (int i = 0; i < (int) a.p.size(); ++i) {
    int coef = mul(a.p[i], inv[i + 1]);
    add(pp[0], coef);
    pp.push_back((md - coef) % md);
  }
  qq.push_back((md - a.c) % md);
  for (int i = 0; i < (int) a.q.size(); ++i) {
    int coef = mul(a.q[i], inv[i + 1]);
    add(qq[0], coef);
    qq.push_back((md - coef) % md);
  }
  cc = a.c;
  return poly(pp, qq, cc);
}

info integral_0_1(const poly &a) {
  int p, q, r;
  p = a.c;
  for (int i = 0; i < (int) a.p.size(); ++i) {
    add(p, mul(a.p[i], inv[i + 1]));
  }
  q = (md - a.c) % md;
  for (int i = 0; i < (int) a.q.size(); ++i) {
    add(q, mul(a.q[i], inv[i + 1]));
  }
  r = 0;
  return info(p, q, r);
}

info integral_0_1_e(const poly &a) {
  int p, q, r;
  p = 0;
  for (int i = 0; i < (int) a.p.size(); ++i) {
    add(p, mul(a.p[i], fact[i]));
  }
  add(p, mul(a.c, (md + 1) >> 1));
  q = 0;
  for (int i = 0; i < (int) a.p.size(); ++i) {
    sub(q, mul(a.p[i], mul(fact[i], inv_fact_sum[i])));
  }
  for (int i = 0; i < (int) a.q.size(); ++i) {
    add(q, mul(a.q[i], fact[i]));
  }
  r = 0;
  for (int i = 0; i < (int) a.q.size(); ++i) {
    sub(r, mul(a.q[i], mul(fact[i], inv_fact_sum[i])));
  }
  sub(r, mul(a.c, (md + 1) >> 1));
  return info(p, q, r);
}

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n;
  string s;
  cin >> n >> s;
  vector<vector<vector<vector<poly>>>> dp(n, vector<vector<vector<poly>>>(2, vector<vector<poly>>(2, vector<poly>(2))));
  fact.resize(n + 1);
  inv.resize(n + 1);
  inv_fact.resize(n + 1);
  inv_fact_sum.resize(n + 1);
  fact[0] = fact[1] = inv[0] = inv[1] = inv_fact[0] = inv_fact[1] = inv_fact_sum[0] = 1;
  inv_fact_sum[1] = 2;
  for (int i = 2; i <= n; ++i) {
    fact[i] = mul(fact[i - 1], i);
    inv[i] = mul(md - md / i, inv[md % i]);
    inv_fact[i] = mul(inv_fact[i - 1], inv[i]);
    inv_fact_sum[i] = inv_fact_sum[i - 1];
    add(inv_fact_sum[i], inv_fact[i]);
  }
  if (s[0] == 'X') {
    dp[0][0][1][0] = poly(vector<int>(), vector<int>(), 1);
  } else {
    dp[0][0][0][1] = poly(vector<int>(), vector<int>(), 1);
    dp[0][1][1][1] = poly(vector<int>(1, 1), vector<int>(), md - 1);
  }
  for (int i = 1; i < n; ++i) {
    if (s[i] == 'X') {
      for (int j = 0; j < 2; ++j) {
        dp[i][0][1][0] += integral_0_x(dp[i - 1][1][1][j]);
      }
      for (int j = 0; j < 2; ++j) {
        for (int k = 0; k < 2; ++k) {
          dp[i][0][1][0] += integral_x_1(dp[i - 1][j][k][1]);
        }
      }
    } else {
      for (int j = 0; j < 2; ++j) {
        dp[i][0][0][1] += integral_0_x(dp[i - 1][1][1][j]);
        dp[i][1][1][1] += integral_0_x(dp[i - 1][0][1][j]);
      }
      for (int j = 0; j < 2; ++j) {
        for (int k = 0; k < 2; ++k) {
          dp[i][0][0][1] += integral_x_1(dp[i - 1][j][1][k]);
        }
      }
    }
  }
  info ans;
  for (int i = 0; i < 2; ++i) {
    ans += integral_0_1(dp[n - 1][i][0][1]);
    ans += integral_0_1(dp[n - 1][i][1][1]);
    ans += integral_0_1_e(dp[n - 1][i][1][0]);
    ans -= integral_0_1_e(dp[n - 1][i][0][1]);
  }
  cout << ans.p << " " << ans.q << " " << ans.r << "\n";
  return 0;
}

### Prompt

Please formulate a cpp solution to the following problem:

There is a very long bench. The bench is divided into M sections, where M is a very large integer.

Initially, the bench is vacant. Then, M people come to the bench one by one, and perform the following action:

* We call a section comfortable if the section is currently unoccupied and is not adjacent to any occupied sections. If there is no comfortable section, the person leaves the bench. Otherwise, the person chooses one of comfortable sections uniformly at random, and sits there. (The choices are independent from each other).



After all M people perform actions, Snuke chooses an interval of N consecutive sections uniformly at random (from M-N+1 possible intervals), and takes a photo. His photo can be described by a string of length N consisting of `X` and `-`: the i-th character of the string is `X` if the i-th section from the left in the interval is occupied, and `-` otherwise. Note that the photo is directed. For example, `-X--X` and `X--X-` are different photos.

What is the probability that the photo matches a given string s? This probability depends on M. You need to compute the limit of this probability when M goes infinity.

Here, we can prove that the limit can be uniquely written in the following format using three rational numbers p, q, r and e = 2.718 \ldots (the base of natural logarithm):

p + \frac{q}{e} + \frac{r}{e^2}

Your task is to compute these three rational numbers, and print them modulo 10^9 + 7, as described in Notes section.

Constraints

* 1 \leq N \leq 1000
* |s| = N
* s consists of `X` and `-`.

Input

Input is given from Standard Input in the following format:


N
s


Output

Print three rational numbers p, q, r, separated by spaces.

Examples

Input

1
X


Output

500000004 0 500000003


Input

3
---


Output

0 0 0


Input

5
X--X-


Output

0 0 1


Input

5
X-X-X


Output

500000004 0 833333337


Input

20
-X--X--X-X--X--X-X-X


Output

0 0 183703705


Input

100
X-X-X-X-X-X-X-X-X-X--X-X-X-X-X-X-X-X-X-X-X-X-X-X-X--X--X-X-X-X--X--X-X-X--X-X-X--X-X--X--X-X--X-X-X-


Output

0 0 435664291

### Response

```cpp
#include <bits/stdc++.h>

using namespace std;

const int md = (int) 1e9 + 7;

vector<int> fact, inv, inv_fact, inv_fact_sum;

struct poly {
  vector<int> p, q;
  int c;

  poly(vector<int> p = vector<int>(), vector<int> q = vector<int>(), int c = 0): p(p), q(q), c(c) {
  }
};

struct info {
  int p, q, r;

  info(int p = 0, int q = 0, int r = 0): p(p), q(q), r(r) {
  }
};

inline void add(int &x, int y) {
  x += y;
  if (x >= md) {
    x -= md;
  }
}

inline void sub(int &x, int y) {
  x -= y;
  if (x < 0) {
    x += md;
  }
}

inline int mul(int x, int y) {
  return (int) ((long long) x * y % md);
}

vector<int>& operator += (vector<int> &a, const vector<int> &b) {
  if (a.size() < b.size()) {
    a.resize(b.size());
  }
  for (int i = 0; i < (int) b.size(); ++i) {
    add(a[i], b[i]);
  }
  return a;
}

poly& operator += (poly &a, const poly &b) {
  a.p += b.p;
  a.q += b.q;
  add(a.c, b.c);
  return a;
}

info& operator += (info &a, const info &b) {
  add(a.p, b.p);
  add(a.q, b.q);
  add(a.r, b.r);
  return a;
}

info& operator -= (info &a, const info &b) {
  sub(a.p, b.p);
  sub(a.q, b.q);
  sub(a.r, b.r);
  return a;
}

poly integral_0_x(const poly &a) {
  vector<int> pp, qq;
  int cc;
  pp.push_back(a.c);
  for (int i = 0; i < (int) a.p.size(); ++i) {
    pp.push_back(mul(a.p[i], inv[i + 1]));
  }
  qq.push_back(0);
  for (int i = 0; i < (int) a.q.size(); ++i) {
    qq.push_back(mul(a.q[i], inv[i + 1]));
  }
  cc = (md - a.c) % md;
  return poly(pp, qq, cc);
}

poly integral_x_1(const poly &a) {
  vector<int> pp, qq;
  int cc;
  pp.push_back(0);
  for (int i = 0; i < (int) a.p.size(); ++i) {
    int coef = mul(a.p[i], inv[i + 1]);
    add(pp[0], coef);
    pp.push_back((md - coef) % md);
  }
  qq.push_back((md - a.c) % md);
  for (int i = 0; i < (int) a.q.size(); ++i) {
    int coef = mul(a.q[i], inv[i + 1]);
    add(qq[0], coef);
    qq.push_back((md - coef) % md);
  }
  cc = a.c;
  return poly(pp, qq, cc);
}

info integral_0_1(const poly &a) {
  int p, q, r;
  p = a.c;
  for (int i = 0; i < (int) a.p.size(); ++i) {
    add(p, mul(a.p[i], inv[i + 1]));
  }
  q = (md - a.c) % md;
  for (int i = 0; i < (int) a.q.size(); ++i) {
    add(q, mul(a.q[i], inv[i + 1]));
  }
  r = 0;
  return info(p, q, r);
}

info integral_0_1_e(const poly &a) {
  int p, q, r;
  p = 0;
  for (int i = 0; i < (int) a.p.size(); ++i) {
    add(p, mul(a.p[i], fact[i]));
  }
  add(p, mul(a.c, (md + 1) >> 1));
  q = 0;
  for (int i = 0; i < (int) a.p.size(); ++i) {
    sub(q, mul(a.p[i], mul(fact[i], inv_fact_sum[i])));
  }
  for (int i = 0; i < (int) a.q.size(); ++i) {
    add(q, mul(a.q[i], fact[i]));
  }
  r = 0;
  for (int i = 0; i < (int) a.q.size(); ++i) {
    sub(r, mul(a.q[i], mul(fact[i], inv_fact_sum[i])));
  }
  sub(r, mul(a.c, (md + 1) >> 1));
  return info(p, q, r);
}

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n;
  string s;
  cin >> n >> s;
  vector<vector<vector<vector<poly>>>> dp(n, vector<vector<vector<poly>>>(2, vector<vector<poly>>(2, vector<poly>(2))));
  fact.resize(n + 1);
  inv.resize(n + 1);
  inv_fact.resize(n + 1);
  inv_fact_sum.resize(n + 1);
  fact[0] = fact[1] = inv[0] = inv[1] = inv_fact[0] = inv_fact[1] = inv_fact_sum[0] = 1;
  inv_fact_sum[1] = 2;
  for (int i = 2; i <= n; ++i) {
    fact[i] = mul(fact[i - 1], i);
    inv[i] = mul(md - md / i, inv[md % i]);
    inv_fact[i] = mul(inv_fact[i - 1], inv[i]);
    inv_fact_sum[i] = inv_fact_sum[i - 1];
    add(inv_fact_sum[i], inv_fact[i]);
  }
  if (s[0] == 'X') {
    dp[0][0][1][0] = poly(vector<int>(), vector<int>(), 1);
  } else {
    dp[0][0][0][1] = poly(vector<int>(), vector<int>(), 1);
    dp[0][1][1][1] = poly(vector<int>(1, 1), vector<int>(), md - 1);
  }
  for (int i = 1; i < n; ++i) {
    if (s[i] == 'X') {
      for (int j = 0; j < 2; ++j) {
        dp[i][0][1][0] += integral_0_x(dp[i - 1][1][1][j]);
      }
      for (int j = 0; j < 2; ++j) {
        for (int k = 0; k < 2; ++k) {
          dp[i][0][1][0] += integral_x_1(dp[i - 1][j][k][1]);
        }
      }
    } else {
      for (int j = 0; j < 2; ++j) {
        dp[i][0][0][1] += integral_0_x(dp[i - 1][1][1][j]);
        dp[i][1][1][1] += integral_0_x(dp[i - 1][0][1][j]);
      }
      for (int j = 0; j < 2; ++j) {
        for (int k = 0; k < 2; ++k) {
          dp[i][0][0][1] += integral_x_1(dp[i - 1][j][1][k]);
        }
      }
    }
  }
  info ans;
  for (int i = 0; i < 2; ++i) {
    ans += integral_0_1(dp[n - 1][i][0][1]);
    ans += integral_0_1(dp[n - 1][i][1][1]);
    ans += integral_0_1_e(dp[n - 1][i][1][0]);
    ans -= integral_0_1_e(dp[n - 1][i][0][1]);
  }
  cout << ans.p << " " << ans.q << " " << ans.r << "\n";
  return 0;
}

```