### Prompt

Develop a solution in Cpp to the problem described below:

Bananistan is a beautiful banana republic. Beautiful women in beautiful dresses. Beautiful statues of beautiful warlords. Beautiful stars in beautiful nights.

In Bananistan people play this crazy game – Bulbo. There’s an array of bulbs and player at the position, which represents one of the bulbs. The distance between two neighboring bulbs is 1. Before each turn player can change his position with cost |posnew - posold|. After that, a contiguous set of bulbs lights-up and player pays the cost that’s equal to the distance to the closest shining bulb. Then, all bulbs go dark again. The goal is to minimize your summed cost. I tell you, Bananistanians are spending their nights playing with bulbs.

Banana day is approaching, and you are hired to play the most beautiful Bulbo game ever. A huge array of bulbs is installed, and you know your initial position and all the light-ups in advance. You need to play the ideal game and impress Bananistanians, and their families.

Input

The first line contains number of turns n and initial position x. Next n lines contain two numbers lstart and lend, which represent that all bulbs from interval [lstart, lend] are shining this turn.

  * 1 ≤ n ≤ 5000
  * 1 ≤ x ≤ 109
  * 1 ≤ lstart ≤ lend ≤ 109

Output

Output should contain a single number which represents the best result (minimum cost) that could be obtained by playing this Bulbo game.

Examples

Input

5 4
2 7
9 16
8 10
9 17
1 6

Output

8

Note

Before 1. turn move to position 5

Before 2. turn move to position 9

Before 5. turn move to position 8

### Response

```cpp
#include <bits/stdc++.h>
const int INF = 1e9;
const long long lINF = 1e18;
const double EPS = 1e-12;
using namespace std;
const int MOD = 1e9 + 7;
int n;
int l[5555], r[5555];
int x;
int main() {
  scanf("%d %d", &n, &x);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", l + i, r + i);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (l[i] > x) {
      vector<int> v;
      int mn = INF;
      for (int j = i; j < n; j++) {
        mn = min(mn, r[j]);
        if (l[j] > x) {
          v.push_back(min(l[j], mn));
        }
      }
      sort((v).begin(), (v).end());
      if (v.size() >= 2) {
        v[v.size() - 2] = max(v[v.size() - 2], x);
        ans += abs(v[v.size() - 2] - x);
        x = v[v.size() - 2];
      }
      if (x < l[i]) {
        ans += l[i] - x;
      }
      if (x > r[i]) {
        ans += x - r[i];
      }
    } else if (r[i] < x) {
      vector<int> v;
      int mx = -INF;
      for (int j = i; j < n; j++) {
        mx = max(mx, l[j]);
        if (r[j] < x) {
          v.push_back(max(r[j], mx));
        }
      }
      sort((v).begin(), (v).end());
      reverse((v).begin(), (v).end());
      if (v.size() >= 2) {
        v[v.size() - 2] = min(v[v.size() - 2], x);
        ans += abs(v[v.size() - 2] - x);
        x = v[v.size() - 2];
      }
      if (x < l[i]) {
        ans += l[i] - x;
      }
      if (x > r[i]) {
        ans += x - r[i];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

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

Professor Vasechkin is studying evolution of worms. Recently he put forward hypotheses that all worms evolve by division. There are n forms of worms. Worms of these forms have lengths a1, a2, ..., an. To prove his theory, professor needs to find 3 different forms that the length of the first form is equal to sum of lengths of the other two forms. Help him to do this.

Input

The first line contains integer n (3 ≤ n ≤ 100) — amount of worm's forms. The second line contains n space-separated integers ai (1 ≤ ai ≤ 1000) — lengths of worms of each form.

Output

Output 3 distinct integers i j k (1 ≤ i, j, k ≤ n) — such indexes of worm's forms that ai = aj + ak. If there is no such triple, output -1. If there are several solutions, output any of them. It possible that aj = ak.

Examples

Input

5
1 2 3 5 7

Output

3 2 1

Input

5
1 8 1 5 1

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
const int MAXN = 110 + 1;
int n, a[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      for (int k = 0; k < n; k++) {
        if (i == k || j == k) continue;
        if (a[i] == a[j] + a[k]) {
          printf("%d %d %d\n", i + 1, j + 1, k + 1);
          return 0;
        }
      }
    }
  }
  puts("-1");
  return 0;
}

```


### Prompt

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

Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.

Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will start painting squares one by one from left to right, starting from the square number 1 and some arbitrary color. If the square was painted in color x, then the next square will be painted in color x + 1. In case of x = n, next square is painted in color 1. If there is no more paint of the color Vika wants to use now, then she stops.

Square is always painted in only one color, and it takes exactly 1 liter of paint. Your task is to calculate the maximum number of squares that might be painted, if Vika chooses right color to paint the first square.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has.

The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that Vika has.

Output

The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.

Examples

Input

5
2 4 2 3 3

Output

12

Input

3
5 5 5

Output

15

Input

6
10 10 10 1 10 10

Output

11

Note

In the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.

In the second sample Vika can start to paint using any color.

