### Prompt

Generate a CPP solution to the following problem:

Enough is enough. Too many times it happened that Vasya forgot to dispose of garbage and his apartment stank afterwards. Now he wants to create a garbage disposal plan and stick to it.

For each of next n days Vasya knows a_i — number of units of garbage he will produce on the i-th day. Each unit of garbage must be disposed of either on the day it was produced or on the next day. Vasya disposes of garbage by putting it inside a bag and dropping the bag into a garbage container. Each bag can contain up to k units of garbage. It is allowed to compose and drop multiple bags into a garbage container in a single day.

Being economical, Vasya wants to use as few bags as possible. You are to compute the minimum number of bags Vasya needs to dispose of all of his garbage for the given n days. No garbage should be left after the n-th day.

Input

The first line of the input contains two integers n and k (1 ≤ n ≤ 2⋅10^5, 1 ≤ k ≤ 10^9) — number of days to consider and bag's capacity. The second line contains n space separated integers a_i (0 ≤ a_i ≤ 10^9) — the number of units of garbage produced on the i-th day.

Output

Output a single integer — the minimum number of bags Vasya needs to dispose of all garbage. Each unit of garbage should be disposed on the day it was produced or on the next day. No garbage can be left after the n-th day. In a day it is allowed to compose and drop multiple bags.

Examples

Input

3 2
3 2 1

Output

3

Input

5 1
1000000000 1000000000 1000000000 1000000000 1000000000

Output

5000000000

Input

3 2
1 0 1

Output

2

Input

4 4
2 8 4 1

Output

4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> vec;
  int v;
  for (int i = 0; i < n; i++) {
    cin >> v;
    vec.push_back(v);
  }
  long long ans = 0, rem = 0;
  for (int i = 0; i < n; i++) {
    vec[i] -= rem;
    if (vec[i] < 0) {
      rem = 0;
      continue;
    }
    int req = vec[i] / k + !!(vec[i] % k);
    if (vec[i] % k)
      rem = k - (vec[i] % k);
    else
      rem = 0;
    ans += req;
  }
  cout << ans << '\n';
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

You are given a directed graph of n vertices and m edges. Vertices are numbered from 1 to n. There is a token in vertex 1.

The following actions are allowed:

  * Token movement. To move the token from vertex u to vertex v if there is an edge u → v in the graph. This action takes 1 second.
  * Graph transposition. To transpose all the edges in the graph: replace each edge u → v by an edge v → u. This action takes increasingly more time: k-th transposition takes 2^{k-1} seconds, i.e. the first transposition takes 1 second, the second one takes 2 seconds, the third one takes 4 seconds, and so on.

The goal is to move the token from vertex 1 to vertex n in the shortest possible time. Print this time modulo 998 244 353.

Input

The first line of input contains two integers n, m (1 ≤ n, m ≤ 200 000).

The next m lines contain two integers each: u, v (1 ≤ u, v ≤ n; u ≠ v), which represent the edges of the graph. It is guaranteed that all ordered pairs (u, v) are distinct.

It is guaranteed that it is possible to move the token from vertex 1 to vertex n using the actions above.

Output

Print one integer: the minimum required time modulo 998 244 353.

Examples

Input

4 4
1 2
2 3
3 4
4 1

Output

2

Input

4 3
2 1
2 3
4 3

Output

10

Note

The first example can be solved by transposing the graph and moving the token to vertex 4, taking 2 seconds.

The best way to solve the second example is the following: transpose the graph, move the token to vertex 2, transpose the graph again, move the token to vertex 3, transpose the graph once more and move the token to vertex 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int mul(int a, int b) { return (long long)a * b % mod; }
int add(int a, int b) {
  int res = (long long)a + b;
  if (res < 0)
    res += mod;
  else if (res > mod)
    res -= mod;
  return res;
}
int bpow(int x, int p) {
  int res = 1;
  while (p) {
    if (p & 1) res = mul(res, x);
    p >>= 1;
    if (p) x = mul(x, x);
  }
  return res;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> g(25 * n);
  vector<vector<pair<int, int>>> g2(2 * n);
  for (int i = 0; i < m; i++) {
    int f, t;
    cin >> f >> t;
    f--;
    t--;
    for (int j = 0; j < 25; j++) {
      if (j % 2)
        g[t + j * n].push_back({f + j * n, 1});
      else
        g[f + j * n].push_back({t + j * n, 1});
    }
    g2[f].push_back({t, 0});
    g2[t + n].push_back({f + n, 0});
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 24; j++) {
      g[i + j * n].push_back({i + (j + 1) * n, 1 << j});
    }
    g2[i].push_back({i + n, 1});
    g2[i + n].push_back({i, 1});
  }
  priority_queue<pair<long long, int>> q;
  vector<long long> used(25 * n, -1);
  q.push({0, 0});
  while (q.size()) {
    auto v = q.top();
    q.pop();
    v.first *= -1;
    if (used[v.second] != -1) continue;
    used[v.second] = v.first;
    for (auto to : g[v.second]) {
      if (used[to.first] == -1) q.push({-(to.second + v.first), to.first});
    }
  }
  long long ans = 1e18;
  for (int i = 0; i < 25; i++) {
    if (used[n - 1 + i * n] != -1) ans = min(ans, used[n - 1 + i * n]);
  }
  if (ans == 1e18) ans = -1;
  if (ans != -1) {
    cout << ans % mod;
    return;
  }
  priority_queue<pair<pair<int, int>, int>> q2;
  vector<pair<int, int>> used2(2 * n, {-1, -1});
  q2.push({{0, 0}, 0});
  while (q2.size()) {
    auto v = q2.top();
    q2.pop();
    v.first.first *= -1;
    v.first.second *= -1;
    if (used2[v.second] != make_pair(-1, -1)) {
      continue;
    }
    used2[v.second] = v.first;
    for (auto to : g2[v.second]) {
      if (to.second == 0 && used2[to.first] == make_pair(-1, -1)) {
        q2.push({{-v.first.first, -v.first.second - 1}, to.first});
      } else if (used2[to.first] == make_pair(-1, -1)) {
        q2.push({{-v.first.first - 1, -v.first.second}, to.first});
      }
    }
  }
  pair<int, int> ans2 = min(used2[n - 1], used2[2 * n - 1]);
  cout << add(ans2.second, add(bpow(2, ans2.first), -1));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q = 1;
  for (; q > 0; q--) {
    solve();
    cout << endl;
  }
}

```


### Prompt

Please create a solution in CPP to the following problem:

Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches.

First, as they know that kingdom police is bad at math, robbers use the positional numeral system with base 7. Second, they divide one day in n hours, and each hour in m minutes. Personal watches of each robber are divided in two parts: first of them has the smallest possible number of places that is necessary to display any integer from 0 to n - 1, while the second has the smallest possible number of places that is necessary to display any integer from 0 to m - 1. Finally, if some value of hours or minutes can be displayed using less number of places in base 7 than this watches have, the required number of zeroes is added at the beginning of notation.

Note that to display number 0 section of the watches is required to have at least one place.

Little robber wants to know the number of moments of time (particular values of hours and minutes), such that all digits displayed on the watches are distinct. Help her calculate this number.

Input

The first line of the input contains two integers, given in the decimal notation, n and m (1 ≤ n, m ≤ 109) — the number of hours in one day and the number of minutes in one hour, respectively.

Output

Print one integer in decimal notation — the number of different pairs of hour and minute, such that all digits displayed on the watches are distinct.

Examples

Input

2 3

Output

4

Input

8 2

Output

5

Note

In the first sample, possible pairs are: (0: 1), (0: 2), (1: 0), (1: 2).

In the second sample, possible pairs are: (02: 1), (03: 1), (04: 1), (05: 1), (06: 1).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
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 (b < a) {
    a = b;
    return true;
  }
  return false;
}
const int mod = 1000000007, MAX = 205, INF = 1 << 30;
int main() {
  std::ifstream in("text.txt");
  std::cin.rdbuf(in.rdbuf());
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> X = {1};
  while (int(X.size()) <= 7) X.push_back(X.back() * 7);
  X.push_back(INF);
  int cnt1 = 0, cnt2 = 0;
  for (int i = 1; i < int(X.size()); i++) {
    if (N <= X[i]) {
      cnt1 = i;
      break;
    }
  }
  for (int i = 1; i < int(X.size()); i++) {
    if (M <= X[i]) {
      cnt2 = i;
      break;
    }
  }
  if (cnt1 + cnt2 >= 8) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> id(7);
  iota((id).begin(), (id).end(), 0);
  set<pair<int, int>> SE;
  do {
    int a = 0, b = 0;
    for (int i = 0; i < cnt1; i++) {
      a *= 7;
      a += id[i];
    }
    for (int i = 0; i < cnt2; i++) {
      b *= 7;
      b += id[cnt1 + i];
    }
    if (a < N && b < M) SE.insert(make_pair(a, b));
  } while (next_permutation((id).begin(), (id).end()));
  cout << int(SE.size()) << endl;
}

```


### Prompt

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

Nauuo is a girl who loves playing cards.

One day she was playing cards but found that the cards were mixed with some empty ones.

There are n cards numbered from 1 to n, and they were mixed with another n empty cards. She piled up the 2n cards and drew n of them. The n cards in Nauuo's hands are given. The remaining n cards in the pile are also given in the order from top to bottom.

In one operation she can choose a card in her hands and play it — put it at the bottom of the pile, then draw the top card from the pile.

Nauuo wants to make the n numbered cards piled up in increasing order (the i-th card in the pile from top to bottom is the card i) as quickly as possible. Can you tell her the minimum number of operations?

Input

The first line contains a single integer n (1≤ n≤ 2⋅ 10^5) — the number of numbered cards.

The second line contains n integers a_1,a_2,…,a_n (0≤ a_i≤ n) — the initial cards in Nauuo's hands. 0 represents an empty card.

The third line contains n integers b_1,b_2,…,b_n (0≤ b_i≤ n) — the initial cards in the pile, given in order from top to bottom. 0 represents an empty card.

It is guaranteed that each number from 1 to n appears exactly once, either in a_{1..n} or b_{1..n}.

Output

The output contains a single integer — the minimum number of operations to make the n numbered cards piled up in increasing order.

Examples

Input

3
0 2 0
3 0 1

Output

2

Input

3
0 2 0
1 0 3

Output

4

Input

11
0 0 0 5 0 0 0 4 0 0 11
9 2 6 0 8 1 7 0 3 0 10

Output

18

Note

Example 1

We can play the card 2 and draw the card 3 in the first operation. After that, we have [0,3,0] in hands and the cards in the pile are [0,1,2] from top to bottom.

Then, we play the card 3 in the second operation. The cards in the pile are [1,2,3], in which the cards are piled up in increasing order.

Example 2

Play an empty card and draw the card 1, then play 1, 2, 3 in order.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  int n;
  cin >> n;
  vector<bool> in(n + 1);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    in[a] = true;
  }
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  int ind = 0;
  int next_ = 1;
  vector<int> c = b;
  for (; next_ <= n; ind++) {
    int t = ind - n - 1;
    if (t >= 0 && t < n) {
      in[b[ind - n - 1]] = true;
    }
    if (c[ind % n] == next_) {
      next_++;
      c[ind % n] = -1;
      continue;
    }
    if (c[ind % n] == -1 && in[next_]) {
      next_++;
      continue;
    }
    c[ind % n] = -1;
    if (ind - next_ + 1 < n) {
      next_ = 1;
    }
  }
  cout << ind - n << endl;
}

