### Prompt

Please formulate a cpp solution to the following problem:

Dasha decided to have a rest after solving the problem D and began to look photos from previous competitions.

Let's call photos as the matrix with the size n × m, which consists of lowercase English letters.

Some k photos especially interested her, because they can be received from photo-template by painting a rectangular area in a certain color. Let's call such photos special.

<image>

More formally the i-th special photo is received from the photo-template by replacing all characters on some rectangle with upper left corner of the cell with coordinates (ai, bi) and lower right corner in the cell with coordinates (ci, di) to the symbol ei.

Dasha asks you to find the special photo so that the total distance from it to all other special photos is minimum. And calculate this distance.

Determine the distance between two photos as the sum of distances between all corresponding letters. The distance between two letters is the difference module of their positions in the alphabet. For example, the distance between letters 'h' and 'm' equals |8 - 13| = 5, because the letter 'h' is the 8-th in the alphabet, the letter 'm' is the 13-th.

Input

The first line contains three integers n, m, k (1 ≤ n, m ≤ 103, 1 ≤ k ≤ 3·105) — the number of strings in the photo-template, the number of columns and the number of special photos which are interesting for Dasha.

The next n lines contains the string with m length which consists of little Latin characters — the description of the photo-template.

Each of the next k lines contains the description of the special photo in the following format, "ai bi ci di ei" (1 ≤ ai ≤ ci ≤ n, 1 ≤ bi ≤ di ≤ m), where (ai, bi) — is the coordinate of the upper left corner of the rectangle, (ci, di) — is the description of the lower right corner, and ei — is the little Latin letter which replaces the photo-template in the described rectangle.

Output

In the only line print the minimum total distance from the found special photo to all other special photos.

Examples

Input

3 3 2
aaa
aaa
aaa
1 1 2 2 b
2 2 3 3 c

Output

10

Input

5 5 3
abcde
eabcd
deabc
cdeab
bcdea
1 1 3 4 f
1 2 3 3 e
1 3 3 4 i

Output

59

Note

In the first example the photos are following:

    bba    aaa
    bba    acc
    aaa    acc

The distance between them is 10.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef struct photo {
  int a, b, c, d;
  char e;
} photo;
char s[1005][1005];
long long int cnt[26][1005][1005], dev[1005][1005];
int n, m, k;
void print(long long int a[26][1005][1005]) {
  for (int c = 0; c < 7; c++) {
    cout << c << endl;
    for (int i = 0; i < n; i++) {
      cout << i << " - ";
      for (int j = 0; j < m; j++) cout << a[c][i][j] << " ";
      printf("\n");
    }
  }
  cout << endl;
}
void calcnt() {
  for (int c = 0; c < 26; c++)
    for (int i = 0; i < n; i++) {
      long long int cur = 0;
      for (int j = 0; j < m; j++) {
        cur += cnt[c][i][j];
        cnt[c][i][j] = cur;
      }
    }
}
void calcum2(long long int a[1005][1005]) {
  for (int i = 1; i < n; i++) a[i][0] += a[i - 1][0];
  for (int j = 1; j < m; j++) a[0][j] += a[0][j - 1];
  for (int i = 1; i < n; i++)
    for (int j = 1; j < m; j++)
      a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
}
void calcum(long long int a[26][1005][1005]) {
  for (int c = 0; c < 26; c++) calcum2(a[c]);
}
void print2(long long int a[1005][1005]) {
  for (int i = 0; i < n; i++) {
    cout << i << " - ";
    for (int j = 0; j < m; j++) cout << a[i][j] << " ";
    printf("\n");
  }
  printf("\n");
}
void caldev() {
  for (int c = 0; c < 26; c++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        dev[i][j] += abs(s[i][j] - 'a' - c) * cnt[c][i][j];
  calcum2(dev);
}
void calactcnt() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      long long int cur = 0;
      for (int c = 0; c < 26; c++) {
        if (c == s[i][j] - 'a') continue;
        cur += cnt[c][i][j];
      }
      cnt[s[i][j] - 'a'][i][j] = k - cur;
    }
}
long long int calcc(int c, photo p) {
  return cnt[c][p.c][p.d] - ((p.b == 0) ? 0 : cnt[c][p.c][p.b - 1]) -
         ((p.a == 0) ? 0 : cnt[c][p.a - 1][p.d]) +
         ((p.a == 0 || p.b == 0) ? 0 : cnt[c][p.a - 1][p.b - 1]);
}
long long int calrest(photo p) {
  return dev[n - 1][m - 1] -
         (dev[p.c][p.d] - ((p.b == 0) ? 0 : dev[p.c][p.b - 1]) -
          ((p.a == 0) ? 0 : dev[p.a - 1][p.d]) +
          ((p.a == 0 || p.b == 0) ? 0 : dev[p.a - 1][p.b - 1]));
}
bool compare(photo a, photo b) {
  if (a.a < b.a) return 1;
  return 0;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  vector<photo> p(k);
  for (int i = 0; i < k; i++) {
    scanf("%d%d%d%d", &p[i].a, &p[i].b, &p[i].c, &p[i].d);
    cin >> p[i].e;
    p[i].a--;
    p[i].b--;
    p[i].c--;
    p[i].d--;
  }
  sort(p.begin(), p.end(), compare);
  multiset<pair<int, long long int> > s[26][1005];
  int ind = 0;
  long long int curcnt[26][1005] = {0};
  for (int i = 0; i < n; i++) {
    while (ind < p.size()) {
      if (p[ind].a == i) {
        curcnt[p[ind].e - 'a'][p[ind].b]++;
        curcnt[p[ind].e - 'a'][p[ind].d + 1]--;
        s[p[ind].e - 'a'][p[ind].b].insert(make_pair(p[ind].c, -1));
        s[p[ind].e - 'a'][p[ind].d + 1].insert(make_pair(p[ind].c, 1));
        ind++;
      } else
        break;
    }
    for (int c = 0; c < 26; c++)
      for (int j = 0; j < m; j++) {
        cnt[c][i][j] = curcnt[c][j];
        while (!s[c][j].empty()) {
          if (s[c][j].begin()->first == i) {
            curcnt[c][j] += s[c][j].begin()->second;
            s[c][j].erase(s[c][j].begin());
          } else
            break;
        }
      }
  }
  calcnt();
  caldev();
  calactcnt();
  calcum(cnt);
  long long int ans = 1000000007;
  ans *= ans;
  for (int i = 0; i < k; i++) {
    long long int temans = calrest(p[i]);
    for (int c = 0; c < 26; c++)
      temans += abs(p[i].e - 'a' - c) * calcc(c, p[i]);
    ans = min(ans, temans);
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.

The presenter has m chips. The presenter stands in the middle of the circle and starts giving the chips to the walruses starting from walrus number 1 and moving clockwise. The walrus number i gets i chips. If the presenter can't give the current walrus the required number of chips, then the presenter takes the remaining chips and the process ends. Determine by the given n and m how many chips the presenter will get in the end.

Input

The first line contains two integers n and m (1 ≤ n ≤ 50, 1 ≤ m ≤ 104) — the number of walruses and the number of chips correspondingly.

Output

Print the number of chips the presenter ended up with.

Examples

Input

4 11

Output

0

Input

17 107

Output

2

Input

3 8

Output

1

Note

In the first sample the presenter gives one chip to the walrus number 1, two chips to the walrus number 2, three chips to the walrus number 3, four chips to the walrus number 4, then again one chip to the walrus number 1. After that the presenter runs out of chips. He can't give anything to the walrus number 2 and the process finishes.

In the third sample the presenter gives one chip to the walrus number 1, two chips to the walrus number 2, three chips to the walrus number 3, then again one chip to the walrus number 1. The presenter has one chip left and he can't give two chips to the walrus number 2, that's why the presenter takes the last chip.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  int total = (n * (n + 1)) / 2;
  if (total <= m) m = (m % total);
  for (int i = 1; i <= n; i++) {
    if (m >= i)
      m -= i;
    else
      break;
  }
  cout << m << endl;
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

Little Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course, Vlad immediately bought only to find out his computer is too old for the new game and needs to be updated.

There are n video cards in the shop, the power of the i-th video card is equal to integer value ai. As Vlad wants to be sure the new game will work he wants to buy not one, but several video cards and unite their powers using the cutting-edge technology. To use this technology one of the cards is chosen as the leading one and other video cards are attached to it as secondary. For this new technology to work it's required that the power of each of the secondary video cards is divisible by the power of the leading video card. In order to achieve that the power of any secondary video card can be reduced to any integer value less or equal than the current power. However, the power of the leading video card should remain unchanged, i.e. it can't be reduced.

Vlad has an infinite amount of money so he can buy any set of video cards. Help him determine which video cards he should buy such that after picking the leading video card and may be reducing some powers of others to make them work together he will get the maximum total value of video power.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of video cards in the shop.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 200 000) — powers of video cards.

Output

The only line of the output should contain one integer value — the maximum possible total power of video cards working together.

Examples

Input

4
3 2 15 9

Output

27

Input

4
8 2 2 7

Output

18

Note

In the first sample, it would be optimal to buy video cards with powers 3, 15 and 9. The video card with power 3 should be chosen as the leading one and all other video cards will be compatible with it. Thus, the total power would be 3 + 15 + 9 = 27. If he buys all the video cards and pick the one with the power 2 as the leading, the powers of all other video cards should be reduced by 1, thus the total power would be 2 + 2 + 14 + 8 = 26, that is less than 27. Please note, that it's not allowed to reduce the power of the leading video card, i.e. one can't get the total power 3 + 1 + 15 + 9 = 28.

In the second sample, the optimal answer is to buy all video cards and pick the one with the power 2 as the leading. The video card with the power 7 needs it power to be reduced down to 6. The total power would be 8 + 2 + 2 + 6 = 18.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<long long int> arr, arr2;
int main(void) {
  long long int n, maxi = 0, x;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> x;
    arr.push_back(x);
    maxi = max(maxi, x);
  }
  sort(arr.begin(), arr.end());
  arr2.push_back(arr[0]);
  for (long long int i = 1; i < n; i++) {
    if (arr[i] != arr[i - 1]) {
      arr2.push_back(arr[i]);
    }
  }
  long long int x1, x2, s, ans = 0, siz = arr2.size();
  for (long long int i = 0; i < siz; i++) {
    s = 0;
    for (long long int j = arr2[i], j2 = 0; j2 <= maxi;
         j += arr2[i], j2 += arr2[i]) {
      x1 = lower_bound(arr.begin(), arr.end(), j2) - arr.begin();
      x2 = upper_bound(arr.begin(), arr.end(), j - 1) - arr.begin() - 1;
      if (x1 <= x2) {
        s += ((x2 - x1 + 1) * j2);
      }
    }
    ans = max(ans, s);
  }
  cout << ans << "\n";
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

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

In this contest, a contestant will first select some number of problems to solve. Then, the contestant will solve the selected problems. After that, the score of the contestant will be calculated as follows:

* (The score) = (The number of the pairs of integers L and R (1≦L≦R≦N) such that for every i satisfying L≦i≦R, problem i is solved) - (The total number of seconds it takes for the contestant to solve the selected problems)

Note that a contestant is allowed to choose to solve zero problems, in which case the score will be 0.

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

A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know the maximum score that can be obtained in the contest if she takes that drink. Your task is to write a program to calculate it instead of her.

Constraints

* All input values are integers.
* 1≦N≦3*10^5
* 1≦T_i≦10^9
* (The sum of T_i) ≦10^{12}
* 1≦M≦3*10^5
* 1≦P_i≦N
* 1≦X_i≦10^9

Input

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

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

Output

For each drink, print the maximum score that can be obtained if Joisino takes that drink, in order, one per line.

Examples

Input

5
1 1 4 1 1
2
3 2
3 10

Output

9
2

Input

12
1 2 1 3 4 1 2 1 12 3 12 12
10
9 3
11 1
5 35
6 15
12 1
1 9
4 3
10 2
5 1
7 6

Output

34
35
5
11
35
17
25
26
28
21

### Response

```cpp
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 300010
using namespace std;
typedef long long ll;
ll f[MAXN],f1[MAXN],f2[MAXN];
ll t[MAXN];
ll st[MAXN],q[MAXN];
ll sum[MAXN],tmp[MAXN];
int n,m;
void prepare(ll fx[]){
	fx[0]=0;
	int top=0;
	st[++top]=0;
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+t[i];
	for(ll i=1;i<=n;i++){
		fx[i]=fx[i-1];
		while(top>1&&q[st[top]]-q[st[top-1]]<=2ll*i*(st[top]-st[top-1]))
			top--;
		fx[i]=max(fx[i],fx[st[top]]+(i-st[top])*(i-st[top]+1)/2ll-sum[i]+sum[st[top]]);
		q[i]=i*i-i+2ll*(fx[i]+sum[i]);
		while(top>1&&(q[st[top]]-q[st[top-1]])*(i-st[top-1])<=(q[i]-q[st[top-1]])*(st[top]-st[top-1]))
			top--;
		st[++top]=i;
	}
}
void solve(ll f1[],ll f2[],ll l,ll r){
	if(l==r){
		f[l]=max(f[l],f1[l-1]+f2[l+1]-t[l]+1ll);
		return ;
	}
	int mid=(l+r)>>1,top=0;
	for(ll i=l-1;i<mid;i++){
		q[i]=i*i-i+2ll*(f1[i]+sum[i]);
		while(top>1&&(q[st[top]]-q[st[top-1]])*(i-st[top-1])<=(q[i]-q[st[top-1]])*(st[top]-st[top-1]))
			top--;
		st[++top]=i;
	}
	for(ll i=mid;i<=r;i++){
		while(top>1&&q[st[top]]-q[st[top-1]]<=2ll*i*(st[top]-st[top-1]))
			top--;
		tmp[i]=f1[st[top]]+f2[i+1]+(i-st[top])*(i-st[top]+1)/2ll-sum[i]+sum[st[top]];
	}
	for(int i=r-1;i>=mid;i--)
		tmp[i]=max(tmp[i],tmp[i+1]);
	for(int i=mid;i<=r;i++)
		f[i]=max(f[i],tmp[i]);
	solve(f1,f2,l,mid);
	solve(f1,f2,mid+1,r);
}
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++){
		SF("%lld",&t[i]);
		f[i]=-t[i]+1ll;
	}
	prepare(f1);
	reverse(t+1,t+1+n);
	prepare(f2);
	reverse(t+1,t+1+n);
	reverse(f2+1,f2+1+n);
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+t[i];
	solve(f1,f2,1,n);
	reverse(t+1,t+1+n);reverse(f1+1,f1+1+n),reverse(f2+1,f2+1+n);reverse(f+1,f+1+n);
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+t[i];
	solve(f2,f1,1,n);
	reverse(t+1,t+1+n);reverse(f1+1,f1+1+n),reverse(f2+1,f2+1+n);reverse(f+1,f+1+n);
	SF("%d",&m);
	for(int i=1;i<=m;i++){
		int p;
		ll t1;
		SF("%d%lld",&p,&t1);
		PF("%lld\n",max(f1[p-1]+f2[p+1],f[p]+t[p]-t1));
	}
}
```


### Prompt

Please formulate a cpp solution to the following problem:

In Berland recently a new collection of toys went on sale. This collection consists of 109 types of toys, numbered with integers from 1 to 109. A toy from the new collection of the i-th type costs i bourles.

Tania has managed to collect n different types of toys a1, a2, ..., an from the new collection. Today is Tanya's birthday, and her mother decided to spend no more than m bourles on the gift to the daughter. Tanya will choose several different types of toys from the new collection as a gift. Of course, she does not want to get a type of toy which she already has.

Tanya wants to have as many distinct types of toys in her collection as possible as the result. The new collection is too diverse, and Tanya is too little, so she asks you to help her in this.

Input

The first line contains two integers n (1 ≤ n ≤ 100 000) and m (1 ≤ m ≤ 109) — the number of types of toys that Tanya already has and the number of bourles that her mom is willing to spend on buying new toys.

The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the types of toys that Tanya already has.

Output

In the first line print a single integer k — the number of different types of toys that Tanya should choose so that the number of different types of toys in her collection is maximum possible. Of course, the total cost of the selected toys should not exceed m.

In the second line print k distinct space-separated integers t1, t2, ..., tk (1 ≤ ti ≤ 109) — the types of toys that Tanya should choose.

If there are multiple answers, you may print any of them. Values of ti can be printed in any order.

Examples

Input

3 7
1 3 4

Output

2
2 5

Input

4 14
4 6 12 8

Output

4
7 2 3 1

Note

In the first sample mom should buy two toys: one toy of the 2-nd type and one toy of the 5-th type. At any other purchase for 7 bourles (assuming that the toys of types 1, 3 and 4 have already been bought), it is impossible to buy two and more toys.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int used[200050];
int main() {
  int n, k, cnt = 0, sum = 0, x;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x <= 200000) used[x] = true;
  }
  for (int i = 1; i <= k; i++) {
    if (used[i] == false) {
      cnt++;
      sum += i;
      if (sum > k) {
        cnt--;
        break;
      }
      if (sum == k) break;
    }
  }
  sum = 0;
  cout << cnt << endl;
  for (int i = 1; i <= k; i++) {
    if (used[i] == false) {
      sum += i;
      if (sum > k)
        break;
      else
        cout << i << " ";
    }
  }
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Inspired by the tv series Stranger Things, bear Limak is going for a walk between two mirror worlds.

