### Prompt

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

The nation of Panel holds an annual show called The Number Games, where each district in the nation will be represented by one contestant.

The nation has n districts numbered from 1 to n, each district has exactly one path connecting it to every other district. The number of fans of a contestant from district i is equal to 2^i.

This year, the president decided to reduce the costs. He wants to remove k contestants from the games. However, the districts of the removed contestants will be furious and will not allow anyone to cross through their districts.

The president wants to ensure that all remaining contestants are from districts that can be reached from one another. He also wishes to maximize the total number of fans of the participating contestants.

Which contestants should the president remove?

Input

The first line of input contains two integers n and k (1 ≤ k < n ≤ 10^6) — the number of districts in Panel, and the number of contestants the president wishes to remove, respectively.

The next n-1 lines each contains two integers a and b (1 ≤ a, b ≤ n, a ≠ b), that describe a road that connects two different districts a and b in the nation. It is guaranteed that there is exactly one path between every two districts.

Output

Print k space-separated integers: the numbers of the districts of which the contestants should be removed, in increasing order of district number.

Examples

Input

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

Output

1 3 4

Input

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

Output

1 3 4 5

Note

In the first sample, the maximum possible total number of fans is 2^2 + 2^5 + 2^6 = 100. We can achieve it by removing the contestants of the districts 1, 3, and 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000 * 1000 + 10;
const int MAX_K = 20 + 5;
vector<int> adj[MAX_N];
int par[MAX_N][MAX_K];
bool block[MAX_N];
bool mark[MAX_N];
void dfs(int u, int dad) {
  par[u][0] = u;
  for (int i = 1; i < MAX_K; i++) par[u][i] = par[par[dad][i - 1]][i - 1];
  for (auto v : adj[u])
    if (v != dad) dfs(v, u);
}
void add(int u) {
  mark[u] = true;
  if (!mark[par[u][1]]) add(par[u][1]);
}
void rem(int u) {
  block[u] = true;
  for (auto v : adj[u])
    if (v != par[u][1] && !block[v]) rem(v);
}
int dis(int u) {
  int L = 0, R = 20;
  while (L + 1 < R) {
    int mid = (L + R) / 2;
    mark[par[u][mid]] ? R = mid : L = mid;
  }
  return (L ? dis(par[u][L]) : 1) + (1 << L) - 1;
}
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  k = n - k - 1;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(n - 1, n - 1), add(n - 1);
  for (int i = n - 2; ~i && k; i--)
    if (!block[i] && !mark[i]) {
      int x = dis(i);
      x <= k ? k -= x, add(i) : rem(i);
    }
  for (int i = 0; i < n; i++)
    if (!mark[i]) cout << i + 1 << ' ';
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

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>
using namespace std;
int main() {
  string str;
  cin >> str;
  int q, n, s = 0, max = 0;
  cin >> n;
  int i, arr[26];
  for (i = 0; i < 26; i++) {
    cin >> arr[i];
    if (max < arr[i]) max = arr[i];
  }
  int k = str.length();
  for (i = 0; i < k; i++) {
    q = str[i] - 96;
    s += (i + 1) * arr[q - 1];
  }
  q = (k + n + 1) * (k + n) / 2 - k * (k + 1) / 2;
  cout << s + q * max;
}

```


### Prompt

Generate a CPP solution 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;
const int MAX = 2e5 + 5;
char T[MAX];
int val[MAX];
int main() {
  int n, x;
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> val[i];
  cin >> T;
  int i = 0, j = 0;
  long long ans = 0;
  while (i < n) {
    vector<int> v;
    v.push_back(val[j]);
    j++;
    while (T[i] == T[j]) {
      v.push_back(val[j]);
      j++;
    }
    i = j;
    int k = 0;
    sort(v.begin(), v.end());
    for (int i = v.size() - 1; i >= 0 && k < x; i--) {
      ans += v[i];
      k++;
    }
  }
  cout << ans;
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

You are given a non-empty string s=s_1s_2... s_n, which consists only of lowercase Latin letters. Polycarp does not like a string if it contains at least one string "one" or at least one string "two" (or both at the same time) as a substring. In other words, Polycarp does not like the string s if there is an integer j (1 ≤ j ≤ n-2), that s_{j}s_{j+1}s_{j+2}="one" or s_{j}s_{j+1}s_{j+2}="two".

For example:

  * Polycarp does not like strings "oneee", "ontwow", "twone" and "oneonetwo" (they all have at least one substring "one" or "two"),
  * Polycarp likes strings "oonnee", "twwwo" and "twnoe" (they have no substrings "one" and "two").

Polycarp wants to select a certain set of indices (positions) and remove all letters on these positions. All removals are made at the same time.

For example, if the string looks like s="onetwone", then if Polycarp selects two indices 3 and 6, then "onetwone" will be selected and the result is "ontwne".

What is the minimum number of indices (positions) that Polycarp needs to select to make the string liked? What should these positions be?

Input

The first line of the input contains an integer t (1 ≤ t ≤ 10^4) — the number of test cases in the input. Next, the test cases are given.

Each test case consists of one non-empty string s. Its length does not exceed 1.5⋅10^5. The string s consists only of lowercase Latin letters.

It is guaranteed that the sum of lengths of all lines for all input data in the test does not exceed 1.5⋅10^6.

Output

Print an answer for each test case in the input in order of their appearance.

The first line of each answer should contain r (0 ≤ r ≤ |s|) — the required minimum number of positions to be removed, where |s| is the length of the given line. The second line of each answer should contain r different integers — the indices themselves for removal in any order. Indices are numbered from left to right from 1 to the length of the string. If r=0, then the second line can be skipped (or you can print empty). If there are several answers, print any of them.

Examples

Input

4
onetwone
testme
oneoneone
twotwo

Output

2
6 3
0

3
4 1 7
2
1 4

Input

10
onetwonetwooneooonetwooo
two
one
twooooo
ttttwo
ttwwoo
ooone
onnne
oneeeee
oneeeeeeetwooooo

Output

6
18 11 12 1 6 21
1
1
1
3
1
2
1
6
0

1
4
0

1
1
2
1 11

Note

In the first example, answers are:

  * "onetwone",
  * "testme" — Polycarp likes it, there is nothing to remove,
  * "oneoneone",
  * "twotwo".

In the second example, answers are:

  * "onetwonetwooneooonetwooo",
  * "two",
  * "one",
  * "twooooo",
  * "ttttwo",
  * "ttwwoo" — Polycarp likes it, there is nothing to remove,
  * "ooone",
  * "onnne" — Polycarp likes it, there is nothing to remove,
  * "oneeeee",
  * "oneeeeeeetwooooo".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int _;
  cin >> _;
  while (_--) {
    string a;
    cin >> a;
    long long int i = 0;
    long long int n = a.size();
    vector<long long int> ans;
    for (i = 0; i < n - 4; i++) {
      if ((a[i] == 't') && (a[i + 1] == 'w') && (a[i + 2] == 'o') &&
          (a[i + 3] == 'n') && (a[i + 4] == 'e')) {
        ans.push_back(i + 2);
        a[i + 2] = 'z';
      }
    }
    for (i = 0; i < n - 2; i++) {
      if (((a[i] == 't') && (a[i + 1] == 'w') && (a[i + 2] == 'o')) ||
          ((a[i] == 'o') && (a[i + 1] == 'n') && (a[i + 2] == 'e'))) {
        ans.push_back(i + 1);
      }
    }
    cout << ans.size() << "\n";
    for (i = 0; i < ans.size(); i++) {
      cout << ans[i] + 1 << " ";
    }
    cout << "\n";
  }
}

```


### Prompt

Please create a solution in Cpp to the following problem:

You have number a, whose decimal representation quite luckily contains digits 1, 6, 8, 9. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.

Number a doesn't contain any leading zeroes and contains digits 1, 6, 8, 9 (it also can contain another digits). The resulting number also mustn't contain any leading zeroes.

Input

The first line contains positive integer a in the decimal record. It is guaranteed that the record of number a contains digits: 1, 6, 8, 9. Number a doesn't contain any leading zeroes. The decimal representation of number a contains at least 4 and at most 106 characters.

Output

Print a number in the decimal notation without leading zeroes — the result of the permutation.

If it is impossible to rearrange the digits of the number a in the required manner, print 0.

Examples

Input

1689

Output

1869

Input

18906

Output

18690

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long n, m;
map<int, int> rt;
string t;
long ry = 0;
string p[] = {"1869", "6198", "1896", "9186", "9168", "6189", "8691"};
void df(int k) {
  for (int i = 1; i <= rt[k]; ++i) {
    ry = (ry * 10 + k) % 7;
    cout << k;
  }
}
int main() {
  cin >> t;
  for (int k = 0; k < t.size(); ++k) {
    rt[t[k] - '0']++;
  }
  --rt[1];
  --rt[6];
  --rt[8];
  --rt[9];
  for (int k = 1; k <= 9; ++k) df(k);
  cout << p[ry];
  df(0);
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

The goal of the 15 puzzle problem is to complete pieces on $4 \times 4$ cells where one of the cells is empty space.

In this problem, the space is represented by 0 and pieces are represented by integers from 1 to 15 as shown below.

1 2 3 4
6 7 8 0
5 10 11 12
9 13 14 15

You can move a piece toward the empty space at one step. Your goal is to make the pieces the following configuration in the shortest move (fewest steps).

1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 0

Write a program which reads an initial state of the puzzle and prints the fewest steps to solve the puzzle.

Constraints

* The given puzzle is solvable in at most 45 steps.

Input

The $4 \times 4$ integers denoting the pieces or space are given.

Output

Print the fewest steps in a line.

Example

Input

1 2 3 4
6 7 8 0
5 10 11 12
9 13 14 15

Output

8

### Response

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

static const int N = 4;
static const int N2 = 16;
static const int LIMIT = 100;

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle{
    int f[N2], space, MD;
};

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz){
    int sum = 0;
    for(int i = 0; i < N2; i++){
        if(pz.f[i] == N2) continue;
        sum += MDT[i][pz.f[i]-1];
    }
    return sum;
}

bool dfs(int depth, int prev){

    if(state.MD == 0) return true;
    if(depth + state.MD > limit) return false;
    int sx = state.space / N;
    int sy = state.space % N;
    Puzzle tmp;

    for(int r = 0; r < 4; r++){
        int tx = sx + dx[r];
        int ty = sy + dy[r];
        if(tx < 0 || ty < 0 || tx >= N || ty >= N){
            continue;
        }
        if(std::max(prev, r) - std::min(prev, r) == 2) continue;
        tmp = state;
        state.MD -= MDT[tx*N+ty][state.f[tx*N+ty]-1];
        state.MD += MDT[sx*N+sy][state.f[tx*N+ty]-1];
        std::swap(state.f[tx*N+ty], state.f[sx*N+sy]);
        state.space = tx * N + ty;
        if(dfs(depth + 1, r)){
            path[depth] = r;
            return true;
        }
        state = tmp;
    }

    return false;

}

