### Prompt

Generate a cpp solution to the following problem:

Sasha lives in a big happy family. At the Man's Day all the men of the family gather to celebrate it following their own traditions. There are n men in Sasha's family, so let's number them with integers from 1 to n.

Each man has at most one father but may have arbitrary number of sons.

Man number A is considered to be the ancestor of the man number B if at least one of the following conditions is satisfied:

  * A = B;
  * the man number A is the father of the man number B;
  * there is a man number C, such that the man number A is his ancestor and the man number C is the father of the man number B.

Of course, if the man number A is an ancestor of the man number B and A ≠ B, then the man number B is not an ancestor of the man number A.

The tradition of the Sasha's family is to give gifts at the Man's Day. Because giving gifts in a normal way is boring, each year the following happens.

  1. A list of candidates is prepared, containing some (possibly all) of the n men in some order.
  2. Each of the n men decides to give a gift.
  3. In order to choose a person to give a gift to, man A looks through the list and picks the first man B in the list, such that B is an ancestor of A and gives him a gift. Note that according to definition it may happen that a person gives a gift to himself.
  4. If there is no ancestor of a person in the list, he becomes sad and leaves the celebration without giving a gift to anyone.

This year you have decided to help in organizing celebration and asked each of the n men, who do they want to give presents to (this person is chosen only among ancestors). Are you able to make a list of candidates, such that all the wishes will be satisfied if they give gifts according to the process described above?

Input

In the first line of the input two integers n and m (0 ≤ m < n ≤ 100 000) are given — the number of the men in the Sasha's family and the number of family relations in it respectively.

The next m lines describe family relations: the (i + 1)th line consists of pair of integers pi and qi (1 ≤ pi, qi ≤ n, pi ≠ qi) meaning that the man numbered pi is the father of the man numbered qi. It is guaranteed that every pair of numbers appears at most once, that among every pair of two different men at least one of them is not an ancestor of another and that every man has at most one father.

The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ n), ith of which means that the man numbered i wants to give a gift to the man numbered ai. It is guaranteed that for every 1 ≤ i ≤ n the man numbered ai is an ancestor of the man numbered i.

Output

Print an integer k (1 ≤ k ≤ n) — the number of the men in the list of candidates, in the first line.

Print then k pairwise different positive integers not exceeding n — the numbers of the men in the list in an order satisfying every of the men's wishes, one per line.

If there are more than one appropriate lists, print any of them. If there is no appropriate list print  - 1 in the only line.

Examples

Input

3 2
1 2
2 3
1 2 1

Output

-1

Input

4 2
1 2
3 4
1 2 3 3

Output

3
2
1
3

Note

The first sample explanation:

  * if there would be no 1 in the list then the first and the third man's wishes would not be satisfied (a1 = a3 = 1);
  * if there would be no 2 in the list then the second man wish would not be satisfied (a2 = 2);
  * if 1 would stay before 2 in the answer then the second man would have to give his gift to the first man, but he wants to give it to himself (a2 = 2).
  * if, at the other hand, the man numbered 2 would stay before the man numbered 1, then the third man would have to give his gift to the second man, but not to the first (a3 = 1).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> G[100100];