There are two perfect binary trees of height H, each with the standard numeration of vertices from 1 to 2^H-1. The root is 1 and the children of x are 2 \cdot x and 2 \cdot x + 1.

Let L denote the number of leaves in a single tree, L = 2^{H-1}.

You are given a permutation P_1, P_2, \ldots, P_L of numbers 1 through L. It describes L special edges that connect leaves of the two trees. There is a special edge between vertex L+i-1 in the first tree and vertex L+P_i-1 in the second tree.

graph for sample1

drawing for the first sample test, permutation P = (2, 3, 1, 4), special edges in green

Let's define product of a cycle as the product of numbers in its vertices. Compute the sum of products of all simple cycles that have exactly two special edges, modulo (10^9+7).

A simple cycle is a cycle of length at least 3, without repeated vertices or edges.

Constraints

* 2 \leq H \leq 18
* 1 \leq P_i \leq L where L = 2^{H-1}
* P_i \neq P_j (so this is a permutation)

Input

Input is given from Standard Input in the following format (where L = 2^{H-1}).

H
P_1 P_2 \cdots P_L

Output

Compute the sum of products of simple cycles that have exactly two special edges. Print the answer modulo (10^9+7).

Examples

Input

3
2 3 1 4

Output

121788

Input

2
1 2

Output

36

Input

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

Output

10199246

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> pi3;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int N=18;

ll n, nn, k, u, v, x, y, a, b, ans;
ll A[1<<N];
int sz[4];
pi3 B[4][N*N<<N>>3];
pii C[4][N*N<<N>>3];
int L[4][1<<N], R[4][1<<N], ted[4][1<<N];
int sum[4][1<<N];