In the third sample Vika should start painting using color number 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<long long int> arr;
vector<long long int> b;
long long int l, f;
long long int mid;
long long int bin_s(long long int x) {
  l = 0;
  f = b.size() - 1;
  while (l <= f) {
    mid = (l + f) / 2;
    if (b[mid] > x) f = mid - 1;
    if (b[mid] < x) l = mid + 1;
    if (b[mid] == x) {
      return 1;
      break;
    }
  }
  return 0;
}
int main() {
  long long int n, i, j, k, q;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> q;
    arr.push_back(q);
  }
  long long int min = arr[0];
  for (i = 0; i < n; i++) {
    if (arr[i] <= min) min = arr[i];
  }
  for (i = 0; i < n; i++) {
    if (arr[i] == min) b.push_back(i);
  }
  long long int c;
  long long int max = 0;
  long long int ways;
  for (i = 0; i < n; i++) {
    c = bin_s(i);
    if (c == 1) {
      ways = min * n;
    }
    if (c == 0) {
      if (b[b.size() - 1] > i) ways = (min * n) + b[l] - i;
      if (b[b.size() - 1] < i) ways = (min * n) + n - i + b[0];
    }
    if (ways > max) max = ways;
  }
  cout << max << endl;
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Recently Luba bought a monitor. Monitor is a rectangular matrix of size n × m. But then she started to notice that some pixels cease to work properly. Luba thinks that the monitor will become broken the first moment when it contains a square k × k consisting entirely of broken pixels. She knows that q pixels are already broken, and for each of them she knows the moment when it stopped working. Help Luba to determine when the monitor became broken (or tell that it's still not broken even after all q pixels stopped working).

Input

The first line contains four integer numbers n, m, k, q (1 ≤ n, m ≤ 500, 1 ≤ k ≤ min(n, m), 0 ≤ q ≤ n·m) — the length and width of the monitor, the size of a rectangle such that the monitor is broken if there is a broken rectangle with this size, and the number of broken pixels.

Each of next q lines contain three integer numbers xi, yi, ti (1 ≤ xi ≤ n, 1 ≤ yi ≤ m, 0 ≤ t ≤ 109) — coordinates of i-th broken pixel (its row and column in matrix) and the moment it stopped working. Each pixel is listed at most once.

We consider that pixel is already broken at moment ti.

Output

Print one number — the minimum moment the monitor became broken, or "-1" if it's still not broken after these q pixels stopped working.

Examples

Input

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

Output

8

Input

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

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 5e2 + 10;
const long long INF = 1e12 + 10;
long long a[MAXN][MAXN];
long long b[MAXN][MAXN];
long long ps[MAXN][MAXN];
long long n, m, k, q;
bool ok(long long f) {
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= m; j++) {
      b[i][j] = (a[i][j] <= f);
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      ps[i][j] = ps[i - 1][j] + ps[i][j - 1] - ps[i - 1][j - 1] + b[i][j];
    }
  }
  for (long long i = k; i <= n; i++) {
    for (long long j = k; j <= m; j++) {
      if (ps[i][j] - ps[i - k][j] - ps[i][j - k] + ps[i - k][j - k] ==
          (k * k)) {
        return true;
      }
    }
  }
  return false;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k >> q;
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= m; j++) {
      a[i][j] = INF;
    }
  }
  for (long long i = 0; i < q; i++) {
    long long x, y, t;
    cin >> x >> y >> t;
    a[x][y] = t;
  }
  long long l = -1, r = INF;
  while (true) {
    if (r - l == 1) {
      cout << (r == INF ? -1 : r);
      return 0;
    }
    long long mid = (l + r) / 2;
    if (ok(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
}

```


### Prompt

Generate a Cpp solution to the following problem:

The new PIN is hard to remember. I was told that I shouldn't take notes, but I don't think I can remember them. Therefore, I decided to embed a numerical value in the text and make a note of the PIN. Here, the sum of all the numbers is the PIN.

Create a program that reads the memorandum and outputs the PIN code.

Input

Sentences with embedded positive integers are given over multiple lines. Each line is a character string containing single-byte alphanumeric characters, symbols, and spaces, or a blank line. However, you are guaranteed to enter no more than 80 characters per line and a PIN of 10,000 or less.

Output

The PIN (the sum of positive integers in the text) is output on one line.

Example

Input

Thereare100yenonthetable.Iam17yearsold.
Ishouldgohomeat6pm.

Output

123

### Response

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

int main()
{
    char a;
    int ans = 0;
    a = getchar();
    while (a != EOF) {
        if ('0' <= a && a <= '9') {
            int num = a - '0';
            a = getchar();
            while ('0' <= a && a <= '9') {
                num *= 10;
                num += a - '0';
                a = getchar();
            }
            ans += num;
        } else {
            a = getchar();
        }
    }

    cout << ans << endl;

    return 0;
}
```


### Prompt

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

Create a program that outputs all leap years between the year a and year b.

The leap year conditions are as follows. However, 0 <a ≤ b <3,000. If there is no leap year in the given period, output "NA".

* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by 400 is a leap year.

Input

Given multiple datasets. The format of each dataset is as follows:

a b

Input ends when both a and b are 0. The number of datasets does not exceed 50.

Output

Print the year or NA for each dataset.

Insert one blank line between the datasets.

Example

Input

2001 2010
2005 2005
2001 2010
0 0

Output

2004
2008

NA

2004
2008

### Response

```cpp
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int a,b;
  for(int c=0; cin >>a>>b,a||b; c++){
    if(c){cout<<endl;}
    vector<int> year;
    for(int i=a; i<=b; i++){
      if(!(i%4) && i%100){year.push_back(i);}
      else if(!(i%400)){year.push_back(i);}
    }
    if(year.empty()){cout<<"NA"<<endl;}
    else{for(int i=0; i<year.size(); i++){cout <<year[i]<<endl;}}
  }
  return 0;
}
```


### Prompt

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

Mr. Takahashi has a string s consisting of lowercase English letters. He repeats the following operation on s exactly K times.

* Choose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of `z` is `a`.

For example, if you perform an operation for the second letter on `aaz`, `aaz` becomes `abz`. If you then perform an operation for the third letter on `abz`, `abz` becomes `aba`.

Mr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s. Find the such string.

Constraints

* 1≤|s|≤10^5
* All letters in s are lowercase English letters.
* 1≤K≤10^9

Input

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

s
K

Output

Print the lexicographically smallest string after performing exactly K operations on s.

Examples

Input

xyz
4

Output

aya

Input

a
25

Output

z

Input

codefestival
100

Output

aaaafeaaivap

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;cin>>s;
  ll i,j,k,n=s.size();cin>>k;
  for(i=0;i<n-1;i++){
    if(s[i]=='a') continue;
    if('z'-s[i]+1<=k){
      k-='z'-s[i]+1;
      s[i]='a';
    }
    if(k==0) break;
  }
  s[n-1]=(((s[n-1]-'a')+k)%26)+'a';
  cout << s << endl;
  return 0;
}

```


### Prompt

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

You are given two strings s and t both of length 2 and both consisting only of characters 'a', 'b' and 'c'.

Possible examples of strings s and t: "ab", "ca", "bb".

You have to find a string res consisting of 3n characters, n characters should be 'a', n characters should be 'b' and n characters should be 'c' and s and t should not occur in res as substrings.

A substring of a string is a contiguous subsequence of that string. So, the strings "ab", "ac" and "cc" are substrings of the string "abacc", but the strings "bc", "aa" and "cb" are not substrings of the string "abacc".

If there are multiple answers, you can print any of them.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 10^5) — the number of characters 'a', 'b' and 'c' in the resulting string.

The second line of the input contains one string s of length 2 consisting of characters 'a', 'b' and 'c'.

The third line of the input contains one string t of length 2 consisting of characters 'a', 'b' and 'c'.

Output

If it is impossible to find the suitable string, print "NO" on the first line.

Otherwise print "YES" on the first line and string res on the second line. res should consist of 3n characters, n characters should be 'a', n characters should be 'b' and n characters should be 'c' and s and t should not occur in res as substrings.

If there are multiple answers, you can print any of them.

Examples

Input

2
ab
bc

Output

YES
acbbac

Input

3
aa
bc

Output

YES
cacbacbab

Input

1
cb
ac

Output

YES
abc

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int modInverse(long long int A, long long int M) {
  return power(A, M - 2, M);
}
void solve() {
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  vector<string> s;
  vector<string> v;
  v.push_back("abc");
  v.push_back("acb");
  v.push_back("bac");
  v.push_back("bca");
  v.push_back("cab");
  v.push_back("cba");
  for (auto x : v) {
    string tmp = "";
    for (int i = 0; i < n; i++) tmp += x;
    s.push_back(tmp);
    s.push_back(string(n, x[0]) + string(n, x[1]) + string(n, x[2]));
  }
  for (auto x : s) {
    if (x.find(a) == string::npos && x.find(b) == string::npos) {
      cout << "YES"
           << "\n";
      cout << x << "\n";
      return;
    }
  }
  cout << "NO"
       << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  for (int i = 1; i <= t; i++) solve();
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

After too much playing on paper, Iahub has switched to computer games. The game he plays is called "Block Towers". It is played in a rectangular grid with n rows and m columns (it contains n × m cells). The goal of the game is to build your own city. Some cells in the grid are big holes, where Iahub can't build any building. The rest of cells are empty. In some empty cell Iahub can build exactly one tower of two following types:

  1. Blue towers. Each has population limit equal to 100.
  2. Red towers. Each has population limit equal to 200. However, it can be built in some cell only if in that moment at least one of the neighbouring cells has a Blue Tower. Two cells are neighbours is they share a side.

Iahub is also allowed to destroy a building from any cell. He can do this operation as much as he wants. After destroying a building, the other buildings are not influenced, and the destroyed cell becomes empty (so Iahub can build a tower in this cell if needed, see the second example for such a case).

Iahub can convince as many population as he wants to come into his city. So he needs to configure his city to allow maximum population possible. Therefore he should find a sequence of operations that builds the city in an optimal way, so that total population limit is as large as possible.

He says he's the best at this game, but he doesn't have the optimal solution. Write a program that calculates the optimal one, to show him that he's not as good as he thinks.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 500). Each of the next n lines contains m characters, describing the grid. The j-th character in the i-th line is '.' if you're allowed to build at the cell with coordinates (i, j) a tower (empty cell) or '#' if there is a big hole there.

Output

Print an integer k in the first line (0 ≤ k ≤ 106) — the number of operations Iahub should perform to obtain optimal result.

Each of the following k lines must contain a single operation in the following format:

  1. «B x y» (1 ≤ x ≤ n, 1 ≤ y ≤ m) — building a blue tower at the cell (x, y);
  2. «R x y» (1 ≤ x ≤ n, 1 ≤ y ≤ m) — building a red tower at the cell (x, y);
  3. «D x y» (1 ≤ x ≤ n, 1 ≤ y ≤ m) — destroying a tower at the cell (x, y).

If there are multiple solutions you can output any of them. Note, that you shouldn't minimize the number of operations.

Examples

Input

2 3
..#
.#.

Output

4
B 1 1
R 1 2
R 2 1
B 2 3

Input

1 3
...

Output

5
B 1 1
B 1 2
R 1 3
D 1 2
R 1 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
char c[505][505];
int a[505][505], b[2][4] = {0, 0, 1, -1, 1, -1, 0, 0};
struct node {
  int x, y;
} d[505 * 505 * 3];
struct nob {
  int x, y;
  char c;
} e[505 * 505 * 3];
int n, m, q;
void bfs(int x, int y) {
  int i, j, k, l, r, x1, y1, x2, y2;
  a[x][y] = 1;
  d[0].x = x;
  d[0].y = y;
  e[q].x = x;
  e[q].y = y;
  e[q++].c = 'B';
  l = 0;
  r = 1;
  while (l < r) {
    x1 = d[l].x;
    y1 = d[l].y;
    for (i = 0; i < 4; i++) {
      x2 = x1 + b[0][i];
      y2 = y1 + b[1][i];
      if (x2 > 0 && x2 <= n && y2 > 0 && y2 <= m && c[x2][y2] == '.' &&
          !a[x2][y2]) {
        e[q].x = x2;
        e[q].y = y2;
        e[q++].c = 'B';
        d[r].x = x2;
        d[r++].y = y2;
        a[x2][y2] = 1;
      }
    }
    l++;
  }
  for (i = r - 1; i > 0; i--) {
    e[q].x = d[i].x;
    e[q].y = d[i].y;
    e[q++].c = 'D';
    e[q].x = d[i].x;
    e[q].y = d[i].y;
    e[q++].c = 'R';
  }
}
int main() {
  ios::sync_with_stdio(0);
  memset(a, 0, sizeof(a));
  int i, j, k, l, p, t, r;
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      cin >> c[i][j];
    }
  q = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (c[i][j] == '.' && !a[i][j]) bfs(i, j);
  cout << q << endl;
  for (i = 0; i < q; i++) {
    cout << e[i].c << " " << e[i].x << " " << e[i].y << endl;
  }
  return 0;
}

```


### Prompt

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

Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.

Constraints

* 1 ≤ a,b,c ≤ 100
* 1 ≤ d ≤ 100
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

a b c d

Output

If A and C can communicate, print `Yes`; if they cannot, print `No`.

Examples

Input

4 7 9 3

Output

Yes

Input

100 10 1 2

Output

No

Input

10 10 10 1

Output

Yes

Input

1 100 2 10

Output

Yes

### Response

```cpp
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(b-a)<=d&&abs(c-b)<=d||abs(c-a)<=d) cout<<"Yes";
	else cout<<"No";
	return 0;
}
```


### Prompt

Create a solution in CPP for the following problem:

Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an electric shock. He can make guesses which letter is selected, but for each incorrect guess he receives an electric shock too. The show ends when Valentin guesses the selected letter correctly.

Valentin can't keep in mind everything, so he could guess the selected letter much later than it can be uniquely determined and get excessive electric shocks. Excessive electric shocks are those which Valentin got after the moment the selected letter can be uniquely determined. You should find out the number of excessive electric shocks.

Input

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

The next n lines contain descriptions of his actions, each line contains description of one action. Each action can be of one of three types:

  1. Valentin pronounced some word and didn't get an electric shock. This action is described by the string ". w" (without quotes), in which "." is a dot (ASCII-code 46), and w is the word that Valentin said.
  2. Valentin pronounced some word and got an electric shock. This action is described by the string "! w" (without quotes), in which "!" is an exclamation mark (ASCII-code 33), and w is the word that Valentin said.
  3. Valentin made a guess about the selected letter. This action is described by the string "? s" (without quotes), in which "?" is a question mark (ASCII-code 63), and s is the guess — a lowercase English letter.

All words consist only of lowercase English letters. The total length of all words does not exceed 105.

It is guaranteed that last action is a guess about the selected letter. Also, it is guaranteed that Valentin didn't make correct guesses about the selected letter before the last action. Moreover, it's guaranteed that if Valentin got an electric shock after pronouncing some word, then it contains the selected letter; and also if Valentin didn't get an electric shock after pronouncing some word, then it does not contain the selected letter.

Output

Output a single integer — the number of electric shocks that Valentin could have avoided if he had told the selected letter just after it became uniquely determined.

Examples

Input

5
! abc
. ad
. b
! cd
? c

Output

1

Input

8
! hello
! codeforces
? c
. o
? d
? h
. l
? e

Output

2

Input

7
! ababahalamaha
? a
? b
? a
? b
? a
? h

Output

0

Note

In the first test case after the first action it becomes clear that the selected letter is one of the following: a, b, c. After the second action we can note that the selected letter is not a. Valentin tells word "b" and doesn't get a shock. After that it is clear that the selected letter is c, but Valentin pronounces the word cd and gets an excessive electric shock.

In the second test case after the first two electric shocks we understand that the selected letter is e or o. Valentin tries some words consisting of these letters and after the second word it's clear that the selected letter is e, but Valentin makes 3 more actions before he makes a correct hypothesis.

In the third example the selected letter can be uniquely determined only when Valentin guesses it, so he didn't get excessive electric shocks.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int Pow(int base, int exp) {
  if (exp == 0)
    return 1;
  else
    return base * Pow(base, exp - 1);
}
vector<char> v;
string s[2000020];
map<char, int> m;
pair<string, string> p[2000020];
int main() {
  int n, t = 0, ans = 0, chk = 0;
  string s1, s2, sb;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) cin >> s1 >> s2, p[i] = make_pair(s1, s2);
  string sa = "abcdefghijklmnopqrstuvwxyz";
  for (char i = 'a'; i <= 'z'; i++) m[i] = 0;
  for (int i = 1; i <= n - 1; i++) {
    string sp = "\0";
    if (!t) {
      if (p[i].first == "!") {
        sb = sa, sa = p[i].second;
        for (char j = 'a'; j <= 'z'; j++) {
          if (!(sa.find(j) != string::npos && sb.find(j) != string::npos))
            m[j] = 0;
          else
            sp += j;
        }
        sa = sp;
      }
      if (p[i].first == "?" || p[i].first == ".") {
        string second = "\0";
        if (sa == "\0")
          sa = p[i].second;
        else {
          for (int j = 0; j <= sa.size() - 1; j++)
            if (!(p[i].second.find(sa[j]) != string::npos)) second += sa[j];
        }
        sa = second;
      }
    }
    if (t && (p[i].first == "!" || p[i].first == "?")) ans++;
    if (sa.size() == 1) t = 1;
  }
  cout << ans;
}