std::string iterative_deepning(Puzzle in){
    in.MD = getAllMD(in);

    for(limit = in.MD; limit <= LIMIT; limit++){
        state = in;
        if(dfs(0, -100)){
            std::string ans = "";
            for(int i = 0; i < limit; i++) ans += dir[path[i]];
            return ans;
        }
    }

    return "unsolvable";
}

int main(void){
    for(int i = 0; i < N2; i++){
        for(int j = 0; j < N2; j++){
            MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
        }
    }

    Puzzle in;

    for(int i = 0; i < N2; i++){
        std::cin >> in.f[i];
        if(in.f[i] == 0){
            in.f[i] = N2;
            in.space = i;
        }
    }

    std::string ans = iterative_deepning(in);
    std::cout << ans.size() << std::endl;

    return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

The Tower of Hanoi is a well-known mathematical puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.

The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules:

  1. Only one disk can be moved at a time.
  2. Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack.
  3. No disk may be placed on top of a smaller disk.

With three disks, the puzzle can be solved in seven moves. The minimum number of moves required to solve a Tower of Hanoi puzzle is 2n - 1, where n is the number of disks. (c) Wikipedia.

SmallY's puzzle is very similar to the famous Tower of Hanoi. In the Tower of Hanoi puzzle you need to solve a puzzle in minimum number of moves, in SmallY's puzzle each move costs some money and you need to solve the same puzzle but for minimal cost. At the beginning of SmallY's puzzle all n disks are on the first rod. Moving a disk from rod i to rod j (1 ≤ i, j ≤ 3) costs tij units of money. The goal of the puzzle is to move all the disks to the third rod.

In the problem you are given matrix t and an integer n. You need to count the minimal cost of solving SmallY's puzzle, consisting of n disks.

Input

Each of the first three lines contains three integers — matrix t. The j-th integer in the i-th line is tij (1 ≤ tij ≤ 10000; i ≠ j). The following line contains a single integer n (1 ≤ n ≤ 40) — the number of disks.

It is guaranteed that for all i (1 ≤ i ≤ 3), tii = 0.

Output

Print a single integer — the minimum cost of solving SmallY's puzzle.

Examples

Input

0 1 1
1 0 1
1 1 0
3

Output

7

Input

0 2 2
1 0 100
1 2 0
3

Output

19

Input

0 2 1
1 0 100
1 2 0
5

Output

87

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
long long t[3][3];
long long mat[41][3][3][3];
long long compute(int n, int i, int j, int k) {
  if (mat[n][i][j][k] != -1) return mat[n][i][j][k];
  if (n == 1) {
    mat[n][i][j][k] =
        ((t[i][j]) < (t[i][k] + t[k][j]) ? (t[i][j]) : (t[i][k] + t[k][j]));
    return mat[n][i][j][k];
  }
  long long a = ((compute(n - 1, i, k, j)) <
                         (compute(n - 1, i, j, k) + compute(n - 1, j, k, i))
                     ? (compute(n - 1, i, k, j))
                     : (compute(n - 1, i, j, k) + compute(n - 1, j, k, i)));
  a += t[i][j];
  a += ((compute(n - 1, k, j, i)) <
                (compute(n - 1, k, i, j) + compute(n - 1, i, j, k))
            ? (compute(n - 1, k, j, i))
            : (compute(n - 1, k, i, j) + compute(n - 1, i, j, k)));
  long long b = ((compute(n - 1, i, j, k)) <
                         (compute(n - 1, i, k, j) + compute(n - 1, k, j, i))
                     ? (compute(n - 1, i, j, k))
                     : (compute(n - 1, i, k, j) + compute(n - 1, k, j, i)));
  b += t[i][k] + t[k][j];
  b += compute(n - 1, j, i, k) +
       ((compute(n - 1, i, j, k)) <
                (compute(n - 1, i, k, j) + compute(n - 1, k, j, i))
            ? (compute(n - 1, i, j, k))
            : (compute(n - 1, i, k, j) + compute(n - 1, k, j, i)));
  mat[n][i][j][k] = ((a) < (b) ? (a) : (b));
  return mat[n][i][j][k];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  for (int i = 0; i < 41; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        for (int l = 0; l < 3; l++) {
          mat[i][j][k][l] = -1;
        }
      }
    }
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> t[i][j];
    }
  }
  int n;
  cin >> n;
  cout << compute(n, 0, 2, 1) << "\n";
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

In order to ensure confidentiality, the access to the "Russian Code Cup" problems is password protected during the problem development process.

To select a password, the jury can generate a special table that contains n columns and the infinite number of rows. To construct a table, the first row is fixed, and all the others are obtained by the following rule:

In the row i at position p there is a number equal to the number of times a[i - 1][p] occurs on the prefix a[i - 1][1... p].

To ensure the required level of confidentiality, the jury must be able to perform the following operations:

  * Replace number a[1][p] by v and rebuild the table.
  * Find the number a[x][y], which will be the new password.

Doing all these steps manually is very tedious, so the jury asks you to help him. Write a program that responds to the request of the jury.

Input

The first line contains an integer n (1 ≤ n ≤ 100000) — the number of columns. The second line contains the description of the first row of the table, that is, n integers, which are not less than 1 and do not exceed 109.

The third line of the input contains an integer m (1 ≤ m ≤ 100000) — the number of requests.

Next, each row contains a description of the request, which consists of three integers:

  * If the first number is equal to 1, then the remaining two numbers are v, p (1 ≤ v ≤ 109; 1 ≤ p ≤ n). So, you should put value v in the position p in the first row.
  * If the first number is equal to 2, then the remaining two numbers are x, y (1 ≤ x ≤ 105; 1 ≤ y ≤ n) — the row and column of the table cell from which you want to get value.

Output

Print an answer for each request of the second type in the order you receive them.

Examples

Input

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

Output

2
1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void read(_T &f) {
  f = 0;
  _T fu = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') {
      fu = -1;
    }
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    f = (f << 3) + (f << 1) + (c & 15);
    c = getchar();
  }
  f *= fu;
}
template <typename T>
void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + 48);
  else
    print(x / 10), putchar(x % 10 + 48);
}
template <typename T>
void print(T x, char t) {
  print(x);
  putchar(t);
}
const int N = 1e5 + 5, B = 310;
vector<int> pos[N * 2], big;
unordered_map<int, int> id;
int a[N], lc[N * 40], rc[N * 40], sum[N * 40], rt[N * 2], root[B + 5],
    tag[N * 2], rub[N * 40];
int n, m, tot, cnt_id, top;
inline int newNode() {
  if (top) {
    int u = rub[top];
    --top;
    lc[u] = rc[u] = 0;
    return u;
  }
  return ++tot;
}
void add(int &u, int l, int r, int x, int y) {
  if (!u) u = newNode();
  sum[u] += y;
  if (l == r) {
    if (!sum[u]) rub[++top] = u, u = 0;
    return;
  }
  int mid = (l + r) >> 1;
  if (mid >= x)
    add(lc[u], l, mid, x, y);
  else
    add(rc[u], mid + 1, r, x, y);
  if (!sum[u]) rub[++top] = u, u = 0;
}
int query(int u, int l, int r, int x) {
  if (!u) return 0;
  if (r <= x) return sum[u];
  int mid = (l + r) >> 1, ans = query(lc[u], l, mid, x);
  if (mid + 1 <= x) ans += query(rc[u], mid + 1, r, x);
  return ans;
}
void add(int x, int y) {
  if (!id.count(x)) id[x] = ++cnt_id;
  x = id[x];
  add(rt[x], 1, n, y, 1);
  if (!tag[x] && (int)pos[x].size() + 1 > B) {
    for (int i = 0; i <= B; i++) add(root[i], 1, n, pos[x][i], -1);
    tag[x] = 1;
    big.push_back(x);
  }
  if (tag[x]) return;
  pos[x].push_back(y);
  int tmp = (int)pos[x].size() - 1;
  while (tmp && pos[x][tmp - 1] > pos[x][tmp]) {
    add(root[tmp - 1], 1, n, pos[x][tmp - 1], -1);
    add(root[tmp], 1, n, pos[x][tmp - 1], 1);
    swap(pos[x][tmp - 1], pos[x][tmp]);
    --tmp;
  }
  add(root[tmp], 1, n, y, 1);
}
void del(int x, int y) {
  x = id[x];
  add(rt[x], 1, n, y, -1);
  if (tag[x]) return;
  int tmp = lower_bound(pos[x].begin(), pos[x].end(), y) - pos[x].begin();
  add(root[tmp], 1, n, y, -1);
  while (tmp < (int)pos[x].size() - 1) {
    add(root[tmp + 1], 1, n, pos[x][tmp + 1], -1);
    add(root[tmp], 1, n, pos[x][tmp + 1], 1);
    swap(pos[x][tmp], pos[x][tmp + 1]);
    ++tmp;
  }
  pos[x].pop_back();
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]), add(a[i], i);
  read(m);
  while (m--) {
    int opt;
    read(opt);
    if (opt == 1) {
      int x, y;
      read(y);
      read(x);
      del(a[x], x);
      a[x] = y;
      add(a[x], x);
    }
    if (opt == 2) {
      int x, y;
      read(x);
      read(y);
      if (x == 1)
        print(a[y], '\n');
      else if (x & 1) {
        int rk = query(rt[id[a[y]]], 1, n, y), ans = 0;
        if (rk <= B + 1) ans += query(root[rk - 1], 1, n, y);
        for (int i = 0; i < (int)big.size(); i++) {
          int id = big[i];
          ans += (query(rt[id], 1, n, y) >= rk);
        }
        print(ans, '\n');
      } else {
        print(query(rt[id[a[y]]], 1, n, y), '\n');
      }
    }
  }
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

Takahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.

First, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.

Then, Aoki gave him M queries. The i-th of them is as follows:

* Increment the number written at each edge along the path connecting vertices a_i and b_i, by one.

After Takahashi executed all of the queries, he told Aoki that, for every edge, the written number became an even number. However, Aoki forgot to confirm that the graph Takahashi created was actually a tree, and it is possible that Takahashi made a mistake in creating a tree or executing queries.

Determine whether there exists a tree that has the property mentioned by Takahashi.

Constraints

* 2 ≤ N ≤ 10^5
* 1 ≤ M ≤ 10^5
* 1 ≤ a_i,b_i ≤ N
* a_i ≠ b_i

Input

Input is given from Standard Input in the following format:

N M
a_1 b_1
:
a_M b_M

Output

