### Prompt

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

You are given an integer sequence of length N, a_1,a_2,...,a_N.

For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.

After these operations, you select an integer X and count the number of i such that a_i=X.

Maximize this count by making optimal choices.

Constraints

* 1≤N≤10^5
* 0≤a_i<10^5 (1≤i≤N)
* a_i is an integer.

Input

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

N
a_1 a_2 .. a_N

Output

Print the maximum possible number of i such that a_i=X.

Examples

Input

7
3 1 4 1 5 9 2

Output

4

Input

10
0 1 2 3 4 5 6 7 8 9

Output

3

Input

1
99999

Output

1

### Response

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

ll N, A[100005], AI;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	cin >> N;
	for (ll i = 0; i < N; i++) {
		cin >> AI;
		for (ll j = max(AI-1, 0LL); j <= AI+1; j++) {
			A[j]++;
		}
	}

	cout << *max_element(A, A+100005) << "\n";
}
```


### Prompt

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

Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters.

Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times before he does the cut:

* Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan).
* Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen.

Find the minimum amount of money needed before cutting the bar into two parts with the same length.

Constraints

* 2 \leq N \leq 200000
* 1 \leq A_i \leq 2020202020
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 A_3 ... A_N

Output

Print an integer representing the minimum amount of money needed before cutting the bar into two parts with the same length.

Examples

Input

3
2 4 3

Output

3

Input

12
100 104 102 105 103 103 101 105 104 102 104 101

Output

0

### Response

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

int main(){
  int n;
  cin >> n;
  vector<int> an(n);
  ll tot = 0;
  for(int i=0; i<n; ++i){
    cin >> an[i];
    tot += an[i];
  }
  ll ans = tot;
  ll tot2 = 0;
  for(int i=0; i<n-1; ++i){
    tot2 += an[i];
    ans = min(ans, abs(tot -tot2*2));
  }
  cout << ans << endl;
}
```


### Prompt

Create a solution in Cpp for the following problem:

You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i and B_i. Your task is to find a path that satisfies the following conditions:

* The path traverses two or more vertices.
* The path does not traverse the same vertex more than once.
* A vertex directly connected to at least one of the endpoints of the path, is always contained in the path.

It can be proved that such a path always exists. Also, if there are more than one solution, any of them will be accepted.

Constraints

* 2 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* 1 \leq A_i < B_i \leq N
* The given graph is connected and simple (that is, for every pair of vertices, there is at most one edge that directly connects them).

Input

Input is given from Standard Input in the following format:

N M
A_1 B_1
A_2 B_2
:
A_M B_M

Output

Find one path that satisfies the conditions, and print it in the following format. In the first line, print the count of the vertices contained in the path. In the second line, print a space-separated list of the indices of the vertices, in order of appearance in the path.

Examples

Input

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

Output

4
2 3 1 4

Input

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

Output

7
1 2 3 4 5 6 7

### Response

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

vector<int> graph[100005];
bool visit[100005];

vector<int> path;
vector<int> path2;

void dfs(int t)
{
    visit[t] = true;
    path.push_back(t);
    for (int nxt : graph[t])
    {
        if (visit[nxt] == false)
        {
            dfs(nxt);
            return;
        }
    }
}

int main()
{
    cin.sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    dfs(1);
    swap(path, path2);
    dfs(1);

    printf("%zd\n", path.size() + path2.size() - 1);
    for (int i = (int)path2.size() - 1; i >= 1; i--)
    {
        printf("%d ", path2[i]);
    }
    for (int t : path) printf("%d ", t);
    printf("\n");
}

```


### Prompt

Please formulate a CPP solution to the following problem:

As meticulous Gerald sets the table and caring Alexander sends the postcards, Sergey makes snowmen. Each showman should consist of three snowballs: a big one, a medium one and a small one. Sergey's twins help him: they've already made n snowballs with radii equal to r1, r2, ..., rn. To make a snowman, one needs any three snowballs whose radii are pairwise different. For example, the balls with radii 1, 2 and 3 can be used to make a snowman but 2, 2, 3 or 2, 2, 2 cannot. Help Sergey and his twins to determine what maximum number of snowmen they can make from those snowballs.

Input

The first line contains integer n (1 ≤ n ≤ 105) — the number of snowballs. The next line contains n integers — the balls' radii r1, r2, ..., rn (1 ≤ ri ≤ 109). The balls' radii can coincide.

Output

Print on the first line a single number k — the maximum number of the snowmen. Next k lines should contain the snowmen's descriptions. The description of each snowman should consist of three space-separated numbers — the big ball's radius, the medium ball's radius and the small ball's radius. It is allowed to print the snowmen in any order. If there are several solutions, print any of them.

Examples

Input

7
1 2 3 4 5 6 7

Output

2
3 2 1
6 5 4

Input

3
2 2 3

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long i, j, k, l, m, n, t;
map<long long, long long> a;
priority_queue<pair<long long, long long> > q;
vector<vector<long long> > msd;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> t;
    a[t]++;
  }
  for (map<long long, long long>::iterator it = a.begin(); it != a.end();
       ++it) {
    q.push(make_pair(it->second, it->first));
  }
  while (q.size() >= 3) {
    vector<long long> res;
    for (i = 0; i < 3; i++) {
      res.push_back(q.top().second);
      q.pop();
    }
    msd.push_back(res);
    for (i = 0; i < 3; i++) {
      if (--a[res[i]]) q.push(make_pair(a[res[i]], res[i]));
    }
  }
  cout << msd.size() << endl;
  for (i = 0; i < msd.size(); i++) {
    sort(msd[i].begin(), msd[i].end());
    cout << msd[i][2] << " " << msd[i][1] << " " << msd[i][0] << endl;
  }
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Consider the infinite sequence s of positive integers, created by repeating the following steps:

  1. Find the lexicographically smallest triple of positive integers (a, b, c) such that
    * a ⊕ b ⊕ c = 0, where ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
    * a, b, c are not in s.
Here triple of integers (a_1, b_1, c_1) is considered to be lexicographically smaller than triple (a_2, b_2, c_2) if sequence [a_1, b_1, c_1] is lexicographically smaller than sequence [a_2, b_2, c_2].
  2. Append a, b, c to s in this order.
  3. Go back to the first step.

You have integer n. Find the n-th element of s.

You have to answer t independent test cases.

A sequence a is lexicographically smaller than a sequence b if in the first position where a and b differ, the sequence a has a smaller element than the corresponding element in b.

Input

The first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases.

Each of the next t lines contains a single integer n (1≤ n ≤ 10^{16}) — the position of the element you want to know.

Output

In each of the t lines, output the answer to the corresponding test case.

Example

Input

9
1
2
3
4
5
6
7
8
9

Output

1
2
3
4
8
12
5
10
15

Note

The first elements of s are 1, 2, 3, 4, 8, 12, 5, 10, 15, ...

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long x[4][3] = {{0, 0, 0}, {1, 2, 3}, {2, 3, 1}, {3, 1, 2}};
int main() {
  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  int t;
  cin >> t;
  while (t-- > 0) {
    long long n;
    cin >> n;
    n -= 1;
    long long m3 = n % 3;
    n /= 3;
    long long mul = 1;
    long long res = 0;
    while (n > 0) {
      n -= 1;
      long long a = n % 4;
      res += mul * x[a][m3];
      mul *= 4;
      n /= 4;
    }
    res += mul * (m3 + 1);
    cout << res << "\n";
  }
  return 0;
}

```


### Prompt

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

A group of university students wants to get to the top of a mountain to have a picnic there. For that they decided to use a cableway.

A cableway is represented by some cablecars, hanged onto some cable stations by a cable. A cable is scrolled cyclically between the first and the last cable stations (the first of them is located at the bottom of the mountain and the last one is located at the top). As the cable moves, the cablecar attached to it move as well.

The number of cablecars is divisible by three and they are painted three colors: red, green and blue, in such manner that after each red cablecar goes a green one, after each green cablecar goes a blue one and after each blue cablecar goes a red one. Each cablecar can transport no more than two people, the cablecars arrive with the periodicity of one minute (i. e. every minute) and it takes exactly 30 minutes for a cablecar to get to the top.

All students are divided into three groups: r of them like to ascend only in the red cablecars, g of them prefer only the green ones and b of them prefer only the blue ones. A student never gets on a cablecar painted a color that he doesn't like,

The first cablecar to arrive (at the moment of time 0) is painted red. Determine the least time it will take all students to ascend to the mountain top.

Input

The first line contains three integers r, g and b (0 ≤ r, g, b ≤ 100). It is guaranteed that r + g + b > 0, it means that the group consists of at least one student.

Output

Print a single number — the minimal time the students need for the whole group to ascend to the top of the mountain.

Examples

Input

1 3 2

Output

34

Input

3 2 1

Output

33

Note

Let's analyze the first sample.

At the moment of time 0 a red cablecar comes and one student from the r group get on it and ascends to the top at the moment of time 30.

At the moment of time 1 a green cablecar arrives and two students from the g group get on it; they get to the top at the moment of time 31.

At the moment of time 2 comes the blue cablecar and two students from the b group get on it. They ascend to the top at the moment of time 32.

At the moment of time 3 a red cablecar arrives but the only student who is left doesn't like red and the cablecar leaves empty.

At the moment of time 4 a green cablecar arrives and one student from the g group gets on it. He ascends to top at the moment of time 34.

Thus, all the students are on the top, overall the ascension took exactly 34 minutes.

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  int i, j, k, s[3], sum = 0;
  scanf("%d %d %d", &s[0], &s[1], &s[2]);
  k = (s[0] + 1) / 2;
  j = 0;
  for (i = 1; i < 3; i++)
    if ((s[j] + 1) / 2 <= (s[i] + 1) / 2) {
      k = (s[i] + 1) / 2;
      j = i;
    }
  sum = sum + 30 + (k - 1) * 3 + j;
  printf("%d", sum);
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.

We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Constraints

* All values in input are integers.
* 0 \leq A, B, C
* 1 \leq K \leq A + B + C \leq 2 \times 10^9

Input

Input is given from Standard Input in the following format:

A B C K

Output

Print the maximum possible sum of the numbers written on the cards chosen.

Examples

Input

2 1 1 3

Output

2

Input

1 2 3 4

Output

0

Input

2000000000 0 0 2000000000

Output

2000000000

### Response

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