vector<int> ans;
bool full[100100];
bool is[100100];
int dep[100100], want[100100];
bool cmp(const int &o, const int &p) { return dep[want[o]] > dep[want[p]]; }
void dfs(int o, int fa, int depth) {
  dep[o] = depth;
  for (auto &i : G[o]) {
    dfs(i, o, depth + 1);
    if (i == want[i]) {
      if (!full[i]) {
        full[i] = true;
        ans.push_back(i);
      }
    } else {
      if (want[i] != want[o]) {
        printf("-1\n");
        exit(0);
      }
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    is[v] = true;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &want[i]);
  }
  for (int i = 1; i <= n; ++i) {
    if (is[i]) continue;
    dfs(i, 0, 0);
    if (!full[i]) {
      full[i] = true;
      ans.push_back(i);
    }
  }
  cout << ans.size() << endl;
  for (auto &i : ans) {
    cout << i << endl;
  }
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Soon there will be held the world's largest programming contest, but the testing system still has m bugs. The contest organizer, a well-known university, has no choice but to attract university students to fix all the bugs. The university has n students able to perform such work. The students realize that they are the only hope of the organizers, so they don't want to work for free: the i-th student wants to get ci 'passes' in his subjects (regardless of the volume of his work).

Bugs, like students, are not the same: every bug is characterized by complexity aj, and every student has the level of his abilities bi. Student i can fix a bug j only if the level of his abilities is not less than the complexity of the bug: bi ≥ aj, and he does it in one day. Otherwise, the bug will have to be fixed by another student. Of course, no student can work on a few bugs in one day. All bugs are not dependent on each other, so they can be corrected in any order, and different students can work simultaneously.

The university wants to fix all the bugs as quickly as possible, but giving the students the total of not more than s passes. Determine which students to use for that and come up with the schedule of work saying which student should fix which bug.

Input

The first line contains three space-separated integers: n, m and s (1 ≤ n, m ≤ 105, 0 ≤ s ≤ 109) — the number of students, the number of bugs in the system and the maximum number of passes the university is ready to give the students.

The next line contains m space-separated integers a1, a2, ..., am (1 ≤ ai ≤ 109) — the bugs' complexities.

The next line contains n space-separated integers b1, b2, ..., bn (1 ≤ bi ≤ 109) — the levels of the students' abilities.

The next line contains n space-separated integers c1, c2, ..., cn (0 ≤ ci ≤ 109) — the numbers of the passes the students want to get for their help.

Output

If the university can't correct all bugs print "NO".

Otherwise, on the first line print "YES", and on the next line print m space-separated integers: the i-th of these numbers should equal the number of the student who corrects the i-th bug in the optimal answer. The bugs should be corrected as quickly as possible (you must spend the minimum number of days), and the total given passes mustn't exceed s. If there are multiple optimal answers, you can output any of them.

Examples

Input

3 4 9
1 3 1 2
2 1 3
4 3 6

Output

YES
2 3 2 3

Input

3 4 10
2 3 1 2
2 1 3
4 3 6

Output

YES
1 3 1 3

Input

3 4 9
2 3 1 2
2 1 3
4 3 6

Output

YES
3 3 2 3

Input

3 4 5
1 3 1 2
2 1 3
5 3 6

Output

NO

Note

Consider the first sample.

The third student (with level 3) must fix the 2nd and 4th bugs (complexities 3 and 2 correspondingly) and the second student (with level 1) must fix the 1st and 3rd bugs (their complexity also equals 1). Fixing each bug takes one day for each student, so it takes 2 days to fix all bugs (the students can work in parallel).

The second student wants 3 passes for his assistance, the third student wants 6 passes. It meets the university's capabilities as it is ready to give at most 9 passes.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, s;
int solver[200001];
struct problem {
  int difficulty, index;
  bool operator<(problem t) const { return difficulty > t.difficulty; }
};
struct student {
  int ability, cost, index;
  bool operator<(const student &t) const { return ability > t.ability; }
};
vector<problem> problems;
vector<student> students;
bool possible(int x) {
  if (x == 0) return false;
  int k = 0;
  long long ss = s;
  priority_queue<int, vector<int>, greater<int> > cost;
  for (int i = 0; i < m; i += x) {
    int a = problems[i].difficulty;
    while (k < n && students[k].ability >= a) {
      cost.push(students[k].cost);
      k++;
    }
    if (cost.empty()) return false;
    ss -= cost.top();
    cost.pop();
  }
  if (ss >= 0) return true;
  return false;
}
void get(int x) {
  int k = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      cost;
  for (int i = 0; i < m; i += x) {
    int a = problems[i].difficulty;
    while (k < n && students[k].ability >= a) {
      cost.push(make_pair(students[k].cost, students[k].index));
      k++;
    }
    int b = cost.top().second;
    for (int j = i; j < min(m, i + x); j++) solver[problems[j].index] = b;
    cost.pop();
  }
}
int main() {
  cin >> n >> m >> s;
  problems.resize(m);
  for (int i = 0; i < m; i++) {
    cin >> problems[i].difficulty;
    problems[i].index = i + 1;
  }
  students.resize(n);
  for (int i = 0; i < n; i++) cin >> students[i].ability;
  for (int i = 0; i < n; i++) cin >> students[i].cost;
  for (int i = 0; i < n; i++) students[i].index = i + 1;
  sort(problems.begin(), problems.end());
  sort(students.begin(), students.end());
  int small = 0, big = m, mid;
  while (small < big) {
    mid = (small + big) / 2;
    if (possible(mid))
      big = mid;
    else
      small = mid + 1;
  }
  if (!possible(small)) {
    cout << "NO\n";
    return 0;
  }
  get(small);
  cout << "YES\n";
  for (int i = 1; i <= m; i++) {
    cout << solver[i];
    if (1 != m) cout << ' ';
  }
  cout << '\n';
}

```


### Prompt

Please create a solution in CPP to the following problem:

Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has n friends and each of them can come to the party in a specific range of days of the year from ai to bi. Of course, Famil Door wants to have as many friends celebrating together with him as possible.

Far cars are as weird as Far Far Away citizens, so they can only carry two people of opposite gender, that is exactly one male and one female. However, Far is so far from here that no other transportation may be used to get to the party.

Famil Door should select some day of the year and invite some of his friends, such that they all are available at this moment and the number of male friends invited is equal to the number of female friends invited. Find the maximum number of friends that may present at the party.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 5000) — then number of Famil Door's friends.

Then follow n lines, that describe the friends. Each line starts with a capital letter 'F' for female friends and with a capital letter 'M' for male friends. Then follow two integers ai and bi (1 ≤ ai ≤ bi ≤ 366), providing that the i-th friend can come to the party from day ai to day bi inclusive.

Output

Print the maximum number of people that may come to Famil Door's party.

Examples

Input

4
M 151 307
F 343 352
F 117 145
M 24 128

Output

2

Input

6
M 128 130
F 128 131
F 131 140
F 131 141
M 131 200
M 140 200

Output

4

Note

In the first sample, friends 3 and 4 can come on any day in range [117, 128].

In the second sample, friends with indices 3, 4, 5 and 6 can come on day 140.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5100;
int n;
char c[maxn];
int l[maxn], r[maxn];
int main(int argc, char *argv[]) {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> c[i] >> l[i] >> r[i];
  int res = 0;
  for (int i = 1; i <= 366; i++) {
    int M = 0, F = 0;
    for (int j = 1; j <= n; j++)
      if (l[j] <= i && i <= r[j]) {
        if (c[j] == 'M')
          M++;
        else
          F++;
      }
    res = max(res, min(M, F) * 2);
  }
  cout << res << endl;
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

It is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new roads. The list of the roads to build was prepared. Each road will connect two cities. Each road should be a curve which lies inside or outside the ring. New roads will have no common points with the ring (except the endpoints of the road).

Now the designers of the constructing plan wonder if it is possible to build the roads in such a way that no two roads intersect (note that the roads may intersect at their endpoints). If it is possible to do, which roads should be inside the ring, and which should be outside?

Input

The first line contains two integers n and m (4 ≤ n ≤ 100, 1 ≤ m ≤ 100). Each of the following m lines contains two integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi). No two cities will be connected by more than one road in the list. The list will not contain the roads which exist in the Silver ring.

Output

If it is impossible to build the roads in such a way that no two roads intersect, output Impossible. Otherwise print m characters. i-th character should be i, if the road should be inside the ring, and o if the road should be outside the ring. If there are several solutions, output any of them.

Examples

Input

4 2
1 3
2 4

Output

io

Input

6 3
1 3
3 5
5 1

Output

ooo

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 100, M = 100;
struct EDGE {
  int to;
  EDGE *nxt;
  EDGE() {}
  EDGE(int _t, EDGE *_n) : to(_t), nxt(_n) {}
};
struct GRAPH {
  EDGE edg[M * M * 4 + 3], *head[N * 2 + 3], *ncnt;
  GRAPH() { ncnt = edg; }
  void AddEdge(int u, int v) {
    ncnt++;
    *ncnt = EDGE(v, head[u]);
    head[u] = ncnt;
  }
  EDGE *operator[](int id) { return head[id]; }
};
GRAPH Gr;
struct STACK {
  int stk[M * 2 + 3], head;
  int Size() { return head; }
  int Top() { return stk[head]; }
  void Pop() { head--; }
  void Push(int val) { stk[++head] = val; }
};
STACK St;
int n, m, ndfn, nscc;
int lnk[M + 3][2], scc[M * 2 + 3], dfn[M * 2 + 3], low[M * 2 + 3];
bool inst[M * 2 + 3];
void Tarjan(int u) {
  dfn[u] = low[u] = ++ndfn;
  St.Push(u);
  inst[u] = true;
  for (EDGE *it = Gr[u]; it; it = it->nxt) {
    int v = it->to;
    if (!dfn[v])
      Tarjan(v), low[u] = min(low[u], low[v]);
    else if (inst[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    nscc++;
    int cur;
    do {
      cur = St.Top();
      St.Pop();
      scc[cur] = nscc;
      inst[cur] = false;
    } while (cur != u);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &lnk[i][0], &lnk[i][1]);
    if (lnk[i][0] > lnk[i][1]) swap(lnk[i][0], lnk[i][1]);
    for (int j = 0; j < i; j++)
      if ((lnk[j][0] < lnk[i][0] && lnk[i][0] < lnk[j][1] &&
           lnk[j][1] < lnk[i][1]) ||
          (lnk[i][0] < lnk[j][0] && lnk[j][0] < lnk[i][1] &&
           lnk[i][1] < lnk[j][1]))
        Gr.AddEdge(i << 1, j << 1 | 1), Gr.AddEdge(i << 1 | 1, j << 1),
            Gr.AddEdge(j << 1, i << 1 | 1), Gr.AddEdge(j << 1 | 1, i << 1);
  }
  for (int i = 0; i < 2 * m; i++)
    if (!dfn[i]) Tarjan(i);
  for (int i = 0; i < m; i++)
    if (scc[i << 1] == scc[i << 1 | 1]) {
      printf("Impossible\n");
      return 0;
    }
  for (int i = 0; i < m; i++)
    if (scc[i << 1] < scc[i << 1 | 1])
      printf("i");
    else
      printf("o");
  printf("\n");
  return 0;
}

```


### Prompt

Your task is to create a cpp solution to the following problem:

Nauuo is a girl who loves writing comments.

One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.

It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.

There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".

Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.

Tell Nauuo the result or report that the result is uncertain.

Input

The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.

Output

If there is only one possible result, print the result : "+", "-" or "0".

Otherwise, print "?" to report that the result is uncertain.

Examples

Input

3 7 0

Output

-

Input

2 0 1

Output

+

Input

1 1 0

Output

0

Input

0 0 1

Output

?

Note

In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".

In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".

In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".

In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
namespace io {
char ch_forREAD;
int val_forREAD, f_forREAD;
int read() {
  val_forREAD = 0, f_forREAD = 1;
  while (!isdigit(ch_forREAD)) {
    if (ch_forREAD == '-') f_forREAD = -1;
    ch_forREAD = getchar();
  }
  while (isdigit(ch_forREAD)) {
    val_forREAD = 10 * val_forREAD + ch_forREAD - 48;
    ch_forREAD = getchar();
  }
  return f_forREAD * val_forREAD;
}
void read(int& x) { x = read(); }
}  // namespace io
using namespace io;
int main() {
  int x, y, z;
  scanf("%d%d%d", &x, &y, &z);
  if (x == y && z == 0) {
    puts("0");
    return 0;
  }
  if (x > y + z)
    puts("+");
  else if (y > x + z)
    puts("-");
  else
    puts("?");
  return 0;
}

```


### Prompt

Your challenge is to write a CPP solution to the following problem:

In order to put away old things and welcome a fresh new year, a thorough cleaning of the house is a must.

Little Tommy finds an old polynomial and cleaned it up by taking it modulo another. But now he regrets doing this...

Given two integers p and k, find a polynomial f(x) with non-negative integer coefficients strictly less than k, whose remainder is p when divided by (x + k). That is, f(x) = q(x)·(x + k) + p, where q(x) is a polynomial (not necessarily with integer coefficients).

Input

The only line of input contains two space-separated integers p and k (1 ≤ p ≤ 1018, 2 ≤ k ≤ 2 000).

Output

If the polynomial does not exist, print a single integer -1, or output two lines otherwise.

In the first line print a non-negative integer d — the number of coefficients in the polynomial.

In the second line print d space-separated integers a0, a1, ..., ad - 1, describing a polynomial <image> fulfilling the given requirements. Your output should satisfy 0 ≤ ai < k for all 0 ≤ i ≤ d - 1, and ad - 1 ≠ 0.

If there are many possible solutions, print any of them.

Examples

Input

46 2

Output

7
0 1 0 0 1 1 1

Input

2018 214

Output

3
92 205 1

Note

In the first example, f(x) = x6 + x5 + x4 + x = (x5 - x4 + 3x3 - 6x2 + 12x - 23)·(x + 2) + 46.

In the second example, f(x) = x2 + 205x + 92 = (x - 9)·(x + 214) + 2018.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 20050;
long long ans[maxn];
long long cal(long long p, long long k) { return (p % k + k) % k; }
int main() {
  long long p, k;
  scanf("%lld %lld", &p, &k);
  int pos = 0;
  while (p) {
    ans[++pos] = cal(p, k);
    p -= ans[pos];
    p /= (-k);
  }
  printf("%d\n", pos);
  for (int i = 1; i <= pos; i++) {
    printf("%lld%c", ans[i], i < pos ? ' ' : '\n');
  }
  return 0;
}

```


### Prompt

Please provide a cpp coded solution to the problem described below:

Jzzhu has invented a kind of sequences, they meet the following property:

<image>

You are given x and y, please calculate fn modulo 1000000007 (109 + 7).

Input

The first line contains two integers x and y (|x|, |y| ≤ 109). The second line contains a single integer n (1 ≤ n ≤ 2·109).

Output

Output a single integer representing fn modulo 1000000007 (109 + 7).

Examples

Input

2 3
3

Output

1

Input

0 -1
2

Output

1000000006

Note

In the first sample, f2 = f1 + f3, 3 = 2 + f3, f3 = 1.

In the second sample, f2 = - 1;  - 1 modulo (109 + 7) equals (109 + 6).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long mod(long long a) {
  long long modi = 1000000007;
  long long ret = a % modi;
  if (ret < 0) {
    ret += modi;
  }
  return ret;
}
int main() {
  long long x, y, n;
  cin >> x >> y;
  cin >> n;
  long long mod1 = mod(x);
  long long mod2 = mod(y);
  long long mod0 = mod1 - mod2;
  long long res;
  if (n % 3 == 0)
    res = mod(pow(-1, n / 3) * mod0);
  else if (n % 3 == 1)
    res = mod(pow(-1, n / 3) * mod1);
  else
    res = mod(pow(-1, n / 3) * mod2);
  cout << res << endl;
  return 0;
}

```


### Prompt

Your challenge is to write a Cpp solution to the following problem:

Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has computed s_v: the sum of all values written on the vertices on the path from vertex v to the root, as well as h_v — the depth of vertex v, which denotes the number of vertices on the path from vertex v to the root. Clearly, s_1=a_1 and h_1=1.

Then Mitya erased all numbers a_v, and by accident he also erased all values s_v for vertices with even depth (vertices with even h_v). Your task is to restore the values a_v for every vertex, or determine that Mitya made a mistake. In case there are multiple ways to restore the values, you're required to find one which minimizes the total sum of values a_v for all vertices in the tree.

Input

The first line contains one integer n — the number of vertices in the tree (2 ≤ n ≤ 10^5). The following line contains integers p_2, p_3, ... p_n, where p_i stands for the parent of vertex with index i in the tree (1 ≤ p_i < i). The last line contains integer values s_1, s_2, ..., s_n (-1 ≤ s_v ≤ 10^9), where erased values are replaced by -1.

Output

Output one integer — the minimum total sum of all values a_v in the original tree, or -1 if such tree does not exist.

Examples

Input

5
1 1 1 1
1 -1 -1 -1 -1

Output

1

Input

5
1 2 3 1
1 -1 2 -1 -1

Output

2

Input

3
1 2
2 -1 1

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<long long int> adj[100000 + 5];
long long int vis[100000 + 5] = {0}, a[100000 + 5] = {0};
long long int sp[100000 + 5], par[100000 + 5];
long long int n, den = 0, x;
void dfs(long long int s, long long int sum, long long int level) {
  long long int i, j, k;
  vis[s] = 1;
  for (i = 0; i < adj[s].size(); i++) {
    if (vis[adj[s][i]] == 0) {
      long long int val;
      par[adj[s][i]] = s;
      if (sp[adj[s][i]] == -1)
        val = 0;
      else {
        val = sp[adj[s][i]];
        if (val < sum) {
          den = 1;
          break;
        } else {
          if (level % 2 == 0) a[adj[s][i]] = val - sum;
        }
      }
      dfs(adj[s][i], max(sum, val), level + 1);
    }
  }
  if (level % 2 == 0) {
    long long int mn = 1000000000000;
    for (i = 0; i < adj[s].size(); i++) {
      if (par[s] != adj[s][i]) {
        mn = min(mn, a[adj[s][i]]);
      }
    }
    if (adj[s].size() >= 2) a[s] = mn;
    for (i = 0; i < adj[s].size(); i++) {
      if (par[s] != adj[s][i]) {
        a[adj[s][i]] = a[adj[s][i]] - mn;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int i, j, k;
  cin >> n;
  for (i = 2; i <= n; i++) {
    cin >> x;
    adj[x].push_back(i);
    adj[i].push_back(x);
  }
  for (i = 1; i <= n; i++) cin >> sp[i];
  a[1] = sp[1];
  dfs(1, sp[1], 1);
  if (den == 1)
    cout << "-1\n";
  else {
    long long int ans = 0;
    for (i = 1; i <= n; i++) ans += a[i];
    cout << ans << "\n";
  }
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

You are given n points on a plane. All points are different.

Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC.

The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are considered the same.

Input

The first line contains a single integer n (3 ≤ n ≤ 3000) — the number of points.

Next n lines contain the points. The i-th line contains coordinates of the i-th point: two space-separated integers xi, yi ( - 1000 ≤ xi, yi ≤ 1000).

It is guaranteed that all given points are different.

Output

Print the single number — the answer to the problem.

Examples

Input

3
1 1
2 2
3 3

Output

1

Input

3
0 0
-1 0
0 1

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(y, x));
  }
  sort(v.begin(), v.end());
  int res = 0;
  for (int i = 0; i < n; i++) {
    int j = i + 1, k = i + 2;
    while (k < n) {
      int x = 2 * v[j].second - v[i].second;
      int y = 2 * v[j].first - v[i].first;
      pair<int, int> c = make_pair(y, x);
      if (c > v[k])
        k++;
      else if (c < v[k])
        j++;
      else
        res++, j++, k++;
    }
  }
  cout << res;
}

```


### Prompt

Create a solution in CPP for the following problem:

You are given an array a of length n that consists of zeros and ones.

You can perform the following operation multiple times. The operation consists of two steps:

  1. Choose three integers 1 ≤ x < y < z ≤ n, that form an arithmetic progression (y - x = z - y).
  2. Flip the values a_x, a_y, a_z (i.e. change 1 to 0, change 0 to 1).

Determine if it is possible to make all elements of the array equal to zero. If yes, print the operations that lead the the all-zero state. Your solution should not contain more than (⌊ n/3 ⌋ + 12) operations. Here ⌊ q ⌋ denotes the number q rounded down. We can show that it is possible to make all elements equal to zero in no more than this number of operations whenever it is possible to do so at all.

Input

The first line contains a single integer n (3 ≤ n ≤ 10^5) — the length of the array.

The second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 1) — the elements of the array.