```


### Prompt

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

In the spring of 2014, a student successfully passed the university and started living alone. The problem here is what to do with the supper. He decided to plan a supper for the next N days.

He wants to maximize the total happiness he gets in N days. Of course, the more delicious or favorite you eat, the higher your happiness.

His dinner options are two, either head to a nearby dining room or cook for himself.

The happiness you get in the cafeteria depends on the menu of the day. The menu changes daily, but there is only one type every day, and all the menus for N days have already been released. So he knows all the information that if you go to the cafeteria on day i (1 ≤ i ≤ N) you will get the happiness of Ci.

The happiness obtained by self-catering is the self-catering power at the start of self-catering multiplied by a constant P. The initial value of self-catering power is Q, which is -1 if you go to the restaurant every day, +1 if you cook yourself, and fluctuates at the end of the meal of the day.

Find the maximum sum of happiness for him.

Constraints

* 1 ≤ N ≤ 500,000
* 0 ≤ P ≤ 500,000
* | Q | ≤ 500,000
* | Ci | ≤ 500,000

Input

The input is given in the following format as N + 1 line.

N P Q
C1
C2
::
CN

* The first line is given three integers N, P, and Q, which are the number of days, the constant for calculating the happiness of self-catering, and the initial value of self-catering power.
* From the 2nd line to the N + 1st line, one integer is given, and the i + 1st line gives the happiness obtained when going to the cafeteria on the i day.

Output

Output the maximum value of happiness that can be taken in one line.

Examples

Input

1 1 1
2

Output

2

Input

3 2 1
3
3
3

Output

12

Input

3 1 -1
2
-3
2

Output

2

Input

3 1 -10
-10
-10
-10

Output

-27

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long int n, p, q;
    cin >> n >> p >> q;
    long long int c[n];
    long long int d[n];
    long long int e[n];
    for(long long int i = 0; i < n; i++)
    {
        cin >> c[i];
        d[i] = c[i] + p * i;
    }
    sort(d, d+n);
    for(long long int j = 0; j < n; j++)
    {
        e[j] = d[j] - p * (q + 2 * j);
    }
    long long int x = 0;
    long long int y = 0;
    for(long long int k = 0; k < n; k++)
    {
        y = y + e[n-1-k];
        if(x < y)
        {
            x = y;
        }
    }

    cout << x + n * p * q + n * (n-1) * p / 2 << endl;

}
```


### Prompt

Create a solution in CPP for the following problem:

It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board.

The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns.

How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?

Constraints

* 1 \leq H, W \leq N \leq 100
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
H
W

Output

Print the answer.

Examples

Input

3
2
3

Output

2

Input

100
1
1

Output

10000

Input

5
4
2

Output

8

### Response

```cpp
#include <iostream>

using namespace std;

int main(){
  int n,h,w;
  cin >> n >> h >> w;
  cout << (n-w+1)*(n-h+1) << endl;
  return 0;
}
```


### Prompt

Please formulate a Cpp solution to the following problem:

Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS).

Note that a bracket sequence is correct if it is possible to get a correct mathematical expression by adding "+"-s and "1"-s to it. For example, sequences "(())()", "()" and "(()(()))" are correct, while ")(", "(()" and "(()))(" are not. Each bracket in CBS has a pair. For example, in "(()(()))":

  * 1st bracket is paired with 8th,
  * 2d bracket is paired with 3d,
  * 3d bracket is paired with 2d,
  * 4th bracket is paired with 7th,
  * 5th bracket is paired with 6th,
  * 6th bracket is paired with 5th,
  * 7th bracket is paired with 4th,
  * 8th bracket is paired with 1st.

Polycarp's editor currently supports only three operations during the use of CBS. The cursor in the editor takes the whole position of one of the brackets (not the position between the brackets!). There are three operations being supported:

  * «L» — move the cursor one position to the left,
  * «R» — move the cursor one position to the right,
  * «D» — delete the bracket in which the cursor is located, delete the bracket it's paired to and all brackets between them (that is, delete a substring between the bracket in which the cursor is located and the one it's paired to).

After the operation "D" the cursor moves to the nearest bracket to the right (of course, among the non-deleted). If there is no such bracket (that is, the suffix of the CBS was deleted), then the cursor moves to the nearest bracket to the left (of course, among the non-deleted).

There are pictures illustrated several usages of operation "D" below.

<image>

All incorrect operations (shift cursor over the end of CBS, delete the whole CBS, etc.) are not supported by Polycarp's editor.

Polycarp is very proud of his development, can you implement the functionality of his editor?

Input

The first line contains three positive integers n, m and p (2 ≤ n ≤ 500 000, 1 ≤ m ≤ 500 000, 1 ≤ p ≤ n) — the number of brackets in the correct bracket sequence, the number of operations and the initial position of cursor. Positions in the sequence are numbered from left to right, starting from one. It is guaranteed that n is even.

It is followed by the string of n characters "(" and ")" forming the correct bracket sequence.

Then follow a string of m characters "L", "R" and "D" — a sequence of the operations. Operations are carried out one by one from the first to the last. It is guaranteed that the given operations never move the cursor outside the bracket sequence, as well as the fact that after all operations a bracket sequence will be non-empty.

Output

Print the correct bracket sequence, obtained as a result of applying all operations to the initial sequence.

Examples

Input

8 4 5
(())()()
RDLD

Output

()

Input

12 5 3
((()())(()))
RRDLD

Output

(()(()))

Input

8 8 8
(())()()
LLLLLLDD

Output

()()

Note

In the first sample the cursor is initially at position 5. Consider actions of the editor:

  1. command "R" — the cursor moves to the position 6 on the right;
  2. command "D" — the deletion of brackets from the position 5 to the position 6. After that CBS takes the form (())(), the cursor is at the position 5;
  3. command "L" — the cursor moves to the position 4 on the left;
  4. command "D" — the deletion of brackets from the position 1 to the position 4. After that CBS takes the form (), the cursor is at the position 1.

Thus, the answer is equal to ().

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, p, l, r;
string s, op;
vector<int> der, izq, match;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  while (cin >> n >> m >> p) {
    cin >> s;
    der = vector<int>(n + 2);
    izq = vector<int>(n + 2);
    for (int i = 0; i <= n + 1; i++) {
      der[i] = i + 1;
      izq[i] = i - 1;
    }
    match = vector<int>(n + 2, -1);
    stack<int> st;
    for (int i = 0; i < n; i++)
      if (s[i] == '(')
        st.push(i);
      else {
        int idx = st.top();
        st.pop();
        match[idx + 1] = i + 1;
        match[i + 1] = idx + 1;
      }
    cin >> op;
    bool empty = false;
    for (int i = 0; i < (int)op.size() && !empty; i++)
      if (op[i] == 'R') {
        if (der[p] >= 1 && der[p] <= n) p = der[p];
      } else if (op[i] == 'L') {
        if (izq[p] >= 1 && izq[p] <= n) p = izq[p];
      } else {
        l = match[p];
        r = p;
        if (l > r) swap(l, r);
        izq[der[r]] = izq[l];
        der[izq[l]] = der[r];
        if (der[izq[l]] >= 1 && der[izq[l]] <= n)
          p = der[izq[l]];
        else if (izq[der[r]] >= 1 && izq[der[r]] <= n)
          p = izq[der[r]];
        else
          empty = true;
      }
    if (empty)
      cout << '\n';
    else {
      int pos = 0;
      while (pos <= n) {
        if (pos != 0) cout << s[pos - 1];
        pos = der[pos];
      }
      cout << '\n';
    }
  }
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

You are given a sequence a_1, a_2, …, a_n of non-negative integers.

You need to find the largest number m of triples (i_1, j_1, k_1), (i_2, j_2, k_2), ..., (i_m, j_m, k_m) such that:

  * 1 ≤ i_p < j_p < k_p ≤ n for each p in 1, 2, …, m;
  * a_{i_p} = a_{k_p} = 0, a_{j_p} ≠ 0;
  * all a_{j_1}, a_{j_2}, …, a_{j_m} are different;
  * all i_1, j_1, k_1, i_2, j_2, k_2, …, i_m, j_m, k_m are different.

Input

The first line of input contains one integer t (1 ≤ t ≤ 500 000): the number of test cases.

The first line of each test case contains one integer n (1 ≤ n ≤ 500 000).

The second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ n).

The total sum of n is at most 500 000.

Output

For each test case, print one integer m: the largest number of proper triples that you can find.

Example

Input

8
1
1
2
0 0
3
0 1 0
6
0 0 1 2 0 0
6
0 1 0 0 1 0
6
0 1 3 2 0 0
6
0 0 0 0 5 0
12
0 1 0 2 2 2 0 0 3 3 4 0

Output

0
0
1
2
1
1
1
2

Note

In the first two test cases, there are not enough elements even for a single triple, so the answer is 0.

In the third test case we can select one triple (1, 2, 3).

In the fourth test case we can select two triples (1, 3, 5) and (2, 4, 6).