signed main(){
  int A,B,C,K; cin>>A>>B>>C>>K;
  cout<<(K<=A+B ? min(A,K) : A-(K-A-B))<<endl;
}
```


### Prompt

Construct a cpp code solution to the problem outlined:

You are given an array a consisting of n integer numbers.

Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i.

You have to remove exactly one element from this array to minimize instability of the resulting (n-1)-elements array. Your task is to calculate the minimum possible instability.

Input

The first line of the input contains one integer n (2 ≤ n ≤ 10^5) — the number of elements in the array a.

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^5) — elements of the array a.

Output

Print one integer — the minimum possible instability of the array if you have to remove exactly one element from the array a.

Examples

Input

4
1 3 3 7

Output

2

Input

2
1 100000

Output

0

Note

In the first example you can remove 7 then instability of the remaining array will be 3 - 1 = 2.

In the second example you can remove either 1 or 100000 then instability of the remaining array will be 100000 - 100000 = 0 and 1 - 1 = 0 correspondingly.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int x1 = a[n - 1] - a[0];
  int y1 = a[n - 2] - a[0];
  int x2 = a[n - 1] - a[1];
  cout << min(x1, min(y1, x2));
  return 0;
}

```


### Prompt

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

Celebrating the new year, many people post videos of falling dominoes; Here's a list of them: https://www.youtube.com/results?search_query=New+Years+Dominos

User ainta, who lives in a 2D world, is going to post a video as well.

There are n dominoes on a 2D Cartesian plane. i-th domino (1 ≤ i ≤ n) can be represented as a line segment which is parallel to the y-axis and whose length is li. The lower point of the domino is on the x-axis. Let's denote the x-coordinate of the i-th domino as pi. Dominoes are placed one after another, so p1 < p2 < ... < pn - 1 < pn holds.

User ainta wants to take a video of falling dominoes. To make dominoes fall, he can push a single domino to the right. Then, the domino will fall down drawing a circle-shaped orbit until the line segment totally overlaps with the x-axis.

<image>

Also, if the s-th domino touches the t-th domino while falling down, the t-th domino will also fall down towards the right, following the same procedure above. Domino s touches domino t if and only if the segment representing s and t intersects.

<image>

See the picture above. If he pushes the leftmost domino to the right, it falls down, touching dominoes (A), (B) and (C). As a result, dominoes (A), (B), (C) will also fall towards the right. However, domino (D) won't be affected by pushing the leftmost domino, but eventually it will fall because it is touched by domino (C) for the first time.

<image>

The picture above is an example of falling dominoes. Each red circle denotes a touch of two dominoes.

User ainta has q plans of posting the video. j-th of them starts with pushing the xj-th domino, and lasts until the yj-th domino falls. But sometimes, it could be impossible to achieve such plan, so he has to lengthen some dominoes. It costs one dollar to increase the length of a single domino by 1. User ainta wants to know, for each plan, the minimum cost needed to achieve it. Plans are processed independently, i. e. if domino's length is increased in some plan, it doesn't affect its length in other plans. Set of dominos that will fall except xj-th domino and yj-th domino doesn't matter, but the initial push should be on domino xj.

Input

The first line contains an integer n (2 ≤ n ≤ 2 × 105)— the number of dominoes.

Next n lines describe the dominoes. The i-th line (1 ≤ i ≤ n) contains two space-separated integers pi, li (1 ≤ pi, li ≤ 109)— the x-coordinate and the length of the i-th domino. It is guaranteed that p1 < p2 < ... < pn - 1 < pn.

The next line contains an integer q (1 ≤ q ≤ 2 × 105) — the number of plans.

Next q lines describe the plans. The j-th line (1 ≤ j ≤ q) contains two space-separated integers xj, yj (1 ≤ xj < yj ≤ n). It means the j-th plan is, to push the xj-th domino, and shoot a video until the yj-th domino falls.

Output

For each plan, print a line containing the minimum cost needed to achieve it. If no cost is needed, print 0.

Examples

Input

6
1 5
3 3
4 4
9 2
10 1
12 1
4
1 2
2 4
2 5
2 6

Output

0
1
1
2

Note

Consider the example. The dominoes are set like the picture below.

<image>

Let's take a look at the 4th plan. To make the 6th domino fall by pushing the 2nd domino, the length of the 3rd domino (whose x-coordinate is 4) should be increased by 1, and the 5th domino (whose x-coordinate is 9) should be increased by 1 (other option is to increase 4th domino instead of 5th also by 1). Then, the dominoes will fall like in the picture below. Each cross denotes a touch between two dominoes.

<image> <image> <image> <image> <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
inline istream& operator>>(istream& fin, pair<T1, T2>& pr) {
  fin >> pr.first >> pr.second;
  return fin;
}
template <class T0, class T1, class T2>
inline istream& operator>>(istream& fin, tuple<T0, T1, T2>& t) {
  fin >> get<0>(t) >> get<1>(t) >> get<2>(t);
  return fin;
}
template <class T>
inline istream& operator>>(istream& fin, vector<T>& a) {
  if (!a.size()) {
    size_t n;
    fin >> n;
    a.resize(n);
  }
  for (auto& u : a) fin >> u;
  return fin;
}
int build_tree(const int x, const int y, const int l, const int r,
               const size_t id, vector<int>& tree, const vector<int>& leaf) {
  if (y < leaf[l] + 1 || leaf[r] < x + 1) return 0;
  int inc = 0;
  if (x < leaf[l] + 1 && leaf[r] < y + 1)
    inc = (leaf[r] - leaf[l]) - tree[id];
  else if (tree[id] != leaf[r] - leaf[l]) {
    const auto mid = (l + r) >> 1;
    inc = build_tree(x, y, l, mid, 2 * id + 1, tree, leaf) +
          build_tree(x, y, mid, r, 2 * id + 2, tree, leaf);
  }
  tree[id] += inc;
  return inc;
}
int query_tree(const int x, const int y, const int l, const int r,
               const size_t id, const vector<int>& tree,
               const vector<int>& leaf) {
  if (y < leaf[l] + 1 || leaf[r] < x + 1) return 0;
  if (x < leaf[l] + 1 && leaf[r] < y + 1) return tree[id];
  if (tree[id] == leaf[r] - leaf[l]) return min(y, leaf[r]) - max(x, leaf[l]);
  const auto mid = (l + r) >> 1;
  return query_tree(x, y, l, mid, 2 * id + 1, tree, leaf) +
         query_tree(x, y, mid, r, 2 * id + 2, tree, leaf);
}
void e500() {
  vector<pair<int, int> > a;
  vector<pair<size_t, size_t> > query;
  cin >> a >> query;
  vector<int> leaf;
  leaf.reserve(a.size());
  for (auto& pr : a) {
    leaf.push_back(pr.first);
    leaf.push_back(pr.first + pr.second);
    pr.second += pr.first;
  }
  sort(begin(leaf), end(leaf));
  leaf.erase(unique(begin(leaf), end(leaf)), end(leaf));
  ;
  vector<size_t> idx(query.size());
  iota(begin(idx), end(idx), 0);
  const auto comp = [&query](const size_t i, const size_t j) {
    return query[i] > query[j];
  };
  sort(begin(idx), end(idx), comp);
  vector<int> soln(query.size());
  vector<int> tree(leaf.size() * 4);
  auto iter = a.rbegin();
  for (const auto i : idx) {
    const auto x = a[query[i].first - 1].first;
    const auto y = a[query[i].second - 1].first;
    for (; iter != a.rend() && x < iter->first + 1; ++iter)
      build_tree(iter->first, iter->second, 0, leaf.size() - 1, 0, tree, leaf);
    soln[i] = y - x - query_tree(x, y, 0, leaf.size() - 1, 0, tree, leaf);
  }
  copy(begin(soln), end(soln), ostream_iterator<int>(cout, "\n"));
}
int main(const int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  e500();
  return EXIT_SUCCESS;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost elements from the deque (let's call them A and B, respectively), and then does the following: if A > B, he writes A to the beginning and writes B to the end of the deque, otherwise, he writes to the beginning B, and A writes to the end of the deque. We call this sequence of actions an operation.

For example, if deque was [2, 3, 4, 5, 1], on the operation he will write B=3 to the beginning and A=2 to the end, so he will get [3, 4, 5, 1, 2].

The teacher of the course, seeing Valeriy, who was passionate about his work, approached him and gave him q queries. Each query consists of the singular number m_j (j = 1, 2, …, q). It is required for each query to answer which two elements he will pull out on the m_j-th operation.

Note that the queries are independent and for each query the numbers A and B should be printed in the order in which they will be pulled out of the deque.

Deque is a data structure representing a list of elements where insertion of new elements or deletion of existing elements can be made from both sides.

Input

The first line contains two integers n and q (2 ≤ n ≤ 10^5, 0 ≤ q ≤ 3 ⋅ 10^5) — the number of elements in the deque and the number of queries. The second line contains n integers a_1, a_2, ..., a_n, where a_i (0 ≤ a_i ≤ 10^9) — the deque element in i-th position. The next q lines contain one number each, meaning m_j (1 ≤ m_j ≤ 10^{18}).

Output

For each teacher's query, output two numbers A and B — the numbers that Valeriy pulls out of the deque for the m_j-th operation.

Examples

Input

5 3
1 2 3 4 5
1
2
10

Output

1 2
2 3
5 2

Input

2 0
0 0

Output

Note

Consider all 10 steps for the first test in detail:
  1. [1, 2, 3, 4, 5] — on the first operation, A and B are 1 and 2, respectively.

So, 2 we write to the beginning of the deque, and 1 — to the end.

We get the following status of the deque: [2, 3, 4, 5, 1].

  2. [2, 3, 4, 5, 1] ⇒ A = 2, B = 3.
  3. [3, 4, 5, 1, 2]
  4. [4, 5, 1, 2, 3]
  5. [5, 1, 2, 3, 4]
  6. [5, 2, 3, 4, 1]
  7. [5, 3, 4, 1, 2]
  8. [5, 4, 1, 2, 3]
  9. [5, 1, 2, 3, 4]
  10. [5, 2, 3, 4, 1] ⇒ A = 5, B = 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, q, i;
  cin >> n >> q;
  long long a[n + 1], b[q], a1[q], b1[q], mxa[n], mx, idx, aux[n];
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < q; i++) cin >> b[i];
  mx = a[0];
  mxa[0] = mx;
  idx = 0;
  for (i = 1; i < n; i++) {
    if (a[i] > mx) {
      mx = a[i];
      idx = i;
    }
    mxa[i] = mx;
  }
  long long g, h, itr = 0;
  g = a[0];
  h = a[1];
  for (i = idx + 1; i < n; i++) {
    aux[itr] = a[i];
    itr++;
  }
  for (i = 0; i < idx; i++) {
    h = a[i + 1];
    if (h > g) {
      aux[itr] = g;
      itr++;
      g = h;
      h = a[i + 2];
    } else {
      aux[itr] = h;
      itr++;
      h = a[i + 2];
    }
  }
  for (i = 0; i < q; i++) {
    if (b[i] > idx) {
      long long temp = b[i] - idx;
      a1[i] = mx;
      b1[i] = aux[(temp - 1) % (n - 1)];
    } else {
      a1[i] = mxa[b[i] - 1];
      b1[i] = a[b[i]];
    }
  }
  for (i = 0; i < q; i++) {
    cout << a1[i] << " " << b1[i] << endl;
  }
  return 0;
}