Output

Print "YES" (without quotes) if the answer exists, otherwise print "NO" (without quotes). You can print each letter in any case (upper or lower).

If there is an answer, in the second line print an integer m (0 ≤ m ≤ (⌊ n/3 ⌋ + 12)) — the number of operations in your answer.

After that in (i + 2)-th line print the i-th operations — the integers x_i, y_i, z_i. You can print them in arbitrary order.

Examples

Input

5
1 1 0 1 1

Output

YES
2
1 3 5
2 3 4

Input

3
0 1 0

Output

NO

Note

In the first sample the shown output corresponds to the following solution:

  * 1 1 0 1 1 (initial state);
  * 0 1 1 1 0 (the flipped positions are the first, the third and the fifth elements);
  * 0 0 0 0 0 (the flipped positions are the second, the third and the fourth elements).

Other answers are also possible. In this test the number of operations should not exceed ⌊ 5/3 ⌋ + 12 = 1 + 12 = 13.

In the second sample the only available operation is to flip all the elements. This way it is only possible to obtain the arrays 0 1 0 and 1 0 1, but it is impossible to make all elements equal to zero.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct kok {
  int a, b, c;
};
int n;
int ar[100000];
vector<kok> res;
void lastP() {
  vector<kok> vc;
  for (int i = 0; i < min(n, 10); ++i) {
    for (int j = i + 1; j < min(n, 10); ++j) {
      for (int k = j + 1; k < min(n, 10); ++k) {
        if (j - i != k - j) continue;
        vc.push_back({i, j, k});
      }
    }
  }
  for (int bp = 0; bp < (1 << vc.size()); ++bp) {
    for (int i = 0; i < vc.size(); ++i) {
      if ((1 << i) & bp) {
        ar[vc[i].a] = !ar[vc[i].a];
        ar[vc[i].b] = !ar[vc[i].b];
        ar[vc[i].c] = !ar[vc[i].c];
      }
    }
    int bad = 0;
    for (int i = 0; i < min(n, 10); ++i) {
      bad |= ar[i];
    }
    for (int i = 0; i < vc.size(); ++i) {
      if ((1 << i) & bp) {
        ar[vc[i].a] = !ar[vc[i].a];
        ar[vc[i].b] = !ar[vc[i].b];
        ar[vc[i].c] = !ar[vc[i].c];
      }
    }
    if (!bad) {
      for (int i = 0; i < vc.size(); ++i) {
        if ((1 << i) & bp) {
          res.push_back(vc[i]);
        }
      }
      break;
    }
  }
}
int ork[11];
vector<kok> vs;
map<int, int> mp;
void genka() {
  for (int i = 0; i < 11; ++i) {
    for (int j = i + 1; j < 11; ++j) {
      for (int k = j + 1; k < 11; ++k) {
        if (j - i != k - j) continue;
        if (k < 5) continue;
        vs.push_back({i, j, k});
      }
    }
  }
  for (int bp = 0; bp < (1 << vs.size()); ++bp) {
    int opa = 0;
    for (int i = 0; i < vs.size(); ++i)
      if ((1 << i) & bp) opa++;
    if (opa != 2) continue;
    for (int i = 0; i < vs.size(); ++i) {
      if ((1 << i) & bp) {
        ork[vs[i].a] = !ork[vs[i].a];
        ork[vs[i].b] = !ork[vs[i].b];
        ork[vs[i].c] = !ork[vs[i].c];
      }
    }
    int cur = 0;
    for (int i = 5; i < 11; ++i) {
      cur |= ork[i];
      cur = cur << 1;
    }
    mp[cur] = bp;
    for (int i = 0; i < vs.size(); ++i) {
      if ((1 << i) & bp) {
        ork[vs[i].a] = !ork[vs[i].a];
        ork[vs[i].b] = !ork[vs[i].b];
        ork[vs[i].c] = !ork[vs[i].c];
      }
    }
  }
}
int main(int argc, char **argv) {
  genka();
  ios::sync_with_stdio(0);
  int suma = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> ar[i];
  }
  if (*max_element(ar, ar + n) == 0) {
    cout << "YES" << endl << 0 << endl;
    return 0;
  }
  int kek = n;
  while (kek >= 11) {
    int cur = 0;
    for (int i = kek - 6; i < kek; ++i) {
      cur |= ar[i];
      cur = cur << 1;
    }
    int bp = mp[cur];
    for (int i = 0; i < vs.size(); ++i) {
      if ((1 << i) & bp) {
        ar[vs[i].a + kek - 11] = !ar[vs[i].a + kek - 11];
        ar[vs[i].b + kek - 11] = !ar[vs[i].b + kek - 11];
        ar[vs[i].c + kek - 11] = !ar[vs[i].c + kek - 11];
      }
    }
    for (int i = 0; i < vs.size(); ++i) {
      if ((1 << i) & bp) {
        res.push_back(
            {vs[i].a + kek - 11, vs[i].b + kek - 11, vs[i].c + kek - 11});
      }
    }
    kek -= 6;
  }
  lastP();
  if (!res.size()) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  cout << res.size() << endl;
  for (auto i : res) {
    cout << i.a + 1 << ' ' << i.b + 1 << ' ' << i.c + 1 << endl;
  }
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations:

* update(s, t, x): change as, as+1, ..., at to x.
* find(i): output the value of ai.

Note that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.

Constraints

* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 100000
* 0 ≤ s ≤ t < n
* 0 ≤ i < n
* 0 ≤ x < 231−1

Input

n q
query1
query2
:
queryq

In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:

0 s t x

or

1 i

The first digit represents the type of the query. '0' denotes update(s, t, x) and '1' denotes find(i).

Output

For each find operation, print the value.

Examples

Input

3 5
0 0 1 1
0 1 2 3
0 2 2 2
1 0
1 1

Output

1
3

Input

1 3
1 0
0 0 0 5
1 0

Output

2147483647
5

### Response

```cpp
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = (1ll << 31) - 1;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct SegmentTree {
	int n;
	vector<int>d;
	SegmentTree(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, INF);
	}
	void update(int a, int b, int x = -1, int k = 1, int l = 0, int r = -1) {
		if (r == -1)r = n;
		if (r <= a || b <= l)return;
		else if (a <= l&&r <= b) {
			if (x >= 0)d[k] = x;
		}
		else {
			if (d[k] != INF)d[2 * k] = d[2 * k + 1] = d[k], d[k] = INF;
			update(a, b, x, 2 * k, l, (l + r) / 2);
			update(a, b, x, 2 * k + 1, (l + r) / 2, r);
		}
	}
	int find(int i) {
		update(i, i + 1);
		return d[n + i];
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	SegmentTree seg(n);
	rep(i, 0, q) {
		int com; cin >> com;
		if (com) {
			int x; cin >> x;
			cout << seg.find(x) << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			seg.update(s, t + 1, x);
		}
	}
	return 0;
}
```


### Prompt

Create a solution in Cpp for the following problem:

Ashishgup and FastestFinger play a game.

They start with a number n and play in turns. In each turn, a player can make any one of the following moves:

  * Divide n by any of its odd divisors greater than 1.
  * Subtract 1 from n if n is greater than 1.

Divisors of a number include the number itself.

The player who is unable to make a move loses the game.

Ashishgup moves first. Determine the winner of the game if both of them play optimally.

Input

The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The description of the test cases follows.

The only line of each test case contains a single integer — n (1 ≤ n ≤ 10^9).

Output

For each test case, print "Ashishgup" if he wins, and "FastestFinger" otherwise (without quotes).

Example

Input

7
1
2
3
4
5
6
12

Output

FastestFinger
Ashishgup
Ashishgup
FastestFinger
Ashishgup
FastestFinger
Ashishgup

Note

In the first test case, n = 1, Ashishgup cannot make a move. He loses.

In the second test case, n = 2, Ashishgup subtracts 1 on the first move. Now n = 1, FastestFinger cannot make a move, so he loses.

In the third test case, n = 3, Ashishgup divides by 3 on the first move. Now n = 1, FastestFinger cannot make a move, so he loses.

In the last test case, n = 12, Ashishgup divides it by 3. Now n = 4, FastestFinger is forced to subtract 1, and Ashishgup gets 3, so he wins by dividing it by 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
bool power(long long int n) {
  if (n != 0 && (n & (n - 1)) == 0) {
    return true;
  } else {
    return false;
  }
}
bool isprime(long long int n) {
  if (n == 1) return false;
  long long int i = 2;
  while (i * i <= n) {
    if (n % i == 0) return false;
    i += 1;
  }
  return true;
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    if (n == 1)
      cout << "FastestFinger\n";
    else if (n % 2 != 0 || n == 2)
      cout << "Ashishgup\n";
    else {
      if (power(n) || isprime(n / 2))
        cout << "FastestFinger\n";
      else
        cout << "Ashishgup\n";
    }
  }
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits.

Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them.

Input

The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has.

Output

Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros.

Examples

Input

100

Output

99

Input

48

Output

48

Input

521

Output