Print `YES` if there exists a tree that has the property mentioned by Takahashi; print `NO` otherwise.

Examples

Input

4 4
1 2
2 4
1 3
3 4

Output

YES

Input

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

Output

NO

### Response

```cpp
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n , m;
int a , b;
int deg[N];
int main(){
	scanf("%d %d" , &n , &m);
	for(int i = 1 ; i <= m ; ++i){
		scanf("%d %d" , &a , &b);
		deg[a] ^= 1;
		deg[b] ^= 1;
	}
	puts(*max_element(deg + 1 , deg + 1 + n) ? "NO" : "YES");
}
```


### Prompt

Develop a solution in cpp to the problem described below:

Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the sea. The airplane has n rows, each of them has 8 seats. We call two seats neighbor, if they are in the same row and in seats {1, 2}, {3, 4}, {4, 5}, {5, 6} or {7, 8}.

<image> A row in the airplane

Daenerys Targaryen wants to place her army in the plane so that there are no two soldiers from different groups sitting on neighboring seats.

Your task is to determine if there is a possible arranging of her army in the airplane such that the condition above is satisfied.

Input

The first line contains two integers n and k (1 ≤ n ≤ 10000, 1 ≤ k ≤ 100) — the number of rows and the number of groups of soldiers, respectively.

The second line contains k integers a1, a2, a3, ..., ak (1 ≤ ai ≤ 10000), where ai denotes the number of soldiers in the i-th group.

It is guaranteed that a1 + a2 + ... + ak ≤ 8·n.

Output

If we can place the soldiers in the airplane print "YES" (without quotes). Otherwise print "NO" (without quotes).

You can choose the case (lower or upper) for each letter arbitrary.

Examples

Input

2 2
5 8

Output

YES

Input

1 2
7 1

Output

NO

Input

1 2
4 4

Output

YES

Input

1 4
2 2 1 2

Output

YES

Note

In the first sample, Daenerys can place the soldiers like in the figure below:

<image>

In the second sample, there is no way to place the soldiers in the plane since the second group soldier will always have a seat neighboring to someone from the first group.

In the third example Daenerys can place the first group on seats (1, 2, 7, 8), and the second group an all the remaining seats.

In the fourth example she can place the first two groups on seats (1, 2) and (7, 8), the third group on seats (3), and the fourth group on seats (5, 6).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, k, m, s2, s4, s1, er = 2;
long long a[110];
bool cmp(int aa, int bb) { return aa > bb; }
long long T;
int main() {
  T = 1;
  while (T--) {
    scanf("%d%d", &n, &k);
    s2 = n * 2;
    s4 = n;
    s1 = 0;
    for (int i = 1; i <= k; i++) scanf("%d", &a[i]);
    sort(a + 1, a + k + 1, cmp);
    for (int i = 1; i <= k; i++) {
      if (a[i] >= 4) m = min(a[i] / 4, s4), s4 -= m, a[i] -= (m * 4);
      if (a[i] == 3 && s4 > 0) s4 -= 1, a[i] -= 3;
      if (a[i] >= 2) m = min((a[i]) / 2, s2), s2 -= m, a[i] -= m * 2;
      if (a[i] > 0) {
        if (s1 > 0 && a[i] == 1)
          while (s1 > 0 && a[i] > 0) a[i]--, s1--;
        if (a[i] == 0) continue;
        if (s4 > 0) {
          if (a[i] == 2)
            s4--, s1++, a[i] = 0;
          else if (a[i] == 1)
            s4--, s2++, a[i]--;
        }
        if (s2 > 0 && a[i] > 0) s2--, m = min(a[i], er), a[i] = a[i] - m;
        if (a[i] > 0 && s1 > 0)
          while (a[i] && s1) s1--, a[i]--;
        if (a[i] <= 0) continue;
        printf("NO\n");
        return 0;
      }
    }
    printf("YES\n");
  }
  return 0;
}

```


### Prompt

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

Bearland has n cities, numbered 1 through n. There are m bidirectional roads. The i-th road connects two distinct cities ai and bi. No two roads connect the same pair of cities. It's possible to get from any city to any other city (using one or more roads).

The distance between cities a and b is defined as the minimum number of roads used to travel between a and b.

Limak is a grizzly bear. He is a criminal and your task is to catch him, or at least to try to catch him. You have only two days (today and tomorrow) and after that Limak is going to hide forever.

Your main weapon is BCD (Bear Criminal Detector). Where you are in some city, you can use BCD and it tells you the distance between you and a city where Limak currently is. Unfortunately, BCD can be used only once a day.

You don't know much about Limak's current location. You assume that he is in one of n cities, chosen uniformly at random (each city with probability <image>). You decided for the following plan:

  1. Choose one city and use BCD there.
    * After using BCD you can try to catch Limak (but maybe it isn't a good idea). In this case you choose one city and check it. You win if Limak is there. Otherwise, Limak becomes more careful and you will never catch him (you loose).
  2. Wait 24 hours to use BCD again. You know that Limak will change his location during that time. In detail, he will choose uniformly at random one of roads from his initial city, and he will use the chosen road, going to some other city.
  3. Tomorrow, you will again choose one city and use BCD there.
  4. Finally, you will try to catch Limak. You will choose one city and check it. You will win if Limak is there, and loose otherwise.

Each time when you choose one of cities, you can choose any of n cities. Let's say it isn't a problem for you to quickly get somewhere.

What is the probability of finding Limak, if you behave optimally?

Input

The first line of the input contains two integers n and m (2 ≤ n ≤ 400, <image>) — the number of cities and the number of roads, respectively.

Then, m lines follow. The i-th of them contains two integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — cities connected by the i-th road.

No two roads connect the same pair of cities. It's possible to get from any city to any other city.

Output

Print one real number — the probability of finding Limak, if you behave optimally. Your answer will be considered correct if its absolute error does not exceed 10 - 6.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct if |a - b| ≤ 10 - 6.

Examples

Input

3 3
1 2
1 3
2 3

Output

0.833333333333

Input

5 4
1 2
3 1
5 1
1 4

Output

1.000000000000

Input

4 4
1 2
1 3
2 3
1 4

Output

0.916666666667

Input

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

Output

0.900000000000

Note

In the first sample test, there are three cities and there is a road between every pair of cities. Let's analyze one of optimal scenarios.

  1. Use BCD in city 1.
    * With probability <image> Limak is in this city and BCD tells you that the distance is 0. You should try to catch him now and you win for sure.
    * With probability <image> the distance is 1 because Limak is in city 2 or city 3. In this case you should wait for the second day.
  2. You wait and Limak moves to some other city.
    * There is probability <image> that Limak was in city 2 and then went to city 3.
    * <image> that he went from 2 to 1.
    * <image> that he went from 3 to 2.
    * <image> that he went from 3 to 1.
  3. Use BCD again in city 1 (though it's allowed to use it in some other city).
    * If the distance is 0 then you're sure Limak is in this city (you win).
    * If the distance is 1 then Limak is in city 2 or city 3. Then you should guess that he is in city 2 (guessing city 3 would be fine too).

You loose only if Limak was in city 2 first and then he moved to city 3. The probability of loosing is <image>. The answer is <image>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct outputer;
struct outputable {};
const double pi = acos(double(-1));
template <typename T>
inline auto sqr(T x) -> decltype(x * x) {
  return x * x;
}
template <typename T1, typename T2>
inline bool umx(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool umn(T1& a, T2 b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 400;
struct Input {
  int n;
  vector<int> e[N];
  bool read() {
    int m;
    if (!(cin >> n >> m)) {
      return 0;
    }
    for (int i = int(0); i < int(m); ++i) {
      int x, y;
      scanf("%d%d", &x, &y);
      --x;
      --y;
      e[x].emplace_back(y);
      e[y].emplace_back(x);
    }
    return 1;
  }
  void init(const Input& input) { *this = input; }
};
struct Data : Input {
  double ans;
  void write() { cout << ans << endl; }
};
namespace Main {
struct Solution : Data {
  int d[N][N];
  double a[N + 2], cur_a[N + 2];
  double b[N + 2][N];
  double c[N][3];
  void solve() {
    ;
    for (int i = int(0); i < int(n); ++i) {
      for (int j = int(0); j < int(n); ++j) {
        d[i][j] = N;
      }
    }
    for (int i = int(0); i < int(n); ++i) {
      d[i][i] = 0;
      for (int j = int(0); j < int(((int)(e[i]).size())); ++j) {
        d[i][e[i][j]] = 1;
      }
    }
    for (int i = int(0); i < int(n); ++i) {
      for (int j = int(0); j < int(n); ++j) {
        for (int k = int(0); k < int(n); ++k) {
          umn(d[j][k], d[j][i] + d[i][k]);
        }
      }
    }
    ans = 0;
    memset(b, 0, sizeof b);
    for (int i = int(0); i < int(n); ++i) {
      ;
      ;
      ;
      double cur = 0;
      memset(a, 0, sizeof a);
      for (int j = int(0); j < int(n); ++j) {
        int l1 = d[i][j] + 1;
        cur -= a[l1];
        umx(a[l1], double(1) / n);
        cur += a[l1];
      };
      ;
      memset(c, 0, sizeof c);
      for (int j = int(0); j < int(n); ++j) {
        for (int k : e[j]) {
          c[k][d[i][j] + 1 - d[i][k]] += double(1) / (n * ((int)(e[j]).size()));
        }
      }
      for (int j = int(0); j < int(n); ++j) {
        ;
      }
      for (int j = int(0); j < int(n); ++j) {
        memset(cur_a, 0, sizeof cur_a);
        ;
        ;
        for (int k = int(0); k < int(n); ++k) {
          for (int t = int(0); t < int(3); ++t) {
            int l1 = d[i][k] + t;
            int l2 = d[j][k];
            ;
            cur_a[l1] -= b[l1][l2];
            umx(b[l1][l2], c[k][t]);
            cur_a[l1] += b[l1][l2];
            cur -= a[l1];
            umx(a[l1], cur_a[l1]);
            cur += a[l1];
          }
        }
        for (int k = int(0); k < int(n + 2); ++k) {
          ;
        }
        for (int k = int(0); k < int(n); ++k) {
          for (int t = int(0); t < int(3); ++t) {
            int l1 = d[i][k] + t;
            int l2 = d[j][k];
            b[l1][l2] = 0;
          }
        }
      };
      ;
      umx(ans, cur);
    }
  }
  void clear() { *this = Solution(); }
};
}  // namespace Main
Main::Solution sol;
int main() {
  cout.setf(ios::showpoint | ios::fixed);
  cout.precision(20);
  sol.read();
  sol.solve();
  sol.write();
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

One day n cells of some array decided to play the following game. Initially each cell contains a number which is equal to it's ordinal number (starting from 1). Also each cell determined it's favourite number. On it's move i-th cell can exchange it's value with the value of some other j-th cell, if |i - j| = di, where di is a favourite number of i-th cell. Cells make moves in any order, the number of moves is unlimited.

The favourite number of each cell will be given to you. You will also be given a permutation of numbers from 1 to n. You are to determine whether the game could move to this state.

Input

The first line contains positive integer n (1 ≤ n ≤ 100) — the number of cells in the array. The second line contains n distinct integers from 1 to n — permutation. The last line contains n integers from 1 to n — favourite numbers of the cells.

Output

If the given state is reachable in the described game, output YES, otherwise NO.

Examples

Input

5
5 4 3 2 1
1 1 1 1 1

Output

YES

Input

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

Output

NO

Input

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

Output

YES

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, a[105], bk[105], tot, q[105];
bool f[105][105];
inline void bfs(int x) {
  q[0] = x;
  int h = 0, t = 1;
  while (h < t) {
    for (int i = 1; i <= n; i++) {
      if (!f[i][q[h]] || bk[i]) continue;
      bk[i] = tot;
      q[t++] = i;
    }
    h++;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    int d;
    scanf("%d", &d);
    if (i > d) f[i - d][i] = f[i][i - d] = 1;
    if (i + d <= n) f[i + d][i] = f[i][i + d] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (bk[i]) continue;
    bk[i] = ++tot;
    bfs(i);
  }
  for (int i = 1; i <= n; i++)
    if (bk[i] != bk[a[i]]) {
      puts("NO");
      return 0;
    }
  puts("YES");
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Once little Vasya read an article in a magazine on how to make beautiful handmade garland from colored paper. Vasya immediately went to the store and bought n colored sheets of paper, the area of each sheet is 1 square meter.

The garland must consist of exactly m pieces of colored paper of arbitrary area, each piece should be of a certain color. To make the garland, Vasya can arbitrarily cut his existing colored sheets into pieces. Vasya is not obliged to use all the sheets to make the garland.

Vasya wants the garland to be as attractive as possible, so he wants to maximize the total area of m pieces of paper in the garland. Calculate what the maximum total area of the pieces of paper in the garland Vasya can get.

Input

The first line contains a non-empty sequence of n (1 ≤ n ≤ 1000) small English letters ("a"..."z"). Each letter means that Vasya has a sheet of paper of the corresponding color.

The second line contains a non-empty sequence of m (1 ≤ m ≤ 1000) small English letters that correspond to the colors of the pieces of paper in the garland that Vasya wants to make.

Output

Print an integer that is the maximum possible total area of the pieces of paper in the garland Vasya wants to get or -1, if it is impossible to make the garland from the sheets he's got. It is guaranteed that the answer is always an integer.

Examples

Input

aaabbac
aabbccac

Output

6

Input

a
z

Output

-1

Note

In the first test sample Vasya can make an garland of area 6: he can use both sheets of color b, three (but not four) sheets of color a and cut a single sheet of color c in three, for example, equal pieces. Vasya can use the resulting pieces to make a garland of area 6.

In the second test sample Vasya cannot make a garland at all — he doesn't have a sheet of color z.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int c = 0;
  string s, t, k;
  cin >> t >> s;
  k = t;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < t.size(); j++) {
      if (s[i] == t[j]) {
        c++;
        t.erase(j, 1);
        break;
      } else if (!(k.find(s[i]) != -1)) {
        cout << -1;
        return 0;
      }
    }
  }
  cout << c;
  return 0;
}

```