```


### Prompt

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

Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi.

How many ways are there to choose K consecutive integers?

Constraints

* All values in input are integers.
* 1 \leq K \leq N \leq 50

Input

Input is given from Standard Input in the following format:

N K

Output

Print the answer.

Examples

Input

3 2

Output

2

Input

13 3

Output

11

### Response

```cpp
#include<stdio.h>
int main()
{
	int k,n;
	scanf("%d%d",&n,&k);
	printf("%d\n",n-k+1);
    return 0;
}
```


### Prompt

Generate a Cpp solution to the following problem:

This problem's actual name, "Lexicographically Largest Palindromic Subsequence" is too long to fit into the page headline.

You are given string s consisting of lowercase English letters only. Find its lexicographically largest palindromic subsequence.

We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk (1 ≤  p1 < p2 < ... < pk ≤  |s|) a subsequence of string s = s1s2... s|s|, where |s| is the length of string s. For example, strings "abcb", "b" and "abacaba" are subsequences of string "abacaba".

String x = x1x2... x|x| is lexicographically larger than string y = y1y2... y|y| if either |x| > |y| and x1 = y1, x2 = y2, ..., x|y| = y|y|, or there exists such number r (r < |x|, r < |y|) that x1 = y1, x2 = y2, ..., xr = yr and xr + 1 > yr + 1. Characters in the strings are compared according to their ASCII codes. For example, string "ranger" is lexicographically larger than string "racecar" and string "poster" is lexicographically larger than string "post".

String s = s1s2... s|s| is a palindrome if it matches string rev(s) = s|s|s|s| - 1... s1. In other words, a string is a palindrome if it reads the same way from left to right and from right to left. For example, palindromic strings are "racecar", "refer" and "z".

Input

The only input line contains a non-empty string s consisting of lowercase English letters only. Its length does not exceed 10.

Output

Print the lexicographically largest palindromic subsequence of string s.

Examples

Input

radar

Output

rr

Input

bowwowwow

Output

wwwww

Input

codeforces

Output

s

Input

mississipp

Output

ssss

Note

Among all distinct subsequences of string "radar" the following ones are palindromes: "a", "d", "r", "aa", "rr", "ada", "rar", "rdr", "raar" and "radar". The lexicographically largest of them is "rr".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const unsigned int m = 1e9 + 7;
inline void solve() {
  string s;
  cin >> s;
  sort(s.begin(), s.end(), greater<char>());
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == s[0]) cout << s[0];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

We have an integer sequence A, whose length is N.

Find the number of the non-empty contiguous subsequences of A whose sums are 0. Note that we are counting the ways to take out subsequences. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.

Constraints

* 1 \leq N \leq 2 \times 10^5
* -10^9 \leq A_i \leq 10^9
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Find the number of the non-empty contiguous subsequences of A whose sum is 0.

Examples

Input

6
1 3 -4 2 2 -2

Output

3

Input

7
1 -1 1 -1 1 -1 1

Output

12

Input

5
1 -2 3 -4 5

Output

0

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    map<ll, ll> p;
    p[0] = 1;
    ll sum = 0;
    ll ans = 0;
    while (n--) {
        int temp;
        cin >> temp;
        sum += temp;
        ans += p[sum];
        p[sum]++;
    }
    cout << ans << "\n";
    return 0;
}

```


### Prompt

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

Gargari is jealous that his friend Caisa won the game from the previous problem. He wants to prove that he is a genius.

He has a n × n chessboard. Each cell of the chessboard has a number written on it. Gargari wants to place two bishops on the chessboard in such a way that there is no cell that is attacked by both of them. Consider a cell with number x written on it, if this cell is attacked by one of the bishops Gargari will get x dollars for it. Tell Gargari, how to place bishops on the chessboard to get maximum amount of money.

We assume a cell is attacked by a bishop, if the cell is located on the same diagonal with the bishop (the cell, where the bishop is, also considered attacked by it).

Input

The first line contains a single integer n (2 ≤ n ≤ 2000). Each of the next n lines contains n integers aij (0 ≤ aij ≤ 109) — description of the chessboard.

Output

On the first line print the maximal number of dollars Gargari will get. On the next line print four integers: x1, y1, x2, y2 (1 ≤ x1, y1, x2, y2 ≤ n), where xi is the number of the row where the i-th bishop should be placed, yi is the number of the column where the i-th bishop should be placed. Consider rows are numbered from 1 to n from top to bottom, and columns are numbered from 1 to n from left to right.

If there are several optimal solutions, you can print any of them.

Examples

Input

4
1 1 1 1
2 1 1 0
1 1 1 0
1 0 0 1

Output

12
2 2 3 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int p[2003][2003], r[2003][2003], l[2003][2003];
int n, rgenap, cgenap, rganjil, cganjil;
long long int calc(int col, int row) {
  int mini;
  mini = min(n - col, n - row);
  long long int a = r[col + mini][row + mini];
  mini = min(col - 1, n - row);
  long long int b = l[col - mini][row + mini];
  return a + b - p[col][row];
}
int main(void) {
  scanf("%d", &n);
  for (int j = 1; j <= n; j++)
    for (int i = 1; i <= n; i++) scanf("%I64d", &p[i][j]);
  for (int j = 1; j <= n; j++)
    for (int i = 1; i <= n; i++) r[i][j] = p[i][j] + r[i - 1][j - 1];
  for (int j = 1; j <= n; j++)
    for (int i = n; i >= 1; i--) l[i][j] = p[i][j] + l[i + 1][j - 1];
  rgenap = cgenap = 1;
  rganjil = 1;
  cganjil = 2;
  for (int j = 1; j <= n; j++)
    for (int i = 1; i <= n; i++) {
      if ((i + j) % 2 == 1) {
        if (calc(i, j) > calc(cganjil, rganjil)) {
          cganjil = i;
          rganjil = j;
        }
      } else {
        if (calc(i, j) > calc(cgenap, rgenap)) {
          cgenap = i;
          rgenap = j;
        }
      }
    }
  printf("%I64d\n", calc(cganjil, rganjil) + calc(cgenap, rgenap));
  printf("%d %d %d %d\n", rganjil, cganjil, rgenap, cgenap);
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following type:

  1. +  ai — add non-negative integer ai to the multiset. Note, that she has a multiset, thus there may be many occurrences of the same integer.
  2. -  ai — delete a single occurrence of non-negative integer ai from the multiset. It's guaranteed, that there is at least one ai in the multiset.
  3. ? s — count the number of integers in the multiset (with repetitions) that match some pattern s consisting of 0 and 1. In the pattern, 0 stands for the even digits, while 1 stands for the odd. Integer x matches the pattern s, if the parity of the i-th from the right digit in decimal notation matches the i-th from the right digit of the pattern. If the pattern is shorter than this integer, it's supplemented with 0-s from the left. Similarly, if the integer is shorter than the pattern its decimal notation is supplemented with the 0-s from the left.

For example, if the pattern is s = 010, than integers 92, 2212, 50 and 414 match the pattern, while integers 3, 110, 25 and 1030 do not.

Input

The first line of the input contains an integer t (1 ≤ t ≤ 100 000) — the number of operation Sonya has to perform.

Next t lines provide the descriptions of the queries in order they appear in the input file. The i-th row starts with a character ci — the type of the corresponding operation. If ci is equal to '+' or '-' then it's followed by a space and an integer ai (0 ≤ ai < 1018) given without leading zeroes (unless it's 0). If ci equals '?' then it's followed by a space and a sequence of zeroes and onse, giving the pattern of length no more than 18.

It's guaranteed that there will be at least one query of type '?'.

It's guaranteed that any time some integer is removed from the multiset, there will be at least one occurrence of this integer in it.

Output

For each query of the third type print the number of integers matching the given pattern. Each integer is counted as many times, as it appears in the multiset at this moment of time.

Examples

Input

12
+ 1
+ 241
? 1
+ 361
- 241
? 0101
+ 101
? 101
- 101
? 101
+ 4000
? 0

Output

2
1
2
1
1

Input

4
+ 200
+ 200
- 200
? 0

Output

1

Note

Consider the integers matching the patterns from the queries of the third type. Queries are numbered in the order they appear in the input.

  1. 1 and 241.
  2. 361.
  3. 101 and 361.
  4. 361.
  5. 4000.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
