### Prompt

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

A student's life is fraught with complications. Some Berland University students know this only too well. Having studied for two years, they contracted strong antipathy towards the chairperson of some department. Indeed, the person in question wasn't the kindest of ladies to begin with: prone to reforming groups, banning automatic passes and other mean deeds. At last the students decided that she just can't get away with all this anymore...

The students pulled some strings on the higher levels and learned that the next University directors' meeting is going to discuss n orders about the chairperson and accept exactly p of them. There are two values assigned to each order: ai is the number of the chairperson's hairs that turn grey if she obeys the order and bi — the displeasement of the directors if the order isn't obeyed. The students may make the directors pass any p orders chosen by them. The students know that the chairperson will obey exactly k out of these p orders. She will pick the orders to obey in the way that minimizes first, the directors' displeasement and second, the number of hairs on her head that turn grey.

The students want to choose p orders in the way that maximizes the number of hairs on the chairperson's head that turn grey. If there are multiple ways to accept the orders, then the students are keen on maximizing the directors' displeasement with the chairperson's actions. Help them.

Input

The first line contains three integers n (1 ≤ n ≤ 105), p (1 ≤ p ≤ n), k (1 ≤ k ≤ p) — the number of orders the directors are going to discuss, the number of orders to pass and the number of orders to be obeyed by the chairperson, correspondingly. Each of the following n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109), describing the corresponding order.

Output

Print in an arbitrary order p distinct integers — the numbers of the orders to accept so that the students could carry out the revenge. The orders are indexed from 1 to n in the order they occur in the input. If there are multiple solutions, you can print any of them.

Examples

Input

5 3 2
5 6
5 8
1 3
4 3
4 11

Output

3 1 2

Input

5 3 3
10 18
18 17
10 20
20 18
20 18

Output

2 4 5

Note

In the first sample one of optimal solutions is to pass orders 1, 2, 3. In this case the chairperson obeys orders number 1 and 2. She gets 10 new grey hairs in the head and the directors' displeasement will equal 3. Note that the same result can be achieved with order 4 instead of order 3.