```


### Prompt

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

The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills.

The boy is now looking at the ratings of consecutive participants written in a binary system. He thinks that the more such ratings differ, the more unfair is that such people are next to each other. He defines the difference between two numbers as the number of bit positions, where one number has zero, and another has one (we suppose that numbers are padded with leading zeros to the same length). For example, the difference of 5 = 101_2 and 14 = 1110_2 equals to 3, since 0101 and 1110 differ in 3 positions. Johnny defines the unfairness of the contest as the sum of such differences counted for neighboring participants.

Johnny has just sent you the rating sequence and wants you to find the unfairness of the competition. You have noticed that you've got a sequence of consecutive integers from 0 to n. That's strange, but the boy stubbornly says that everything is right. So help him and find the desired unfairness for received numbers.

Input

The input consists of multiple test cases. The first line contains one integer t (1 ≤ t ≤ 10 000) — the number of test cases. The following t lines contain a description of test cases.

The first and only line in each test case contains a single integer n (1 ≤ n ≤ 10^{18}).

Output

Output t lines. For each test case, you should output a single line with one integer — the unfairness of the contest if the rating sequence equals to 0, 1, ..., n - 1, n.

Example

Input

5
5
7
11
1
2000000000000

Output

8
11
19
1
3999999999987

Note

For n = 5 we calculate unfairness of the following sequence (numbers from 0 to 5 written in binary with extra leading zeroes, so they all have the same length):

  * 000
  * 001
  * 010
  * 011
  * 100
  * 101

The differences are equal to 1, 2, 1, 3, 1 respectively, so unfairness is equal to 1 + 2 + 1 + 3 + 1 = 8.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long ans = 0, o = 1, tw = 2;
    n++;
    while (n > 1) {
      ans += (n - o);
      if (n % 2 != 0)
        n = n / tw + o;
      else
        n /= tw;
    }
    cout << ans << endl;
  }
}

```


### Prompt

Please create a solution in cpp to the following problem:

Sereja is interested in intervals of numbers, so he has prepared a problem about intervals for you. An interval of numbers is a pair of integers [l, r] (1 ≤ l ≤ r ≤ m). Interval [l1, r1] belongs to interval [l2, r2] if the following condition is met: l2 ≤ l1 ≤ r1 ≤ r2.

Sereja wants to write out a sequence of n intervals [l1, r1], [l2, r2], ..., [ln, rn] on a piece of paper. At that, no interval in the sequence can belong to some other interval of the sequence. Also, Sereja loves number x very much and he wants some (at least one) interval in the sequence to have li = x. Sereja wonders, how many distinct ways to write such intervals are there?

Help Sereja and find the required number of ways modulo 1000000007 (109 + 7).

Two ways are considered distinct if there is such j (1 ≤ j ≤ n), that the j-th intervals in two corresponding sequences are not equal.

Input

The first line contains integers n, m, x (1 ≤ n·m ≤ 100000, 1 ≤ x ≤ m) — the number of segments in the sequence, the constraints on the numbers in segments and Sereja's favourite number.

Output

In a single line print the answer modulo 1000000007 (109 + 7).

Examples

Input

1 1 1

Output

1

Input

3 5 1

Output

240

Input

2 3 3

Output

6

Note

In third example next sequences will be correct: {[1, 1], [3, 3]}, {[1, 2], [3, 3]}, {[2, 2], [3, 3]}, {[3, 3], [1, 1]}, {[3, 3], [2, 2]}, {[3, 3], [1, 2]}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
const int MM = 998244353;
const long double PI = acos(-1);
long long power(long long b, long long e, long long m) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b % m, e / 2, m) % m;
  return power(b * b % m, e / 2, m);
}
long long power(long long b, long long e) {
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b, e / 2);
  return power(b * b, e / 2);
}
template <typename T, typename U>
static inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
static inline void amax(T &x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << '(' << p.first << "," << p.second << ')';
}
const int MOD = 1000000007;
struct Mint {
  int val;
  Mint(long long v = 0) {
    if (v < 0) v = v % MOD + MOD;
    if (v >= MOD) v %= MOD;
    val = v;
  }
  static int mod_inv(int a, int m = MOD) {
    int g = m, r = a, x = 0, y = 1;
    while (r != 0) {
      int q = g / r;
      g %= r;
      swap(g, r);
      x -= q * y;
      swap(x, y);
    }
    return x < 0 ? x + m : x;
  }
  explicit operator int() const { return val; }
  Mint &operator+=(const Mint &other) {
    val += other.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  Mint &operator-=(const Mint &other) {
    val -= other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
    return x % m;
    unsigned x_high = x >> 32, x_low = (unsigned)x;
    unsigned quot, rem;
    asm("divl %4\n" : "=a"(quot), "=d"(rem) : "d"(x_high), "a"(x_low), "r"(m));
    return rem;
  }
  Mint &operator*=(const Mint &other) {
    val = fast_mod((uint64_t)val * other.val);
    return *this;
  }
  Mint &operator/=(const Mint &other) { return *this *= other.inv(); }
  friend Mint operator+(const Mint &a, const Mint &b) { return Mint(a) += b; }
  friend Mint operator-(const Mint &a, const Mint &b) { return Mint(a) -= b; }
  friend Mint operator*(const Mint &a, const Mint &b) { return Mint(a) *= b; }
  friend Mint operator/(const Mint &a, const Mint &b) { return Mint(a) /= b; }
  Mint &operator++() {
    val = val == MOD - 1 ? 0 : val + 1;
    return *this;
  }
  Mint &operator--() {
    val = val == 0 ? MOD - 1 : val - 1;
    return *this;
  }
  Mint operator++(int32_t) {
    Mint before = *this;
    ++*this;
    return before;
  }
  Mint operator--(int32_t) {
    Mint before = *this;
    --*this;
    return before;
  }
  Mint operator-() const { return val == 0 ? 0 : MOD - val; }
  bool operator==(const Mint &other) const { return val == other.val; }
  bool operator!=(const Mint &other) const { return val != other.val; }
  Mint inv() const { return mod_inv(val); }
  Mint power(long long p) const {
    assert(p >= 0);
    Mint a = *this, result = 1;
    while (p > 0) {
      if (p & 1) result *= a;
      a *= a;
      p >>= 1;
    }
    return result;
  }
  friend ostream &operator<<(ostream &stream, const Mint &m) {
    return stream << m.val;
  }
  friend istream &operator>>(istream &stream, Mint &m) {
    return stream >> m.val;
  }
};
int _runtimeTerror_() {
  int n, m, x;
  cin >> n >> m >> x;
  if (n > m) {
    cout << 0;
    return 0;
  }
  Mint dp[m + 3][n + 3][n + 3];
  for (int i = 0; i <= m; ++i)
    for (int j = 0; j <= n; ++j)
      for (int k = 0; k <= n; ++k) dp[i][j][k] = 0;
  dp[0][0][0] = 1;
  for (int i = 1; i <= m; ++i) {
    for (int j = 0; j <= n; ++j) {
      for (int k = 0; k <= n; ++k) {
        if (j + k > n) continue;
        if (i != x) dp[i][j][k] += dp[i - 1][j][k];
        if (k) {
          if (i != x) dp[i][j + 1][k - 1] += dp[i - 1][j][k];
          dp[i][j + 1][k] += dp[i - 1][j][k];
        }
        dp[i][j][k + 1] += dp[i - 1][j][k];
        if (k == 0) dp[i][j + 1][0] += dp[i - 1][j][0];
      }
    }
  }
  for (int i = 1; i <= n; ++i) dp[m][n][0] *= i;
  cout << dp[m][n][0] << "\n";
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) _runtimeTerror_();
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

You are given array ai of length n. You may consecutively apply two operations to this array:

  * remove some subsegment (continuous subsequence) of length m < n and pay for it m·a coins;
  * change some elements of the array by at most 1, and pay b coins for each change.

Please note that each of operations may be applied at most once (and may be not applied at all) so you can remove only one segment and each number may be changed (increased or decreased) by at most 1. Also note, that you are not allowed to delete the whole array.

Your goal is to calculate the minimum number of coins that you need to spend in order to make the greatest common divisor of the elements of the resulting array be greater than 1.

Input

The first line of the input contains integers n, a and b (1 ≤ n ≤ 1 000 000, 0 ≤ a, b ≤ 109) — the length of the array, the cost of removing a single element in the first operation and the cost of changing an element, respectively.

The second line contains n integers ai (2 ≤ ai ≤ 109) — elements of the array.

Output

Print a single number — the minimum cost of changes needed to obtain an array, such that the greatest common divisor of all its elements is greater than 1.

Examples

Input

3 1 4
4 2 3

Output

1

Input

5 3 2
5 17 13 5 6

Output

8

Input

8 3 4
3 7 5 4 3 12 9 4

Output

13

Note

In the first sample the optimal way is to remove number 3 and pay 1 coin for it.

In the second sample you need to remove a segment [17, 13] and then decrease number 6. The cost of these changes is equal to 2·3 + 2 = 8 coins.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &rhs) {
  out << "( " << rhs.first << " , " << rhs.second << " )";
  return out;
}
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string &s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(char c) { return (string(1, c)); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
using ll = int64_t;
using ld = long double;
const ld EPS = 1e-11;
const ll MOD = 998244353;
const ld PI = 3.141592653589793;
const int maxn = 2e6 + 100;
template <typename ForwardIter, typename Callback>
void forn(ForwardIter arr, int n, Callback c) {
  int z = 1;
  for (auto x = arr; z <= n; ++z, ++x) {
    c(*x);
  }
}
int el[maxn];
int suff_ones[maxn];
int pref_ones[maxn];
int pref_shit[maxn];
int suff_shit[maxn];
vector<int> dec(int n) {
  vector<int> res;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      res.push_back(i);
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n != 1) {
    res.push_back(n);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.precision(10);
  cout << fixed;
  cin.tie(0);
  int n;
  cin >> n;
  ll a, b;
  cin >> a >> b;
  forn(el + 1, n, [](int &x) { cin >> x; });
  ll ans = 1e18;
  for (int e = 0; e < 2; ++e, reverse(el + 1, el + n + 1)) {
    for (int dx = -1; dx <= 1; ++dx) {
      ll cur_cost = abs(dx) * b;
      vector<int> primes = dec(el[1] + dx);
      for (int p : primes) {
        for (int i = n; i >= 1; --i) {
          int ost = el[i] % p;
          suff_ones[i] = suff_ones[i + 1] + (ost != 0);
          if (ost == 0 || ost == 1 || ost == p - 1) {
            suff_shit[i] = suff_shit[i + 1];
          } else {
            suff_shit[i] = suff_shit[i + 1] + 1;
          }
        }
        for (int i = 1; i <= n; ++i) {
          int ost = el[i] % p;
          pref_ones[i] = pref_ones[i - 1] + (ost != 0);
          if (ost == 0 || ost == 1 || ost == p - 1) {
            pref_shit[i] = pref_shit[i - 1];
          } else {
            pref_shit[i] = pref_shit[i - 1] + 1;
          }
        }
        if (!suff_shit[1]) {
          ans = min(ans, suff_ones[1] * b);
        }
        ll mn = a;
        for (int i = n - 1; i >= 1; --i) {
          if (!suff_shit[i + 1]) {
            mn = min(mn, suff_ones[i + 1] * b);
          }
          if (!pref_shit[i]) {
            ans = min(ans, pref_ones[i] * b + mn);
          }
          mn += a;
        }
      }
    }
  }
  cout << ans;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

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

Input

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

Output

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

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

Examples

Input

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

Output

YES
5 6 7 8
1 2 3 4

Input

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

Output

NO

Input

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

Output

YES
1 2 3 4
5 6 7 8

Note

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, INF = 1e18, mx = 1e6;
int testCase = 1, cas = 0;
long long Dis[10][10];
vector<pair<long long, long long> > P;
long long F(int i, int j) {
  int x1 = P[i].first;
  int y1 = P[i].second;
  int x2 = P[j].first;
  int y2 = P[j].second;
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0);
  for (int i = 0; i < 8; i++) {
    long long x, y;
    cin >> x >> y;
    P.push_back({x, y});
  }
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      long long d = F(i, j);
      Dis[i][j] = d;
    }
  }
  int ok = 1;
  for (int i = 0; ok && i < 8; i++) {
    for (int j = 0; ok && j < 8; j++) {
      if (i == j) continue;
      for (int k = 0; ok && k < 8; k++) {
        if (k == i || k == j) continue;
        for (int l = 0; ok && l < 8; l++) {
          if (l == i || l == j || l == k) continue;
          if (Dis[i][j] == Dis[j][k] && Dis[j][k] == Dis[k][l] &&
              Dis[k][l] == Dis[l][i] && Dis[l][j] == Dis[i][k]) {
            vector<int> R;
            for (int m = 0; m < 8; m++) {
              if (m == i || m == j || m == k || m == l) continue;
              R.push_back(m);
            }
            int flag = 0;
            for (int ii = 0; !flag && ii < 4; ii++) {
              for (int jj = 0; !flag && jj < 4; jj++) {
                if (ii == jj) continue;
                for (int kk = 0; !flag && kk < 4; kk++) {
                  if (kk == ii || kk == jj) continue;
                  for (int mm = 0; !flag && mm < 4; mm++) {
                    if (mm == ii || mm == jj || mm == kk) continue;
                    if (Dis[R[ii]][R[jj]] == Dis[R[kk]][R[mm]] &&
                        Dis[R[ii]][R[kk]] == Dis[R[jj]][R[mm]] &&
                        Dis[R[ii]][R[mm]] == Dis[R[jj]][R[kk]])
                      flag = 1;
                  }
                }
              }
            }
            if (flag) {
              ok = 0;
              cout << "YES" << endl;
              cout << i + 1 << " " << j + 1 << " " << k + 1 << " " << l + 1
                   << endl;
              cout << R[0] + 1 << " " << R[1] + 1 << " " << R[2] + 1 << " "
                   << R[3] + 1 << endl;
            }
          }
        }
      }
    }
  }
  if (ok) cout << "NO" << endl;
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either empty or filled with water.

The vertices of the tree are numbered from 1 to n with the root at vertex 1. For each vertex, the reservoirs of its children are located below the reservoir of this vertex, and the vertex is connected with each of the children by a pipe through which water can flow downwards.

Mike wants to do the following operations with the tree:

  1. Fill vertex v with water. Then v and all its children are filled with water.
  2. Empty vertex v. Then v and all its ancestors are emptied.
  3. Determine whether vertex v is filled with water at the moment.

Initially all vertices of the tree are empty.

Mike has already compiled a full list of operations that he wants to perform in order. Before experimenting with the tree Mike decided to run the list through a simulation. Help Mike determine what results will he get after performing all the operations.

Input

The first line of the input contains an integer n (1 ≤ n ≤ 500000) — the number of vertices in the tree. Each of the following n - 1 lines contains two space-separated numbers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — the edges of the tree.

The next line contains a number q (1 ≤ q ≤ 500000) — the number of operations to perform. Each of the following q lines contains two space-separated numbers ci (1 ≤ ci ≤ 3), vi (1 ≤ vi ≤ n), where ci is the operation type (according to the numbering given in the statement), and vi is the vertex on which the operation is performed.

It is guaranteed that the given graph is a tree.

Output

For each type 3 operation print 1 on a separate line if the vertex is full, and 0 if the vertex is empty. Print the answers to queries in the order in which the queries are given in the input.

Examples

Input

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

Output