map<string, int> s;
void del(long long x) {
  string cc(18, '0');
  long long tmp, cn = 0;
  while (1) {
    tmp = x % 10;
    x /= 10;
    cc[cn] = (char)(tmp % 2 + '0');
    if (x == 0) break;
    ++cn;
  }
  --s[cc];
}
void ins(long long x) {
  string cc(18, '0');
  long long tmp, cn = 0;
  while (1) {
    tmp = x % 10;
    x /= 10;
    cc[cn] = (char)(tmp % 2 + '0');
    if (x == 0) break;
    ++cn;
  }
  ++s[cc];
}
int cnt(string st) {
  string cc(18, '0');
  int cn = 0;
  for (long long i = (long long)(st.size()) - 1; i >= 0; --i) {
    cc[cn] = st[i];
    ++cn;
  }
  return s[cc];
}
int main() {
  long long n, x;
  char c[10];
  string st;
  while (cin >> n) {
    s.clear();
    for (long long i = 0; i < n; ++i) {
      scanf("%s", c);
      if (c[0] == '+') {
        scanf("%I64d", &x);
        ins(x);
      } else if (c[0] == '-') {
        scanf("%I64d", &x);
        del(x);
      } else {
        cin >> st;
        printf("%d\n", cnt(st));
      }
    }
  }
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya and his friend Vasya play an interesting game. Petya randomly chooses an integer p from the interval [pl, pr] and Vasya chooses an integer v from the interval [vl, vr] (also randomly). Both players choose their integers equiprobably. Find the probability that the interval [min(v, p), max(v, p)] contains exactly k lucky numbers.

Input

The single line contains five integers pl, pr, vl, vr and k (1 ≤ pl ≤ pr ≤ 109, 1 ≤ vl ≤ vr ≤ 109, 1 ≤ k ≤ 1000).

Output

On the single line print the result with an absolute error of no more than 10 - 9.

Examples

Input

1 10 1 10 2

Output

0.320000000000

Input

5 6 8 10 1

Output

1.000000000000

Note

Consider that [a, b] denotes an interval of integers; this interval includes the boundaries. That is, <image>

In first case there are 32 suitable pairs: (1, 7), (1, 8), (1, 9), (1, 10), (2, 7), (2, 8), (2, 9), (2, 10), (3, 7), (3, 8), (3, 9), (3, 10), (4, 7), (4, 8), (4, 9), (4, 10), (7, 1), (7, 2), (7, 3), (7, 4), (8, 1), (8, 2), (8, 3), (8, 4), (9, 1), (9, 2), (9, 3), (9, 4), (10, 1), (10, 2), (10, 3), (10, 4). Total number of possible pairs is 10·10 = 100, so answer is 32 / 100.

In second case Petya always get number less than Vasya and the only lucky 7 is between this numbers, so there will be always 1 lucky number.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
template <class T>
inline T sqr(T x) {
  return x * x;
}
vector<int> lucky;
void precalc() {
  lucky.clear();
  for (int len = 1; len <= 9; ++len) {
    for (int mask = 0; mask < (1 << len); ++mask) {
      int cur = 0;
      for (int i = 0; i < len; ++i) {
        if (mask & (1 << i))
          cur = cur * 10 + 4;
        else
          cur = cur * 10 + 7;
      }
      lucky.push_back(cur);
    }
  }
  sort((lucky).begin(), (lucky).end());
}
int l1, r1;
int l2, r2;
int n;
inline pair<int, int> intersect(pair<int, int> a, pair<int, int> b) {
  if (a.first > a.second || b.first > b.second) return pair<int, int>();
  int L = max(a.first, b.first);
  int R = min(a.second, b.second);
  return L <= R ? make_pair(L, R) : pair<int, int>();
}
int main() {
  precalc();
  cin >> l1 >> r1 >> l2 >> r2 >> n;
  double res = 0.0;
  for (int i = 0; i + n - 1 < (int)((lucky).size()); ++i) {
    int l = lucky[i];
    int r = lucky[i + n - 1];
    int left, right;
    pair<int, int> a, b;
    left = i ? max(lucky[i - 1] + 1, l1) : l1;
    right = i + n < (int)((lucky).size()) ? min(lucky[i + n] - 1, r2) : r2;
    a = make_pair(left, min(l, r1));
    b = make_pair(max(r, l2), right);
    left = max(min(l, r1) - left + 1, 0);
    right = max(right - max(r, l2) + 1, 0);
    res += left * 1ll * right;
    pair<int, int> c = intersect(a, b);
    left = i ? max(lucky[i - 1] + 1, l2) : l2;
    right = i + n < (int)((lucky).size()) ? min(lucky[i + n] - 1, r1) : r1;
    a = make_pair(left, min(l, r2));
    b = make_pair(max(r, l1), right);
    left = max(min(l, r2) - left + 1, 0);
    right = max(right - max(r, l1) + 1, 0);
    res += left * 1ll * right;
    c = intersect(c, intersect(a, b));
    if (c.first) {
      res -= c.second - c.first + 1;
    }
  }
  res /= (r1 - l1 + 1);
  res /= (r2 - l2 + 1);
  printf("%.15lf\n", res);
  return 0;
}

```


### Prompt

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

You are given a string S consisting of uppercase English letters. Find the length of the longest ACGT string that is a substring (see Notes) of S.

Here, a ACGT string is a string that contains no characters other than `A`, `C`, `G` and `T`.

Constraints

* S is a string of length between 1 and 10 (inclusive).
* Each character in S is an uppercase English letter.

Input

Input is given from Standard Input in the following format:

S

Output

Print the length of the longest ACGT string that is a substring of S.

Examples

Input

ATCODER

Output

3

Input

HATAGAYA

Output

5

Input

SHINJUKU

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int m=0,now=0;
  string s;
  cin >> s;
  for (int i=0;i < s.size();i++){
    if (s[i]!='A' && s[i]!='T' && s[i]!='G' && s[i]!='C'){
      now=0;
    }
    else{
      now++;
    }
    m=max(m,now);
  }
  cout << m << endl;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

After all the events in Orlando we all know, Sasha and Roma decided to find out who is still the team's biggest loser. Thankfully, Masha found somewhere a revolver with a rotating cylinder of n bullet slots able to contain exactly k bullets, now the boys have a chance to resolve the problem once and for all.

Sasha selects any k out of n slots he wishes and puts bullets there. Roma spins the cylinder so that every of n possible cylinder's shifts is equiprobable. Then the game starts, the players take turns, Sasha starts: he puts the gun to his head and shoots. If there was no bullet in front of the trigger, the cylinder shifts by one position and the weapon is given to Roma for make the same move. The game continues until someone is shot, the survivor is the winner.

Sasha does not want to lose, so he must choose slots for bullets in such a way as to minimize the probability of its own loss. Of all the possible variant he wants to select the lexicographically minimal one, where an empty slot is lexicographically less than a charged one.

More formally, the cylinder of n bullet slots able to contain k bullets can be represented as a string of n characters. Exactly k of them are "X" (charged slots) and the others are "." (uncharged slots).

Let us describe the process of a shot. Suppose that the trigger is in front of the first character of the string (the first slot). If a shot doesn't kill anyone and the cylinder shifts, then the string shifts left. So the first character becomes the last one, the second character becomes the first one, and so on. But the trigger doesn't move. It will be in front of the first character of the resulting string.

Among all the strings that give the minimal probability of loss, Sasha choose the lexicographically minimal one. According to this very string, he charges the gun. You have to help Sasha to charge the gun. For that, each xi query must be answered: is there a bullet in the positions xi?

Input

The first line contains three integers n, k and p (1 ≤ n ≤ 1018, 0 ≤ k ≤ n, 1 ≤ p ≤ 1000) — the number of slots in the cylinder, the number of bullets and the number of queries. Then follow p lines; they are the queries. Each line contains one integer xi (1 ≤ xi ≤ n) the number of slot to describe.

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

Output

For each query print "." if the slot should be empty and "X" if the slot should be charged.

Examples

Input

3 1 3
1
2
3

Output

..X

Input

6 3 6
1
2
3
4
5
6

Output

.X.X.X

Input

5 2 5
1
2
3
4
5

Output

...XX

Note

The lexicographical comparison of is performed by the < operator in modern programming languages. The a string is lexicographically less that the b string, if there exists such i (1 ≤ i ≤ n), that ai < bi, and for any j (1 ≤ j < i) aj = bj.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, p, d, x;
  cin >> n >> k >> d;
  p = n - k;
  for (int i = 0; i < d; i++) {
    cin >> x;
    x--;
    if (p <= k) {
      if (x % 2 == 0 && x / 2 < p) {
        cout << ".";
      } else {
        cout << "X";
      }
    } else {
      if (n % 2 == 0) {
        if ((x % 2 == 1) && (n - 1 - x) / 2 < k) {
          cout << "X";
        } else {
          cout << ".";
        }
      } else {
        if (x != n - 1) {
          if ((x % 2 == 1) && (n - 2 - x) / 2 < (k - 1)) {
            cout << "X";
          } else {
            cout << ".";
          }
        } else {
          if (k > 0)
            cout << "X";
          else
            cout << ".";
        }
      }
    }
  }
  return 0;
}

```


### Prompt

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

Takahashi is solving quizzes. He has easily solved all but the last one.

The last quiz has three choices: 1, 2, and 3.

With his supernatural power, Takahashi has found out that the choices A and B are both wrong.

Print the correct choice for this problem.

Constraints

* Each of the numbers A and B is 1, 2, or 3.
* A and B are different.

Input

Input is given from Standard Input in the following format:

A
B

Output

Print the correct choice.

Examples

Input

3
1

Output

2

Input

1
2

Output

3

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s=0,a,b;
    cin>>a>>b;
    s=a+b;
    cout<<6-s;
}

```


### Prompt

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

For a dynamic array $A = \\{a_0, a_1, ...\\}$ of integers, perform a sequence of the following operations:

* push($d$, $x$): Add element $x$ at the begining of $A$, if $d = 0$. Add element $x$ at the end of $A$, if $d = 1$.
* randomAccess($p$): Print element $a_p$.
* pop($d$): Delete the first element of $A$, if $d = 0$. Delete the last element of $A$, if $d = 1$.

$A$ is a 0-origin array and it is empty in the initial state.

Constraints

* $1 \leq q \leq 400,000$
* $0 \leq p < $ the size of $A$
* $-1,000,000,000 \leq x \leq 1,000,000,000$

Input

The input is given in the following format.

$q$
$query_1$
$query_2$
:
$query_q$

Each query $query_i$ is given by

0 $d$ $x$

or

1 $p$

or

2 $d$

where the first digits 0, 1 and 2 represent push, randomAccess and pop operations respectively.

randomAccess and pop operations will not be given for an empty array.

Output

For each randomAccess, print $a_p$ in a line.

Example

Input

11
0 0 1
0 0 2
0 1 3
1 0
1 1
1 2
2 0
2 1
0 0 4
1 0
1 1

Output

2
1
3
4
1

### Response

```cpp
#include <iostream>
#include <deque>
using namespace std;
int main(){

  int q;
  deque <int> a;
  cin>>q;

  for(int i=0;i<q;i++){
    int n,d;
    cin>>n>>d;
    if(!n){
      int x;
      cin>>x;
      if(d) a.push_back(x);
      else a.push_front(x);
    }
    else if(n==1){
      cout<<a[d]<<endl;
    }
    else {
      if(d) a.pop_back();
      else a.pop_front();
    }
  }

  return 0;

}