499

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000 * 1000 * 1000 + 7;
const long long INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const long long MOD2 = 998244353;
const long long N = 1000 * 1000 + 10;
const long long NN = 100000LL * 100000LL + 1LL;
const long long N2 = 70;
const long double PI = 3.14159265358979323846;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long power(long long x, long long y, long long p = LLONG_MAX) {
  long long res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
void solve() {}
long long f(long long n) {
  long long ans = 0;
  while (n > 0) {
    ans += (n % 10);
    n /= 10;
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long nn, n;
  cin >> n;
  nn = n;
  long long ans = n, pv = f(n);
  long long nd = log10(n), o = (long long)pow(10LL, nd);
  for (long long i = 1; i <= nd; i++) {
    long long val = 0;
    long long pr = n / o;
    pr--;
    long long lp = nd - i + 1;
    while (lp--) {
      pr *= 10;
      pr += 9;
    }
    val = f(pr);
    if (pv < val) {
      pv = val;
      ans = pr;
    } else if (pv == val) {
      if (ans < pr) ans = pr;
    }
    o /= 10;
  }
  cout << ans;
  return 0;
}

```


### Prompt

Your challenge is to write a CPP solution to the following problem:

DZY loves Fast Fourier Transformation, and he enjoys using it.

Fast Fourier Transformation is an algorithm used to calculate convolution. Specifically, if a, b and c are sequences with length n, which are indexed from 0 to n - 1, and

<image>

We can calculate c fast using Fast Fourier Transformation.

DZY made a little change on this formula. Now

<image>

To make things easier, a is a permutation of integers from 1 to n, and b is a sequence only containing 0 and 1. Given a and b, DZY needs your help to calculate c.

Because he is naughty, DZY provides a special way to get a and b. What you need is only three integers n, d, x. After getting them, use the code below to generate a and b.

    //x is 64-bit variable;
    function getNextX() {
        x = (x * 37 + 10007) % 1000000007;
        return x;
    }
    function initAB() {
        for(i = 0; i < n; i = i + 1){
            a[i] = i + 1;
        }
        for(i = 0; i < n; i = i + 1){
            swap(a[i], a[getNextX() % (i + 1)]);
        }
        for(i = 0; i < n; i = i + 1){
            if (i < d)
                b[i] = 1;
            else
                b[i] = 0;
        }
        for(i = 0; i < n; i = i + 1){
            swap(b[i], b[getNextX() % (i + 1)]);
        }
    }

Operation x % y denotes remainder after division x by y. Function swap(x, y) swaps two values x and y.

Input

The only line of input contains three space-separated integers n, d, x (1 ≤ d ≤ n ≤ 100000; 0 ≤ x ≤ 1000000006). Because DZY is naughty, x can't be equal to 27777500.

Output

Output n lines, the i-th line should contain an integer ci - 1.

Examples

Input

3 1 1

Output

1
3
2

Input

5 4 2

Output

2
2
4
5
5

Input

5 4 3

Output

5
5
5
5
4

Note

In the first sample, a is [1 3 2], b is [1 0 0], so c0 = max(1·1) = 1, c1 = max(1·0, 3·1) = 3, c2 = max(1·0, 3·0, 2·1) = 2.

In the second sample, a is [2 1 4 5 3], b is [1 1 1 0 1].

In the third sample, a is [5 2 1 4 3], b is [1 1 1 1 0].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, d, a[100010], b[100010], c[100010], p[100010];
long long x;
long long getNextX() {
  x = (x * 37 + 10007) % 1000000007;
  return x;
}
void initAB() {
  for (int i = 0; i < n; i++) a[i] = i + 1;
  for (int i = 0; i < n; i++) swap(a[i], a[getNextX() % (i + 1)]);
  for (int i = 0; i < n; i++)
    if (i < d)
      b[i] = 1;
    else
      b[i] = 0;
  for (int i = 0; i < n; i++) swap(b[i], b[getNextX() % (i + 1)]);
}
void work() {
  scanf("%d %d %I64d", &n, &d, &x);
  initAB();
  for (int i = 0; i < n; i++) c[a[i]] = i;
  for (int i = 0; i < n; i++)
    if (b[i]) p[++p[0]] = i;
  int s = 300;
  for (int i = 0; i < n; i++) {
    int j;
    for (j = n; j >= n - s; j--)
      if ((j > 0) && (i >= c[j]) && (b[i - c[j]])) {
        printf("%d\n", j);
        break;
      };
    if (j < n - s) {
      int Max = 0;
      for (j = 1; j <= p[0] && p[j] <= i; j++) Max = max(Max, a[i - p[j]]);
      printf("%d\n", Max);
    }
  }
}
int main() {
  work();
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Example

Input

3
NNN
NNN
NNN

Output

Taro

### Response

```cpp
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
vector<int> G[1001];
int vcnt,mcnt,a,b,c2;
bool used[1001];
int dp[1001][1001][2];

void dfs(int v){
	used[v]=true;
	vcnt++;
	mcnt+=G[v].size();
	for(int i=0;i<G[v].size();i++){
		if(!used[G[v][i]]){
			dfs(G[v][i]);
		}
	}
}

int func(int a,int b,int c){
	if(a+b<=1)return 1;
	if(dp[a][b][c]!=-1)return dp[a][b][c];
	int res=0;
	if(c>0){
		res|=1^func(a,b,c-1);
	}
	if(a>0 && b>0){
		res|=1^func(a,b-1,c^1);
	}
	if(a>1){
		res|=1^func(a-2,b+1,c);
	}
	if(b>1){
		res|=1^func(a,b-1,c^1);
	}
	return (dp[a][b][c]=res);
}

int main(void){
	int m=0;
	scanf("%d%*c",&n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			char c;
			scanf("%c",&c);
			if(c=='Y'){
				G[i].push_back(j);
				m++;
			}
		}
		scanf("%*c");
	}
	memset(used,false,sizeof(used));
	for(int i=0;i<n;i++){
		if(!used[i]){
			mcnt=0;
			vcnt=0;
			dfs(i);
			if(vcnt%2==1)a++;
			else b++;
			if((vcnt*(vcnt-1)/2-(mcnt/2))%2==1){
				c2^=1;
			}
		}
	}
	memset(dp,-1,sizeof(dp));
	printf("%s\n",func(a,b,c2)==1?"Taro":"Hanako");
	return 0;
}
```


### Prompt

Your task is to create a Cpp solution to the following problem:

We have a pyramid with N steps, built with blocks. The steps are numbered 1 through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks aligned horizontally. The pyramid is built so that the blocks at the centers of the steps are aligned vertically.

<image>

A pyramid with N=4 steps

Snuke wrote a permutation of (1, 2, ..., 2N-1) into the blocks of step N. Then, he wrote integers into all remaining blocks, under the following rule:

* The integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b, or to the lower left or lower right of b.

<image>

Writing integers into the blocks

Afterwards, he erased all integers written into the blocks. Now, he only remembers that the integer written into the block of step 1 was x.

Construct a permutation of (1, 2, ..., 2N-1) that could have been written into the blocks of step N, or declare that Snuke's memory is incorrect and such a permutation does not exist.

Constraints

* 2≤N≤10^5
* 1≤x≤2N-1

Input

The input is given from Standard Input in the following format:

N x

Output

If no permutation of (1, 2, ..., 2N-1) could have been written into the blocks of step N, print `No`.

Otherwise, print `Yes` in the first line, then print 2N-1 lines in addition.

The i-th of these 2N-1 lines should contain the i-th element of a possible permutation.

Examples

Input

4 4

Output

Yes
1
6
3
7
4
5
2

Input

2 1

Output

No

### Response

```cpp
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  int N, x; std::cin >> N >> x;
  if(x == 1 || x == N*2-1) fin("No");
  std::cout << "Yes\n";
  int n = 2;
  for(int i = 0; i < N-2; ++i) {
    if(n == x) ++n;
    std::cout << n << "\n";
    ++n;
  }
  std::cout << "1\n" << x << "\n" << (N*2-1) << "\n";
  for(int i = 0; i < N-2; ++i) {
    if(n == x) ++n;
    std::cout << n << "\n";
    ++n;
  }
  return 0;
}