In the fifth test case we can select one triple (1, 2, 3). We can't select two triples (1, 2, 3) and (4, 5, 6), because a_2 = a_5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int read() {
  int g = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    g = g * 10 + ch - '0';
    ch = getchar();
  }
  return g * f;
}
const int N = 5e5 + 5;
int vl[N];
struct Seg {
  int mn[N << 2], tag[N << 2];
  void up(int v) { mn[v] = min(mn[v << 1], mn[v << 1 | 1]); }
  void ud(int v, int w) { tag[v] += w, mn[v] += w; }
  void dn(int v) {
    if (tag[v]) ud(v << 1, tag[v]), ud(v << 1 | 1, tag[v]), tag[v] = 0;
  }
  void bu(int v, int l, int r) {
    tag[v] = 0;
    if (l == r) return mn[v] = vl[l], void();
    int mid = l + r >> 1;
    bu(v << 1, l, mid), bu(v << 1 | 1, mid + 1, r);
    up(v);
  }
  void ins(int v, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return ud(v, -1), void();
    int mid = l + r >> 1;
    dn(v);
    if (ql <= mid) ins(v << 1, l, mid, ql, qr);
    if (qr > mid) ins(v << 1 | 1, mid + 1, r, ql, qr);
    up(v);
  }
} seg;
int n, a[N], pre[N], op[N], lmx[N], rmn[N];
void Main() {
  int cnt = 0, col = 0, sign = 0;
  n = read();
  for (int i = (1); i <= (n); i++)
    a[i] = read(), cnt += a[i] ? 0 : 1, pre[i] = pre[i - 1] + (a[i] ? 0 : 1);
  for (int i = (1); i <= (n); i++) lmx[i] = -1, rmn[i] = -1;
  for (int i = (1); i <= (n); i++)
    op[i] = (pre[i] - (a[i] ? 0 : 1) >= (cnt >> 1)) ? 2 : 1;
  for (int i = (1); i <= (n); i++)
    if (a[i] && op[i] == 1) lmx[a[i]] = i;
  for (int i = (n); i >= (1); i--)
    if (a[i] && op[i] == 2) rmn[a[i]] = i;
  for (int i = (1); i <= (n); i++)
    if (lmx[i] != -1 || rmn[i] != -1) col++;
  for (int i = (1); i <= (n); i++)
    if (op[i] == 2 && !a[i]) sign++;
  for (int i = (1); i <= (sign + 1); i++) vl[i] = col + sign + 1 - i;
  int tot = sign + 1;
  seg.bu(1, 1, tot);
  for (int i = (1); i <= (n); i++)
    if (lmx[i] == -1 && rmn[i] != -1)
      seg.ins(1, 1, tot, 1, pre[rmn[i]] + 1 - (cnt >> 1));
  int Ans = min(cnt >> 1, seg.mn[1]);
  int now = 0;
  for (int i = (1); i <= (n); i++)
    if (op[i] == 1) {
      if (!a[i]) now++;
      if (a[i] && i == lmx[a[i]]) {
        int x = rmn[a[i]];
        if (x != -1)
          seg.ins(1, 1, tot, 1, pre[x] + 1 - (cnt >> 1));
        else
          seg.ins(1, 1, tot, 1, tot);
      }
      Ans = min(Ans, seg.mn[1] + now);
    }
  cout << Ans << '\n';
}
signed main() {
  for (int T = read(); T--;) Main();
  return signed();
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

The tram in Berland goes along a straight line from the point 0 to the point s and back, passing 1 meter per t1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly turning around at points x = 0 and x = s.

Igor is at the point x1. He should reach the point x2. Igor passes 1 meter per t2 seconds.

Your task is to determine the minimum time Igor needs to get from the point x1 to the point x2, if it is known where the tram is and in what direction it goes at the moment Igor comes to the point x1.

Igor can enter the tram unlimited number of times at any moment when his and the tram's positions coincide. It is not obligatory that points in which Igor enter and exit the tram are integers. Assume that any boarding and unboarding happens instantly. Igor can move arbitrary along the line (but not faster than 1 meter per t2 seconds). He can also stand at some point for some time.

Input

The first line contains three integers s, x1 and x2 (2 ≤ s ≤ 1000, 0 ≤ x1, x2 ≤ s, x1 ≠ x2) — the maximum coordinate of the point to which the tram goes, the point Igor is at, and the point he should come to.

The second line contains two integers t1 and t2 (1 ≤ t1, t2 ≤ 1000) — the time in seconds in which the tram passes 1 meter and the time in seconds in which Igor passes 1 meter.

The third line contains two integers p and d (1 ≤ p ≤ s - 1, d is either 1 or <image>) — the position of the tram in the moment Igor came to the point x1 and the direction of the tram at this moment. If <image>, the tram goes in the direction from the point s to the point 0. If d = 1, the tram goes in the direction from the point 0 to the point s.

Output

Print the minimum time in seconds which Igor needs to get from the point x1 to the point x2.

Examples

Input

4 2 4
3 4
1 1

Output

8

Input

5 4 0
1 2
3 1

Output

7

Note

In the first example it is profitable for Igor to go by foot and not to wait the tram. Thus, he has to pass 2 meters and it takes 8 seconds in total, because he passes 1 meter per 4 seconds.

In the second example Igor can, for example, go towards the point x2 and get to the point 1 in 6 seconds (because he has to pass 3 meters, but he passes 1 meters per 2 seconds). At that moment the tram will be at the point 1, so Igor can enter the tram and pass 1 meter in 1 second. Thus, Igor will reach the point x2 in 7 seconds in total.

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  int s, x1, x2, t1, t2, p, d;
  scanf("%d %d %d", &s, &x1, &x2);
  scanf("%d %d", &t1, &t2);
  scanf("%d %d", &p, &d);
  if (x1 < x2) {
    int min1 = (x2 - x1) * t2;
    if (t2 <= t1) {
      printf("%d\n", min1);
    } else {
      int min2;
      if (d == 1) {
        if (p <= x1) {
          min2 = (x2 - p) * t1;
        } else {
          min2 = (2 * s - p + x2) * t1;
        }
      } else {
        min2 = (p + x2) * t1;
      }
      if (min1 < min2) {
        printf("%d\n", min1);
      } else {
        printf("%d\n", min2);
      }
    }
  } else {
    int min1 = (x1 - x2) * t2;
    if (t2 <= t1) {
      printf("%d\n", min1);
    } else {
      int min2;
      if (d == 1) {
        min2 = (s - p + s - x2) * t1;
      } else {
        if (p >= x1) {
          min2 = (p - x2) * t1;
        } else {
          min2 = (p + 2 * s - x2) * t1;
        }
      }
      if (min1 < min2) {
        printf("%d\n", min1);
      } else {
        printf("%d\n", min2);
      }
    }
  }
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

n people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins k games in a row. This player becomes the winner.

For each of the participants, you know the power to play table tennis, and for all players these values are different. In a game the player with greater power always wins. Determine who will be the winner.

Input

The first line contains two integers: n and k (2 ≤ n ≤ 500, 2 ≤ k ≤ 1012) — the number of people and the number of wins.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ n) — powers of the player. It's guaranteed that this line contains a valid permutation, i.e. all ai are distinct.

Output

Output a single integer — power of the winner.

Examples

Input

2 2
1 2

Output

2

Input

4 2
3 1 2 4

Output

3

Input

6 2
6 5 3 1 2 4

Output

6

Input

2 10000000000
2 1

Output

2

Note

Games in the second sample:

3 plays with 1. 3 wins. 1 goes to the end of the line.

3 plays with 2. 3 wins. He wins twice in a row. He becomes the winner.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  long long int k;
  cin >> n >> k;
  queue<int> q;
  int maxx = INT_MIN;
  for (int i = 0; i < n; i++) {
    int ele;
    cin >> ele;
    maxx = max(maxx, ele);
    q.push(ele);
  }
  if (k >= n - 1)
    cout << maxx;
  else {
    int wins = 0, winner = q.front();
    q.pop();
    while (wins < k) {
      int p2 = q.front();
      q.pop();
      if (winner < p2) {
        winner = p2;
        wins = 1;
        q.push(winner);
      } else {
        wins++;
        q.push(p2);
      }
    }
    cout << winner;
  }
  return 0;
}

```


### Prompt

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

You are given a connected undirected graph consisting of n vertices and m edges. There are no self-loops or multiple edges in the given graph.

You have to direct its edges in such a way that the obtained directed graph does not contain any paths of length two or greater (where the length of path is denoted as the number of traversed edges).

Input

The first line contains two integer numbers n and m (2 ≤ n ≤ 2 ⋅ 10^5, n - 1 ≤ m ≤ 2 ⋅ 10^5) — the number of vertices and edges, respectively.

The following m lines contain edges: edge i is given as a pair of vertices u_i, v_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i). There are no multiple edges in the given graph, i. e. for each pair (u_i, v_i) there are no other pairs (u_i, v_i) and (v_i, u_i) in the list of edges. It is also guaranteed that the given graph is connected (there is a path between any pair of vertex in the given graph).

Output

If it is impossible to direct edges of the given graph in such a way that the obtained directed graph does not contain paths of length at least two, print "NO" in the first line.

Otherwise print "YES" in the first line, and then print any suitable orientation of edges: a binary string (the string consisting only of '0' and '1') of length m. The i-th element of this string should be '0' if the i-th edge of the graph should be directed from u_i to v_i, and '1' otherwise. Edges are numbered in the order they are given in the input.

Example

Input

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

Output

YES
10100

Note

The picture corresponding to the first example: <image>

And one of possible answers: <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long N = 200100;
long long visited[N] = {0};
vector<long long> adj[N];
long long color[N] = {0};
void dfs(long long v) {
  if (color[v] == 1) {
    for (long long x : adj[v]) {
      if (color[x] == 0) {
        color[x] = 2;
        dfs(x);
      } else if (color[x] == 1) {
        cout << "NO" << '\n';
        exit(0);
      }
    }
  } else {
    for (long long x : adj[v]) {
      if (color[x] == 0) {
        color[x] = 1;
        dfs(x);
      } else if (color[x] == 2) {
        cout << "NO" << '\n';
        exit(0);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, i, j;
  cin >> n >> m;
  vector<pair<long long, long long> > edge;
  for (i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    edge.push_back({a, b});
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  if (n == 2 && m == 1) {
    cout << "YES" << '\n';
    cout << 1 << '\n';
    return 0;
  }
  color[1] = 1;
  dfs(1);
  cout << "YES" << '\n';
  for (i = 0; i < m; i++) {
    if (color[edge[i].first] == 1) {
      cout << 0;
    } else {
      cout << 1;
    }
  }
  return 0;
}

```


### Prompt

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

While Duff was resting in the beach, she accidentally found a strange array b0, b1, ..., bl - 1 consisting of l positive integers. This array was strange because it was extremely long, but there was another (maybe shorter) array, a0, ..., an - 1 that b can be build from a with formula: bi = ai mod n where a mod b denoted the remainder of dividing a by b.

<image>

Duff is so curious, she wants to know the number of subsequences of b like bi1, bi2, ..., bix (0 ≤ i1 < i2 < ... < ix < l), such that:

  * 1 ≤ x ≤ k
  * For each 1 ≤ j ≤ x - 1, <image>
  * For each 1 ≤ j ≤ x - 1, bij ≤ bij + 1. i.e this subsequence is non-decreasing.

Since this number can be very large, she want to know it modulo 109 + 7.

Duff is not a programmer, and Malek is unavailable at the moment. So she asked for your help. Please tell her this number.

Input

The first line of input contains three integers, n, l and k (1 ≤ n, k, n × k ≤ 106 and 1 ≤ l ≤ 1018).

The second line contains n space separated integers, a0, a1, ..., an - 1 (1 ≤ ai ≤ 109 for each 0 ≤ i ≤ n - 1).

Output

Print the answer modulo 1 000 000 007 in one line.

Examples

Input

3 5 3
5 9 1

Output

10

Input

5 10 3
1 2 3 4 5

Output

25

Note

In the first sample case, <image>. So all such sequences are: <image>, <image>, <image>, <image>, <image>, <image>, <image>, <image>, <image> and <image>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int base = (int)1e9 + 7;
int n, k;
long long l;
int a[1000005];
int gt[1000005];
long long res = 0;
long long mul(long long a, int b) {
  long long re = 0;
  long long c = a;
  while (b) {
    if (b & 1) re = (re + c) % base;
    c = (c + c) % base;
    b /= 2;
  }
  return re;
}
int main() {
  cin >> n >> l >> k;
  vector<vector<int> > f(k + 5, vector<int>(n + 5));
  vector<vector<int> > sum(k + 5, vector<int>(n + 5));
  vector<int> g(n + 5);
  vector<int> b(n + 5);
  map<int, int> Map;
  Map.clear();
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    b[i] = a[i];
  }
  sort(a + 1, a + 1 + n);
  for (int i = n; i >= 1; --i) {
    if (a[i] == a[i + 1])
      g[i] = g[i + 1];
    else
      g[i] = i;
    Map[a[i]] = g[i];
    sum[0][i] = 1;
  }
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= n; ++j) {
      f[i][j] = sum[i - 1][g[j]];
      sum[i][j] = (sum[i][j - 1] + f[i][j]) % base;
    }
    long long tmp1 = 0;
    for (int j = 1; j <= l % n; ++j)
      tmp1 = (tmp1 + sum[i - 1][Map[b[j]]]) % base;
    long long t1 = l / n + (l % n != 0);
    long long tmp = 0;
    if (t1 >= i) {
      if (l % n == 0)
        tmp = mul(t1 - i + 1, sum[i][n]);
      else
        tmp = (mul(t1 - i, sum[i][n]) + tmp1) % base;
    }
    res = (res + tmp) % base;
  }
  cout << res << endl;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Given an array a of length n, tell us whether it has a non-empty subsequence such that the product of its elements is not a perfect square.

A sequence b is a subsequence of an array a if b can be obtained from a by deleting some (possibly zero) elements.

Input

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