```


### Prompt

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

Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.

That element can store information about the matrix of integers size n × m. There are n + m inputs in that element, i.e. each row and each column can get the signal. When signal comes to the input corresponding to some row, this row cyclically shifts to the left, that is the first element of the row becomes last element, second element becomes first and so on. When signal comes to the input corresponding to some column, that column shifts cyclically to the top, that is first element of the column becomes last element, second element becomes first and so on. Rows are numbered with integers from 1 to n from top to bottom, while columns are numbered with integers from 1 to m from left to right.

Artem wants to carefully study this element before using it. For that purpose he is going to set up an experiment consisting of q turns. On each turn he either sends the signal to some input or checks what number is stored at some position of the matrix.

Artem has completed his experiment and has written down the results, but he has lost the chip! Help Artem find any initial matrix that will match the experiment results. It is guaranteed that experiment data is consistent, which means at least one valid matrix exists.

Input

The first line of the input contains three integers n, m and q (1 ≤ n, m ≤ 100, 1 ≤ q ≤ 10 000) — dimensions of the matrix and the number of turns in the experiment, respectively.

Next q lines contain turns descriptions, one per line. Each description starts with an integer ti (1 ≤ ti ≤ 3) that defines the type of the operation. For the operation of first and second type integer ri (1 ≤ ri ≤ n) or ci (1 ≤ ci ≤ m) follows, while for the operations of the third type three integers ri, ci and xi (1 ≤ ri ≤ n, 1 ≤ ci ≤ m,  - 109 ≤ xi ≤ 109) are given.

Operation of the first type (ti = 1) means that signal comes to the input corresponding to row ri, that is it will shift cyclically. Operation of the second type (ti = 2) means that column ci will shift cyclically. Finally, operation of the third type means that at this moment of time cell located in the row ri and column ci stores value xi.

Output

Print the description of any valid initial matrix as n lines containing m integers each. All output integers should not exceed 109 by their absolute value.

If there are multiple valid solutions, output any of them.

Examples

Input

2 2 6
2 1
2 2
3 1 1 1
3 2 2 2
3 1 2 8
3 2 1 8

Output

8 2
1 8

Input

3 3 2
1 2
3 2 2 5

Output

0 0 0
0 0 5
0 0 0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
int main() {
  int r, c, q, x, a, b, _c, i, j;
  cin >> r >> c >> q;
  int matrix[r + 1][c + 1];
  for (i = 1; i <= r; i++)
    for (j = 1; j <= c; j++) matrix[i][j] = 0;
  while (q--) {
    cin >> x >> a;
    if (x < 3) {
      v.push_back(make_pair(x, a));
      if (x == 1) {
        b = matrix[a][1];
        for (j = 2; j <= c; j++) matrix[a][j - 1] = matrix[a][j];
        matrix[a][c] = b;
      } else {
        b = matrix[1][a];
        for (j = 2; j <= r; j++) matrix[j - 1][a] = matrix[j][a];
        matrix[r][a] = b;
      }
    } else {
      cin >> b >> _c;
      matrix[a][b] = _c;
    }
  }
  for (i = v.size() - 1; i >= 0; i--) {
    x = v[i].second;
    if (v[i].first == 1) {
      b = matrix[x][c];
      for (j = c; j > 1; j--) matrix[x][j] = matrix[x][j - 1];
      matrix[x][1] = b;
    } else {
      b = matrix[r][x];
      for (j = r; j > 1; j--) matrix[j][x] = matrix[j - 1][x];
      matrix[1][x] = b;
    }
  }
  for (i = 1; i <= r; i++) {
    for (j = 1; j <= c; j++) cout << matrix[i][j] << " ";
    cout << endl;
  }
  return 0;
}

```


### Prompt

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

You're given a row with n chairs. We call a seating of people "maximal" if the two following conditions hold:

  1. There are no neighbors adjacent to anyone seated.
  2. It's impossible to seat one more person without violating the first rule.

The seating is given as a string consisting of zeros and ones (0 means that the corresponding seat is empty, 1 — occupied). The goal is to determine whether this seating is "maximal".

Note that the first and last seats are not adjacent (if n ≠ 2).

Input

The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of chairs.

The next line contains a string of n characters, each of them is either zero or one, describing the seating.

Output

Output "Yes" (without quotation marks) if the seating is "maximal". Otherwise print "No".

You are allowed to print letters in whatever case you'd like (uppercase or lowercase).

Examples

Input

3
101

Output

Yes

Input

4
1011

Output

No

Input

5
10001

Output

No

Note

In sample case one the given seating is maximal.

In sample case two the person at chair three has a neighbour to the right.

In sample case three it is possible to seat yet another person into chair three.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int b[100], a[1000000];
vector<int> g;
int main() {
  int n, i, k = 0, j;
  string s;
  cin >> n;
  cin >> s;
  for (i = 0; i < n; i++) {
    if ((i == 0 && i < n - 1 && s[i] == '0' && s[i + 1] == '0') ||
        (i > 0 && i < n - 1 && s[i - 1] == '0' && s[i] == '0' &&
         s[i + 1] == '0') ||
        (i > 0 && i == n - 1 && s[i - 1] == '0' && s[i] == '0') ||
        (n == 1 && s[i] == '0') ||
        (i < n - 1 && s[i] == '1' && s[i + 1] == '1')) {
      k++;
      break;
    }
  }
  if (k)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Three years have passes and nothing changed. It is still raining in London, and Mr. Black has to close all the doors in his home in order to not be flooded. Once, however, Mr. Black became so nervous that he opened one door, then another, then one more and so on until he opened all the doors in his house.

There are exactly two exits from Mr. Black's house, let's name them left and right exits. There are several doors in each of the exits, so each door in Mr. Black's house is located either in the left or in the right exit. You know where each door is located. Initially all the doors are closed. Mr. Black can exit the house if and only if all doors in at least one of the exits is open. You are given a sequence in which Mr. Black opened the doors, please find the smallest index k such that Mr. Black can exit the house after opening the first k doors.

We have to note that Mr. Black opened each door at most once, and in the end all doors became open.

Input

The first line contains integer n (2 ≤ n ≤ 200 000) — the number of doors.

The next line contains n integers: the sequence in which Mr. Black opened the doors. The i-th of these integers is equal to 0 in case the i-th opened door is located in the left exit, and it is equal to 1 in case it is in the right exit.

It is guaranteed that there is at least one door located in the left exit and there is at least one door located in the right exit.

Output

Print the smallest integer k such that after Mr. Black opened the first k doors, he was able to exit the house.

Examples

Input

5
0 0 1 0 0

Output

3

Input

4
1 0 0 1

Output

3

Note

In the first example the first two doors are from the left exit, so when Mr. Black opened both of them only, there were two more closed door in the left exit and one closed door in the right exit. So Mr. Black wasn't able to exit at that moment.

When he opened the third door, all doors from the right exit became open, so Mr. Black was able to exit the house.

In the second example when the first two doors were opened, there was open closed door in each of the exit.

With three doors opened Mr. Black was able to use the left exit.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int nsave = 0;
  int arr[n];
  while (nsave < n) {
    cin >> arr[nsave];
    nsave++;
  }
  int tmp = arr[n - 1];
  for (int i = n - 1; i >= 0; i--) {
    if (arr[i] != tmp) {
      cout << i + 1;
      exit(0);
    }
  }
  cout << n;
  return 0;
}

```


### Prompt

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

Programmers working on a large project have just received a task to write exactly m lines of code. There are n programmers working on a project, the i-th of them makes exactly ai bugs in every line of code that he writes.

Let's call a sequence of non-negative integers v1, v2, ..., vn a plan, if v1 + v2 + ... + vn = m. The programmers follow the plan like that: in the beginning the first programmer writes the first v1 lines of the given task, then the second programmer writes v2 more lines of the given task, and so on. In the end, the last programmer writes the remaining lines of the code. Let's call a plan good, if all the written lines of the task contain at most b bugs in total.

Your task is to determine how many distinct good plans are there. As the number of plans can be large, print the remainder of this number modulo given positive integer mod.

Input

The first line contains four integers n, m, b, mod (1 ≤ n, m ≤ 500, 0 ≤ b ≤ 500; 1 ≤ mod ≤ 109 + 7) — the number of programmers, the number of lines of code in the task, the maximum total number of bugs respectively and the modulo you should use when printing the answer.

The next line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 500) — the number of bugs per line for each programmer.

Output

Print a single integer — the answer to the problem modulo mod.

Examples

Input

3 3 3 100
1 1 1

Output

10

Input

3 6 5 1000000007
1 2 3

Output

0

Input

3 5 6 11
1 2 1

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, m, b, mod, ans;
long long a[510], dp[510][510];
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &b, &mod);
  for (register int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  dp[0][0] = 1;
  for (register int i = 1; i <= n; i++)
    for (register int j = 1; j <= m; j++)
      for (register int k = a[i]; k <= b; k++)
        dp[j][k] = (dp[j][k] + dp[j - 1][k - a[i]]) % mod;
  for (register int i = 0; i <= b; i++) ans = (ans + dp[m][i]) % mod;
  printf("%lld\n", ans);
  return 0;
}

```


### Prompt

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

Vasya the Great Magician and Conjurer loves all kinds of miracles and wizardry. In one wave of a magic wand he can turn an object into something else. But, as you all know, there is no better magic in the Universe than the magic of numbers. That's why Vasya adores math and spends a lot of time turning some numbers into some other ones.

This morning he has n cards with integers lined up in front of him. Each integer is not less than 1, but not greater than l. When Vasya waves his magic wand, two rightmost cards vanish from the line and a new card magically appears in their place. It contains the difference between the left and the right numbers on the two vanished cards. Vasya was very interested to know what would happen next, and so he waved with his magic wand on and on, until the table had a single card left.

Suppose that Vasya originally had the following cards: 4, 1, 1, 3 (listed from left to right). Then after the first wave the line would be: 4, 1, -2, and after the second one: 4, 3, and after the third one the table would have a single card with number 1.

Please note that in spite of the fact that initially all the numbers on the cards were not less than 1 and not greater than l, the numbers on the appearing cards can be anything, no restrictions are imposed on them.

It is now evening. Vasya is very tired and wants to return everything back, but does not remember which cards he had in the morning. He only remembers that there were n cards, they contained integers from 1 to l, and after all magical actions he was left with a single card containing number d.

Help Vasya to recover the initial set of cards with numbers.

Input

The single line contains three space-separated integers: n (2 ≤ n ≤ 100) — the initial number of cards on the table, d (|d| ≤ 104) — the number on the card that was left on the table after all the magical actions, and l (1 ≤ l ≤ 100) — the limits for the initial integers.

Output

If Vasya is mistaken, that is, if there doesn't exist a set that meets the requirements given in the statement, then print a single number -1, otherwise print the sought set containing n integers from 1 to l. Separate the integers by spaces. Print the integers in the order, in which they were written on the cards from left to right. If there are several suitable sets of numbers, you can print any of them.

Examples

Input

3 3 2

Output

2 1 2

Input

5 -4 3

Output

-1

Input

5 -4 4

Output

2 4 1 4 1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d, l;
  int ans[101];
  int s = 0;
  cin >> n >> d >> l;
  for (int i = 0; i < n; ++i) {
    ans[i] = (i & 1) ? -1 : 1;
    s += ans[i];
  }
  bool sw = false;
  while (true) {
    if (s == d) break;
    sw = false;
    if (s < d) {
      for (int i = 0; i < n; ++i) {
        if (ans[i] < l and ans[i] > 0) {
          ans[i]++;
          s++;
          sw = true;
          break;
        }
      }
    } else if (s > d) {
      for (int i = 0; i < n; ++i) {
        if (ans[i] < 0 and ans[i] > -l) {
          ans[i]--;
          s--;
          sw = true;
          break;
        }
      }
    }
    if (!sw) return cout << -1, 0;
  }
  for (int i = 0; i < n; ++i) cout << abs(ans[i]) << " ";
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Example

Input

7
>>

Output

7

### Response