inline void fix(int &x){
	if (x>=mod) x-=mod;
	if (x<0) x+=mod;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n; nn=(1<<(n-1));
	for (int i=0; i<nn; i++){
		cin>>A[i];
		int u=i+nn, v=A[i]+nn-1;
		ll mul=1;
		while (u>1){
			mul=mul*u%mod;
			int vv=v;
			ll mul2=mul;
			while (vv>1){
				mul2=mul2*vv%mod;
				int tmp=((u&1)<<1)|(vv&1);
				B[tmp][sz[tmp]++]={{u>>1, vv>>1}, mul2};
//				cerr<<"path "<<(u>>1)<<' '<<(vv>>1)<<' '<<tmp<<" "<<mul2<<"\n";
				ted[tmp][u>>1]++;
				vv>>=1;
			}
			u>>=1;
		}
	}
	for (int tmp:{0, 1, 2, 3}){
		for (int i=1; i<(1<<n); i++) L[tmp][i]=R[tmp][i]=L[tmp][i-1]+ted[tmp][i-1];
	}
	for (int tmp:{0, 1, 2, 3}){
		for (int i=0; i<sz[tmp]; i++){
			int u=B[tmp][i].first.first, v=B[tmp][i].first.second, mul=B[tmp][i].second;
			C[tmp][R[tmp][u]++]={v, mul};
		}
	}
	for (int u=1; u<(1<<n); u++){
		for (int tmp:{0, 1, 2, 3}){
			for (int i=L[tmp][u]; i<R[tmp][u]; i++){
				pii p=C[tmp][i];
				fix(sum[tmp][p.first]+=p.second);
			}
		}
		for (int tmp:{0, 1, 2, 3}){
			for (int i=L[tmp][u]; i<R[tmp][u]; i++){
				int v=C[tmp][i].first, mul=C[tmp][i].second;
//				cerr<<"cycle "<<u<<' '<<v<<' '<<tmp<<"  "<<mul<<' '<<sum[tmp^3][v]<<"\n";
				ans=(ans + 1ll*sum[tmp^3][v]*mul%mod*v%mod*u%mod)%mod;
			}
		}
		for (int tmp:{0, 1, 2, 3}){
			for (int i=L[tmp][u]; i<R[tmp][u]; i++){
				pii p=C[tmp][i];
				sum[tmp][p.first]=0;
			}
		}

	}
	ans%=mod;
	ans=ans*(mod+1)/2%mod;
	cout<<ans<<"\n";

	return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Find the minimum prime number greater than or equal to X.

Constraints

* 2 \le X \le 10^5
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

X

Output

Print the minimum prime number greater than or equal to X.

Examples

Input

20

Output

23

Input

2

Output

2

Input

99992

Output

100003

### Response

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

int main(){
	int x;	cin>>x;
	for(int i=x;i<=1000000;i++){
		bool flag=true;
		for(int j=2;j*j<=i;j++){
			if(i%j==0){
				flag=false;
				break;
			}
		}
		if(flag){
			cout<<i<<endl;
			return 0;
		}
	}

	return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

There is a bus route as shown in Figure 1. There are 10 stops, each numbered 0-9. The bus turns back at stop 0, but the other side is a circulation route, which circulates in the order of 5 → 6 → 7 → 8 → 9 → 5 as shown in the figure.

<image>

For this bus route, create a program that inputs the stop to get on and the stop to get off, and outputs the number of the stop that goes from getting on to getting off.

However, you can take a two-way bus at stops 1-5, but we will take a bus that arrives at the stop on a shorter route. For example, if you are going from stop 4 to stop 2, take the bus going to the left and follow the route "4 → 3 → 2". Also, once you get on the bus, you will not get off the bus. The same stop is not designated as a boarding stop or a getting-off stop.

Input

Given multiple datasets. The first line gives the number of datasets n (n ≤ 20). For each dataset, the stop number to get on and the stop number to get off are given on one line separated by blanks.

Output

For each data set, output the list of passing stop numbers on one line separated by blanks.

Example

Input

2
2 4
4 2

Output

2 3 4
4 3 2

### Response

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

int main(){
	int n;
	cin >> n ;
	for(int t=0 ; t < n ; t++ ){
		int s, g;
		cin >> s >> g;
		if( g < s && s <= 5 ){
			for(int i=s ; i >= g ; i-- ){
				cout << i;
				(i == g)? cout << endl : cout << " ";
			}
		}else if( s >= 6 && g <= 5 ){
			for(int i=s ; i <= 9 ; i++ ){
				cout << i << " ";
			}
			for(int i=5 ; i >= g ; i-- ){
				cout << i;
				(i == g)? cout << endl : cout << " ";
			}
		}else if( s >= 6 && g >= 6 && g < s ){
			for(int i=s ; i <= 9 ; i++ ){
				cout << i << " ";
			}
			cout << "5 4 3 2 1 ";
			for(int i=0 ; i <= g ; i++ ){
				cout << i;
				(i == g)? cout << endl : cout << " ";
			}
		}else{
			for(int i=s ; i <= g ; i++ ){
				cout << i;
				(i == g)? cout << endl : cout << " ";
			}
		}
	}
}
```


### Prompt

Please create a solution in CPP to the following problem:

A mischievous notice has arrived from the primitive slow-life organization "Akaruda". Akaruda is famous for mischief such as throwing a pie at the face of a VIP, but recently it has become more radical, such as using gunpowder to sprinkle rat fireworks at the reception venue. The notice is the following text.

--- Personal computer Takes human time. not good.
When the short and long hands of the clock meet, Akaruda justice is done.
Slow life great.

It's terrifying and I'm not sure, but it seems to mean that the mischief is carried out when the minute hand and the minute hand of the clock overlap.

To be wary of this mischief, create a program that inputs the time and outputs "alert" if the short hand and the long hand are close, "safe" if they are far, and "warning" otherwise. However, "close" means that the angle between the short hand and the long hand is 0 ° or more and less than 30 °, and "far" means that the angle is 90 ° or more and 180 ° or less. The time should be between 00:00 and 11:59.

Input

The input is given in the following format:

n
hh1: mm1
hh2: mm2
::
hhn: mmn

The number of times to be judged on the first line n (1 ≤ n ≤ 10000), and the i-th time hhi: mmi on the second and subsequent lines are given to each line.

Output

Output the judgment result of the i-th time safe, warning, or alert in order on one line.

Example

Input

4
02:15
06:01
11:55
10:40

Output

alert
safe
alert
warning

### Response

```cpp
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000;

 int main(){
 	int k,n,m;
 	cin>>k;
 	for(int i = 0; i < k; i++){
 		scanf("%d:%d", &m, &n);
	 	m = m>12?m-12:m;
		double d = 360.0 * m / 12.0;
		d += 30.0 * n / 60.0;
		double e = 360.0 * n / 60.0;
		double f = min(abs(d-e),abs(360-abs(d-e)));

		if(f < 30.0) cout<<"alert"<<endl;
		else if(f >= 90.0) cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
 }
```


### Prompt

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

You have recently fallen through a hole and, after several hours of unconsciousness, have realized you are in an underground city. On one of your regular, daily walks through the unknown, you have encountered two unusually looking skeletons called Sanz and P’pairus, who decided to accompany you and give you some puzzles for seemingly unknown reasons.

One day, Sanz has created a crossword for you. Not any kind of crossword, but a 1D crossword! You are given m words and a string of length n. You are also given an array p, which designates how much each word is worth — the i-th word is worth pi points. Whenever you find one of the m words in the string, you are given the corresponding number of points. Each position in the crossword can be used at most x times. A certain word can be counted at different places, but you cannot count the same appearance of a word multiple times. If a word is a substring of another word, you can count them both (presuming you haven’t used the positions more than x times).

In order to solve the puzzle, you need to tell Sanz what’s the maximum achievable number of points in the crossword. There is no need to cover all postions, just get the maximal score! Crossword and words contain only lowercase English letters.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 500) — the length of the crossword. The second line contains the crossword string. The third line contains a single integer m (1 ≤ m ≤ 100) — the number of given words, and next m lines contain description of words: each line will have a string representing a non-empty word (its length doesn't exceed the length of the crossword) and integer pi (0 ≤ pi ≤ 100). Last line of the input will contain x (1 ≤ x ≤ 100) — maximum number of times a position in crossword can be used.

Output

Output single integer — maximum number of points you can get.

Example

Input

6
abacba
2
aba 6
ba 3
3

Output

12

Note

For example, with the string "abacba", words "aba" (6 points) and "ba" (3 points), and x = 3, you can get at most 12 points - the word "aba" appears once ("abacba"), while "ba" appears two times ("abacba"). Note that for x = 1, you could get at most 9 points, since you wouldn’t be able to count both "aba" and the first appearance of "ba".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 550;
const int oo = 1e9;
struct edge {
  int v, cap, f, c, doi;
  edge() {}
  edge(int _v, int _cap, int _f, int _c, int _doi) {
    v = _v;
    cap = _cap;
    f = _f;
    c = _c;
    doi = _doi;
  }
};
struct tnode {
  int c;
  tnode* ke[26];
};
typedef tnode* pnode;
pnode root, nilT;
vector<edge> ke[maxn];
int n, k;
string S;
pair<int, int> trace[maxn];
int d[maxn], dau[maxn];
deque<int> Q;
void add_edge(int u, int v, int cap, int c) {
  edge a = edge(v, cap, 0, c, ke[v].size());
  edge b = edge(u, 0, 0, -c, ke[u].size());
  ke[u].push_back(a);
  ke[v].push_back(b);
}
void create_graph() {
  for (int i = 0; i <= n + 1; i++) add_edge(i, i + 1, k, 0);
  for (int i = 1; i <= n; i++) {
    pnode p = root;
    int j = i;
    while (1) {
      if (j > n) break;
      p = p->ke[S[j - 1] - 'a'];
      if (p == nilT) break;
      if (p->c != 0) {
        add_edge(i, j + 1, 1, -p->c);
      }
      j++;
    }
  }
}
void create(pnode& p) {
  p = new (tnode);
  for (int i = 0; i < 26; i++) {
    p->ke[i] = nilT;
  }
  p->c = 0;
}
void build(pnode p, string T, int c, int l) {
  if (l == T.size()) {
    p->c = c;
    return;
  }
  if (p->ke[T[l] - 'a'] == nilT) create(p->ke[T[l] - 'a']);
  build(p->ke[T[l] - 'a'], T, c, l + 1);
}
bool findPath() {
  for (int i = 0; i <= n; i++) {
    d[i] = oo;
    trace[i] = make_pair(-1, -1);
    dau[i] = 0;
  }
  d[0] = 0;
  while (!Q.empty()) Q.pop_front();
  Q.push_front(0);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop_front();
    dau[u] = 2;
    for (int j = 0; j < ke[u].size(); j++)
      if (ke[u][j].f < ke[u][j].cap) {
        int v = ke[u][j].v;
        long long tmp = d[u] + ke[u][j].c;
        if (tmp < d[v]) {
          d[v] = tmp;
          trace[v] = make_pair(u, j);
          if (dau[v] == 0)
            Q.push_back(v);
          else if (dau[v] == 2)
            Q.push_front(v);
          dau[v] = 1;
        }
      }
  }
  return (trace[n].first > -1);
}
int enLarge(int& flow) {
  int delta = oo;
  int v = n;
  while (v != 0) {
    int u = trace[v].first;
    int j = trace[v].second;
    delta = min(delta, ke[u][j].cap - ke[u][j].f);
    v = u;
  }
  v = n;
  int res = 0;
  while (v != 0) {
    int u = trace[v].first;
    int j = trace[v].second;
    int nj = ke[u][j].doi;
    ke[u][j].f += delta;
    ke[v][nj].f -= delta;
    res += (ke[u][j].c * delta);
    v = u;
  }
  flow += delta;
  return res;
}
void solve() {
  n = n + 2;
  int flow = 0;
  int res = 0;
  int s = 0;
  while (findPath()) {
    int t = enLarge(flow);
    s += t;
    if (-s > res) res = -s;
  }
  printf("%d\n", res);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  cin >> S;
  int m;
  cin >> m;
  nilT = new (tnode);
  create(root);
  for (int i = 1; i <= m; i++) {
    string T;
    int p;
    cin >> T >> p;
    build(root, T, p, 0);
  }
  cin >> k;
  create_graph();
  solve();
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

A substring of some string is called the most frequent, if the number of its occurrences is not less than number of occurrences of any other substring.

You are given a set of strings. A string (not necessarily from this set) is called good if all elements of the set are the most frequent substrings of this string. Restore the non-empty good string with minimum length. If several such strings exist, restore lexicographically minimum string. If there are no good strings, print "NO" (without quotes).

A substring of a string is a contiguous subsequence of letters in the string. For example, "ab", "c", "abc" are substrings of string "abc", while "ac" is not a substring of that string.

The number of occurrences of a substring in a string is the number of starting positions in the string where the substring occurs. These occurrences could overlap.

String a is lexicographically smaller than string b, if a is a prefix of b, or a has a smaller letter at the first position where a and b differ.

Input

The first line contains integer n (1 ≤ n ≤ 105) — the number of strings in the set.

Each of the next n lines contains a non-empty string consisting of lowercase English letters. It is guaranteed that the strings are distinct.

The total length of the strings doesn't exceed 105.

Output

Print the non-empty good string with minimum length. If several good strings exist, print lexicographically minimum among them. Print "NO" (without quotes) if there are no good strings.

Examples

Input

4
mail
ai
lru
cf

Output

cfmailru

Input

3
kek
preceq
cheburek

Output

NO

Note

One can show that in the first sample only two good strings with minimum length exist: "cfmailru" and "mailrucf". The first string is lexicographically minimum.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool check = true, visited[26];
int to[26], deg[26], father[26], cnt = 0;
char str[200002], ans[200002];
int find(int x) { return father[x] != x ? father[x] = find(father[x]) : x; }
void go(int s) {
  for (int now = s; now != -1; now = to[now])
    ans[cnt++] = (char)((int)'a' + now);
}
void merge(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) check = false;
  father[x] = y;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 26; i++)
    visited[i] = false, deg[i] = 0, to[i] = -1, father[i] = i;
  for (int i = 0; i < n; i++) {
    scanf("%s", str);
    for (int i = 0; str[i]; i++) visited[(int)(str[i] - 'a')] = true;
    for (int i = 0; str[i + 1]; i++) {
      int s = (int)(str[i] - 'a');
      int t = to[s], next = (int)(str[i + 1] - 'a');
      if (t >= 0 && t != next) check = false;
      if (t != next) merge(s, next);
      to[s] = next;
    }
  }
  for (int i = 0; i < 26; i++) deg[to[i]]++;
  for (int i = 0; i < 26; i++)
    if (deg[i] > 1) check = false;
  if (!check)
    printf("NO\n");
  else {
    for (int i = 0; i < 26; i++)
      if (visited[i] && !deg[i]) go(i);
    if (!check)
      printf("NO\n");
    else
      for (int i = 0; i < cnt; i++) printf("%c", ans[i]);
  }
  return 0;
}

```


### Prompt

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

HQ9+ is a joke programming language which has only four one-character instructions:

  * "H" prints "Hello, World!",
  * "Q" prints the source code of the program itself,
  * "9" prints the lyrics of "99 Bottles of Beer" song,
  * "+" increments the value stored in the internal accumulator.

Instructions "H" and "Q" are case-sensitive and must be uppercase. The characters of the program which are not instructions are ignored.

You are given a program written in HQ9+. You have to figure out whether executing this program will produce any output.

Input

The input will consist of a single line p which will give a program in HQ9+. String p will contain between 1 and 100 characters, inclusive. ASCII-code of each character of p will be between 33 (exclamation mark) and 126 (tilde), inclusive.

Output

Output "YES", if executing the program will produce any output, and "NO" otherwise.

Examples

Input

Hi!

Output

YES

Input

Codeforces

Output

NO

Note

In the first case the program contains only one instruction — "H", which prints "Hello, World!".

In the second case none of the program characters are language instructions.

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  char c;
  int count = 0;
  for (;;) {
    scanf("%c", &c);
    if (c == 10) {
      break;
    }
    if (c == 'H' || c == 'Q' || c == '9') {
      count = 1;
    }
  }
  if (count == 1) {
    printf("YES");
  } else {
    printf("NO");
  }
}

```


### Prompt

Create a solution in CPP for the following problem:

Elections in Berland are coming. There are only two candidates — Alice and Bob.

The main Berland TV channel plans to show political debates. There are n people who want to take part in the debate as a spectator. Each person is described by their influence and political views. There are four kinds of political views:

  * supporting none of candidates (this kind is denoted as "00"),
  * supporting Alice but not Bob (this kind is denoted as "10"),
  * supporting Bob but not Alice (this kind is denoted as "01"),
  * supporting both candidates (this kind is denoted as "11").

The direction of the TV channel wants to invite some of these people to the debate. The set of invited spectators should satisfy three conditions:

  * at least half of spectators support Alice (i.e. 2 ⋅ a ≥ m, where a is number of spectators supporting Alice and m is the total number of spectators),
  * at least half of spectators support Bob (i.e. 2 ⋅ b ≥ m, where b is number of spectators supporting Bob and m is the total number of spectators),
  * the total influence of spectators is maximal possible.

Help the TV channel direction to select such non-empty set of spectators, or tell that this is impossible.

Input

The first line contains integer n (1 ≤ n ≤ 4⋅10^5) — the number of people who want to take part in the debate as a spectator.

These people are described on the next n lines. Each line describes a single person and contains the string s_i and integer a_i separated by space (1 ≤ a_i ≤ 5000), where s_i denotes person's political views (possible values — "00", "10", "01", "11") and a_i — the influence of the i-th person.

Output

Print a single integer — maximal possible total influence of a set of spectators so that at least half of them support Alice and at least half of them support Bob. If it is impossible print 0 instead.

Examples

Input

6
11 6
10 4
01 3
00 3
00 7
00 9

Output

22

Input

5
11 1
01 1
00 100
10 1
01 1

Output

103

Input

6
11 19
10 22
00 18
00 29
11 29
10 28

Output

105

Input

3
00 5000
00 5000
00 5000

Output

0

Note

In the first example 4 spectators can be invited to maximize total influence: 1, 2, 3 and 6. Their political views are: "11", "10", "01" and "00". So in total 2 out of 4 spectators support Alice and 2 out of 4 spectators support Bob. The total influence is 6+4+3+9=22.

In the second example the direction can select all the people except the 5-th person.

In the third example the direction can select people with indices: 1, 4, 5 and 6.

In the fourth example it is impossible to select any non-empty set of spectators.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
int n, num[5], a[5][N], cnt, sum, ans;
inline bool cmp(const int &a, const int &b) { return a > b; }
int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i <= n; i++) {
    scanf("%d%d", &x, &y);
    if (!x)
      a[0][++num[0]] = y;
    else if (x == 1)
      a[1][++num[1]] = y;
    else if (x == 10)
      a[2][++num[2]] = y;
    else
      a[3][++num[3]] = y, sum += y;
  }
  sort(a[0] + 1, a[0] + num[0] + 1, cmp);
  sort(a[1] + 1, a[1] + num[1] + 1, cmp);
  sort(a[2] + 1, a[2] + num[2] + 1, cmp);
  for (int i = 2; i <= num[0]; i++) a[0][i] += a[0][i - 1];
  for (int i = 2; i <= num[1]; i++) a[1][i] += a[1][i - 1];
  for (int i = 2; i <= num[2]; i++) a[2][i] += a[2][i - 1];
  for (int i = 0; i <= num[1]; i++) {
    if (num[3] + i < num[2] || num[3] + num[2] < i) continue;
    ans = max(
        ans,
        a[1][i] + a[2][num[2]] +
            a[0][min(num[0], min(num[3] + i - num[2], num[3] + num[2] - i))]);
  }
  for (int i = 0; i <= num[2]; i++) {
    if (num[3] + i < num[1] || num[3] + num[1] < i) continue;
    ans = max(
        ans,
        a[2][i] + a[1][num[1]] +
            a[0][min(num[0], min(num[3] + i - num[1], num[3] + num[1] - i))]);
  }
  printf("%d\n", ans + sum);
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.

As you may know, the coolest photos are on the film (because you can specify the hashtag #film for such).

Brain took a lot of colourful pictures on colored and black-and-white film. Then he developed and translated it into a digital form. But now, color and black-and-white photos are in one folder, and to sort them, one needs to spend more than one hour!

As soon as Brain is a photographer not programmer now, he asks you to help him determine for a single photo whether it is colored or black-and-white.

Photo can be represented as a matrix sized n × m, and each element of the matrix stores a symbol indicating corresponding pixel color. There are only 6 colors:

  * 'C' (cyan)
  * 'M' (magenta)
  * 'Y' (yellow)
  * 'W' (white)
  * 'G' (grey)
  * 'B' (black)

The photo is considered black-and-white if it has only white, black and grey pixels in it. If there are any of cyan, magenta or yellow pixels in the photo then it is considered colored.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 100) — the number of photo pixel matrix rows and columns respectively.

Then n lines describing matrix rows follow. Each of them contains m space-separated characters describing colors of pixels in a row. Each character in the line is one of the 'C', 'M', 'Y', 'W', 'G' or 'B'.

Output

Print the "#Black&White" (without quotes), if the photo is black-and-white and "#Color" (without quotes), if it is colored, in the only line.

Examples

Input

2 2
C M
Y Y

Output

#Color

Input

3 2
W W
W W
B B

Output

#Black&White

Input

1 1
W

Output

#Black&White

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k; j++) {
      char x;
      cin >> x;
      if (x == 'C' || x == 'M' || x == 'Y') flag = true;
    }
  }
  if (flag)
    cout << "#Color" << endl;
  else
    cout << "#Black&White" << endl;
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

You are given an array a_1, a_2, …, a_n.

You need to perform q queries of the following two types:

  1. "MULTIPLY l r x" — for every i (l ≤ i ≤ r) multiply a_i by x.
  2. "TOTIENT l r" — print \varphi(∏ _{i=l}^{r} a_i) taken modulo 10^9+7, where \varphi denotes Euler's totient function.

The [Euler's totient function](http://gg.gg/euler_totient) of a positive integer n (denoted as \varphi(n)) is the number of integers x (1 ≤ x ≤ n) such that \gcd(n,x) = 1.

Input

The first line contains two integers n and q (1 ≤ n ≤ 4 ⋅ 10^5, 1 ≤ q ≤ 2 ⋅ 10^5) — the number of elements in array a and the number of queries.

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

Then q lines follow, describing queries in the format given in the statement.

  1. "MULTIPLY l r x" (1 ≤ l ≤ r ≤ n, 1 ≤ x ≤ 300) — denotes a multiplication query.
  2. "TOTIENT l r" (1 ≤ l ≤ r ≤ n) — denotes a query on the value of Euler's totient function.

It is guaranteed that there is at least one "TOTIENT" query.

Output

For each "TOTIENT" query, print the answer to it.

Example

Input

4 4
5 9 1 2
TOTIENT 3 3
TOTIENT 3 4
MULTIPLY 4 4 3
TOTIENT 4 4

Output

1
1
2

Note

In the first example, \varphi(1) = 1 for the first query, \varphi(2) = 1 for the second query and \varphi(6) = 2 for the third one.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int md = 1e9 + 7;
inline int mul(int a, int b) { return (int)((long long)a * b % md); }
inline int sub(int a, int b) {
  a -= b;
  if (a < 0) return a + md;
  return a;
}
inline int po(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
inline int inv(int a) { return po(a, md - 2); }
inline int di(int a, int b) { return mul(a, inv(b)); }
const int X = 300;
const int P = 62;
int p[P], lp[X + 1];
long long fact[X + 1];
void prime_init() {
  int size = 0;
  memset(lp, -1, (X + 1) * 4);
  for (int i = 2; i <= X; ++i) {
    if (lp[i] == -1) {
      lp[i] = size;
      p[size] = i;
      ++size;
    }
    for (int j = 0; j < size && p[j] <= p[lp[i]] && i * p[j] <= X; ++j)
      lp[i * p[j]] = j;
  }
}
void fact_init() {
  for (int i = 1; i <= X; ++i) {
    int t = i;
    while (t != 1) {
      fact[i] |= (long long)1 << lp[t];
      t /= p[lp[t]];
    }
  }
}
const int N = 400000;
int a[N];
struct SegmentTree {
  vector<pair<int, long long> > t;
  vector<pair<int, long long> > upd;
  SegmentTree(int n) {
    t.resize(1 << (33 - __builtin_clz(n - 1)));
    upd.resize(1 << (33 - __builtin_clz(n - 1)), pair<int, long long>(1, 0));
    build(0, 0, n - 1);
  }
  void build(int v, int tl, int tr);
  void push(int v, int tl, int tr);
  void update(int v, int tl, int tr, int l, int r, int val);
  pair<int, long long> query(int v, int tl, int tr, int l, int r);
};
void SegmentTree::build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v].first = a[tl];
    t[v].second = fact[a[tl]];
  } else {
    build(v * 2 + 1, tl, (tl + tr) / 2);
    build(v * 2 + 2, (tl + tr) / 2 + 1, tr);
    t[v].first = mul(t[v * 2 + 1].first, t[v * 2 + 2].first);
    t[v].second = t[v * 2 + 1].second | t[v * 2 + 2].second;
  }
}
void SegmentTree::push(int v, int tl, int tr) {
  if (upd[v].first != 1) {
    t[v].first = mul(t[v].first, po(upd[v].first, tr - tl + 1));
    t[v].second |= upd[v].second;
    if (tl != tr) {
      upd[v * 2 + 1].first = mul(upd[v * 2 + 1].first, upd[v].first);
      upd[v * 2 + 2].first = mul(upd[v * 2 + 2].first, upd[v].first);
      upd[v * 2 + 1].second |= upd[v].second;
      upd[v * 2 + 2].second |= upd[v].second;
    }
    upd[v].first = 1;
    upd[v].second = 0;
  }
}
void SegmentTree::update(int v, int tl, int tr, int l, int r, int val) {
  if (tr < l || tl > r)
    push(v, tl, tr);
  else if (tl >= l && tr <= r) {
    upd[v].first = mul(upd[v].first, val);
    upd[v].second |= fact[val];
    push(v, tl, tr);
  } else {
    push(v, tl, tr);
    update(v * 2 + 1, tl, (tl + tr) / 2, l, r, val);
    update(v * 2 + 2, (tl + tr) / 2 + 1, tr, l, r, val);
    t[v].first = mul(t[v * 2 + 1].first, t[v * 2 + 2].first);
    t[v].second = t[v * 2 + 1].second | t[v * 2 + 2].second;
  }
}
pair<int, long long> SegmentTree::query(int v, int tl, int tr, int l, int r) {
  if (tr < l || tl > r) return make_pair((int)1, (long long)0);
  push(v, tl, tr);
  if (tl >= l && tr <= r) return t[v];
  pair<int, long long> ansl = query(v * 2 + 1, tl, (tl + tr) / 2, l, r);
  pair<int, long long> ansr = query(v * 2 + 2, (tl + tr) / 2 + 1, tr, l, r);
  ansl.first = mul(ansl.first, ansr.first);
  ansl.second |= ansr.second;
  return ansl;
}
int totient(pair<int, long long> x) {
  for (int i = 0; i < P; ++i)
    if (((long long)1 << i) & x.second)
      x.first = mul(x.first, sub(1, di(1, p[i])));
  return x.first;
}
int main() {
  prime_init();
  fact_init();
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  SegmentTree tr(n);
  char qtype[9];
  int l, r;
  while (q--) {
    scanf("%s%d%d", qtype, &l, &r);
    if (!strcmp(qtype, "TOTIENT")) {
      pair<int, long long> qans = tr.query(0, 0, n - 1, l - 1, r - 1);
      printf("%d\n", totient(qans));
    } else {
      int val;
      scanf("%d", &val);
      tr.update(0, 0, n - 1, l - 1, r - 1, val);
    }
  }
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Let's call some positive integer classy if its decimal representation contains no more than 3 non-zero digits. For example, numbers 4, 200000, 10203 are classy and numbers 4231, 102306, 7277420000 are not.

You are given a segment [L; R]. Count the number of classy integers x such that L ≤ x ≤ R.

Each testcase contains several segments, for each of them you are required to solve the problem separately.

Input

The first line contains a single integer T (1 ≤ T ≤ 10^4) — the number of segments in a testcase.

Each of the next T lines contains two integers L_i and R_i (1 ≤ L_i ≤ R_i ≤ 10^{18}).

Output

Print T lines — the i-th line should contain the number of classy integers on a segment [L_i; R_i].

Example

Input

4
1 1000
1024 1024
65536 65536
999999 1000001

Output

1000
1
0
2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 20;
long long dp[N][2][4];
vector<int> num(N);
long long cn(int cur, bool f, int k) {
  if (k > 3) return 0;
  if (cur == N) return (k > 0);
  if (dp[cur][f][k] == -1) {
    int limit = 9;
    if (f) limit = num[cur];
    long long res = 0;
    for (int i = 0; i <= limit; i++) {
      if (f && i == limit)
        res += cn(cur + 1, true, k + (i > 0));
      else
        res += cn(cur + 1, false, k + (i > 0));
    }
    dp[cur][f][k] = res;
  }
  return dp[cur][f][k];
}
long long solve(long long n) {
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < N; i++) num[i] = 0;
  for (int i = N - 1; i >= 0 && n > 0; i--, n /= 10) num[i] = n % 10;
  return cn(0, true, 0);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t-- > 0) {
    long long l, r;
    cin >> l >> r;
    cout << solve(r) - solve(l - 1) << "\n";
  }
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

A telephone number is a sequence of exactly 11 digits such that its first digit is 8.

Vasya and Petya are playing a game. Initially they have a string s of length n (n is odd) consisting of digits. Vasya makes the first move, then players alternate turns. In one move the player must choose a character and erase it from the current string. For example, if the current string 1121, after the player's move it may be 112, 111 or 121. The game ends when the length of string s becomes 11. If the resulting string is a telephone number, Vasya wins, otherwise Petya wins.

You have to determine if Vasya has a winning strategy (that is, if Vasya can win the game no matter which characters Petya chooses during his moves).

Input

The first line contains one integer n (13 ≤ n < 10^5, n is odd) — the length of string s.

The second line contains the string s (|s| = n) consisting only of decimal digits.

Output

If Vasya has a strategy that guarantees him victory, print YES.

Otherwise print NO.

Examples

Input

13
8380011223344

Output

YES

Input

15
807345619350641

Output

NO

Note

In the first example Vasya needs to erase the second character. Then Petya cannot erase a character from the remaining string 880011223344 so that it does not become a telephone number.

In the second example after Vasya's turn Petya can erase one character character 8. The resulting string can't be a telephone number, because there is no digit 8 at all.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0, cnt5 = 0, ind;
  for (int i = 0; i < n; i++) {
    if (s[i] == '8') {
      cnt1++;
      ind = i;
    }
  }
  int ch = (n - 11) / 2;
  if (ch >= cnt1) {
    cout << "NO" << endl;
  } else {
    cnt3 = ch + 1;
    for (int i = 0; i < n; i++) {
      if (s[i] == '8') {
        cnt4++;
        if (cnt4 == cnt3) {
          ind = i;
          break;
        }
      }
    }
    for (int i = 0; i < ind; i++) {
      if (s[i] != '8') cnt5++;
    }
    if (cnt5 <= ch)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

```


### Prompt

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

Musicians of a popular band "Flayer" have announced that they are going to "make their exit" with a world tour. Of course, they will visit Berland as well.

There are n cities in Berland. People can travel between cities using two-directional train routes; there are exactly m routes, i-th route can be used to go from city vi to city ui (and from ui to vi), and it costs wi coins to use this route.

Each city will be visited by "Flayer", and the cost of the concert ticket in i-th city is ai coins.

You have friends in every city of Berland, and they, knowing about your programming skills, asked you to calculate the minimum possible number of coins they have to pay to visit the concert. For every city i you have to compute the minimum number of coins a person from city i has to spend to travel to some city j (or possibly stay in city i), attend a concert there, and return to city i (if j ≠ i).

Formally, for every <image> you have to calculate <image>, where d(i, j) is the minimum number of coins you have to spend to travel from city i to city j. If there is no way to reach city j from city i, then we consider d(i, j) to be infinitely large.

Input

The first line contains two integers n and m (2 ≤ n ≤ 2·105, 1 ≤ m ≤ 2·105).

Then m lines follow, i-th contains three integers vi, ui and wi (1 ≤ vi, ui ≤ n, vi ≠ ui, 1 ≤ wi ≤ 1012) denoting i-th train route. There are no multiple train routes connecting the same pair of cities, that is, for each (v, u) neither extra (v, u) nor (u, v) present in input.

The next line contains n integers a1, a2, ... ak (1 ≤ ai ≤ 1012) — price to attend the concert in i-th city.

Output

Print n integers. i-th of them must be equal to the minimum number of coins a person from city i has to spend to travel to some city j (or possibly stay in city i), attend a concert there, and return to city i (if j ≠ i).

Examples

Input

4 2
1 2 4
2 3 7
6 20 1 25

Output

6 14 1 25

Input

3 3
1 2 1
2 3 1
1 3 1
30 10 20

Output

12 10 12

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  long long int inp[200004];
  vector<pair<long long int, long long int>> graph[200004];
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int>>,
                 greater<pair<long long int, long long int>>>
      minHeap;
  cin >> n >> m;
  while (m--) {
    int u, v;
    long long int weight;
    cin >> u >> v >> weight;
    weight *= 2;
    graph[u].push_back({v, weight});
    graph[v].push_back({u, weight});
  }
  for (int i = 1; i <= n; i++) cin >> inp[i];
  for (int i = 1; i <= n; i++) minHeap.push({inp[i], i});
  while (minHeap.empty() == false) {
    long long int temp = minHeap.top().second;
    long long int pre = minHeap.top().first;
    minHeap.pop();
    if (inp[temp] != pre) continue;
    for (auto i : graph[temp]) {
      int to = i.first;
      long long int w = i.second;
      if (inp[to] > pre + w) {
        inp[to] = pre + w;
        minHeap.push({inp[to], to});
      }
    }
  }
  for (int i = 1; i <= n; i++) cout << inp[i] << " ";
  cout << endl;
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and the finish on the tile number n. During the walk it is allowed to move from right to left between adjacent tiles in a row, and jump over a tile. More formally, if you are standing on the tile number i (i < n - 1), you can reach the tiles number i + 1 or the tile number i + 2 from it (if you stand on the tile number n - 1, you can only reach tile number n). We can assume that all the opposition movements occur instantaneously.

In order to thwart an opposition rally, the Berland bloody regime organized the rain. The tiles on the boulevard are of poor quality and they are rapidly destroyed in the rain. We know that the i-th tile is destroyed after ai days of rain (on day ai tile isn't destroyed yet, and on day ai + 1 it is already destroyed). Of course, no one is allowed to walk on the destroyed tiles! So the walk of the opposition is considered thwarted, if either the tile number 1 is broken, or the tile number n is broken, or it is impossible to reach the tile number n from the tile number 1 if we can walk on undestroyed tiles.

The opposition wants to gather more supporters for their walk. Therefore, the more time they have to pack, the better. Help the opposition to calculate how much time they still have and tell us for how many days the walk from the tile number 1 to the tile number n will be possible.

Input

The first line contains integer n (1 ≤ n ≤ 103) — the boulevard's length in tiles.

The second line contains n space-separated integers ai — the number of days after which the i-th tile gets destroyed (1 ≤ ai ≤ 103).

Output

Print a single number — the sought number of days.

Examples

Input

4
10 3 5 10

Output

5

Input

5
10 2 8 3 5

Output

5

Note

In the first sample the second tile gets destroyed after day three, and the only path left is 1 → 3 → 4. After day five there is a two-tile gap between the first and the last tile, you can't jump over it.

In the second sample path 1 → 3 → 5 is available up to day five, inclusive. On day six the last tile is destroyed and the walk is thwarted.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ;
  int n;
  cin >> n;
  ;
  int A[100000];
  int max = 0;
  for (int i = (1); i < n + 1; i++) {
    cin >> A[i];
    if (A[i] > max) max = A[i];
  }
  int pos = 1;
  int ans = max + 1;
  for (int i = (1); i < max + 1; i++) {
    pos = 1;
    while (pos < n) {
      if (A[1] < i) {
        ans = min(i, ans);
        break;
      }
      if (A[n] < i) {
        ans = min(i, ans);
        break;
      }
      if (A[pos + 1] >= i) {
        pos++;
      } else if (A[pos + 2] >= i)
        pos++;
      else {
        ans = min(ans, i);
        break;
      }
    }
  }
  cout << ans - 1 << endl;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Vasya is reading a e-book. The file of the book consists of n pages, numbered from 1 to n. The screen is currently displaying the contents of page x, and Vasya wants to read the page y. There are two buttons on the book which allow Vasya to scroll d pages forwards or backwards (but he cannot scroll outside the book). For example, if the book consists of 10 pages, and d = 3, then from the first page Vasya can scroll to the first or to the fourth page by pressing one of the buttons; from the second page — to the first or to the fifth; from the sixth page — to the third or to the ninth; from the eighth — to the fifth or to the tenth.

Help Vasya to calculate the minimum number of times he needs to press a button to move to page y.

Input

The first line contains one integer t (1 ≤ t ≤ 10^3) — the number of testcases.

Each testcase is denoted by a line containing four integers n, x, y, d (1≤ n, d ≤ 10^9, 1 ≤ x, y ≤ n) — the number of pages, the starting page, the desired page, and the number of pages scrolled by pressing one button, respectively.

Output

Print one line for each test.

If Vasya can move from page x to page y, print the minimum number of times he needs to press a button to do it. Otherwise print -1.

Example

Input

3
10 4 5 2
5 1 3 4
20 4 19 3

Output

4
-1
5

Note

In the first test case the optimal sequence is: 4 → 2 → 1 → 3 → 5.

In the second test case it is possible to get to pages 1 and 5.

In the third test case the optimal sequence is: 4 → 7 → 10 → 13 → 16 → 19.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int q, w, e, r;
    scanf("%d %d %d %d", &q, &w, &e, &r);
    int ch = 1234567890;
    int xx = abs(e - w);
    if (xx % r == 0) {
      ch = min(ch, xx / r);
    }
    int gap = 0;
    gap = (w - 1) / r;
    if ((w - 1) % r) gap++;
    if ((e - 1) % r == 0) {
      ch = min(ch, gap + (e - 1) / r);
    }
    gap = (q - w) / r;
    if ((q - w) % r) gap++;
    if ((q - e) % r == 0) ch = min(ch, gap + (q - e) / r);
    if (ch == 1234567890)
      puts("-1");
    else
      printf("%d\n", ch);
  }
}

```


### Prompt

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

N friends of Takahashi has come to a theme park.

To ride the most popular roller coaster in the park, you must be at least K centimeters tall.

The i-th friend is h_i centimeters tall.

How many of the Takahashi's friends can ride the roller coaster?

Constraints

* 1 \le N \le 10^5
* 1 \le K \le 500
* 1 \le h_i \le 500
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
h_1 h_2 \ldots h_N

Output

Print the number of people among the Takahashi's friends who can ride the roller coaster.

Examples

Input

4 150
150 140 100 200

Output

2

Input

1 500
499

Output

0

Input

5 1
100 200 300 400 500

Output

5

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int n,k,x,c;
int main(){
cin>>n>>k;
for(int i=0;i<n;i++){
    cin>>x;
    if(x>=k)c++;
}
cout<<c<<endl;
}

```


### Prompt

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

You are given an array a of n integers.

You want to make all elements of a equal to zero by doing the following operation exactly three times:

  * Select a segment, for each number in this segment we can add a multiple of len to it, where len is the length of this segment (added integers can be different).

It can be proven that it is always possible to make all elements of a equal to zero.

Input

The first line contains one integer n (1 ≤ n ≤ 100 000): the number of elements of the array.

The second line contains n elements of an array a separated by spaces: a_1, a_2, ..., a_n (-10^9 ≤ a_i ≤ 10^9).

Output

The output should contain six lines representing three operations.

For each operation, print two lines:

  * The first line contains two integers l, r (1 ≤ l ≤ r ≤ n): the bounds of the selected segment.

  * The second line contains r-l+1 integers b_l, b_{l+1}, ..., b_r (-10^{18} ≤ b_i ≤ 10^{18}): the numbers to add to a_l, a_{l+1}, …, a_r, respectively; b_i should be divisible by r - l + 1.

Example

Input

4
1 3 2 4

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  if (n == 1) {
    for (int i = 0; i < 2; i++) {
      cout << "1 1\n" << 0 << endl;
    }
    cout << "1 1\n" << -v[0] << endl;
    return 0;
  }
  cout << "1 1\n" << -v[0] << endl;
  cout << "1 " << n << endl;
  cout << 0 << " ";
  for (int i = 1; i < n; i++) {
    cout << -(n * v[i]) << " ";
  }
  cout << endl;
  cout << "2 " << n << endl;
  for (int i = 1; i < n; i++) {
    cout << (n - 1) * v[i] << " ";
  }
  cout << endl;
  return 0;
}