The first line of each test case contains an integer n (1 ≤ n ≤ 100) — the length of the array a.

The second line of each test case contains n integers a_1, a_2, …, a_{n} (1 ≤ a_i ≤ 10^4) — the elements of the array a.

Output

If there's a subsequence of a whose product isn't a perfect square, print "YES". Otherwise, print "NO".

Example

Input

2
3
1 5 4
2
100 10000

Output

YES
NO

Note

In the first example, the product of the whole array (20) isn't a perfect square.

In the second example, all subsequences have a perfect square product.

### Response

```cpp
  #include <bits/stdc++.h>
#include <list>
#include <stack>
  using namespace std;
  #define ll long long
  #define fo(i,n) for(int i=0;i<n;i++)
  #define rep(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
  #define pb push_back
  #define mp make_pair
  #define F first
  #define S second
  #define all(x) x.begin(), x.end()
  #define clr(x) memset(x, 0, sizeof(x))
  #define ini(a, i) memset(a, i, sizeof(a))
  #define sortall(x) sort(all(x))
  #define rev(x) reverse(all(x))
  #define PI 3.1415926535897932384626
  typedef pair<ll, ll> pii;
  typedef pair<ll, ll> pl;
  typedef vector<ll> vi;
  typedef vector<ll>  vl;
  typedef vector<pii> vpii;
  typedef vector<pl>  vpl;
  typedef vector<vi>  vvi;
  typedef vector<vl>  vvl;
  const int INF = 1000000007;
  const long long INFLL = (ll)INF * (ll)INF;
  #define ld long double
  const ld EPS = 10e-9;
  const unsigned int M = 1000000007;
  #define int long long
  long double pi = 2*acos(0.0);

  // cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;

  //s.substr(start index,length)
  //lower_bound
  //upper_bound
  //*max_element
  //*min_element
  //continue
  // vector<vector<int>> vec( n , vector<int> (m, 0));
  // in a matrix if i select cell a(i,j) then the parity of (i+j) all the adjacent cells is opposite
  //check cube root
  // double b=cbrt(x-a*a*a);
  // if(floor(b)==b)
  // {
  //   yes;return;
  // }
//const bool is_in = container.find(element) != container.end();
  //int chalao=1000000000000;
  // x has cbrt(x) divisors
  // pass string by reference
  // PREFER DP[MIN_SIZE][MAX_SIZE] OVER DP[MAX_SIZE][MIN_SIZE]
int mod=1000000007;
// int dp[1003][1003];
// memset(dp,-1,sizeof(dp));

void solve()
{
  int n;
  cin>>n;
  int a[n];
  int flag=0;
  for (int i = 0; i < n; ++i)
  {
    cin>>a[i];
    double ash=sqrt((double)a[i]);
    if(floor(ash)!=ceil(ash))
      flag=1;
  }
  if(flag==1)
  {
    cout<<"YES"<<endl;
  }
  else
    cout<<"NO"<<endl;

}

 int32_t main()
 {
     clock_t start, end;
     start = clock();
       // ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
         #ifndef ONLINE_JUDGE
         freopen("input.txt", "r", stdin);
         freopen("output.txt", "w", stdout);
         #endif // ONLINE_JUDGE
     // sieve();
       // initalize();
     int t=1;
      cin>>t;

     while(t--)
      solve();
    // cout<<primes.size();

     //cout<<t1;
     end = clock();

    //  // Calculating total time taken by the program.
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
    // cout << "\nTime taken by program is : " << fixed << time_taken << setprecision(5);
    // cout << " sec " << endl;

     return 0;
 }
```


### Prompt

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

Lunar New Year is approaching, and Bob is struggling with his homework – a number division problem.

There are n positive integers a_1, a_2, …, a_n on Bob's homework paper, where n is always an even number. Bob is asked to divide those numbers into groups, where each group must contain at least 2 numbers. Suppose the numbers are divided into m groups, and the sum of the numbers in the j-th group is s_j. Bob's aim is to minimize the sum of the square of s_j, that is $$$∑_{j = 1}^{m} s_j^2.$$$

Bob is puzzled by this hard problem. Could you please help him solve it?

Input

The first line contains an even integer n (2 ≤ n ≤ 3 ⋅ 10^5), denoting that there are n integers on Bob's homework paper.

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^4), describing the numbers you need to deal with.

Output

A single line containing one integer, denoting the minimum of the sum of the square of s_j, which is $$$∑_{i = j}^{m} s_j^2, where m$$$ is the number of groups.

Examples

Input

4
8 5 2 3

Output

164

Input

6
1 1 1 2 2 2

Output

27

Note

In the first sample, one of the optimal solutions is to divide those 4 numbers into 2 groups \{2, 8\}, \{5, 3\}. Thus the answer is (2 + 8)^2 + (5 + 3)^2 = 164.

In the second sample, one of the optimal solutions is to divide those 6 numbers into 3 groups \{1, 2\}, \{1, 2\}, \{1, 2\}. Thus the answer is (1 + 2)^2 + (1 + 2)^2 + (1 + 2)^2 = 27.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long int ans = 0;
  for (int i = 0; i < n / 2; i++) {
    long long int numone = a[i];
    long long int numtwo = a[n - i - 1];
    long long int sum = numtwo + numone;
    ans += (sum * sum);
  }
  cout << ans << endl;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

User ainta has a stack of n red and blue balls. He can apply a certain operation which changes the colors of the balls inside the stack.

  * While the top ball inside the stack is red, pop the ball from the top of the stack.
  * Then replace the blue ball on the top with a red ball.
  * And finally push some blue balls to the stack until the stack has total of n balls inside.

If there are no blue balls inside the stack, ainta can't apply this operation. Given the initial state of the stack, ainta wants to know the maximum number of operations he can repeatedly apply.

Input

The first line contains an integer n (1 ≤ n ≤ 50) — the number of balls inside the stack.

The second line contains a string s (|s| = n) describing the initial state of the stack. The i-th character of the string s denotes the color of the i-th ball (we'll number the balls from top to bottom of the stack). If the character is "R", the color is red. If the character is "B", the color is blue.

Output

Print the maximum number of operations ainta can repeatedly apply.

Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

3
RBR

Output

2

Input

4
RBBR

Output

6

Input

5
RBBRR

Output

6

Note

The first example is depicted below.

The explanation how user ainta applies the first operation. He pops out one red ball, changes the color of the ball in the middle from blue to red, and pushes one blue ball.

<image>

The explanation how user ainta applies the second operation. He will not pop out red balls, he simply changes the color of the ball on the top from blue to red.

<image>

From now on, ainta can't apply any operation because there are no blue balls inside the stack. ainta applied two operations, so the answer is 2.

The second example is depicted below. The blue arrow denotes a single operation.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  long long count = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'B') count += pow(2, i);
  }
  cout << count << endl;
  return 0;
}