```cpp
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
//struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
string s;

int main(){
  cin >> n;
  cin >> s;
  deque<int> l, r;
  rep(i, n) if (s[i] == '<') r.push_back(i);
  int res = 0;
  rep(i, n){
    if (r.size() && r[0] == i) r.pop_front();
    if (s[i] == '>'){
      if (r.empty()) chmax(res, n - i);
      else if (l.size() >= r.size()) chmax(res, n - l[r.size() - 1]);
      else chmax(res, r[l.size()] + 1);
    }
    else {
      if (l.empty()) chmax(res, i + 1);
      else if (l.size() <= r.size()) chmax(res, r[l.size() - 1] + 1);
      else chmax(res, n - l[r.size()]);
    }
    if (s[i] == '>') l.push_front(i);
  }
  cout << res << endl;
}
```


### Prompt

Please formulate a cpp solution to the following problem:

Little X has met the following problem recently.

Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234) = 1 + 2 + 3 + 4). You are to calculate <image>

Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code:

        ans = solve(l, r) % a;
        if (ans <= 0)
          ans += a;

This code will fail only on the test with <image>. You are given number a, help Little X to find a proper test for hack.

Input

The first line contains a single integer a (1 ≤ a ≤ 1018).

Output

Print two integers: l, r (1 ≤ l ≤ r < 10200) — the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.

Examples

Input

46

Output

1 10

Input

126444381000032

Output

2333333 2333333333333

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long a, mx = 1e18 + 1;
signed main() {
  cin >> a;
  long long l, r;
  l = a - mx % a * 9 % a * 9 % a, r = mx + l - 1;
  cout << l << " " << r << endl;
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and an integer $K$, find the smallest sub-array size (smallest window length) where the elements in the sub-array contains all integers in range [$1, 2, ..., K$]. If there is no such sub-array, report 0.

Constraints

* $1 \leq N \leq 10^5$
* $1 \leq K \leq 10^5$
* $1 \leq a_i \leq 10^5$

Input

The input is given in the following format.

$N$ $K$
$a_1$ $a_2$ ... $a_N$

Output

Print the smallest sub-array size in a line.

Examples

Input

6 2
4 1 2 1 3 5

Output

2

Input

6 3
4 1 2 1 3 5

Output

3

Input

3 4
1 2 3

Output

0

### Response

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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k; cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i], a[i]--;

    int res = inf;
    int l = 0, r = 0, s = 0;
    vector<int> count(k, 0);
    for (; l < n; l++) {
        while (r < n && s < k) {
            if (a[r] < k && ++count[a[r]] == 1) s++;
            r++;
        }
        if (s < k) break;
        res = min(res, r - l);
        if (a[l] < k && --count[a[l]] == 0) s--;
    }
    cout << (res <= n ? res : 0) << endl;
    return 0;
}

```


### Prompt

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

Game field is represented by a line of n square cells. In some cells there are packmen, in some cells there are asterisks and the rest of the cells are empty. Packmen eat asterisks.

Before the game starts you can choose a movement direction, left or right, for each packman. Once the game begins all the packmen simultaneously start moving according their directions. A packman can't change the given direction.

Once a packman enters a cell containing an asterisk, packman immediately eats the asterisk. Once the packman leaves the cell it becomes empty. Each packman moves at speed 1 cell per second. If a packman enters a border cell, the packman stops. Packmen do not interfere with the movement of other packmen; in one cell there can be any number of packmen moving in any directions.

Your task is to assign a direction to each packman so that they eat the maximal number of asterisks. If there are multiple ways to assign directions to eat the maximal number of asterisks, you should choose the way which minimizes the time to do that.

Input

The first line contains integer number n (2 ≤ n ≤ 1 000 000) — the number of cells in the game field.

The second line contains n characters. If the i-th character is '.', the i-th cell is empty. If the i-th character is '*', the i-th cell contains an asterisk. If the i-th character is 'P', the i-th cell contains a packman.

The field contains at least one asterisk and at least one packman.

Output

Print two integer numbers — the maximal number of asterisks packmen can eat and the minimal time to do it.

Examples

Input

6
*.P*P*

Output

3 4

Input

8
*...P..*

Output

1 3

Note

In the first example the leftmost packman should move to the right, the rightmost packman should move to the left. All the asterisks will be eaten, the last asterisk will be eaten after 4 seconds.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int n, p[1000010], sum[1000010], cnt = 0, f[1000010][2], r[1000010];
char s[1000010];
bool chk(int x) {
  f[0][0] = f[0][1] = r[0];
  for (int i = 1; i <= cnt; i++) {
    f[i][1] = max(f[i - 1][0], f[i - 1][1]) >= p[i]
                  ? r[min(n + 1, p[i] + x + 1)]
                  : max(f[i - 1][0], f[i - 1][1]);
    f[i][0] = r[0];
    if (f[i - 1][0] >= p[i] - x)
      f[i][0] = max({f[i][0], f[i - 1][0], r[p[i] + 1]});
    else
      f[i][0] = max(f[i][0], f[i - 1][0]);
    if (f[i - 1][1] >= p[i] - x)
      f[i][0] =
          max(f[i][0], r[min(n + 1, max({0, p[i - 1] + x + 1, p[i] + 1}))]);
    else
      f[i][0] = max(f[i][0], f[i - 1][1]);
  }
  return max(f[cnt][0], f[cnt][1]) == n + 1;
}
int main() {
  scanf("%d%s", &n, s + 1);
  p[0] = -inf;
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1];
    if (s[i] == 'P')
      p[++cnt] = i;
    else if (s[i] == '*')
      sum[i]++;
  }
  r[n + 1] = n + 1;
  for (int i = n; i >= 0; i--)
    if (s[i] == '*')
      r[i] = i;
    else
      r[i] = r[i + 1];
  if (cnt == 1) {
    int l = 1, r = n;
    while (s[l] != '*') l++;
    while (s[r] != '*') r--;
    pair<int, int> ans = max(make_pair(sum[p[1] - 1], l - p[1]),
                             make_pair(sum[n] - sum[p[1]], p[1] - r));
    printf("%d %d\n", ans.first, -ans.second);
    return 0;
  }
  printf("%d ", sum[n]);
  int l = 1, len = n;
  while (len) {
    int md = l + (len >> 1);
    if (!chk(md)) {
      l = md + 1;
      len = len - (len >> 1) - 1;
    } else
      len >>= 1;
  }
  printf("%d\n", l);
}

```


### Prompt

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

The Metropolis computer network consists of n servers, each has an encryption key in the range from 0 to 2^k - 1 assigned to it. Let c_i be the encryption key assigned to the i-th server. Additionally, m pairs of servers are directly connected via a data communication channel. Because of the encryption algorithms specifics, a data communication channel can only be considered safe if the two servers it connects have distinct encryption keys. The initial assignment of encryption keys is guaranteed to keep all data communication channels safe.

You have been informed that a new virus is actively spreading across the internet, and it is capable to change the encryption key of any server it infects. More specifically, the virus body contains some unknown number x in the same aforementioned range, and when server i is infected, its encryption key changes from c_i to c_i ⊕ x, where ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).

Sadly, you know neither the number x nor which servers of Metropolis are going to be infected by the dangerous virus, so you have decided to count the number of such situations in which all data communication channels remain safe. Formally speaking, you need to find the number of pairs (A, x), where A is some (possibly empty) subset of the set of servers and x is some number in the range from 0 to 2^k - 1, such that when all servers from the chosen subset A and none of the others are infected by a virus containing the number x, all data communication channels remain safe. Since this number can be quite big, you are asked to find its remainder modulo 10^9 + 7.

Input

The first line of input contains three integers n, m and k (1 ≤ n ≤ 500 000, 0 ≤ m ≤ min((n(n - 1))/(2), 500 000), 0 ≤ k ≤ 60) — the number of servers, the number of pairs of servers directly connected by a data communication channel, and the parameter k, which defines the range of possible values for encryption keys.

The next line contains n integers c_i (0 ≤ c_i ≤ 2^k - 1), the i-th of which is the encryption key used by the i-th server.

The next m lines contain two integers u_i and v_i each (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i) denoting that those servers are connected by a data communication channel. It is guaranteed that each pair of servers appears in this list at most once.

Output

The only output line should contain a single integer — the number of safe infections of some subset of servers by a virus with some parameter, modulo 10^9 + 7.

Examples

Input

4 4 2
0 1 0 1
1 2
2 3
3 4
4 1

Output

50

Input

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

Output

96

Note

Consider the first example.

Possible values for the number x contained by the virus are 0, 1, 2 and 3.

For values 0, 2 and 3 the virus can infect any subset of the set of servers, which gives us 16 pairs for each values. A virus containing the number 1 can infect either all of the servers, or none. This gives us 16 + 2 + 16 + 16 = 50 pairs in total.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10, mod = 1e9 + 7;
long long val[maxn], pw[maxn];
vector<int> adj[maxn];
inline int ad(int x, int y) { return (x + y) % mod; }
inline int mu(int x, int y) { return 1LL * x * y % mod; }
bool mark[maxn];
int Tot = 0;
void dfs(int v) {
  if (mark[v]) return;
  mark[v] = 1;
  Tot++;
  for (auto u : adj[v]) dfs(u);
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> val[i];
  pw[0] = 1;
  for (int i = 1; i < maxn; i++) pw[i] = ad(pw[i - 1], pw[i - 1]);
  vector<pair<long long, pair<int, int> > > ed;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    ed.push_back({val[u] ^ val[v], {u, v}});
  }
  sort(ed.begin(), ed.end());
  int ted = 0, ans = 0;
  for (int i = 0; i < m; i++) {
    if (!i || ed[i].first != ed[i - 1].first) {
      vector<int> seen;
      int cnt = 0;
      for (int j = i; ed[j].first == ed[i].first; j++) {
        int u = ed[j].second.first;
        int v = ed[j].second.second;
        seen.push_back(u);
        seen.push_back(v);
        adj[u].push_back(v);
        adj[v].push_back(u);
      }
      Tot = 0;
      for (auto ver : seen) {
        if (!mark[ver]) cnt++, dfs(ver);
      }
      for (auto ver : seen) mark[ver] = 0, adj[ver].clear();
      cnt += (n - Tot);
      ans = ad(ans, pw[cnt]);
      ted++;
    }
  }
  int lef = ad(pw[k], mod - ted);
  ans = ad(ans, mu(lef, pw[n]));
  cout << ans << '\n';
}