```


### Prompt

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

Okabe needs to renovate the Future Gadget Laboratory after he tried doing some crazy experiments! The lab is represented as an n by n square grid of integers. A good lab is defined as a lab in which every number not equal to 1 can be expressed as the sum of a number in the same row and a number in the same column. In other words, for every x, y such that 1 ≤ x, y ≤ n and ax, y ≠ 1, there should exist two indices s and t so that ax, y = ax, s + at, y, where ai, j denotes the integer in i-th row and j-th column.

Help Okabe determine whether a given lab is good!

Input

The first line of input contains the integer n (1 ≤ n ≤ 50) — the size of the lab.

The next n lines contain n space-separated integers denoting a row of the grid. The j-th integer in the i-th row is ai, j (1 ≤ ai, j ≤ 105).

Output

Print "Yes" if the given lab is good and "No" otherwise.

You can output each letter in upper or lower case.

Examples

Input

3
1 1 2
2 3 1
6 4 1

Output

Yes

Input

3
1 5 2
1 1 1
1 2 3

Output

No

Note

In the first sample test, the 6 in the bottom left corner is valid because it is the sum of the 2 above it and the 4 on the right. The same holds for every number not equal to 1 in this table, so the answer is "Yes".

In the second sample test, the 5 cannot be formed as the sum of an integer in the same row and an integer in the same column. Thus the answer is "No".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m = 0, k = 1, e, mo = 0, x, y = 0, d, i, l = -8909, j = -987,
                   na = 0, p = 0, o = 0, t = 0, z = 0, c1 = 12341, c2 = -2;
  cin >> n;
  long long int a[n][n], b[n][n];
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      cin >> a[i][j];
      b[i][j] = a[i][j];
    }
  }
  p = 0;
  z = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (a[i][j] != 1) {
        z = 0;
        for (k = 0; k < n; k++) {
          for (l = 0; l < n; l++) {
            if (k == j || l == i) continue;
            if (a[i][k] + a[l][j] == a[i][j]) {
              z = 1;
              break;
            }
          }
          if (z == 1) break;
        }
        if (z != 1) {
          cout << "No";
          return 0;
        }
      }
    }
  }
  cout << "Yes";
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Dr. Evil kidnapped Mahmoud and Ehab in the evil land because of their performance in the Evil Olympiad in Informatics (EOI). He decided to give them some problems to let them go.

Dr. Evil is interested in sets, He has a set of n integers. Dr. Evil calls a set of integers evil if the MEX of it is exactly x. the MEX of a set of integers is the minimum non-negative integer that doesn't exist in it. For example, the MEX of the set {0, 2, 4} is 1 and the MEX of the set {1, 2, 3} is 0 .

Dr. Evil is going to make his set evil. To do this he can perform some operations. During each operation he can add some non-negative integer to his set or erase some element from it. What is the minimal number of operations Dr. Evil has to perform to make his set evil?

Input

The first line contains two integers n and x (1 ≤ n ≤ 100, 0 ≤ x ≤ 100) — the size of the set Dr. Evil owns, and the desired MEX.

The second line contains n distinct non-negative integers not exceeding 100 that represent the set.

Output

The only line should contain one integer — the minimal number of operations Dr. Evil should perform.

Examples

Input

5 3
0 4 5 6 7

Output

2

Input

1 0
0

Output

1

Input

5 0
1 2 3 4 5

Output

0

Note

For the first test case Dr. Evil should add 1 and 2 to the set performing 2 operations.

For the second test case Dr. Evil should erase 0 from the set. After that, the set becomes empty, so the MEX of it is 0.

In the third test case the set is already evil.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string digit = "0123456789";
string small = "abcdefghijklmnopqrstuvwxyz";
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
int dx4[] = {1, -1, 0, 0};
int dy4[] = {0, 0, 1, -1};
int main() {
  long long n, x;
  cin >> n >> x;
  long long arr[101] = {0};
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    arr[x] = 1;
  }
  long long cnt = 0;
  for (long long i = 0; i <= x; i++) {
    if ((arr[i] == 0 && i != x) || (arr[i] == 1 && x == i)) cnt++;
  }
  cout << cnt;
}

```


