### Prompt

Please create a solution in Cpp to the following problem:

Vasiliy is fond of solving different tasks. Today he found one he wasn't able to solve himself, so he asks you to help.

Vasiliy is given n strings consisting of lowercase English letters. He wants them to be sorted in lexicographical order (as in the dictionary), but he is not allowed to swap any of them. The only operation he is allowed to do is to reverse any of them (first character becomes last, second becomes one before last and so on).

To reverse the i-th string Vasiliy has to spent ci units of energy. He is interested in the minimum amount of energy he has to spent in order to have strings sorted in lexicographical order.

String A is lexicographically smaller than string B if it is shorter than B (|A| < |B|) and is its prefix, or if none of them is a prefix of the other and at the first position where they differ character in A is smaller than the character in B.

For the purpose of this problem, two equal strings nearby do not break the condition of sequence being sorted lexicographically.

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of strings.

The second line contains n integers ci (0 ≤ ci ≤ 109), the i-th of them is equal to the amount of energy Vasiliy has to spent in order to reverse the i-th string.

Then follow n lines, each containing a string consisting of lowercase English letters. The total length of these strings doesn't exceed 100 000.

Output

If it is impossible to reverse some of the strings such that they will be located in lexicographical order, print  - 1. Otherwise, print the minimum total amount of energy Vasiliy has to spent.

Examples

Input

2
1 2
ba
ac

Output

1

Input

3
1 3 1
aa
ba
ac

Output

1

Input

2
5 5
bbb
aaa

Output

-1

Input

2
3 3
aaa
aa

Output

-1

Note

In the second sample one has to reverse string 2 or string 3. To amount of energy required to reverse the string 3 is smaller.

In the third sample, both strings do not change after reverse and they go in the wrong order, so the answer is  - 1.

In the fourth sample, both strings consists of characters 'a' only, but in the sorted order string "aa" should go before string "aaa", thus the answer is  - 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2e5 + 5;
struct ff {
  long long id;
  string ss;
  long long flag;
  bool operator<(const ff& b) const {
    if (ss != b.ss)
      return ss < b.ss;
    else
      return id < b.id;
  }
};
vector<ff> tt;
string ss;
long long dp[MAXN << 1];
long long flag[MAXN << 1];
long long c[MAXN << 1];
int main() {
  long long n;
  cin >> n;
  memset(dp, 127, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> ss;
    tt.push_back({i, ss, 0});
    reverse(ss.begin(), ss.end());
    tt.push_back({i, ss, 1});
  }
  sort(tt.begin(), tt.end());
  dp[0] = 0;
  flag[0] = 1;
  for (int i = 0; i < tt.size(); i++) {
    if (flag[tt[i].id - 1]) {
      if (tt[i].flag == 1) {
        dp[tt[i].id] = min(dp[tt[i].id], dp[tt[i].id - 1] + c[tt[i].id]);
      } else {
        dp[tt[i].id] = min(dp[tt[i].id], dp[tt[i].id - 1]);
      }
      flag[tt[i].id] = 1;
    }
  }
  if (dp[n] != dp[(MAXN << 1) - 2])
    cout << dp[n] << endl;
  else
    cout << -1 << endl;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).

Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems.

A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.

Constraints

* All input values are integers.
* 1≦N≦100
* 1≦T_i≦10^5
* 1≦M≦100
* 1≦P_i≦N
* 1≦X_i≦10^5

Input

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

N
T_1 T_2 ... T_N
M
P_1 X_1
P_2 X_2
:
P_M X_M

Output

For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.

Examples

Input

3
2 1 4
2
1 1
2 3

Output

6
9

Input

5
7 2 3 8 5
3
4 2
1 7
4 13

Output

19
25
30

### Response

```cpp
#include<cstdio>
int n,m,a[105],sum=0;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    scanf("%d",&m);
    while(m--){
        int p,x;
        scanf("%d%d",&p,&x);
        printf("%d\n",sum-a[p]+x);
    }
    return 0;
}
```


### Prompt

Construct a Cpp code solution to the problem outlined:

The dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the mountains to watch fairies dancing in the moonlight, while the princess thinks they should just go to bed early. They are desperate to come to an amicable agreement, so they decide to leave this up to chance.