```


### Prompt

Create a solution in Cpp for the following problem:

The Little Elephant has array a, consisting of n positive integers, indexed from 1 to n. Let's denote the number with index i as ai.

The Little Elephant wants to count, how many pairs of integers l and r are there, such that 1 ≤ l < r ≤ n and sequence b = a1a2... alarar + 1... an has no more than k inversions.

An inversion in sequence b is a pair of elements of the sequence b, that change their relative order after a stable sorting of the sequence. In other words, an inversion is a pair of integers i and j, such that 1 ≤ i < j ≤ |b| and bi > bj, where |b| is the length of sequence b, and bj is its j-th element.

Help the Little Elephant and count the number of the described pairs.

Input

The first line contains two integers n and k (2 ≤ n ≤ 105, 0 ≤ k ≤ 1018) — the size of array a and the maximum allowed number of inversions respectively. The next line contains n positive integers, separated by single spaces, a1, a2, ..., an (1 ≤ ai ≤ 109) — elements of array a.

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

Output

In a single line print a single number — the answer to the problem.

Examples

Input

3 1
1 3 2

Output

3

Input

5 2
1 3 2 1 7

Output

6

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 100 + 100;
struct fenwick {
  long long tree[maxn];
  fenwick() { memset(tree, 0, sizeof tree); }
  long long C(long long i) {
    long long ret = 0;
    for (; i > 0; i -= i & (-i)) ret += tree[i];
    return ret;
  }
  long long sum(int i, int j) { return C(j) - C(i - 1); }
  void update(long long x, long long val) {
    for (; x < maxn; x += x & (-x)) tree[x] += val;
  }
};
long long n, k, ans, l, r, x, y, z, t = 1, a[maxn], b[maxn], d[maxn], m;
map<long long, long long> mp;
fenwick f, c;
bool flag;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    a[i] = d[i];
  }
  sort(d + 1, d + n + 1);
  for (int i = 1; i <= n; i++)
    if (!mp[d[i]]) mp[d[i]] = t++;
  for (int i = 1; i <= n; i++) b[i] = mp[a[i]];
  for (int i = 1; i <= n; i++) {
    x = f.sum(b[i] + 1, n);
    m += x;
    f.update(b[i], 1);
  }
  if (m <= k) {
    cout << (n * (n - 1)) / 2 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    x = 0;
    if (i != 1) {
      if (b[i - 1] != 1) m += f.sum(1, b[i - 1] - 1);
      m += c.sum(b[i - 1] + 1, n);
      c.update(b[i - 1], 1);
    }
    while (m > k) {
      x = 0;
      if (r == n) {
        flag = 1;
        break;
      }
      if (b[r + 1] != 1) m -= f.sum(1, b[r + 1] - 1);
      m -= c.sum(b[r + 1] + 1, n);
      f.update(b[++r], -1);
    }
    if (flag) break;
    if (i != 1) ans += (n - r);
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

We have N logs of lengths A_1,A_2,\cdots A_N.

We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t.

Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.

Constraints

* 1 \leq N \leq 2 \times 10^5
* 0 \leq K \leq 10^9
* 1 \leq A_i \leq 10^9
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \cdots A_N

Output

Print an integer representing the answer.

Examples

Input

2 3
7 9

Output

4

Input

3 0
3 4 5

Output

5

Input

10 10
158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202

Output

292638192

### Response

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

using namespace std;
using ll = long long;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (auto &x : a) {
		cin >> x;
	}
	int L = 0, R = *max_element(a.begin(), a.end()) + 1;
	while (R - L > 1) {
		int mid = (L + R) / 2;
		ll cnt = 0;
		for (int i = 0; i < n; i++) {
			cnt += (a[i] - 1) / mid;
		}
		(cnt > k ? L : R) = mid;
	}
	cout << R << '\n';
}
```


### Prompt

Develop a solution in CPP to the problem described below:

Recently Vasya decided to improve his pistol shooting skills. Today his coach offered him the following exercise. He placed n cans in a row on a table. Cans are numbered from left to right from 1 to n. Vasya has to knock down each can exactly once to finish the exercise. He is allowed to choose the order in which he will knock the cans down.

Vasya knows that the durability of the i-th can is a_i. It means that if Vasya has already knocked x cans down and is now about to start shooting the i-th one, he will need (a_i ⋅ x + 1) shots to knock it down. You can assume that if Vasya starts shooting the i-th can, he will be shooting it until he knocks it down.

Your task is to choose such an order of shooting so that the number of shots required to knock each of the n given cans down exactly once is minimum possible.

Input

The first line of the input contains one integer n (2 ≤ n ≤ 1 000) — the number of cans.

The second line of the input contains the sequence a_1, a_2, ..., a_n (1 ≤ a_i ≤ 1 000), where a_i is the durability of the i-th can.

Output

In the first line print the minimum number of shots required to knock each of the n given cans down exactly once.

In the second line print the sequence consisting of n distinct integers from 1 to n — the order of indices of cans that minimizes the number of shots required. If there are several answers, you can print any of them.

Examples

Input

3
20 10 20

Output

43
1 3 2

Input

4
10 10 10 10

Output

64
2 1 4 3

Input

6
5 4 5 4 4 5

Output

69
6 1 3 5 2 4

Input

2
1 4

Output

3
2 1

Note

In the first example Vasya can start shooting from the first can. He knocks it down with the first shot because he haven't knocked any other cans down before. After that he has to shoot the third can. To knock it down he shoots 20 ⋅ 1 + 1 = 21 times. After that only second can remains. To knock it down Vasya shoots 10 ⋅ 2 + 1 = 21 times. So the total number of shots is 1 + 21 + 21 = 43.