0
0
0
1
0
1
0
1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
double PI = acos(-1);
double EPS = 1e-7;
int INF = 1000000000;
int MOD = 1000000007;
int MAXINT = 2147483647;
long long INFLL = 1000000000000000000LL;
long long MAXLL = 9223372036854775807LL;
vector<int> adj[500005];
int st[500005], en[500005];
int par[500005];
int seg[2000005];
bool rem[2000005];
int co = 0;
void go(int pos, int prev) {
  st[pos] = ++co;
  for (int(a) = (0); (a) <= ((int)adj[pos].size() - 1); (a)++) {
    int nx = adj[pos][a];
    if (nx != prev) {
      go(nx, pos);
      par[nx] = pos;
    }
  }
  en[pos] = co;
}
int build(int n = 1, int l = 1, int r = co) {
  if (l == r) return seg[n] = 1;
  int m = (l + r) / 2;
  return seg[n] = build(2 * n, l, m) + build(2 * n + 1, m + 1, r);
}
int val(int n) {
  if (rem[n])
    return 0;
  else
    return seg[n];
}
void update(int v, int n = 1, int l = 1, int r = co) {
  if (l == r) {
    seg[n] |= 1;
    rem[n] = 0;
    return;
  }
  if (rem[n]) {
    rem[2 * n] = rem[2 * n + 1] = 1;
    rem[n] = 0;
  }
  int m = (l + r) / 2;
  if (v <= m)
    update(v, 2 * n, l, m);
  else
    update(v, 2 * n + 1, m + 1, r);
  seg[n] = val(2 * n) + val(2 * n + 1);
}
void clean(int fl, int fr, int n = 1, int l = 1, int r = co) {
  if (fr < l || fl > r || fl > fr) return;
  if (fl <= l && r <= fr) {
    rem[n] = 1;
    return;
  }
  if (rem[n]) {
    rem[2 * n] = rem[2 * n + 1] = 1;
    rem[n] = 0;
  }
  int m = (l + r) / 2;
  clean(fl, fr, 2 * n, l, m);
  clean(fl, fr, 2 * n + 1, m + 1, r);
  seg[n] = val(2 * n) + val(2 * n + 1);
}
int query(int fl, int fr, int n = 1, int l = 1, int r = co) {
  if (fr < l || fl > r || fl > fr) return 0;
  if (fl <= l && r <= fr) {
    return val(n);
  }
  if (rem[n]) {
    rem[2 * n] = rem[2 * n + 1] = 1;
    rem[n] = 0;
  }
  int m = (l + r) / 2;
  int tmp = query(fl, fr, 2 * n, l, m) + query(fl, fr, 2 * n + 1, m + 1, r);
  seg[n] = val(2 * n) + val(2 * n + 1);
  return tmp;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int(a) = (1); (a) <= (n - 1); (a)++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  go(1, -1);
  build();
  int q;
  scanf("%d", &q);
  while (q--) {
    int t, v;
    scanf("%d%d", &t, &v);
    if (t == 1) {
      if (query(st[v], en[v])) {
        clean(st[v], en[v]);
        if (v != 1) {
          update(st[par[v]]);
        }
      } else
        clean(st[v], en[v]);
    } else if (t == 2) {
      update(st[v]);
    } else if (t == 3) {
      if (query(st[v], en[v]))
        puts("0");
      else
        puts("1");
    }
  }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Let's play a traditional game Nim. You and I are seated across a table and we have a hundred stones on the table (we know the number of stones exactly). We play in turn and at each turn, you or I can remove one to four stones from the heap. You play first and the one who removed the last stone loses.

In this game, you have a winning strategy. To see this, you first remove four stones and leave 96 stones. No matter how I play, I will end up with leaving 92-95 stones. Then you will in turn leave 91 stones for me (verify this is always possible). This way, you can always leave 5k + 1 stones for me and finally I get the last stone, sigh. If we initially had 101 stones, on the other hand, I have a winning strategy and you are doomed to lose.

Let's generalize the game a little bit. First, let's make it a team game. Each team has n players and the 2n players are seated around the table, with each player having opponents at both sides. Turns round the table so the two teams play alternately. Second, let's vary the maximum number ofstones each player can take. That is, each player has his/her own maximum number ofstones he/she can take at each turn (The minimum is always one). So the game is asymmetric and may even be unfair.

In general, when played between two teams of experts, the outcome of a game is completely determined by the initial number ofstones and the minimum number of stones each player can take at each turn. In other words, either team has a winning strategy.

You are the head-coach of a team. In each game, the umpire shows both teams the initial number of stones and the maximum number of stones each player can take at each turn. Your team plays first. Your job is, given those numbers, to instantaneously judge whether your team has a winning strategy.

Incidentally, there is a rumor that Captain Future and her officers of Hakodate-maru love this game, and they are killing their time playing it during their missions. You wonder where the stones are?. Well, they do not have stones but do have plenty of balls in the fuel containers!.

Input

The input is a sequence of lines, followed by the last line containing a zero. Each line except the last is a sequence of integers and has the following format.

n S M1 M2  ...  M2n

where n is the number of players in a team, S the initial number of stones, and Mi the maximum number of stones i th player can take. 1st, 3rd, 5th, ... players are your team's players and 2nd, 4th, 6th, ... the opponents. Numbers are separated by a single space character. You may assume 1 ≤ n ≤ 10, 1 ≤ Mi ≤ 16, and 1 ≤ S ≤ 213.

Output

The out put should consist of lines each containing either a one, meaning your team has a winning strategy, or a zero otherwise.

Example

Input

1 101 4 4
1 100 4 4
3 97 8 7 6 5 4 3
0

Output

0
1
1

### Response

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

long long int GR[8200][21];

int main() {

  for ( long long int i = 0; i < 21; i++ ) {
    GR[1][i] = 0;
  }

  long long int n, S, input;

  while( true ) {

    cin >> n;

    if ( n == 0 ) break;

    cin >> S;

    vector< long long int > m;

    for ( long long int i = 0; i < n * 2; i++ ) {

      cin >> input;

      m.push_back( input );

    }

    for ( long long int i = 2; i <= S; i++ ) {

      for ( long long int j = 0; j < n * 2; j++ ) {

	bool flag[17] = {};

	for ( long long int k = max( 1LL, i - m[j] ); k < i; k++ ) {

	  flag[ GR[k][(j+1)%(n*2)] ] = true;

	}

	int cnt = 0;
	while( flag[cnt] ) {cnt++;}
	GR[i][j] = cnt;

      }

    }

    cout << ( GR[S][0] == 0 ? "0" : "1" ) << endl;

  }

  return 0;

}
```


### Prompt

Develop a solution in Cpp to the problem described below:

A sequence a0, a1, ..., at - 1 is called increasing if ai - 1 < ai for each i: 0 < i < t.

You are given a sequence b0, b1, ..., bn - 1 and a positive integer d. In each move you may choose one element of the given sequence and add d to it. What is the least number of moves required to make the given sequence increasing?

Input

The first line of the input contains two integer numbers n and d (2 ≤ n ≤ 2000, 1 ≤ d ≤ 106). The second line contains space separated sequence b0, b1, ..., bn - 1 (1 ≤ bi ≤ 106).

Output

Output the minimal number of moves needed to make the sequence increasing.

Examples

Input

4 2
1 3 3 2

Output

3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int a[2005];
int main() {
  int n, i;
  long long int d, c = 0, dif;
  cin >> n >> d;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n - 1; i++) {
    if (a[i + 1] <= a[i]) {
      dif = a[i] - a[i + 1] + 1;
      if (dif % d == 0) {
        a[i + 1] += dif;
        c += dif / d;
      } else {
        a[i + 1] += ((dif / d) + 1) * d;
        c += ((dif / d) + 1);
      }
    }
  }
  cout << c;
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Input

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

Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between  - 1000 and 1000, inclusive.

Output

Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2.

Examples

Input

8
-2.14 2.06
-1.14 2.04
-2.16 1.46
-2.14 0.70
-1.42 0.40
-0.94 -0.48
-1.42 -1.28
-2.16 -1.62

Output

5.410

Input

5
2.26 1.44
2.28 0.64
2.30 -0.30
1.58 0.66
3.24 0.66

Output

5.620

Input

8
6.98 2.06
6.40 1.12
5.98 0.24
5.54 -0.60
7.16 0.30
7.82 1.24
8.34 0.24
8.74 -0.76

Output

5.480

Input

5
10.44 2.06
10.90 0.80
11.48 -0.48
12.06 0.76
12.54 2.06

Output

6.040

Input

8
16.94 2.42
15.72 2.38
14.82 1.58
14.88 0.50
15.76 -0.16
16.86 -0.20
17.00 0.88
16.40 0.92

Output

6.040

Input

7
20.62 3.00
21.06 2.28
21.56 1.36
21.66 0.56
21.64 -0.52
22.14 2.32
22.62 3.04

Output

6.720

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  cin >> n;
  double x, y, sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    sum += y;
  }
  sum /= n;
  sum += 5;
  printf("%.3lf", sum);
}

```


### Prompt

Generate a cpp solution to the following problem:

Example

Input

1+2*3+4
11

Output

M

### Response

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

VI a, b;
bool d[100010];
signed main(void)
{
	string s, t = "";
	int m;
	cin >> s >> m;
	REP(i, s.size()) {
		if(s[i] == '+') {
			a.PB(stoi(t));
			b.PB(1);
			t = "";
		} else if(s[i] == '*') {
			a.PB(stoi(t));
			b.PB(0);
			t = "";
		} else {
			t += s[i];
		}
	}
	a.PB(stoi(t));
	//for(int i: a) cout << i << " "; cout << endl;
	//for(int i: b) cout << i << " "; cout << endl;

	bool f1 = false, f2 = false;
	int c = a[0];
	REP(i, b.size()) {
		if(b[i]) {
			c += a[i+1];
		} else {
			c *= a[i+1];
		}
	}
	//cout << c << " ";
	if(c == m) f1 = true;

	VI e;
	bool con = false;
	c = 0;
	REP(i, b.size()) {
		if(!b[i]) {
			if(!con) c = a[i]*a[i+1];
			else c *= a[i+1];
			d[i] = d[i+1] = true;
			con = true;
		} else {
			e.PB(c);
			c = 0;
			con = false;
		}
	}
	e.PB(c);
	REP(i, a.size()) {
		if(!d[i]) e.PB(a[i]);
	}
	int ret = 0;
	for(int i: e) ret += i;
	//cout << ret << endl;
	//for(int i: e) cout << i << " "; cout << endl;
	if(ret == m) f2 = true;

	if(f1 && f2) cout << "U" << endl;
	else if(!f1 && !f2) cout << "I" << endl;
	else if(f1 && !f2) cout << "L" << endl;
	else if(!f1 && f2) cout << "M" << endl;
	else assert(false);

	return 0;
}
```


### Prompt

Generate a Cpp solution to the following problem:

Problem

N people with IDs from 1 to N are about to sit in N-legged chairs with numbers from 1 to N. The person with ID i wants to sit in the chair pi.

N people are lined up in a row in ascending order of ID, and the first person in the row takes the following actions.

1. If no one is sitting on the chair pi, sit on that chair.
2. Otherwise, add 1 to pi and rearrange at the end of the column. However, if pi exceeds N, pi is set to 1.

When this action is repeated until everyone sits in a chair, finally output the ID of the person sitting in each chair.

Constraints

The input satisfies the following conditions.

* 1 ≤ N ≤ 105
* 1 ≤ pi ≤ N

Input

The input is given in the following format.

N
p1 p2 ... pN

The integer N is given on the first line.
N integers p1, p2, ..., pN are given on the second line, separated by blanks.

Output

Print the final state on line N.
The ID of the person sitting on the chair i is output on the i-line.

Examples

Input

5
1 2 3 4 5

Output

1
2
3
4
5

Input

5
3 3 4 4 5

Output

4
2
1
3
5

### Response

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

using namespace std;
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VV<int> hu(n);
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p; p--;
        hu[p].push_back(i);
    }
    for (int i = 0; i < n; i++) {
        reverse(begin(hu[i]), end(hu[i]));
    }
    V<int> ans(n);
    V<int> st;
    for (int fe = 0; fe < 2*n; fe++) {
        int i = fe % n;
        for (int d: hu[i]) {
            st.push_back(d);
        }
        if (st.size()) {
            ans[i] = st.back(); st.pop_back();
        }
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i] + 1 << endl;
    }
    return 0;
}
```


### Prompt

Generate a Cpp solution to the following problem:

Soon a school Olympiad in Informatics will be held in Berland, n schoolchildren will participate there.

At a meeting of the jury of the Olympiad it was decided that each of the n participants, depending on the results, will get a diploma of the first, second or third degree. Thus, each student will receive exactly one diploma.

They also decided that there must be given at least min1 and at most max1 diplomas of the first degree, at least min2 and at most max2 diplomas of the second degree, and at least min3 and at most max3 diplomas of the third degree.

After some discussion it was decided to choose from all the options of distributing diplomas satisfying these limitations the one that maximizes the number of participants who receive diplomas of the first degree. Of all these options they select the one which maximizes the number of the participants who receive diplomas of the second degree. If there are multiple of these options, they select the option that maximizes the number of diplomas of the third degree.

Choosing the best option of distributing certificates was entrusted to Ilya, one of the best programmers of Berland. However, he found more important things to do, so it is your task now to choose the best option of distributing of diplomas, based on the described limitations.

It is guaranteed that the described limitations are such that there is a way to choose such an option of distributing diplomas that all n participants of the Olympiad will receive a diploma of some degree.

Input

The first line of the input contains a single integer n (3 ≤ n ≤ 3·106) — the number of schoolchildren who will participate in the Olympiad.

The next line of the input contains two integers min1 and max1 (1 ≤ min1 ≤ max1 ≤ 106) — the minimum and maximum limits on the number of diplomas of the first degree that can be distributed.

The third line of the input contains two integers min2 and max2 (1 ≤ min2 ≤ max2 ≤ 106) — the minimum and maximum limits on the number of diplomas of the second degree that can be distributed.

The next line of the input contains two integers min3 and max3 (1 ≤ min3 ≤ max3 ≤ 106) — the minimum and maximum limits on the number of diplomas of the third degree that can be distributed.

It is guaranteed that min1 + min2 + min3 ≤ n ≤ max1 + max2 + max3.

Output

In the first line of the output print three numbers, showing how many diplomas of the first, second and third degree will be given to students in the optimal variant of distributing diplomas.

The optimal variant of distributing diplomas is the one that maximizes the number of students who receive diplomas of the first degree. Of all the suitable options, the best one is the one which maximizes the number of participants who receive diplomas of the second degree. If there are several of these options, the best one is the one that maximizes the number of diplomas of the third degree.

Examples

Input

6
1 5
2 6
3 7

Output

1 2 3

Input

10
1 2
1 3
1 5

Output

2 3 5

Input

6
1 3
2 2
2 2

Output

2 2 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int Max[3];
  int Min[3];
  int brayce[3];
  int sum = 0;
  cin >> n;
  for (int i = 0; i < 3; i++) {
    cin >> Min[i] >> Max[i];
    brayce[i] = Min[i];
    sum += Min[i];
  }
  int flag = 0;
  while (1) {
    if (sum == n || flag > 2) break;
    if (brayce[flag] == Max[flag]) {
      flag++;
      continue;
    }
    brayce[flag]++;
    sum++;
  }
  for (int i = 0; i < 3; i++) cout << brayce[i] << " ";
  cout << endl;
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Rng is baking cookies.

Initially, he can bake one cookie per second.

He can also eat the cookies baked by himself. When there are x cookies not yet eaten, he can choose to eat all those cookies. After he finishes eating those cookies, the number of cookies he can bake per second becomes x. Note that a cookie always needs to be baked for 1 second, that is, he cannot bake a cookie in 1/x seconds when x > 1. When he choose to eat the cookies, he must eat all of them; he cannot choose to eat only part of them. It takes him A seconds to eat the cookies regardless of how many, during which no cookies can be baked.

He wants to give N cookies to Grandma. Find the shortest time needed to produce at least N cookies not yet eaten.

Constraints

* 1≦N≦10^{12}
* 0≦A≦10^{12}
* A is an integer.

Input

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

N A

Output

Print the shortest time needed to produce at least N cookies not yet eaten.

Examples

Input

8 1

Output

7

Input

1000000000000 1000000000000

Output

1000000000000

### Response

```cpp
#include<bits/stdc++.h>
#define REP(i,x,y) for(ll i=x; i<=y; i++)
#define BIT(t) ((long long 1) << t)
#define PER(i,y,x) for(ll i=y; i>=x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
using namespace std;
typedef long long ll;

ll const kmax = 50;

ll f(ll n,ll a,ll k){
	ll t = 1;
	while(1){
		bool flag = 1;
		ll cur = 1;
		REP(i,1,k){
			cur *= t+1;
			if(cur >= n){
				flag = 0;
				break;
			}
		}
		if(flag){
			t++;
		}else break;
	}
	ll ttl = pow(t,k);
	ll u = 0;
	while(ttl < n){
		ttl = ttl / t * (t + 1);
		u++;
	}
	ll ans = (k-1) * a + (k-u) * t + u * (t + 1);
	return ans;
}

int main(){
	ll n,a;
	cin >> n >> a;
	ll ans = n;
	REP(k,2,kmax){
		ans = min(ans, f(n,a,k));
	}
	cout << ans << endl;
}
```


### Prompt

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

An English booklet has been created for publicizing Aizu to the world. When you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says "Hoshino" not "Hoshina".

Your task is to write a program which replace all the words "Hoshino" with "Hoshina". You can assume that the number of characters in a text is less than or equal to 1000.

Input

The input consists of several datasets. There will be the number of datasets n in the first line. There will be n lines. A line consisting of english texts will be given for each dataset.

Output

For each dataset, print the converted texts in a line.

Example

Input

3
Hoshino
Hashino
Masayuki Hoshino was the grandson of Ieyasu Tokugawa.

Output

Hoshina
Hashino
Masayuki Hoshina was the grandson of Ieyasu Tokugawa.

### Response

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

int main()
{
    int n;
    int index;
    string s;

    cin >> n;
    cin.ignore();

    for(int i=0; i < n; i++)
    {
        getline(cin, s);

        while(true)
        {
            index = s.find("Hoshino");

            if(index == string::npos)
                break;
            else
                s.replace(index, 7, "Hoshina");
        }
        cout << s << endl;
    }

    return 0;
}
```


### Prompt

Please formulate a cpp solution to the following problem:

A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.

The number is called beautiful if it consists of at least one digit, doesn't have leading zeroes and is a multiple of 3. For example, 0, 99, 10110 are beautiful numbers, and 00, 03, 122 are not.

Write a program which for the given n will find a beautiful number such that n can be transformed into this number by erasing as few digits as possible. You can erase an arbitraty set of digits. For example, they don't have to go one after another in the number n.

If it's impossible to obtain a beautiful number, print -1. If there are multiple answers, print any of them.

Input

The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).

Output

Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print  - 1.

Examples

Input

1033

Output

33

Input

10

Output

0

Input

11

Output

-1

Note

In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
void infile() { freopen("input.in", "r", stdin); }
void outfile() { freopen("output.out", "w", stdout); }
long long int modex(long long int a, long long int b, long long int mod) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long int tmp = modex(a, b / 2, mod);
  tmp = (tmp * tmp) % mod;
  if (b & 1) tmp = (tmp * a) % mod;
  return tmp;
}
string s;
int len;
long long int memo[100005][3];
long long int dp(int id, int m) {
  if (id == len) {
    if (m == 0) return 0;
    return INT_MIN;
  }
  if (memo[id][m] != -1) return memo[id][m];
  long long int ans1, ans2;
  ans1 = 1 + dp(id + 1, (m + (s[id] - '0')) % 3);
  ans2 = dp(id + 1, m);
  return memo[id][m] = max(ans1, ans2);
}
int main() {
  cin >> s;
  len = s.length();
  memset((memo), (-1), sizeof((memo)));
  long long int ans = 0;
  for (long long int(i) = (0); (i) < (len); ++(i)) {
    if (s[i] != '0') {
      ans = max(ans, 1 + dp(i + 1, (s[i] - '0') % 3));
    }
  }
  if (ans == 0) {
    int flag = 1;
    for (long long int(i) = (0); (i) < (len); ++(i)) {
      if (s[i] == '0') {
        flag = 0;
      }
    }
    if (flag)
      cout << -1 << endl;
    else
      cout << 0 << endl;
  } else if (ans == 1) {
    int flag = 1;
    for (long long int(i) = (0); (i) < (len); ++(i)) {
      if (s[i] == '3' || s[i] == '6' || s[i] == '9') {
        flag = s[i] - '0';
        break;
      }
    }
    cout << flag << endl;
  } else {
    string res = "";
    int id, now;
    int flag = 0;
    for (long long int(j) = (0); (j) < (len); ++(j)) {
      for (long long int(k) = (0); (k) < (3); ++(k)) {
        if (memo[j][k] == ans - 1) {
          res += s[j - 1];
          id = j;
          now = k;
          flag = 1;
          break;
        }
      }
      if (flag) break;
    }
    ans -= 1;
    while (ans) {
      if (id == len - 1 ||
          (memo[id + 1][(now + (s[id] - '0')) % 3] == memo[id][now] - 1)) {
        res += s[id];
        now = (now + (s[id] - '0')) % 3;
        id++;
        ans--;
      } else {
        id++;
      }
    }
    cout << res << endl;
  }
  return 0;
}

```


### Prompt

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

There are n students living in the campus. Every morning all students wake up at the same time and go to wash. There are m rooms with wash basins. The i-th of these rooms contains ai wash basins. Every student independently select one the rooms with equal probability and goes to it. After all students selected their rooms, students in each room divide into queues by the number of wash basins so that the size of the largest queue is the least possible. Calculate the expected value of the size of the largest queue among all rooms.

Input

The first line contains two positive integers n and m (1 ≤ n, m ≤ 50) — the amount of students and the amount of rooms. The second line contains m integers a1, a2, ... , am (1 ≤ ai ≤ 50). ai means the amount of wash basins in the i-th room.

Output

Output single number: the expected value of the size of the largest queue. Your answer must have an absolute or relative error less than 10 - 9.

Examples

Input

1 1
2

Output

1.00000000000000000000

Input

2 2
1 1

Output

1.50000000000000000000

Input

2 3
1 1 1

Output

1.33333333333333350000

Input

7 5
1 1 2 3 1

Output

2.50216960000000070000

### Response

```cpp
#include <bits/stdc++.h>
const double pi = acos(-1.0);
const double eps = 1e-14;
using namespace std;
const int N = 55;
int n, m;
int a[N];
long double pw[N], c[N][N], dp[N][N][N];
void solve() {
  cin >> n >> m;
  pw[0] = 1;
  for (int i = 1; i < N; i++) pw[i] = pw[i - 1] * (1 / (double)m);
  for (int i = 0; i < N; i++) c[i][0] = 1.0;
  for (int i = 1; i < N; i++)
    for (int j = 1; j < N; j++) c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
  for (int i = 1; i <= m; i++) cin >> a[i];
  dp[0][0][0] = 1;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        double v = dp[i - 1][j][k];
        if (abs(v) < eps) continue;
        for (int t = 0; t <= n - j; t++) {
          int my_mx = (t + a[i] - 1) / a[i];
          dp[i][j + t][max(k, my_mx)] += c[n - j][t] * pw[t] * v;
        }
      }
    }
  }
  double ans = 0.0;
  for (int i = 1; i <= n; i++) {
    ans += dp[m][n][i] * (double)i;
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(10);
  int step;
  step = 1;
  for (int i = 1; i <= step; i++) {
    solve();
  }
}

```


### Prompt

Create a solution in cpp for the following problem:

Kitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.

Each apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't want to offend any of his friend. Therefore the total weight of the apples given to Touma Kazusa must be equal to the total weight of the apples given to Ogiso Setsuna.

But unfortunately Kitahara Haruki doesn't have a knife right now, so he cannot split any apple into some parts. Please, tell him: is it possible to divide all the apples in a fair way between his friends?

Input

The first line contains an integer n (1 ≤ n ≤ 100) — the number of apples. The second line contains n integers w1, w2, ..., wn (wi = 100 or wi = 200), where wi is the weight of the i-th apple.

Output

In a single line print "YES" (without the quotes) if it is possible to divide all the apples between his friends. Otherwise print "NO" (without the quotes).

Examples

Input

3
100 200 100

Output

YES

Input

4
100 100 100 200

Output

NO

Note

In the first test sample Kitahara Haruki can give the first and the last apple to Ogiso Setsuna and the middle apple to Touma Kazusa.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s = 0;
  char flag = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    s += a;
    if (a == 100) flag = 1;
  }
  if (s % 200 != 0 || n == 1 || (!flag && n % 2 != 0))
    printf("NO");
  else
    printf("YES");
}