In the second sample, the chairperson can obey all the orders, so the best strategy for the students is to pick the orders with the maximum sum of ai values. The chairperson gets 58 new gray hairs and the directors' displeasement will equal 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Data {
  int a, b, id;
};
bool cmp1(const Data& x, const Data& y) {
  return x.b != y.b ? x.b > y.b : x.a != y.a ? x.a < y.a : x.id < y.id;
}
bool cmp2(const Data& x, const Data& y) { return x.a > y.a; }
int N, P, K;
Data data[100010];
bool use[100010];
int main() {
  scanf("%d%d%d", &N, &P, &K);
  for (int i = 0; i < N; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    data[i].a = a;
    data[i].b = b;
    data[i].id = i;
  }
  sort(data, data + N, cmp1);
  stable_sort(data, data + N - P + K, cmp2);
  for (int i = 0; i < K; i++) {
    printf("%d ", data[i].id + 1);
    use[data[i].id] = true;
  }
  sort(data, data + N, cmp1);
  int cnt = 0, t;
  for (t = 0; t < N; t++) {
    if (use[data[t].id]) cnt++;
    if (cnt == K) break;
  }
  t++;
  for (int i = 0; i < P - K; i++) printf("%d ", data[t + i].id + 1);
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

There is a square grid of size n × n. Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs max(h, w) to color a rectangle of size h × w. You are to make all cells white for minimum total cost.

Input

The first line contains a single integer n (1 ≤ n ≤ 50) — the size of the square grid.

Each of the next n lines contains a string of length n, consisting of characters '.' and '#'. The j-th character of the i-th line is '#' if the cell with coordinates (i, j) is black, otherwise it is white.

Output

Print a single integer — the minimum total cost to paint all cells in white.

Examples

Input

3
###
#.#
###

Output

3

Input

3
...
...
...

Output

0

Input

4
#...
....
....
#...

Output

2

Input

5
#...#
.#.#.
.....
.#...
#....

Output

5

Note

The examples and some of optimal solutions are shown on the pictures below.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1e9 + 7;
constexpr int INF = INT32_MAX;
constexpr int MAXN = 2e6 + 10;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
using Vec = vector<int>;
template <class T>
void Min(T &a, T &&b) {
  if (b < a) a = b;
}
template <class T>
void Max(T &a, T &&b) {
  if (b > a) a = b;
}
ll N, M, K, T;
Vec A;
string grid[MAXN];
;
ll Solution() {
  int dp[N + 2][N + 2][N + 2][N + 2];
  memset(dp, 0, sizeof dp);
  for (int i = (int)(1); i < (int)(N + 1); ++i) {
    for (int j = (int)(1); j < (int)(N + 1); ++j) {
      dp[1][1][i][j] = (grid[i - 1][j - 1] == '#');
    }
  }
  for (int h = (int)(1); h < (int)(N + 1); ++h) {
    for (int w = (int)(1); w < (int)(N + 1); ++w) {
      for (int i = (int)(1); i < (int)(N - h + 2); ++i) {
        for (int j = (int)(1); j < (int)(N - w + 2); ++j) {
          if (h == 1 && w == 1) continue;
          dp[h][w][i][j] = max(h, w);
          for (int k = (int)(0); k < (int)(h + 1); ++k) {
            Min(dp[h][w][i][j], dp[k][w][i][j] + dp[h - k][w][i + k][j]);
          }
          for (int k = (int)(0); k < (int)(w + 1); ++k) {
            Min(dp[h][w][i][j], dp[h][k][i][j] + dp[h][w - k][i][j + k]);
          }
        }
      }
    }
  }
  return dp[N][N][1][1];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  while (cin >> N) {
    for (int i = (int)(0); i < (int)(N); ++i) {
      cin >> grid[i];
    }
    cout << Solution() << '\n';
  }
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below.

Alice goes first and then they take alternating turns. In the i-th turn, the player whose turn it is selects a prime number smaller than the current number, and announces the smallest multiple of this prime number that is not smaller than the current number.

Formally, he or she selects a prime p < Xi - 1 and then finds the minimum Xi ≥ Xi - 1 such that p divides Xi. Note that if the selected prime p already divides Xi - 1, then the number does not change.

Eve has witnessed the state of the game after two turns. Given X2, help her determine what is the smallest possible starting number X0. Note that the players don't necessarily play optimally. You should consider all possible game evolutions.

Input

The input contains a single integer X2 (4 ≤ X2 ≤ 106). It is guaranteed that the integer X2 is composite, that is, is not prime.

Output

Output a single integer — the minimum possible X0.

Examples

Input

14

Output

6

Input

20

Output

15

Input

8192

Output

8191

Note

In the first test, the smallest possible starting number is X0 = 6. One possible course of the game is as follows:

  * Alice picks prime 5 and announces X1 = 10
  * Bob picks prime 7 and announces X2 = 14.

In the second case, let X0 = 15.

  * Alice picks prime 2 and announces X1 = 16
  * Bob picks prime 5 and announces X2 = 20.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x;
  cin >> x;
  vector<long long int> prime;
  long long int n = x;
  if (n % 2 == 0) {
    prime.push_back(2);
    while (n % 2 == 0) n /= 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    if (n % i == 0) {
      prime.push_back(i);
      while (n % i == 0) n = n / i;
    }
  }
  if (n > 2) prime.push_back(n);
  sort(prime.begin(), prime.end());
  long long int great = prime[prime.size() - 1];
  long long int lo = ((x / great) - 1) * great;
  long long int ans = INT_MAX;
  for (long long int i = lo + 1; i < x; i++) {
    n = i;
    vector<long long int> v;
    if (n % 2 == 0) {
      v.push_back(2);
      while (n % 2 == 0) n /= 2;
    }
    for (int j = 3; j <= sqrt(n); j = j + 2) {
      if (n % j == 0) {
        v.push_back(j);
        while (n % j == 0) n = n / j;
      }
    }
    if (n > 2) v.push_back(n);
    sort(v.begin(), v.end());
    long long int val;
    if (v[v.size() - 1] > 1) {
      if ((((i / v[v.size() - 1]) - 1) * v[v.size() - 1]) > 0)
        val = ((i / v[v.size() - 1]) - 1) * v[v.size() - 1];
      else
        val = i - 1;
      ans = min(ans, val + 1);
    }
  }
  cout << ans << endl;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones.

Alice and Bob will play a game alternating turns with Alice going first.

On a player's turn, they must choose exactly n/2 nonempty piles and independently remove a positive number of stones from each of the chosen piles. They can remove a different number of stones from the piles in a single turn. The first player unable to make a move loses (when there are less than n/2 nonempty piles).

Given the starting configuration, determine who will win the game.

Input

The first line contains one integer n (2 ≤ n ≤ 50) — the number of piles. It is guaranteed that n is an even number.

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 50) — the number of stones in the piles.

Output

Print a single string "Alice" if Alice wins; otherwise, print "Bob" (without double quotes).

Examples

Input

2
8 8

Output

Bob

Input

4
3 1 4 1

Output

Alice

Note

In the first example, each player can only remove stones from one pile (2/2=1). Alice loses, since Bob can copy whatever Alice does on the other pile, so Alice will run out of moves first.

In the second example, Alice can remove 2 stones from the first pile and 3 stones from the third pile on her first move to guarantee a win.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
int a[500010];
signed main() {
  int n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  sort(a + 1, a + n + 1);
  puts(a[1] == a[n / 2 + 1] ? "Bob" : "Alice");
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

JAG mock qualifying practice session

The ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG) has N questions in stock of questions to be asked in the mock contest, and each question is numbered with an integer from 1 to N. Difficulty evaluation and recommendation voting are conducted for each problem. Problem i has a difficulty level of di and a recommendation level of vi. The maximum difficulty level is M.

In the next contest, we plan to ask a total of M questions, one for each of the difficulty levels 1 to M. In order to improve the quality of the contest, I would like to select the questions so that the total recommendation level is maximized. However, since JAG's questioning ability is tremendous, it can be assumed that there is at least one question for each difficulty level.

Your job is to create a program that finds the maximum sum of the sums of recommendations when the questions are selected to meet the conditions.

Input

The input consists of multiple datasets. Each dataset is represented in the following format.

> N M
> d1 v1
> ...
> dN vN
>

The first line of the dataset is given an integer N, which represents the number of problem stocks, and a maximum difficulty value, M, separated by blanks. These numbers satisfy 1 ≤ M ≤ N ≤ 100. On the i-th line of the following N lines, the integers di and vi representing the difficulty level and recommendation level of problem i are given, separated by blanks. These numbers satisfy 1 ≤ di ≤ M and 0 ≤ vi ≤ 100. Also, for each 1 ≤ j ≤ M, it is guaranteed that there is at least one i such that di = j.

> The end of the input is represented by two zeros separated by a blank. Also, the number of datasets does not exceed 50.

> ### Output

For each data set, output the maximum value of the sum of the recommendation levels of the questions to be asked when one question is asked from each difficulty level on one line.

> ### Sample Input

5 3
1 1
twenty three
3 2
3 5
twenty one
4 2
1 7
twenty one
13
1 5
6 1
13
1 2
1 8
1 2
1 7
1 6
20 9
4 10
twenty four
5 3
6 6
6 3
7 4
8 10
4 6
7 5
1 8
5 7
1 5
6 6
9 9
5 8
6 7
14
6 4
7 10
3 5
19 6
4 1
6 5
5 10
1 10
3 10
4 6
twenty three
5 4
2 10
1 8
3 4
3 1
5 4
1 10
13
5 6
5 2
1 10
twenty three
0 0

There are 5 sample datasets, in order
Lines 1 to 6 are the first (N = 5, M = 3) test cases,
Lines 7 to 11 are the second (N = 4, M = 2) test case,
Lines 12-18 are the third (N = 6, M = 1) test case,
The fourth (N = 20, M = 9) test case from line 19 to line 39,
Lines 40 to 59 represent the fifth test case (N = 19, M = 6).

Output for Sample Input

9
8
8
71
51

Example

Input

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

Output

9
8
8
71
51

### Response

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

int main() {
    while(1) {
        int n, m;
        cin >> n >> m;
        if(!n and !m) return 0;
        vector<int> ans(m);
        for(int i = 0; i < n; ++i) {
            int d, x;
            cin >> d >> x;
            ans[d - 1] = max(ans[d - 1], x);
        }
        cout << accumulate(ans.begin(), ans.end(), 0LL) << endl;
    }
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Translator's note: in Russia's most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system.

The term is coming to an end and students start thinking about their grades. Today, a professor told his students that the grades for his course would be given out automatically — he would calculate the simple average (arithmetic mean) of all grades given out for lab works this term and round to the nearest integer. The rounding would be done in favour of the student — 4.5 would be rounded up to 5 (as in example 3), but 4.4 would be rounded down to 4.

This does not bode well for Vasya who didn't think those lab works would influence anything, so he may receive a grade worse than 5 (maybe even the dreaded 2). However, the professor allowed him to redo some of his works of Vasya's choosing to increase his average grade. Vasya wants to redo as as few lab works as possible in order to get 5 for the course. Of course, Vasya will get 5 for the lab works he chooses to redo.

Help Vasya — calculate the minimum amount of lab works Vasya has to redo.

Input

The first line contains a single integer n — the number of Vasya's grades (1 ≤ n ≤ 100).

The second line contains n integers from 2 to 5 — Vasya's grades for his lab works.

Output

Output a single integer — the minimum amount of lab works that Vasya has to redo. It can be shown that Vasya can always redo enough lab works to get a 5.

Examples

Input

3
4 4 4

Output

2

Input

4
5 4 5 5

Output

0

Input

4
5 3 3 5

Output

1

Note

In the first sample, it is enough to redo two lab works to make two 4s into 5s.

In the second sample, Vasya's average is already 4.75 so he doesn't have to redo anything to get a 5.

In the second sample Vasya has to redo one lab work to get rid of one of the 3s, that will make the average exactly 4.5 so the final grade would be 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int base = 31337;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;
int n;
int niz[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", niz + i);
    niz[i] *= 2;
  }
  int sum = 0;
  for (int i = 0; i < n; i++) sum += niz[i];
  if (sum >= 9 * n)
    printf("0");
  else {
    sort(niz, niz + n);
    for (int i = 0; i < n; i++) {
      sum += 10 - niz[i];
      if (sum >= 9 * n) {
        printf("%d\n", i + 1);
        break;
      }
    }
  }
  return 0;
}

```


### Prompt

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

Sergey is testing a next-generation processor. Instead of bytes the processor works with memory cells consisting of n bits. These bits are numbered from 1 to n. An integer is stored in the cell in the following way: the least significant bit is stored in the first bit of the cell, the next significant bit is stored in the second bit, and so on; the most significant bit is stored in the n-th bit.

Now Sergey wants to test the following instruction: "add 1 to the value of the cell". As a result of the instruction, the integer that is written in the cell must be increased by one; if some of the most significant bits of the resulting number do not fit into the cell, they must be discarded.

Sergey wrote certain values of the bits in the cell and is going to add one to its value. How many bits of the cell will change after the operation?

Input

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of bits in the cell.

The second line contains a string consisting of n characters — the initial state of the cell. The first character denotes the state of the first bit of the cell. The second character denotes the second least significant bit and so on. The last character denotes the state of the most significant bit.

Output

Print a single integer — the number of bits in the cell which change their state after we add 1 to the cell.

Examples

Input

4
1100

Output

3

Input

4
1111

Output

4

Note

In the first sample the cell ends up with value 0010, in the second sample — with 0000.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int i, j, n;
int main() {
  cin >> n;
  string s;
  cin >> s;
  if (s[0] == 0) {
    cout << 1;
    return 0;
  }
  long long int ones = 0;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == '1')
      ones++;
    else
      break;
  }
  if (ones == n)
    cout << n;
  else
    cout << i + 1;
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two students, then they get bored, and if one compartment contain three or four students, then the compartment has fun throughout the entire trip.

The students want to swap with other people, so that no compartment with students had bored students. To swap places with another person, you need to convince him that it is really necessary. The students can not independently find the necessary arguments, so they asked a sympathetic conductor for help. The conductor can use her life experience to persuade any passenger to switch places with some student.

However, the conductor does not want to waste time persuading the wrong people, so she wants to know what is the minimum number of people necessary to persuade her to change places with the students. Your task is to find the number.

After all the swaps each compartment should either have no student left, or have a company of three or four students.

Input

The first line contains integer n (1 ≤ n ≤ 106) — the number of compartments in the carriage. The second line contains n integers a1, a2, ..., an showing how many students ride in each compartment (0 ≤ ai ≤ 4). It is guaranteed that at least one student is riding in the train.

Output

If no sequence of swapping seats with other people leads to the desired result, print number "-1" (without the quotes). In another case, print the smallest number of people you need to persuade to swap places.

Examples

Input

5
1 2 2 4 3

Output

2

Input

3
4 1 1

Output

2

Input

4
0 3 0 4

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, x, k, z, tot, res;
int d[10];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> x, tot += x, d[x]++;
  if (tot < 6 && tot != 4 && tot != 3) {
    cout << -1 << endl;
    exit(0);
  }
  if (d[2] > d[1])
    k = 2;
  else
    k = 1;
  z = d[3 - k];
  res += z, d[k] -= z;
  d[3] += z;
  res += d[k] / 3 * 2, d[3] += d[k] / 3 * k, d[k] %= 3;
  if (d[k] == 1 && d[k + 2])
    ++res;
  else if (d[k])
    res += 2;
  cout << res << endl;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The last one to be pointed at by the leader is eliminated, and the next player after him becomes the new leader.

For example, if there are children with numbers [8, 10, 13, 14, 16] currently in the circle, the leader is child 13 and ai = 12, then counting-out rhyme ends on child 16, who is eliminated. Child 8 becomes the leader.

You have to write a program which prints the number of the child to be eliminated on every step.

Input

The first line contains two integer numbers n and k (2 ≤ n ≤ 100, 1 ≤ k ≤ n - 1).

The next line contains k integer numbers a1, a2, ..., ak (1 ≤ ai ≤ 109).

Output

Print k numbers, the i-th one corresponds to the number of child to be eliminated at the i-th step.

Examples

Input

7 5
10 4 11 4 1

Output

4 2 5 6 1

Input

3 2
2 5

Output

3 2

Note

Let's consider first example:

  * In the first step child 4 is eliminated, child 5 becomes the leader.
  * In the second step child 2 is eliminated, child 3 becomes the leader.
  * In the third step child 5 is eliminated, child 6 becomes the leader.
  * In the fourth step child 6 is eliminated, child 7 becomes the leader.
  * In the final step child 1 is eliminated, child 3 becomes the leader.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, n, t, k;
  cin >> n >> k;
  long long int a[k + 1];
  for (i = 0; i < k; i++) {
    cin >> a[i];
  }
  vector<long long int> v;
  for (i = 1; i <= n; i++) {
    v.push_back(i);
  }
  long long int leader = 0;
  for (i = 0; i < k; i++) {
    leader = (leader + a[i]) % n;
    cout << v[leader] << " ";
    v.erase(v.begin() + leader);
    n--;
  }
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Arcady is a copywriter. His today's task is to type up an already well-designed story using his favorite text editor.

Arcady types words, punctuation signs and spaces one after another. Each letter and each sign (including line feed) requires one keyboard click in order to be printed. Moreover, when Arcady has a non-empty prefix of some word on the screen, the editor proposes a possible autocompletion for this word, more precisely one of the already printed words such that its prefix matches the currently printed prefix if this word is unique. For example, if Arcady has already printed «codeforces», «coding» and «codeforces» once again, then there will be no autocompletion attempt for «cod», but if he proceeds with «code», the editor will propose «codeforces».

With a single click Arcady can follow the editor's proposal, i.e. to transform the current prefix to it. Note that no additional symbols are printed after the autocompletion (no spaces, line feeds, etc). What is the minimum number of keyboard clicks Arcady has to perform to print the entire text, if he is not allowed to move the cursor or erase the already printed symbols?

A word here is a contiguous sequence of latin letters bordered by spaces, punctuation signs and line/text beginnings/ends. Arcady uses only lowercase letters. For example, there are 20 words in «it's well-known that tic-tac-toe is a paper-and-pencil game for two players, x and o.».

Input

The only line contains Arcady's text, consisting only of lowercase latin letters, spaces, line feeds and the following punctuation signs: «.», «,», «?», «!», «'» and «-». The total amount of symbols doesn't exceed 3·105. It's guaranteed that all lines are non-empty.

Output

Print a single integer — the minimum number of clicks.

Examples

Input

snow affects sports such as skiing, snowboarding, and snowmachine travel.
snowboarding is a recreational activity and olympic and paralympic sport.

Output

141

Input

'co-co-co, codeforces?!'

Output

25

Input

thun-thun-thunder, thunder, thunder
thunder, thun-, thunder
thun-thun-thunder, thunder
thunder, feel the thunder
lightning then the thunder
thunder, feel the thunder
lightning then the thunder
thunder, thunder

Output

183

Note

In sample case one it's optimal to use autocompletion for the first instance of «snowboarding» after typing up «sn» and for the second instance of «snowboarding» after typing up «snowb». This will save 7 clicks.

In sample case two it doesn't matter whether to use autocompletion or not.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Node {
  int cnt;
  int next[26];
  Node() {
    cnt = 0;
    for (int i = 0; i < 26; ++i) next[i] = -1;
  }
  bool isLeaf;
};
Node nodes[1700000];
int sz = 1;
int answer = 0;
set<string> st;
void add_string(const string& s) {
  bool isNeedPlusPlus = (st.find(s) == st.end());
  if (isNeedPlusPlus) st.insert(s);
  int v = 0;
  int max_cnt = 0;
  bool ok = 0;
  for (size_t i = 0; i < s.length(); ++i) {
    char c = s[i] - 'a';
    if (nodes[v].next[c] == -1) {
      nodes[v].next[c] = sz++;
    }
    if (nodes[v].cnt == 1 && !nodes[v].isLeaf) ++max_cnt;
    if (v && isNeedPlusPlus) nodes[v].cnt++;
    v = nodes[v].next[c];
    if (nodes[v].cnt == 1 && nodes[v].isLeaf) ok = 1;
  }
  if (isNeedPlusPlus) nodes[v].cnt++;
  nodes[v].isLeaf = true;
  if (ok)
    answer += min(s.size() - max_cnt + 1, s.size());
  else
    answer += s.size();
}
int main() {
  string s;
  while (getline(cin, s)) {
    vector<string> v;
    string cur = "";
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] >= 'a' && s[i] <= 'z')
        cur += s[i];
      else {
        if (cur != "") v.push_back(cur);
        v.push_back(string(1, s[i]));
        cur = "";
      }
    }
    if (cur != "") v.push_back(cur);
    for (int i = 0; i < v.size(); ++i) {
      if (v[i][0] < 'a' || v[i][0] > 'z') {
        answer++;
        continue;
      } else {
        add_string(v[i]);
      }
    }
    ++answer;
  }
  cout << answer;
  return 0;
}

```


### Prompt

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

There are N pinholes on the xy-plane. The i-th pinhole is located at (x_i,y_i).

We will denote the Manhattan distance between the i-th and j-th pinholes as d(i,j)(=|x_i-x_j|+|y_i-y_j|).

You have a peculiar pair of compasses, called Manhattan Compass. This instrument always points at two of the pinholes. The two legs of the compass are indistinguishable, thus we do not distinguish the following two states: the state where the compass points at the p-th and q-th pinholes, and the state where it points at the q-th and p-th pinholes.

When the compass points at the p-th and q-th pinholes and d(p,q)=d(p,r), one of the legs can be moved so that the compass will point at the p-th and r-th pinholes.

Initially, the compass points at the a-th and b-th pinholes. Find the number of the pairs of pinholes that can be pointed by the compass.

Constraints

* 2≦N≦10^5
* 1≦x_i, y_i≦10^9
* 1≦a < b≦N
* When i ≠ j, (x_i, y_i) ≠ (x_j, y_j)
* x_i and y_i are integers.

Input

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

N a b
x_1 y_1
:
x_N y_N

Output

Print the number of the pairs of pinholes that can be pointed by the compass.

Examples

Input

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

Output

4

Input

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

Output

4

Input

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

Output

7

### Response

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

const int maxn=1e5+10;

int n,A,B,D,cnt[maxn],f[maxn];
LL sz[maxn];

struct Point{
	int x,y,id;
	Point() {}
	Point(int x,int y,int id):x(x),y(y),id(id) {}
	bool operator < (const Point &p) const {return x==p.x?y<p.y:x<p.x;}
	bool operator <= (const Point &p) const {return x==p.x?y<=p.y:x<p.x;}
	bool operator == (const Point &p) const {return x==p.x&&y==p.y;}
}P[maxn];

int find(int x) {return x==f[x]?x:f[x]=find(f[x]);}

void Union(int x,int y,int times)
{
	x=find(x); y=find(y);
	if (x==y) {sz[x]+=times; return;}
	sz[x]+=times+sz[y];
	sz[y]=0; f[y]=x;
}

void solve(int flag)
{
	int i,L=1,R=0;
	memset(cnt,0,sizeof(cnt));
	for (i=1;i<=n;i++)
	{
		while (L<=n&&P[L]<Point(P[i].x-D,P[i].y-D+flag,0)) L++;
		while (R<n&&P[R+1]<=Point(P[i].x-D,P[i].y+D-flag,0)) R++;
		if (L<=R) Union(P[i].id,P[L].id,1),cnt[L]++,cnt[R]--;
	}
	for (i=1;i<n;i++)
		if (cnt[i]+=cnt[i-1]) Union(P[i].id,P[i+1].id,cnt[i]);
}

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i;
	scanf("%d%d%d",&n,&A,&B);
	for (i=1;i<=n;i++)
	{
		scanf("%d%d",&P[i].x,&P[i].y);
		P[i]=Point(P[i].x-P[i].y,P[i].x+P[i].y,i);
	}
	D=max(abs(P[A].x-P[B].x),abs(P[A].y-P[B].y));
	for (i=1;i<=n;i++) f[i]=i,sz[i]=0;
	sort(P+1,P+n+1);
	solve(0);
	for (i=1;i<=n;i++)
		swap(P[i].x,P[i].y);
	sort(P+1,P+n+1);
	solve(1);
	printf("%lld\n",sz[find(A)]);
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Niwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he collected a lot of soft toys of her and spread them on the floor.

Niwango-kun has N black rare soft toys of Niconico TV-chan and they are spread together with ordinary ones. He wanted these black rare soft toys to be close together, so he decided to rearrange them.

In an infinitely large two-dimensional plane, every lattice point has a soft toy on it. The coordinates (x_i,y_i) of N black rare soft toys are given. All soft toys are considered to be points (without a length, area, or volume).

He may perform the following operation arbitrarily many times:

* Put an axis-aligned square with side length D, rotate the square by 90 degrees with four soft toys on the four corners of the square. More specifically, if the left bottom corner's coordinate is (x, y), rotate four points (x,y) \rightarrow (x+D,y) \rightarrow (x+D,y+D) \rightarrow (x,y+D) \rightarrow (x,y) in this order. Each of the four corners of the square must be on a lattice point.

Let's define the scatteredness of an arrangement by the minimum side length of an axis-aligned square enclosing all black rare soft toys. Black rare soft toys on the edges or the vertices of a square are considered to be enclosed by the square.

Find the minimum scatteredness after he performs arbitrarily many operations.

Constraints

* 2 \leq N \leq 10^5
* 1 \leq D \leq 1000
* 0 \leq x_i, y_i \leq 10^9
* Given coordinates are pairwise distinct
* All numbers given in input are integers

Input

Input is given from Standard Input in the following format:

N D
x_1 y_1
:
x_N y_N

Output

Print the answer.

Examples

Input

3 1
0 0
1 0
2 0

Output

1

Input

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

Output

4

Input

8 3
0 0
0 3
3 0
3 3
2 2
2 5
5 2
5 5

Output

4

### Response

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

int n,d,v[3000][3000],s[3][3000][3000];

int S(int x1,int y1,int x2,int y2,int t)
{
	return s[t][x2][y2]-s[t][x2][y1-1]-s[t][x1-1][y2]+s[t][x1-1][y1-1];
}

int check(int x)
{
	int r=x%d;
	for(int i=1;i<=d;i++)
		for(int j=1;j<=d;j++)
		{
			int x1=i,y1=j,x2=x1+r,y2=y1+r,x3=x1+d-1,y3=y1+d-1;
			if(!S(x1,y2+1,x3,y3,1)&&!S(x2+1,y1,x3,y3,1)&&!S(x2+1,y2+1,x3,y3,0))
				return 1;
		}
	return 0;
}
int main()
{
	scanf("%d%d",&n,&d);
	memset(v,0,sizeof v);
	for(int i=0;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x%d+1][y%d+1]++;
	}
	int Mx=0,t;
	for(int i=1;i<=d;i++)
		for(int j=1;j<=d;j++)
			v[i+d][j]=v[i][j+d]=v[i+d][j+d]=v[i][j],Mx=max(Mx,v[i][j]);
	for(t=0;(t+1)*(t+1)<Mx;t++);
	int l[3]={t*t+1,t*(t+1)+1,(int)1e9};
	for(int i=1;i<=d*2;i++)
		for(int j=1;j<=d*2;j++)
			for(int t=0;t<2;t++)
			{
				s[t][i][j]=s[t][i-1][j]+s[t][i][j-1]-s[t][i-1][j-1];
				if(l[t]<=v[i][j])
					s[t][i][j]++;
			}
	int L=t*d,R=t*d+d,ans=R,mid;
	while(L<=R)
		if(check(mid=(L+R)>>1))
			R=mid-1,ans=mid;
		else
			L=mid+1;
	cout<<ans;
	return 0;
}
```


### Prompt

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

This is the easy version of the problem. The difference between the versions is in the constraints on the array elements. You can make hacks only if all versions of the problem are solved.

You are given an array [a_1, a_2, ..., a_n].

Your goal is to find the length of the longest subarray of this array such that the most frequent value in it is not unique. In other words, you are looking for a subarray such that if the most frequent value occurs f times in this subarray, then at least 2 different values should occur exactly f times.

An array c is a subarray of an array d if c can be obtained from d by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

Input

The first line contains a single integer n (1 ≤ n ≤ 200 000) — the length of the array.

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

Output

You should output exactly one integer — the length of the longest subarray of the array whose most frequent value is not unique. If there is no such subarray, output 0.

Examples

Input

7
1 1 2 2 3 3 3

Output

6

Input

10
1 1 1 5 4 1 3 1 2 2

Output

7

Input

1
1

Output

0

Note

In the first sample, the subarray [1, 1, 2, 2, 3, 3] is good, but [1, 1, 2, 2, 3, 3, 3] isn't: in the latter there are 3 occurrences of number 3, and no other element appears 3 times.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 200005, M = 200000;
int n, a[N], cn[N], c[N], c0[N], ans, maxn, p[N << 1];
template <class I>
void Max(I& p, int q) {
  p = (p > q ? p : q);
}
void ins(int x) { --c0[c[x]], ++c[x], ++c0[c[x]], Max(maxn, c[x]); }
void del(int x) { --c0[c[x]], --c[x], ++c0[c[x]], maxn -= (c0[maxn] == 0); }
int lst[N << 1];
int mx;
int solve1() {
  int ans = 0;
  int fix = 2e5;
  for (int i = 1; i <= n; i++)
    if (i != mx && cn[i] >= 512) {
      for (int j = -n; j <= n; j++) lst[j + fix] = -1;
      lst[fix] = 0;
      int sum = 0;
      for (int j = 1; j <= n; j++) {
        sum += (a[j] == mx);
        sum -= (a[j] == i);
        if (lst[sum + fix] >= 0)
          ans = max(ans, j - lst[sum + fix]);
        else
          lst[sum + fix] = j;
      }
    }
  return ans;
}
int solve2() {
  int ans = 0;
  for (int i = 1; i <= 500; i++) {
    for (int j = 1; j <= n; j++) c[j] = c0[j] = 0;
    c0[maxn = 0] = n;
    for (int j = 1, k = 1, x = 0; j <= n; j++) {
      while (k <= n && x + (a[k] == mx) <= i) ins(a[k]), x += (a[k] == mx), ++k;
      c0[maxn] >= 2 ? Max(ans, k - j), 0 : 0, del(a[j]), x -= (a[j] == mx);
    }
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d", &a[i]), ++cn[a[i]], cn[a[i]] > cn[mx] ? mx = a[i] : 0;
  if (cn[mx] == n) return putchar('0'), 0;
  int lim = (cn[mx] < 512 ? cn[mx] : 512);
  ans = max(solve1(), solve2());
  printf("%d", ans);
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

In BerSoft n programmers work, the programmer i is characterized by a skill r_i.

A programmer a can be a mentor of a programmer b if and only if the skill of the programmer a is strictly greater than the skill of the programmer b (r_a > r_b) and programmers a and b are not in a quarrel.

You are given the skills of each programmers and a list of k pairs of the programmers, which are in a quarrel (pairs are unordered). For each programmer i, find the number of programmers, for which the programmer i can be a mentor.

Input

The first line contains two integers n and k (2 ≤ n ≤ 2 ⋅ 10^5, 0 ≤ k ≤ min(2 ⋅ 10^5, (n ⋅ (n - 1))/(2))) — total number of programmers and number of pairs of programmers which are in a quarrel.

The second line contains a sequence of integers r_1, r_2, ..., r_n (1 ≤ r_i ≤ 10^{9}), where r_i equals to the skill of the i-th programmer.

Each of the following k lines contains two distinct integers x, y (1 ≤ x, y ≤ n, x ≠ y) — pair of programmers in a quarrel. The pairs are unordered, it means that if x is in a quarrel with y then y is in a quarrel with x. Guaranteed, that for each pair (x, y) there are no other pairs (x, y) and (y, x) in the input.

Output

Print n integers, the i-th number should be equal to the number of programmers, for which the i-th programmer can be a mentor. Programmers are numbered in the same order that their skills are given in the input.

Examples

Input

4 2
10 4 10 15
1 2
4 3

Output

0 0 1 2

Input

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

Output

5 4 0 5 3 3 9 0 2 5

Note

In the first example, the first programmer can not be mentor of any other (because only the second programmer has a skill, lower than first programmer skill, but they are in a quarrel). The second programmer can not be mentor of any other programmer, because his skill is minimal among others. The third programmer can be a mentor of the second programmer. The fourth programmer can be a mentor of the first and of the second programmers. He can not be a mentor of the third programmer, because they are in a quarrel.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5;
int a[2 * MaxN + 5], ans[2 * MaxN + 5];
struct pp {
  int w;
  int id;
} b[2 * MaxN + 5];
bool cmp(pp x, pp y) { return x.w < y.w; }
int main() {
  int n, m, mi, ma, x, u, v;
  while (~scanf("%d %d", &n, &m)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      b[i].id = i;
      b[i].w = a[i];
    }
    sort(b + 1, b + 1 + n, cmp);
    for (int i = 1; i <= n; i++) {
      if (i > 1 && a[b[i].id] == a[b[i - 1].id])
        ans[b[i].id] = ans[b[i - 1].id];
      else
        ans[b[i].id] = i - 1;
    }
    for (int i = 1; i <= m; i++) {
      scanf("%d %d", &u, &v);
      if (a[u] > a[v])
        ans[u]--;
      else if (a[v] > a[u])
        ans[v]--;
    }
    for (int i = 1; i < n; i++) printf("%d ", ans[i]);
    printf("%d\n", ans[n]);
  }
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.

In Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant "n"; after this letter, there can be any letter (not only a vowel) or there can be no letter at all. For example, the words "harakiri", "yupie", "man", and "nbo" are Berlanese while the words "horse", "king", "my", and "nz" are not.

Help Vitya find out if a word s is Berlanese.

Input

The first line of the input contains the string s consisting of |s| (1≤ |s|≤ 100) lowercase Latin letters.

Output

Print "YES" (without quotes) if there is a vowel after every consonant except "n", otherwise print "NO".

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

Examples

Input

sumimasen

Output

YES

Input

ninja

Output

YES

Input

codeforces

Output

NO

Note

In the first and second samples, a vowel goes after each consonant except "n", so the word is Berlanese.

In the third sample, the consonant "c" goes after the consonant "r", and the consonant "s" stands on the end, so the word is not Berlanese.

### Response

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

```