In the second example the order of shooting does not matter because all cans have the same durability.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long double PI = (long double)(3.1415926535897932384626433832795);
int parity_check(int n) {
  int par = n;
  par = par ^ (par >> 1);
  par = par ^ (par >> 2);
  par = par ^ (par >> 4);
  par = par ^ (par >> 8);
  par = par ^ (par >> 16);
  if (par % 2 == 1) {
    return 1;
  } else {
    return 0;
  }
}
int lcs(string X, string Y, int m, int n) {
  int L[m + 1][n + 1];
  int i, j;
  for (i = 0; i <= m; i++) {
    for (j = 0; j <= n; j++) {
      if (i == 0 || j == 0)
        L[i][j] = 0;
      else if (X[i - 1] == Y[j - 1] && i != j)
        L[i][j] = L[i - 1][j - 1] + 1;
      else
        L[i][j] = max(L[i - 1][j], L[i][j - 1]);
    }
  }
  return L[m][n];
}
int long long gcd(int long long a, int long long b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
int long long lcm(int long long a, int long long b) {
  int long long pro = a * b;
  int long long ans = gcd(a, b);
  pro = pro / ans;
  return pro;
}
int long long fast_power(int long long a, int long long b, int long long p) {
  if (b == 0) {
    return (1 % p);
  }
  int long long t = fast_power(a, b / 2, p);
  int long long ans = (t * t) % p;
  if (b % 2) {
    ans = (ans * (a % p)) % p;
  }
  return ans;
}
bool prime_check(int long long n) {
  int long long i, j;
  if (n == 1) {
    return false;
  }
  for (i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int long long fact(int long long n, int long long mod) {
  int long long prod = 1;
  for (int long long i = 1; i <= n; i++) {
    prod = (prod * i) % mod;
  }
  return prod;
}
void mera_sieve() {
  bool prime[6000013];
  memset(prime, true, sizeof(prime));
  for (int long long p = 2; p * p <= 6000012; p++) {
    if (prime[p] == true) {
      for (int long long i = p * p; i <= 6000012; i += p) prime[i] = false;
    }
  }
  for (int long long i = 2; i <= 6000012; i++) {
    if (prime[i]) {
    }
  }
}
void solve() {
  int n;
  cin >> n;
  vector<pair<int, int>> v;
  int long long ans = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    v.push_back(make_pair(t, i + 1));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    ans += (v[n - i - 1].first * i + 1);
  }
  cout << ans << "\n";
  for (int i = n - 1; i >= 0; i--) cout << v[i].second << " ";
}
int main() {
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive).

There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them.

Since this sum can be enormous, print the value modulo (10^9+7).

Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1, ..., A_N.

Constraints

* 2 \leq N \leq 10^5
* 1 \leq K \leq 10^5
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the sum of \gcd(A_1, ..., A_N) over all K^N sequences, modulo (10^9+7).

Examples

Input

3 2

Output

9

Input

3 200

Output

10813692

Input

100000 100000

Output

742202979

### Response

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

int n,k;
long long s,s1,m=1e9+7,b[100001];

int xar(int n, int p){
    long long s;
    if ( p==1 )
        return n;

    long long l=xar(n, p/2);

    if (p%2==1)
      s=(((l*l)%m)*n)%m;
    else
      s=(l*l)%m;

    return s%m;
}

int main()
{
	ios::sync_with_stdio(0);

	cin >> n >> k;

	for (int i=k; i>=1; i--){
		int j=i+i;

		while(j<=k){
			s+=b[j];
			s%=m;
			j+=i;
		}

		b[i]=((xar(k/i, n) % m)-s)%m;
		b[i]=(b[i]+m)%m;
		s=0;
		s1=0;
	}

	for (int i=1; i<=k; i++){
		s+=(b[i]*i)%m;
		//cout << b[i] << " ";
		s%=m;
		s=(s+m)%m;
	}
	cout << s << endl;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

The official capital and the cultural capital of Berland are connected by a single road running through n regions. Each region has a unique climate, so the i-th (1 ≤ i ≤ n) region has a stable temperature of ti degrees in summer.

This summer a group of m schoolchildren wants to get from the official capital to the cultural capital to visit museums and sights. The trip organizers transport the children between the cities in buses, but sometimes it is very hot. Specifically, if the bus is driving through the i-th region and has k schoolchildren, then the temperature inside the bus is ti + k degrees.

Of course, nobody likes it when the bus is hot. So, when the bus drives through the i-th region, if it has more than Ti degrees inside, each of the schoolchild in the bus demands compensation for the uncomfortable conditions. The compensation is as large as xi rubles and it is charged in each region where the temperature in the bus exceeds the limit.

To save money, the organizers of the trip may arbitrarily add or remove extra buses in the beginning of the trip, and between regions (of course, they need at least one bus to pass any region). The organizers can also arbitrarily sort the children into buses, however, each of buses in the i-th region will cost the organizers costi rubles. Please note that sorting children into buses takes no money.

Your task is to find the minimum number of rubles, which the organizers will have to spend to transport all schoolchildren.

Input

The first input line contains two integers n and m (1 ≤ n ≤ 105; 1 ≤ m ≤ 106) — the number of regions on the way and the number of schoolchildren in the group, correspondingly. Next n lines contain four integers each: the i-th line contains ti, Ti, xi and costi (1 ≤ ti, Ti, xi, costi ≤ 106). The numbers in the lines are separated by single spaces.

Output

Print the only integer — the minimum number of roubles the organizers will have to spend to transport all schoolchildren.

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

Examples

Input

2 10
30 35 1 100
20 35 10 10

Output

120

Input

3 100
10 30 1000 1
5 10 1000 3
10 40 1000 100000

Output

200065

Note

In the first sample the organizers will use only one bus to travel through the first region. However, the temperature in the bus will equal 30 + 10 = 40 degrees and each of 10 schoolchildren will ask for compensation. Only one bus will transport the group through the second region too, but the temperature inside won't exceed the limit. Overall, the organizers will spend 100 + 10 + 10 = 120 rubles.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long long ans = 0;
  for (int i = (0); i < (n); ++i) {
    long long t, T, x, cost;
    cin >> t >> T >> x >> cost;
    if (t >= T) {
      ans += cost + m * x;
      continue;
    }
    long long aux1 = cost;
    if (m > (T - t)) aux1 += m * x;
    long long aux2 = (long long)ceil((double)(m - (T - t)) / (T - t)) + 1;
    aux2 *= cost;
    ans += min(aux1, aux2);
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

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

Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the points from the second set lay at the vertexes of a rectangle. Each point of initial 8 should belong to exactly one set. It is acceptable for a rectangle from the second set was also a square. If there are several partitions, Petya will be satisfied by any of them. Help him find such partition. Note that the rectangle and the square from the partition should have non-zero areas. The sides of the figures do not have to be parallel to the coordinate axes, though it might be the case.

Input

You are given 8 pairs of integers, a pair per line — the coordinates of the points Petya has. The absolute value of all coordinates does not exceed 104. It is guaranteed that no two points coincide.

Output

Print in the first output line "YES" (without the quotes), if the desired partition exists. In the second line output 4 space-separated numbers — point indexes from the input, which lie at the vertexes of the square. The points are numbered starting from 1. The numbers can be printed in any order. In the third line print the indexes of points lying at the vertexes of a rectangle in the similar format. All printed numbers should be pairwise distinct.

If the required partition does not exist, the first line should contain the word "NO" (without the quotes), after which no output is needed.

Examples

Input

0 0
10 11
10 0
0 11
1 1
2 2
2 1
1 2

Output

YES
5 6 7 8
1 2 3 4

Input

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

Output

NO

Input

0 0
4 4
4 0
0 4
1 2
2 3
3 2
2 1

Output

YES
1 2 3 4
5 6 7 8

Note

Pay attention to the third example: the figures do not necessarily have to be parallel to the coordinate axes.

### Response

```cpp
#include <bits/stdc++.h>
const int MAXINT = 2147483640;
const long long MAXLL = 9223372036854775800LL;
const long long MAXN = 1e6;
const double eps = 1e-9;
const long long mod = 1e9 + 7;
using namespace std;
bool f1(vector<pair<long long, pair<long double, long double>>> v) {
  sort(v.begin(), v.end());
  do {
    long double ans1 = sqrt((v[0].second.first - v[2].second.first) *
                                (v[0].second.first - v[2].second.first) +
                            (v[0].second.second - v[2].second.second) *
                                (v[0].second.second - v[2].second.second));
    long double ans2 = sqrt((v[1].second.first - v[3].second.first) *
                                (v[1].second.first - v[3].second.first) +
                            (v[1].second.second - v[3].second.second) *
                                (v[1].second.second - v[3].second.second));
    if (abs(ans1 - ans2) <= eps) {
      long double ans3 = sqrt((v[0].second.first - v[1].second.first) *
                                  (v[0].second.first - v[1].second.first) +
                              (v[0].second.second - v[1].second.second) *
                                  (v[0].second.second - v[1].second.second));
      long double ans4 = sqrt((v[1].second.first - v[2].second.first) *
                                  (v[1].second.first - v[2].second.first) +
                              (v[1].second.second - v[2].second.second) *
                                  (v[1].second.second - v[2].second.second));
      long double ans5 = sqrt((v[2].second.first - v[3].second.first) *
                                  (v[2].second.first - v[3].second.first) +
                              (v[2].second.second - v[3].second.second) *
                                  (v[2].second.second - v[3].second.second));
      long double ans6 = sqrt((v[0].second.first - v[3].second.first) *
                                  (v[0].second.first - v[3].second.first) +
                              (v[0].second.second - v[3].second.second) *
                                  (v[0].second.second - v[3].second.second));
      if (ans3 * ans4 > 0 && abs(ans3 - ans4) <= eps &&
          abs(ans4 - ans5) <= eps && abs(ans5 - ans6) <= eps &&
          abs(ans6 - ans3) <= eps)
        return 1;
    }
  } while (next_permutation(v.begin(), v.end()));
  return 0;
}
bool f2(vector<pair<long long, pair<long double, long double>>> v) {
  sort(v.begin(), v.end());
  do {
    long double ans1 = sqrt((v[0].second.first - v[2].second.first) *
                                (v[0].second.first - v[2].second.first) +
                            (v[0].second.second - v[2].second.second) *
                                (v[0].second.second - v[2].second.second));
    long double ans2 = sqrt((v[1].second.first - v[3].second.first) *
                                (v[1].second.first - v[3].second.first) +
                            (v[1].second.second - v[3].second.second) *
                                (v[1].second.second - v[3].second.second));
    if (abs(ans1 - ans2) <= eps) {
      long double ans3 = sqrt((v[0].second.first - v[1].second.first) *
                                  (v[0].second.first - v[1].second.first) +
                              (v[0].second.second - v[1].second.second) *
                                  (v[0].second.second - v[1].second.second));
      long double ans4 = sqrt((v[1].second.first - v[2].second.first) *
                                  (v[1].second.first - v[2].second.first) +
                              (v[1].second.second - v[2].second.second) *
                                  (v[1].second.second - v[2].second.second));
      long double ans5 = sqrt((v[2].second.first - v[3].second.first) *
                                  (v[2].second.first - v[3].second.first) +
                              (v[2].second.second - v[3].second.second) *
                                  (v[2].second.second - v[3].second.second));
      long double ans6 = sqrt((v[0].second.first - v[3].second.first) *
                                  (v[0].second.first - v[3].second.first) +
                              (v[0].second.second - v[3].second.second) *
                                  (v[0].second.second - v[3].second.second));
      if (abs(ans3 - ans5) <= eps && abs(ans4 - ans6) <= eps && ans3 * ans4 > 0)
        return 1;
    }
  } while (next_permutation(v.begin(), v.end()));
  return 0;
}
long double x[MAXN], y[MAXN];
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  for (int i = 0; i < 8; ++i) {
    cin >> x[i] >> y[i];
  }
  for (int mask = 0; mask < (1ll << 8); ++mask) {
    if (__builtin_popcount(mask) == 4) {
      vector<pair<long long, pair<long double, long double>>> v1, v2;
      for (int j = 0; j < 8; ++j)
        if (((1ll << j) & mask) == 0)
          v2.push_back(make_pair(j, make_pair(x[j], y[j])));
        else
          v1.push_back(make_pair(j, make_pair(x[j], y[j])));
      if (f1(v1) && f2(v2)) {
        cout << "YES"
             << "\n";
        for (auto j : v1) cout << j.first + 1 << " ";
        cout << "\n";
        for (auto j : v2) cout << j.first + 1 << " ";
        cout << "\n";
        return 0;
      }
    }
  }
  cout << "NO"
       << "\n";
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Sherlock Holmes found a mysterious correspondence of two VIPs and made up his mind to read it. But there is a problem! The correspondence turned out to be encrypted. The detective tried really hard to decipher the correspondence, but he couldn't understand anything.

At last, after some thought, he thought of something. Let's say there is a word s, consisting of |s| lowercase Latin letters. Then for one operation you can choose a certain position p (1 ≤ p < |s|) and perform one of the following actions:

  * either replace letter sp with the one that alphabetically follows it and replace letter sp + 1 with the one that alphabetically precedes it;
  * or replace letter sp with the one that alphabetically precedes it and replace letter sp + 1 with the one that alphabetically follows it.

Let us note that letter "z" doesn't have a defined following letter and letter "a" doesn't have a defined preceding letter. That's why the corresponding changes are not acceptable. If the operation requires performing at least one unacceptable change, then such operation cannot be performed.

Two words coincide in their meaning iff one of them can be transformed into the other one as a result of zero or more operations.

Sherlock Holmes needs to learn to quickly determine the following for each word: how many words can exist that coincide in their meaning with the given word, but differs from the given word in at least one character? Count this number for him modulo 1000000007 (109 + 7).

Input

The input data contains several tests. The first line contains the only integer t (1 ≤ t ≤ 104) — the number of tests.

Next t lines contain the words, one per line. Each word consists of lowercase Latin letters and has length from 1 to 100, inclusive. Lengths of words can differ.

Output

For each word you should print the number of different other words that coincide with it in their meaning — not from the words listed in the input data, but from all possible words. As the sought number can be very large, print its value modulo 1000000007 (109 + 7).

Examples

Input

1
ab

Output

1

Input

1
aaaaaaaaaaa

Output

0

Input

2
ya
klmbfxzb

Output

24
320092793

Note

Some explanations about the operation:

  * Note that for each letter, we can clearly define the letter that follows it. Letter "b" alphabetically follows letter "a", letter "c" follows letter "b", ..., "z" follows letter "y".
  * Preceding letters are defined in the similar manner: letter "y" precedes letter "z", ..., "a" precedes letter "b".
  * Note that the operation never changes a word's length.

In the first sample you can obtain the only other word "ba". In the second sample you cannot obtain any other word, so the correct answer is 0.

Consider the third sample. One operation can transform word "klmbfxzb" into word "klmcexzb": we should choose p = 4, and replace the fourth letter with the following one ("b"  →  "c"), and the fifth one — with the preceding one ("f"  →  "e"). Also, we can obtain many other words from this one. An operation can transform word "ya" only into one other word "xb".

Word "ya" coincides in its meaning with words "xb", "wc", "vd", ..., "ay" (overall there are 24 other words). The word "klmbfxzb has many more variants — there are 3320092814 other words that coincide with in the meaning. So the answer for the first word equals 24 and for the second one equals 320092793 — the number 3320092814 modulo 109 + 7

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long dp[110][3100];
void init() {
  int i, j;
  memset(dp, 0, sizeof(dp));
  for (i = 0; i < 26; i++) dp[1][i]++;
  for (i = 2; i < 110; i++) {
    for (j = 0; j < 26; j++) {
      for (int k = j; k < 3100; k++) {
        dp[i][k] = (dp[i][k] + dp[i - 1][k - j]) % 1000000007;
      }
    }
  }
}
int main() {
  char str[110];
  int n, i;
  init();
  scanf("%d", &n);
  while (n--) {
    int sum = 0;
    scanf("%s", str);
    int len = strlen(str);
    for (i = 0; i < len; i++) sum += str[i] - 'a';
    if (dp[len][sum] == 0)
      printf("%lld\n", 1000000007 - 1);
    else
      printf("%lld\n", dp[len][sum] - 1);
  }
  return 0;
}

```