```


### Prompt

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

Snuke lives in another world, where slimes are real creatures and kept by some people. Slimes come in N colors. Those colors are conveniently numbered 1 through N. Snuke currently has no slime. His objective is to have slimes of all the colors together.

Snuke can perform the following two actions:

* Select a color i (1≤i≤N), such that he does not currently have a slime in color i, and catch a slime in color i. This action takes him a_i seconds.

* Cast a spell, which changes the color of all the slimes that he currently has. The color of a slime in color i (1≤i≤N-1) will become color i+1, and the color of a slime in color N will become color 1. This action takes him x seconds.

Find the minimum time that Snuke needs to have slimes in all N colors.

Constraints

* 2≤N≤2,000
* a_i are integers.
* 1≤a_i≤10^9
* x is an integer.
* 1≤x≤10^9

Input

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

N x
a_1 a_2 ... a_N

Output

Find the minimum time that Snuke needs to have slimes in all N colors.

Examples

Input

2 10
1 100

Output

12

Input

3 10
100 1 100

Output

23

Input

4 10
1 2 3 4

Output

10

### Response

```cpp
#include <iostream>
using namespace std;
long long a[3000],b[3000];
int main(){
	long long ans=1234123412341234,x,ans0=0;int n;
	cin>>n>>x;
	for(int i=0;i<n;i++){
		cin>>a[i];b[i]=a[i];ans0+=a[i];
	}
	for(int i=1;i<=n;i++){
		if(ans>ans0)ans=ans0;
		ans0+=x;
		for(int j=0;j<n;j++){
			int k=j-i;
			while(k<0)k+=n;
			if(b[j]>a[k]){
				ans0-=(b[j]-a[k]);
				b[j]=a[k];
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
```


### Prompt

Create a solution in cpp for the following problem:

N friends of Takahashi has come to a theme park.

To ride the most popular roller coaster in the park, you must be at least K centimeters tall.

The i-th friend is h_i centimeters tall.

How many of the Takahashi's friends can ride the roller coaster?

Constraints

* 1 \le N \le 10^5
* 1 \le K \le 500
* 1 \le h_i \le 500
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
h_1 h_2 \ldots h_N

Output

Print the number of people among the Takahashi's friends who can ride the roller coaster.

Examples

Input

4 150
150 140 100 200

Output

2

Input

1 500
499

Output

0

Input

5 1
100 200 300 400 500

Output

5

### Response

```cpp
#include <iostream>
using namespace std;
int main(){
  int A,B,C=0;
  cin>>A>>B;
  int D[A];
  for(int i=0;i<A;i++){
    cin>>D[i];
    if(D[i]>=B) C++;
  }
  cout<<C;
  return 0;
}
```


### Prompt

Please formulate a Cpp solution to the following problem:

Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of sportsmen, training at that racetrack, equals n. And each of them regularly runs distances within a particular segment of the racetrack, which is the same for each sportsman. For example, the first sportsman runs from position a1 to position b1, the second — from a2 to b2

What is the minimum distance that Bob should move to have a chance to take pictures of each sportsman? Bob can take a picture of a sportsman, if he stands within the segment that this sportsman covers on the racetrack.

Input

The first line of the input file contains integers n and x0 (1 ≤ n ≤ 100; 0 ≤ x0 ≤ 1000). The following n lines contain pairs of integers ai, bi (0 ≤ ai, bi ≤ 1000; ai ≠ bi).

Output

Output the required minimum distance in the same units as the positions on the racetrack. If there is no such a position, output -1.

Examples

Input

3 3
0 7
14 2
4 6

Output

1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int const N = 1234;
int a[N], n, m, ans = 10 * N;
int main() {
  scanf("%d%d", &n, &m);
  for (register int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    for (register int j = x; j <= y; j++) {
      a[j]++;
      if (a[j] == n) {
        if (abs(j - m) < ans) ans = abs(j - m);
      }
    }
  }
  if (ans == 10 * N)
    puts("-1");
  else
    printf("%d", ans);
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and rotate specified elements by a list of the following operation:

* rotate($b, m, e$): For each integer $k$ ($0 \leq k < (e - b)$), move element $b + k$ to the place of element $b + ((k + (e - m)) \mod (e - b))$.

Constraints

* $1 \leq n \leq 1,000$
* $-1,000,000,000 \leq a_i \leq 1,000,000,000$
* $1 \leq q \leq 1,000$
* $0 \leq b_i \leq m_i < e_i \leq n$

Input

The input is given in the following format.

$n$
$a_0 \; a_1 \; ...,\; a_{n-1}$
$q$
$b_1 \; m_1 \; e_1$
$b_2 \; m_2 \; e_2$
:
$b_{q} \; m_{q} \; e_{q}$

In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; m_i \; e_i$ in the following $q$ lines.

Output

Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element.

Example

Input

11
1 2 3 4 5 6 7 8 9 10 11
1
2 6 9

Output

1 2 7 8 9 3 4 5 6 10 11

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
	int n, a, q, b, m, e;
	vector<int> A;
	cin >> n;
	rep(i, n)
	{
		cin >> a;
		A.push_back(a);
	}

	cin >> q;
	rep(i, q)
	{
	    cin >> b >> m >> e;
	    rotate(A.begin() + b, A.begin() + m,  A.begin() + e);
	}

	rep(i, n)
	{
	    if (i)
	    {
	        cout << " ";
	    }
	    cout << A[i];
	}
	cout << endl;
}

```


### Prompt

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

Berland scientists face a very important task - given the parts of short DNA fragments, restore the dinosaur DNA! The genome of a berland dinosaur has noting in common with the genome that we've used to: it can have 26 distinct nucleotide types, a nucleotide of each type can occur at most once. If we assign distinct English letters to all nucleotides, then the genome of a Berland dinosaur will represent a non-empty string consisting of small English letters, such that each letter occurs in it at most once.

Scientists have n genome fragments that are represented as substrings (non-empty sequences of consecutive nucleotides) of the sought genome.

You face the following problem: help scientists restore the dinosaur genome. It is guaranteed that the input is not contradictory and at least one suitable line always exists. When the scientists found out that you are a strong programmer, they asked you in addition to choose the one with the minimum length. If there are multiple such strings, choose any string.

Input

The first line of the input contains a positive integer n (1 ≤ n ≤ 100) — the number of genome fragments.

Each of the next lines contains one descriptions of a fragment. Each fragment is a non-empty string consisting of distinct small letters of the English alphabet. It is not guaranteed that the given fragments are distinct. Fragments could arbitrarily overlap and one fragment could be a substring of another one.

It is guaranteed that there is such string of distinct letters that contains all the given fragments as substrings.

Output

In the single line of the output print the genome of the minimum length that contains all the given parts. All the nucleotides in the genome must be distinct. If there are multiple suitable strings, print the string of the minimum length. If there also are multiple suitable strings, you can print any of them.

Examples

Input

3
bcd
ab
cdef

Output

abcdef

Input

4
x
y
z
w

Output

xyzw

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  char s[30];
  bool used[30] = {};
  int nx[30] = {};
  int indeg[30] = {};
  cin >> n;
  memset(nx, -1, sizeof nx);
  for (int i = 0; i < n; i++) {
    cin >> s;
    int len = strlen(s);
    for (int j = 0; j < len; j++) used[s[j] - 'a'] = true;
    for (int j = 0; j < len - 1; j++) {
      nx[s[j] - 'a'] = s[j + 1] - 'a';
      ++indeg[s[j + 1] - 'a'];
    }
  }
  string ans = "";
  for (int i = 0; i < 26; i++) {
    if (used[i] && !indeg[i]) {
      for (int c = i; c != -1; c = nx[c]) {
        ans += char(c + 'a');
      }
    }
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

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

The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Instead of improving the demographic situation, they decided to achieve its goal by expanding the boundaries of the city.

The city of Tomsk can be represented as point on the plane with coordinates (0; 0). The city is surrounded with n other locations, the i-th one has coordinates (xi, yi) with the population of ki people. You can widen the city boundaries to a circle of radius r. In such case all locations inside the circle and on its border are included into the city.

Your goal is to write a program that will determine the minimum radius r, to which is necessary to expand the boundaries of Tomsk, so that it becomes a megacity.

Input

The first line of the input contains two integers n and s (1 ≤ n ≤ 103; 1 ≤ s < 106) — the number of locatons around Tomsk city and the population of the city. Then n lines follow. The i-th line contains three integers — the xi and yi coordinate values of the i-th location and the number ki of people in it (1 ≤ ki < 106). Each coordinate is an integer and doesn't exceed 104 in its absolute value.

It is guaranteed that no two locations are at the same point and no location is at point (0; 0).

Output

In the output, print "-1" (without the quotes), if Tomsk won't be able to become a megacity. Otherwise, in the first line print a single real number — the minimum radius of the circle that the city needs to expand to in order to become a megacity.

The answer is considered correct if the absolute or relative error don't exceed 10 - 6.

Examples

Input

4 999998
1 1 1
2 2 1
3 3 1
2 -2 1

Output

2.8284271

Input

4 999998
1 1 2
2 2 1
3 3 1
2 -2 1

Output

1.4142136

Input

2 1
1 1 999997
2 2 1

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
int main() {
  int n, p, a = 0, x, y, z;
  cin >> n >> p;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> z;
    v.push_back(make_pair(x * x + y * y, z));
    a += z;
  }
  if ((p + a) < 1000000) {
    cout << -1;
    return 0;
  }
  sort(v.begin(), v.end());
  int r = 0, c = 0;
  for (int i = 0; i < n; i++) {
    c += v[i].second;
    if ((c + p) >= 1000000) {
      r = v[i].first;
      break;
    }
  }
  double ans = sqrt(1.0 * r);
  printf("%.6f", ans);
}

```


### Prompt

Please create a solution in CPP to the following problem:

You work in a big office. It is a 9 floor building with an elevator that can accommodate up to 4 people. It is your responsibility to manage this elevator.

Today you are late, so there are queues on some floors already. For each person you know the floor where he currently is and the floor he wants to reach. Also, you know the order in which people came to the elevator.

According to the company's rules, if an employee comes to the elevator earlier than another one, he has to enter the elevator earlier too (even if these employees stay on different floors). Note that the employees are allowed to leave the elevator in arbitrary order.

The elevator has two commands:

  * Go up or down one floor. The movement takes 1 second.
  * Open the doors on the current floor. During this operation all the employees who have reached their destination get out of the elevator. Then all the employees on the floor get in the elevator in the order they are queued up while it doesn't contradict the company's rules and there is enough space in the elevator. Each employee spends 1 second to get inside and outside the elevator.

Initially the elevator is empty and is located on the floor 1.

You are interested what is the minimum possible time you need to spend to deliver all the employees to their destination. It is not necessary to return the elevator to the floor 1.

Input

The first line contains an integer n (1 ≤ n ≤ 2000) — the number of employees.

The i-th of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 9, ai ≠ bi) — the floor on which an employee initially is, and the floor he wants to reach.

The employees are given in the order they came to the elevator.

Output

Print a single integer — the minimal possible time in seconds.

Examples

Input

2
3 5
5 3

Output

10

Input

2
5 3
3 5

Output

12

Note

Explaination for the first sample <image> t = 0

<image> t = 2

<image> t = 3

<image> t = 5

<image> t = 6

<image> t = 7

<image> t = 9

<image> t = 10

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
multiset<int> s;
map<multiset<int>, int> mmp;
multiset<int> ssr[720];
void dfs(int stp) {
  if (stp == 5) {
    mmp[s] = 0;
    return;
  }
  for (int i = 1; i <= 9; i++) {
    dfs(stp + 1);
    s.insert(i);
    dfs(stp + 1);
    s.erase(s.find(i));
  }
}
int dp[2005][10][720];
int up[720][10];
pair<int, int> down[720][5];
struct node {
  int i, j, k;
  int val;
  bool operator<(const node &t) const { return val > t.val; }
};
void show(int x) {
  for (auto it = ssr[x].begin(); it != ssr[x].end(); it++) cout << *it << " ";
  cout << endl;
}
int n;
int a[2005], b[2005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  dfs(1);
  int L = 0;
  for (auto it = mmp.begin(); it != mmp.end(); it++) {
    it->second = ++L;
    ssr[L] = it->first;
  }
  for (int state = 1; state <= 715; state++) {
    multiset<int> s = ssr[state];
    if (ssr[state].size() < 4) {
      for (int i = 1; i <= 9; i++) {
        s.insert(i);
        up[state][i] = mmp[s];
        s.erase(s.find(i));
      }
    }
    if (ssr[state].size()) {
      int i = 0;
      for (auto it = ssr[state].begin(); it != ssr[state].end(); it++) {
        s.erase(s.find(*it));
        down[state][++i] = {mmp[s], *it};
        s.insert(*it);
      }
    }
  }
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
  memset(dp, 0x3f, sizeof dp);
  dp[0][1][1] = 0;
  priority_queue<node> q;
  q.push({0, 1, 1, 0});
  while (!q.empty()) {
    int ui = q.top().i, uj = q.top().j, uk = q.top().k, val = q.top().val;
    q.pop();
    if (ui == n && uk == 1) break;
    for (int i = 1; i <= 4; i++) {
      if (!down[uk][i].first) break;
      int nk = down[uk][i].first, nj = down[uk][i].second;
      if (dp[ui][nj][nk] > dp[ui][uj][uk] + abs(nj - uj)) {
        dp[ui][nj][nk] = dp[ui][uj][uk] + abs(nj - uj);
        q.push({ui, nj, nk, dp[ui][nj][nk]});
      }
    }
    int nk = up[uk][b[ui + 1]];
    if (nk) {
      int nj = a[ui + 1];
      if (dp[ui + 1][nj][nk] > dp[ui][uj][uk] + abs(nj - uj)) {
        dp[ui + 1][nj][nk] = dp[ui][uj][uk] + abs(nj - uj);
        q.push({ui + 1, nj, nk, dp[ui + 1][nj][nk]});
      }
    }
  }
  int ans = 0x3f3f3f3f;
  for (int i = 1; i <= 9; i++) ans = min(ans, dp[n][i][1]);
  cout << ans + 2 * n << endl;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

As we all know, Max is the best video game player among her friends. Her friends were so jealous of hers, that they created an actual game just to prove that she's not the best at games. The game is played on a directed acyclic graph (a DAG) with n vertices and m edges. There's a character written on each edge, a lowercase English letter.

<image>

Max and Lucas are playing the game. Max goes first, then Lucas, then Max again and so on. Each player has a marble, initially located at some vertex. Each player in his/her turn should move his/her marble along some edge (a player can move the marble from vertex v to vertex u if there's an outgoing edge from v to u). If the player moves his/her marble from vertex v to vertex u, the "character" of that round is the character written on the edge from v to u. There's one additional rule; the ASCII code of character of round i should be greater than or equal to the ASCII code of character of round i - 1 (for i > 1). The rounds are numbered for both players together, i. e. Max goes in odd numbers, Lucas goes in even numbers. The player that can't make a move loses the game. The marbles may be at the same vertex at the same time.

Since the game could take a while and Lucas and Max have to focus on finding Dart, they don't have time to play. So they asked you, if they both play optimally, who wins the game?

You have to determine the winner of the game for all initial positions of the marbles.

Input

The first line of input contains two integers n and m (2 ≤ n ≤ 100, <image>).

The next m lines contain the edges. Each line contains two integers v, u and a lowercase English letter c, meaning there's an edge from v to u written c on it (1 ≤ v, u ≤ n, v ≠ u). There's at most one edge between any pair of vertices. It is guaranteed that the graph is acyclic.

Output

Print n lines, a string of length n in each one. The j-th character in i-th line should be 'A' if Max will win the game in case her marble is initially at vertex i and Lucas's marble is initially at vertex j, and 'B' otherwise.

Examples

Input

4 4
1 2 b
1 3 a
2 4 c
3 4 b

Output

BAAA
ABAA
BBBA
BBBB

Input

5 8
5 3 h
1 2 c
3 1 c
3 2 r
5 1 r
4 3 z
5 4 r
5 2 h

Output

BABBB
BBBBB
AABBB
AAABA
AAAAB

Note

Here's the graph in the first sample test case:

<image>

Here's the graph in the second sample test case:

<image>

### Response

```cpp
#include <bits/stdc++.h>
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int& n, int b) { n |= two(b); }
inline void unset_bit(int& n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) {
  int res = 0;
  while (n && ++res) n -= n & (-n);
  return res;
}
long long int gcd(long long int a, long long int b) {
  return (a ? gcd(b % a, a) : b);
}
long long int modPow(long long int a, long long int b, long long int MOD) {
  long long int x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y) % MOD;
    }
    b /= 2;
    y = (y * y) % MOD;
  }
  return x;
}
long long int modInverse(long long int a, long long int p) {
  return modPow(a, p - 2, p);
}
using namespace std;
int dp[101][101][101];
vector<pair<int, int> > adj[101];
int solve(int v, int u, int ch) {
  if (dp[v][u][ch] != -1) return dp[v][u][ch];
  int ans = 0;
  for (auto x : adj[v]) {
    if (x.second >= ch) ans |= !solve(u, x.first, x.second);
  }
  return (dp[v][u][ch] = ans);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(dp, -1, sizeof(dp));
  int n, m, u, v;
  char ch;
  cin >> n >> m;
  for (auto i = (1); i <= (m); i++) {
    cin >> u >> v >> ch;
    adj[u].push_back({v, ch - 'a'});
  }
  for (auto i = (1); i <= (n); i++) {
    for (auto j = (1); j <= (n); j++) {
      if (solve(i, j, 0))
        cout << "A";
      else
        cout << "B";
    }
    cout << endl;
  }
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

While discussing a proper problem A for a Codeforces Round, Kostya created a cyclic array of positive integers a_1, a_2, …, a_n. Since the talk was long and not promising, Kostya created a new cyclic array b_1, b_2, …, b_{n} so that b_i = (a_i mod a_{i + 1}), where we take a_{n+1} = a_1. Here mod is the [modulo operation](https://en.wikipedia.org/wiki/Modulo_operation). When the talk became interesting, Kostya completely forgot how array a had looked like. Suddenly, he thought that restoring array a from array b would be an interesting problem (unfortunately, not A).

Input

The first line contains a single integer n (2 ≤ n ≤ 140582) — the length of the array a.

The second line contains n integers b_1, b_2, …, b_{n} (0 ≤ b_i ≤ 187126).

Output

If it is possible to restore some array a of length n so that b_i = a_i mod a_{(i mod n) + 1} holds for all i = 1, 2, …, n, print «YES» in the first line and the integers a_1, a_2, …, a_n in the second line. All a_i should satisfy 1 ≤ a_i ≤ 10^{18}. We can show that if an answer exists, then an answer with such constraint exists as well.

It it impossible to restore any valid a, print «NO» in one line.

You can print each letter in any case (upper or lower).

Examples

Input

4
1 3 1 0

Output

YES
1 3 5 2

Input

2
4 4

Output

NO

Note

In the first example:

  * 1 mod 3 = 1
  * 3 mod 5 = 3
  * 5 mod 2 = 1
  * 2 mod 1 = 0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 140582 + 5;
int n, a[MAXN], mx = 0, v = 0;
long long b[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  bool flg = 1;
  for (int i = 2; i <= n; i++) flg &= (a[i] == a[1]);
  if (flg && a[1] == 0) {
    puts("YES");
    for (int i = 1; i <= n; i++) printf("1 ");
    printf("\n");
    return 0;
  }
  if (flg) return puts("NO"), 0;
  for (int i = 1; i <= n; i++) (a[i] > mx) ? (mx = a[i], v = i) : 0;
  while (a[v] == mx) {
    v--;
    if (!v) v = n;
  }
  v++;
  if (v == n + 1) v = 1;
  long long x = 0;
  for (int i = 1; i <= n; i++) {
    if (i == 2) x += mx;
    x += a[v];
    b[v] = x;
    v--;
    if (!v) v = n;
  }
  puts("YES");
  for (int i = 1; i <= n; i++) printf("%lld ", b[i]);
  return 0;
}

```


### Prompt

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

Polycarpus works as a programmer in a start-up social network. His boss gave his a task to develop a mechanism for determining suggested friends. Polycarpus thought much about the task and came to the folowing conclusion.

Let's say that all friendship relationships in a social network are given as m username pairs ai, bi (ai ≠ bi). Each pair ai, bi means that users ai and bi are friends. Friendship is symmetric, that is, if ai is friends with bi, then bi is also friends with ai. User y is a suggested friend for user x, if the following conditions are met:

  1. x ≠ y;
  2. x and y aren't friends;
  3. among all network users who meet the first two conditions, user y has most of all common friends with user x. User z is a common friend of user x and user y (z ≠ x, z ≠ y), if x and z are friends, and y and z are also friends.

Your task is to help Polycarpus to implement a mechanism for determining suggested friends.

Input

The first line contains a single integer m (1 ≤ m ≤ 5000) — the number of pairs of friends in the social network. Next m lines contain pairs of names of the users who are friends with each other. The i-th line contains two space-separated names ai and bi (ai ≠ bi). The users' names are non-empty and consist of at most 20 uppercase and lowercase English letters.

It is guaranteed that each pair of friends occurs only once in the input. For example, the input can't contain x, y and y, x at the same time. It is guaranteed that distinct users have distinct names. It is guaranteed that each social network user has at least one friend. The last thing guarantees that each username occurs at least once in the input.

Output

In the first line print a single integer n — the number of network users. In next n lines print the number of suggested friends for each user. In the i-th line print the name of the user ci and the number of his suggested friends di after a space.

You can print information about the users in any order.

Examples

Input

5
Mike Gerald
Kate Mike
Kate Tank
Gerald Tank
Gerald David

Output

5
Mike 1
Gerald 1
Kate 1
Tank 1
David 2

Input

4
valera vanya
valera edik
pasha valera
igor valera

Output

5
valera 0
vanya 3
edik 3
pasha 3
igor 3

Note

In the first test case consider user David. Users Mike and Tank have one common friend (Gerald) with David. User Kate has no common friends with David. That's why David's suggested friends are users Mike and Tank.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 10;
map<string, int> m;
map<int, string> m2;
int s[MAXN];
vector<pair<int, int> > v;
bitset<10010> g;
int main() {
  ios::sync_with_stdio(false);
  int n, cnt = 1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string a, b;
    cin >> a >> b;
    if (m[a] == 0) m[a] = cnt++, m2[cnt - 1] = a;
    if (m[b] == 0) m[b] = cnt++, m2[cnt - 1] = b;
    int x = m[a], y = m[b];
    v.push_back({m[a], m[b]});
  }
  cnt--;
  cout << cnt << endl;
  for (int i = 1; i <= cnt; i++) {
    g = 0;
    for (pair<int, int> p : v)
      if (p.first == i)
        g[p.second] = 1;
      else if (p.second == i)
        g[p.first] = 1;
    memset(s, 0, sizeof s);
    for (pair<int, int> p : v) {
      if (g[p.first]) s[p.second]++;
      if (g[p.second]) s[p.first]++;
    }
    int ind = 0, ans = 0;
    for (int j = 1; j <= cnt; j++)
      if (g[j] == 0 and j != i and s[j] > s[ind]) ind = j;
    for (int j = 1; j <= cnt; j++)
      if (g[j] == 0 and j != i and s[j] == s[ind]) ans++;
    cout << m2[i] << " " << ans << "\n";
  }
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

The ship crashed into a reef and is sinking. Now the entire crew must be evacuated. All n crew members have already lined up in a row (for convenience let's label them all from left to right with positive integers from 1 to n) and await further instructions. However, one should evacuate the crew properly, in a strict order. Specifically:

The first crew members to leave the ship are rats. Then women and children (both groups have the same priority) leave the ship. After that all men are evacuated from the ship. The captain leaves the sinking ship last.

If we cannot determine exactly who should leave the ship first for any two members of the crew by the rules from the previous paragraph, then the one who stands to the left in the line leaves the ship first (or in other words, the one whose number in the line is less).

For each crew member we know his status as a crew member, and also his name. All crew members have different names. Determine the order in which to evacuate the crew.

Input

The first line contains an integer n, which is the number of people in the crew (1 ≤ n ≤ 100). Then follow n lines. The i-th of those lines contains two words — the name of the crew member who is i-th in line, and his status on the ship. The words are separated by exactly one space. There are no other spaces in the line. The names consist of Latin letters, the first letter is uppercase, the rest are lowercase. The length of any name is from 1 to 10 characters. The status can have the following values: rat for a rat, woman for a woman, child for a child, man for a man, captain for the captain. The crew contains exactly one captain.

Output

Print n lines. The i-th of them should contain the name of the crew member who must be the i-th one to leave the ship.

Examples

Input

6
Jack captain
Alice woman
Charlie man
Teddy rat
Bob child
Julia woman

Output

Teddy
Alice
Bob
Julia
Charlie
Jack

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s, h;
  vector<pair<string, string> > t1, t2, t3, t4;
  for (int i = 0; i < n; i++) {
    cin >> s >> h;
    if (h == "rat")
      t1.push_back({s, h});
    else if (h == "woman" || h == "child")
      t2.push_back({s, h});
    else if (h == "man")
      t3.push_back({s, h});
    else
      t4.push_back({s, h});
  }
  for (int i = 0; i < t1.size(); i++) cout << t1[i].first << endl;
  for (int i = 0; i < t2.size(); i++) cout << t2[i].first << endl;
  for (int i = 0; i < t3.size(); i++) cout << t3[i].first << endl;
  for (int i = 0; i < t4.size(); i++) cout << t4[i].first << endl;
  return 0;
}

```


### Prompt

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

Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller.

Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number occurs in this array. He wants to choose the smallest subsegment of this array such that the beauty of it will be the same as the original array.

Help Amr by choosing the smallest subsegment possible.

Input

The first line contains one number n (1 ≤ n ≤ 105), the size of the array.

The second line contains n integers ai (1 ≤ ai ≤ 106), representing elements of the array.

Output

Output two integers l, r (1 ≤ l ≤ r ≤ n), the beginning and the end of the subsegment chosen respectively.

If there are several possible answers you may output any of them.

Examples

Input

5
1 1 2 2 1

Output

1 5

Input

5
1 2 2 3 1

Output

2 3

Input

6
1 2 2 1 1 2

Output

1 5

Note

A subsegment B of an array A from l to r is an array of size r - l + 1 where Bi = Al + i - 1 for all 1 ≤ i ≤ r - l + 1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, -1, 0};
int dy[] = {1, 0, 0, -1};
long double PI = 3.14159265358979323846264338327950;
const int N = 1e6 + 10;
int st[N], End[N], mp[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mp[a[i]]++;
    End[a[i]] = i;
    if (!st[a[i]]) st[a[i]] = i;
  }
  int l, r, mx = 0;
  for (int i = 0; i < N; i++) {
    if (mp[i]) {
      if (mp[i] > mx) {
        mx = mp[i];
        l = st[i];
        r = End[i];
      } else if (mp[i] == mx) {
        if (End[i] - st[i] < r - l) {
          l = st[i];
          r = End[i];
        }
      }
    }
  }
  cout << l << " " << r;
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

There are N cubes stacked vertically on a desk.

You are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is `0`, and blue if that character is `1`.

You can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.

At most how many cubes can be removed?

Constraints

* 1 \leq N \leq 10^5
* |S| = N
* Each character in S is `0` or `1`.

Input

Input is given from Standard Input in the following format:

S

Output

Print the maximum number of cubes that can be removed.

Examples

Input

0011

Output

4

Input

11011010001011

Output

12

Input

0

Output

0

### Response

```cpp
#include<iostream>
using namespace std;
int x;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
		if(s[i]=='0')
			x++;
	cout<<2*min(x,(int)s.size()-x);
	return 0;
}
```


### Prompt

Construct a CPP code solution to the problem outlined:

We're giving away nice huge bags containing number tiles! A bag we want to present to you contains n tiles. Each of them has a single number written on it — either 1 or 2.

However, there is one condition you must fulfill in order to receive the prize. You will need to put all the tiles from the bag in a sequence, in any order you wish. We will then compute the sums of all prefixes in the sequence, and then count how many of these sums are prime numbers. If you want to keep the prize, you will need to maximize the number of primes you get.

Can you win the prize? Hurry up, the bags are waiting!

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of number tiles in the bag. The following line contains n space-separated integers a_1, a_2, ..., a_n (a_i ∈ \{1, 2\}) — the values written on the tiles.

Output

Output a permutation b_1, b_2, ..., b_n of the input sequence (a_1, a_2, ..., a_n) maximizing the number of the prefix sums being prime numbers. If there are multiple optimal permutations, output any.

Examples

Input

5
1 2 1 2 1

Output

1 1 1 2 2

Input

9
1 1 2 1 1 1 2 1 1

Output

1 1 1 2 1 1 1 2 1

Note

The first solution produces the prefix sums 1, \mathbf{\color{blue}{2}}, \mathbf{\color{blue}{3}}, \mathbf{\color{blue}{5}}, \mathbf{\color{blue}{7}} (four primes constructed), while the prefix sums in the second solution are 1, \mathbf{\color{blue}{2}}, \mathbf{\color{blue}{3}}, \mathbf{\color{blue}{5}}, 6, \mathbf{\color{blue}{7}}, 8, 10, \mathbf{\color{blue}{11}} (five primes). Primes are marked bold and blue. In each of these cases, the number of produced primes is maximum possible.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1e6 + 4;
int main() {
  int n;
  scanf("%d", &n);
  int one = 0, two = 0;
  for (int i = 0; i < n; i++) {
    int temp;
    scanf("%d", &temp);
    if (temp == 1)
      one++;
    else
      two++;
  }
  if (two) {
    cout << "2 ";
    two--;
    if (one) {
      cout << "1 ";
      one--;
    }
    while (two--) cout << "2 ";
    while (one > 0) {
      cout << "1 ";
      one--;
    }
  } else {
    while (one--) cout << "1 ";
  }
  return 0;
}

```


### Prompt

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

Little Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming language. After long considerations he realized that Java is the best choice. The main argument in favor of choosing Java was that it has a very large integer data type, called BigInteger.

But having attended several classes of the club, Petya realized that not all tasks require using the BigInteger type. It turned out that in some tasks it is much easier to use small data types. That's why a question arises: "Which integer type to use if one wants to store a positive integer n?"

Petya knows only 5 integer types:

1) byte occupies 1 byte and allows you to store numbers from  - 128 to 127

2) short occupies 2 bytes and allows you to store numbers from  - 32768 to 32767

3) int occupies 4 bytes and allows you to store numbers from  - 2147483648 to 2147483647

4) long occupies 8 bytes and allows you to store numbers from  - 9223372036854775808 to 9223372036854775807

5) BigInteger can store any integer number, but at that it is not a primitive type, and operations with it are much slower.

For all the types given above the boundary values are included in the value range.

From this list, Petya wants to choose the smallest type that can store a positive integer n. Since BigInteger works much slower, Peter regards it last. Help him.

Input

The first line contains a positive number n. It consists of no more than 100 digits and doesn't contain any leading zeros. The number n can't be represented as an empty string.

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

Output

Print the first type from the list "byte, short, int, long, BigInteger", that can store the natural number n, in accordance with the data given above.

Examples

Input

127

Output

byte

Input

130

Output

short

Input

123456789101112131415161718192021222324

Output

BigInteger

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin >> s;
  if (s.size() > 19)
    cout << "BigInteger" << endl;
  else if (s.size() == 19) {
    if (s <= "9223372036854775807")
      cout << "long" << endl;
    else
      cout << "BigInteger" << endl;
  } else {
    long long n = 0;
    for (int i = 0; i < s.size(); i++) n = n * 10 + s[i] - '0';
    if (n > 2147483647)
      cout << "long" << endl;
    else if (n > 32767)
      cout << "int" << endl;
    else if (n > 127)
      cout << "short" << endl;
    else
      cout << "byte" << endl;
  }
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.

Kirill has already made his measurements, and has got the following integer values: x1, x2, ..., xn. It is important that the values are close to each other, namely, the difference between the maximum value and the minimum value is at most 2.

Anya does not want to make the measurements, however, she can't just copy the values from Kirill's work, because the error of each measurement is a random value, and this coincidence will be noted by the teacher. Anya wants to write such integer values y1, y2, ..., yn in her work, that the following conditions are met:

  * the average value of x1, x2, ..., xn is equal to the average value of y1, y2, ..., yn;
  * all Anya's measurements are in the same bounds as all Kirill's measurements, that is, the maximum value among Anya's values is not greater than the maximum value among Kirill's values, and the minimum value among Anya's values is not less than the minimum value among Kirill's values;
  * the number of equal measurements in Anya's work and Kirill's work is as small as possible among options with the previous conditions met. Formally, the teacher goes through all Anya's values one by one, if there is equal value in Kirill's work and it is not strike off yet, he strikes off this Anya's value and one of equal values in Kirill's work. The number of equal measurements is then the total number of strike off values in Anya's work.

Help Anya to write such a set of measurements that the conditions above are met.

Input

The first line contains a single integer n (1 ≤ n ≤ 100 000) — the numeber of measurements made by Kirill.

The second line contains a sequence of integers x1, x2, ..., xn ( - 100 000 ≤ xi ≤ 100 000) — the measurements made by Kirill. It is guaranteed that the difference between the maximum and minimum values among values x1, x2, ..., xn does not exceed 2.

Output

In the first line print the minimum possible number of equal measurements.

In the second line print n integers y1, y2, ..., yn — the values Anya should write. You can print the integers in arbitrary order. Keep in mind that the minimum value among Anya's values should be not less that the minimum among Kirill's values, and the maximum among Anya's values should be not greater than the maximum among Kirill's values.

If there are multiple answers, print any of them.

Examples

Input

6
-1 1 1 0 0 -1

Output

2
0 0 0 0 0 0

Input

3
100 100 101

Output

3
101 100 100

Input

7
-10 -9 -10 -8 -10 -9 -9

Output

5
-10 -10 -9 -9 -9 -9 -9

Note

In the first example Anya can write zeros as here measurements results. The average value is then equal to the average value of Kirill's values, and there are only two equal measurements.

In the second example Anya should write two values 100 and one value 101 (in any order), because it is the only possibility to make the average be the equal to the average of Kirill's values. Thus, all three measurements are equal.

In the third example the number of equal measurements is 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
static const int MAXN = 1e5 + 10;
static const int OO = 0x3fffffff;
inline int read() {
  int ret = 0, f = 1;
  char c;
  while (c = getchar(), !isdigit(c)) f = c == 45 ? -1 : 1;
  while (isdigit(c)) {
    ret = (ret << 3) + (ret << 1);
    ret += c - 48;
    c = getchar();
  }
  return f * ret;
}
map<int, int> vis;
vector<int> v;
vector<int> a;
int n;
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    int x;
    x = read();
    if (vis[x]) {
      ++vis[x];
    } else {
      vis[x] = 1;
      v.push_back(x);
    }
    a.push_back(x);
  }
  sort(v.begin(), v.end());
  if (abs(v[v.size() - 1] - v[0]) != 2) {
    printf("%d\n", a.size());
    for (int i = 0; i < a.size(); ++i) {
      printf("%d ", a[i]);
    }
  } else {
    int num1 = vis[v[0]], num2 = vis[v[0] + 1], num3 = vis[v[v.size() - 1]];
    int mi = min(num1, num3);
    int mid = num2;
    int c1 = num1 - mi, d1 = num3 - mi, e1 = num2 + mi * 2;
    int mm = mid / 2;
    int c2 = num1 + mm, d2 = num3 + mm, e2 = num2 - mm * 2;
    int ans1, ans2, ans3, nb;
    int same1 = num1 + num2 + num3 - mi * 2;
    int same2 = num1 + num2 + num3 - mm * 2;
    if (same1 > same2) {
      ans1 = c2, ans2 = d2, ans3 = e2;
      nb = same2;
    } else {
      ans1 = c1, ans2 = d1, ans3 = e1;
      nb = same1;
    }
    printf("%d\n", nb);
    for (int i = 1; i <= ans1; ++i) {
      printf("%d ", v[0]);
    }
    for (int i = 1; i <= ans2; ++i) {
      printf("%d ", v[v.size() - 1]);
    }
    for (int i = 1; i <= ans3; ++i) {
      printf("%d ", v[0] + 1);
    }
    puts("");
  }
}

```


### Prompt

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

Binary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either

* contains no nodes, or
* is composed of three disjoint sets of nodes:
- a root node.
- a binary tree called its left subtree.
- a binary tree called its right subtree.

Your task is to write a program which perform tree walks (systematically traverse all nodes in a tree) based on the following algorithms:

1. Print the root, the left subtree and right subtree (preorder).
2. Print the left subtree, the root and right subtree (inorder).
3. Print the left subtree, right subtree and the root (postorder).

Here, the given binary tree consists of n nodes and evey node has a unique ID from 0 to n-1.

Constraints

* 1 ≤ n ≤ 25

Input

The first line of the input includes an integer n, the number of nodes of the tree.

In the next n linen, the information of each node is given in the following format:

id left right

id is the node ID, left is ID of the left child and right is ID of the right child. If the node does not have the left (right) child, the left(right) is indicated by -1

Output

In the 1st line, print "Preorder", and in the 2nd line print a list of node IDs obtained by the preorder tree walk.

In the 3rd line, print "Inorder", and in the 4th line print a list of node IDs obtained by the inorder tree walk.

In the 5th line, print "Postorder", and in the 6th line print a list of node IDs obtained by the postorder tree walk.

Print a space character before each node ID.

Example

Input

9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1

Output

Preorder
 0 1 2 3 4 5 6 7 8
Inorder
 2 1 3 0 6 5 7 4 8
Postorder
 2 3 1 6 7 5 8 4 0

### Response

```cpp
#include<bits/stdc++.h>
#define N 25
using namespace std;
int n,a[N],l[N],r[N];
bool used[N];

void dfs(int x,int z){
  if(z==0)cout<<' '<<x;
  if(l[x]!=-1)dfs(l[x],z);
  if(z==1)cout<<' '<<x;
  if(r[x]!=-1)dfs(r[x],z);
  if(z==2)cout<<' '<<x;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    cin>>l[a[i]]>>r[a[i]];
    if(l[a[i]]!=-1)used[l[a[i]]]=true;
    if(r[a[i]]!=-1)used[r[a[i]]]=true;
  }
  for(int i=0;i<n;i++)
    if(!used[i])cout<<"Preorder"<<endl,dfs(i,0),cout<<endl;
  for(int i=0;i<n;i++)
    if(!used[i])cout<<"Inorder"<<endl,dfs(i,1),cout<<endl;
  for(int i=0;i<n;i++)
    if(!used[i])cout<<"Postorder"<<endl,dfs(i,2),cout<<endl;
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action — multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k.

Input

The first line contains a single integer k (2 ≤ k ≤ 10) — the radix of the system.

Output

Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity).

Examples

Input

10

Output

1  2  3  4  5  6  7  8  9
2  4  6  8 10 12 14 16 18
3  6  9 12 15 18 21 24 27
4  8 12 16 20 24 28 32 36
5 10 15 20 25 30 35 40 45
6 12 18 24 30 36 42 48 54
7 14 21 28 35 42 49 56 63
8 16 24 32 40 48 56 64 72
9 18 27 36 45 54 63 72 81

Input

3

Output

1  2
2 11

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void input() {}
void base(long long int a, long long int n) {
  if (a / n > 0) cout << a / n;
  cout << a % n << " ";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  input();
  long long int n;
  cin >> n;
  long long int arr[n][n];
  for (long long int i = 1; i < n; i++) {
    for (long long int j = 1; j < n; j++) {
      base(i * j, n);
    }
    cout << "\n";
  }
}

```


### Prompt

Generate a Cpp solution to the following problem:

Warawreh created a great company called Nanosoft. The only thing that Warawreh still has to do is to place a large picture containing its logo on top of the company's building.

The logo of Nanosoft can be described as four squares of the same size merged together into one large square. The top left square is colored with red, the top right square is colored with green, the bottom left square is colored with yellow and the bottom right square is colored with blue.

An Example of some correct logos:

<image>

An Example of some incorrect logos:

<image>

Warawreh went to Adhami's store in order to buy the needed picture. Although Adhami's store is very large he has only one picture that can be described as a grid of n rows and m columns. The color of every cell in the picture will be green (the symbol 'G'), red (the symbol 'R'), yellow (the symbol 'Y') or blue (the symbol 'B').

Adhami gave Warawreh q options, in every option he gave him a sub-rectangle from that picture and told him that he can cut that sub-rectangle for him. To choose the best option, Warawreh needs to know for every option the maximum area of sub-square inside the given sub-rectangle that can be a Nanosoft logo. If there are no such sub-squares, the answer is 0.

Warawreh couldn't find the best option himself so he asked you for help, can you help him?

Input

The first line of input contains three integers n, m and q (1 ≤ n , m ≤ 500, 1 ≤ q ≤ 3 ⋅ 10^{5}) — the number of row, the number columns and the number of options.

For the next n lines, every line will contain m characters. In the i-th line the j-th character will contain the color of the cell at the i-th row and j-th column of the Adhami's picture. The color of every cell will be one of these: {'G','Y','R','B'}.

For the next q lines, the input will contain four integers r_1, c_1, r_2 and c_2 (1 ≤ r_1 ≤ r_2 ≤ n, 1 ≤ c_1 ≤ c_2 ≤ m). In that option, Adhami gave to Warawreh a sub-rectangle of the picture with the upper-left corner in the cell (r_1, c_1) and with the bottom-right corner in the cell (r_2, c_2).

Output

For every option print the maximum area of sub-square inside the given sub-rectangle, which can be a NanoSoft Logo. If there are no such sub-squares, print 0.

Examples

Input

5 5 5
RRGGB
RRGGY
YYBBG
YYBBR
RBBRG
1 1 5 5
2 2 5 5
2 2 3 3
1 1 3 5
4 4 5 5

Output

16
4
4
4
0

Input

6 10 5
RRRGGGRRGG
RRRGGGRRGG
RRRGGGYYBB
YYYBBBYYBB
YYYBBBRGRG
YYYBBBYBYB
1 1 6 10
1 3 3 10
2 2 6 6
1 7 6 10
2 1 5 10

Output

36
4
16
16
16

Input

8 8 8
RRRRGGGG
RRRRGGGG
RRRRGGGG
RRRRGGGG
YYYYBBBB
YYYYBBBB
YYYYBBBB
YYYYBBBB
1 1 8 8
5 2 5 7
3 1 8 6
2 3 5 8
1 2 6 8
2 1 5 5
2 1 7 7
6 5 7 5

Output

64
0
16
4
16
4
36
0

Note

Picture for the first test:

<image>

The pictures from the left to the right corresponds to the options. The border of the sub-rectangle in the option is marked with black, the border of the sub-square with the maximal possible size, that can be cut is marked with gray.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 510, LOG = 10;
char grid[N][N];
int val[N][N], sum[N][N][4];
int st[N][N][LOG][LOG], lg[N];
int n, q, m, r1, c1, r2, c2, nr, nc;
string S = "RGYB";
int dr[4] = {0, 0, 1, 1};
int dc[4] = {0, 1, 0, 1};
inline bool check(int r1, int c1, int r2, int c2, int k) {
  r1++, c1++, r2++, c2++;
  return ((sum[r2][c2][k] - sum[r1 - 1][c2][k] - sum[r2][c1 - 1][k] +
           sum[r1 - 1][c1 - 1][k]) == (r2 - r1 + 1) * (c2 - c1 + 1));
}
inline bool can(int r, int c, int s) {
  if (r < 0 || c < 0) return false;
  if (r + (s << 1) - 1 >= n || c + (s << 1) - 1 >= m) return false;
  for (int i = 0; i < 4; i++) {
    nr = r + dr[i] * s;
    nc = c + dc[i] * s;
    if (!check(nr, nc, nr + s - 1, nc + s - 1, i)) return false;
  }
  return true;
}
void build() {
  lg[1] = 0;
  for (int i = 2; i < N; i++) {
    lg[i] = lg[i - 1];
    if ((1 << (lg[i] + 1)) == i) lg[i]++;
  }
  for (int k = 1; k < LOG; k++) {
    for (int i = 0; i + (1 << k) <= n; i++) {
      for (int j = 0; j < m; j++) {
        st[i][j][k][0] =
            max(st[i][j][k - 1][0], st[i + (1 << (k - 1))][j][k - 1][0]);
      }
    }
  }
  for (int l = 1; l < LOG; l++) {
    for (int k = 0; k < LOG; k++) {
      for (int i = 0; i + (1 << k) <= n; i++) {
        for (int j = 0; j + (1 << l) <= m; j++) {
          st[i][j][k][l] =
              max(st[i][j][k][l - 1], st[i][j + (1 << (l - 1))][k][l - 1]);
        }
      }
    }
  }
}
int a, b;
inline int getmax(int r1, int c1, int r2, int c2) {
  if (r2 < r1 || c2 < c1 || r1 < 0 || r2 >= n || c1 < 0 || c2 >= m)
    return -1000000010;
  a = lg[(r2 - r1) + 1];
  b = lg[(c2 - c1) + 1];
  return max(max(st[r1][c1][a][b], st[r2 - (1 << a) + 1][c1][a][b]),
             max(st[r1][c2 - (1 << b) + 1][a][b],
                 st[r2 - (1 << a) + 1][c2 - (1 << b) + 1][a][b]));
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) {
    scanf(" %s", grid[i]);
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < 4; k++) {
        sum[i + 1][j + 1][k] = sum[i][j + 1][k] + sum[i + 1][j][k] -
                               sum[i][j][k] + (S[k] == grid[i][j]);
      }
    }
  }
  int low, high, mid, res;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      low = 1, high = min(min(i + 1, n - i), min(j + 1, m - j));
      while (high >= low) {
        mid = ((low + high) >> 1);
        if (can(i - mid + 1, j - mid + 1, mid))
          st[i][j][0][0] = mid, low = mid + 1;
        else
          high = mid - 1;
      }
    }
  }
  build();
  while (q--) {
    scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
    r1--, c1--, r2--, c2--;
    low = 1, high = (n >> 1), res = 0;
    while (high >= low) {
      mid = ((low + high) >> 1);
      if (getmax(r1 + mid - 1, c1 + mid - 1, r2 - mid, c2 - mid) >= mid)
        res = mid, low = mid + 1;
      else
        high = mid - 1;
    }
    printf("%d\n", res * res * 4);
  }
  return 0;
}