### Prompt

Create a solution in Cpp for the following problem:

Igor the analyst has adopted n little bunnies. As we all know, bunnies love carrots. Thus, Igor has bought a carrot to be shared between his bunnies. Igor wants to treat all the bunnies equally, and thus he wants to cut the carrot into n pieces of equal area.

Formally, the carrot can be viewed as an isosceles triangle with base length equal to 1 and height equal to h. Igor wants to make n - 1 cuts parallel to the base to cut the carrot into n pieces. He wants to make sure that all n pieces have the same area. Can you help Igor determine where to cut the carrot so that each piece have equal area?

<image> Illustration to the first example.

Input

The first and only line of input contains two space-separated integers, n and h (2 ≤ n ≤ 1000, 1 ≤ h ≤ 105).

Output

The output should contain n - 1 real numbers x1, x2, ..., xn - 1. The number xi denotes that the i-th cut must be made xi units away from the apex of the carrot. In addition, 0 < x1 < x2 < ... < xn - 1 < h must hold.

Your output will be considered correct if absolute or relative error of every number in your output doesn't exceed 10 - 6.

Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if <image>.

Examples

Input

3 2

Output

1.154700538379 1.632993161855

Input

2 100000

Output

70710.678118654752

Note

Definition of isosceles triangle: <https://en.wikipedia.org/wiki/Isosceles_triangle>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const long long INFL = 1e18 + 123;
const double PI = atan2(0, -1);
int main() {
  cerr << fixed << setprecision(15);
  cout << fixed << setprecision(15);
  int n, h;
  scanf("%d%d", &n, &h);
  double s = (h * 1) / 2.0 / n;
  double cur = 1;
  vector<double> ans;
  for (int i = 0; i < n - 1; ++i) {
    double l = cur, r = 0;
    for (int j = 0; j < 100; ++j) {
      double mid = (l + r) / 2;
      if ((cur - mid) * h * (cur + mid) / 2 > s) {
        r = mid;
      } else {
        l = mid;
      }
    }
    ans.push_back(l * h);
    cur = l;
  }
  sort(begin(ans), end(ans));
  for (auto num : ans) {
    cout << num << " ";
  }
  cout << "\n";
  return 0;
}