### Prompt

Generate a CPP solution to the following problem:

Little Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vitaly's algorithm works with string s, consisting of characters "x" and "y", and uses two following operations at runtime:

  1. Find two consecutive characters in the string, such that the first of them equals "y", and the second one equals "x" and swap them. If there are several suitable pairs of characters, we choose the pair of characters that is located closer to the beginning of the string.
  2. Find in the string two consecutive characters, such that the first of them equals "x" and the second one equals "y". Remove these characters from the string. If there are several suitable pairs of characters, we choose the pair of characters that is located closer to the beginning of the string.

The input for the new algorithm is string s, and the algorithm works as follows:

  1. If you can apply at least one of the described operations to the string, go to step 2 of the algorithm. Otherwise, stop executing the algorithm and print the current string.
  2. If you can apply operation 1, then apply it. Otherwise, apply operation 2. After you apply the operation, go to step 1 of the algorithm.

Now Vitaly wonders, what is going to be printed as the result of the algorithm's work, if the input receives string s.

Input

The first line contains a non-empty string s.

It is guaranteed that the string only consists of characters "x" and "y". It is guaranteed that the string consists of at most 106 characters. It is guaranteed that as the result of the algorithm's execution won't be an empty string.

Output

In the only line print the string that is printed as the result of the algorithm's work, if the input of the algorithm input receives string s.