```


### Prompt

Please provide a CPP coded solution to the problem described below:

Carousel Boutique is busy again! Rarity has decided to visit the pony ball and she surely needs a new dress, because going out in the same dress several times is a sign of bad manners. First of all, she needs a dress pattern, which she is going to cut out from the rectangular piece of the multicolored fabric.

The piece of the multicolored fabric consists of n × m separate square scraps. Since Rarity likes dresses in style, a dress pattern must only include scraps sharing the same color. A dress pattern must be the square, and since Rarity is fond of rhombuses, the sides of a pattern must form a 45^{\circ} angle with sides of a piece of fabric (that way it will be resembling the traditional picture of a rhombus).

Examples of proper dress patterns: <image> Examples of improper dress patterns: <image> The first one consists of multi-colored scraps, the second one goes beyond the bounds of the piece of fabric, the third one is not a square with sides forming a 45^{\circ} angle with sides of the piece of fabric.

Rarity wonders how many ways to cut out a dress pattern that satisfies all the conditions that do exist. Please help her and satisfy her curiosity so she can continue working on her new masterpiece!

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 2000). Each of the next n lines contains m characters: lowercase English letters, the j-th of which corresponds to scrap in the current line and in the j-th column. Scraps having the same letter share the same color, scraps having different letters have different colors.

Output

Print a single integer: the number of ways to cut out a dress pattern to satisfy all of Rarity's conditions.

Examples

Input

3 3
aaa
aaa
aaa

Output

10

Input

3 4
abab
baba
abab

Output

12

Input

5 5
zbacg
baaac
aaaaa
eaaad
weadd

Output

31

Note

In the first example, all the dress patterns of size 1 and one of size 2 are satisfactory.

In the second example, only the dress patterns of size 1 are satisfactory.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
char a[2009][2009] = {0};
long long int dp1[2009][2009] = {0};
long long int dp2[2009][2009] = {0};
long long int dp3[2009][2009] = {0};
long long int dp4[2009][2009] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  string s;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    for (int j = 1; j <= m; j++) a[i][j] = s[j - 1];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      dp1[i][j] = 1;
      if (a[i - 1][j] == a[i][j] and a[i][j] == a[i][j - 1])
        dp1[i][j] = min(dp1[i - 1][j], dp1[i][j - 1]) + 1;
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = 1; j <= m; j++) {
      dp3[i][j] = 1;
      if (a[i + 1][j] == a[i][j] and a[i][j] == a[i][j - 1])
        dp3[i][j] = min(dp3[i + 1][j], dp3[i][j - 1]) + 1;
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      dp2[i][j] = 1;
      if (a[i + 1][j] == a[i][j] and a[i][j] == a[i][j + 1])
        dp2[i][j] = min(dp2[i + 1][j], dp2[i][j + 1]) + 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = m; j >= 1; j--) {
      dp4[i][j] = 1;
      if (a[i - 1][j] == a[i][j] and a[i][j] == a[i][j + 1])
        dp4[i][j] = min(dp4[i - 1][j], dp4[i][j + 1]) + 1;
    }
  }
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      ans += min(dp1[i][j], min(dp2[i][j], min(dp3[i][j], dp4[i][j])));
    }
  }
  cout << ans;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

As Famil Door’s birthday is coming, some of his friends (like Gabi) decided to buy a present for him. His friends are going to buy a string consisted of round brackets since Famil Door loves string of brackets of length n more than any other strings!

The sequence of round brackets is called valid if and only if:

  1. the total number of opening brackets is equal to the total number of closing brackets;
  2. for any prefix of the sequence, the number of opening brackets is greater or equal than the number of closing brackets.

Gabi bought a string s of length m (m ≤ n) and want to complete it to obtain a valid sequence of brackets of length n. He is going to pick some strings p and q consisting of round brackets and merge them in a string p + s + q, that is add the string p at the beginning of the string s and string q at the end of the string s.

Now he wonders, how many pairs of strings p and q exists, such that the string p + s + q is a valid sequence of round brackets. As this number may be pretty large, he wants to calculate it modulo 109 + 7.

Input

First line contains n and m (1 ≤ m ≤ n ≤ 100 000, n - m ≤ 2000) — the desired length of the string and the length of the string bought by Gabi, respectively.

The second line contains string s of length m consisting of characters '(' and ')' only.

Output

Print the number of pairs of string p and q such that p + s + q is a valid sequence of round brackets modulo 109 + 7.

Examples

Input

4 1
(

Output

4

Input

4 4
(())

Output

1

Input

4 3
(((

Output

0

Note

In the first sample there are four different valid pairs:

  1. p = "(", q = "))"
  2. p = "()", q = ")"
  3. p = "", q = "())"
  4. p = "", q = ")()"

In the second sample the only way to obtain a desired string is choose empty p and q.

In the third sample there is no way to get a valid sequence of brackets.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, LEN = 100010, MAX = 2010;
inline void add(int &a, int b) { a = (((long long)a) + b) % MOD; }
char str[LEN];
int dpL[MAX][MAX], dpR[MAX][2 * MAX], diff, total, m, n;
int g(int i, int j) {
  ;
  if (j + total < 0) return 0;
  if (i == m - n) return j + total == 0;
  int &ret = dpR[i][j + MAX];
  if (ret == -1) {
    ret = 0;
    add(ret, g(i + 1, j + 1));
    add(ret, g(i + 1, j - 1));
  }
  return ret;
}
int f(int i, int j) {
  ;
  if (j < 0) return 0;
  if (i == m - n) return j + diff >= 0 && j + total == 0;
  int &ret = dpL[i][j];
  if (ret == -1) {
    ret = 0;
    add(ret, f(i + 1, j + 1));
    add(ret, f(i + 1, j - 1));
    if (j + diff >= 0) add(ret, g(i, j));
  }
  return ret;
}
int main() {
  memset(dpL, -1, sizeof dpL);
  memset(dpR, -1, sizeof dpR);
  scanf("%d %d %s", &m, &n, str);
  diff = 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (str[i] == '(')
      cnt++;
    else
      cnt--;
    ;
    diff = min(diff, cnt);
  }
  total = cnt;
  ;
  printf("%d\n", f(0, 0));
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Yuu Koito and Touko Nanami are newlyweds! On the wedding day, Yuu gifted Touko a directed tree with n nodes and rooted at 1, and a labeling a which is some DFS order of the tree. Every edge in this tree is directed away from the root.

After calling dfs(1) the following algorithm returns a as a DFS order of a tree rooted at 1 :

    order := 0
    a := array of length n

    function dfs(u):
        order := order + 1
        a[u] := order
        for all v such that there is a directed edge (u -> v):
            dfs(v)

Note that there may be different DFS orders for a given tree.

Touko likes the present so much she decided to play with it! On each day following the wedding day, Touko performs this procedure once:

  * Among all directed edges u → v such that a_u < a_v, select the edge u' → v' with the lexicographically smallest pair (a_{u'}, a_{v'}).
  * Swap a_{u'} and a_{v'}.

Days have passed since their wedding, and Touko has somehow forgotten which date the wedding was and what was the original labeling a! Fearing that Yuu might get angry, Touko decided to ask you to derive these two pieces of information using the current labeling.

Being her good friend, you need to find the number of days that have passed since the wedding, and the original labeling of the tree. However, there is a chance that Touko might have messed up her procedures, which result in the current labeling being impossible to obtain from some original labeling; in that case, please inform Touko as well.

Input

The first line of the input contains an integer n (2 ≤ n ≤ 3 ⋅ 10^5) — the number of nodes on the tree.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n, all a_i are distinct) — the current labeling of the tree.

Each of the next n - 1 lines contains two integers u_i and v_i (1 ≤ u, v ≤ n, u ≠ v), describing an directed edge from u_i to v_i. The edges form a directed tree rooted at 1.

Output

If the current labeling is impossible to arrive at from any DFS order, print NO.

Else, on the first line, print YES. On the second line, print a single integer denoting the number of days since the wedding. On the third line, print n numbers space-separated denoting the original labeling of the tree.

If there are multiple correct outputs, print any. This means: you are allowed to output any pair (DFS order, number of days), such that we get the current configuration from the DFS order you provided in exactly the number of days you provided.

Examples

Input

7
4 5 2 1 7 6 3
1 5
7 6
1 2
2 7
3 4
1 3

Output

YES
5
1 4 2 3 7 6 5

Input

7
7 6 5 3 1 4 2
4 3
2 5
3 7
1 4
7 2
2 6

Output

NO

Note

The following animation showcases the first sample test case. The white label inside the node represents the index of the node i, while the boxed orange label represents the value a_i.

<image>

### Response

```cpp
/**
 *    author:  tourist
 *    created: 16.04.2021 18:25:16
**/
#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void my_assert(bool x) {
  if (!x) {
    cout << "NO" << '\n';
    exit(0);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> pos(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    --a[i];
    pos[a[i]] = i;
  }
  vector<vector<int>> g(n);
  vector<int> pv(n, -1);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    g[u].push_back(v);
    pv[v] = u;
  }
  vector<int> depth(n);
  function<void(int)> Dfs = [&](int v) {
    for (int u : g[v]) {
      depth[u] = depth[v] + 1;
      Dfs(u);
    }
  };
  depth[0] = 0;
  Dfs(0);
  vector<int> deg(n);
  for (int i = 0; i < n; i++) {
    deg[i] = (int) g[i].size();
  }
  vector<int> aux = a;
  long long ans = 0;
  vector<bool> used(n, false);
  vector<int> post;
  for (int i = 0; i < n; i++) {
    int v = pos[i];
    ans += depth[v];
    if (deg[v] == 0) {
      used[v] = true;
      post.push_back(v);
      if (pv[v] != -1) {
        deg[pv[v]] -= 1;
      }
      continue;
    }
    while (v != 0) {
      swap(aux[v], aux[pv[v]]);
      v = pv[v];
    }
    break;
  }
  function<void(int)> Restore = [&](int v) {
    if (used[v]) {
      return;
    }
    sort(g[v].begin(), g[v].end(), [&](int i, int j) {
      return aux[i] < aux[j];
    });
    for (int u : g[v]) {
      Restore(u);
    }
    post.push_back(v);
  };
  Restore(0);
  my_assert((int) post.size() == n);
  vector<int> pos_post(n, -1);
  for (int i = 0; i < n; i++) {
    pos_post[post[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    my_assert(pos_post[i] != -1);
  }
  vector<int> pre;
  function<void(int)> Build = [&](int v) {
    pre.push_back(v);
    sort(g[v].begin(), g[v].end(), [&](int i, int j) {
      return pos_post[i] < pos_post[j];
    });
    for (int u : g[v]) {
      Build(u);
    }
  };
  Build(0);
  my_assert((int) pre.size() == n);
  vector<int> pos_pre(n, -1);
  for (int i = 0; i < n; i++) {
    pos_pre[pre[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    my_assert(pos_pre[i] != -1);
  }
  vector<int> new_post;
  function<void(int)> BuildAgain = [&](int v) {
    sort(g[v].begin(), g[v].end(), [&](int i, int j) {
      return pos_pre[i] < pos_pre[j];
    });
    for (int u : g[v]) {
      BuildAgain(u);
    }
    new_post.push_back(v);
  };
  BuildAgain(0);
  debug(post);
  debug(pre);
  debug(new_post);
  debug(ans);
  my_assert(post == new_post);
  vector<int> mark(n, -1);
  long long got = 0;
  for (int i = 0; i < n; i++) {
    int v = post[i];
    if (got + depth[v] <= ans) {
      got += depth[v];
      mark[v] = i;
      continue;
    }
    vector<int> foo;
    for (int j = 0; j < n; j++) {
      if (mark[j] == -1) {
        foo.push_back(j);
      }
    }
    my_assert((int) foo.size() == n - i);
    sort(foo.begin(), foo.end(), [&](int ii, int j) {
      return pos_pre[ii] < pos_pre[j];
    });
    for (int j = 0; j < n - i; j++) {
      mark[foo[j]] = i + j;
    }
    long long extra = got + depth[v] - ans;
    int me = v;
    debug(me, extra);
    while (extra > 0) {
      my_assert(pv[me] != -1);
      me = pv[me];
      extra -= 1;
    }
    vector<int> path;
    while (me != -1) {
      path.push_back(me);
      me = pv[me];
    }
    reverse(path.begin(), path.end());
    for (int j = 0; j < (int) path.size() - 1; j++) {
      swap(mark[path[j]], mark[path[j + 1]]);
    }
    got = ans;
    break;
  }
  my_assert(got == ans);
  for (int i = 0; i < n; i++) {
    my_assert(mark[i] == a[i]);
  }
  cout << "YES" << '\n';
  cout << ans << '\n';
  for (int i = 0; i < n; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << pos_pre[i] + 1;
  }
  cout << '\n';
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Hongcow is ruler of the world. As ruler of the world, he wants to make it easier for people to travel by road within their own countries.

The world can be modeled as an undirected graph with n nodes and m edges. k of the nodes are home to the governments of the k countries that make up the world.

There is at most one edge connecting any two nodes and no edge connects a node to itself. Furthermore, for any two nodes corresponding to governments, there is no path between those two nodes. Any graph that satisfies all of these conditions is stable.

Hongcow wants to add as many edges as possible to the graph while keeping it stable. Determine the maximum number of edges Hongcow can add.

Input

The first line of input will contain three integers n, m and k (1 ≤ n ≤ 1 000, 0 ≤ m ≤ 100 000, 1 ≤ k ≤ n) — the number of vertices and edges in the graph, and the number of vertices that are homes of the government.

The next line of input will contain k integers c1, c2, ..., ck (1 ≤ ci ≤ n). These integers will be pairwise distinct and denote the nodes that are home to the governments in this world.

The following m lines of input will contain two integers ui and vi (1 ≤ ui, vi ≤ n). This denotes an undirected edge between nodes ui and vi.

It is guaranteed that the graph described by the input is stable.

Output

Output a single integer, the maximum number of edges Hongcow can add to the graph while keeping it stable.

Examples

Input

4 1 2
1 3
1 2

Output

2

Input

3 3 1
2
1 2
1 3
2 3

Output

0

Note

For the first sample test, the graph looks like this:

<image> Vertices 1 and 3 are special. The optimal solution is to connect vertex 4 to vertices 1 and 2. This adds a total of 2 edges. We cannot add any more edges, since vertices 1 and 3 cannot have any path between them.

For the second sample test, the graph looks like this:

<image> We cannot add any more edges to this graph. Note that we are not allowed to add self-loops, and the graph must be simple.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 10005, M = 100005;
int n, m, k, r[N], tot, lnk[N], nxt[M << 1], son[M << 1];
int cnt, cn, ce, mx, num, vis[N];
bool b[N];
long long ans;
void add(int x, int y) { nxt[++tot] = lnk[x], lnk[x] = tot, son[tot] = y; }
void dfs(int x, int c) {
  vis[x] = c, ++cn;
  for (int j = lnk[x]; j; j = nxt[j]) {
    ++ce;
    if (vis[son[j]]) continue;
    dfs(son[j], c);
  }
}
int Cn2(int x) { return x * (x - 1) >> 1; }
int main() {
  scanf("%d%d%d", &n, &m, &k), tot = 0;
  for (int i = 1; i <= k; ++i) scanf("%d", &r[i]), b[r[i]] = 1;
  for (int i = 1, x, y; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    add(x, y), add(y, x);
  }
  mx = num = 0;
  for (int i = 1; i <= k; ++i) {
    ce = cn = 0, ++cnt;
    dfs(r[i], cnt);
    ce >>= 1, ans += Cn2(cn) - ce, mx = max(mx, cn);
  }
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      ce = cn = 0;
      dfs(i, ++cnt);
      ce >>= 1, ans -= ce, num += cn;
    }
  ans += 1ll * Cn2(num) + 1ll * mx * num;
  cout << ans << endl;
  return 0;
}

```


### Prompt

Please provide a CPP coded solution to the problem described below:

Kostya is a progamer specializing in the discipline of Dota 2. Valve Corporation, the developer of this game, has recently released a new patch which turned the balance of the game upside down. Kostya, as the captain of the team, realizes that the greatest responsibility lies on him, so he wants to resort to the analysis of innovations patch from the mathematical point of view to choose the best heroes for his team in every game.

A Dota 2 match involves two teams, each of them must choose some heroes that the players of the team are going to play for, and it is forbidden to choose the same hero several times, even in different teams. In large electronic sports competitions where Kostya's team is going to participate, the matches are held in the Captains Mode. In this mode the captains select the heroes by making one of two possible actions in a certain, predetermined order: pick or ban.

  * To pick a hero for the team. After the captain picks, the picked hero goes to his team (later one of a team members will play it) and can no longer be selected by any of the teams.
  * To ban a hero. After the ban the hero is not sent to any of the teams, but it still can no longer be selected by any of the teams.

The team captain may miss a pick or a ban. If he misses a pick, a random hero is added to his team from those that were available at that moment, and if he misses a ban, no hero is banned, as if there was no ban.

Kostya has already identified the strength of all the heroes based on the new patch fixes. Of course, Kostya knows the order of picks and bans. The strength of a team is the sum of the strengths of the team's heroes and both teams that participate in the match seek to maximize the difference in strengths in their favor. Help Kostya determine what team, the first one or the second one, has advantage in the match, and how large the advantage is.

Input

The first line contains a single integer n (2 ≤ n ≤ 100) — the number of heroes in Dota 2.

The second line contains n integers s1, s2, ..., sn (1 ≤ si ≤ 106) — the strengths of all the heroes.

The third line contains a single integer m (2 ≤ m ≤ min(n, 20)) — the number of actions the captains of the team must perform.

Next m lines look like "action team", where action is the needed action: a pick (represented as a "p") or a ban (represented as a "b"), and team is the number of the team that needs to perform the action (number 1 or 2).

It is guaranteed that each team makes at least one pick. Besides, each team has the same number of picks and the same number of bans.

Output

Print a single integer — the difference between the strength of the first team and the strength of the second team if the captains of both teams will act optimally well.

Examples

Input

2
2 1
2
p 1
p 2

Output

1

Input

6
6 4 5 4 5 5
4
b 2
p 1
b 1
p 2

Output

0

Input

4
1 2 3 4
4
p 2
b 2
p 1
b 1

Output

-2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int s[200], n, m;
vector<pair<char, int> > ve;
int res[21][1 << 21];
int cam(const void *x, const void *y) { return *(int *)y - *(int *)x; }
int dp(int step, int val) {
  pair<char, int> pi = ve[step];
  int maxnum = -1, index = -1, i, ans;
  for (i = 0; i <= 20; i++) {
    if ((val & (1 << i)) && maxnum == -1) {
      maxnum = s[i];
      index = i;
    }
  }
  if (step == m) return 0;
  if (res[step][val] != 1000000000) return res[step][val];
  if (pi.first == 'p') {
    if (pi.second == 1) {
      res[step][val] = maxnum + dp(step + 1, val ^ (1 << index));
      return res[step][val];
    } else {
      return res[step][val] = -maxnum + dp(step + 1, val ^ (1 << index));
    }
  } else {
    if (pi.second == 1) {
      ans = -1000000000;
      for (i = 0; i <= 20; i++) {
        if (val & (1 << i)) {
          ans = max(ans, dp(step + 1, val ^ (1 << i)));
        }
      }
    } else {
      ans = 1000000000;
      for (i = 0; i <= 20; i++) {
        if (val & (1 << i)) {
          ans = min(ans, dp(step + 1, val ^ (1 << i)));
        }
      }
    }
  }
  return res[step][val] = ans;
}
int main() {
  memset(res, -1, sizeof(res));
  int i, j, x;
  char str[20];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &s[i]);
  }
  qsort(s, n, sizeof(s[0]), cam);
  if (n > 20) n = 20;
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    for (j = 0; j < (1 << n); j++) {
      res[i][j] = 1000000000;
    }
  }
  for (i = 0; i < m; i++) {
    scanf("%s %d", str, &x);
    ve.push_back(make_pair(str[0], x));
  }
  printf("%d\n", dp(0, (1 << n) - 1));
  return 0;
}

```


### Prompt

Your task is to create a Cpp solution to the following problem:

Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.

Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three or more consonants in a row in the word. The only exception is that if the block of consonants has all letters the same, then this block (even if its length is greater than three) is not considered a typo. Formally, a word is typed with a typo if there is a block of not less that three consonants in a row, and there are at least two different letters in this block.

For example:

  * the following words have typos: "hellno", "hackcerrs" and "backtothefutttture";
  * the following words don't have typos: "helllllooooo", "tobeornottobe" and "oooooo".

When Beroffice editor finds a word with a typo, it inserts as little as possible number of spaces in this word (dividing it into several words) in such a way that each of the resulting words is typed without any typos.

Implement this feature of Beroffice editor. Consider the following letters as the only vowels: 'a', 'e', 'i', 'o' and 'u'. All the other letters are consonants in this problem.

Input

The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters.

Output

Print the given word without any changes if there are no typos.

If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them.

Examples

Input

hellno

Output

hell no

Input

abacaba

Output

abacaba

Input

asdfasdf

Output

asd fasd f

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int a = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' ||
        s[i] == 'u') {
      cout << s[i];
      a = 0;
    } else {
      if (i != 0 && (s[i - 1] == 'a' || s[i - 1] == 'e' || s[i - 1] == 'i' ||
                     s[i - 1] == 'o' || s[i - 1] == 'u'))
        a++;
      else if (i != 0 && s[i] == s[i - 1]) {
        if (i > 1 && a == 2 && s[i] == s[i - 2]) {
        } else
          a++;
      } else
        a++;
      if (a == 3) {
        a = 1;
        cout << " ";
      }
      cout << s[i];
    }
  }
  return 0;
}