```


### Prompt

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

Little X and Little Z are good friends. They always chat online. But both of them have schedules.

Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time when he gets up. If he gets up at time 0, he will be online at any moment of time between c1 and d1, between c2 and d2, ..., between cq and dq (all borders inclusive). But if he gets up at time t, these segments will be shifted by t. They become [ci + t, di + t] (for all i).

If at a moment of time, both Little X and Little Z are online simultaneosly, they can chat online happily. You know that Little X can get up at an integer moment of time between l and r (both borders inclusive). Also you know that Little X wants to get up at the moment of time, that is suitable for chatting with Little Z (they must have at least one common moment of time in schedules). How many integer moments of time from the segment [l, r] suit for that?

Input

The first line contains four space-separated integers p, q, l, r (1 ≤ p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000).

Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai < bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj < dj ≤ 1000).

It's guaranteed that bi < ai + 1 and dj < cj + 1 for all valid i and j.

Output

Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.

Examples

Input

1 1 0 4
2 3
0 1

Output

3

Input

2 3 0 20
15 17
23 26
1 4
7 11
15 17

Output

20

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int p, q, l, r;
int a[2100], b[2100], c[2100], d[2100];
int dd[2100];
void nhap() {
  cin >> p >> q >> l >> r;
  for (int i = 1; i <= p; i++) cin >> a[i] >> b[i];
  for (int i = 1; i <= q; i++) cin >> c[i] >> d[i];
}
void chuanbi() {
  memset(dd, 0, sizeof(dd));
  for (int i = 1; i <= p; i++)
    for (int j = a[i]; j <= b[i]; j++) dd[j] = 1;
}
void xuli() {
  int dem = 0;
  for (int t = l; t <= r; t++) {
    int ok = 0;
    for (int i = 1; i <= q; i++) {
      if (ok == 1) break;
      for (int j = c[i] + t; j <= d[i] + t; j++)
        if (dd[j]) {
          dem++;
          ok = 1;
          break;
        }
    }
  }
  cout << dem;
}
void ghikq() {}
int main() {
  nhap();
  chuanbi();
  xuli();
  ghikq();
}

```