They take turns drawing a mouse from a bag which initially contains w white and b black mice. The person who is the first to draw a white mouse wins. After each mouse drawn by the dragon the rest of mice in the bag panic, and one of them jumps out of the bag itself (the princess draws her mice carefully and doesn't scare other mice). Princess draws first. What is the probability of the princess winning?

If there are no more mice in the bag and nobody has drawn a white mouse, the dragon wins. Mice which jump out of the bag themselves are not considered to be drawn (do not define the winner). Once a mouse has left the bag, it never returns to it. Every mouse is drawn from the bag with the same probability as every other one, and every mouse jumps out of the bag with the same probability as every other one.

Input

The only line of input data contains two integers w and b (0 ≤ w, b ≤ 1000).

Output

Output the probability of the princess winning. The answer is considered to be correct if its absolute or relative error does not exceed 10 - 9.

Examples

Input

1 3

Output

0.500000000

Input

5 5

Output

0.658730159

Note

Let's go through the first sample. The probability of the princess drawing a white mouse on her first turn and winning right away is 1/4. The probability of the dragon drawing a black mouse and not winning on his first turn is 3/4 * 2/3 = 1/2. After this there are two mice left in the bag — one black and one white; one of them jumps out, and the other is drawn by the princess on her second turn. If the princess' mouse is white, she wins (probability is 1/2 * 1/2 = 1/4), otherwise nobody gets the white mouse, so according to the rule the dragon wins.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long double f[1005][1005], i, j;
int w, b;
int main() {
  scanf("%d %d", &w, &b);
  for (int ii = 1; ii <= w; ++ii) {
    i = ii;
    f[ii][0] = 1;
    f[ii][1] = i / (i + 1);
    f[ii][2] = 2 / (i + 2) / (i + 1) * i / (i + 0) * f[ii - 1][0] + i / (i + 2);
    for (int jj = 3; jj <= b; jj++) {
      j = jj;
      f[ii][jj] = j / (i + j) * (j - 1) / (i + j - 1) * i / (i + j - 2) *
                      f[ii - 1][jj - 2] +
                  i / (i + j) +
                  j / (i + j) * (j - 1) / (i + j - 1) * (j - 2) / (i + j - 2) *
                      f[ii][jj - 3];
    }
  }
  printf("%.9Lf\n", f[w][b]);
  return 0;
}

```


### Prompt

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

Inna and Dima bought a table of size n × m in the shop. Each cell of the table contains a single letter: "D", "I", "M", "A".

Inna loves Dima, so she wants to go through his name as many times as possible as she moves through the table. For that, Inna acts as follows:

  1. initially, Inna chooses some cell of the table where letter "D" is written;
  2. then Inna can move to some side-adjacent table cell that contains letter "I"; then from this cell she can go to one of the side-adjacent table cells that contains the written letter "M"; then she can go to a side-adjacent cell that contains letter "A". Then Inna assumes that she has gone through her sweetheart's name;
  3. Inna's next move can be going to one of the side-adjacent table cells that contains letter "D" and then walk on through name DIMA in the similar manner. Inna never skips a letter. So, from the letter "D" she always goes to the letter "I", from the letter "I" she always goes the to letter "M", from the letter "M" she always goes to the letter "A", and from the letter "A" she always goes to the letter "D".

Depending on the choice of the initial table cell, Inna can go through name DIMA either an infinite number of times or some positive finite number of times or she can't go through his name once. Help Inna find out what maximum number of times she can go through name DIMA.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 103).

Then follow n lines that describe Inna and Dima's table. Each line contains m characters. Each character is one of the following four characters: "D", "I", "M", "A".

Note that it is not guaranteed that the table contains at least one letter "D".

Output

If Inna cannot go through name DIMA once, print on a single line "Poor Dima!" without the quotes. If there is the infinite number of names DIMA Inna can go through, print "Poor Inna!" without the quotes. Otherwise print a single integer — the maximum number of times Inna can go through name DIMA.

Examples

Input

1 2
DI

Output

Poor Dima!

Input

2 2
MA
ID

Output

Poor Inna!

Input

5 5
DIMAD
DIMAI
DIMAM
DDMAA
AAMID

Output

4

Note

Notes to the samples:

In the first test sample, Inna cannot go through name DIMA a single time.

In the second test sample, Inna can go through the infinite number of words DIMA. For that, she should move in the clockwise direction starting from the lower right corner.

In the third test sample the best strategy is to start from the cell in the upper left corner of the table. Starting from this cell, Inna can go through name DIMA four times.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, Si;
const int M = 1010;
char table[M][M];
char c[4] = {'D', 'I', 'M', 'A'};
int d[5] = {0, 1, 0, -1, 0};
int V[M][M];
struct point {
  int x, y;
} p;
queue<point> q;
int len = -1;
int GT(int s, int t, int l) {
  if (l > Si) {
    return -1;
  }
  for (int i = 0; i < 4; i++) {
    int x = s + d[i], y = t + d[i + 1];
    if (x >= 1 && x <= n && y >= 1 && y <= m && table[x][y] == c[l % 4]) {
      if (V[x][y] > 0)
        len = max(len, l + V[x][y]);
      else if (GT(x, y, l + 1) == -1)
        return -1;
    }
  }
  len = max(len, l);
  V[s][t] = len - l + 1;
  if (l == 1) {
    return len;
  }
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    Si = m * n;
    getchar();
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        scanf("%c", &table[i][j]);
        if (table[i][j] == 'D') {
          p.x = i;
          p.y = j;
          q.push(p);
        }
      }
      getchar();
    }
    memset(V, 0, sizeof(V));
    if (n * m < 4 || q.empty()) {
      cout << "Poor Dima!\n";
      return 0;
    }
    int re = 0;
    while (!q.empty()) {
      len = -1;
      p = q.front();
      q.pop();
      if (V[p.x][p.y] > 0) {
        continue;
      }
      int ll = GT(p.x, p.y, 1);
      if (ll == -1) {
        cout << "Poor Inna!\n";
        return 0;
      } else
        re = max(re, ll);
    }
    if (re >= 4)
      cout << re / 4 << endl;
    else
      cout << "Poor Dima!\n";
  }
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Flatland has recently introduced a new type of an eye check for the driver's licence. The check goes like that: there is a plane with mannequins standing on it. You should tell the value of the minimum angle with the vertex at the origin of coordinates and with all mannequins standing inside or on the boarder of this angle.

As you spend lots of time "glued to the screen", your vision is impaired. So you have to write a program that will pass the check for you.

Input

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

Next n lines contain two space-separated integers each: xi, yi (|xi|, |yi| ≤ 1000) — the coordinates of the i-th mannequin. It is guaranteed that the origin of the coordinates has no mannequin. It is guaranteed that no two mannequins are located in the same point on the plane.

Output

Print a single real number — the value of the sought angle in degrees. The answer will be considered valid if the relative or absolute error doesn't exceed 10 - 6.

Examples

Input

2
2 0
0 2

Output

90.0000000000

Input

3
2 0
0 2
-2 2

Output

135.0000000000

Input

4
2 0
0 2
-2 0
0 -2

Output

270.0000000000

Input

2
2 1
1 2

Output

36.8698976458

Note

Solution for the first sample test is shown below:

<image>

Solution for the second sample test is shown below:

<image>

Solution for the third sample test is shown below:

<image>

Solution for the fourth sample test is shown below:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MAX = 2500000000;
const int inf = 0x3f3f3f3f;
const double EPS = 1e-11;
const double PII = 2 * asin(1.0);
const long long mod = 1e9 + 7;
const long long mod2 = 1000000016531;
const long long mod3 = 1000000014367;
int double_cmp(double x, double y = 0, double tol = EPS) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
double angle[100010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    angle[i] = acos((10.0 * a) / (sqrtl(100.0) * sqrtl(a * a + b * b)));
    if ((a < 0.0 && b < 0.0) || (a >= 0.0 && b < 0.0))
      angle[i] = (2.0 * PII) - angle[i];
  }
  sort(angle, angle + n);
  double menor = 400000000.0;
  for (int i = 1; i < n; ++i) {
    menor = min(menor,
                abs((180.0 * ((2 * PII) - (angle[i] - angle[i - 1]))) / PII));
  }
  menor = min(menor, abs((180.0 * (angle[n - 1] - angle[0])) / PII));
  printf("%.14lf\n", menor);
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

The hero of our story, Valera, and his best friend Arcady are still in school, and therefore they spend all the free time playing turn-based strategy "GAGA: Go And Go Again". The gameplay is as follows.

There are two armies on the playing field each of which consists of n men (n is always even). The current player specifies for each of her soldiers an enemy's soldier he will shoot (a target) and then all the player's soldiers shot simultaneously. This is a game world, and so each soldier shoots perfectly, that is he absolutely always hits the specified target. If an enemy soldier is hit, he will surely die. It may happen that several soldiers had been indicated the same target. Killed soldiers do not participate in the game anymore.

The game "GAGA" consists of three steps: first Valera makes a move, then Arcady, then Valera again and the game ends.

You are asked to calculate the maximum total number of soldiers that may be killed during the game.

Input

The input data consist of a single integer n (2 ≤ n ≤ 108, n is even). Please note that before the game starts there are 2n soldiers on the fields.

Output

Print a single number — a maximum total number of soldiers that could be killed in the course of the game in three turns.

Examples

Input

2

Output

3

Input

4

Output

6

Note

The first sample test:

1) Valera's soldiers 1 and 2 shoot at Arcady's soldier 1.

2) Arcady's soldier 2 shoots at Valera's soldier 1.

3) Valera's soldier 1 shoots at Arcady's soldier 2.

There are 3 soldiers killed in total: Valera's soldier 1 and Arcady's soldiers 1 and 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  cout << n * 2 - (n * 2) / 4;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

RedDreamer has an array a consisting of n non-negative integers, and an unlucky integer T.

Let's denote the misfortune of array b having length m as f(b) — the number of pairs of integers (i, j) such that 1 ≤ i < j ≤ m and b_i + b_j = T. RedDreamer has to paint each element of a into one of two colors, white and black (for each element, the color is chosen independently), and then create two arrays c and d so that all white elements belong to c, and all black elements belong to d (it is possible that one of these two arrays becomes empty). RedDreamer wants to paint the elements in such a way that f(c) + f(d) is minimum possible.

For example:

  * if n = 6, T = 7 and a = [1, 2, 3, 4, 5, 6], it is possible to paint the 1-st, the 4-th and the 5-th elements white, and all other elements black. So c = [1, 4, 5], d = [2, 3, 6], and f(c) + f(d) = 0 + 0 = 0;
  * if n = 3, T = 6 and a = [3, 3, 3], it is possible to paint the 1-st element white, and all other elements black. So c = [3], d = [3, 3], and f(c) + f(d) = 0 + 1 = 1.

Help RedDreamer to paint the array optimally!

Input

The first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases. Then t test cases follow.

The first line of each test case contains two integers n and T (1 ≤ n ≤ 10^5, 0 ≤ T ≤ 10^9) — the number of elements in the array and the unlucky integer, respectively.

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

The sum of n over all test cases does not exceed 10^5.

Output

For each test case print n integers: p_1, p_2, ..., p_n (each p_i is either 0 or 1) denoting the colors. If p_i is 0, then a_i is white and belongs to the array c, otherwise it is black and belongs to the array d.

If there are multiple answers that minimize the value of f(c) + f(d), print any of them.

Example

Input

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

Output

1 0 0 1 1 0
1 0 0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b);
void print(long long arr[], long long n);
void printv(vector<long long> arr);
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long k;
    cin >> k;
    vector<long long> arr(n);
    unordered_map<long long, long long> m;
    for (long long i = 0; i < n; i++) {
      cin >> arr[i];
      m[arr[i]]++;
    }
    vector<long long> tem = arr;
    sort(tem.begin(), tem.end());
    set<long long> a, b;
    if (arr[0] * 2 != k) a.insert(arr[0]);
    for (long long i = 1; i < n; i++) {
      if (arr[i] * 2 == k) continue;
      if (a.find(k - arr[i]) == a.end())
        a.insert(arr[i]);
      else
        b.insert(arr[i]);
    }
    long long ii = 0;
    for (long long i = 0; i < n; i++) {
      if (a.find(arr[i]) != a.end())
        cout << 1 << " ";
      else if (b.find(arr[i]) != b.end())
        cout << 0 << " ";
      else {
        cout << ii << " ";
        ii = (ii + 1) % 2;
      }
    }
    cout << "\n";
  }
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void print(long long arr[], long long n) {
  for (long long i = 0; i < n; i++) cout << arr[i] << " ";
  cout << "\n";
}
void printv(vector<long long> arr) {
  for (long long i = 0; i < arr.size(); i++) cout << arr[i] << " ";
  cout << "\n";
}

```


### Prompt

Generate a cpp solution to the following problem:

This is an interactive problem.

Yui is a girl who enjoys playing Mahjong.

<image>

She has a mysterious set which consists of tiles (this set can be empty). Each tile has an integer value between 1 and n, and at most n tiles in the set have the same value. So the set can contain at most n^2 tiles.

You want to figure out which values are on the tiles. But Yui is shy, she prefers to play a guessing game with you.

Let's call a set consisting of three tiles triplet if their values are the same. For example, \{2, 2, 2\} is a triplet, but \{2, 3, 3\} is not.

Let's call a set consisting of three tiles straight if their values are consecutive integers. For example, \{2, 3, 4\} is a straight, but \{1, 3, 5\} is not.

At first, Yui gives you the number of triplet subsets and straight subsets of the initial set respectively. After that, you can insert a tile with an integer value between 1 and n into the set at most n times. Every time you insert a tile, you will get the number of triplet subsets and straight subsets of the current set as well.

Note that two tiles with the same value are treated different. In other words, in the set \{1, 1, 2, 2, 3\} you can find 4 subsets \{1, 2, 3\}.

Try to guess the number of tiles in the initial set with value i for all integers i from 1 to n.

Input

The first line contains a single integer n (4 ≤ n ≤ 100).

The second line contains two integers which represent the number of triplet subsets and straight subsets of the initial set respectively.

Output

When you are ready to answer, print a single line of form "! a_1 a_2 … a_n" (0 ≤ a_i ≤ n), where a_i is equal to the number of tiles in the initial set with value i.

Interaction

To insert a tile, print a single line of form "+ x" (1 ≤ x ≤ n), where x is the value of the tile you insert. Then you should read two integers which represent the number of triplet subsets and straight subsets of the current set respectively.

After printing a line, do not forget to flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

  * fflush(stdout) or cout.flush() in C++;
  * System.out.flush() in Java;
  * flush(output) in Pascal;
  * stdout.flush() in Python;
  * see documentation for other languages.

You will get Wrong answer if you insert more than n tiles.

Hacks

To make a hack you should provide a test in such format:

The first line contains a single integer n (4 ≤ n ≤ 100).

The second line contains n integers a_1,a_2,…,a_n (0 ≤ a_i ≤ n) — a_i is equal to the number of tiles with value i in the set.

Example

Input

5
1 6
2 9
5 12
5 24
6 24

Output

+ 1
+ 1
+ 2
+ 5
! 2 1 3 0 2

Note

In the first test, the initial set of tiles is \{1, 1, 2, 3, 3, 3, 5, 5\}. It has only one triplet subset \{3, 3, 3\} and six straight subsets, all equal to \{1, 2, 3\}. After inserting a tile with value 1 the set of tiles will be \{1, 1, 1, 2, 3, 3, 3, 5, 5\} and will have two triplet subsets \{1, 1, 1\}, \{3, 3, 3\} and nine straight subsets, all equal to \{1, 2, 3\}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int t[105], s[105], ans[105];
void ask(int x, int i) {
  cout << "+ " << x << endl;
  cin >> t[i] >> s[i];
}
int calc(int x) {
  int i = 1;
  while (1) {
    if (i * (i - 1) / 2 == x) return i;
    ++i;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  cin >> t[0] >> s[0];
  memset(ans, -1, sizeof ans);
  for (int i = 1; i <= n - 1; ++i) {
    ask(i, i);
  }
  ask(1, n);
  for (int i = n; i >= 1; --i) t[i] -= t[i - 1], s[i] -= s[i - 1];
  ans[1] = t[n] - t[1];
  for (int i = 2; i <= n - 1; ++i) {
    if (t[i]) ans[i] = calc(t[i]);
  }
  if (ans[3] == -1) ans[3] = (s[2] > 0);
  if (ans[2] == -1) ans[2] = s[n] / (ans[3] + 1) - 1;
  for (int i = 3; i <= n - 2; ++i) {
    if (ans[i + 1] == -1) {
      s[i] -= (ans[i - 1] + 1) * (ans[i - 2] + 1);
      ans[i + 1] = (s[i] > 0);
    }
  }
  ans[n] = (s[n - 1] - (ans[n - 2] + 1) * (ans[n - 3] + 1)) / (ans[n - 2] + 1);
  cout << "! ";
  for (int i = 1; i <= n; ++i) cout << ans[i] << ' ';
  cout << '\n';
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of string a. It can happen that you will not need to remove any characters at all, or maybe you will have to remove all of the characters from b and make it empty.

Subsequence of string s is any such string that can be obtained by erasing zero or more characters (not necessarily consecutive) from string s.

Input

The first line contains string a, and the second line — string b. Both of these strings are nonempty and consist of lowercase letters of English alphabet. The length of each string is no bigger than 105 characters.

Output

On the first line output a subsequence of string a, obtained from b by erasing the minimum number of consecutive characters.

If the answer consists of zero characters, output «-» (a minus sign).

Examples

Input

hi
bob

Output

-

Input

abca
accepted

Output

ac

Input

abacaba
abcdcba

Output

abcba

Note

In the first example strings a and b don't share any symbols, so the longest string that you can get is empty.

In the second example ac is a subsequence of a, and at the same time you can obtain it by erasing consecutive symbols cepted from string b.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  char a[100001] = {};
  char b[100001] = {};
  scanf("%s", a);
  scanf("%s", b);
  size_t alen = strlen(a);
  size_t blen = strlen(b);
  char* aend = a + alen;
  char* cura = a;
  char* curb = b;
  std::vector<int> prefixes;
  prefixes.reserve(blen);
  prefixes.push_back(-1);
  for (size_t i = 0; i < blen; ++i) {
    while (cura != aend) {
      if (*curb == *cura) {
        prefixes.push_back(cura - a);
        ++cura;
        break;
      }
      ++cura;
    }
    if (cura == aend) break;
    ++curb;
  }
  cura = a + alen - 1;
  curb = b + blen - 1;
  std::vector<int> postfix;
  postfix.reserve(blen);
  postfix.push_back(alen);
  for (size_t i = 0; i < blen; ++i) {
    while (cura != a - 1) {
      if (*curb == *cura) {
        postfix.push_back(cura - a);
        --cura;
        break;
      }
      --cura;
    }
    if (cura == a - 1) break;
    --curb;
  }
  int curMax = -1;
  int curPostfixIdx = postfix.size() - 1;
  std::pair<int, int> res;
  for (int i = 0; i < prefixes.size() && curPostfixIdx >= 0; ++i) {
    while (blen - curPostfixIdx <= i || prefixes[i] >= postfix[curPostfixIdx]) {
      --curPostfixIdx;
      if (curPostfixIdx < 0) break;
    }
    if (curMax <= (i + curPostfixIdx)) {
      curMax = i + curPostfixIdx;
      res.first = i;
      res.second = curPostfixIdx;
    }
  }
  std::string qqq(b, b + res.first);
  if (res.second >= 0) qqq.insert(qqq.end(), b + blen - res.second, b + blen);
  if (qqq.length())
    std::cout << qqq;
  else
    std::cout << '-';
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

As you know, lemmings like jumping. For the next spectacular group jump n lemmings gathered near a high rock with k comfortable ledges on it. The first ledge is situated at the height of h meters, the second one is at the height of 2h meters, and so on (the i-th ledge is at the height of i·h meters). The lemmings are going to jump at sunset, and there's not much time left.

Each lemming is characterized by its climbing speed of vi meters per minute and its weight mi. This means that the i-th lemming can climb to the j-th ledge in <image> minutes.

To make the jump beautiful, heavier lemmings should jump from higher ledges: if a lemming of weight mi jumps from ledge i, and a lemming of weight mj jumps from ledge j (for i < j), then the inequation mi ≤ mj should be fulfilled.

Since there are n lemmings and only k ledges (k ≤ n), the k lemmings that will take part in the jump need to be chosen. The chosen lemmings should be distributed on the ledges from 1 to k, one lemming per ledge. The lemmings are to be arranged in the order of non-decreasing weight with the increasing height of the ledge. In addition, each lemming should have enough time to get to his ledge, that is, the time of his climb should not exceed t minutes. The lemmings climb to their ledges all at the same time and they do not interfere with each other.

Find the way to arrange the lemmings' jump so that time t is minimized.

Input

The first line contains space-separated integers n, k and h (1 ≤ k ≤ n ≤ 105, 1 ≤ h ≤ 104) — the total number of lemmings, the number of ledges and the distance between adjacent ledges.

The second line contains n space-separated integers m1, m2, ..., mn (1 ≤ mi ≤ 109), where mi is the weight of i-th lemming.

The third line contains n space-separated integers v1, v2, ..., vn (1 ≤ vi ≤ 109), where vi is the speed of i-th lemming.

Output

Print k different numbers from 1 to n — the numbers of the lemmings who go to ledges at heights h, 2h, ..., kh, correspondingly, if the jump is organized in an optimal way. If there are multiple ways to select the lemmings, pick any of them.

Examples

Input

5 3 2
1 2 3 2 1
1 2 1 2 10

Output

5 2 4

Input

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

Output

4 3 1

Note

Let's consider the first sample case. The fifth lemming (speed 10) gets to the ledge at height 2 in <image> minutes; the second lemming (speed 2) gets to the ledge at height 4 in 2 minutes; the fourth lemming (speed 2) gets to the ledge at height 6 in 3 minutes. All lemmings manage to occupy their positions in 3 minutes.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int tam = 200010;
const int MOD = 1000000007;
const int MOD1 = 998244353;
const double EPS = 1e-9;
const double PI = acos(-1);
pair<pair<int, int>, int> ar[tam];
int res[tam];
int n, k, h;
bool first(double t) {
  int mul = 1;
  for (int i = 0, asdz = n; i < asdz; i++) {
    if (mul <= k && mul * h <= ar[i].first.second * t) {
      res[mul - 1] = ar[i].second + 1;
      mul++;
    }
  }
  return mul > k;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> h;
  for (int i = 0, asdz = n; i < asdz; i++) {
    cin >> ar[i].first.first;
    ar[i].second = i;
  }
  for (int i = 0, asdz = n; i < asdz; i++) cin >> ar[i].first.second;
  sort(ar, ar + n);
  double lo = 0, hi = 1000000000, mid, resp;
  for (int i = 0, asdz = 100; i < asdz; i++) {
    mid = (lo + hi) / 2;
    if (first(mid))
      resp = mid, hi = mid;
    else
      lo = mid;
  }
  assert(first(resp));
  for (int i = 0, asdz = k; i < asdz; i++) {
    if (i > 0) cout << ' ';
    cout << res[i];
  }
  cout << '\n';
  return 0;
}

```


### Prompt

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

Numbers of black and white points are placed on a plane. Let's imagine that a straight line of infinite length is drawn on the plane. When the line does not meet any of the points, the line divides these points into two groups. If the division by such a line results in one group consisting only of black points and the other consisting only of white points, we say that the line "separates black and white points".

Let's see examples in Figure 3. In the leftmost example, you can easily find that the black and white points can be perfectly separated by the dashed line according to their colors. In the remaining three examples, there exists no such straight line that gives such a separation.

<image>

Figure 3: Example planes

In this problem, given a set of points with their colors and positions, you are requested to decide whether there exists a straight line that separates black and white points.

Input

The input is a sequence of datasets, each of which is formatted as follows.

n m
x1 y1
.
.
.
xn yn
xn+1 yn+1
.
.
.
xn+m yn+m

The first line contains two positive integers separated by a single space; n is the number of black points, and m is the number of white points. They are less than or equal to 100. Then n + m lines representing the coordinates of points follow. Each line contains two integers xi and yi separated by a space, where (xi , yi ) represents the x-coordinate and the y-coordinate of the i-th point. The color of the i-th point is black for 1 ≤ i ≤ n, and is white for n + 1 ≤ i ≤ n + m.

All the points have integral x- and y-coordinate values between 0 and 10000 inclusive. You can also assume that no two points have the same position.

The end of the input is indicated by a line containing two zeros separated by a space.

Output

For each dataset, output "YES" if there exists a line satisfying the condition. If not, output "NO". In either case, print it in one line for each input dataset.

Example

Input

3 3
100 700
200 200
600 600
500 100
500 300
800 500
3 3
100 300
400 600
400 100
600 400
500 900
300 300
3 4
300 300
500 300
400 600
100 100
200 900
500 900
800 100
1 2
300 300
100 100
500 500
1 1
100 100
200 100
2 2
0 0
500 700
1000 1400
1500 2100
2 2
0 0
1000 1000
1000 0
0 1000
3 3
0 100
4999 102
10000 103
5001 102
10000 102
0 101
3 3
100 100
200 100
100 200
0 0
400 0
0 400
3 3
2813 1640
2583 2892
2967 1916
541 3562
9298 3686
7443 7921
0 0

Output

YES
NO
NO
NO
YES
YES
NO
NO
NO
YES

### Response

```cpp
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-8;
static const double PI = 3.141592653589793238462643383279;

/*
typedef complex<double> point;

template<typename T>
int sig2(T x){
    if(abs(x)<EPS) return 0;
    if(x>0) return 1;
    return -1;
}

double det(point p1, point p2, point q){
    return p2.real()*q.imag()+p1.real()*p2.imag()+q.real()*p1.imag()
            -p2.real()*p1.imag()-q.real()*p2.imag()-q.imag()*p1.real();
}
int main(){
    int i,j,k,n,m;
    double x,y,bxma,byma,bxmi,bymi,wxma,wyma,wxmi,wymi;
    bool yes;
    while(scanf("%d%d",&n,&m)){
        if(n==0 && m==0) break;
        bxma=byma=wxma=wyma=-1e99;
        bxmi=bymi=wxmi=wymi=1e99;
        yes=false;
        vector<point> bs(n), ws(m);
        REP(i,n){
            scanf("%lf%lf",&x,&y);
            bs[i]=point(x,y);
            bxma=max(bxma, x);
            byma=max(byma, y);
            bxmi=min(bxmi, x);
            bymi=min(bymi, y);
        }
        REP(i,m){
            scanf("%lf%lf",&x,&y);
            ws[i]=point(x,y);
            wxma=max(wxma, x);
            wyma=max(wyma, y);
            wxmi=min(wxmi, x);
            wymi=min(wymi, y);
        }
        if(bxma<wxmi||bxmi>wxma||byma<wymi||bymi>wyma){
            printf("YES\n");
            continue;
        }
        if(n==1 && m==1){
            printf("YES\n");
            continue;
        }
        int w=0, b;
        REP(i,n)for(j=i+1;j<n;j++){
            w = 0;
            REP(k,m) w+=sig2(det(bs[i],bs[j],ws[k]));
            if(abs(w)<m)break;
            REP(k,n)if(sig2(det(bs[i],bs[j],bs[k]))==sig2(w))break;
            if(k==n){
                yes = true;
                goto end;
            }
        }
        swap(n,m);
        swap(bs,ws);
        REP(i,n)for(j=i+1;j<n;j++){
            w = 0;
            REP(k,m) w+=sig2(det(bs[i],bs[j],ws[k]));
            if(abs(w)<m)break;
            REP(k,n)if(sig2(det(bs[i],bs[j],bs[k]))==sig2(w))break;
            if(k==n){
                yes = true;
                goto end;
            }
        }
        REP(i,n)REP(j,m){
            w = b = 0;
            REP(k,m) w+=sig2(det(bs[i],ws[j],ws[k]));
            if(abs(w)<m-1)break;
            REP(k,n) b+=sig2(det(bs[i],ws[j],bs[k]));
            if(abs(b)<n-1)break;
            if(w*b<0){
                yes = true;
                goto end;
            }
        }
        end:;
        if(yes)printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}
*/

#define N 80000

int main(){
    int i,j,n,m;
    double bma,bmi,wma,wmi,ang=PI/N,tmp;
    static double bxs[100], wxs[100], bys[100], wys[100];
    while(scanf("%d%d",&n,&m)){
        if(n==0 && m==0) break;
        REP(i,n)scanf("%lf%lf",bxs+i,bys+i);
        REP(i,m)scanf("%lf%lf",wxs+i,wys+i);
        REP(i,N){
            bma=wma=-1e99;
            bmi=wmi=1e99;
            REP(j,n){
                tmp = cos(ang*i)*bxs[j]-sin(ang*i)*bys[j];
                if(tmp<bmi)bmi=tmp;
                if(tmp>bma)bma=tmp;
            }
            REP(j,m){
                tmp = cos(ang*i)*wxs[j]-sin(ang*i)*wys[j];
                if(bmi<tmp && tmp<bma) goto mark;
                if(tmp<wmi)wmi=tmp;
                if(tmp>wma)wma=tmp;
            }
            if((bma < wmi - EPS) || (wma < bmi - EPS)) break;
            mark:;
        }
        if(i==N)printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}
```


### Prompt

Please formulate a CPP solution to the following problem:

Artsem is on vacation and wants to buy souvenirs for his two teammates. There are n souvenir shops along the street. In i-th shop Artsem can buy one souvenir for ai dollars, and he cannot buy more than one souvenir in one shop. He doesn't want to introduce envy in his team, so he wants to buy two souvenirs with least possible difference in price.

Artsem has visited the shopping street m times. For some strange reason on the i-th day only shops with numbers from li to ri were operating (weird? yes it is, but have you ever tried to come up with a reasonable legend for a range query problem?). For each visit, Artsem wants to know the minimum possible difference in prices of two different souvenirs he can buy in the opened shops.

In other words, for each Artsem's visit you should find the minimum possible value of |as - at| where li ≤ s, t ≤ ri, s ≠ t.

Input

The first line contains an integer n (2 ≤ n ≤ 105).

The second line contains n space-separated integers a1, ..., an (0 ≤ ai ≤ 109).

The third line contains the number of queries m (1 ≤ m ≤ 3·105).

Next m lines describe the queries. i-th of these lines contains two space-separated integers li and ri denoting the range of shops working on i-th day (1 ≤ li < ri ≤ n).

Output

Print the answer to each query in a separate line.

Example

Input

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

Output

0
1
1
3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, q;
pair<int, int> a[100001];
int pos[100001];
vector<pair<int, int> > qr[100001];
int max1[262144];
int max2[262144];
int ans[300001];
void upd1(int id, int l, int r, int x, int v) {
  if (l == r) {
    max1[id] = max(max1[id], v);
    return;
  }
  int mid = (l + r) / 2;
  if (x <= mid)
    upd1(id * 2, l, mid, x, v);
  else
    upd1(id * 2 + 1, mid + 1, r, x, v);
  max1[id] = max(max1[id * 2], max1[id * 2 + 1]);
}
void upd2(int id, int l, int r, int x, int v) {
  if (l == r) {
    max2[id] = max(max2[id], v);
    return;
  }
  int mid = (l + r) / 2;
  if (x <= mid)
    upd2(id * 2, l, mid, x, v);
  else
    upd2(id * 2 + 1, mid + 1, r, x, v);
  max2[id] = max(max2[id * 2], max2[id * 2 + 1]);
}
int qr1(int id, int l, int r, int ll, int rr) {
  if (r < ll || l > rr) return -1e9;
  if (ll <= l && r <= rr) return max1[id];
  int mid = (l + r) / 2;
  return max(qr1(id * 2, l, mid, ll, rr), qr1(id * 2 + 1, mid + 1, r, ll, rr));
}
int qr2(int id, int l, int r, int ll, int rr) {
  if (r < ll || l > rr) return -1e9;
  if (ll <= l && r <= rr) return max2[id];
  int mid = (l + r) / 2;
  return max(qr2(id * 2, l, mid, ll, rr), qr2(id * 2 + 1, mid + 1, r, ll, rr));
}
void wash(int id, int l, int r) {
  max2[id] = -1e9;
  if (l == r) return;
  int mid = (l + r) / 2;
  wash(id * 2, l, mid);
  wash(id * 2 + 1, mid + 1, r);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) pos[a[i].second] = i;
  wash(1, 1, n);
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int l, r;
    cin >> l >> r;
    qr[r].push_back({l, i});
  }
  for (int i = 1; i <= n; i++) {
    int len = 1e9, lb;
    while (len >= 0) {
      int val = a[pos[i]].first - len;
      lb = lower_bound(a + 1, a + n + 1, make_pair(val, 0)) - a;
      int maxi = qr1(1, 1, n, lb, pos[i]);
      if (maxi == 0) break;
      upd2(1, 1, n, maxi, a[pos[maxi]].first - a[pos[i]].first);
      len = (a[pos[i]].first - a[pos[maxi]].first + 1) / 2 - 1;
    }
    len = 1e9;
    while (len >= 0) {
      int val = a[pos[i]].first + len;
      lb = lower_bound(a + 1, a + n + 1, make_pair(val + 1, 0)) - a - 1;
      int maxi = qr1(1, 1, n, pos[i], lb);
      if (maxi == 0) break;
      upd2(1, 1, n, maxi, a[pos[i]].first - a[pos[maxi]].first);
      len = (a[pos[maxi]].first - a[pos[i]].first + 1) / 2 - 1;
    }
    upd1(1, 1, n, pos[i], i);
    for (auto cur : qr[i]) ans[cur.second] = -qr2(1, 1, n, cur.first, i);
  }
  for (int i = 1; i <= q; i++) {
    cout << ans[i] << '\n';
  }
}

```


### Prompt

Generate a CPP solution to the following problem:

Little Petya likes positive integers a lot. Recently his mom has presented him a positive integer a. There's only one thing Petya likes more than numbers: playing with little Masha. It turned out that Masha already has a positive integer b. Petya decided to turn his number a into the number b consecutively performing the operations of the following two types:

  1. Subtract 1 from his number.
  2. Choose any integer x from 2 to k, inclusive. Then subtract number (a mod x) from his number a. Operation a mod x means taking the remainder from division of number a by number x.

Petya performs one operation per second. Each time he chooses an operation to perform during the current move, no matter what kind of operations he has performed by that moment. In particular, this implies that he can perform the same operation any number of times in a row.

Now he wonders in what minimum number of seconds he could transform his number a into number b. Please note that numbers x in the operations of the second type are selected anew each time, independently of each other.

Input

The only line contains three integers a, b (1 ≤ b ≤ a ≤ 1018) and k (2 ≤ k ≤ 15).

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

Output

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

Examples

Input

10 1 4

Output

6

Input

6 3 10

Output

2

Input

1000000000000000000 1 3

Output

666666666666666667

Note

In the first sample the sequence of numbers that Petya gets as he tries to obtain number b is as follows: 10  →  8  →  6  →  4  →  3  →  2  →  1.

In the second sample one of the possible sequences is as follows: 6  →  4  →  3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-6;
const int INF = 0x3fffffff;
const long long LINF = INF * 1ll * INF;
const double PI = acos(-1.0);
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long d[400005];
long long a, b, k, lcm;
long long bfs(long long a, long long target) {
  queue<int> q;
  memset(d, -1, sizeof(d));
  q.push(a);
  d[a] = 0;
  while (!q.empty()) {
    int st = q.front();
    q.pop();
    for (int i = 2; i <= k; i++) {
      if (st % i == 0) continue;
      int tmp = st - st % i;
      if (tmp < 0) tmp += lcm;
      if (d[tmp] <= 0) {
        d[tmp] = d[st] + 1;
        q.push(tmp);
      }
    }
    int tmp = st - 1;
    if (tmp < 0) tmp += lcm;
    if (d[tmp] <= 0) {
      d[tmp] = d[st] + 1;
      q.push(tmp);
    }
  }
  return d[target];
}
int main(void) {
  cin >> a >> b >> k;
  lcm = 1;
  for (int i = 2; i <= k; i++) lcm = lcm / gcd(lcm, i) * i;
  long long ans = 0;
  if (a / lcm == b / lcm) {
    if (a % lcm != b % lcm) ans = bfs(a % lcm, b % lcm);
  } else {
    if (a % lcm) ans += bfs(a % lcm, 0);
    if (b % lcm) ans += bfs(0, b % lcm);
    ans += (a / lcm - b / lcm - 1) * bfs(0, 0);
  }
  cout << ans << endl;
}

```


### Prompt

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

Given are an integer N and arrays S, T, U, and V, each of length N. Construct an N×N matrix a that satisfy the following conditions:

* a_{i,j} is an integer.
* 0 \leq a_{i,j} \lt 2^{64}.
* If S_{i} = 0, the bitwise AND of the elements in the i-th row is U_{i}.
* If S_{i} = 1, the bitwise OR of the elements in the i-th row is U_{i}.
* If T_{i} = 0, the bitwise AND of the elements in the i-th column is V_{i}.
* If T_{i} = 1, the bitwise OR of the elements in the i-th column is V_{i}.

However, there may be cases where no matrix satisfies the conditions.

Constraints

* All values in input are integers.
* 1 \leq N \leq 500
* 0 \leq S_{i} \leq 1
* 0 \leq T_{i} \leq 1
* 0 \leq U_{i} \lt 2^{64}
* 0 \leq V_{i} \lt 2^{64}

Input

Input is given from Standard Input in the following format:

N
S_{1} S_{2} ...  S_{N}
T_{1} T_{2} ...  T_{N}
U_{1} U_{2} ...  U_{N}
V_{1} V_{2} ...  V_{N}

Output

If there exists a matrix that satisfies the conditions, print one such matrix in the following format:

a_{1,1} ...  a_{1,N}
:
a_{N,1} ...  a_{N,N}

Note that any matrix satisfying the conditions is accepted.

If no matrix satisfies the conditions, print -1.

Examples

Input

2
0 1
1 0
1 1
1 0

Output

1 1
1 0

Input

2
1 1
1 0
15 15
15 11

Output

15 11
15 11

### Response

```cpp
#include <cstdio>
#include <cstring>

typedef unsigned long long int ull;

int N;

ull targetOfRow[505],targetOfCol[505];
ull opcatOfRow[505],opcatOfCol[505];
ull matrix[505][505];

int zeroCountOfRow[505],zeroCountOfCol[505];

bool check(){
    //
    for(int r=1;r<=N;r++){
        ull androw=-1,orrow=0ull,andcol=androw,orcol=orrow;
        for(int c=1;c<=N;c++){
            androw&=matrix[r][c];
            orrow|=matrix[r][c];
            andcol&=matrix[c][r];
            orcol|=matrix[c][r];
        }

        if (opcatOfRow[r]&&orrow!=targetOfRow[r]) return false;
        if (!opcatOfRow[r]&&androw!=targetOfRow[r]) return false;
        if (opcatOfCol[r]&&orcol!=targetOfCol[r]) return false;
        if (!opcatOfCol[r]&&andcol!=targetOfCol[r]) return false;
    }

    return true;
}

void simpleInference(int pos){
    for(int r=1;r<=N;r++){
        for(int c=1;c<=N;c++){
            //目標値の対応ビットを取り出す
            auto colBit=(targetOfCol[c]>>pos)&1;
            auto rowBit=(targetOfRow[r]>>pos)&1;

            if (colBit^opcatOfCol[c]) matrix[r][c]|=(colBit<<pos);

            if (rowBit^opcatOfRow[r]) matrix[r][c]|=(rowBit<<pos);

            if (rowBit==colBit) matrix[r][c]|=(rowBit<<pos);
        }
    }
}

void SpecialInference(ull targets[],ull targets2[],ull ops1[],ull ops2[],int zeros1[],int zeros2[],bool isRow,int pos){
    ull mask=(ull)1<<(ull)pos;
    for(int r=1;r<=N;r++){
        //今の桁を何にするかを表す
        auto bitTarget=(targets[r]>>pos)&ops1[r];
        if (!bitTarget||zeros1[r]<N) continue;

        int c=1;
        while(c<=N){
            if (ops2[c]==0&&(targets2[c]&mask)==0&&zeros2[c]>1) break;
            c++;
        }
        if (c>N) continue;
        if (isRow)
            matrix[r][c]|=mask;
        else
            matrix[c][r]|=mask;
        zeros2[c]--;
        zeros1[r]--;
    }
}

int main(){

    scanf("%d",&N);

    for(int i=1;i<=N;i++) scanf("%llu",opcatOfRow+i);
    for(int i=1;i<=N;i++) scanf("%llu",opcatOfCol+i);
    for(int i=1;i<=N;i++) scanf("%llu",targetOfRow+i);
    for(int i=1;i<=N;i++) scanf("%llu",targetOfCol+i);

    for(int bit=0;bit<64;bit++){
        ull mask=(ull)1<<(ull)bit;

        simpleInference(bit);

        memset(zeroCountOfCol,0,sizeof(zeroCountOfCol));
        memset(zeroCountOfRow,0,sizeof(zeroCountOfRow));
        for(int r=1;r<=N;r++)
            for(int w=1;w<=N;w++)
                if ((mask&matrix[r][w])==0) zeroCountOfRow[r]++,zeroCountOfCol[w]++;

        SpecialInference(targetOfRow,targetOfCol,opcatOfRow,opcatOfCol,zeroCountOfRow,zeroCountOfCol,true,bit);
        SpecialInference(targetOfCol,targetOfRow,opcatOfCol,opcatOfRow,zeroCountOfCol,zeroCountOfRow,false,bit);
        // for(int r=1;r<=N;r++){
        //     //今の桁を何にするかを表す
        //     auto bitTarget=(targetOfRow[r]>>bit)&opcatOfRow[r];
        //     if (!bitTarget||zeroCountOfRow[r]<N) continue;

        //     int c=1;
        //     while(c<=N){
        //         if (opcatOfCol[c]==0&&(targetOfCol[c]&mask)==0&&zeroCountOfCol[c]>1) break;
        //         c++;
        //     }
        //     if (c>N) continue;
        //     matrix[r][c]|=mask;
        //     zeroCountOfCol[c]--;
        //     zeroCountOfRow[r]--;
        // }

        // for(int c=1;c<=N;c++){
        //     //今の桁を何にするかを表す
        //     auto bitTarget=(targetOfCol[c]>>bit)&opcatOfCol[c];
        //     if (!bitTarget||zeroCountOfCol[c]<N) continue;
        //     int r=1;
        //     while(r<=N) {
        //         if (opcatOfRow[r]==0&&(targetOfRow[r]&mask)==0&&zeroCountOfRow[r]>1) break;
        //         r++;
        //     }
        //     if (r>N) continue;
        //     matrix[r][c]|=mask;
        //     zeroCountOfCol[c]--;
        //     zeroCountOfRow[r]--;
        // }

    }

    if (!check()){
        puts("-1");
        return 0;
    }

    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++)
            printf("%llu ",matrix[i][j]);
            putchar('\n');
    }

    return 0;
}
```


### Prompt

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

Do you know "sed," a tool provided with Unix? Its most popular use is to substitute every occurrence of a string  contained in the input string (actually each input line) with another string β. More precisely, it proceeds as follows.

1. Within the input string, every non-overlapping (but possibly adjacent) occurrences of α are marked. If there is more than one possibility for non-overlapping matching, the leftmost one is chosen.
2. Each of the marked occurrences is substituted with β to obtain the output string; other parts of the input string remain intact.

For example, when α is "aa" and β is "bca", an input string "aaxaaa" will produce "bcaxbcaa", but not "aaxbcaa" nor "bcaxabca". Further application of the same substitution to the string "bcaxbcaa" will result in "bcaxbcbca", but this is another substitution, which is counted as the second one.

In this problem, a set of substitution pairs (αi, βi) (i = 1, 2, ... , n), an initial string γ, and a final string δ are given, and you must investigate how to produce δ from γ with a minimum number of substitutions. A single substitution (αi, βi) here means simultaneously substituting all the non-overlapping occurrences of αi, in the sense described above, with βi.

You may use a specific substitution (αi, βi ) multiple times, including zero times.

Input

The input consists of multiple datasets, each in the following format.

n
α1 β1
α2 β2
.
.
.
αn βn
γ δ

n is a positive integer indicating the number of pairs. αi and βi are separated by a single space. You may assume that 1 ≤ |αi| < |βi| ≤ 10 for any i (|s| means the length of the string s), αi ≠ αj for any i ≠ j, n ≤ 10 and 1 ≤ |γ| < |δ| ≤ 10. All the strings consist solely of lowercase letters. The end of the input is indicated by a line containing a single zero.

Output

For each dataset, output the minimum number of substitutions to obtain δ from γ. If δ cannot be produced from γ with the given set of substitutions, output -1.

Example

Input

2
a bb
b aa
a
bbbbbbbb
1
a aa
a
aaaaa
3
ab aab
abc aadc
ad dee
abc
deeeeeeeec
10
a abc
b bai
c acf
d bed
e abh
f fag
g abe
h bag
i aaj
j bbb
a
abacfaabe
0

Output

3
-1
7
4

### Response

```cpp
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define mk make_pair
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    set<string>se;
    string s,t,w1,w2;
    string m[n][2];
    r(i,n)cin>>m[i][0]>>m[i][1];
    cin>>s>>t;
    queue<pair<string,int> >q;
    q.push(mk(s,0));
    se.insert(s);
    while(!q.empty()){
      pair<string,int>p=q.front();q.pop();
      string tt=p.first;
      if(tt==t){cout<<p.second<<endl;goto L;}
      for(int i=0;i<n;i++){
        string g,x;
        for(int j=0;j<tt.size();j++){
          string y;
          int hh=0;
          for(int k=j;k<tt.size()+1;k++){
            if(y==m[i][0]){hh++;j=k-1;break;}
            if(k>=tt.size())break;
            y+=tt[k];
          }
          if(!hh)g+=tt[j];
          else g+=m[i][1];
        }
        if(!se.count(g)&&g.size()<=t.size()){
          q.push(mk(g,p.second+1));
          se.insert(g);
        }
      }
    }
    cout<<-1<<endl;L:;
  }
}
```


### Prompt

Develop a solution in Cpp to the problem described below:

Alice wants to send an email to Miku on her mobile phone.

The only buttons that can be used for input on mobile phones are number buttons. Therefore, in order to input characters, the number buttons are pressed several times to input characters. The following characters are assigned to the number buttons of the mobile phone, and the confirmation button is assigned to button 0. With this mobile phone, you are supposed to press the confirm button after you finish entering one character.

* 1:.,!? (Space)
* 2: a b c
* 3: d e f
* 4: g h i
* 5: j k l
* 6: m n o
* 7: p q r s
* 8: t u v
* 9: w x y z
* 0: Confirm button

For example, if you press button 2, button 2, or button 0, the letter changes from'a'to'b', and the confirm button is pressed here, so the letter b is output. If you enter the same number in succession, the changing characters will loop. That is, if you press button 2 five times and then button 0, the letters change from'a'→' b'→'c' →'a' →'b', and the confirm button is pressed here. 'b' is output.

You can press the confirm button when no button is pressed, but in that case no characters are output.

Your job is to recreate the message Alice created from a row of buttons pressed by Alice.

Input

The first line gives the number of test cases. Each test case is then given a string of digits up to 1024 in length in one row.

Output

Print the string of Alice's message line by line for each test case. However, you can assume that the output is one or more and less than 76 characters.

Example

Input

5
20
220
222220
44033055505550666011011111090666077705550301110
000555555550000330000444000080000200004440000

Output

a
b
b
hello, world!
keitai

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
  string table[]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  char str[1280];
  int a;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>str;
    int r=0;
    char now='0';
    for(int i=0;str[i];i++){
            if(now!=str[i]){
                if(now!='0'){
		  cout<<table[now-'0'][(r-1)%table[now-'0'].size()];
                }
                r=1;
                now=str[i];
            }else r++;
    }
	    cout<<endl;
  }
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Petya sometimes has to water his field. To water the field, Petya needs a tank with exactly V ml of water.

Petya has got N tanks, i-th of them initially containing ai ml of water. The tanks are really large, any of them can contain any amount of water (no matter how large this amount is).

Also Petya has got a scoop that can contain up to K ml of water (initially the scoop is empty). This scoop can be used to get some water from some tank, and after that pour it all into some tank (it is impossible to get water from multiple tanks without pouring it, or leave some water in the scoop when pouring it). When Petya tries to get some water from a tank, he gets min(v, K) water, where v is the current volume of water in the tank.

Is it possible to obtain a tank with exactly V ml of water using these operations? If it is possible, print a sequence of operations that allows to do it. If there are multiple ways to obtain needed amount of water in some tank, print any of them.

Input

The first line contains 3 integers: N (2 ≤ N ≤ 5000), K (1 ≤ K ≤ 5000), and V (0 ≤ V ≤ 109) — the number of tanks, the maximum volume of water the scoop can contain, and the required amount of water in some tank, respectively.

The second line contains N integers ai (0 ≤ ai ≤ 105), where ai is initial volume of water in i-th tank.

Output

If it is impossible to obtain a tank with exactly V ml of water, print NO.

Otherwise print YES in the first line, and beginning from the second line, print the sequence of operations in the following format:

Each line has to contain 3 numbers denoting a compressed operation: "cnt x y" (1 ≤ cnt ≤ 109, 1 ≤ x, y ≤ N), where x is the index of the tank where we get water, y is the index of the tank where we pour water, and cnt is the number of times we transfer water from tank x to tank y.

The number of these lines must not exceed N + 5.

Examples

Input

2 3 5
2 3

Output

YES
1 2 1

Input

2 3 4
2 3

Output

NO

Input

5 2 0
1 3 5 7 9

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
const int inf = 1e9;
void dao(int x, int y, int z) {
  if (x) printf("%d %d %d\n", x, y, z);
}
int n, k, v, a[N], b[N];
bool f[N][N], g[N][N];
int main() {
  int i, j, t, r, s = 0;
  scanf("%d%d%d", &n, &k, &v);
  for (i = 1; i <= n; i = i + 1) scanf("%d", a + i), s += a[i];
  if (s < v) {
    printf("NO\n");
    return 0;
  }
  if (v % k == 0) {
    printf("YES\n");
    for (i = 2; i <= n; i = i + 1)
      if (a[i]) dao((a[i] - 1) / k + 1, i, 1);
    dao(v / k, 1, 2);
    return 0;
  }
  f[0][0] = 1;
  for (i = 1; i <= n; i = i + 1)
    for (j = 0; j < k; j = j + 1) {
      if (f[i - 1][j]) f[i][j] = 1, g[i][j] = 0;
      if (f[i - 1][(j - a[i] % k + k) % k]) f[i][j] = 1, g[i][j] = 1;
    }
  if (!f[n][v % k]) {
    printf("NO\n");
    return 0;
  }
  j = v % k;
  for (i = n; i >= 1; i = i - 1) {
    if (g[i][j])
      b[i] = 1, t = i, j = (j - a[i] % k + k) % k;
    else
      b[i] = 0, r = i;
  }
  printf("YES\n");
  s = a[t];
  for (i = 1; i <= n; i = i + 1)
    if (a[i] && b[i] && i != t) dao((a[i] - 1) / k + 1, i, t), r = i, s += a[i];
  for (i = 1; i <= n; i = i + 1)
    if (a[i] && !b[i] && i != r) dao((a[i] - 1) / k + 1, i, r);
  if (s >= v)
    dao((s - v) / k, t, r);
  else
    dao((v - s) / k, r, t);
  return 0;
}

```