```


### Prompt

In CPP, your task is to solve the following problem:

Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.

For example, let's say that Vitaly's favourite digits are 1 and 3, then number 12 isn't good and numbers 13 or 311 are. Also, number 111 is excellent and number 11 isn't.

Now Vitaly is wondering, how many excellent numbers of length exactly n are there. As this number can be rather large, he asks you to count the remainder after dividing it by 1000000007 (109 + 7).

A number's length is the number of digits in its decimal representation without leading zeroes.

Input

The first line contains three integers: a, b, n (1 ≤ a < b ≤ 9, 1 ≤ n ≤ 106).

Output

Print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

Examples

Input

1 3 3

Output

1

Input

2 3 10

Output

165

### Response

```cpp
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:500000000")
using namespace std;
const int mod = 1000000007;
long long modpow(long long a, long long n, long long mod) {
  long long b = 1;
  while (n > 0) {
    if (n & 1) b = (long long)b * a % mod;
    n >>= 1;
    a = (long long)a * a % mod;
  }
  return b;
}
long long fact[1000009], rev[1000009];
long long C(int n, int k) { return fact[n] * rev[k] % mod * rev[n - k] % mod; }
int L[1111];
int main() {
  int i;
  fact[0] = 1;
  for (i = 1; i < 1000009; i++) fact[i] = fact[i - 1] * i % mod;
  for (i = 0; i < 1000009; i++) rev[i] = modpow(fact[i], mod - 2, mod);
  int a, b, n;
  cin >> a >> b >> n;
  int sz = 0;
  for (int len = 1; len <= 7; len++) {
    for (int mask = 0; mask < (1 << len); mask++) {
      int v = 0;
      for (i = 0; i < len; i++) {
        v *= 10;
        v += (mask & (1 << i)) ? a : b;
      }
      L[sz++] = v;
    }
  }
  sort(L, L + sz);
  long long res = 0;
  for (i = 0; i <= n; i++) {
    int j = n - i;
    if (binary_search(L, L + sz, i * a + j * b)) res = (res + C(n, i)) % mod;
  }
  cout << res << endl;
}

```


### Prompt

Your task is to create a CPP solution to the following problem:

Problem

Given a sequence of length $ N $ $ A = $ {$ a_ {1}, a_ {2}, a_ {3}, ..., a_ {n} $}.
It is assumed that $ a_ {i} $ ($ i = 1,2,3, ..., n $) is initialized with $ i $.

Process the following two types of queries a total of $ Q $ times.

* Outputs the value of the $ k $ th element from the beginning of the sequence $ A $.
* Swap two sequences with the $ k $ and $ k + 1 $ th boundaries from the beginning of the sequence $ A $.

For details, refer to sample input / output.

Constraints

The input satisfies the following conditions.

* $ 2 \ leq N \ leq 10 ^ 9 $
* $ 1 \ leq Q \ leq 10 ^ 5 $

For each query, the input satisfies the following conditions.

Query $ 0 $

* $ 1 \ leq k \ leq N $

Query $ 1 $

* $ 1 \ leq k \ leq N-1 $

Input

The input is given in the following format.

$ N $ $ Q $
$ query_1 $
$ query_2 $
...
$ query_Q $

Each query is given in one of two forms:

Query $ 0 $
$ 0 $ $ k $
Outputs the value of the $ k $ th element from the beginning of the sequence $ A $.

Query $ 1 $
$ 1 $ $ k $
Swap two sequences at the boundary of $ k $ and $ k + 1 $ from the beginning of the sequence $ A $.

All inputs are given as integers.

$ N $ and $ Q $ are given on the $ 1 $ line, separated by blanks.
Queries are given on the $ Q $ lines after the $ 2 $ line, separated by line breaks.
All numbers in each query are separated by blanks.

Output

Print the value on one line for each query $ 1 $.

Examples

Input

5 4
1 2
0 2
1 1
0 3

Output

4
1

Input

4 4
1 2
1 1
0 1
0 4

Output

4
3

Input

10 6
1 1
0 1
1 9
0 5
1 1
0 10

Output

2
5
1

### Response

```cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def>pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf=1000000019;
int main(){
	ll n,m;
	cin>>n>>m;
	ll t=0;
	while(m--){
		ll a,b;
		cin>>a>>b;
		if(a){
			t+=b;
		}else{
			cout<<(t+b-1)%n+1<<endl;
		}
	}
}

```


### Prompt

Please provide a cpp coded solution to the problem described below:

Create a program that takes two dates as input and outputs the number of days between the two dates.

Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as follows.

* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.

Input

Given multiple datasets. The format of each dataset is as follows:

y1 m1 d1 y2 m2 d2

When any of y1, m1, d1, y2, m2, and d2 is a negative number, the input ends.

The number of datasets does not exceed 50.

Output

Output the number of days on one line for each dataset.

Example

Input

2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1

Output

1
70
366
2192
36890

### Response

```cpp
#include <iostream>
using namespace std;

int daycount(int y, int m, int d) {
  if (m==1 || m==2) {
    --y;
    m+=12;
  }
  return (365*y + y/4 - y/100 + y/400 + (306*(m+1))/10 + d - 428);
}