### Prompt

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

There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i).

We will repeat the following operation as long as possible:

* Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position.

We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.

Constraints

* 1 \leq N \leq 10^5
* 1 \leq x_i, y_i \leq 10^5
* If i \neq j, x_i \neq x_j or y_i \neq y_j.
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
:
x_N y_N

Output

Print the maximum number of times we can do the operation.

Examples

Input

3
1 1
5 1
5 5

Output

1

Input

2
10 10
20 20

Output

0

Input

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

Output

16

### Response

```cpp

#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=1e18;
vector<vector<ll>>x(100005);
vector<vector<ll>>y(100005);
vector<vector<ll>> used(2, vector<ll> (100005,0));
ll cx,cy;

void dfs(int t, int n){
  if (used[n][t]==1)return;
  used[n][t]=1;
  if (n==0){
    cx++;
    n++;
    n%=2;
  //  cout<<"t"<<t<<"cx"<<cx<<endl;
    for (ll to:x[t]){

      dfs(to,n);
    //  return;

    }
  }
  else if(n==1){
    cy++;
  //  cout<<"t"<<t<<"cy"<<cy<<endl;
  n++;
  n%=2;
    for (ll to:y[t]){

      dfs(to,n);
    //  return;

    }
  }
}

int main() {
  ll n;
  cin >> n;
  vector<P> v(n);

  rep(i,n){
    ll a1,b1;
    cin>>a1>>b1;
    v[i]=make_pair(a1,b1);
    x[a1].push_back(b1);
    y[b1].push_back(a1);
  }
ll ans=0;
  rep(i,n){
    cx=0;
    cy=0;
    dfs(v[i].first,0);
  //  cout<<"i"<<i<<cx<<" "<<cy<<endl;
    ans+=cx*cy;
  }

  ans-=n;
  cout<<ans;

}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai ≥ ai - 1 is met, so the sequence is sorted.

Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>).

Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously.

Input

The first line contains three integers n, k, x (1 ≤ k ≤ n ≤ 100, 1 ≤ x ≤ 99) — the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself.

The second line contains n integer numbers ai (2 ≤ ai ≤ 100) — the time Luba has to spend to do i-th chore.

It is guaranteed that <image>, and for each <image> ai ≥ ai - 1.

Output

Print one number — minimum time Luba needs to do all n chores.

Examples

Input

4 2 2
3 6 7 10

Output

13

Input

5 2 1
100 100 100 100 100

Output

302

Note

In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13.

In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100·3 + 2·1 = 302.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mxn = 1e6;
const int mod1 = 1e9 + 7;
const int mod2 = 998244353;
const long long inf = 1e18;
const double pi = 3.1415926535897932384626;
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
long long mpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long inv(long long a, long long m) { return mpow(a, m - 2, m); }
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long ncr(long long n, long long k) {
  if (n < k) return 0;
  long long C[n + 1][k + 1];
  long long i, j;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= min(i, k); j++) {
      if (j == 0 || j == i)
        C[i][j] = 1;
      else
        C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
    }
  }
  return C[n][k];
}
void solve() {
  int n, k, x;
  cin >> n >> k >> x;
  int c = k * x;
  int p = n - k;
  int a[n], sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < p; i++) {
    sum += a[i];
  }
  cout << sum + c;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  clock_t start, end;
  start = clock();
  solve();
  end = clock();
  double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
  cerr << "\nTime : " << fixed << time_taken << setprecision(5) << " s \n";
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

You are given a huge decimal number consisting of n digits. It is guaranteed that this number has no leading zeros. Each digit of this number is either 0 or 1.

You may perform several (possibly zero) operations with this number. During each operation you are allowed to change any digit of your number; you may change 0 to 1 or 1 to 0. It is possible that after some operation you can obtain a number with leading zeroes, but it does not matter for this problem.

You are also given two integers 0 ≤ y < x < n. Your task is to calculate the minimum number of operations you should perform to obtain the number that has remainder 10^y modulo 10^x. In other words, the obtained number should have remainder 10^y when divided by 10^x.

Input

The first line of the input contains three integers n, x, y (0 ≤ y < x < n ≤ 2 ⋅ 10^5) — the length of the number and the integers x and y, respectively.

The second line of the input contains one decimal number consisting of n digits, each digit of this number is either 0 or 1. It is guaranteed that the first digit of the number is 1.

Output

Print one integer — the minimum number of operations you should perform to obtain the number having remainder 10^y modulo 10^x. In other words, the obtained number should have remainder 10^y when divided by 10^x.

Examples

Input

11 5 2
11010100101

Output

1

Input

11 5 1
11010100101

Output

3

Note

In the first example the number will be 11010100100 after performing one operation. It has remainder 100 modulo 100000.

In the second example the number will be 11010100010 after performing three operations. It has remainder 10 modulo 100000.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int main() {
  int n, x, y, ans = 0;
  cin >> n >> x >> y;
  string s;
  cin >> s;
  for (int i = n - x; i < n; i++) {
    if (i == n - 1 - y) {
      if (s[i] != '1') ans++;
    } else {
      if (s[i] != '0') ans++;
    }
  }
  cout << ans;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Valera has n counters numbered from 1 to n. Some of them are connected by wires, and each of the counters has a special button.

Initially, all the counters contain number 0. When you press a button on a certain counter, the value it has increases by one. Also, the values recorded in all the counters, directly connected to it by a wire, increase by one.

Valera and Ignat started having a dispute, the dispute is as follows. Ignat thought of a sequence of n integers a1, a2, ..., an. Valera should choose some set of distinct counters and press buttons on each of them exactly once (on other counters the buttons won't be pressed). If after that there is a counter with the number i, which has value ai, then Valera loses the dispute, otherwise he wins the dispute.

Help Valera to determine on which counters he needs to press a button to win the dispute.

Input

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 105), that denote the number of counters Valera has and the number of pairs of counters connected by wires.

Each of the following m lines contains two space-separated integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi), that mean that counters with numbers ui and vi are connected by a wire. It is guaranteed that each pair of connected counters occurs exactly once in the input.

The last line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 105), where ai is the value that Ignat choose for the i-th counter.

Output

If Valera can't win the dispute print in the first line -1.

Otherwise, print in the first line integer k (0 ≤ k ≤ n). In the second line print k distinct space-separated integers — the numbers of the counters, where Valera should push buttons to win the dispute, in arbitrary order.

If there exists multiple answers, you are allowed to print any of them.

Examples

Input

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

Output

2
1 2

Input

4 2
1 2
3 4
0 0 0 0

Output

3
1 3 4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXX = 1e6;
vector<int> vec[MAXX], ans;
int c[MAXX], cnt[MAXX];
queue<int> qu;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i <= n; i++)
    if (c[i] == cnt[i]) qu.push(i);
  while (qu.size() > 0) {
    int v = qu.front();
    qu.pop();
    if (cnt[v] != c[v]) continue;
    cnt[v]++;
    ans.push_back(v);
    for (int i = 0; i < vec[v].size(); i++) {
      int u = vec[v][i];
      cnt[u]++;
      if (cnt[u] == c[u]) qu.push(u);
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Lindsey Buckingham told Stevie Nicks ["Go your own way"](https://www.youtube.com/watch?v=6ul-cZyuYq4). Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.

Consider a hexagonal tiling of the plane as on the picture below.

<image>

Nicks wishes to go from the cell marked (0, 0) to a certain cell given by the coordinates. She may go from a hexagon to any of its six neighbors you want, but there is a cost associated with each of them. The costs depend only on the direction in which you travel. Going from (0, 0) to (1, 1) will take the exact same cost as going from (-2, -1) to (-1, 0). The costs are given in the input in the order c_1, c_2, c_3, c_4, c_5, c_6 as in the picture below.

<image>

Print the smallest cost of a path from the origin which has coordinates (0, 0) to the given cell.

Input

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

The first line of each test case contains two integers x and y (-10^{9} ≤ x, y ≤ 10^{9}) representing the coordinates of the target hexagon.

The second line of each test case contains six integers c_1, c_2, c_3, c_4, c_5, c_6 (1 ≤ c_1, c_2, c_3, c_4, c_5, c_6 ≤ 10^{9}) representing the six costs of the making one step in a particular direction (refer to the picture above to see which edge is for each value).

Output

For each testcase output the smallest cost of a path from the origin to the given cell.

Example

Input

2
-3 1
1 3 5 7 9 11
1000000000 1000000000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

Output

18
1000000000000000000

Note

The picture below shows the solution for the first sample. The cost 18 is reached by taking c_3 3 times and c_2 once, amounting to 5+5+5+3=18.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll c[10];
int dx[] = {1, 0, -1, -1, 0, 1};
int dy[] = {1, 1, 0, -1, -1, 0};
int main() {
  int t;
  cin >> t;
  while (t--) {
    ll x, y;
    cin >> x >> y;
    for (int i = 0; i < 6; ++i) cin >> c[i];
    long long ans = 5e18;
    for (int i = 0; i < 6; ++i) {
      for (int j = i; j < 6; ++j) {
        int det = dx[i] * dy[j] - dx[j] * dy[i];
        if (det != 0) {
          long long t1 = (x * dy[j] - y * dx[j]) / det;
          long long t2 = (dx[i] * y - dy[i] * x) / det;
          if (t1 >= 0 && t2 >= 0) {
            ans = min(ans, t1 * c[i] + t2 * c[j]);
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

You are given string s consists of opening and closing brackets of four kinds <>, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace < by the bracket {, but you can't replace it by ) or >.

The following definition of a regular bracket sequence is well-known, so you can be familiar with it.

Let's define a regular bracket sequence (RBS). Empty string is RBS. Let s1 and s2 be a RBS then the strings <s1>s2, {s1}s2, [s1]s2, (s1)s2 are also RBS.

For example the string "[[(){}]<>]" is RBS, but the strings "[)()" and "][()()" are not.

Determine the least number of replaces to make the string s RBS.

Input

The only line contains a non empty string s, consisting of only opening and closing brackets of four kinds. The length of s does not exceed 106.

Output

If it's impossible to get RBS from s print Impossible.

Otherwise print the least number of replaces needed to get RBS from s.

Examples

Input

[<}){}

Output

2

Input

{()}[]

Output

0

Input

]]

Output

Impossible

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long sum = 0;
  stack<char> sol;
  string s;
  cin >> s;
  for (long long i = 0; i < s.length(); i++) {
    if (s[i] == '(' || s[i] == '{' || s[i] == '[' || s[i] == '<') {
      sol.push(s[i]);
    } else if (sol.empty()) {
      cout << "Impossible";
      return 0;
    } else if (s[i] == ')') {
      if (sol.top() == '(')
        sol.pop();
      else {
        sum++;
        sol.pop();
      }
    } else if (s[i] == '}') {
      if (sol.top() == '{')
        sol.pop();
      else {
        sum++;
        sol.pop();
      }
    } else if (s[i] == ']') {
      if (sol.top() == '[')
        sol.pop();
      else {
        sum++;
        sol.pop();
      }
    } else if (s[i] == '>') {
      if (sol.top() == '<')
        sol.pop();
      else {
        sum++;
        sol.pop();
      }
    }
  }
  if (sol.empty())
    cout << sum;
  else
    cout << "Impossible";
  return 0;
}

```