```


### Prompt

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

Now that you have proposed a fake post for the HC2 Facebook page, Heidi wants to measure the quality of the post before actually posting it. She recently came across a (possibly fake) article about the impact of fractal structure on multimedia messages and she is now trying to measure the self-similarity of the message, which is defined as

<image>

where the sum is over all nonempty strings p and <image> is the number of occurences of p in s as a substring. (Note that the sum is infinite, but it only has a finite number of nonzero summands.)

Heidi refuses to do anything else until she knows how to calculate this self-similarity. Could you please help her? (If you would like to instead convince Heidi that a finite string cannot be a fractal anyway – do not bother, we have already tried.)

Input

The input starts with a line indicating the number of test cases T (1 ≤ T ≤ 10). After that, T test cases follow, each of which consists of one line containing a string s (1 ≤ |s| ≤ 100 000) composed of lowercase letters (a-z).

Output

Output T lines, every line containing one number – the answer to the corresponding test case.

Example

Input

4
aa
abcd
ccc
abcc

Output

5
10
14
12

Note

A string s contains another string p as a substring if p is a contiguous subsequence of s. For example, ab is a substring of cab but not of acb.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int t, Num_Edge, head[200001];
long long ret, siz[200001];
char s[200001];
struct Edge {
  int v, nxt;
} E[300001];
void Add_Edge(int u, int v) {
  E[++Num_Edge].v = v;
  E[Num_Edge].nxt = head[u];
  head[u] = Num_Edge;
}
struct SAM {
  int tot = 1, pre = 1, fa[200001], v[200001], tr[200001][51];
  void Clear() {
    tot = pre = 1;
    memset(fa, 0, sizeof(fa));
    memset(v, 0, sizeof(v));
    memset(tr, 0, sizeof(tr));
  }
  void Ins(int x) {
    int now = ++tot, t = pre;
    pre = now;
    v[now] = v[t] + 1;
    siz[now] = 1;
    while (t && !tr[t][x]) {
      tr[t][x] = now;
      t = fa[t];
    }
    if (!t)
      fa[now] = 1;
    else if (v[tr[t][x]] == v[t] + 1)
      fa[now] = tr[t][x];
    else {
      int nv = ++tot, pv = tr[t][x];
      fa[nv] = fa[pv];
      v[nv] = v[t] + 1;
      for (int i = 0; i < 26; i++) tr[nv][i] = tr[pv][i];
      while (t && tr[t][x] == pv) {
        tr[t][x] = nv;
        t = fa[t];
      }
      fa[now] = fa[pv] = nv;
    }
  }
} T;
void DFS(int x) {
  for (int i = head[x]; i; i = E[i].nxt) {
    DFS(E[i].v);
    siz[x] += siz[E[i].v];
  }
  ret += siz[x] * siz[x] * (T.v[x] - T.v[T.fa[x]]);
}
int main() {
  scanf("%d", &t);
  while (t--) {
    T.Clear();
    ret = Num_Edge = 0;
    memset(E, 0, sizeof(E));
    memset(siz, 0, sizeof(siz));
    memset(head, 0, sizeof(head));
    scanf("%s", s);
    int n = strlen(s);
    for (int i = 0; i < n; i++) T.Ins(s[i] - 'a');
    for (int i = 2; i <= T.tot; i++) Add_Edge(T.fa[i], i);
    DFS(1);
    printf("%lld\n", ret);
  }
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

You are given a sequence of positive integers x1, x2, ..., xn and two non-negative integers a and b. Your task is to transform a into b. To do that, you can perform the following moves:

  * subtract 1 from the current a;
  * subtract a mod xi (1 ≤ i ≤ n) from the current a.

Operation a mod xi means taking the remainder after division of number a by number xi.

Now you want to know the minimum number of moves needed to transform a into b.

Input

The first line contains a single integer n (1 ≤ n ≤ 105). The second line contains n space-separated integers x1, x2, ..., xn (2 ≤ xi ≤ 109). The third line contains two integers a and b (0 ≤ b ≤ a ≤ 109, a - b ≤ 106).

Output

Print a single integer — the required minimum number of moves needed to transform number a into number b.

Examples

Input

3
3 4 5
30 17

Output

6

Input

3
5 6 7
1000 200

Output

206

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  cin >> n;
  vector<int> mod(n);
  for (int i = 0; i < n; i++) cin >> mod[i];
  sort(mod.begin(), mod.end());
  mod.resize(unique(mod.begin(), mod.end()) - mod.begin());
  n = mod.size();
  cin >> a >> b;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      next;
  next.push(pair<int, int>(a, 0));
  int ans = 0;
  while (!next.empty()) {
    pair<int, int> front = next.top();
    next.pop();
    int now = front.first, depth = front.second;
    if (now == b) {
      ans = depth;
      break;
    }
    for (int i = 0; i < mod.size(); i++) {
      int target = now - (now % mod[i]);
      if (target >= b) next.push(pair<int, int>(target, depth + 1));
    }
    while (!mod.empty() && now - (now % mod.back()) < b) {
      mod.pop_back();
    }
    next.push(pair<int, int>(now - 1, depth + 1));
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

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

Levian works as an accountant in a large company. Levian knows how much the company has earned in each of the n consecutive months — in the i-th month the company had income equal to a_i (positive income means profit, negative income means loss, zero income means no change). Because of the general self-isolation, the first ⌈ n/2 ⌉ months income might have been completely unstable, but then everything stabilized and for the last ⌊ n/2 ⌋ months the income was the same.

Levian decided to tell the directors n-k+1 numbers — the total income of the company for each k consecutive months. In other words, for each i between 1 and n-k+1 he will say the value a_i + a_{i+1} + … + a_{i + k - 1}. For example, if a=[-1, 0, 1, 2, 2] and k=3 he will say the numbers 0, 3, 5.

Unfortunately, if at least one total income reported by Levian is not a profit (income ≤ 0), the directors will get angry and fire the failed accountant.

Save Levian's career: find any such k, that for each k months in a row the company had made a profit, or report that it is impossible.

Input

The first line contains a single integer n (2 ≤ n ≤ 5⋅ 10^5) — the number of months for which Levian must account.

The second line contains ⌈{n/2}⌉ integers a_1, a_2, …, a_{⌈{n/2}⌉}, where a_i (-10^9 ≤ a_i ≤ 10^9) — the income of the company in the i-th month.

Third line contains a single integer x (-10^9 ≤ x ≤ 10^9) — income in every month from ⌈{n/2}⌉ + 1 to n.

Output

In a single line, print the appropriate integer k or -1, if it does not exist.

If there are multiple possible answers, you can print any.

Examples

Input

3
2 -1
2

Output

2

Input

5
2 2 -8
2

Output

-1

Input

6
-2 -2 6
-1

Output

4

Note

In the first example, k=2 and k=3 satisfy: in the first case, Levian will report the numbers 1, 1, and in the second case — one number 3.

In the second example, there is no such k.

In the third example, the only answer is k=4: he will report the numbers 1,2,3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template <typename... T>
void rd(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void wr(T... args) {
  ((cout << args << " "), ...);
  cout << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < int((n + 1) / 2); ++i) {
    cin >> a[i];
  }
  int x;
  cin >> x;
  for (int i = (n + 1) / 2; i < n; i++) a[i] = x;
  vector<ll> ps(n + 1);
  partial_sum((a).begin(), (a).end(), ps.begin() + 1);
  if (ps.back() > 0) return cout << n, 0;
  if (x >= 0) return cout << -1, 0;
  ll N2 = n / 2, N1 = n - N2, sum = ps.back();
  ll mx = -1e18;
  for (int i = 0; i <= N1; i++) {
    mx = max(mx, ps[i] + x * ll(n - i));
    if (mx < sum + x * ll(n - i)) {
      cout << n - i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Let's denote a function f(x) in such a way: we add 1 to x, then, while there is at least one trailing zero in the resulting number, we remove that zero. For example,

  * f(599) = 6: 599 + 1 = 600 → 60 → 6;
  * f(7) = 8: 7 + 1 = 8;
  * f(9) = 1: 9 + 1 = 10 → 1;
  * f(10099) = 101: 10099 + 1 = 10100 → 1010 → 101.

We say that some number y is reachable from x if we can apply function f to x some (possibly zero) times so that we get y as a result. For example, 102 is reachable from 10098 because f(f(f(10098))) = f(f(10099)) = f(101) = 102; and any number is reachable from itself.

You are given a number n; your task is to count how many different numbers are reachable from n.

Input

The first line contains one integer n (1 ≤ n ≤ 10^9).

Output

Print one integer: the number of different numbers that are reachable from n.

Examples

Input

1098

Output

20

Input

10

Output

19

Note

The numbers that are reachable from 1098 are:

1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1098, 1099.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  set<long long int> s;
  while (s.find(n) == s.end()) {
    s.insert(n);
    n += 1;
    while (n % 10 == 0) n /= 10;
  }
  cout << s.size();
}

```