### Prompt

Create a solution in CPP for the following problem:

There are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1).

You're given k subsets A_1, …, A_k of \{1, 2, ..., n\}, such that the intersection of any three subsets is empty. In other words, for all 1 ≤ i_1 < i_2 < i_3 ≤ k, A_{i_1} ∩ A_{i_2} ∩ A_{i_3} = ∅.

In one operation, you can choose one of these k subsets and switch the state of all lamps in it. It is guaranteed that, with the given subsets, it's possible to make all lamps be simultaneously on using this type of operation.

Let m_i be the minimum number of operations you have to do in order to make the i first lamps be simultaneously on. Note that there is no condition upon the state of other lamps (between i+1 and n), they can be either off or on.

You have to compute m_i for all 1 ≤ i ≤ n.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 3 ⋅ 10^5).

The second line contains a binary string of length n, representing the initial state of each lamp (the lamp i is off if s_i = 0, on if s_i = 1).

The description of each one of the k subsets follows, in the following format:

The first line of the description contains a single integer c (1 ≤ c ≤ n) — the number of elements in the subset.

The second line of the description contains c distinct integers x_1, …, x_c (1 ≤ x_i ≤ n) — the elements of the subset.

It is guaranteed that:

  * The intersection of any three subsets is empty;
  * It's possible to make all lamps be simultaneously on using some operations.

Output

You must output n lines. The i-th line should contain a single integer m_i — the minimum number of operations required to make the lamps 1 to i be simultaneously on.

Examples

Input

7 3
0011100
3
1 4 6
3
3 4 7
2
2 3

Output

1
2
3
3
3
3
3

Input

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

Output

1
1
1
1
1
1
4
4

Input

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

Output

1
1
1
1
1

Input

19 5
1001001001100000110
2
2 3
2
5 6
2
8 9
5
12 13 14 15 16
1
19

Output

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

Note

In the first example:

  * For i = 1, we can just apply one operation on A_1, the final states will be 1010110;
  * For i = 2, we can apply operations on A_1 and A_3, the final states will be 1100110;
  * For i ≥ 3, we can apply operations on A_1, A_2 and A_3, the final states will be 1111111.

In the second example:

  * For i ≤ 6, we can just apply one operation on A_2, the final states will be 11111101;
  * For i ≥ 7, we can apply operations on A_1, A_3, A_4, A_6, the final states will be 11111111.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline long long read1() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 3e5 + 10;
int n, k;
vector<int> q[N];
int f[N], val[N], sz[N][2], vis[N], ans;
int Find(int x) {
  if (x == f[x]) return x;
  Find(f[x]);
  val[x] ^= val[f[x]];
  f[x] = f[f[x]];
  return f[x];
}
int getval(int x) {
  if (vis[x] == -1)
    return min(sz[x][0], sz[x][1]);
  else
    return sz[x][vis[x]];
}
void merge(int u, int v, int c) {
  Find(u);
  Find(v);
  if (f[u] != f[v]) {
    ans -= getval(f[u]);
    ans -= getval(f[v]);
    c ^= val[u] ^ val[v];
    u = f[u];
    v = f[v];
    sz[u][0] += sz[v][c];
    sz[u][1] += sz[v][1 - c];
    if (vis[v] != -1 && vis[u] == -1) vis[u] = vis[v] ^ c;
    f[v] = u;
    val[v] = c;
    ans += getval(u);
  }
}
void sure(int u, int c) {
  Find(u);
  c ^= val[u];
  u = f[u];
  ans -= getval(u);
  if (vis[u] == -1) vis[u] = c;
  ans += getval(u);
}
char ch[N];
int main() {
  n = read();
  k = read();
  scanf("%s", ch + 1);
  for (int i = 1; i <= k; i++) {
    int num = read();
    while (num--) {
      int x = read();
      q[x].push_back(i);
    }
  }
  for (int i = 1; i <= k; i++)
    f[i] = i, sz[i][1] = 1, sz[i][0] = 0, vis[i] = -1;
  for (int i = 1; i <= n; i++) {
    if (q[i].size() == 2)
      merge(q[i][0], q[i][1], 1 - (ch[i] - '0'));
    else if (q[i].size() != 0)
      sure(q[i][0], 1 - (ch[i] - '0'));
    printf("%d\n", ans);
  }
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

If you draw a few infinitely long straight lines on an infinitely wide plane, this plane will be divided into several areas. For example, if you draw a straight line, the plane will be divided into two areas. Even if you draw the same number of straight lines, the number of areas obtained will differ depending on how you draw. For example, if you draw two straight lines in parallel, you get three areas, and if you draw two straight lines perpendicular to each other, you get four areas.

<image>

Create a program that outputs the maximum number of regions that can be obtained by drawing n straight lines.

Input

Given multiple datasets. Each dataset is given n (1 ≤ n ≤ 10,000) on one row. Please process until the end of the input.

The number of datasets does not exceed 50.

Output

For each dataset, output the maximum number of divisions on one line.

Example

Input

1
3

Output

2
7

### Response

```cpp
#include<iostream>
using namespace std;
int main(){
long i,n,s;
while(cin>>n){
for(s=1,i=1;i<=n;i++)s+=i;
cout<<s<<endl;
}
return 0;
}
```


### Prompt

Please create a solution in CPP to the following problem:

You are given an array a consisting of n non-negative integers. You have to choose a non-negative integer x and form a new array b of size n according to the following rule: for all i from 1 to n, b_i = a_i ⊕ x (⊕ denotes the operation [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR)).

An inversion in the b array is a pair of integers i and j such that 1 ≤ i < j ≤ n and b_i > b_j.

You should choose x in such a way that the number of inversions in b is minimized. If there are several options for x — output the smallest one.

Input

First line contains a single integer n (1 ≤ n ≤ 3 ⋅ 10^5) — the number of elements in a.

Second line contains n space-separated integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^9), where a_i is the i-th element of a.

Output

Output two integers: the minimum possible number of inversions in b, and the minimum possible value of x, which achieves those number of inversions.

Examples

Input

4
0 1 3 2

Output

1 0

Input

9
10 7 9 10 7 5 5 3 5

Output

4 14

Input

3
8 10 3

Output

0 8

Note

In the first sample it is optimal to leave the array as it is by choosing x = 0.

In the second sample the selection of x = 14 results in b: [4, 9, 7, 4, 9, 11, 11, 13, 11]. It has 4 inversions:

  * i = 2, j = 3;
  * i = 2, j = 4;
  * i = 3, j = 4;
  * i = 8, j = 9.