int main() {
  int y1, m1, d1, y2, m2, d2;
  while (1) {
    cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
    if (y1==-1 || m1==-1 || d1==-1 || y2==-1 || m2==-1 || d2==-1) break;
    cout << daycount(y2, m2, d2) - daycount(y1, m1, d1) << endl;
  }
  return 0;
}
```


### Prompt

Create a solution in Cpp for the following problem:

Recently, the bear started studying data structures and faced the following problem.

You are given a sequence of integers x1, x2, ..., xn of length n and m queries, each of them is characterized by two integers li, ri. Let's introduce f(p) to represent the number of such indexes k, that xk is divisible by p. The answer to the query li, ri is the sum: <image>, where S(li, ri) is a set of prime numbers from segment [li, ri] (both borders are included in the segment).

Help the bear cope with the problem.

Input

The first line contains integer n (1 ≤ n ≤ 106). The second line contains n integers x1, x2, ..., xn (2 ≤ xi ≤ 107). The numbers are not necessarily distinct.

The third line contains integer m (1 ≤ m ≤ 50000). Each of the following m lines contains a pair of space-separated integers, li and ri (2 ≤ li ≤ ri ≤ 2·109) — the numbers that characterize the current query.

Output

Print m integers — the answers to the queries on the order the queries appear in the input.

Examples

Input

6
5 5 7 10 14 15
3
2 11
3 12
4 4

Output

9
7
0

Input

7
2 3 5 7 11 4 8
2
8 10
2 123

Output

0
7

Note

Consider the first sample. Overall, the first sample has 3 queries.

  1. The first query l = 2, r = 11 comes. You need to count f(2) + f(3) + f(5) + f(7) + f(11) = 2 + 1 + 4 + 2 + 0 = 9.
  2. The second query comes l = 3, r = 12. You need to count f(3) + f(5) + f(7) + f(11) = 1 + 4 + 2 + 0 = 7.
  3. The third query comes l = 4, r = 4. As this interval has no prime numbers, then the sum equals 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
void print_array(T a[], int size) {
  for (int i = 0; i < size; i++) cout << a[i] << " ";
  cout << endl;
}
template <class T>
void print_array_v(T &a) {
  int size = a.size();
  for (int i = 0; i < size; i++) cout << a[i] << " ";
  cout << endl;
}
const int MAXN = 1e7 + 10;
int cnt[MAXN] = {0};
int ps[MAXN] = {0};
int tot[MAXN] = {0};
int main() {
  int n, num;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &num);
    cnt[num]++;
  }
  ps[0] = ps[1] = 1;
  for (int i = 2; i < MAXN; i++) {
    if (ps[i]) continue;
    for (int j = i; j < MAXN; j += i) {
      ps[j] = 1;
      tot[i] += cnt[j];
    }
  }
  for (int i = 1; i < MAXN; i++) tot[i] += tot[i - 1];
  int m;
  cin >> m;
  int l, r;
  for (int i = 0; i < m; i++) {
    scanf("%d", &l);
    scanf("%d", &r);
    r = min(MAXN - 1, r);
    l = min(l, r);
    printf("%d\n", tot[r] - tot[l - 1]);
  }
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Petya has a string of length n consisting of small and large English letters and digits.

He performs m operations. Each operation is described with two integers l and r and a character c: Petya removes from the string all characters c on positions between l and r, inclusive. It's obvious that the length of the string remains the same or decreases after each operation.

Find how the string will look like after Petya performs all m operations.

Input

The first string contains two integers n and m (1 ≤ n, m ≤ 2·105) — the length of the string and the number of operations.

The second line contains the string of length n, consisting of small and large English letters and digits. Positions in the string are enumerated from 1.

Each of the next m lines contains two integers l and r (1 ≤ l ≤ r), followed by a character c, which is a small or large English letter or a digit. This line describes one operation. It is guaranteed that r doesn't exceed the length of the string s before current operation.

Output

Print the string Petya will obtain after performing all m operations. If the strings becomes empty after all operations, print an empty line.

Examples

Input

4 2
abac
1 3 a
2 2 c

Output

b

Input

3 2
A0z
1 3 0
1 1 z

Output

Az

Input

10 4
agtFrgF4aF
2 5 g
4 9 F
1 5 4
1 7 a

Output

tFrg4

Input

9 5
aAAaBBccD
1 4 a
5 6 c
2 3 B
4 4 D
2 3 A

Output

AB

Note

In the first example during the first operation both letters 'a' are removed, so the string becomes "bc". During the second operation the letter 'c' (on the second position) is removed, and the string becomes "b".

In the second example during the first operation Petya removes '0' from the second position. After that the string becomes "Az". During the second operations the string doesn't change.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long modpow(long long b, long long e, long long mod) {
  long long ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}
const int N = 200005;
struct ST {
  vector<int> st;
  int n;
  ST(int n) : st(2 * n, 0), n(n) {}
  void upd(int pos, int val) {
    for (st[pos += n] = val; pos /= 2;) st[pos] = st[2 * pos] + st[2 * pos + 1];
  }
  int query(int x, int y) {
    int ans = 0;
    for (x += n, y += n + 1; x < y; x /= 2, y /= 2) {
      if (x & 1) ans += st[x++];
      if (y & 1) ans += st[--y];
    }
    return ans;
  }
};
ST seg(N);
map<char, set<int> > pos;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  for (int i = 1; i < ((int)(s).size() + 1); ++i) {
    pos[s[i - 1]].insert(i);
    seg.upd(i, 1);
  }
  while (m--) {
    int l, r;
    char c;
    cin >> l >> r >> c;
    int L = 1, R = n;
    int lf = -1;
    while (L <= R) {
      int mid = (L + R) / 2;
      if (seg.query(1, mid) >= l) {
        lf = mid;
        R = mid - 1;
      } else
        L = mid + 1;
    }
    l = lf;
    L = 1, R = n;
    lf = -1;
    while (L <= R) {
      int mid = (L + R) / 2;
      if (seg.query(1, mid) >= r) {
        lf = mid;
        R = mid - 1;
      } else
        L = mid + 1;
    }
    r = lf;
    while ((int)(pos[c]).size()) {
      auto u = pos[c].lower_bound(l);
      if (u == end(pos[c])) break;
      if (*u > r) {
        break;
      } else {
        seg.upd(*u, 0);
        pos[c].erase(u);
      }
    }
  }
  vector<pair<int, char> > ans;
  for (auto w : pos) {
    for (auto k : w.second) {
      ans.push_back({k, w.first});
    }
  }
  sort(begin(ans), end(ans));
  for (int i = 0; i < ((int)(ans).size()); ++i) {
    cout << ans[i].second;
  }
}

```


### Prompt

Please provide a cpp coded solution to the problem described below:

This problem consists of two subproblems: for solving subproblem D1 you will receive 3 points, and for solving subproblem D2 you will receive 16 points.

Manao is the chief architect involved in planning a new supercollider. He has to identify a plot of land where the largest possible supercollider can be built. The supercollider he is building requires four-way orthogonal collisions of particles traveling at the same speed, so it will consist of four accelerating chambers and be shaped like a plus sign (i.e., +). Each of the four accelerating chambers must be the same length and must be aligned with the Earth's magnetic field (parallel or orthogonal) to minimize interference.

The accelerating chambers need to be laid down across long flat stretches of land to keep costs under control. Thus, Manao has already commissioned a topographical study that has identified all possible maximal length tracts of land available for building accelerating chambers that are either parallel or orthogonal to the Earth's magnetic field. To build the largest possible supercollider, Manao must identify the largest symmetric plus shape from among these candidate tracts. That is, he must find the two tracts of land that form an axis-aligned plus shape with the largest distance from the center of the plus to the tip of the shortest of the four arms of the plus. Note that the collider need not use the entire length of the tracts identified (see the example in the notes).

Input

The first line of the input will contain two single-space-separated integers n, the number of north-south tracts and m, the number of west-east tracts.

Each of the n lines following the first describes a north-south tract. Each such tract is described by three single-space-separated integers xi, yi, li representing the vertical line segment from (xi, yi) to (xi, yi + li).

Similarly, after the n lines describing north-south tracts follow m similar lines describing the west-east tracts. Each such tract is described by three single-space-separated integers xi, yi, li representing the horizontal line segment from (xi, yi) to (xi + li, yi).

All xi and yi are between -100000000 and 100000000, inclusive. All li are between 1 and 100000000, inclusive. No pair of horizontal segments will touch or intersect, and no pair of vertical segments will touch or intersect.

The problem consists of two subproblems. The subproblems have different constraints on the input. You will get some score for the correct submission of the subproblem. The description of the subproblems follows.

  * In subproblem D1 (3 points), n and m will be between 1 and 1000, inclusive.
  * In subproblem D2 (16 points), n and m will be between 1 and 50000, inclusive.

Output

Print one line containing a single integer, the size of the largest supercollider that can be built on one north-south tract and one west-east tract. The size of the supercollider is defined to be the length of one of the four accelerating chambers. In other words, the size of the resulting supercollider is defined to be the distance from the intersection of the two line segments to the closest endpoint of either of the two segments. If no pair of north-south and west-east tracts intersects, it is not possible to build a supercollider and the program should report a maximum size of zero.

Examples

Input

1 2
4 0 9
1 1 8
1 2 7

Output

2

Note

Consider the example. There is one vertical line segment from (4, 0) to (4, 9) and two horizontal line segments: from (1, 1) to (9, 1) and from (1, 2) to (8, 2). The largest plus shape that can be found among these segments is formed from the only vertical segment and the second of horizontal segments, and is centered at (4, 2).