### Prompt

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

Problem statement

There is a tree consisting of $ N $ vertices $ N-1 $ edges, and the $ i $ th edge connects the $ u_i $ and $ v_i $ vertices.

Each vertex has a button, and the button at the $ i $ th vertex is called the button $ i $.

First, the beauty of the button $ i $ is $ a_i $.

Each time you press the button $ i $, the beauty of the button $ i $ is given to the adjacent buttons by $ 1 $.

That is, if the $ i $ th vertex is adjacent to the $ c_1, ..., c_k $ th vertex, the beauty of the button $ i $ is reduced by $ k $, and the button $ c_1, ..., The beauty of c_k $ increases by $ 1 $ each.

At this time, you may press the button with negative beauty, or the beauty of the button as a result of pressing the button may become negative.

Your goal is to make the beauty of buttons $ 1, 2, ..., N $ $ b_1, ..., b_N $, respectively.

How many times in total can you press the button to achieve your goal?

Constraint

* All inputs are integers
* $ 1 \ leq N \ leq 10 ^ 5 $
* $ 1 \ leq u_i, v_i \ leq N $
* $ -1000 \ leq a_i, b_i \ leq 1000 $
* $ \ sum_i a_i = \ sum_i b_i $
* The graph given is a tree
* The purpose can always be achieved with the given input