### Prompt

Develop a solution in cpp to the problem described below:

You are given a positive decimal number x.

Your task is to convert it to the "simple exponential notation".

Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b.

Input

The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other.

Output

Print the only line — the "simple exponential notation" of the given number x.

Examples

Input

16

Output

1.6E1

Input

01.23400

Output

1.234

Input

.100

Output

1E-1

Input

100.

Output

1E2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  size_t x = s.find_first_of("123456789");
  size_t y = s.find_last_of("123456789");
  size_t z = s.find('.');
  if (z == string::npos) {
    s += ".";
    z = s.size() - 1;
  }
  if (x == string::npos) {
    cout << 0 << endl;
  } else {
    int pow = (z < x) ? z - x : z - (x + 1);
    string ss;
    for (int i = x; i <= y; i++)
      if (s[i] != '.') ss.push_back(s[i]);
    cout << ss[0];
    if (ss.size() > 1) cout << "." + ss.substr(1, ss.size() - 1);
    if (pow != 0) cout << "E" << pow;
  }
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

You have matrix a of size n × n. Let's number the rows of the matrix from 1 to n from top to bottom, let's number the columns from 1 to n from left to right. Let's use aij to represent the element on the intersection of the i-th row and the j-th column.

Matrix a meets the following two conditions:

  * for any numbers i, j (1 ≤ i, j ≤ n) the following inequality holds: aij ≥ 0;
  * <image>.

Matrix b is strictly positive, if for any numbers i, j (1 ≤ i, j ≤ n) the inequality bij > 0 holds. You task is to determine if there is such integer k ≥ 1, that matrix ak is strictly positive.

Input

The first line contains integer n (2 ≤ n ≤ 2000) — the number of rows and columns in matrix a.

The next n lines contain the description of the rows of matrix a. The i-th line contains n non-negative integers ai1, ai2, ..., ain (0 ≤ aij ≤ 50). It is guaranteed that <image>.

Output

If there is a positive integer k ≥ 1, such that matrix ak is strictly positive, print "YES" (without the quotes). Otherwise, print "NO" (without the quotes).

Examples

Input

2
1 0
0 1

Output

NO

Input

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

Output

YES

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2200;
const int MAXM = 4400000;
stack<int> sta;
int dfn[MAXN], low[MAXN], ins[MAXN];
int cntn, ans, n;
struct Edge {
  int u, v, nxt;
} e[MAXM];
int e_cnt;
int head[MAXN];
void Add(int u, int v) {
  int id = ++e_cnt;
  e[id].u = u;
  e[id].v = v;
  e[id].nxt = head[u];
  head[u] = id;
}
void Tarjan(int u) {
  dfn[u] = low[u] = ++cntn;
  sta.push(u);
  ins[u] = 1;
  for (int id = head[u]; ~id; id = e[id].nxt) {
    int v = e[id].v;
    if (!dfn[v]) {
      Tarjan(v);
      low[u] = min(low[u], low[v]);
    } else if (ins[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (dfn[u] == low[u]) {
    int v = -1;
    while (u != v) {
      v = sta.top();
      ins[v] = 0;
      sta.pop();
    }
    ans++;
  }
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int x;
      scanf("%d", &x);
      if (x) Add(i, j);
    }
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) Tarjan(i);
  if (ans > 1)
    printf("NO");
  else
    printf("YES");
  return 0;
}

```


### Prompt

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

You are given a range of positive integers from l to r.

Find such a pair of integers (x, y) that l ≤ x, y ≤ r, x ≠ y and x divides y.

If there are multiple answers, print any of them.

You are also asked to answer T independent queries.

Input

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

Each of the next T lines contains two integers l and r (1 ≤ l ≤ r ≤ 998244353) — inclusive borders of the range.

It is guaranteed that testset only includes queries, which have at least one suitable pair.

Output

Print T lines, each line should contain the answer — two integers x and y such that l ≤ x, y ≤ r, x ≠ y and x divides y. The answer in the i-th line should correspond to the i-th query from the input.

If there are multiple answers, print any of them.

Example

Input

3
1 10
3 14
1 10

Output

1 7
3 9
5 10

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  vector<pair<int, int> > ans(t);
  for (int i = 0; i < t; i++) {
    int l;
    int r;
    cin >> l;
    cin >> r;
    ans[i].first = l;
    ans[i].second = 2 * l;
  }
  for (int i = 0; i < t; i++) {
    cout << ans[i].first << " " << ans[i].second << "\n";
  }
  return 0;
}

```


### Prompt

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

Long time ago Alex created an interesting problem about parallelogram. The input data for this problem contained four integer points on the Cartesian plane, that defined the set of vertices of some non-degenerate (positive area) parallelogram. Points not necessary were given in the order of clockwise or counterclockwise traversal.

Alex had very nice test for this problem, but is somehow happened that the last line of the input was lost and now he has only three out of four points of the original parallelogram. He remembers that test was so good that he asks you to restore it given only these three points.

Input

The input consists of three lines, each containing a pair of integer coordinates xi and yi ( - 1000 ≤ xi, yi ≤ 1000). It's guaranteed that these three points do not lie on the same line and no two of them coincide.

Output

First print integer k — the number of ways to add one new integer point such that the obtained set defines some parallelogram of positive area. There is no requirement for the points to be arranged in any special order (like traversal), they just define the set of vertices.

Then print k lines, each containing a pair of integer — possible coordinates of the fourth point.

Example

Input

0 0
1 0
0 1

Output

3
1 -1
-1 1
1 1

Note

If you need clarification of what parallelogram is, please check Wikipedia page:

https://en.wikipedia.org/wiki/Parallelogram

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x1, y1, x2, y2, x3, y3;
  scanf("%d %d %d %d %d %d", &x1, &y1, &x2, &y2, &x3, &y3);
  int a, b;
  printf("3\n%d %d\n%d %d\n%d %d\n", x1 - x2 + x3, y1 - y2 + y3, x2 - x3 + x1,
         y2 - y3 + y1, x3 - x1 + x2, y3 - y1 + y2);
}