Examples

Input

x

Output

x

Input

yxyxy

Output

y

Input

xxxxxy

Output

xxxx

Note

In the first test the algorithm will end after the first step of the algorithm, as it is impossible to apply any operation. Thus, the string won't change.

In the second test the transformation will be like this:

  1. string "yxyxy" transforms into string "xyyxy";
  2. string "xyyxy" transforms into string "xyxyy";
  3. string "xyxyy" transforms into string "xxyyy";
  4. string "xxyyy" transforms into string "xyy";
  5. string "xyy" transforms into string "y".

As a result, we've got string "y".

In the third test case only one transformation will take place: string "xxxxxy" transforms into string "xxxx". Thus, the answer will be string "xxxx".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string str1;
int main() {
  int i, cnt1, cnt2;
  char ch;
  str1 = "";
  cnt1 = cnt2 = 0;
  ch = getchar();
  while (ch != '\n' && ch != EOF) {
    str1 += ch;
    if (ch == 'x')
      cnt1++;
    else
      cnt2++;
    ch = getchar();
  }
  if (cnt1 > cnt2) {
    for (i = 1; i <= cnt1 - cnt2; i++) putchar('x');
  } else {
    for (i = 1; i <= cnt2 - cnt1; i++) putchar('y');
  }
}

```


### Prompt

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

You have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of having x people for the task is xk.

Output the sum of costs over all non-empty subsets of people.

Input

Only line of input contains two integers N (1 ≤ N ≤ 109) representing total number of people and k (1 ≤ k ≤ 5000).

Output

Output the sum of costs for all non empty subsets modulo 109 + 7.

Examples

Input

1 1

Output

1

Input

3 2

Output

24

Note

In the first example, there is only one non-empty subset {1} with cost 11 = 1.

In the second example, there are seven non-empty subsets.

- {1} with cost 12 = 1

- {2} with cost 12 = 1

- {1, 2} with cost 22 = 4

- {3} with cost 12 = 1

- {1, 3} with cost 22 = 4

- {2, 3} with cost 22 = 4

- {1, 2, 3} with cost 32 = 9

The total cost is 1 + 1 + 4 + 1 + 4 + 4 + 9 = 24.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long power(long long base, long long exp, long long p) {
  base %= p;
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % p;
    base = (base * base) % p;
    exp /= 2;
  }
  return res % p;
}
std::vector<std::vector<long long> > sn(5010, std::vector<long long>(5010, 0));
void pre() {
  for (long long n = 1; n < 5010; n++) {
    sn[n][1] = 1;
    for (long long k = 2; k <= n; k++) {
      sn[n][k] = (sn[n - 1][k - 1] + k * sn[n - 1][k]) % 1000000007;
    }
  }
}
void solve() {
  long long n, k;
  cin >> n >> k;
  long long ans = 0, c = 1;
  for (long long i = 1; i <= min(n, k); i++) {
    long long x = power(2, n - i, 1000000007);
    c = (c * (n - i + 1)) % 1000000007;
    x = (x * c) % 1000000007;
    x = (x * sn[k][i]) % 1000000007;
    ans = (ans + x) % 1000000007;
  }
  cout << ans << "\n";
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  pre();
  long long t = 1;
  while (t--) solve();
}

```