* * *

input

Input is given from standard input in the following format.

$ N $
$ u_1 $ $ v_1 $
$ \ vdots $
$ u_ {N-1} $ $ v_ {N-1} $
$ a_1 $ $ a_2 $ $ ... $ $ a_N $
$ b_1 $ $ b_2 $ $ ... $ $ b_N $

output

Output the minimum total number of button presses to achieve your goal.

* * *

Input example 1

Four
1 2
13
3 4
0 3 2 0
-3 4 5 -1

Output example 1

Four

You can achieve your goal by pressing the button a total of $ 4 $ times as follows, which is the minimum.

* Press the $ 1 $ button $ 2 $ times. The beauty of the buttons $ 1, 2, 3, 4 $ changes to $ -4, 5, 4, 0 $, respectively.
* Press the $ 2 $ button $ 1 $ times. Beauty changes to $ -3, 4, 4, 0 $ respectively.
* Press the $ 4 $ button $ 1 $ times. Beauty changes to $ -3, 4, 5, -1 $ respectively.

* * *

Input example 2

Five
1 2
13
3 4
3 5
-9 5 7 1 8
-7 4 5 1 9

Output example 2

3

Example

Input

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

Output

4

### Response

```cpp
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
vector<vector<int> > g;
vector<ll> c;
vector<ll> sub;
int n;
pair<ll,ll> dfs(int id,int pre){
    ll mi = 0;
    ll sm = 0;
    map<int,ll> mp;
    for(auto x:g[id]){
        if(x!=pre){
            auto y = dfs(x,id);
            chmin(mi,y.first);
            sm += y.second;
            sub[id] += sub[x];
        }
    }
    sub[id]++;
    sm += -mi;
    ll cc = -mi;
    c[id] -= (ll)cc*(ll)g[id].size();
    if(pre!=-1){
        c[pre] += cc;
    }
    for(auto x:g[id]){
        if(x!=pre){
            c[x] += cc;
        }
    }
    for(auto x:g[id]){
        if(x!=pre){
            if(c[x]>0){
                sm += c[x]*sub[x];
                c[id] += c[x];
                c[x] = 0;
            }
        }
    }
    if(c[id]>0){
        sm += sub[id]*c[id];
        c[pre] += c[id];
        c[id] = 0;
    }
    return MP(c[id],sm);
}

int main(){

    cin >> n;
    vector<int>a(n);
    vector<int>b(n);
    sub.resize(n);
    g.resize(n);
    c.resize(n);
    rep(i,n-1){
        int s,t;
        cin >> s >> t;
        s--;t--;
        g[s].push_back(t);
        g[t].push_back(s);
    }
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    rep(i,n)c[i] = a[i]-b[i];
    auto x = dfs(0,-1);
    cout << x.second << endl;
    return 0;
}

```