### Prompt

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

Koa the Koala has a binary string s of length n. Koa can perform no more than n-1 (possibly zero) operations of the following form:

In one operation Koa selects positions i and i+1 for some i with 1 ≤ i < |s| and sets s_i to max(s_i, s_{i+1}). Then Koa deletes position i+1 from s (after the removal, the remaining parts are concatenated).

Note that after every operation the length of s decreases by 1.

How many different binary strings can Koa obtain by doing no more than n-1 (possibly zero) operations modulo 10^9+7 (1000000007)?

Input

The only line of input contains binary string s (1 ≤ |s| ≤ 10^6). For all i (1 ≤ i ≤ |s|) s_i = 0 or s_i = 1.

Output

On a single line print the answer to the problem modulo 10^9+7 (1000000007).

Examples

Input

000

Output

3

Input

0101

Output

6

Input

0001111

Output

16

Input

00101100011100

Output

477

Note

In the first sample Koa can obtain binary strings: 0, 00 and 000.

In the second sample Koa can obtain binary strings: 1, 01, 11, 011, 101 and 0101. For example:

  * to obtain 01 from 0101 Koa can operate as follows: 0101 → 0(10)1 → 011 → 0(11) → 01.
  * to obtain 11 from 0101 Koa can operate as follows: 0101 → (01)01 → 101 → 1(01) → 11.

Parentheses denote the two positions Koa selected in each operation.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int md = 1000000007, MX = 1000100;
int n, m, i, lft, cur, sum, pos, a[MX];
long long rgh;
char s[MX];
bool was;
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (lft = rgh = -1, i = 0; i < n; i++)
    if (s[i] == '1') {
      was = true;
      rgh = i;
    } else if (!was)
      lft = i;
  if (!was) {
    printf("%d\n", n);
    return 0;
  }
  a[0] = sum = 1;
  for (i = lft + 1; i <= rgh; i++)
    if (s[i] == '0') {
      ++pos;
      sum = (sum + md - a[pos]) % md;
      a[pos] = cur;
      sum = (sum + a[pos]) % md;
    } else {
      cur = (cur + sum) % md;
      pos = 0;
    }
  cur = (cur * (lft + 2LL)) % md;
  cur = (cur * (n - rgh)) % md;
  printf("%d\n", cur);
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

You are given N items.
The value of the i-th item (1 \leq i \leq N) is v_i.
Your have to select at least A and at most B of these items.
Under this condition, find the maximum possible arithmetic mean of the values of selected items.
Additionally, find the number of ways to select items so that the mean of the values of selected items is maximized.

Constraints

* 1 \leq N \leq 50
* 1 \leq A,B \leq N
* 1 \leq v_i \leq 10^{15}
* Each v_i is an integer.

Input

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

N A B
v_1
v_2
...
v_N

Output

Print two lines.
The first line should contain the maximum possible arithmetic mean of the values of selected items. The output should be considered correct if the absolute or relative error is at most 10^{-6}.
The second line should contain the number of ways to select items so that the mean of the values of selected items is maximized.

Examples

Input

5 2 2
1 2 3 4 5

Output

4.500000
1

Input

4 2 3
10 20 10 10

Output

15.000000
3

Input

5 1 5
1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996

Output

1000000000000000.000000
1

### Response

```cpp

#include<cstdio>
#include<cmath>
#include<algorithm>
#define ll long long

using namespace std;

ll v[55];
ll ans=0;
void cnt(int a,int b){
	double sum=1;
	if(a>b/2)
		a=b-a;
	for(int i=b,j=1;i>=b-a+1;i--,j++){
		sum*=i*1.0/j;
	}
	ans+=sum;
}

bool cmp(ll a,ll b){
	return a>b;//从大到小排序
}

int main(){
	int n,min_,max_;
	scanf("%d %d %d",&n,&min_,&max_);
	for(int i=1;i<=n;i++){
		scanf("%lld",&v[i]);
	}

	sort(v+1,v+n+1,cmp);
	int num=min_;
	double ave=0;
	ave+=v[1];
	int same=1,dsam;
	for(int i=2;i<=min_;i++){
		ave+=v[i];
		if(v[i]==v[i-1]){
			same++;
		}
		else {
			same=1;
		}
	}
	ave/=num;//计算选最少的数时最大平均值
	dsam=min_-same;//已选择的不同的数

	for(int i=min_+1;v[i]==v[min_]&&i<=n;i++){
		same++;//已选择+未选择的相同的数
	}
	if(dsam==0){//如果所有的数都相同
		for(int k=min_;k<=max_;k++){
			if(k>same)
				break;
			cnt(k,same);
		}
	}
	else {
		cnt(min_-dsam,same);
	}
	printf("%.6lf\n%lld\n",ave,ans);
	return 0;
}
```


### Prompt

Develop a solution in Cpp to the problem described below:

A social network for dogs called DH (DogHouse) has k special servers to recompress uploaded videos of cute cats. After each video is uploaded, it should be recompressed on one (any) of the servers, and only after that it can be saved in the social network.

We know that each server takes one second to recompress a one minute fragment. Thus, any server takes m seconds to recompress a m minute video.

We know the time when each of the n videos were uploaded to the network (in seconds starting from the moment all servers started working). All videos appear at different moments of time and they are recompressed in the order they appear. If some video appeared at time s, then its recompressing can start at that very moment, immediately. Some videos can await recompressing when all the servers are busy. In this case, as soon as a server is available, it immediately starts recompressing another video. The videos that await recompressing go in a queue. If by the moment the videos started being recompressed some servers are available, then any of them starts recompressing the video.

For each video find the moment it stops being recompressed.

Input

The first line of the input contains integers n and k (1 ≤ n, k ≤ 5·105) — the number of videos and servers, respectively.

Next n lines contain the descriptions of the videos as pairs of integers si, mi (1 ≤ si, mi ≤ 109), where si is the time in seconds when the i-th video appeared and mi is its duration in minutes. It is guaranteed that all the si's are distinct and the videos are given in the chronological order of upload, that is in the order of increasing si.

Output

Print n numbers e1, e2, ..., en, where ei is the time in seconds after the servers start working, when the i-th video will be recompressed.

Examples

Input

3 2
1 5
2 5
3 5

Output

6
7
11

Input

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

Output