```


### Prompt

Please create a solution in Cpp to the following problem:

There are N islands floating in Ringo Sea, and M travel agents operate ships between these islands. For convenience, we will call these islands Island 1, 2, …, N, and call these agents Agent 1, 2, …, M.

The sea currents in Ringo Sea change significantly each day. Depending on the state of the sea on the day, Agent i (1 ≤ i ≤ M) operates ships from Island a_i to b_i, or Island b_i to a_i, but not both at the same time. Assume that the direction of the ships of each agent is independently selected with equal probability.

Now, Takahashi is on Island 1, and Hikuhashi is on Island 2. Let P be the probability that Takahashi and Hikuhashi can travel to the same island in the day by ships operated by the M agents, ignoring the factors such as the travel time for ships. Then, P × 2^M is an integer. Find P × 2^M modulo 10^9 + 7.

Constraints

* 2 ≤ N ≤ 15
* 1 ≤ M ≤ N(N-1)/2
* 1 ≤ a_i < b_i ≤ N
* All pairs (a_i, b_i) are distinct.

Input

Input is given from Standard Input in the following format:

N M
a_1 b_1
:
a_M b_M

Output

Print the value P × 2^M modulo 10^9 + 7.

Examples

Input

4 3
1 3
2 3
3 4

Output

6

Input

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

Output

18

Input

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

Output

64

### Response

```cpp
#pragma GCC target("avx")  // CPU 処理並列化
#pragma GCC optimize("O3")  // CPU 処理並列化
#pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
long long dp[1<<15];
int p3[16];
int n;
int g[20][20];
int C[16][1<<15];
long long calc(int a){
	if(~dp[a])return dp[a];
	long long ret=1;
	int t=0;
	if(!(a&1))t=1;
	int tmp=a;
	while(tmp){
		if(tmp!=a&&(tmp&(1<<t))){
			int cnt=0;
			for(int i=0;i<n;i++){
				if(!(tmp&(1<<i)))continue;
				cnt+=C[i][a-tmp];
			}
			ret=(ret+mod-calc(tmp)*pw(d2,cnt)%mod)%mod;
		}
		tmp=(tmp-1)&a;
	}
	// printf("%d: %lld\n",a,ret);
	return dp[a]=ret;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);n=a;
	for(int i=0;i<b;i++){
		int s,t;scanf("%d%d",&s,&t);s--;t--;
		g[s][t]=g[t][s]=1;
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<(1<<a);j++){
			for(int k=0;k<a;k++){
				if(j&(1<<k)){
					if(g[i][k])C[i][j]++;
				}
			}
		}
	}
	long long ret=0;
	p3[0]=1;
	for(int i=0;i<(1<<a);i++)dp[i]=-1;
	for(int i=1;i<16;i++)p3[i]=p3[i-1]*3;
	for(int i=0;i<p3[a];i++){
		int A=0;
		int B=0;
		for(int j=0;j<a;j++){
			if(i/p3[j]%3==1)A+=(1<<j);
			if(i/p3[j]%3==2)B+=(1<<j);
		}
		if(!(A&1))continue;
		if(!(B&2))continue;
		bool ok=true;
		int cnt=0;
		for(int j=0;j<a;j++){
			if(!(A&(1<<j)))continue;
			if(C[j][B])ok=false;

		}
		if(!ok)continue;
		for(int j=0;j<a;j++){
			if(!(A&(1<<j)))continue;
			cnt+=C[j][(1<<a)-1-A];
		}
		for(int j=0;j<a;j++){
			if(!(B&(1<<j)))continue;
			cnt+=C[j][(1<<a)-1-B];
		}
		// printf("%d: %lld\n",i,pw(d2,cnt)*calc(A)%mod*calc(B)%mod);
		ret=(ret+pw(d2,cnt)*calc(A)%mod*calc(B))%mod;
	}
	ret=(1+mod-ret)%mod;
	ret=ret*pw(2,b)%mod;
	printf("%lld\n",ret);
}
```


### Prompt

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

Alice and Bob play 5-in-a-row game. They have a playing field of size 10 × 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts.

In current match they have made some turns and now it's Alice's turn. She wonders if she can put cross in such empty cell that she wins immediately.

Alice wins if some crosses in the field form line of length not smaller than 5. This line can be horizontal, vertical and diagonal.

Input

You are given matrix 10 × 10 (10 lines of 10 characters each) with capital Latin letters 'X' being a cross, letters 'O' being a nought and '.' being an empty cell. The number of 'X' cells is equal to the number of 'O' cells and there is at least one of each type. There is at least one empty cell.

It is guaranteed that in the current arrangement nobody has still won.

Output

Print 'YES' if it's possible for Alice to win in one turn by putting cross in some empty cell. Otherwise print 'NO'.

Examples

Input

XX.XX.....
.....OOOO.
..........
..........
..........
..........
..........
..........
..........
..........

Output

YES

Input

XXOXX.....
OO.O......
..........
..........
..........
..........
..........
..........
..........
..........

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using vs = vector<string>;
bool gen(vs& v, int i, int j, int di, int dj) {
  int cnt = 0;
  for (int k = 0; k < 5 && i >= 0 && i < 10 && j >= 0 && j < 10;
       k++, i += di, j += dj) {
    cnt += v[i][j] == 'X';
  }
  return cnt == 5;
}
int check(vs& v) {
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++) {
      if (gen(v, i, j, 0, 1)) return 1;
      if (gen(v, i, j, 1, 0)) return 1;
      if (gen(v, i, j, 1, 1)) return 1;
      if (gen(v, i, j, 1, -1)) return 1;
    }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  vs v(10);
  for (int i = 0; i < 10; i++) cin >> v[i];
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      if (v[i][j] == '.') {
        v[i][j] = 'X';
        if (check(v)) {
          cout << "YES" << endl;
          return 0;
        }
        v[i][j] = '.';
      }
  cout << "NO" << endl;
  return 0;
}

```


### Prompt

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

The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her n students and give each of them a jigsaw puzzle (which, as wikipedia states, is a tiling puzzle that requires the assembly of numerous small, often oddly shaped, interlocking and tessellating pieces).

The shop assistant told the teacher that there are m puzzles in the shop, but they might differ in difficulty and size. Specifically, the first jigsaw puzzle consists of f1 pieces, the second one consists of f2 pieces and so on.

Ms. Manana doesn't want to upset the children, so she decided that the difference between the numbers of pieces in her presents must be as small as possible. Let A be the number of pieces in the largest puzzle that the teacher buys and B be the number of pieces in the smallest such puzzle. She wants to choose such n puzzles that A - B is minimum possible. Help the teacher and find the least possible value of A - B.

Input

The first line contains space-separated integers n and m (2 ≤ n ≤ m ≤ 50). The second line contains m space-separated integers f1, f2, ..., fm (4 ≤ fi ≤ 1000) — the quantities of pieces in the puzzles sold in the shop.

Output

Print a single integer — the least possible difference the teacher can obtain.

Examples

Input

4 6
10 12 10 7 5 22

Output

5

Note

Sample 1. The class has 4 students. The shop sells 6 puzzles. If Ms. Manana buys the first four puzzles consisting of 10, 12, 10 and 7 pieces correspondingly, then the difference between the sizes of the largest and the smallest puzzle will be equal to 5. It is impossible to obtain a smaller difference. Note that the teacher can also buy puzzles 1, 3, 4 and 5 to obtain the difference 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, m, mn = 996;
  cin >> n >> m;
  int a[m];
  for (i = 0; i < m; i++) cin >> a[i];
  sort(a, a + m);
  for (i = 0; i <= m - n; i++)
    if (a[n + i - 1] - a[i] < mn) mn = a[n + i - 1] - a[i];
  cout << mn;
}

```


### Prompt

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

Bajtek is learning to skate on ice. He's a beginner, so his only mode of transportation is pushing off from a snow drift to the north, east, south or west and sliding until he lands in another snow drift. He has noticed that in this way it's impossible to get from some snow drifts to some other by any sequence of moves. He now wants to heap up some additional snow drifts, so that he can get from any snow drift to any other one. He asked you to find the minimal number of snow drifts that need to be created.

We assume that Bajtek can only heap up snow drifts at integer coordinates.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 100) — the number of snow drifts. Each of the following n lines contains two integers xi and yi (1 ≤ xi, yi ≤ 1000) — the coordinates of the i-th snow drift.

Note that the north direction coinсides with the direction of Oy axis, so the east direction coinсides with the direction of the Ox axis. All snow drift's locations are distinct.

Output

Output the minimal number of snow drifts that need to be created in order for Bajtek to be able to reach any snow drift from any other one.

Examples

Input

2
2 1
1 2

Output

1

Input

2
2 1
4 1

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
set<int> a, b;
vector<pair<int, int> > z;
int aa[101] = {0};
int n;
void refresh() {
  for (__typeof((n)) i = (0); i < (n); i += 1) {
    if (aa[i] == 0) {
      if (a.find(z[i].first) != a.end() || b.find(z[i].second) != b.end()) {
        a.insert(z[i].first);
        b.insert(z[i].second);
        aa[i] = 1;
        refresh();
        break;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int ans = -1;
  for (__typeof((n)) i = (0); i < (n); i += 1) {
    int x, y;
    cin >> x >> y;
    z.push_back(make_pair(x, y));
  }
  for (__typeof((n)) i = (0); i < (n); i += 1) {
    if (aa[i] == 0) {
      aa[i] = 1;
      if (a.find(z[i].first) == a.end() && b.find(z[i].second) == b.end()) {
        ans++;
        a.insert(z[i].first);
        b.insert(z[i].second);
        refresh();
      }
      a.insert(z[i].first);
      b.insert(z[i].second);
    }
  }
  cout << ans;
}

```


### Prompt

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

DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the string) he represents its value with a function f(s), where

<image>

Now DZY has a string s. He wants to insert k lowercase letters into this string in order to get the largest possible value of the resulting string. Can you help him calculate the largest possible value he could get?

Input

The first line contains a single string s (1 ≤ |s| ≤ 103).

The second line contains a single integer k (0 ≤ k ≤ 103).

The third line contains twenty-six integers from wa to wz. Each such number is non-negative and doesn't exceed 1000.

Output

Print a single integer — the largest possible value of the resulting string DZY could get.

Examples

Input

abc
3
1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output

41

Note

In the test sample DZY can obtain "abcbbc", value = 1·1 + 2·2 + 3·2 + 4·2 + 5·2 + 6·2 = 41.

### Response