### Prompt

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

Decimal numbers are a common notation system currently in use and use ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 to represent all numbers.

Binary numbers are a popular notation in the computer world and use two symbols, 0 and 1, to represent all numbers.

Only the four numbers 0, 1, 2, and 3 are used in quaternary numbers. In quaternary numbers, when the number is incremented from 0, it will be carried to the next digit when it reaches 4. Therefore, the decimal number 4 is carried to the expression "10".

Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ...
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |- ---
Binary | 0 | 1 | 10 | 11 | 100 | 101 | 110 | 111 | 1000 | 101 | 1010 | ...
Quadrant | 0 | 1 | 2 | 3 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | ...

In Hawaii, fish and taro were counted between fingers in the old days, so it seems that they used quaternary numbers instead of decimal numbers.

Create a program that converts the integer n input in decimal to decimal and outputs it.

Input

A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of -1. One integer n (0 ≤ n ≤ 1000000) is given on one row for each dataset.

The number of datasets does not exceed 2000.

Output

The result of conversion to quaternary number for each input data set is output on one line.

Example

Input

7
4
0
12
10
10000
-1

Output

13
10
0
30
22
2130100

### Response

```cpp
#include <cstdio>
#include <algorithm>
using namespace std;
int quad[100];

void decToQuad(int n) {
    if (n == 0) { printf("0\n"); return; }
    int idx = 0;
    while (n > 0) {
        quad[idx++] = n%4;
        n /= 4;
    }
    for (int i = idx -1; i >= 0; i--) printf("%d", quad[i]);
    printf("\n");
}

int main()
{
    int n;
    for (; ;) {
        scanf("%d", &n);
        if (n == -1) break;
        decToQuad(n);
    }
    return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor.

There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood will take exactly 1 coin from the richest person in the city and he will give it to the poorest person (poorest person right after taking richest's 1 coin). In case the choice is not unique, he will select one among them at random. Sadly, Robin Hood is old and want to retire in k days. He decided to spend these last days with helping poor people.

After taking his money are taken by Robin Hood richest person may become poorest person as well, and it might even happen that Robin Hood will give his money back. For example if all people have same number of coins, then next day they will have same number of coins too.

Your task is to find the difference between richest and poorest persons wealth after k days. Note that the choosing at random among richest and poorest doesn't affect the answer.

Input

The first line of the input contains two integers n and k (1 ≤ n ≤ 500 000, 0 ≤ k ≤ 109) — the number of citizens in Kekoland and the number of days left till Robin Hood's retirement.

The second line contains n integers, the i-th of them is ci (1 ≤ ci ≤ 109) — initial wealth of the i-th person.

Output

Print a single line containing the difference between richest and poorest peoples wealth.

Examples

Input

4 1
1 1 4 2

Output

2

Input

3 1
2 2 2

Output

0

Note

Lets look at how wealth changes through day in the first sample.

  1. [1, 1, 4, 2]
  2. [2, 1, 3, 2] or [1, 2, 3, 2]

So the answer is 3 - 1 = 2

In second sample wealth will remain the same for each person.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
long long int k;
vector<long long int> v;
vector<long long int> sum;
vector<long long int> tmp_sum;
long long int cnt(long long int L) {
  int id = upper_bound(v.begin(), v.end(), L) - v.begin();
  int cnt = id;
  long long int S = (long long int)(cnt)*L;
  id--;
  if (id >= 0) {
    S -= tmp_sum[id];
  }
  return S;
}
long long int cnt2(long long int L) {
  int id = upper_bound(v.begin(), v.end(), L) - v.begin();
  if (id == v.size()) return 0;
  long long int S = (long long int)(v.size() - id) * L;
  S = sum[id] - S;
  return S;
}
long long int f(long long int mid) { return abs(cnt2(mid) - cnt(mid)); }
int main() {
  scanf("%d%lld", &n, &k);
  for (int i = 0; i < n; i++) {
    long long int a;
    scanf("%lld", &a);
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  long long int mint = v[0];
  long long int maxt = v.back();
  if (mint == maxt) {
    puts("0");
    return 0;
  }
  sum = v;
  for (int i = 1; i < sum.size(); i++) {
    sum[i] += sum[i - 1];
  }
  tmp_sum = sum;
  while (mint + 1LL < maxt) {
    long long mid = (mint + maxt) >> 1LL;
    if (cnt(mid) > k) {
      maxt = mid;
    } else {
      mint = mid;
    }
  }
  long long int __LEF = mint;
  if (cnt(maxt) <= k) {
    __LEF = maxt;
  }
  for (int i = 0; i < v.size(); i++) {
    sum[i] = 0;
  }
  for (int i = v.size() - 1; i >= 0; i--) {
    sum[i] = v[i];
    if (i + 1 < sum.size()) {
      sum[i] += sum[i + 1];
    }
  }
  mint = v[0];
  maxt = v.back();
  while (mint + 1LL < maxt) {
    long long int mid = (mint + maxt) >> 1LL;
    if (cnt2(mid) > k) {
      mint = mid;
    } else {
      maxt = mid;
    }
  }
  long long int __RIG = maxt;
  if (cnt2(mint) <= k) {
    __RIG = mint;
  }
  if (__LEF < __RIG) {
    printf("%lld\n", __RIG - __LEF);
    return 0;
  }
  if (v.size() % 2) {
    long long int mid = v[(v.size()) / 2];
    int idd = -1;
    for (int i = 0; i < v.size(); i++) {
      if (v[i] != mid) {
        idd = i;
        break;
      }
    }
    int iddd = v.size();
    for (int i = v.size() - 1; i >= 0; i--) {
      if (v[i] != mid) {
        iddd = i;
        break;
      }
    }
    if (idd + 1 == v.size() - iddd) {
      if (cnt(mid - 1) == cnt2(mid + 1)) {
        puts("0");
        return 0;
      }
    }
    puts("1");
    return 0;
  } else {
    long long int mint = 0;
    long long int maxt = v.back();
    while (mint + 2LL < maxt) {
      long long int mid = (maxt - mint) / 3LL + mint;
      long long int mid2 = 2LL * (maxt - mint) / 3LL + mint;
      if (f(mid) < f(mid2)) {
        maxt = mid2;
      } else {
        mint = mid;
      }
    }
    long long int MM = LLONG_MAX;
    while (mint <= maxt) {
      MM = min(MM, f(mint));
      mint++;
    }
    if (MM == 0LL) {
      puts("0");
    } else {
      puts("1");
    }
  }
  return 0;
}

```