```


### Prompt

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

We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the path u-v.

It is expected that one of the vertices will be invaded by aliens from outer space. Snuke wants to immediately identify that vertex when the invasion happens. To do so, he has decided to install an antenna on some vertices.

First, he decides the number of antennas, K (1 ≤ K ≤ N). Then, he chooses K different vertices, x_0, x_1, ..., x_{K - 1}, on which he installs Antenna 0, 1, ..., K - 1, respectively. If Vertex v is invaded by aliens, Antenna k (0 ≤ k < K) will output the distance d(x_k, v). Based on these K outputs, Snuke will identify the vertex that is invaded. Thus, in order to identify the invaded vertex no matter which one is invaded, the following condition must hold:

* For each vertex u (0 ≤ u < N), consider the vector (d(x_0, u), ..., d(x_{K - 1}, u)). These N vectors are distinct.

Find the minumum value of K, the number of antennas, when the condition is satisfied.

Constraints

* 2 ≤ N ≤ 10^5
* 0 ≤ a_i, b_i < N
* The given graph is a tree.

Input

Input is given from Standard Input in the following format:

N
a_0 b_0
a_1 b_1
:
a_{N - 2} b_{N - 2}

Output

Print the minumum value of K, the number of antennas, when the condition is satisfied.

Examples

Input

5
0 1
0 2
0 3
3 4

Output

2

Input

2
0 1

Output

1

Input

10
2 8
6 0
4 1
7 6
2 3
8 6
6 9
2 4
5 8

Output

3

### Response

```cpp
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
vector<int> a[MAXN];
int n,root;
pair<int,int> dfs(int x,int fa){
    int res=0,rs=0;
    int flag=0;
    for(int i=0;i<a[x].size();i++){
        if(a[x][i]==fa)
            continue;
        pair<int,int> t=dfs(a[x][i],x);
        int res1=t.first;
        if(a[x].size()+(root==x)==2)
            rs=t.second;
        if(res1==0&&flag==1)
            res++;
        if(res1==0&&flag==0)
            flag=1;
        res+=res1;
    }
    return make_pair(res,max(rs,flag));
}
int main(){
    SF("%d",&n);
    int u,v;
    for(int i=1;i<n;i++){
        SF("%d%d",&u,&v);
        a[u].push_back(v);
        a[v].push_back(u);
    }
    for(int i=0;i<n;i++)
        if(a[i].size()==1){
            root=i;
            break;
        }
    pair<int,int> ans=dfs(root,-1);
    PF("%d",ans.first+ans.second);
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Given a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both `voodoo` and `melee` are unbalanced, while neither `noon` nor `a` is.

You are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s.

Constraints

* 2 ≦ |s| ≦ 10^5
* s consists of lowercase letters.

Input

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

s

Output

If there exists no unbalanced substring of s, print `-1 -1`.

If there exists an unbalanced substring of s, let one such substring be s_a s_{a+1} ... s_{b} (1 ≦ a < b ≦ |s|), and print `a b`. If there exists more than one such substring, any of them will be accepted.

Examples

Input

needed

Output

2 5

Input

atcoder

Output

-1 -1

### Response

```cpp
#include <string>
#include <iostream>
#include <cstdio>
using namespace std;
string a,b,c,d,e,f,g,h;
int main() {
cin >> f;
for(int i=0;i<f.length();i++){
if (f[i]==f[i+1]) return printf("%d %d\n",i+1,i+2), 0;
}
for (int i = 0; i + 2 < f.length(); i++) {
if(f[i]==f[i+2]) return printf("%d %d\n",i+1,i+3), 0;
}
printf("-1 -1\n");
}
```