The program should output 2 because the closest end point of those segments to the center is (4, 0), which is distance 2 from the center point of (4, 2). The collider will be formed by the line segments from (2, 2) to (6, 2) and from (4, 0) to (4, 4).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct event {
  int type, x, y1, y2;
  bool operator<(event a) const {
    if (x != a.x) return x < a.x;
    if (type != a.type) return type > a.type;
    return y1 < a.y1;
  };
};
struct segment {
  int inix, iniy, fimx, fimy;
};
int n, mm, n1, n2, n3, node_cur = 1;
vector<event> nw;
vector<segment> v;
vector<int> e, d, sum;
void build() {
  e.push_back(-1);
  d.push_back(-1);
  sum.push_back(0);
}
void update(int id, int ini, int fim, int cur, int val) {
  if (ini > cur || fim < cur) return;
  if (ini == fim) {
    sum[id] += val;
    return;
  }
  int m = ((long long int)ini + fim) / 2;
  if (ini == fim - 1) m = ini;
  if (cur > m) {
    if (d[id] == -1) {
      d[id] = ++node_cur;
      build();
    }
    update(d[id], m + 1, fim, cur, val);
  } else {
    if (e[id] == -1) {
      e[id] = ++node_cur;
      build();
    }
    update(e[id], ini, m, cur, val);
  }
  sum[id] = ((e[id] == -1) ? 0 : sum[e[id]]) + ((d[id] == -1) ? 0 : sum[d[id]]);
}
int query(int id, int ini, int fim, int i, int j) {
  if (id == -1 || ini > j || fim < i) return 0;
  if (ini >= i && fim <= j) return sum[id];
  int m = ((long long int)ini + fim) / 2;
  if (ini == fim - 1) m = ini;
  return query(e[id], ini, m, i, j) + query(d[id], m + 1, fim, i, j);
}
bool test(int i) {
  nw.clear();
  e.clear();
  d.clear();
  sum.clear();
  build();
  build();
  node_cur = 1;
  int tam = v.size();
  for (int g = 0; g < n + mm; g++) {
    event a;
    if (v[g].inix == v[g].fimx) {
      if (v[g].fimy < v[g].iniy + 2 * i) continue;
      a.type = 0;
      a.x = v[g].inix;
      a.y1 = v[g].iniy + i;
      a.y2 = v[g].fimy - i;
      nw.push_back(a);
    } else {
      if (v[g].fimx < v[g].inix + 2 * i) continue;
      a.y1 = a.y2 = v[g].iniy;
      a.type = 1;
      a.x = v[g].inix + i;
      nw.push_back(a);
      a.type = -1;
      a.x = v[g].fimx - i;
      nw.push_back(a);
    }
  }
  sort(nw.begin(), nw.end());
  bool aux = false;
  tam = nw.size();
  for (int g = 0; g < tam; g++) {
    if (nw[g].type != 0)
      update(1, -200000010, 200000010, nw[g].y1, nw[g].type);
    else if (query(1, -200000010, 200000010, nw[g].y1, nw[g].y2) > 0)
      aux = true;
  }
  return aux;
}
int binary_search() {
  if (!test(0)) return 0;
  long long int i = 0, j = 200000010;
  while (j > i) {
    int m = (i + j) / 2;
    if (i == j - 1) m = j;
    if (test(m))
      i = m;
    else
      j = m - 1;
  }
  return i;
}
int main() {
  scanf("%d %d", &n, &mm);
  for (int g = 0; g < n; g++) {
    scanf("%d %d %d", &n1, &n2, &n3);
    segment a;
    a.inix = a.fimx = n1;
    a.iniy = n2;
    a.fimy = n2 + n3;
    v.push_back(a);
  }
  for (int g = 0; g < mm; g++) {
    scanf("%d %d %d", &n1, &n2, &n3);
    segment a;
    a.iniy = a.fimy = n2;
    a.inix = n1;
    a.fimx = n1 + n3;
    v.push_back(a);
  }
  printf("%d\n", binary_search());
}

```


### Prompt

Please provide a CPP coded solution to the problem described below:

For a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequnece (LIS) in A.

An increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 ≤ i0 < i1 < ... < ik < n and ai0 < ai1 < ... < aik.

Constraints

* 1 ≤ n ≤ 100000
* 0 ≤ ai ≤ 109

Input

n
a0
a1
:
an-1

In the first line, an integer n is given. In the next n lines, elements of A are given.

Output

The length of the longest increasing subsequence of A.

Examples

Input

5
5
1
3
2
4

Output

3

Input

3
1
1
1

Output

1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d", &n);
    int a[n+1];
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    vector<int> dp;
    dp.push_back(a[0]);
    for(int i = 1; i <= n-1; i++){
        if(a[i] > dp[dp.size()-1]){
            dp.push_back(a[i]);
        }
        else{
            *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
        }
    }
    printf("%d\n", dp.size());
    return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array a of length n and possibly swapped some elements of the array.

The Little Elephant doesn't want to call the police until he understands if he could have accidentally changed the array himself. He thinks that he could have accidentally changed array a, only if array a can be sorted in no more than one operation of swapping elements (not necessarily adjacent). That is, the Little Elephant could have accidentally swapped some two elements.

Help the Little Elephant, determine if he could have accidentally changed the array a, sorted by non-decreasing, himself.

Input

The first line contains a single integer n (2 ≤ n ≤ 105) — the size of array a. The next line contains n positive integers, separated by single spaces and not exceeding 109, — array a.

Note that the elements of the array are not necessarily distinct numbers.

Output

In a single line print "YES" (without the quotes) if the Little Elephant could have accidentally changed the array himself, and "NO" (without the quotes) otherwise.

Examples

Input

2
1 2

Output

YES

Input

3
3 2 1

Output

YES

Input

4
4 3 2 1

Output

NO

Note

In the first sample the array has already been sorted, so to sort it, we need 0 swap operations, that is not more than 1. Thus, the answer is "YES".

In the second sample we can sort the array if we swap elements 1 and 3, so we need 1 swap operation to sort the array. Thus, the answer is "YES".

In the third sample we can't sort the array in more than one swap operation, so the answer is "NO".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
int n;
int flag1, flag2;
int cnt;
int main() {
  cnt = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (a[i] != b[i]) {
      cnt++;
      if (cnt == 1)
        flag1 = i;
      else
        flag2 = i;
    }
    if (cnt == 3) break;
  }
  bool flag = true;
  if (cnt == 0 || cnt == 2) {
    if (cnt == 2) {
      int tmp = a[flag1];
      a[flag1] = a[flag2];
      a[flag2] = tmp;
    }
    for (int i = 1; i <= n; i++)
      if (a[i] != b[i]) {
        flag = false;
        break;
      }
  } else {
    flag = false;
  }
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Problem statement

Given the string $ S $. Find the number of all anagrams in $ S $ that are palindromic.

An anagram of the string $ X $ is an anagram of $ Y $, which means that $ X $ is equal to $ Y $, or that the rearranged characters of $ X $ are equal to $ Y $. For example, for the string abcd, abcd and cbda are anagrams, but abed, cab and abcdd are not anagrams.

When the string $ X $ is a palindrome, it means that the reverse reading of $ X $ is equal to $ X $ itself. For example, abc and ab are not palindromes, and a and abccba are palindromes.

Constraint

* $ 1 \ leq | S | \ leq 40 $ ($ | S | $ is the length of the string $ S $)
* $ S $ contains only lowercase letters.
* The answer is guaranteed to be less than $ 2 ^ {63} $.

input

Input follows the following format.

$ S $

output

Output the number on one line.

Examples

Input

ab

Output

0

Input

abba

Output

2

### Response

```cpp
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue 优先队列
#include <map>
#include <set> //multiset  set<int>::reverse_iterator rit; for(rit=s.rbegin();rit!=s.rend();rit++)
#include <vector>
#include <stack>
#include <cmath>
#include <utility>
#include <sstream>
#include <string>
#define mod 1000000007
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
const db eps=1e-6;
const int INF=0x3f3f3f3f;
const int N=50;
using namespace std;
int t,n,m=0,a[N]={0};
char c[N]={0};

ll C(int a,int b){
	ll c=1,d=1,e=a;
	while(a){
		c*=a--;
	}
	while(e--){
		d*=b--;
	}
	return d/c;
}

int flag=0;
int main(){
	scanf("%s",c);
	for(int i=0;i<strlen(c);i++){
		a[c[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		if(a[i]%2==1){
			if(flag==0){
				a[i]--;
				a[i]/=2;
				flag=1;
			}else{
				flag=2;
			}
		}else{
			a[i]/=2;
		}
	}
	if(flag==2){
		printf("0\n");
	}else{
		sort(a,a+26);
		int s=strlen(c)/2;
		ll sum=1;
		for(int i=0;i<26;i++){
			if(a[i]!=0){
				sum*=C(a[i],s);
				s-=a[i];
			}
		}
		printf("%lld\n",sum);
	}
	return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

We have N lamps numbered 1 to N, and N buttons numbered 1 to N. Initially, Lamp 1, 2, \cdots, A are on, and the other lamps are off.

Snuke and Ringo will play the following game.

* First, Ringo generates a permutation (p_1,p_2,\cdots,p_N) of (1,2,\cdots,N). The permutation is chosen from all N! possible permutations with equal probability, without being informed to Snuke.

* Then, Snuke does the following operation any number of times he likes:

* Choose a lamp that is on at the moment. (The operation cannot be done if there is no such lamp.) Let Lamp i be the chosen lamp. Press Button i, which switches the state of Lamp p_i. That is, Lamp p_i will be turned off if it is on, and vice versa.

At every moment, Snuke knows which lamps are on. Snuke wins if all the lamps are on, and he will surrender when it turns out that he cannot win. What is the probability of winning when Snuke plays optimally?

Let w be the probability of winning. Then, w \times N! will be an integer. Compute w \times N! modulo (10^9+7).

Constraints

* 2 \leq N \leq 10^7
* 1 \leq A \leq \min(N-1,5000)

Input

Input is given from Standard Input in the following format:

N A

Output

Print w \times N! modulo (10^9+7), where w is the probability of Snuke's winning.

Examples

Input

3 1

Output

2

Input

3 2

Output

3

Input

8 4

Output

16776

Input

9999999 4999

Output

90395416

### Response

```cpp
#include<iostream>
#include<cstdio>
using namespace std;
const int N=10000005,M=5005;
const int MOD=1000000007;
int n,m;
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
long long fac[N],inv[N];
void init(int n=10000000)
{
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[n]=ksm(fac[n],MOD-2);
	for(int i=n;i>=1;i--)
		inv[i-1]=inv[i]*i%MOD;
	return;
}
long long C(int n,int m)
{
	if(m>n) return 0;
	else return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int main()
{
	scanf("%d%d",&n,&m);
	init();
	long long ans=0;
	for(int i=1;i<=m+1;i++)
		for(int j=0;j<i;j++)
		{
			int a=i-1-j,b=n-m,c=max(m-i,0);
			long long res=C(i-1,j);
			res=(res*fac[a])%MOD;
			res=(res*fac[a+b-1]%MOD*inv[a-1]%MOD)%MOD;
			res=(res*fac[a+b+c]%MOD*inv[a+b]%MOD)%MOD;
			if(j&1) ans=(ans-res+MOD)%MOD;
			else ans=(ans+res)%MOD;
		}
	printf("%lld",ans);
	return 0;
}
```


### Prompt

Generate a Cpp solution to the following problem:

Try guessing the statement from this picture:

<image>

You are given a non-negative integer d. You have to find two non-negative real numbers a and b such that a + b = d and a ⋅ b = d.

Input

The first line contains t (1 ≤ t ≤ 10^3) — the number of test cases.

Each test case contains one integer d (0 ≤ d ≤ 10^3).

Output

For each test print one line.

If there is an answer for the i-th test, print "Y", and then the numbers a and b.

If there is no answer for the i-th test, print "N".

Your answer will be considered correct if |(a + b) - a ⋅ b| ≤ 10^{-6} and |(a + b) - d| ≤ 10^{-6}.

Example

Input

7
69
0
1
4
5
999
1000

Output

Y 67.985071301 1.014928699
Y 0.000000000 0.000000000
N
Y 2.000000000 2.000000000
Y 3.618033989 1.381966011
Y 997.998996990 1.001003010
Y 998.998997995 1.001002005

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long fn = 1e10;
bool f(double mid, double d) { return (mid * mid - d * mid + d) > 0; }
void solve(double d) {
  if (d * d - 4 * d < 0) {
    cout << "N"
         << "\n";
    return;
  }
  double lo = 0, hi = d / 2 + 1e-15;
  while (abs(lo - hi) > 1e-15) {
    double mid = 0.5 * (lo + hi);
    (f(mid, d) ? lo : hi) = mid;
  }
  if (lo >= 0 && d - lo >= 0) {
    cout << "Y"
         << " " << d - lo << " " << lo << "\n";
    return;
  }
}
int main() {
  int t;
  cin >> t;
  cout << fixed << setprecision(9);
  for (int i = 0; i < t; ++i) {
    double d;
    cin >> d;
    solve(d);
  }
}

```