### Prompt

Generate a Cpp solution to the following problem:

The Little Elephant has two permutations a and b of length n, consisting of numbers from 1 to n, inclusive. Let's denote the i-th (1 ≤ i ≤ n) element of the permutation a as ai, the j-th (1 ≤ j ≤ n) element of the permutation b — as bj.

The distance between permutations a and b is the minimum absolute value of the difference between the positions of the occurrences of some number in a and in b. More formally, it's such minimum |i - j|, that ai = bj.

A cyclic shift number i (1 ≤ i ≤ n) of permutation b consisting from n elements is a permutation bibi + 1... bnb1b2... bi - 1. Overall a permutation has n cyclic shifts.

The Little Elephant wonders, for all cyclic shifts of permutation b, what is the distance between the cyclic shift and permutation a?

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the size of the permutations. The second line contains permutation a as n distinct numbers from 1 to n, inclusive. The numbers are separated with single spaces. The third line contains permutation b in the same format.

Output

In n lines print n integers — the answers for cyclic shifts. Print the answers to the shifts in the order of the shifts' numeration in permutation b, that is, first for the 1-st cyclic shift, then for the 2-nd, and so on.

Examples

Input

2
1 2
2 1

Output

1
0

Input

4
2 1 3 4
3 4 2 1

Output