### Prompt

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

There is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j).

In Cell (i, j), a_{ij} coins are placed.

You can perform the following operation any number of times:

Operation: Choose a cell that was not chosen before and contains one or more coins, then move one of those coins to a vertically or horizontally adjacent cell.

Maximize the number of cells containing an even number of coins.

Constraints

* All values in input are integers.
* 1 \leq H, W \leq 500
* 0 \leq a_{ij} \leq 9

Input

Input is given from Standard Input in the following format:

H W
a_{11} a_{12} ... a_{1W}
a_{21} a_{22} ... a_{2W}
:
a_{H1} a_{H2} ... a_{HW}

Output

Print a sequence of operations that maximizes the number of cells containing an even number of coins, in the following format:

N
y_1 x_1 y_1' x_1'
y_2 x_2 y_2' x_2'
:
y_N x_N y_N' x_N'

That is, in the first line, print an integer N between 0 and H \times W (inclusive), representing the number of operations.

In the (i+1)-th line (1 \leq i \leq N), print four integers y_i, x_i, y_i' and x_i' (1 \leq y_i, y_i' \leq H and 1 \leq x_i, x_i' \leq W), representing the i-th operation. These four integers represents the operation of moving one of the coins placed in Cell (y_i, x_i) to a vertically or horizontally adjacent cell, (y_i', x_i').

Note that if the specified operation violates the specification in the problem statement or the output format is invalid, it will result in Wrong Answer.

Examples

Input

2 3
1 2 3
0 1 1

Output

3
2 2 2 3
1 1 1 2
1 3 1 2

Input

3 2
1 0
2 1
1 0

Output

3
1 1 1 2
1 2 2 2
3 1 3 2

Input

1 5
9 9 9 9 9

Output

2
1 1 1 2
1 3 1 4

### Response

```cpp
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int h,w;
  cin >> h >> w;;
  int** a = new int*[500];
  stringstream ans;
  int counter = 0;
  for(int i=0;i<h;i++){
    a[i] = new int[500];
    for(int j=0;j<w;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++){
      if(a[i][j]%2==1){
        counter++;
        ans << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
        a[i][j+1] += 1;
      }
    }
  }
  for(int i=0;i<h-1;i++){
    if(a[i][w-1]%2==1){
        counter++;
        ans << i+1 << " " << w << " " << i+2 << " " << w << endl;
        a[i+1][w-1] += 1;
    }
  }
  cout << counter << endl;
  cout << ans.str();
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Berland Football Cup starts really soon! Commentators from all over the world come to the event.

Organizers have already built n commentary boxes. m regional delegations will come to the Cup. Every delegation should get the same number of the commentary boxes. If any box is left unoccupied then the delegations will be upset. So each box should be occupied by exactly one delegation.

If n is not divisible by m, it is impossible to distribute the boxes to the delegations at the moment.

Organizers can build a new commentary box paying a burles and demolish a commentary box paying b burles. They can both build and demolish boxes arbitrary number of times (each time paying a corresponding fee). It is allowed to demolish all the existing boxes.

What is the minimal amount of burles organizers should pay to satisfy all the delegations (i.e. to make the number of the boxes be divisible by m)?

Input

The only line contains four integer numbers n, m, a and b (1 ≤ n, m ≤ 10^{12}, 1 ≤ a, b ≤ 100), where n is the initial number of the commentary boxes, m is the number of delegations to come, a is the fee to build a box and b is the fee to demolish a box.

Output

Output the minimal amount of burles organizers should pay to satisfy all the delegations (i.e. to make the number of the boxes be divisible by m). It is allowed that the final number of the boxes is equal to 0.

Examples

Input

9 7 3 8

Output

15

Input

2 7 3 7

Output

14

Input

30 6 17 19

Output

0

Note

In the first example organizers can build 5 boxes to make the total of 14 paying 3 burles for the each of them.

In the second example organizers can demolish 2 boxes to make the total of 0 paying 7 burles for the each of them.

In the third example organizers are already able to distribute all the boxes equally among the delegations, each one get 5 boxes.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = INT_MAX;
const long long int infl = LLONG_MAX;
long long int n, i, j, k, m, a, b;
int main() {
  cin >> n >> m >> a >> b;
  long long int x = n % m;
  long long int cost2 = x * b;
  long long int cost1 = (m - x) * a;
  cout << min(cost1, cost2);
  return 0;
}

```


### Prompt

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

Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task.

Two matrices A and B are given, each of them has size n × m. Nastya can perform the following operation to matrix A unlimited number of times:

  * take any square square submatrix of A and transpose it (i.e. the element of the submatrix which was in the i-th row and j-th column of the submatrix will be in the j-th row and i-th column after transposing, and the transposed submatrix itself will keep its place in the matrix A).

Nastya's task is to check whether it is possible to transform the matrix A to the matrix B.

<image> Example of the operation

As it may require a lot of operations, you are asked to answer this question for Nastya.

A square submatrix of matrix M is a matrix which consist of all elements which comes from one of the rows with indeces x, x+1, ..., x+k-1 of matrix M and comes from one of the columns with indeces y, y+1, ..., y+k-1 of matrix M. k is the size of square submatrix. In other words, square submatrix is the set of elements of source matrix which form a solid square (i.e. without holes).

Input

The first line contains two integers n and m separated by space (1 ≤ n, m ≤ 500) — the numbers of rows and columns in A and B respectively.