```cpp
#include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 1e+9 + 7;
const ll INF = LLONG_MAX;
const int N = (int)2e+5 + 8;
template <typename T>
string itos(T i) {
  stringstream second;
  second << i;
  return second.str();
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  ios_base ::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  string second;
  cin >> second;
  int n;
  cin >> n;
  vector<pair<int, char>> vec;
  int arr[123] = {0};
  for (char i = 'a'; i <= 'z'; i++) {
    int a;
    cin >> a;
    vec.push_back({a, i});
    arr[i] = a;
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int temp = vec[0].first;
  int index = 1;
  ll res = 0;
  for (int i = 0; i < second.length(); i++) {
    res += index * arr[second[i]];
    index++;
  }
  for (; index <= second.length() + n; index++) {
    res += index * temp;
  }
  cout << res;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

In this problem, a n × m rectangular matrix a is called increasing if, for each row of i, when go from left to right, the values strictly increase (that is, a_{i,1}<a_{i,2}<...<a_{i,m}) and for each column j, when go from top to bottom, the values strictly increase (that is, a_{1,j}<a_{2,j}<...<a_{n,j}).

In a given matrix of non-negative integers, it is necessary to replace each value of 0 with some positive integer so that the resulting matrix is increasing and the sum of its elements is maximum, or find that it is impossible.

It is guaranteed that in a given value matrix all values of 0 are contained only in internal cells (that is, not in the first or last row and not in the first or last column).

Input

The first line contains integers n and m (3 ≤ n, m ≤ 500) — the number of rows and columns in the given matrix a.

The following lines contain m each of non-negative integers — the values in the corresponding row of the given matrix: a_{i,1}, a_{i,2}, ..., a_{i,m} (0 ≤ a_{i,j} ≤ 8000).

It is guaranteed that for all a_{i,j}=0, 1 < i < n and 1 < j < m are true.

Output

If it is possible to replace all zeros with positive numbers so that the matrix is increasing, print the maximum possible sum of matrix elements. Otherwise, print -1.

Examples

Input

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

Output

144

Input

3 3
1 2 3
2 0 4
4 5 6

Output

30

Input

3 3
1 2 3
3 0 4
4 5 6

Output

-1

Input

3 3
1 2 3
2 3 4
3 4 2

Output

-1

Note

In the first example, the resulting matrix is as follows:

    1 3 5 6 7
    3 6 7 8 9
    5 7 8 9 10
    8 9 10 11 12

In the second example, the value 3 must be put in the middle cell.

In the third example, the desired resultant matrix does not exist.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline void filee() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int main() {
  int n, m;
  cin >> m >> n;
  int sum = 0;
  int a[m][n];
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
      sum += a[i][j];
    }
  }
  for (int i = m - 1; i >= 1; i--) {
    for (int j = n - 1; j >= 1; j--) {
      if (a[i][j] == 0) {
        a[i][j] = min(a[i + 1][j], a[i][j + 1]) - 1;
        sum += a[i][j];
      }
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 1; j < n; j++) {
      if (a[i][j] <= a[i][j - 1]) {
        cout << -1;
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < m; j++) {
      if (a[j][i] <= a[j - 1][i]) {
        cout << -1;
        return 0;
      }
    }
  }
  cout << sum;
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.

Pavel drew a grid maze with all empty cells forming a connected area. That is, you can go from any empty cell to any other one. Pavel doesn't like it when his maze has too little walls. He wants to turn exactly k empty cells into walls so that all the remaining cells still formed a connected area. Help him.

Input

The first line contains three integers n, m, k (1 ≤ n, m ≤ 500, 0 ≤ k < s), where n and m are the maze's height and width, correspondingly, k is the number of walls Pavel wants to add and letter s represents the number of empty cells in the original maze.

Each of the next n lines contains m characters. They describe the original maze. If a character on a line equals ".", then the corresponding cell is empty and if the character equals "#", then the cell is a wall.

Output

Print n lines containing m characters each: the new maze that fits Pavel's requirements. Mark the empty cells that you transformed into walls as "X", the other cells must be left without changes (that is, "." and "#").

It is guaranteed that a solution exists. If there are multiple solutions you can output any of them.

Examples

Input

3 4 2
#..#
..#.
#...

Output

#.X#
X.#.
#...

Input

5 4 5
#...
#.#.
.#..
...#
.#.#

Output

#XXX
#X#.
X#..
...#
.#.#

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int row[] = {-1, 0, 0, 1};
int col[] = {0, -1, 1, 0};
int n, m, k;
char matrix[501][501];
bool visited[501][501] = {0};
bool isValid(int i, int j) {
  if (i >= 0 && i < n && j >= 0 && j < m) return true;
  return false;
}
void dfs(int i, int j) {
  visited[i][j] = 1;
  for (int x = 0; x < 4; x++) {
    int new_i = i + row[x];
    int new_j = j + col[x];
    if (isValid(new_i, new_j) && !visited[new_i][new_j] &&
        matrix[new_i][new_j] == '.')
      dfs(new_i, new_j);
  }
  if (k == 0)
    return;
  else {
    matrix[i][j] = 'X';
    k--;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> k;
  bool flag = true;
  int start_i, start_j;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> matrix[i][j];
      if (flag && matrix[i][j] == '.') {
        start_i = i;
        start_j = j;
        flag = false;
      }
    }
  }
  dfs(start_i, start_j);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << matrix[i][j];
    }
    cout << "\n";
  }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

<image>

To monitor cryptocurrency exchange rates trader William invented a wonderful device consisting of n lights arranged in a row. The device functions in the following way:

Initially, all lights on William's device are turned off. At the beginning of a new iteration the device randomly, with a uniform distribution, picks a light that is turned off and turns it on, telling William which cryptocurrency he should invest in. After this iteration if any k consecutive lights contain more than one turned on light, then the device finishes working.

William doesn't like uncertainty, so he wants you to calculate the expected value of the number of lights that are turned on in the device after it finishes working.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10). Description of the test cases follows.

The only line for each test case contains two integers n and k (2 ≤ k ≤ n ≤ 10^5), which are the total number of lights and the length of subsegment of lights that are being checked, respectively.

Output

For each test case print the answer, modulo 10^9+7.

Formally, let M = 10^9+7. It can be shown that the answer can be expressed as an irreducible fraction p/q, where p and q are integers and q not ≡ 0 \pmod{M}. Output the integer equal to p ⋅ q^{-1} mod M. In other words, output such an integer x that 0 ≤ x < M and x ⋅ q ≡ p \pmod{M}.

Example

Input

3
3 2
15 2
40 15

Output

333333338
141946947
329622137

Note

Explanation of the first sample test case:

Let's write out all possible sequences of light toggles, which will make the device complete its operation:

  1. (1, 2) — 2 lights are turned on
  2. (1, 3, 2) — 3 lights are turned on
  3. (2, 1) — 2 lights are turned on
  4. (2, 3) — 2 lights are turned on
  5. (3, 2) — 2 lights are turned on
  6. (3, 1, 2) — 3 lights are turned on

Then the final expected value will be equal to 2/6 + 3/6 + 2/6 + 2/6 + 2/6 + 3/6 = 14/6 = 7/3.

Then the required output will be 333333338, since 333333338 ⋅ 3 ≡ 7 \pmod{10^9+7}.

### Response

```cpp
#include <cstdio>
#include <cassert>

const int MOD=1e9+7;

int inv[200005]={0,1};
int fact[200005]={1,1};
int invfact[200005]={1,1};

int choose(int n,int k){
  if(k<0||k>n) return 0;
  return 1LL*fact[n]*invfact[k]%MOD*invfact[n-k]%MOD;
}
int invchoose(int n,int k){
  if(k<0||k>n) return 0;
  return 1LL*invfact[n]*fact[k]%MOD*fact[n-k]%MOD;
}

void solve(){
  int ans=0;
  int N,K;
  scanf("%d %d",&N,&K);
  for(int l=0;N>=(l-1)*(K-1);l++){
    ans=(ans+1LL*invchoose(N,l)*choose(N-(l-1)*(K-1),l))%MOD;
    //printf("%d=>%d: %d ways\n",l,l+1,choose(N-(l-1)*(K-1),l));
  }
  printf("%d\n",ans);
}

int main(){
  for(int i=2;i<=200000;i++){
    inv[i]=1LL*(MOD-MOD/i)*inv[MOD%i]%MOD;
    //printf("%lld\n",1LL*i*inv[i]%MOD);
    fact[i]=1LL*i*fact[i-1]%MOD;
    invfact[i]=1LL*inv[i]*invfact[i-1]%MOD;
    //printf("%lld\n",1LL*fact[i]*invfact[i]%MOD);
  }
  int T;
  scanf("%d",&T);
  while(T--){
    solve();
  }
}

```


### Prompt

Please create a solution in cpp to the following problem:

There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparing special agent Pearlo for many years. When, finally, Pearlo learned all secrets of espionage, he penetrated into the Potatoland territory and reached the secret base.

Now he is standing at the entrance, but to get inside he need to pass combination lock. Minute ago one of the workers entered the password on the terminal and opened the door. The terminal is a square digital keyboard 3 × 3 with digits from 1 to 9.

Pearlo knows that the password consists from distinct digits and is probably symmetric with respect to the central button of the terminal. He has heat sensor which allowed him to detect the digits which the worker pressed. Now he wants to check whether the password entered by the worker is symmetric with respect to the central button of the terminal. This fact can Help Pearlo to reduce the number of different possible password combinations.

Input

Input contains the matrix of three rows of three symbols each. Symbol «X» means that the corresponding button was pressed, and «.» means that is was not pressed. The matrix may contain no «X», also it may contain no «.».

Output

Print YES if the password is symmetric with respect to the central button of the terminal and NO otherwise.

Examples

Input

XX.
...
.XX

Output

YES

Input

X.X
X..
...

Output

NO

Note

If you are not familiar with the term «central symmetry», you may look into http://en.wikipedia.org/wiki/Central_symmetry

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, flag, k;
  char matrix[3][3];
  int d[9] = {0};
  k = 0;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      cin >> matrix[i][j];
      k++;
      if (matrix[i][j] == 'X') {
        d[k - 1] = 1;
      }
    }
  }
  flag = 0;
  for (i = 0; i < 9; i++) {
    if ((d[0] && !d[8]) || (!d[0] && d[8])) {
      flag = 1;
    }
    if ((d[1] && !d[7]) || (!d[1] && d[7])) {
      flag = 1;
    }
    if ((d[2] && !d[6]) || (!d[2] && d[6])) {
      flag = 1;
    }
    if ((d[3] && !d[5]) || (!d[3] && d[5])) {
      flag = 1;
    }
  }
  if (flag == 1) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
  }
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Recent improvements in information and communication technology have made it possible to provide municipal service to a wider area more quickly and with less costs. Stimulated by this, and probably for saving their not sufficient funds, mayors of many cities started to discuss on mergers of their cities.

There are, of course, many obstacles to actually put the planned mergers in practice. Each city has its own culture of which citizens are proud. One of the largest sources of friction is with the name of the new city. All citizens would insist that the name of the new city should have the original name of their own city at least as a part of it. Simply concatenating all the original names would, however, make the name too long for everyday use.

You are asked by a group of mayors to write a program that finds the shortest possible name for the new city that includes all the original names of the merged cities. If two or more cities have common parts, they can be overlapped. For example, if "FUKUOKA", "OKAYAMA", and "YAMAGUCHI" cities are to be merged, "FUKUOKAYAMAGUCHI" is such a name that include all three of the original city names. Although this includes all the characters of the city name "FUKUYAMA" in this order, it does not appear as a consecutive substring, and thus "FUKUYAMA" is not considered to be included in the name.

Input

The input is a sequence of datasets. Each dataset begins with a line containing a positive integer n (n ≤ 14), which denotes the number of cities to be merged. The following n lines contain the names of the cities in uppercase alphabetical letters, one in each line. You may assume that none of the original city names has more than 20 characters. Of course, no two cities have the same name.

The end of the input is indicated by a line consisting of a zero.

Output

For each dataset, output the length of the shortest possible name of the new city in one line. The output should not contain any other characters.

Examples

Input

3

Output

16

Input

3
FUKUOKA
OKAYAMA
YAMAGUCHI
3
FUKUOKA
FUKUYAMA
OKAYAMA
2
ABCDE
EDCBA
4
GA
DEFG
CDDE
ABCD
2
ABCDE
C
14
AAAAA
BBBBB
CCCCC
DDDDD
EEEEE
FFFFF
GGGGG
HHHHH
IIIII
JJJJJ
KKKKK
LLLLL
MMMMM
NNNNN
0

Output

16
19
9
9
5
70

### Response

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

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
const double EPS=1e-6;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) a.rbegin(),a.rend()
#define FLL(a,b) memset((a),b,sizeof(a))
#define CLR(a) FLL(a,0)
#define declare(a,it) __typeof(a) it=(a)
#define FOR(it,a) for(declare(a.begin(),it);it!=a.end();++it)
#define FORR(it,a) for(declare(a.rbegin(),it);it!=a.rend();++it)
template<class T,class U> ostream& operator<< (ostream& o, const pair<T,U>& v){return o << "(" << v.F << ", " << v.S << ")";}
template<class T> ostream& operator<< (ostream& o, const vector<T>& v){o << "{";rep(i,SZ(v)) o << (i?", ":"") << v[i];return o << "}";}
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};
int s2i(string& a){stringstream ss(a);int r;ss>>r;return r;}
int geti(){int n;scanf("%d", &n);return n;}

int n;
string in[100];

int over(string a,string b){
  int ov = min(a.size(),b.size()) - 1;
  for(;ov;--ov){
    if(a.substr(a.size()-ov) == b.substr(0,ov)){
      //cout << a << " " << b << " " << ov << endl;
      return ov;
    }
  }
  return 0;
}

int cost[100][100];
int memo[1<<14][14];

int rec(int st,int l){
  if(st == (1<<l)){
    //cout << "hitt" << endl;
    return 0;//cost[l][l];
  }

  if(memo[st][l] >= 0)
    return memo[st][l];

  int& ret = memo[st][l] = 0;
  for(int i = 0; (1<<i) <= st; ++i){
    if(~st&(1<<i)) continue;
    if(i == l) continue;
    ret = max(ret, cost[i][l] + rec(st^(1<<l),i));
  }
  //cout << st << " " << l << " " << ret << endl;
  return ret;
}

int main(){
  while(cin >> n && n){
    set<string> app;
    for(int i = 0; i < n; ++i){
      string s;
      cin >> s;
      app.insert(s);
    }

    set<string> use;
    for(auto s : app){
      bool ok = 1;
      for(auto e : app){
        if(s == e) continue;
        ok &= e.find(s) == string::npos;
      }
      if(ok) use.insert(s);
    }

    vector<string> vs(use.begin(), use.end());

    memset(cost, 0 , sizeof(cost));
    for(int i = 0; i < vs.size(); ++i){
      for(int j = 0; j < vs.size(); ++j)
        cost[i][j] = over(vs[i], vs[j]);
      cost[i][i] = 0;//vs[i].size();
    }

    int ans = 0;
    memset(memo,-1 ,sizeof(memo));
    int sum = 0;
    for(int i = 0; i < vs.size(); ++i){
      ans = max(ans, rec((1<<vs.size()) - 1, i));
      sum += vs[i].size();
    }

    cout << sum - ans << endl;
  }
}
```