1000000001
2000000001
3000000001
4000000001
5000000001
5000000004

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline void read(long long &n) {
  char c;
  n = 0;
  long long x = 1;
  while (!isdigit(c = fgetc(stdin)) && c != '-')
    ;
  if (c == '-') x = -1, c = fgetc(stdin);
  while (isdigit(c)) n = n * 10 + c - '0', c = fgetc(stdin);
  n *= x;
}
inline void read(int &n) {
  long long x;
  read(x);
  n = x;
}
template <typename T1, typename T2>
inline void read(T1 &a, T2 &b) {
  read(a);
  read(b);
}
template <typename T1, typename T2, typename T3>
inline void read(T1 &a, T2 &b, T3 &c) {
  read(a);
  read(b);
  read(c);
}
template <typename T1, typename T2, typename T3, typename T4>
inline void read(T1 &a, T2 &b, T3 &c, T4 &d) {
  read(a);
  read(b);
  read(c);
  read(d);
}
priority_queue<long long> servers;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (__typeof(0) i = (0) - ((0) > (m)), a = (m) - ((0) > (m)); i != a;
       i += 1 - 2 * ((0) > (m)))
    servers.push(1);
  for (__typeof(0) i = (0) - ((0) > (n)), a = (n) - ((0) > (n)); i != a;
       i += 1 - 2 * ((0) > (n))) {
    int s, t;
    scanf("%d%d", &s, &t);
    long long e = max(-servers.top(), (long long)s + 1) + t - 1;
    servers.pop();
    servers.push(-(e + 1));
    printf("%I64d\n", e);
  }
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Andrew and Eugene are playing a game. Initially, Andrew has string s, consisting of digits. Eugene sends Andrew multiple queries of type "di → ti", that means "replace all digits di in string s with substrings equal to ti". For example, if s = 123123, then query "2 → 00" transforms s to 10031003, and query "3 → " ("replace 3 by an empty string") transforms it to s = 1212. After all the queries Eugene asks Andrew to find the remainder after division of number with decimal representation equal to s by 1000000007 (109 + 7). When you represent s as a decimal number, please ignore the leading zeroes; also if s is an empty string, then it's assumed that the number equals to zero.

Andrew got tired of processing Eugene's requests manually and he asked you to write a program for that. Help him!

Input

The first line contains string s (1 ≤ |s| ≤ 105), consisting of digits — the string before processing all the requests.

The second line contains a single integer n (0 ≤ n ≤ 105) — the number of queries.

The next n lines contain the descriptions of the queries. The i-th query is described by string "di->ti", where di is exactly one digit (from 0 to 9), ti is a string consisting of digits (ti can be an empty string). The sum of lengths of ti for all queries doesn't exceed 105. The queries are written in the order in which they need to be performed.

Output

Print a single integer — remainder of division of the resulting number by 1000000007 (109 + 7).

Examples

Input

123123
1
2->00

Output

10031003

Input

123123
1
3->

Output

1212

Input

222
2
2->0
0->7

Output

777

Input

1000000008
0

Output

1

Note

Note that the leading zeroes are not removed from string s after the replacement (you can see it in the third sample).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const long double pi = acos(-1.0);
int n;
int m;
const int mod = 1e9 + 7;
string s;
char buf[100100];
int a[10], b[10];
int v[100100][10];
string ss[100100];
int res[100100];
int len10[100100];
long long len[100100];
long long pow10(long long l) {
  long long res = 1, mul = 10;
  for (; l > 0; l >>= 1) {
    if (l & 1) res = (res * mul) % mod;
    mul = (mul * mul) % mod;
  }
  return res;
}
int main() {
  cin >> ss[0];
  scanf("%d\n", &n);
  for (int i = 1; i <= n; i++) {
    char ch;
    scanf("%c->", &ch);
    ch -= '0';
    gets(buf);
    ss[i] = buf;
    if (a[ch]) b[ch] = a[ch];
    a[ch] = i;
    for (int j = b[ch]; j < i; j++) v[j][ch] = i;
  }
  for (int i = n; i >= 0; i--) {
    long long l = 0;
    long long h = 0;
    for (int j = 0; j < ((int)(ss[i]).size()); j++) {
      int k = v[i][ss[i][j] - '0'];
      if (k) {
        h = h * len10[k] + res[k];
        l = (l + len[k]) % (mod - 1);
      } else {
        h = h * 10 + ss[i][j] - '0';
        l++;
      }
      h %= mod;
    }
    len[i] = l;
    len10[i] = pow10(l);
    res[i] = h;
  }
  printf("%d\n", res[0]);
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

You are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m).

Your task is to find a maximum sub-rectangle on the grid (x1, y1, x2, y2) so that it contains the given point (x, y), and its length-width ratio is exactly (a, b). In other words the following conditions must hold: 0 ≤ x1 ≤ x ≤ x2 ≤ n, 0 ≤ y1 ≤ y ≤ y2 ≤ m, <image>.

The sides of this sub-rectangle should be parallel to the axes. And values x1, y1, x2, y2 should be integers.

<image>

If there are multiple solutions, find the rectangle which is closest to (x, y). Here "closest" means the Euclid distance between (x, y) and the center of the rectangle is as small as possible. If there are still multiple solutions, find the lexicographically minimum one. Here "lexicographically minimum" means that we should consider the sub-rectangle as sequence of integers (x1, y1, x2, y2), so we can choose the lexicographically minimum one.

Input

The first line contains six integers n, m, x, y, a, b (1 ≤ n, m ≤ 109, 0 ≤ x ≤ n, 0 ≤ y ≤ m, 1 ≤ a ≤ n, 1 ≤ b ≤ m).

Output

Print four integers x1, y1, x2, y2, which represent the founded sub-rectangle whose left-bottom point is (x1, y1) and right-up point is (x2, y2).

Examples

Input

9 9 5 5 2 1

Output

1 3 9 7

Input

100 100 52 50 46 56

Output

17 8 86 92

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long qq;
long long l, mm, r;
long long lx, rx, ly, ry, ta, tb;
long long n, m, x, y, a, b;
long long span;
long long stepp;
long long gcd(long long a, long long b) {
  while (a && b) a > b ? a %= b : b %= a;
  return a + b;
}
bool cp(long long mid) {
  ta = mid * a;
  tb = mid * b;
  lx = max(0ll, x - ta);
  rx = min(n, x + ta);
  ly = max(0ll, y - tb);
  ry = min(m, y + tb);
  if (lx + ta <= rx && ly + tb <= ry) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> x >> y >> a >> b;
  qq = gcd(a, b);
  a /= qq;
  b /= qq;
  l = 0;
  r = 1000000000;
  while (l < r) {
    mm = l + r + 1;
    mm /= 2;
    if (cp(mm))
      l = mm;
    else
      r = mm - 1;
  }
  mm = cp(l);
  span = ta;
  rx -= ta;
  stepp = span / 2 + (span % 2 > 0);
  lx = min(rx, max(lx, x - stepp));
  span = tb;
  ry -= tb;
  stepp = span / 2 + (span % 2 > 0);
  ly = min(ry, max(ly, y - stepp));
  cout << lx << " " << ly << " " << lx + ta << " " << ly + tb << endl;
  cin.get();
  cin.get();
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

You are given $n$ packages of $w_i$ kg from a belt conveyor in order ($i = 0, 1, ... n-1$). You should load all packages onto $k$ trucks which have the common maximum load $P$. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load $P$.

Write a program which reads $n$, $k$ and $w_i$, and reports the minimum value of the maximum load $P$ to load all packages from the belt conveyor.

Constraints

* $1 \leq n \leq 100,000$
* $1 \leq k \leq 100,000$
* $1 \leq w_i \leq 10,000$

Input

In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.

Output

Print the minimum value of $P$ in a line.

Examples

Input

5 3
8
1
7
3
9

Output

10

Input

4 2
1
2
2
6

Output

6

### Response

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

int n, k;
long long int T[100000];
long long sum;
long long l;

int check(long long p) {
	int m = 0;
	for (int i = 0; i < k; i++) {
		long long s = 0;
		while (s + T[m] <= p) {
			s += T[m];
			m++;
			if (m >= n) {
				return n;
			}
		}
	}
	return m;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> T[i];
		sum += T[i];
	}
	l = sum / k;
	while (check(l) != n) {
		l++;
	}
	cout << l << endl;
	return 0;
}
```


### Prompt

Please create a solution in cpp to the following problem:

As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively.

Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertices of a graph, such that any two vertices of this subset are connected by an edge. In particular, an empty set of vertexes and a set consisting of a single vertex, are cliques.

Let's define a divisibility graph for a set of positive integers A = {a1, a2, ..., an} as follows. The vertices of the given graph are numbers from set A, and two numbers ai and aj (i ≠ j) are connected by an edge if and only if either ai is divisible by aj, or aj is divisible by ai.

You are given a set of non-negative integers A. Determine the size of a maximum clique in a divisibility graph for set A.

Input

The first line contains integer n (1 ≤ n ≤ 106), that sets the size of set A.

The second line contains n distinct positive integers a1, a2, ..., an (1 ≤ ai ≤ 106) — elements of subset A. The numbers in the line follow in the ascending order.

Output

Print a single number — the maximum size of a clique in a divisibility graph for set A.

Examples

Input

8
3 4 6 8 10 18 21 24

Output

3

Note

In the first sample test a clique of size 3 is, for example, a subset of vertexes {3, 6, 18}. A clique of a larger size doesn't exist in this graph.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[1100001];
bool x[1100001];
int dp[1100001];
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    x[a[i]] = true;
    dp[a[i]] = 1;
  }
  for (int i = 1; i <= 1000000; ++i) {
    if (x[i]) {
      for (int j = i + i; j <= 1000000; j += i)
        if (x[j]) dp[j] = max(dp[j], dp[i] + 1);
    }
  }
  int mx = 0;
  for (int i = 1; i <= 1000000; ++i) {
    mx = max(mx, dp[i]);
  }
  cout << mx;
  return 0;
}

```


### Prompt

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

You have been blessed as a child of Omkar. To express your gratitude, please solve this problem for Omkar!

An array a of length n is called complete if all elements are positive and don't exceed 1000, and for all indices x,y,z (1 ≤ x,y,z ≤ n), a_{x}+a_{y} ≠ a_{z} (not necessarily distinct).

You are given one integer n. Please find any complete array of length n. It is guaranteed that under given constraints such array exists.

Input

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

The only line of each test case contains one integer n (1 ≤ n ≤ 1000).

It is guaranteed that the sum of n over all test cases does not exceed 1000.

Output

For each test case, print a complete array on a single line. All elements have to be integers between 1 and 1000 and for all indices x,y,z (1 ≤ x,y,z ≤ n) (not necessarily distinct), a_{x}+a_{y} ≠ a_{z} must hold.

If multiple solutions exist, you may print any.

Example

Input

2
5
4

Output

1 5 3 77 12
384 384 44 44

Note

It can be shown that the outputs above are valid for each test case. For example, 44+44 ≠ 384.

Below are some examples of arrays that are NOT complete for the 1st test case:

[1,2,3,4,5]

Notice that a_{1}+a_{2} = a_{3}.

[1,3000,1,300,1]

Notice that a_{2} = 3000 > 1000.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int n;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cout << "1"
           << " ";
    }
    cout << endl;
  }
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