Each of the next n lines contains m integers, the j-th number in the i-th of these lines denotes the j-th element of the i-th row of the matrix A (1 ≤ A_{ij} ≤ 10^{9}).

Each of the next n lines contains m integers, the j-th number in the i-th of these lines denotes the j-th element of the i-th row of the matrix B (1 ≤ B_{ij} ≤ 10^{9}).

Output

Print "YES" (without quotes) if it is possible to transform A to B and "NO" (without quotes) otherwise.

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

Examples

Input

2 2
1 1
6 1
1 6
1 1

Output

YES

Input

2 2
4 4
4 5
5 4
4 4

Output

NO

Input

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

Output

YES

Note

Consider the third example. The matrix A initially looks as follows.

$$$ \begin{bmatrix} 1 & 2 & 3\\\ 4 & 5 & 6\\\ 7 & 8 & 9 \end{bmatrix} $$$

Then we choose the whole matrix as transposed submatrix and it becomes

$$$ \begin{bmatrix} 1 & 4 & 7\\\ 2 & 5 & 8\\\ 3 & 6 & 9 \end{bmatrix} $$$

Then we transpose the submatrix with corners in cells (2, 2) and (3, 3).

$$$ \begin{bmatrix} 1 & 4 & 7\\\ 2 & 5 & 8\\\ 3 & 6 & 9 \end{bmatrix} $$$

So matrix becomes

$$$ \begin{bmatrix} 1 & 4 & 7\\\ 2 & 5 & 6\\\ 3 & 8 & 9 \end{bmatrix} $$$

and it is B.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
int n, m;
vector<int> vec[2][1100];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int k = 0; k < 2; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        int tmp = i + j, x;
        cin >> x;
        vec[k][tmp].push_back(x);
      }
    }
  }
  for (int i = 0; i < n + m; i++) {
    sort(vec[0][i].begin(), vec[0][i].end());
    sort(vec[1][i].begin(), vec[1][i].end());
    int len = vec[0][i].size();
    for (int j = 0; j < len; j++) {
      if (vec[0][i][j] != vec[1][i][j]) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  return 0;
}

```


### Prompt

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

Arkady wants to have a dinner. He has just returned from a shop where he has bought a semifinished cutlet. He only needs to fry it. The cutlet should be fried for 2n seconds, in particular, it should be fried for n seconds on one side and n seconds on the other side. Arkady has already got a frying pan and turn on fire, but understood that maybe he won't be able to flip the cutlet exactly after n seconds after the beginning of cooking.

Arkady is too busy with sorting sticker packs in his favorite messenger and can flip the cutlet only in some periods of time. Namely, there are k periods of time in which he can do it, the i-th of them is an interval of time from li seconds after he starts cooking till ri seconds, inclusive. Arkady decided that it's not required to flip the cutlet exactly in the middle of cooking, instead, he will flip it several times in such a way that the cutlet will be fried exactly n seconds on one side and n seconds on the other side in total.

Help Arkady and find out if it's possible for him to cook the cutlet, if he is able to flip the cutlet only in given periods of time; and if yes, find the minimum number of flips he needs to cook the cutlet.

Input

The first line contains two integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ 100) — the number of seconds the cutlet should be cooked on each side and number of periods of time in which Arkady can flip it.

The next k lines contain descriptions of these intervals. Each line contains two integers li and ri (0 ≤ li ≤ ri ≤ 2·n), meaning that Arkady can flip the cutlet in any moment starting from li seconds after the beginning of cooking and finishing at ri seconds after beginning of cooking. In particular, if li = ri then Arkady can flip the cutlet only in the moment li = ri. It's guaranteed that li > ri - 1 for all 2 ≤ i ≤ k.

Output

Output "Hungry" if Arkady won't be able to fry the cutlet for exactly n seconds on one side and exactly n seconds on the other side.

Otherwise, output "Full" in the first line, and the minimum number of times he should flip the cutlet in the second line.

Examples

Input

10 2
3 5
11 13

Output

Full
2

Input

10 3
3 5
9 10
11 13

Output

Full
1

Input

20 1
3 19

Output

Hungry

Note

In the first example Arkady should flip the cutlet in time moment 3 seconds after he starts cooking and in time moment 13 seconds after he starts cooking.

In the second example, Arkady can flip the cutlet at 10 seconds after he starts cooking.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int BUF = 100005;
const int RANGE = 105;
int leng, nRange;
int range[RANGE][2];
void read() {
  cin >> leng >> nRange;
  for (int i = 0; i < nRange; ++i) {
    cin >> range[i][0] >> range[i][1];
  }
}
void work() {
  int dp[2][BUF];
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j <= leng; ++j) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  for (int rangeId = 0; rangeId < nRange; ++rangeId) {
    int nextDp[2][BUF];
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j <= leng; ++j) {
        nextDp[i][j] = INF;
      }
    }
    int dt;
    dt = range[rangeId][0] - (rangeId == 0 ? 0 : range[rangeId - 1][1]);
    for (int i = 0; i <= leng; ++i) {
      if (i >= dt) {
        nextDp[0][i] = min(nextDp[0][i], dp[0][i - dt]);
      }
      nextDp[1][i] = min(nextDp[1][i], dp[1][i]);
    }
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j <= leng; ++j) {
        dp[i][j] = nextDp[i][j];
        nextDp[i][j] = INF;
      }
    }
    dt = range[rangeId][1] - range[rangeId][0];
    deque<int> DQ[2];
    for (int i = 0; i <= leng; ++i) {
      while (DQ[0].size() > 0 && DQ[0].back() > dp[0][i]) DQ[0].pop_back();
      DQ[0].push_back(dp[0][i]);
      while (DQ[1].size() > 0 && DQ[1].back() > dp[1][i]) DQ[1].pop_back();
      DQ[1].push_back(dp[1][i]);
      if (i >= dt) {
        nextDp[0][i] = min(nextDp[0][i], dp[0][i - dt]);
      }
      nextDp[1][i] = min(nextDp[1][i], dp[1][i]);
      if (DQ[1].size() > 0) nextDp[0][i] = min(nextDp[0][i], DQ[1].front() + 1);
      if (DQ[0].size() > 0) nextDp[1][i] = min(nextDp[1][i], DQ[0].front() + 1);
      if (DQ[0].size() > 0) nextDp[0][i] = min(nextDp[0][i], DQ[0].front() + 2);
      if (DQ[1].size() > 0) nextDp[1][i] = min(nextDp[1][i], DQ[1].front() + 2);
      if (DQ[0].size() > 0 && i - dt >= 0 && DQ[0].front() == dp[0][i - dt])
        DQ[0].pop_front();
      if (DQ[1].size() > 0 && i - dt >= 0 && DQ[1].front() == dp[1][i - dt])
        DQ[1].pop_front();
    }
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j <= leng; ++j) {
        dp[i][j] = nextDp[i][j];
      }
    }
  }
  int nextDp[2][BUF];
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j <= leng; ++j) {
      nextDp[i][j] = INF;
    }
  }
  int dt = leng * 2 - range[nRange - 1][1];
  for (int i = 0; i <= leng; ++i) {
    if (i >= dt) {
      nextDp[0][i] = min(nextDp[0][i], dp[0][i - dt]);
    }
    nextDp[1][i] = min(nextDp[1][i], dp[1][i]);
  }
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j <= leng; ++j) {
      dp[i][j] = nextDp[i][j];
    }
  }
  if (dp[0][leng] != INF || dp[1][leng] != INF) {
    cout << "Full" << endl;
    cout << min(dp[0][leng], dp[1][leng]) << endl;
  } else {
    cout << "Hungry" << endl;
  }
}
int main() {
  read();
  work();
  return 0;
}

```


### Prompt

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

You get to work and turn on the computer. You start coding and give little thought to the RAM role in the whole process. In this problem your task is to solve one of the problems you encounter in your computer routine.

We'll consider the RAM as a sequence of cells that can contain data. Some cells already contain some data, some are empty. The empty cells form the so-called memory clusters. Thus, a memory cluster is a sequence of some consecutive empty memory cells.

You have exactly n memory clusters, the i-th cluster consists of ai cells. You need to find memory for m arrays in your program. The j-th array takes 2bj consecutive memory cells. There possibly isn't enough memory for all m arrays, so your task is to determine what maximum number of arrays can be located in the available memory clusters. Of course, the arrays cannot be divided between the memory clusters. Also, no cell can belong to two arrays.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 106). The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109). The next line contains m integers b1, b2, ..., bm (1 ≤ 2bi ≤ 109).

Output

Print a single integer — the answer to the problem.

Examples

Input

5 3
8 4 3 2 2
3 2 2

Output

2

Input

10 6
1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0

Output

6

Note

In the first example you are given memory clusters with sizes 8, 4, 3, 2, 2 and arrays with sizes 8, 4, 4. There are few ways to obtain an answer equals 2: you can locate array with size 8 to the cluster with size 8, and one of the arrays with size 4 to the cluster with size 4. Another way is to locate two arrays with size 4 to the one cluster with size 8.

In the second example you are given 10 memory clusters with size 1 and 6 arrays with size 1. You can choose any 6 clusters and locate all given arrays to them.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, foo;
const int oo = 1e9;
int p[33];
int a[1000000];
int st[222], cnt[33];
void pull(int idx) { st[idx] = min(st[idx + idx], st[idx + idx + 1]); }
int query(int idx, int l, int r, int i, int j) {
  if (l > j || r < i) {
    return oo;
  }
  if (l >= i && r <= j) {
    return st[idx];
  }
  return min(query(idx + idx, l, (r + l) / 2, i, j),
             query(idx + idx + 1, (r + l) / 2 + 1, r, i, j));
}
void update(int idx, int l, int r, int i, int j, int val) {
  if (l > j || r < i) {
    return;
  }
  if (l == r && l == i) {
    cnt[l] += val;
    if (cnt[l] == 0) {
      st[idx] = oo;
    } else {
      st[idx] = l;
    }
    return;
  }
  update(idx + idx, l, (r + l) / 2, i, j, val);
  update(idx + idx + 1, (r + l) / 2 + 1, r, i, j, val);
  pull(idx);
}
void get(int x) {
  int bit = 0;
  while (x) {
    if (x & 1) {
      if (cnt[bit]) {
        cnt[bit]++;
      } else {
        update(1, 0, 30, bit, bit, 1);
      }
    }
    x >>= 1;
    bit++;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < 222; i++) {
    st[i] = oo;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &foo);
    get(foo);
  }
  p[0] = 1;
  for (int i = 1; i <= 30; i++) {
    p[i] = p[i - 1] << 1;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + m);
  int ans = 0;
  for (int i = 0; i < m; i++) {
    int mn = query(1, 0, 30, a[i], 30);
    if (mn == oo) {
      break;
    }
    ans++;
    update(1, 0, 30, mn, mn, -1);
    if (mn > a[i]) {
      get(p[mn] - p[a[i]]);
    }
  }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

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

Gerald has been selling state secrets at leisure. All the secrets cost the same: n marks. The state which secrets Gerald is selling, has no paper money, only coins. But there are coins of all positive integer denominations that are powers of three: 1 mark, 3 marks, 9 marks, 27 marks and so on. There are no coins of other denominations. Of course, Gerald likes it when he gets money without the change. And all buyers respect him and try to give the desired sum without change, if possible. But this does not always happen.

One day an unlucky buyer came. He did not have the desired sum without change. Then he took out all his coins and tried to give Gerald a larger than necessary sum with as few coins as possible. What is the maximum number of coins he could get?

The formal explanation of the previous paragraph: we consider all the possible combinations of coins for which the buyer can not give Gerald the sum of n marks without change. For each such combination calculate the minimum number of coins that can bring the buyer at least n marks. Among all combinations choose the maximum of the minimum number of coins. This is the number we want.

Input

The single line contains a single integer n (1 ≤ n ≤ 1017).

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

Output

In a single line print an integer: the maximum number of coins the unlucky buyer could have paid with.

Examples

Input

1

Output

1

Input

4

Output

2

Note

In the first test case, if a buyer has exactly one coin of at least 3 marks, then, to give Gerald one mark, he will have to give this coin. In this sample, the customer can not have a coin of one mark, as in this case, he will be able to give the money to Gerald without any change.

In the second test case, if the buyer had exactly three coins of 3 marks, then, to give Gerald 4 marks, he will have to give two of these coins. The buyer cannot give three coins as he wants to minimize the number of coins that he gives.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int te;
  cin >> te;
  long long int cg = 3;
  long long int ans = 1;
  while (cg < te) {
    if (te % cg != 0) {
      ans = te / cg;
      ans++;
      break;
    } else
      cg *= 3;
  }
  cout << ans << "\n";
  return 0;
}