### Prompt

Please create a solution in Cpp to the following problem:

You are playing a new famous fighting game: Kortal Mombat XII. You have to perform a brutality on your opponent's character.

You are playing the game on the new generation console so your gamepad have 26 buttons. Each button has a single lowercase Latin letter from 'a' to 'z' written on it. All the letters on buttons are pairwise distinct.

You are given a sequence of hits, the i-th hit deals a_i units of damage to the opponent's character. To perform the i-th hit you have to press the button s_i on your gamepad. Hits are numbered from 1 to n.

You know that if you press some button more than k times in a row then it'll break. You cherish your gamepad and don't want to break any of its buttons.

To perform a brutality you have to land some of the hits of the given sequence. You are allowed to skip any of them, however changing the initial order of the sequence is prohibited. The total damage dealt is the sum of a_i over all i for the hits which weren't skipped.

Note that if you skip the hit then the counter of consecutive presses the button won't reset.

Your task is to skip some hits to deal the maximum possible total damage to the opponent's character and not break your gamepad buttons.

Input

The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 2 ⋅ 10^5) — the number of hits and the maximum number of times you can push the same button in a row.

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9), where a_i is the damage of the i-th hit.

The third line of the input contains the string s consisting of exactly n lowercase Latin letters — the sequence of hits (each character is the letter on the button you need to press to perform the corresponding hit).

Output

Print one integer dmg — the maximum possible damage to the opponent's character you can deal without breaking your gamepad buttons.

Examples

Input

7 3
1 5 16 18 7 2 10
baaaaca

Output

54

Input

5 5
2 4 1 3 1000
aaaaa

Output

1010

Input

5 4
2 4 1 3 1000
aaaaa

Output

1009

Input

8 1
10 15 2 1 4 8 15 16
qqwweerr

Output

41

Input

6 3
14 18 9 19 2 15
cccccc

Output

52

Input

2 1
10 10
qq

Output

10

Note

In the first example you can choose hits with numbers [1, 3, 4, 5, 6, 7] with the total damage 1 + 16 + 18 + 7 + 2 + 10 = 54.

In the second example you can choose all hits so the total damage is 2 + 4 + 1 + 3 + 1000 = 1010.

In the third example you can choose all hits expect the third one so the total damage is 2 + 4 + 3 + 1000 = 1009.

In the fourth example you can choose hits with numbers [2, 3, 6, 8]. Only this way you can reach the maximum total damage 15 + 2 + 8 + 16 = 41.

In the fifth example you can choose only hits with numbers [2, 4, 6] with the total damage 18 + 19 + 15 = 52.

In the sixth example you can change either first hit or the second hit (it does not matter) with the total damage 10.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, k;
long long process(priority_queue<int> &Q) {
  long long ans = 0;
  for (int i = 0; i < k; ++i) {
    if (Q.empty()) {
      break;
    }
    ans += Q.top();
    Q.pop();
  }
  while (!Q.empty()) {
    Q.pop();
  }
  return ans;
}
int a[200005];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  string s;
  cin >> s;
  priority_queue<int> Q;
  long long ans = 0;
  Q.push(a[0]);
  for (int i = 1; i < s.size(); ++i) {
    if (s[i] != s[i - 1]) {
      ans += process(Q);
    }
    Q.push(a[i]);
  }
  ans += process(Q);
  cout << ans;
}

```


### Prompt

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

Kevin Sun wants to move his precious collection of n cowbells from Naperthrill to Exeter, where there is actually grass instead of corn. Before moving, he must pack his cowbells into k boxes of a fixed size. In order to keep his collection safe during transportation, he won't place more than two cowbells into a single box. Since Kevin wishes to minimize expenses, he is curious about the smallest size box he can use to pack his entire collection.

Kevin is a meticulous cowbell collector and knows that the size of his i-th (1 ≤ i ≤ n) cowbell is an integer si. In fact, he keeps his cowbells sorted by size, so si - 1 ≤ si for any i > 1. Also an expert packer, Kevin can fit one or two cowbells into a box of size s if and only if the sum of their sizes does not exceed s. Given this information, help Kevin determine the smallest s for which it is possible to put all of his cowbells into k boxes of size s.

Input

The first line of the input contains two space-separated integers n and k (1 ≤ n ≤ 2·k ≤ 100 000), denoting the number of cowbells and the number of boxes, respectively.

The next line contains n space-separated integers s1, s2, ..., sn (1 ≤ s1 ≤ s2 ≤ ... ≤ sn ≤ 1 000 000), the sizes of Kevin's cowbells. It is guaranteed that the sizes si are given in non-decreasing order.

Output

Print a single integer, the smallest s for which it is possible for Kevin to put all of his cowbells into k boxes of size s.

Examples

Input

2 1
2 5

Output

7

Input

4 3
2 3 5 9

Output

9

Input

3 2
3 5 7

Output

8

Note

In the first sample, Kevin must pack his two cowbells into the same box.

In the second sample, Kevin can pack together the following sets of cowbells: {2, 3}, {5} and {9}.

In the third sample, the optimal solution is {3, 5} and {7}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 1e5 + 55;
int N, K;
int S[kMaxN];
int temp[kMaxN];
int main(void) {
  int mx = -1;
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &S[i]);
    mx = max(mx, S[i]);
  }
  if (K >= N) {
    printf("%d\n", mx);
    return 0;
  }
  int len = N - K;
  mx = -1;
  for (int i = N - 1; i >= len; --i) {
    temp[N - 1 - i] = S[i];
    mx = max(mx, temp[N - 1 - i]);
  }
  for (int i = len - 1, j = K - 1; i >= 0; --i, --j) {
    temp[j] += S[i];
    mx = max(mx, temp[j]);
  }
  printf("%d\n", mx);
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Write a program which reads a $n \times m$ matrix $A$ and a $m \times l$ matrix $B$, and prints their product, a $n \times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula:

\\[ c_{ij} = \sum_{k=1}^m a_{ik}b_{kj} \\]

where $a_{ij}$, $b_{ij}$ and $c_{ij}$ are elements of $A$, $B$ and $C$ respectively.

Note

解説

Constraints

* $1 \leq n, m, l \leq 100$
* $0 \leq a_{ij}, b_{ij} \leq 10000$

Input

In the first line, three integers $n$, $m$ and $l$ are given separated by space characters

In the following lines, the $n \times m$ matrix $A$ and the $m \times l$ matrix $B$ are given.

Output

Print elements of the $n \times l$ matrix $C$ ($c_{ij}$). Print a single space character between adjacent elements.

Example

Input

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

Output

1 8 5
0 9 6
4 23 14

### Response

```cpp
#include<iostream>
#include<algorithm>
#include<vector>

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

using namespace std;

const int INF = 100;

int main()
{

	int n, m, l;

	cin >> n >> m >> l;

	int A[200][200];
	rep(i, n)rep(j, m)cin >> A[i][j];

	int B[200][200];
	rep(i, m)rep(j, l)cin >> B[i][j];

	rep(i, n) {
		rep(j, l) {
			ll out = 0;
			rep(k, m) {
				out += A[i][k] * B[k][j];
			}
			if (j == 0) {
				cout << out;
			}
			else {
				cout << " " << out;
			}
		}
		cout << endl;
	}

	return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.

A single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.

The deck of cards is represented by a string as follows.

abcdeefab

The first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively.

For example, a shuffle with h = 4 to the above deck, moves the first 4 characters "abcd" to the end of the remaining characters "eefab", and generates the following deck:

eefababcd

You can repeat such shuffle operations.

Write a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).

Constraints

* The length of the string ≤ 200
* 1 ≤ m ≤ 100
* 1 ≤ hi < The length of the string
* The number of datasets ≤ 10

Input

The input consists of multiple datasets. Each dataset is given in the following format:

A string which represents a deck
The number of shuffle m
h1
h2
.
.
hm

The input ends with a single character '-' for the string.

Output

For each dataset, print a string which represents the final state in a line.

Example

Input

aabc
3
1
2
1
vwxyz
2
3
4
-

Output

aabc
xyzvw

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,to) for(int i=x;i<to;i++)

int main(){
	string str;
	while(1){
		cin>>str;
		if(str=="-")break;
		int m,h;
		cin>>m;
		rep(i,0,m){
			cin >> h;
			str = str.substr(h)+str.substr(0,h);
		}
		cout<<str<<endl;
	}
	return 0;
}

```