And here goes another problem on arrays. You are given positive integer len and array a which consists of n integers a1, a2, ..., an. Let's introduce two characteristics for the given array.

  * Let's consider an arbitrary interval of the array with length len, starting in position i. Value <image>, is the modular sum on the chosen interval. In other words, the modular sum is the sum of integers on the chosen interval with length len, taken in its absolute value.
  * Value <image> is the optimal sum of the array. In other words, the optimal sum of an array is the maximum of all modular sums on various intervals of array with length len.

Your task is to calculate the optimal sum of the given array a. However, before you do the calculations, you are allowed to produce no more than k consecutive operations of the following form with this array: one operation means taking an arbitrary number from array ai and multiply it by -1. In other words, no more than k times you are allowed to take an arbitrary number ai from the array and replace it with  - ai. Each number of the array is allowed to choose an arbitrary number of times.

Your task is to calculate the maximum possible optimal sum of the array after at most k operations described above are completed.

Input

The first line contains two integers n, len (1 ≤ len ≤ n ≤ 105) — the number of elements in the array and the length of the chosen subinterval of the array, correspondingly.

The second line contains a sequence consisting of n integers a1, a2, ..., an (|ai| ≤ 109) — the original array.

The third line contains a single integer k (0 ≤ k ≤ n) — the maximum allowed number of operations.

All numbers in lines are separated by a single space.

Output

In a single line print the maximum possible optimal sum after no more than k acceptable operations are fulfilled.

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

Examples

Input

5 3
0 -2 3 -5 1
2

Output

10

Input

5 2
1 -3 -10 4 1
3

Output

14

Input

3 3
-2 -5 4
1

Output

11

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, len, k, ans;
  cin >> n >> len;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> k;
  long long sum = 0, sumout = 0;
  multiset<long long> negout;
  multiset<long long> negin;
  for (int i = 0; i < len; i++) {
    sum += abs(a[i]);
    if (a[i] < 0) {
      if (negin.size() < k)
        negin.insert(abs(a[i]));
      else if (k && *negin.begin() < abs(a[i])) {
        sumout += *negin.begin();
        negout.insert(*negin.begin());
        negin.erase(negin.begin());
        negin.insert(abs(a[i]));
      } else {
        sumout += abs(a[i]);
        negout.insert(abs(a[i]));
      }
    }
  }
  ans = sum - 2 * sumout;
  multiset<long long>::iterator it;
  for (int j = len; j < n; j++) {
    sum -= abs(a[j - len]);
    if (a[j - len] < 0) {
      it = negout.find(abs(a[j - len]));
      if (it != negout.end()) {
        sumout -= abs(a[j - len]);
        negout.erase(it);
      } else {
        negin.erase(negin.find(abs(a[j - len])));
        if (negout.size()) {
          it = negout.end();
          it--;
          sumout -= *it;
          negin.insert(*it);
          negout.erase(it);
        }
      }
    }
    sum += abs(a[j]);
    if (a[j] < 0) {
      if (negin.size() < k)
        negin.insert(abs(a[j]));
      else if (k && *negin.begin() < abs(a[j])) {
        sumout += *negin.begin();
        negout.insert(*negin.begin());
        negin.erase(negin.begin());
        negin.insert(abs(a[j]));
      } else {
        sumout += abs(a[j]);
        negout.insert(abs(a[j]));
      }
    }
    ans = max(ans, sum - 2 * sumout);
  }
  for (int i = 0; i < n; i++) a[i] = -a[i];
  negout.clear();
  negin.clear();
  sum = 0;
  sumout = 0;
  for (int i = 0; i < len; i++) {
    sum += abs(a[i]);
    if (a[i] < 0) {
      if (negin.size() < k)
        negin.insert(abs(a[i]));
      else if (k && *negin.begin() < abs(a[i])) {
        sumout += *negin.begin();
        negout.insert(*negin.begin());
        negin.erase(negin.begin());
        negin.insert(abs(a[i]));
      } else {
        sumout += abs(a[i]);
        negout.insert(abs(a[i]));
      }
    }
  }
  ans = max(ans, sum - 2 * sumout);
  for (int j = len; j < n; j++) {
    sum -= abs(a[j - len]);
    if (a[j - len] < 0) {
      it = negout.find(abs(a[j - len]));
      if (it != negout.end()) {
        sumout -= abs(a[j - len]);
        negout.erase(it);
      } else {
        negin.erase(negin.find(abs(a[j - len])));
        if (negout.size()) {
          it = negout.end();
          it--;
          sumout -= *it;
          negin.insert(*it);
          negout.erase(it);
        }
      }
    }
    sum += abs(a[j]);
    if (a[j] < 0) {
      if (negin.size() < k)
        negin.insert(abs(a[j]));
      else if (k && *negin.begin() < abs(a[j])) {
        sumout += *negin.begin();
        negout.insert(*negin.begin());
        negin.erase(negin.begin());
        negin.insert(abs(a[j]));
      } else {
        sumout += abs(a[j]);
        negout.insert(abs(a[j]));
      }
    }
    ans = max(ans, sum - 2 * sumout);
  }
  cout << ans << '\n';
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