In the third sample the selection of x = 8 results in b: [0, 2, 11]. It has no inversions.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &n) {
  T w = 1;
  n = 0;
  char ch = getchar();
  while (!isdigit(ch) && ch != EOF) {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (isdigit(ch) && ch != EOF) {
    n = (n << 1) + (n << 3) + (ch ^ 48);
    ch = getchar();
  }
  n *= w;
}
template <typename T>
inline void write(T x) {
  unsigned long long y = 0;
  T l = 0;
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (!x) {
    putchar(48);
    return;
  }
  while (x) {
    y = y * 10 + x % 10;
    x /= 10;
    l++;
  }
  while (l) {
    putchar(y % 10 + 48);
    y /= 10;
    l--;
  }
}
template <typename T>
inline void writeln(T x) {
  write(x);
  puts("");
}
template <typename T>
inline void writes(T x) {
  write(x);
  putchar(' ');
}
template <typename T>
inline void checkmax(T &a, T b) {
  a = a > b ? a : b;
}
template <typename T>
inline void checkmin(T &a, T b) {
  a = a < b ? a : b;
}
int a[300100], c[300100], now[300100];
long long no;
inline void merge(int l, int r) {
  int mid = (l + r) >> 1;
  int i = l, j = mid + 1, p = l;
  for (; i <= mid && j <= r;)
    if (c[i] > c[j]) {
      no += mid - i + 1;
      now[p++] = c[j++];
    } else
      now[p++] = c[i++];
  while (i <= mid) now[p++] = c[i++];
  while (j <= r) now[p++] = c[j++];
  for (int i = (l); i <= (r); i++) c[i] = now[i];
}
inline void mergesort(int l, int r) {
  if (l >= r) return;
  int mid = (l + r) >> 1;
  mergesort(l, mid);
  mergesort(mid + 1, r);
  merge(l, r);
}
int main() {
  int n, ans = 0;
  read(n);
  for (int i = (1); i <= (n); i++) read(a[i]);
  for (int i = (30); i >= (0); i--) {
    int sum1 = 0, sum0 = 0;
    long long ni1 = 0, ni2 = 0;
    for (int j = (1); j <= (n); j++) c[j] = a[j];
    no = 0;
    mergesort(1, n);
    ni1 = no;
    for (int j = (1); j <= (n); j++) c[j] = a[j] ^ (1 << i);
    no = 0;
    mergesort(1, n);
    ni2 = no;
    if (ni1 > ni2) {
      for (int j = (1); j <= (n); j++) a[j] ^= (1 << i);
      ans += (1 << i);
    }
  }
  for (int i = (1); i <= (n); i++) c[i] = a[i];
  no = 0;
  mergesort(1, n);
  writes(no);
  writeln(ans);
  return 0;
}

```


### Prompt

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

Nick likes strings very much, he likes to rotate them, sort them, rearrange characters within a string... Once he wrote a random string of characters a, b, c on a piece of paper and began to perform the following operations:

  * to take two adjacent characters and replace the second character with the first one,
  * to take two adjacent characters and replace the first character with the second one

To understand these actions better, let's take a look at a string «abc». All of the following strings can be obtained by performing one of the described operations on «abc»: «bbc», «abb», «acc». Let's denote the frequency of a character for each of the characters a, b and c as the number of occurrences of this character in the string. For example, for string «abc»: |a| = 1, |b| = 1, |c| = 1, and for string «bbc»: |a| = 0, |b| = 2, |c| = 1.

While performing the described operations, Nick sometimes got balanced strings. Let's say that a string is balanced, if the frequencies of each character differ by at most 1. That is  - 1 ≤ |a| - |b| ≤ 1,  - 1 ≤ |a| - |c| ≤ 1 и  - 1 ≤ |b| - |c| ≤ 1.

Would you help Nick find the number of different balanced strings that can be obtained by performing the operations described above, perhaps multiple times, on the given string s. This number should be calculated modulo 51123987.

Input

The first line contains integer n (1 ≤ n ≤ 150) — the length of the given string s. Next line contains the given string s. The initial string can be balanced as well, in this case it should be counted too. The given string s consists only of characters a, b and c.

Output

Output the only number — the number of different balanced strings that can be obtained by performing the described operations, perhaps multiple times, on the given string s, modulo 51123987.

Examples

Input

4
abca

Output

7

Input

4
abbc

Output

3

Input

2
ab

Output

1

Note

In the first sample it is possible to get 51 different strings through the described operations, but only 7 of them are balanced: «abca», «bbca», «bcca», «bcaa», «abcc», «abbc», «aabc». In the second sample: «abbc», «aabc», «abcc». In the third sample there is only one balanced string — «ab» itself.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int dp[158][55][55][55];
string ss;
int n;
void add(int &x, int y) {
  x += y;
  if (x >= 51123987) x -= 51123987;
}
int bucket[158];
int nxt[158][8];
int main() {
  cin >> n >> ss;
  bucket[0] = bucket[1] = bucket[2] = ss.size() + 5;
  for (int i = 0; i < ss.size() - 1; i++)
    if (ss[i] == ss[i + 1]) ss = ss.substr(0, i + 1) + ss.substr(i + 2), i--;
  for (int i = ss.size(); i >= 0; i--) {
    if (i < ss.size()) bucket[ss[i] - 'a'] = i;
    for (int j = 0; j < 3; j++) nxt[i][j] = bucket[j];
  }
  dp[0][0][0][0] = 1;
  int now = 0;
  int ans = 0;
  for (int i = 0; i <= ss.size(); i++) {
    for (int a = 0; a <= n / 3 + 1; a++) {
      for (int b = 0; b <= n / 3 + 1; b++) {
        for (int c = 0; c <= n / 3 + 1; c++) {
          add(dp[nxt[i][0]][a + 1][b][c], dp[i][a][b][c]);
          add(dp[nxt[i][1]][a][b + 1][c], dp[i][a][b][c]);
          add(dp[nxt[i][2]][a][b][c + 1], dp[i][a][b][c]);
          if (abs(a - b) <= 1 and abs(a - c) <= 1 and abs(b - c) <= 1 and
              a + b + c == n)
            add(ans, dp[i][a][b][c]);
        }
      }
    }
  }
  cout << ans;
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

One day Vasya painted a Cartesian coordinate system on a piece of paper and marked some set of points (x1, y1), (x2, y2), ..., (xn, yn). Let's define neighbors for some fixed point from the given set (x, y):

  * point (x', y') is (x, y)'s right neighbor, if x' > x and y' = y
  * point (x', y') is (x, y)'s left neighbor, if x' < x and y' = y
  * point (x', y') is (x, y)'s lower neighbor, if x' = x and y' < y
  * point (x', y') is (x, y)'s upper neighbor, if x' = x and y' > y

We'll consider point (x, y) from the given set supercentral, if it has at least one upper, at least one lower, at least one left and at least one right neighbor among this set's points.

Vasya marked quite many points on the paper. Analyzing the picture manually is rather a challenge, so Vasya asked you to help him. Your task is to find the number of supercentral points in the given set.

Input

The first input line contains the only integer n (1 ≤ n ≤ 200) — the number of points in the given set. Next n lines contain the coordinates of the points written as "x y" (without the quotes) (|x|, |y| ≤ 1000), all coordinates are integers. The numbers in the line are separated by exactly one space. It is guaranteed that all points are different.

Output

Print the only number — the number of supercentral points of the given set.

Examples

Input

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

Output

2

Input

5
0 0
0 1
1 0
0 -1
-1 0

Output

1

Note

In the first sample the supercentral points are only points (1, 1) and (1, 2).

In the second sample there is one supercental point — point (0, 0).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int x[234], y[234];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d %d", x + i, y + i);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    set<int> st;
    for (int j = 0; j < n; j++) {
      if (j == i) continue;
      if (x[i] == x[j]) {
        st.insert(y[i] < y[j] ? -1 : 1);
      } else if (y[i] == y[j]) {
        st.insert(x[i] < x[j] ? -2 : 2);
      }
    }
    if (st.size() == 4) ans++;
  }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

This is an interactive problem.

Imur Ishakov decided to organize a club for people who love to play the famous game «The hat». The club was visited by n students, where n is even. Imur arranged them all in a circle and held a draw to break the students in pairs, but something went wrong. The participants are numbered so that participant i and participant i + 1 (1 ≤ i ≤ n - 1) are adjacent, as well as participant n and participant 1. Each student was given a piece of paper with a number in such a way, that for every two adjacent students, these numbers differ exactly by one. The plan was to form students with the same numbers in a pair, but it turned out that not all numbers appeared exactly twice.

As you know, the most convenient is to explain the words to the partner when he is sitting exactly across you. Students with numbers i and <image> sit across each other. Imur is wondering if there are two people sitting across each other with the same numbers given. Help him to find such pair of people if it exists.

You can ask questions of form «which number was received by student i?», and the goal is to determine whether the desired pair exists in no more than 60 questions.

Input

At the beginning the even integer n (2 ≤ n ≤ 100 000) is given — the total number of students.

You are allowed to ask no more than 60 questions.

Output

To ask the question about the student i (1 ≤ i ≤ n), you should print «? i». Then from standard output you can read the number ai received by student i ( - 109 ≤ ai ≤ 109).

When you find the desired pair, you should print «! i», where i is any student who belongs to the pair (1 ≤ i ≤ n). If you determined that such pair doesn't exist, you should output «! -1». In both cases you should immediately terminate the program.

The query that contains your answer is not counted towards the limit of 60 queries.

Please make sure to flush the standard output after each command. For example, in C++ use function fflush(stdout), in Java call System.out.flush(), in Pascal use flush(output) and stdout.flush() for Python language.

Hacking

Use the following format for hacking:

In the first line, print one even integer n (2 ≤ n ≤ 100 000) — the total number of students.

In the second line print n integers ai ( - 109 ≤ ai ≤ 109) separated by spaces, where ai is the number to give to i-th student. Any two adjacent elements, including n and 1, must differ by 1 or  - 1.

The hacked solution will not have direct access to the sequence ai.

Examples

Input

8

2

2

Output

? 4

? 8

! 4

Input

6

1

2

3

2

1

0

Output

? 1

? 2

? 3

? 4

? 5

? 6

! -1

Note

Input-output in statements illustrates example interaction.

In the first sample the selected sequence is 1, 2, 1, 2, 3, 4, 3, 2

In the second sample the selection sequence is 1, 2, 3, 2, 1, 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MAXN = 100000 + 5;
int d[MAXN];
int num1, num2, n;
void ending() {
  cout << "! -1" << endl;
  exit(0);
}
int main() {
  cin >> n;
  if (n % 4) ending();
  cout << "? 1" << endl;
  cin >> num1;
  cout << "? " << 1 + n / 2 << endl;
  cin >> num2;
  d[1] = num2 - num1;
  d[1 + n / 2] = -d[1];
  if (!d[1]) {
    cout << "! 1" << endl;
    return 0;
  }
  int l = 1, r = 1 + n / 2;
  for (int i = 0; i < 29; i++) {
    int mid = (l + r) / 2;
    cout << "? " << mid << endl;
    cin >> num1;
    cout << "? " << mid + n / 2 << endl;
    cin >> num2;
    d[mid] = num2 - num1;
    if (!d[mid]) {
      cout << "! " << mid << endl;
      return 0;
    }
    if (d[mid] < 0) {
      if (d[l] < 0)
        l = mid;
      else
        r = mid;
    } else {
      if (d[l] > 0)
        l = mid;
      else
        r = mid;
    }
  }
  cout << "! -1" << endl;
  return 0;
}

```


### Prompt

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

Bran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies.

At first, Arya and Bran have 0 Candies. There are n days, at the i-th day, Arya finds ai candies in a box, that is given by the Many-Faced God. Every day she can give Bran at most 8 of her candies. If she don't give him the candies at the same day, they are saved for her and she can give them to him later.

Your task is to find the minimum number of days Arya needs to give Bran k candies before the end of the n-th day. Formally, you need to output the minimum day index to the end of which k candies will be given out (the days are indexed from 1 to n).

Print -1 if she can't give him k candies during n given days.

Input

The first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 10000).

The second line contains n integers a1, a2, a3, ..., an (1 ≤ ai ≤ 100).

Output

If it is impossible for Arya to give Bran k candies within n days, print -1.

Otherwise print a single integer — the minimum number of days Arya needs to give Bran k candies before the end of the n-th day.

Examples

Input

2 3
1 2

Output

2

Input

3 17
10 10 10

Output

3

Input

1 9
10

Output

-1

Note

In the first sample, Arya can give Bran 3 candies in 2 days.

In the second sample, Arya can give Bran 17 candies in 3 days, because she can give him at most 8 candies per day.

In the third sample, Arya can't give Bran 9 candies, because she can give him at most 8 candies per day and she must give him the candies within 1 day.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, t = 0, tmp, ans = 0;
  cin >> n >> k;
  while (k > 0 && n) {
    ans++;
    n--;
    cin >> tmp;
    t += tmp;
    if (t <= 8) {
      k -= t;
      t = 0;
    } else {
      k -= 8;
      t -= 8;
    }
  }
  if (k > 0)
    cout << -1;
  else
    cout << ans;
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

The weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...

Given is a string S representing the weather in the town today. Predict the weather tomorrow.

Constraints

* S is `Sunny`, `Cloudy`, or `Rainy`.

Input

Input is given from Standard Input in the following format:

S

Output

Print a string representing the expected weather tomorrow, in the same format in which input is given.

Examples

Input

Sunny

Output

Cloudy

Input

Rainy

Output

Sunny

### Response

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

int main() {
    string S;
    cin >> S;
    if (S[0] == 'C') puts("Rainy");
    else if (S[0] == 'R') puts("Sunny");
	else puts("Cloudy");
}
```