2
1
0
1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int list1[111111];
int pos[111111];
int list2[111111];
int n;
int abs(int x) { return x > 0 ? x : -x; }
multiset<int> st;
int find(int x) {
  multiset<int>::iterator i = st.lower_bound(x);
  multiset<int>::iterator j;
  if (i == st.begin()) {
    return abs(*i - x);
  }
  j = i;
  j--;
  int r1 = abs(*i - x);
  int r2 = abs(*j - x);
  return r1 > r2 ? r2 : r1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", list1 + i);
    pos[list1[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", list2 + i);
    st.insert(i - pos[list2[i]]);
  }
  for (int i = 0; i < n;) {
    printf("%d\n", find(i));
    i++;
    st.erase(st.find(i - pos[list2[i]]));
    st.insert(n - pos[list2[i]] + i);
  }
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

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

Vova likes pictures with kittens. The news feed in the social network he uses can be represented as an array of n consecutive pictures (with kittens, of course). Vova likes all these pictures, but some are more beautiful than the others: the i-th picture has beauty a_i.

Vova wants to repost exactly x pictures in such a way that:

  * each segment of the news feed of at least k consecutive pictures has at least one picture reposted by Vova;
  * the sum of beauty values of reposted pictures is maximum possible.

For example, if k=1 then Vova has to repost all the pictures in the news feed. If k=2 then Vova can skip some pictures, but between every pair of consecutive pictures Vova has to repost at least one of them.

Your task is to calculate the maximum possible sum of values of reposted pictures if Vova follows conditions described above, or say that there is no way to satisfy all conditions.

Input

The first line of the input contains three integers n, k and x (1 ≤ k, x ≤ n ≤ 200) — the number of pictures in the news feed, the minimum length of segment with at least one repost in it and the number of pictures Vova is ready to repost.

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

Output

Print -1 if there is no way to repost some pictures to satisfy all the conditions in the problem statement.

Otherwise print one integer — the maximum sum of values of reposted pictures if Vova follows conditions described in the problem statement.

Examples

Input

5 2 3
5 1 3 10 1

Output

18

Input

6 1 5
10 30 30 70 10 10

Output

-1

Input

4 3 1
1 100 1 1

Output

100

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline int read(T& x) {
  x = 0;
  char c = getchar(), f = 1;
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    if (c == -1) return -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  x *= f;
  return 1;
}
template <typename T, typename... Args>
inline int read(T& x, Args&... args) {
  return read(x) + read(args...);
}
template <typename T>
inline int write(T x) {
  if (x < 0) return putchar('-') & write((~x) + 1);
  if (x / 10) return write(x / 10) & putchar(x % 10 | 48);
  return putchar(x | 48);
}
template <typename T>
inline int write(T x, char c) {
  return write(x) + putchar(c);
}
long long n, m, k;
long long dp[5005][5005];
long long a[5005];
deque<int> dq;
signed main() {
  read(n, k, m);
  for (int i = 1; i <= n; i++) read(a[i]);
  memset(dp, -0x3f, sizeof dp);
  dp[0][0] = 0;
  for (int i = 1; i <= m; i++) {
    dq.clear();
    dq.push_back(0);
    for (int j = 1; j <= n; j++) {
      while (!dq.empty() && j - dq.front() > k) dq.pop_front();
      if (!dq.empty()) dp[i][j] = dp[i - 1][dq.front()] + a[j];
      while (!dq.empty() && dp[i - 1][dq.back()] < dp[i - 1][j]) dq.pop_back();
      dq.push_back(j);
    }
  }
  long long ans = -1;
  for (int i = n - k + 1; i <= n; i++)
    ans = ((ans) > (dp[m][i]) ? (ans) : (dp[m][i]));
  write(ans, '\n');
}

```


### Prompt

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

Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card.

The players take turns and Ciel takes the first turn. In Ciel's turn she takes a card from the top of any non-empty pile, and in Jiro's turn he takes a card from the bottom of any non-empty pile. Each player wants to maximize the total sum of the cards he took. The game ends when all piles become empty.

Suppose Ciel and Jiro play optimally, what is the score of the game?

Input

The first line contain an integer n (1 ≤ n ≤ 100). Each of the next n lines contains a description of the pile: the first integer in the line is si (1 ≤ si ≤ 100) — the number of cards in the i-th pile; then follow si positive integers c1, c2, ..., ck, ..., csi (1 ≤ ck ≤ 1000) — the sequence of the numbers on the cards listed from top of the current pile to bottom of the pile.

Output

Print two integers: the sum of Ciel's cards and the sum of Jiro's cards if they play optimally.

Examples

Input

2
1 100
2 1 10

Output

101 10

Input

1
9 2 8 6 5 9 4 7 1 3

Output

30 15

Input

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

Output

18 18

Input

3
3 1000 1000 1000
6 1000 1000 1000 1000 1000 1000
5 1000 1000 1000 1000 1000

Output

7000 7000

Note

In the first example, Ciel will take the cards with number 100 and 1, Jiro will take the card with number 10.

In the second example, Ciel will take cards with numbers 2, 8, 6, 5, 9 and Jiro will take cards with numbers 4, 7, 1, 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m, c[N], s[N];
bool cmp(const int& a, const int& b) { return a > b; }
int main() {
  int cnt = 0, p = 0, q = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &m);
    int tmp = m / 2;
    for (int j = 0; j < m; j++) {
      scanf("%d", &c[j]);
      if (j < tmp)
        p += c[j];
      else
        q += c[j];
    }
    if (m & 1) {
      q -= c[tmp];
      s[cnt++] = c[tmp];
    }
  }
  sort(s, s + cnt, cmp);
  for (int i = 0; i < cnt; i++) {
    if (i & 1)
      q += s[i];
    else
      p += s[i];
  }
  printf("%d %d\n", p, q);
  return 0;
}

```


### Prompt

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

Tom loves vowels, and he likes long words with many vowels. His favorite words are vowelly words. We say a word of length k is vowelly if there are positive integers n and m such that n⋅ m = k and when the word is written by using n rows and m columns (the first row is filled first, then the second and so on, with each row filled from left to right), every vowel of the English alphabet appears at least once in every row and every column.

You are given an integer k and you must either print a vowelly word of length k or print -1 if no such word exists.

In this problem the vowels of the English alphabet are 'a', 'e', 'i', 'o' ,'u'.

Input

Input consists of a single line containing the integer k (1≤ k ≤ 10^4) — the required length.

Output

The output must consist of a single line, consisting of a vowelly word of length k consisting of lowercase English letters if it exists or -1 if it does not.

If there are multiple possible words, you may output any of them.

Examples

Input

7

Output

-1

Input

36

Output

agoeuioaeiruuimaeoieauoweouoiaouimae

Note

In the second example, the word "agoeuioaeiruuimaeoieauoweouoiaouimae" can be arranged into the following 6 × 6 grid:

<image>

It is easy to verify that every row and every column contain all the vowels.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
ostream &operator<<(ostream &out, pair<S, T> const &p) {
  out << p.first << " " << p.second;
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> const &v) {
  long long int l = v.size();
  for (long long int i = 0; i < l - 1; i++) out << v[i] << ' ';
  if (l > 0) out << v[l - 1];
  return out;
}
template <typename T>
void trace(const char *name, T &&arg1) {
  cout << name << " : " << arg1 << "\n";
}
template <typename T, typename... Args>
void trace(const char *names, T &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  trace(comma + 1, args...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  map<long long int, char> ma;
  ma[0] = 'a';
  ma[1] = 'e';
  ma[2] = 'i';
  ma[3] = 'o';
  ma[4] = 'u';
  long long int k;
  cin >> k;
  for (int i = 1; i * i <= k; i++) {
    if (k % i == 0) {
      long long int n = i;
      long long int m = k / i;
      if (n >= 5 and m >= 5) {
        for (int j = 0; j < n; j++) {
          for (int k = 0; k < m; k++) {
            cout << ma[(j + k) % 5];
          }
        }
        return 0;
      }
    }
  }
  cout << -1 << "\n";
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

Athenaeus has just finished creating his latest musical composition and will present it tomorrow to the people of Athens. Unfortunately, the melody is rather dull and highly likely won't be met with a warm reception.

His song consists of n notes, which we will treat as positive integers. The diversity of a song is the number of different notes it contains. As a patron of music, Euterpe watches over composers and guides them throughout the process of creating new melodies. She decided to help Athenaeus by changing his song to make it more diverse.

Being a minor goddess, she cannot arbitrarily change the song. Instead, for each of the n notes in the song, she can either leave it as it is or increase it by 1.

Given the song as a sequence of integers describing the notes, find out the maximal, achievable diversity.

Input

The input consists of multiple test cases. The first line contains an integer t (1 ≤ t ≤ 10 000) — the number of test cases. Then t test cases follow, each one is described in two lines.

In the first line of each test case there is a single integer n (1 ≤ n ≤ 10^5) denoting the length of the song. The next line contains a sequence of n integers x_1, x_2, …, x_n (1 ≤ x_1 ≤ x_2 ≤ … ≤ x_n ≤ 2 ⋅ n), describing the song.

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

Output

For each test case, you should output a single line containing precisely one integer, the maximal diversity of the song, i.e. the maximal possible number of different elements in the final sequence.

Example

Input

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

Output

5
2
6
1
3

Note

In the first test case, Euterpe can increase the second, fifth and sixth element to obtain the sequence 1, \underline{3}, 2, 2, \underline{6}, \underline{7}, which has 5 different elements (increased elements are underlined).

In the second test case, Euterpe can increase the first element to obtain the sequence \underline{5}, 4, which has 2 different elements.

In the third test case, Euterpe can increase the second, fifth and sixth element to obtain the sequence 1, \underline{2}, 3, 4, \underline{5}, \underline{6}, which has 6 different elements.

### Response

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

using namespace std;

int main(){
  int t;
  cin >> t;
  while(t--){
    int n;
    cin >> n;
    vector<int> arr(n);
    vector<int> arr1(n);
    for (int i=0;i<n;++i){
      cin >> arr[i];
      arr1[i] = arr[i] + 1;
    }
    set<int> st;
    for (int i=0;i<n;++i){
      if (st.find(arr[i]) == st.end()) st.insert(arr[i]);
      else st.insert(arr1[i]);
    }
    cout << st.size() << endl;
  }
}

/*
1 2 2 2 5 6
2 3 3 3 6 7
1 2 3 3 5 6

113445
224556
123456
*/
```


### Prompt

Create a solution in cpp for the following problem:

Uncle Fyodor, Matroskin the Cat and Sharic the Dog live their simple but happy lives in Prostokvashino. Sometimes they receive parcels from Uncle Fyodor’s parents and sometimes from anonymous benefactors, in which case it is hard to determine to which one of them the package has been sent. A photographic rifle is obviously for Sharic who loves hunting and fish is for Matroskin, but for whom was a new video game console meant? Every one of the three friends claimed that the present is for him and nearly quarreled. Uncle Fyodor had an idea how to solve the problem justly: they should suppose that the console was sent to all three of them and play it in turns. Everybody got relieved but then yet another burning problem popped up — who will play first? This time Matroskin came up with a brilliant solution, suggesting the most fair way to find it out: play rock-paper-scissors together. The rules of the game are very simple. On the count of three every player shows a combination with his hand (or paw). The combination corresponds to one of three things: a rock, scissors or paper. Some of the gestures win over some other ones according to well-known rules: the rock breaks the scissors, the scissors cut the paper, and the paper gets wrapped over the stone. Usually there are two players. Yet there are three friends, that’s why they decided to choose the winner like that: If someone shows the gesture that wins over the other two players, then that player wins. Otherwise, another game round is required. Write a program that will determine the winner by the gestures they have shown.

Input

The first input line contains the name of the gesture that Uncle Fyodor showed, the second line shows which gesture Matroskin showed and the third line shows Sharic’s gesture.

Output

Print "F" (without quotes) if Uncle Fyodor wins. Print "M" if Matroskin wins and "S" if Sharic wins. If it is impossible to find the winner, print "?".

Examples

Input

rock
rock
rock

Output

?

Input

paper
rock
rock

Output

F

Input

scissors
rock
rock

Output

?

Input

scissors
paper
rock

Output

?

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string win(string s1, string s2);
int main() {
  string s[3] = {""};
  int array[3] = {0};
  for (int i = 0; i < 3; ++i) cin >> s[i];
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (win(s[i], s[j]) == s[i]) ++array[i];
    }
  }
  if (array[0] == 2)
    cout << "F" << endl;
  else if (array[1] == 2)
    cout << "M" << endl;
  else if (array[2] == 2)
    cout << "S" << endl;
  else
    cout << "?" << endl;
  return 0;
}
string win(string s1, string s2) {
  if (s1 == "rock" && s2 == "scissors")
    return s1;
  else if (s1 == "rock" && s2 == "paper")
    return s2;
  else if (s1 == "scissors" && s2 == "paper")
    return s1;
  else if (s1 == "scissors" && s2 == "rock")
    return s2;
  else if (s1 == "paper" && s2 == "rock")
    return s1;
  else if (s1 == "paper" && s2 == "scissors")
    return s2;
  else
    return "no";
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

A company has N members, who are assigned ID numbers 1, ..., N.

Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number.

When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X.

You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.

Constraints

* 2 \leq N \leq 2 \times 10^5
* 1 \leq A_i < i

Input

Input is given from Standard Input in the following format:

N
A_2 ... A_N

Output

For each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line.

Examples

Input

5
1 1 2 2

Output

2
2
0
0
0

Input

10
1 1 1 1 1 1 1 1 1

Output

9
0
0
0
0
0
0
0
0
0

Input

7
1 2 3 4 5 6

Output

1
1
1
1
1
1
0

### Response

```cpp
#include <iostream>

using namespace std;
int n,s,m,x,i,fr[200005];
int main()
{
    cin>>n;
   for(i=1;i<n;i++)
   {
       cin>>x;
      fr[x]++;
   }
    for(i=1;i<=n;i++)
        cout<<fr[i]<<'\n';
    return 0;
}

```


### Prompt

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

There are n students numerated from 1 to n. The level of the i-th student is a_i. You need to split the students into stable groups. A group of students is called stable, if in the sorted array of their levels no two neighboring elements differ by more than x.

For example, if x = 4, then the group with levels [1, 10, 8, 4, 4] is stable (because 4 - 1 ≤ x, 4 - 4 ≤ x, 8 - 4 ≤ x, 10 - 8 ≤ x), while the group with levels [2, 10, 10, 7] is not stable (7 - 2 = 5 > x).

Apart from the n given students, teachers can invite at most k additional students with arbitrary levels (at teachers' choice). Find the minimum number of stable groups teachers can form from all students (including the newly invited).

For example, if there are two students with levels 1 and 5; x = 2; and k ≥ 1, then you can invite a new student with level 3 and put all the students in one stable group.

Input

The first line contains three integers n, k, x (1 ≤ n ≤ 200 000, 0 ≤ k ≤ 10^{18}, 1 ≤ x ≤ 10^{18}) — the initial number of students, the number of students you can additionally invite, and the maximum allowed level difference.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{18}) — the students levels.

Output

In the only line print a single integer: the minimum number of stable groups you can split the students into.

Examples

Input

8 2 3
1 1 5 8 12 13 20 22

Output

2

Input

13 0 37
20 20 80 70 70 70 420 5 1 5 1 60 90

Output

3

Note

In the first example you can invite two students with levels 2 and 11. Then you can split the students into two stable groups:

  1. [1, 1, 2, 5, 8, 11, 12, 13],
  2. [20, 22].

In the second example you are not allowed to invite new students, so you need 3 groups:

  1. [1, 1, 5, 5, 20, 20]
  2. [60, 70, 70, 70, 80, 90]
  3. [420]

### Response

```cpp
#include<bits/stdc++.h>
#define ll long long int
#define scn(a) scanf("%d",&a)
#define scnl(a) scanf("%lld",&a)
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int main()
{
    int n;
    ll k,x;
    scn(n),scnl(k),scnl(x);
    ll a[n];
    for(int i=0;i<n;++i)
    scnl(a[i]);
    sort(a,a+n);
    vector<ll> v;
    for(int i=1;i<n;++i)
    if(a[i]-a[i-1]>x)
    v.pb(a[i]-a[i-1]);
    int l=v.size();
    if(l)
    {
        sort(v.begin(),v.end());
        int j=l;
        for(int i=0;i<j;++i,--l)
        {
            ll d=(v[i]+x-1)/x-1;
            if(k>=d)
            k-=d;
            else
            break;
        }
    }
    printf("%d",l+1);
    return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Calculate the minimum number of characters you need to change in the string s, so that it contains at least k different letters, or print that it is impossible.

String s consists only of lowercase Latin letters, and it is allowed to change characters only to lowercase Latin letters too.

Input

First line of input contains string s, consisting only of lowercase Latin letters (1 ≤ |s| ≤ 1000, |s| denotes the length of s).

Second line of input contains integer k (1 ≤ k ≤ 26).

Output

Print single line with a minimum number of necessary changes, or the word «impossible» (without quotes) if it is impossible.

Examples

Input

yandex
6

Output

0

Input

yahoo
5

Output

1

Input

google
7

Output

impossible

Note

In the first test case string contains 6 different letters, so we don't need to change anything.

In the second test case string contains 4 different letters: {'a', 'h', 'o', 'y'}. To get 5 different letters it is necessary to change one occurrence of 'o' to some letter, which doesn't occur in the string, for example, {'b'}.

In the third test case, it is impossible to make 7 different letters because the length of the string is 6.

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
long long int mod = 1000000007;
double PI = 3.14159265358979323846264338327950288;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long int arr[1000010] = {0};
int main() {
  long long int k, n, len;
  string s;
  cin >> s >> k;
  n = 0;
  len = (long long int)(s.size());
  for (long long int i = (0); i < (len); i++) {
    if (arr[s[i] - 'a'] == 0) n++;
    arr[s[i] - 'a']++;
  }
  if (len < k)
    printf("%s\n", "impossible");
  else {
    long long int ans = 0;
    if (n < k) {
      ans = k - n;
    }
    printf("%lld\n", ans);
  }
  return 0;
}

```