You a captain of a ship. Initially you are standing in a point (x_1, y_1) (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point (x_2, y_2).

You know the weather forecast — the string s of length n, consisting only of letters U, D, L and R. The letter corresponds to a direction of wind. Moreover, the forecast is periodic, e.g. the first day wind blows to the side s_1, the second day — s_2, the n-th day — s_n and (n+1)-th day — s_1 again and so on.

Ship coordinates change the following way:

  * if wind blows the direction U, then the ship moves from (x, y) to (x, y + 1);
  * if wind blows the direction D, then the ship moves from (x, y) to (x, y - 1);
  * if wind blows the direction L, then the ship moves from (x, y) to (x - 1, y);
  * if wind blows the direction R, then the ship moves from (x, y) to (x + 1, y).

The ship can also either go one of the four directions or stay in place each day. If it goes then it's exactly 1 unit of distance. Transpositions of the ship and the wind add up. If the ship stays in place, then only the direction of wind counts. For example, if wind blows the direction U and the ship moves the direction L, then from point (x, y) it will move to the point (x - 1, y + 1), and if it goes the direction U, then it will move to the point (x, y + 2).

You task is to determine the minimal number of days required for the ship to reach the point (x_2, y_2).

Input

The first line contains two integers x_1, y_1 (0 ≤ x_1, y_1 ≤ 10^9) — the initial coordinates of the ship.

The second line contains two integers x_2, y_2 (0 ≤ x_2, y_2 ≤ 10^9) — the coordinates of the destination point.

It is guaranteed that the initial coordinates and destination point coordinates are different.

The third line contains a single integer n (1 ≤ n ≤ 10^5) — the length of the string s.

The fourth line contains the string s itself, consisting only of letters U, D, L and R.

Output

The only line should contain the minimal number of days required for the ship to reach the point (x_2, y_2).

If it's impossible then print "-1".

Examples

Input

0 0
4 6
3
UUU

Output

5

Input

0 3
0 0
3
UDD

Output

3

Input

0 0
0 1
1
L

Output

-1

Note

In the first example the ship should perform the following sequence of moves: "RRRRU". Then its coordinates will change accordingly: (0, 0) → (1, 1) → (2, 2) → (3, 3) → (4, 4) → (4, 6).

In the second example the ship should perform the following sequence of moves: "DD" (the third day it should stay in place). Then its coordinates will change accordingly: (0, 3) → (0, 3) → (0, 1) → (0, 0).

In the third example the ship can never reach the point (0, 1).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
double PI = 3.1415926535897932384626;
int main() {
  long long int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  x2 -= x1;
  y2 -= y1;
  vector<pair<long long int, long long int> > v;
  v.push_back({0, 0});
  for (int i = 0; i < n; i++) {
    long long int xd = 0, yd = 0;
    if (s[i] == 'U') {
      yd++;
    }
    if (s[i] == 'D') {
      yd--;
    }
    if (s[i] == 'R') {
      xd++;
    }
    if (s[i] == 'L') {
      xd--;
    }
    v.push_back(v[v.size() - 1]);
    v[i + 1].first += xd;
    v[i + 1].second += yd;
  }
  long long int xd = v[n].first, yd = v[n].second;
  long long int l = 0, r = 1e12 + 10, mid;
  if (abs(xd) + abs(yd) == n)
    if (abs((r)*xd - x2) + abs((r)*yd - y2) > n * (r)) {
      cout << "-1" << endl;
      return 0;
    }
  r = 1e16;
  while (l <= r) {
    mid = (l + r) / 2;
    long long int a = mid / n;
    long long int b = mid % n;
    long long int ax = a * xd, ay = a * yd;
    ax += v[b].first;
    ay += v[b].second;
    long long int dis = abs(ax - x2) + abs(ay - y2);
    if (dis <= mid) {
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  cout << l << endl;
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m genres.

In the bookshop, Jack decides to buy two books of different genres.

Based on the genre of books on sale in the shop, find the number of options available to Jack for choosing two books of different genres for Emily. Options are considered different if they differ in at least one book.

The books are given by indices of their genres. The genres are numbered from 1 to m.

Input

The first line contains two positive integers n and m (2 ≤ n ≤ 2·105, 2 ≤ m ≤ 10) — the number of books in the bookstore and the number of genres.

The second line contains a sequence a1, a2, ..., an, where ai (1 ≤ ai ≤ m) equals the genre of the i-th book.

It is guaranteed that for each genre there is at least one book of that genre.

Output

Print the only integer — the number of ways in which Jack can choose books.

It is guaranteed that the answer doesn't exceed the value 2·109.

Examples

Input

4 3
2 1 3 1

Output

5

Input

7 4
4 2 3 1 2 4 3

Output

18

Note

The answer to the first test sample equals 5 as Sasha can choose:

  1. the first and second books,
  2. the first and third books,
  3. the first and fourth books,
  4. the second and third books,
  5. the third and fourth books.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, x, v[12], i, j, s = 0;
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> x;
    v[x]++;
  }
  for (i = 1; i < m; i++) {
    for (j = i + 1; j <= m; j++) s = s + v[i] * v[j];
  }
  cout << s;
  return 0;
}

```


### Prompt

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

The only difference between easy and hard versions is the constraints.

Polycarp has to write a coursework. The coursework consists of m pages.

Polycarp also has n cups of coffee. The coffee in the i-th cup has a_i caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He can drink cups in any order. Polycarp drinks each cup instantly and completely (i.e. he cannot split any cup into several days).

Surely, courseworks are not usually being written in a single day (in a perfect world of Berland, at least). Some of them require multiple days of hard work.

Let's consider some day of Polycarp's work. Consider Polycarp drinks k cups of coffee during this day and caffeine dosages of cups Polycarp drink during this day are a_{i_1}, a_{i_2}, ..., a_{i_k}. Then the first cup he drinks gives him energy to write a_{i_1} pages of coursework, the second cup gives him energy to write max(0, a_{i_2} - 1) pages, the third cup gives him energy to write max(0, a_{i_3} - 2) pages, ..., the k-th cup gives him energy to write max(0, a_{i_k} - k + 1) pages.

If Polycarp doesn't drink coffee during some day, he cannot write coursework at all that day.

Polycarp has to finish his coursework as soon as possible (spend the minimum number of days to do it). Your task is to find out this number of days or say that it is impossible.

Input

The first line of the input contains two integers n and m (1 ≤ n ≤ 100, 1 ≤ m ≤ 10^4) — the number of cups of coffee and the number of pages in the coursework.

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the caffeine dosage of coffee in the i-th cup.

Output

If it is impossible to write the coursework, print -1. Otherwise print the minimum number of days Polycarp needs to do it.

Examples

Input

5 8
2 3 1 1 2

Output

4

Input

7 10
1 3 4 2 1 4 2

Output

2

Input

5 15
5 5 5 5 5

Output

1

Input

5 16
5 5 5 5 5

Output

2

Input

5 26
5 5 5 5 5

Output

-1

Note

In the first example Polycarp can drink fourth cup during first day (and write 1 page), first and second cups during second day (and write 2 + (3 - 1) = 4 pages), fifth cup during the third day (and write 2 pages) and third cup during the fourth day (and write 1 page) so the answer is 4. It is obvious that there is no way to write the coursework in three or less days in this test.

In the second example Polycarp can drink third, fourth and second cups during first day (and write 4 + (2 - 1) + (3 - 2) = 6 pages) and sixth cup during second day (and write 4 pages) so the answer is 2. It is obvious that Polycarp cannot write the whole coursework in one day in this test.

In the third example Polycarp can drink all cups of coffee during first day and write 5 + (5 - 1) + (5 - 2) + (5 - 3) + (5 - 4) = 15 pages of coursework.

In the fourth example Polycarp cannot drink all cups during first day and should drink one of them during the second day. So during first day he will write 5 + (5 - 1) + (5 - 2) + (5 - 3) = 14 pages of coursework and during second day he will write 5 pages of coursework. This is enough to complete it.

In the fifth example Polycarp cannot write the whole coursework at all, even if he will drink one cup of coffee during each day, so the answer is -1.

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC Optimize("O3")
using namespace std;
const int N = 2e5, OO = 0x3f3f3f3f;
int n, m, arr[N];
bool valid(int num) {
  long long tot = 0;
  int x;
  for (int i = 0, day = 0; i < n; day++) {
    x = num;
    while (i < n && x--) tot += max(arr[i++] - day, 0);
  }
  return tot >= m;
}
int bs() {
  int lo = 1, hi = n, mid, ans = -1;
  while (lo <= hi) {
    mid = lo + (hi - lo) / 2;
    if (valid(mid)) {
      hi = mid - 1;
      ans = mid;
    } else
      lo = mid + 1;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", arr + i);
  sort(arr, arr + n);
  reverse(arr, arr + n);
  printf("%d", bs());
}

```


### Prompt

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

Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler!

However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measurements. We assume that the marks are numbered from 1 to n in the order they appear from the beginning of the ruler to its end. The first point coincides with the beginning of the ruler and represents the origin. The last mark coincides with the end of the ruler, at distance l from the origin. This ruler can be repesented by an increasing sequence a1, a2, ..., an, where ai denotes the distance of the i-th mark from the origin (a1 = 0, an = l).

Valery believes that with a ruler he can measure the distance of d centimeters, if there is a pair of integers i and j (1 ≤ i ≤ j ≤ n), such that the distance between the i-th and the j-th mark is exactly equal to d (in other words, aj - ai = d).

Under the rules, the girls should be able to jump at least x centimeters, and the boys should be able to jump at least y (x < y) centimeters. To test the children's abilities, Valery needs a ruler to measure each of the distances x and y.

Your task is to determine what is the minimum number of additional marks you need to add on the ruler so that they can be used to measure the distances x and y. Valery can add the marks at any integer non-negative distance from the origin not exceeding the length of the ruler.

Input

The first line contains four positive space-separated integers n, l, x, y (2 ≤ n ≤ 105, 2 ≤ l ≤ 109, 1 ≤ x < y ≤ l) — the number of marks, the length of the ruler and the jump norms for girls and boys, correspondingly.

The second line contains a sequence of n integers a1, a2, ..., an (0 = a1 < a2 < ... < an = l), where ai shows the distance from the i-th mark to the origin.

Output

In the first line print a single non-negative integer v — the minimum number of marks that you need to add on the ruler.

In the second line print v space-separated integers p1, p2, ..., pv (0 ≤ pi ≤ l). Number pi means that the i-th mark should be at the distance of pi centimeters from the origin. Print the marks in any order. If there are multiple solutions, print any of them.

Examples

Input

3 250 185 230
0 185 250

Output

1
230

Input

4 250 185 230
0 20 185 250

Output

0

Input

2 300 185 230
0 300

Output

2
185 230

Note

In the first sample it is impossible to initially measure the distance of 230 centimeters. For that it is enough to add a 20 centimeter mark or a 230 centimeter mark.

In the second sample you already can use the ruler to measure the distances of 185 and 230 centimeters, so you don't have to add new marks.

In the third sample the ruler only contains the initial and the final marks. We will need to add two marks to be able to test the children's skills.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MX = 100000;
const long long MOD = 1000000007;
long long fast_exp(long long base, long long exp, long long mod) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % mod;
    base = (base * base) % mod;
    exp /= 2;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, l, x, y;
  cin >> n >> l >> x >> y;
  vector<long long> v(n);
  for (int i = 0, _i = (n); i < _i; ++i) cin >> v[i];
  bool f1, f2;
  f1 = f2 = false;
  for (int i = 0, _i = (n); i < _i; ++i) {
    if (binary_search(v.begin() + i, v.end(), v[i] + x)) f1 = true;
    if (binary_search(v.begin() + i, v.end(), v[i] + y)) f2 = true;
    if (f1 && f2) {
      cout << 0;
      return 0;
    }
  }
  if (f1 || f2) {
    cout << 1 << "\n";
    cout << (f1 ? y : x);
    return 0;
  }
  for (int i = 0, _i = (n); i < _i; ++i) {
    long long p = v[i] + x;
    if (p >= 0 && p <= l &&
        (binary_search(v.begin(), v.end(), p - y) ||
         binary_search(v.begin(), v.end(), p + y))) {
      cout << 1 << "\n" << p;
      return 0;
    }
    p = v[i] - x;
    if (p >= 0 && p <= l &&
        (binary_search(v.begin(), v.end(), p - y) ||
         binary_search(v.begin(), v.end(), p + y))) {
      cout << 1 << "\n" << p;
      return 0;
    }
    p = v[i] + y;
    if (p >= 0 && p <= l &&
        (binary_search(v.begin(), v.end(), p - x) ||
         binary_search(v.begin(), v.end(), p + x))) {
      cout << 1 << "\n" << p;
      return 0;
    }
    p = v[i] - y;
    if (p >= 0 && p <= l &&
        (binary_search(v.begin(), v.end(), p - x) ||
         binary_search(v.begin(), v.end(), p + x))) {
      cout << 1 << "\n" << p;
      return 0;
    }
  }
  cout << 2 << "\n";
  cout << x << " " << y;
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

As you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires.

Vova managed to build a large army, but forgot about the main person in the army - the commander. So he tries to hire a commander, and he wants to choose the person who will be respected by warriors.

Each warrior is represented by his personality — an integer number pi. Each commander has two characteristics — his personality pj and leadership lj (both are integer numbers). Warrior i respects commander j only if <image> (<image> is the bitwise excluding OR of x and y).

Initially Vova's army is empty. There are three different types of events that can happen with the army:

  * 1 pi — one warrior with personality pi joins Vova's army;
  * 2 pi — one warrior with personality pi leaves Vova's army;
  * 3 pi li — Vova tries to hire a commander with personality pi and leadership li.

For each event of the third type Vova wants to know how many warriors (counting only those who joined the army and haven't left yet) respect the commander he tries to hire.

Input

The first line contains one integer q (1 ≤ q ≤ 100000) — the number of events.

Then q lines follow. Each line describes the event:

  * 1 pi (1 ≤ pi ≤ 108) — one warrior with personality pi joins Vova's army;
  * 2 pi (1 ≤ pi ≤ 108) — one warrior with personality pi leaves Vova's army (it is guaranteed that there is at least one such warrior in Vova's army by this moment);
  * 3 pi li (1 ≤ pi, li ≤ 108) — Vova tries to hire a commander with personality pi and leadership li. There is at least one event of this type.

Output

For each event of the third type print one integer — the number of warriors who respect the commander Vova tries to hire in the event.

Example

Input

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

Output

1
0

Note

In the example the army consists of two warriors with personalities 3 and 4 after first two events. Then Vova tries to hire a commander with personality 6 and leadership 3, and only one warrior respects him (<image>, and 2 < 3, but <image>, and 5 ≥ 3). Then warrior with personality 4 leaves, and when Vova tries to hire that commander again, there are no warriors who respect him.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
struct node {
  node* ch[2] = {0, 0};
  int size = 0;
};
void add(node* n, int x) {
  for (int i = int(30) - 1; i >= (0); --i) {
    int c = (((x) >> (i)) & 1);
    if (n->ch[c] == 0) {
      n->ch[c] = new node();
    }
    n = n->ch[c];
    n->size++;
  }
}
void rem(node* n, int x) {
  for (int i = int(30) - 1; i >= (0); --i) {
    int c = (((x) >> (i)) & 1);
    n = n->ch[c];
    n->size--;
  }
}
int get(node* n, int y, int l) {
  int res = 0;
  for (int i = int(30) - 1; i >= (0); --i) {
    if (!n) {
      break;
    }
    int tz = (((y) >> (i)) & 1);
    if ((((l) >> (i)) & 1)) {
      res += n->ch[tz] ? n->ch[tz]->size : 0;
      n = n->ch[tz ^ 1];
    } else {
      n = n->ch[tz];
    }
  }
  return res;
}
void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  node* root = new node();
  for (int i = (0); i < int(n); ++i) {
    int t;
    cin >> t;
    if (t == 1) {
      int x;
      cin >> x;
      add(root, x);
    } else if (t == 2) {
      int x;
      cin >> x;
      rem(root, x);
    } else {
      int y, l;
      cin >> y >> l;
      cout << get(root, y, l) << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve(cin, cout);
  return 0;
}

```