```


### Prompt

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

Tomorrow is a difficult day for Polycarp: he has to attend a lectures and b practical classes at the university! Since Polycarp is a diligent student, he is going to attend all of them.

While preparing for the university, Polycarp wonders whether he can take enough writing implements to write all of the lectures and draw everything he has to during all of the practical classes. Polycarp writes lectures using a pen (he can't use a pencil to write lectures!); he can write down c lectures using one pen, and after that it runs out of ink. During practical classes Polycarp draws blueprints with a pencil (he can't use a pen to draw blueprints!); one pencil is enough to draw all blueprints during d practical classes, after which it is unusable.

Polycarp's pencilcase can hold no more than k writing implements, so if Polycarp wants to take x pens and y pencils, they will fit in the pencilcase if and only if x + y ≤ k.

Now Polycarp wants to know how many pens and pencils should he take. Help him to determine it, or tell that his pencilcase doesn't have enough room for all the implements he needs tomorrow!

Note that you don't have to minimize the number of writing implements (though their total number must not exceed k).

Input

The first line of the input contains one integer t (1 ≤ t ≤ 100) — the number of test cases in the input. Then the test cases follow.

Each test case is described by one line containing five integers a, b, c, d and k, separated by spaces (1 ≤ a, b, c, d, k ≤ 100) — the number of lectures Polycarp has to attend, the number of practical classes Polycarp has to attend, the number of lectures which can be written down using one pen, the number of practical classes for which one pencil is enough, and the number of writing implements that can fit into Polycarp's pencilcase, respectively.

In hacks it is allowed to use only one test case in the input, so t = 1 should be satisfied.

Output

For each test case, print the answer as follows:

If the pencilcase can't hold enough writing implements to use them during all lectures and practical classes, print one integer -1. Otherwise, print two non-negative integers x and y — the number of pens and pencils Polycarp should put in his pencilcase. If there are multiple answers, print any of them. Note that you don't have to minimize the number of writing implements (though their total number must not exceed k).

Example

Input

3
7 5 4 5 8
7 5 4 5 2
20 53 45 26 4

Output

7 1
-1
1 3

Note

There are many different answers for the first test case; x = 7, y = 1 is only one of them. For example, x = 3, y = 1 is also correct.

x = 1, y = 3 is the only correct answer for the third test case.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0 || a == 0) return a + b;
  return gcd(b, a % b);
}
const int inf = int(1e9);
const int mod = inf + 7;
void solve() {
  int a, b, c, d, k;
  cin >> a >> b >> c >> d >> k;
  int x = a / c + (a % c != 0);
  int y = b / d + (b % d != 0);
  if (x + y > k)
    cout << -1 << endl;
  else
    cout << x << " " << y << endl;
}
int main() {
  int t = 1;
  cin >> t;
  while (t--) solve();
}

```


### Prompt

Please create a solution in Cpp to the following problem:

You are given an array a_1, a_2, …, a_n of integers. This array is non-increasing.

Let's consider a line with n shops. The shops are numbered with integers from 1 to n from left to right. The cost of a meal in the i-th shop is equal to a_i.

You should process q queries of two types:

  * 1 x y: for each shop 1 ≤ i ≤ x set a_{i} = max(a_{i}, y).
  * 2 x y: let's consider a hungry man with y money. He visits the shops from x-th shop to n-th and if he can buy a meal in the current shop he buys one item of it. Find how many meals he will purchase. The man can buy a meal in the shop i if he has at least a_i money, and after it his money decreases by a_i.

Input

The first line contains two integers n, q (1 ≤ n, q ≤ 2 ⋅ 10^5).

The second line contains n integers a_{1},a_{2}, …, a_{n} (1 ≤ a_{i} ≤ 10^9) — the costs of the meals. It is guaranteed, that a_1 ≥ a_2 ≥ … ≥ a_n.

Each of the next q lines contains three integers t, x, y (1 ≤ t ≤ 2, 1≤ x ≤ n, 1 ≤ y ≤ 10^9), each describing the next query.

It is guaranteed that there exists at least one query of type 2.

Output

For each query of type 2 output the answer on the new line.

Example

Input

10 6
10 10 10 6 6 5 5 5 3 1
2 3 50
2 4 10
1 3 10
2 2 36
1 4 7
2 2 17

Output

8
3
6
2

Note

In the first query a hungry man will buy meals in all shops from 3 to 10.

In the second query a hungry man will buy meals in shops 4, 9, and 10.

After the third query the array a_1, a_2, …, a_n of costs won't change and will be \{10, 10, 10, 6, 6, 5, 5, 5, 3, 1\}.

In the fourth query a hungry man will buy meals in shops 2, 3, 4, 5, 9, and 10.

After the fifth query the array a of costs will be \{10, 10, 10, 7, 6, 5, 5, 5, 3, 1\}.

In the sixth query a hungry man will buy meals in shops 2 and 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long X = 0;
  bool flag = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = 0;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    X = (X << 1) + (X << 3) + ch - '0';
    ch = getchar();
  }
  if (flag) return X;
  return ~(X - 1);
}
const int N = 5e5 + 5, SZ = N << 2, INF = 0x7fffffff;
int n, m;
int a[N];
struct data {
  int mx, mx2, mn, mn2, cmx, cmn, tmx, tmn, tad;
  long long sum;
};
data t[SZ];
void pushup(int u) {
  const int lu = u << 1, ru = u << 1 | 1;
  t[u].sum = t[lu].sum + t[ru].sum;
  if (t[lu].mx == t[ru].mx) {
    t[u].mx = t[lu].mx, t[u].cmx = t[lu].cmx + t[ru].cmx;
    t[u].mx2 = max(t[lu].mx2, t[ru].mx2);
  } else if (t[lu].mx > t[ru].mx) {
    t[u].mx = t[lu].mx, t[u].cmx = t[lu].cmx;
    t[u].mx2 = max(t[lu].mx2, t[ru].mx);
  } else {
    t[u].mx = t[ru].mx, t[u].cmx = t[ru].cmx;
    t[u].mx2 = max(t[lu].mx, t[ru].mx2);
  }
  if (t[lu].mn == t[ru].mn) {
    t[u].mn = t[lu].mn, t[u].cmn = t[lu].cmn + t[ru].cmn;
    t[u].mn2 = min(t[lu].mn2, t[ru].mn2);
  } else if (t[lu].mn < t[ru].mn) {
    t[u].mn = t[lu].mn, t[u].cmn = t[lu].cmn;
    t[u].mn2 = min(t[lu].mn2, t[ru].mn);
  } else {
    t[u].mn = t[ru].mn, t[u].cmn = t[ru].cmn;
    t[u].mn2 = min(t[lu].mn, t[ru].mn2);
  }
}
void push_add(int u, int l, int r, int v) {
  t[u].sum += (r - l + 1ll) * v;
  t[u].mx += v, t[u].mn += v;
  if (t[u].mx2 != -INF) t[u].mx2 += v;
  if (t[u].mn2 != INF) t[u].mn2 += v;
  if (t[u].tmx != -INF) t[u].tmx += v;
  if (t[u].tmn != INF) t[u].tmn += v;
  t[u].tad += v;
}
void push_min(int u, int tg) {
  if (t[u].mx <= tg) return;
  t[u].sum += (tg * 1ll - t[u].mx) * t[u].cmx;
  if (t[u].mn2 == t[u].mx) t[u].mn2 = tg;
  if (t[u].mn == t[u].mx) t[u].mn = tg;
  if (t[u].tmx > tg) t[u].tmx = tg;
  t[u].mx = tg, t[u].tmn = tg;
}
void push_max(int u, int tg) {
  if (t[u].mn > tg) return;
  t[u].sum += (tg * 1ll - t[u].mn) * t[u].cmn;
  if (t[u].mx2 == t[u].mn) t[u].mx2 = tg;
  if (t[u].mx == t[u].mn) t[u].mx = tg;
  if (t[u].tmn < tg) t[u].tmn = tg;
  t[u].mn = tg, t[u].tmx = tg;
}
void pushdown(int u, int l, int r) {
  const int lu = u << 1, ru = u << 1 | 1, mid = (l + r) >> 1;
  if (t[u].tad)
    push_add(lu, l, mid, t[u].tad), push_add(ru, mid + 1, r, t[u].tad);
  if (t[u].tmx != -INF) push_max(lu, t[u].tmx), push_max(ru, t[u].tmx);
  if (t[u].tmn != INF) push_min(lu, t[u].tmn), push_min(ru, t[u].tmn);
  t[u].tad = 0, t[u].tmx = -INF, t[u].tmn = INF;
}
void build(int u = 1, int l = 1, int r = n) {
  t[u].tmn = INF, t[u].tmx = -INF;
  if (l == r) {
    t[u].sum = t[u].mx = t[u].mn = a[l];
    t[u].mx2 = -INF, t[u].mn2 = INF;
    t[u].cmx = t[u].cmn = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(u << 1, l, mid), build(u << 1 | 1, mid + 1, r);
  pushup(u);
}
void add(int L, int R, int v, int u = 1, int l = 1, int r = n) {
  if (R < l || r < L) return;
  if (L <= l && r <= R) return push_add(u, l, r, v);
  int mid = (l + r) >> 1;
  pushdown(u, l, r);
  add(L, R, v, u << 1, l, mid), add(L, R, v, u << 1 | 1, mid + 1, r);
  pushup(u);
}
void tomax(int L, int R, int v, int u = 1, int l = 1, int r = n) {
  if (R < l || r < L || t[u].mn >= v) return;
  if (L <= l && r <= R && t[u].mn2 > v) return push_max(u, v);
  int mid = (l + r) >> 1;
  pushdown(u, l, r);
  tomax(L, R, v, u << 1, l, mid), tomax(L, R, v, u << 1 | 1, mid + 1, r);
  pushup(u);
}
long long qmin(int L, int R, int u = 1, int l = 1, int r = n) {
  if (R < l || r < L) return INF;
  if (L <= l && r <= R) return t[u].mn;
  int mid = (l + r) >> 1;
  pushdown(u, l, r);
  return min(qmin(L, R, u << 1, l, mid), qmin(L, R, u << 1 | 1, mid + 1, r));
}
int y;
int bns(int l, int r) {
  int res = -1;
  while (l <= r) {
    int md = l + r >> 1;
    if (qmin(md, md) <= y)
      res = md, r = md - 1;
    else
      l = md + 1;
  }
  return res;
}
long long qsum(int L, int R, int u = 1, int l = 1, int r = n) {
  if (R < l || r < L) return 0;
  int mid = (l + r) >> 1;
  if (L <= l && r <= R) {
    if (t[u].sum <= y && y > 0) {
      y -= t[u].sum;
      return r - l + 1;
    } else {
      pushdown(u, l, r);
      if (t[u].mn > y) return 0;
      return qsum(L, R, u << 1, l, mid) + qsum(L, R, u << 1 | 1, mid + 1, r);
    }
  }
  pushdown(u, l, r);
  return qsum(L, R, u << 1, l, mid) + qsum(L, R, u << 1 | 1, mid + 1, r);
}
int main() {
  n = rd();
  m = rd();
  for (int i = 1; i <= n; i++) a[i] = rd();
  build();
  for (int i = 1; i <= m; i++) {
    int op, l, x;
    op = rd(), l = rd(), y = rd();
    if (op == 1)
      tomax(1, l, y);
    else
      printf("%lld\n", qsum(l, n));
  }
  return 0;
}

```