### Prompt

Please formulate a Cpp solution to the following problem:

Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome world, where everything is of the same color and only saturation differs. This pack can be represented as a sequence a1, a2, ..., an of n integer numbers — saturation of the color of each pencil. Now Mishka wants to put all the mess in the pack in order. He has an infinite number of empty boxes to do this. He would like to fill some boxes in such a way that:

  * Each pencil belongs to exactly one box;
  * Each non-empty box has at least k pencils in it;
  * If pencils i and j belong to the same box, then |ai - aj| ≤ d, where |x| means absolute value of x. Note that the opposite is optional, there can be pencils i and j such that |ai - aj| ≤ d and they belong to different boxes.

Help Mishka to determine if it's possible to distribute all the pencils into boxes. Print "YES" if there exists such a distribution. Otherwise print "NO".

Input

The first line contains three integer numbers n, k and d (1 ≤ k ≤ n ≤ 5·105, 0 ≤ d ≤ 109) — the number of pencils, minimal size of any non-empty box and maximal difference in saturation between any pair of pencils in the same box, respectively.

The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 109) — saturation of color of each pencil.

Output

Print "YES" if it's possible to distribute all the pencils into boxes and satisfy all the conditions. Otherwise print "NO".

Examples

Input

6 3 10
7 2 7 7 4 2

Output

YES

Input

6 2 3
4 5 3 13 4 10

Output

YES

Input

3 2 5
10 16 22

Output

NO

Note

In the first example it is possible to distribute pencils into 2 boxes with 3 pencils in each with any distribution. And you also can put all the pencils into the same box, difference of any pair in it won't exceed 10.

In the second example you can split pencils of saturations [4, 5, 3, 4] into 2 boxes of size 2 and put the remaining ones into another box.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = int(5e5) + 10;
const int K = int(2e6) + 10;
const int MOD = int(1e9) + 7;
const int INF = int(1e9) + 5;
const long long INF64 = 1e18;
int a[N], dp[N], l[N];
void solve() {
  int n, k, d;
  cin >> n >> k >> d;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  dp[0] = 1;
  for (int i = k; i <= n; i++) {
    int x = l[i - k];
    if (a[i] - a[x + 1] <= d) {
      dp[i] = 1;
    }
    if (dp[i])
      l[i] = i;
    else
      l[i] = l[i - 1];
  }
  if (dp[n])
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Snuke can change a string t of length N into a string t' of length N - 1 under the following rule:

* For each i (1 ≤ i ≤ N - 1), the i-th character of t' must be either the i-th or (i + 1)-th character of t.

There is a string s consisting of lowercase English letters. Snuke's objective is to apply the above operation to s repeatedly so that all the characters in s are the same. Find the minimum necessary number of operations.

Constraints

* 1 ≤ |s| ≤ 100
* s consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

s

Output

Print the minimum necessary number of operations to achieve the objective.

Examples

Input

serval

Output

3

Input

jackal

Output

2

Input

zzz

Output

0

Input

whbrjpjyhsrywlqjxdbrbaomnw

Output

8

### Response

```cpp
#include <iostream>

using namespace std;

const int kInf = 1e9;

void Solve() {
	string s;
	cin >> s;

	int ans = kInf;

	for (char c = 'a'; c <= 'z'; ++c) {
		int tans = 0;
		int last = s.length();

		for (int j = s.length() - 1; j >= 0; --j) {
			if (s[j] == c) {
				tans = max(tans, last - j - 1);
				last = j;
			}
		}
		tans = max(tans, last);
		ans = min(ans, tans);
	}

	cout << ans << "\n";
}

int main() {
	int tests = 1;
	for (;tests; --tests) {
		Solve();
	}
}
```


### Prompt

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

Takahashi and Aoki are playing a stone-taking game. Initially, there are N piles of stones, and the i-th pile contains A_i stones and has an associated integer K_i.

Starting from Takahashi, Takahashi and Aoki take alternate turns to perform the following operation:

* Choose a pile. If the i-th pile is selected and there are X stones left in the pile, remove some number of stones between 1 and floor(X/K_i) (inclusive) from the pile.

The player who first becomes unable to perform the operation loses the game. Assuming that both players play optimally, determine the winner of the game. Here, floor(x) represents the largest integer not greater than x.

Constraints

* 1 \leq N \leq 200
* 1 \leq A_i,K_i \leq 10^9
* All input values are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 K_1
:
A_N K_N

Output

If Takahashi will win, print `Takahashi`; if Aoki will win, print `Aoki`.

Examples

Input

2
5 2
3 3

Output

Aoki

Input

3
3 2
4 3
5 1

Output

Takahashi

Input

3
28 3
16 4
19 2

Output

Aoki

Input

4
3141 59
26535 897
93 23
8462 64

Output

Takahashi

### Response

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

int cal(int n,int k)
{
	while(n>=k&&n%k!=0) {
		int div = n/k+1;
		n -= ((n-1)%k/div+1)*div;
	}
	return n/k;
}
int n;
int main()
{
	scanf("%d",&n);
	int val = 0;
	for(int i = 0;i < n;++i) {
		int a,b;
		scanf("%d%d",&a,&b);
		val ^= cal(a,b);
	}
	if(val > 0) {
		printf("Takahashi\n");
	} else {
		printf("Aoki\n");
	}
}

```


### Prompt

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

A fraction whose numerator is 1 and whose denominator is a positive integer is called a unit fraction. A representation of a positive rational number p/q as the sum of finitely many unit fractions is called a partition of p/q into unit fractions. For example, 1/2 + 1/6 is a partition of 2/3 into unit fractions. The difference in the order of addition is disregarded. For example, we do not distinguish 1/6 + 1/2 from 1/2 + 1/6.

For given four positive integers p, q, a, and n, count the number of partitions of p/q into unit fractions satisfying the following two conditions.

* The partition is the sum of at most n many unit fractions.
* The product of the denominators of the unit fractions in the partition is less than or equal to a.

For example, if (p,q,a,n) = (2,3,120,3), you should report 4 since

2/3 = 1/3 + 1/3 = 1/2 + 1/6 = 1/4 + 1/4 + 1/6 = 1/3 + 1/6 + 1/6

enumerates all of the valid partitions.

Input

The input is a sequence of at most 1000 data sets followed by a terminator.

A data set is a line containing four positive integers p, q, a, and n satisfying p,q <= 800, a <= 12000 and n <= 7. The integers are separated by a space.

The terminator is composed of just one line which contains four zeros separated by a space. It is not a part of the input data but a mark for the end of the input.

Output

The output should be composed of lines each of which contains a single integer. No other characters should appear in the output.

The output integer corresponding to a data set p, q, a, n should be the number of all partitions of p/q into at most n many unit fractions such that the product of the denominators of the unit fractions is less than or equal to a.

Example

Input

2 3 120 3
2 3 300 3
2 3 299 3
2 3 12 3
2 3 12000 7
54 795 12000 7
2 3 300 1
2 1 200 5
2 4 54 2
0 0 0 0

Output

4
7
6
2
42
1
0
9
3

### Response

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

int n, p, q, a;

int dfs(int i, int last, int prod, int c, int d){
    int count = 0;
    if (c * q == d * p) {
        return 1;
    }
    if (i >= n) {
        return 0;
    }
    for (int j = last; j * prod <= a; j++) {
        if (q * (c * j + d) <= (p * j * d)){
            count += dfs(i+1, j, j*prod, c*j+d, d*j);
        }
    }
    return count;
}

int main()
{
    while (true) {
        cin >> p >> q >> a >> n;
        if (p == 0) {
            break;
        }
        cout << dfs(0, 1, 1, 0, 1) << endl;
    }

    return 0;
}
```


### Prompt

Construct a cpp code solution to the problem outlined:

problem

Given a sequence of n integers a1, a2, ..., an and a positive integer k (1 ≤ k ≤ n), then the sum of k consecutive integers Si = ai + ai + Create a program that outputs the maximum value of 1 + ... + ai + k-1 (1 ≤ i ≤ n --k + 1).

input

The input consists of multiple datasets. Each dataset is given in the following format. The input ends on a line containing two zeros.

On the first line, the positive integer n (1 ≤ n ≤ 100000) and the positive integer k (1 ≤ k ≤ n) are written in this order, separated by blanks. The first + i lines after the second line. (1 ≤ i ≤ n) contains the i-th term ai (-10000 ≤ ai ≤ 10000) in the sequence. Of the scoring data, 60% of the points are n ≤ 5000, k ≤ 1000. Meet.

The number of datasets does not exceed 5.

output

The maximum value of Si is output to one line for each data set.

Examples

Input

5 3
2
5
-4
10
3
0 0

Output

11

Input

None

Output

None

### Response

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

int main()
{
  int n, k;

  while (cin >> n >> k, n || k){
    int a[100010], num;

    for (int i = 0; i < n; i++){
      cin >> num;
      if (i == 0) a[i] = num;
      else a[i] = a[i - 1] + num;
    }

    int res = 0;
    for (int i = k; i < n; i++){
      res = max(res, a[i] - a[i - k]);
    }
    cout << res << '\n';
  }
}
```


### Prompt

Create a solution in cpp for the following problem:

The king of Berland organizes a ball! n pair are invited to the ball, they are numbered from 1 to n. Each pair consists of one man and one woman. Each dancer (either man or woman) has a monochrome costume. The color of each costume is represented by an integer from 1 to k, inclusive.

Let b_i be the color of the man's costume and g_i be the color of the woman's costume in the i-th pair. You have to choose a color for each dancer's costume (i.e. values b_1, b_2, ..., b_n and g_1, g_2, ... g_n) in such a way that:

  1. for every i: b_i and g_i are integers between 1 and k, inclusive;
  2. there are no two completely identical pairs, i.e. no two indices i, j (i ≠ j) such that b_i = b_j and g_i = g_j at the same time;
  3. there is no pair such that the color of the man's costume is the same as the color of the woman's costume in this pair, i.e. b_i ≠ g_i for every i;
  4. for each two consecutive (adjacent) pairs both man's costume colors and woman's costume colors differ, i.e. for every i from 1 to n-1 the conditions b_i ≠ b_{i + 1} and g_i ≠ g_{i + 1} hold.

Let's take a look at the examples of bad and good color choosing (for n=4 and k=3, man is the first in a pair and woman is the second):

Bad color choosing:

  * (1, 2), (2, 3), (3, 2), (1, 2) — contradiction with the second rule (there are equal pairs);
  * (2, 3), (1, 1), (3, 2), (1, 3) — contradiction with the third rule (there is a pair with costumes of the same color);
  * (1, 2), (2, 3), (1, 3), (2, 1) — contradiction with the fourth rule (there are two consecutive pairs such that colors of costumes of men/women are the same).

Good color choosing:

  * (1, 2), (2, 1), (1, 3), (3, 1);
  * (1, 2), (3, 1), (2, 3), (3, 2);
  * (3, 1), (1, 2), (2, 3), (3, 2).

You have to find any suitable color choosing or say that no suitable choosing exists.

Input

The only line of the input contains two integers n and k (2 ≤ n, k ≤ 2 ⋅ 10^5) — the number of pairs and the number of colors.

Output

If it is impossible to find any suitable colors choosing, print "NO".

Otherwise print "YES" and then the colors of the costumes of pairs in the next n lines. The i-th line should contain two integers b_i and g_i — colors of costumes of man and woman in the i-th pair, respectively.

You can print each letter in any case (upper or lower). For example, "YeS", "no" and "yES" are all acceptable.

Examples

Input

4 3

Output

YES
3 1
1 3
3 2
2 3

Input

10 4

Output

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

Input

13 4

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int prime_table[] = {1009L,     10007L,     100003L,    1000003L,
                               10000019L, 100000007L, 1000000007L};
const long long int maxn_1 = 3.1e1;
const long long int maxn_2 = 3.1e2;
const long long int maxn_3 = 3.1e3;
const long long int maxn_4 = 3.1e4;
const long long int maxn_5 = 3.1e5;
const long long int maxn_6 = 3.1e6;
signed main() {
  {
    ios::sync_with_stdio(0);
    cin.tie(0);
  };
  long long int n, k;
  cin >> n >> k;
  long long int shang, remain;
  shang = n / k;
  remain = n % k;
  if (remain != 0) {
    shang++;
  }
  if (shang >= k) {
    (cout << "NO" << endl);
  } else {
    (cout << "YES" << endl);
    vector<pair<long long int, long long int> > re;
    re.resize(n + 1);
    re[0].first = re[0].second = -1;
    for (long long int i = 0; i < n; i += 1) {
      re[i + 1].first = (i % k) + 1;
    }
    long long int start = 1;
    long long int pos = 1;
    for (long long int i = 0; i < shang; i += 1) {
      for (long long int j = 0; j < k; j += 1) {
        re[pos].second = (start + j) % k + 1;
        pos++;
        if (pos > n) {
          break;
        }
      }
      if (pos > n) {
        break;
      }
      start++;
    }
    for (long long int i = 1; i < n + 1; i += 1) {
      cout << re[i].first << " " << re[i].second << endl;
    }
  }
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Write a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function.

Merge(A, left, mid, right)
n1 = mid - left;
n2 = right - mid;
create array L[0...n1], R[0...n2]
for i = 0 to n1-1
do L[i] = A[left + i]
for i = 0 to n2-1
do R[i] = A[mid + i]
L[n1] = SENTINEL
R[n2] = SENTINEL
i = 0;
j = 0;
for k = left to right-1
if L[i] <= R[j]
then A[k] = L[i]
i = i + 1
else A[k] = R[j]
j = j + 1

Merge-Sort(A, left, right){
if left+1 < right
then mid = (left + right)/2;
call Merge-Sort(A, left, mid)
call Merge-Sort(A, mid, right)
call Merge(A, left, mid, right)

Notes

Constraints

* n ≤ 500000
* 0 ≤ an element in S ≤ 109

Input

In the first line n is given. In the second line, n integers are given.

Output

In the first line, print the sequence S. Two consequtive elements should be separated by a space character.

In the second line, print the number of comparisons.

Example

Input

10
8 5 9 2 6 3 7 1 10 4

Output

1 2 3 4 5 6 7 8 9 10
34

### Response

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

using namespace std;

const int maxn=1e6;
int a[maxn];
int b[maxn];
int cnt;

void merge(int l,int mid,int r)
{
	int p1=l,p2=mid+1;//双指针
	int pos=l;//当前位置
	while(p1<=mid&&p2<=r){
		cnt++;
		if(a[p1]<a[p2]){
			b[pos++]=a[p1++];
		}else{
			b[pos++]=a[p2++];
		}
	}
	while(p1<=mid){
		cnt++;
		b[pos++]=a[p1++];
	}
	while(p2<=r){
		cnt++;
		b[pos++]=a[p2++];
	}
	for(int i=l;i<=r;i++)a[i]=b[i];
}

void merge_sort(int l,int r)
{
	if(l<r){
		int mid=(l+r)/2;
		merge_sort(l,mid);
		merge_sort(mid+1,r);
		merge(l,mid,r);
	}
}

int main()
{
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	int n;
	cin>>n;
	cnt=0;
	for(int i=1;i<=n;i++)cin>>a[i];
	merge_sort(1,n);
	for(int i=1;i<=n;i++){
		if(i>1)cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
	cout<<cnt<<endl;
	return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Homer has two friends Alice and Bob. Both of them are string fans.

One day, Alice and Bob decide to play a game on a string s = s_1 s_2 ... s_n of length n consisting of lowercase English letters. They move in turns alternatively and Alice makes the first move.

In a move, a player must choose an index i (1 ≤ i ≤ n) that has not been chosen before, and change s_i to any other lowercase English letter c that c ≠ s_i.

When all indices have been chosen, the game ends.

The goal of Alice is to make the final string lexicographically as small as possible, while the goal of Bob is to make the final string lexicographically as large as possible. Both of them are game experts, so they always play games optimally. Homer is not a game expert, so he wonders what the final string will be.

A string a is lexicographically smaller than a string b if and only if one of the following holds:

  * a is a prefix of b, but a ≠ b;
  * in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b.

Input

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

The only line of each test case contains a single string s (1 ≤ |s| ≤ 50) consisting of lowercase English letters.

Output

For each test case, print the final string in a single line.

Example

Input

3
a
bbbb
az

Output

b
azaz
by

Note

In the first test case: Alice makes the first move and must change the only letter to a different one, so she changes it to 'b'.

In the second test case: Alice changes the first letter to 'a', then Bob changes the second letter to 'z', Alice changes the third letter to 'a' and then Bob changes the fourth letter to 'z'.

In the third test case: Alice changes the first letter to 'b', and then Bob changes the second letter to 'y'.

### Response

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

char alice(char c){
    if(c=='a')  return 'b';
    return 'a';
}
char bob(char c){
    if(c=='z')  return 'y';
    return 'z';
}

int main()
{
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        unordered_map<char, vector<int>> m;
        vector<char> v;
        bool turn=1;
        for(int i =0;i<s.size();i++){
            char c=s[i];
            if(turn){
                s[i]=alice(c);
            }
            else{
                s[i]=bob(c);
            }
            turn=!turn;
        }
        cout<<s<<"\n";
    }
    return 0;
}
```


### Prompt

Please formulate a Cpp solution to the following problem:

In this task you have to write a program dealing with nonograms on fields no larger than 5 × 20.

Simplified nonogram is a task where you have to build such field (each cell is either white or black) that satisfies the given information about rows and columns. For each row and each column the number of contiguous black segments is specified.

For example if size of the field is n = 3, m = 5, аnd numbers of contiguous black segments in rows are: [2, 3, 2] and in columns are: [1, 0, 1, 2, 1] then the solution may look like:

<image>

It is guaranteed that on each test in the testset there exists at least one solution.

Input

In the first line there follow two integers n, m (1 ≤ n ≤ 5, 1 ≤ m ≤ 20) — number of rows and number of columns respectively.

Second line contains n integers a1, a2, ..., an where ai is the number of contiguous black segments in i-th row of the field.

Similarly, third line contains m integers b1, b2, ..., bm where bi is the number of contiguous black segments in the i-th column of the field.

It is guaranteed that there exists at least one solution.

Output

Output any possible solution. Output should consist of n lines each containing m characters. Denote white cell as "." and black cell as "*".

Examples

Input

3 5
2 3 2
1 0 1 2 1

Output

*.**.
*.*.*
*..**

Input

3 3
2 1 2
2 1 2

Output

*.*
.*.
*.*

Input

3 3
1 0 1
2 2 2

Output

***
...
***

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool vis[20][32][11][11][11][11][11];
bool dp[20][32][11][11][11][11][11];
int r[25], c[25], R, C;
bool dp_func(int row, int prv, int col1, int col2, int col3, int col4,
             int col5);
inline bool check(int mask, int pos) { return (bool)(mask & (1 << pos)); }
int ou[25];
bool rec(int row, int prv, int col1, int col2, int col3, int col4, int col5,
         int pos, int ager, int seg) {
  if (seg > r[row]) return 0;
  if (pos == C) {
    if (seg == r[row])
      return dp_func(row + 1, prv, col1, col2, col3, col4, col5);
    return 0;
  }
  int tmp[] = {col1, col2, col3, col4, col5};
  int ret = 0;
  if (check(prv, pos)) {
    ret |= rec(row, prv, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], pos + 1, 1,
               seg + (ager == 0));
    if (ret) return 1;
    ret |= rec(row, prv ^ (1 << pos), tmp[0], tmp[1], tmp[2], tmp[3], tmp[4],
               pos + 1, 0, seg);
    return ret;
  }
  ret |= rec(row, prv, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], pos + 1, 0, seg);
  if (ret) return 1;
  if (c[pos] == tmp[pos]) return 0;
  tmp[pos]++;
  ret |= rec(row, prv | (1 << pos), tmp[0], tmp[1], tmp[2], tmp[3], tmp[4],
             pos + 1, 1, seg + (ager == 0));
  return ret;
}
bool dp_func(int row, int prv, int col1, int col2, int col3, int col4,
             int col5) {
  if (row == R) {
    if (col1 == c[0] && col2 == c[1] && col3 == c[2] && col4 == c[3] &&
        col5 == c[4])
      return 1;
    return 0;
  }
  if (vis[row][prv][col1][col2][col3][col4][col5])
    return dp[row][prv][col1][col2][col3][col4][col5];
  vis[row][prv][col1][col2][col3][col4][col5] = 1;
  bool d = rec(row, prv, col1, col2, col3, col4, col5, 0, 0, 0);
  return dp[row][prv][col1][col2][col3][col4][col5] = d;
}
void path(int row, int prv, int col1, int col2, int col3, int col4, int col5,
          int pos, int ager, int seg) {
  if (seg > r[row]) assert(0);
  if (row == R) return;
  if (pos == C) {
    if (seg == r[row] && dp_func(row + 1, prv, col1, col2, col3, col4, col5)) {
      path(row + 1, prv, col1, col2, col3, col4, col5, 0, 0, 0);
      ou[row] |= prv;
      return;
    }
    assert(0);
  }
  int tmp[] = {col1, col2, col3, col4, col5};
  int ret = 0;
  if ((bool)(prv & (1 << pos))) {
    ret |= rec(row, prv, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], pos + 1, 1,
               seg + (ager == 0));
    if (ret == 1) {
      path(row, prv, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], pos + 1, 1,
           seg + (ager == 0));
      return;
    }
    path(row, prv ^ (1 << pos), tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], pos + 1,
         0, seg);
    return;
  }
  ret |= rec(row, prv, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], pos + 1, 0, seg);
  if (ret) {
    path(row, prv, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], pos + 1, 0, seg);
    return;
  }
  tmp[pos]++;
  path(row, prv | (1 << pos), tmp[0], tmp[1], tmp[2], tmp[3], tmp[4], pos + 1,
       1, seg + (ager == 0));
}
int main() {
  int i, j, k, l, m, n;
  scanf("%d%d", &R, &C);
  swap(R, C);
  for (int i = 0; i < C; i++) scanf("%d", &c[i]);
  for (int i = 0; i < R; i++) scanf("%d", &r[i]);
  int d = dp_func(0, 0, 0, 0, 0, 0, 0);
  path(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  for (int i = 0; i < C; i++) {
    for (int j = 0; j < R; j++) {
      if (check(ou[j], i))
        printf("*");
      else
        printf(".");
    }
    printf("\n");
  }
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

This is an interactive problem.

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

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

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

Input

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

You are allowed to ask no more than 60 questions.

Output

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

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

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

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

Hacking

Use the following format for hacking:

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

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

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

Examples

Input

8

2

2

Output

? 4

? 8

! 4

Input

6

1

2

3

2

1

0

Output

? 1

? 2

? 3

? 4

? 5

? 6

! -1

Note

Input-output in statements illustrates example interaction.

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

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  if (n % 4 != 0) {
    cout << "! -1\n";
    return 0;
  }
  int l = 1, r = 1 + n / 2, x, y, cur;
  cout << "? " << 1 << endl;
  cin >> x;
  cout << "? " << 1 + n / 2 << endl;
  cin >> y;
  if (x == y) {
    cout << "! " << 1 << endl;
    return 0;
  }
  bool f = (x < y);
  while (1) {
    cur = (l + r) / 2;
    cout << "? " << cur << endl;
    cin >> x;
    cout << "? " << cur + n / 2 << endl;
    cin >> y;
    if (x == y) {
      cout << "! " << cur << endl;
      return 0;
    }
    if ((x < y) == f)
      l = cur;
    else
      r = cur;
  }
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

There is a bookshelf which can fit n books. The i-th position of bookshelf is a_i = 1 if there is a book on this position and a_i = 0 otherwise. It is guaranteed that there is at least one book on the bookshelf.

In one move, you can choose some contiguous segment [l; r] consisting of books (i.e. for each i from l to r the condition a_i = 1 holds) and:

  * Shift it to the right by 1: move the book at index i to i + 1 for all l ≤ i ≤ r. This move can be done only if r+1 ≤ n and there is no book at the position r+1.
  * Shift it to the left by 1: move the book at index i to i-1 for all l ≤ i ≤ r. This move can be done only if l-1 ≥ 1 and there is no book at the position l-1.

Your task is to find the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without any gaps).

For example, for a = [0, 0, 1, 0, 1] there is a gap between books (a_4 = 0 when a_3 = 1 and a_5 = 1), for a = [1, 1, 0] there are no gaps between books and for a = [0, 0,0] there are also no gaps between books.

You have to answer t independent test cases.

Input

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

The first line of the test case contains one integer n (1 ≤ n ≤ 50) — the number of places on a bookshelf. The second line of the test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 1), where a_i is 1 if there is a book at this position and 0 otherwise. It is guaranteed that there is at least one book on the bookshelf.

Output

For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).

Example

Input

5
7
0 0 1 0 1 0 1
3
1 0 0
5
1 1 0 0 1
6
1 0 0 0 0 1
5
1 1 0 1 1

Output

2
0
2
4
1

Note

In the first test case of the example, you can shift the segment [3; 3] to the right and the segment [4; 5] to the right. After all moves, the books form the contiguous segment [5; 7]. So the answer is 2.

In the second test case of the example, you have nothing to do, all the books on the bookshelf form the contiguous segment already.

In the third test case of the example, you can shift the segment [5; 5] to the left and then the segment [4; 4] to the left again. After all moves, the books form the contiguous segment [1; 3]. So the answer is 2.

In the fourth test case of the example, you can shift the segment [1; 1] to the right, the segment [2; 2] to the right, the segment [6; 6] to the left and then the segment [5; 5] to the left. After all moves, the books form the contiguous segment [3; 4]. So the answer is 4.

In the fifth test case of the example, you can shift the segment [1; 2] to the right. After all moves, the books form the contiguous segment [2; 5]. So the answer is 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int T, a[55], n;
int main() {
  scanf("%d", &T);
  while (T--) {
    memset(a, 0, sizeof a);
    scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &a[i]);
    }
    int first, last;
    for (int i = 1; i <= n; ++i)
      if (a[i] == 1) {
        first = i;
        break;
      }
    for (int i = n; i >= 1; --i)
      if (a[i] == 1) {
        last = i;
        break;
      }
    for (int i = first; i <= last; ++i) {
      if (a[i] == 0) ans++;
    }
    printf("%d\n", ans);
  }
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.

Constraints

* 1\leq N,K\leq 100
* N and K are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

If we can choose K integers as above, print `YES`; otherwise, print `NO`.

Examples

Input

3 2

Output

YES

Input

5 5

Output

NO

Input

31 10

Output

YES

Input

10 90

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
int n, k;
int main()
{
std::cin >> n >> k;
std::cout << ((n + 1) / 2 >= k ? "YES" : "NO");
}
```


### Prompt

Please create a solution in CPP to the following problem:

problem

Given a sequence of n integers a1, a2, ..., an and a positive integer k (1 ≤ k ≤ n), then the sum of k consecutive integers Si = ai + ai + Create a program that outputs the maximum value of 1 + ... + ai + k-1 (1 ≤ i ≤ n --k + 1).

input

The input consists of multiple datasets. Each dataset is given in the following format. The input ends on a line containing two zeros.

On the first line, the positive integer n (1 ≤ n ≤ 100000) and the positive integer k (1 ≤ k ≤ n) are written in this order, separated by blanks. The first + i lines after the second line. (1 ≤ i ≤ n) contains the i-th term ai (-10000 ≤ ai ≤ 10000) in the sequence. Of the scoring data, 60% of the points are n ≤ 5000, k ≤ 1000. Meet.

The number of datasets does not exceed 5.

output

The maximum value of Si is output to one line for each data set.

Examples

Input

5 3
2
5
-4
10
3
0 0

Output

11

Input

None

Output

None

### Response

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

int main(){
while(1){
	int a[100000+2],n,k,ans=0,sum=0;
	scanf("%d%d",&n,&k);
if(n==0&&k==0)break;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<k;i++){
		sum+=a[i];
	}
	ans=sum;
	for(int i=k;i<n;i++){
		sum+=a[i]-a[i-k];
		if(ans<sum)ans=sum;
	}
	printf("%d\n",ans);
}
}
```


### Prompt

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

Edo has got a collection of n refrigerator magnets!

He decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door must be rectangle, and both the length and the width of the door must be positive integers.

Edo figured out how he wants to place the magnets on the refrigerator. He introduced a system of coordinates on the plane, where each magnet is represented as a rectangle with sides parallel to the coordinate axes.

Now he wants to remove no more than k magnets (he may choose to keep all of them) and attach all remaining magnets to the refrigerator door, and the area of the door should be as small as possible. A magnet is considered to be attached to the refrigerator door if its center lies on the door or on its boundary. The relative positions of all the remaining magnets must correspond to the plan.

Let us explain the last two sentences. Let's suppose we want to hang two magnets on the refrigerator. If the magnet in the plan has coordinates of the lower left corner (x1, y1) and the upper right corner (x2, y2), then its center is located at (<image>, <image>) (may not be integers). By saying the relative position should correspond to the plan we mean that the only available operation is translation, i.e. the vector connecting the centers of two magnets in the original plan, must be equal to the vector connecting the centers of these two magnets on the refrigerator.

The sides of the refrigerator door must also be parallel to coordinate axes.

Input

The first line contains two integers n and k (1 ≤ n ≤ 100 000, 0 ≤ k ≤ min(10, n - 1)) — the number of magnets that Edo has and the maximum number of magnets Edo may not place on the refrigerator.

Next n lines describe the initial plan of placing magnets. Each line contains four integers x1, y1, x2, y2 (1 ≤ x1 < x2 ≤ 109, 1 ≤ y1 < y2 ≤ 109) — the coordinates of the lower left and upper right corners of the current magnet. The magnets can partially overlap or even fully coincide.

Output

Print a single integer — the minimum area of the door of refrigerator, which can be used to place at least n - k magnets, preserving the relative positions.

Examples

Input

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

Output

1

Input

4 1
1 1 2 2
1 9 2 10
9 9 10 10
9 1 10 2

Output

64

Input

3 0
1 1 2 2
1 1 1000000000 1000000000
1 3 8 12

Output

249999999000000001

Note

In the first test sample it is optimal to remove either the first or the third magnet. If we remove the first magnet, the centers of two others will lie at points (2.5, 2.5) and (3.5, 3.5). Thus, it is enough to buy a fridge with door width 1 and door height 1, the area of the door also equals one, correspondingly.

In the second test sample it doesn't matter which magnet to remove, the answer will not change — we need a fridge with door width 8 and door height 8.

In the third sample you cannot remove anything as k = 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int maxm = maxn * 4 + 10;
const int inf = 1e9;
const long long mod = 1e9 + 7;
int getint() {
  char c;
  while ((c = getchar()) && !(c >= '0' && c <= '9') && c != '-')
    ;
  int ret = c - '0', sgn = 0;
  if (c == '-') sgn = 1, ret = 0;
  while ((c = getchar()) && c >= '0' && c <= '9') ret = ret * 10 + c - '0';
  if (sgn) ret = -ret;
  return ret;
}
multiset<pair<long long, long long> > st1, st2;
multiset<pair<long long, long long> >::iterator it;
vector<pair<long long, long long> > g;
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    int i;
    st1.clear();
    st2.clear();
    for (i = 1; i <= n; i++) {
      long long x1, y1, x2, y2;
      scanf("%I64d%I64d%I64d%I64d", &x1, &y1, &x2, &y2);
      x1 *= 2, y1 *= 2, x2 *= 2, y2 *= 2;
      st1.insert(make_pair((x1 + x2) / 2, (y1 + y2) / 2));
      st2.insert(make_pair((y1 + y2) / 2, (x1 + x2) / 2));
    }
    long long ans = 1e18 + 10;
    for (int i = 0; i <= m; i++) {
      for (int j = 0; j <= m; j++) {
        for (int k = 0; k <= m; k++) {
          for (int l = 0; l <= m; l++) {
            if (i + j + k + l > m) continue;
            g.clear();
            int cnt = 0;
            while (cnt < i && (st1.size())) {
              it = st1.begin();
              int xx = (*it).first, yy = (*it).second;
              g.push_back(make_pair(xx, yy));
              st1.erase(it);
              it = st2.find(make_pair(yy, xx));
              st2.erase(it);
              cnt++;
            }
            cnt = 0;
            while (cnt < j && (st1.size())) {
              it = st1.end();
              it--;
              int xx = (*it).first, yy = (*it).second;
              g.push_back(make_pair(xx, yy));
              st1.erase(it);
              it = st2.find(make_pair(yy, xx));
              st2.erase(it);
              cnt++;
            }
            cnt = 0;
            while (cnt < k && (st2.size())) {
              it = st2.begin();
              int xx = (*it).first, yy = (*it).second;
              g.push_back(make_pair(yy, xx));
              st2.erase(it);
              it = st1.find(make_pair(yy, xx));
              st1.erase(it);
              cnt++;
            }
            cnt = 0;
            while (cnt < l && (st2.size())) {
              it = st2.end();
              it--;
              int xx = (*it).first, yy = (*it).second;
              g.push_back(make_pair(yy, xx));
              st2.erase(it);
              it = st1.find(make_pair(yy, xx));
              st1.erase(it);
              cnt++;
            }
            long long x, y, t1, t2;
            if (st1.size() == 0) {
              ans = 0;
              continue;
            }
            it = st1.begin();
            x = (*it).first;
            it = st1.end();
            it--;
            y = (*it).first;
            t1 = (y - x) / 2;
            t1 = max(t1, (long long)1);
            it = st2.begin();
            x = (*it).first;
            it = st2.end();
            it--;
            y = (*it).first;
            t2 = (y - x) / 2;
            t2 = max(t2, (long long)1);
            ans = min(ans, t1 * t2);
            int len = g.size();
            for (int c = 0; c < len; c++) {
              st1.insert(g[c]);
              st2.insert(make_pair(g[c].second, g[c].first));
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President of Berland, G.W. Boosch, to be signed.

This time mr. Boosch plans to sign 2k laws. He decided to choose exactly two non-intersecting segments of integers from 1 to n of length k and sign all laws, whose numbers fall into these segments. More formally, mr. Boosch is going to choose two integers a, b (1 ≤ a ≤ b ≤ n - k + 1, b - a ≥ k) and sign all laws with numbers lying in the segments [a; a + k - 1] and [b; b + k - 1] (borders are included).

As mr. Boosch chooses the laws to sign, he of course considers the public opinion. Allberland Public Opinion Study Centre (APOSC) conducted opinion polls among the citizens, processed the results into a report and gave it to the president. The report contains the absurdity value for each law, in the public opinion. As mr. Boosch is a real patriot, he is keen on signing the laws with the maximum total absurdity. Help him.

Input

The first line contains two integers n and k (2 ≤ n ≤ 2·105, 0 < 2k ≤ n) — the number of laws accepted by the parliament and the length of one segment in the law list, correspondingly. The next line contains n integers x1, x2, ..., xn — the absurdity of each law (1 ≤ xi ≤ 109).

Output

Print two integers a, b — the beginning of segments that mr. Boosch should choose. That means that the president signs laws with numbers from segments [a; a + k - 1] and [b; b + k - 1]. If there are multiple solutions, print the one with the minimum number a. If there still are multiple solutions, print the one with the minimum b.

Examples

Input

5 2
3 6 1 1 6

Output

1 4

Input

6 2
1 1 1 1 1 1

Output

1 3

Note

In the first sample mr. Boosch signs laws with numbers from segments [1;2] and [4;5]. The total absurdity of the signed laws equals 3 + 6 + 1 + 6 = 16.

In the second sample mr. Boosch signs laws with numbers from segments [1;2] and [3;4]. The total absurdity of the signed laws equals 1 + 1 + 1 + 1 = 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)(1e18);
const int maxn = 200010;
struct node {
  long long sum;
  int id;
  node(long long s = 0, int i = -1) {
    sum = s;
    id = i;
  }
  bool operator>(const node& b) const {
    if (sum == b.sum) return id < b.id;
    return sum > b.sum;
  }
  bool operator<(const node& b) const {
    if (sum == b.sum) return id > b.id;
    return sum < b.sum;
  }
} t[maxn << 2];
long long a[maxn], b[maxn];
int n, k;
void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = node(a[tl], tl);
  } else {
    int tm = (tl + tr) >> 1;
    int next = v << 1;
    build(next, tl, tm);
    build(next + 1, tm + 1, tr);
    t[v] = max(t[next], t[next + 1]);
  }
}
node query(int v, int tl, int tr, int l, int r) {
  if (l > tr || r < tl) return node(-INF, int(1e9));
  if (l <= tl && tr <= r) return t[v];
  int tm = (tl + tr) >> 1;
  int next = v << 1;
  node left_max = query(next, tl, tm, l, r);
  node right_max = query(next + 1, tm + 1, tr, l, r);
  return max(left_max, right_max);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (i > 0) b[i] += b[i - 1];
    a[i] = -INF;
  }
  for (int i = 0; i + k - 1 < n; i++) {
    a[i] = b[i + k - 1];
    if (i > 0) a[i] -= b[i - 1];
  }
  build(1, 0, n);
  int aa, bb;
  long long best = -INF;
  for (int i = 0; i + k + k - 1 < n; i++) {
    node m = query(1, 0, n, i + k, n);
    long long curr = a[i] + m.sum;
    if (curr > best) {
      aa = i + 1;
      bb = m.id + 1;
      best = curr;
    }
  }
  cout << aa << " " << bb << endl;
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Imagine that you are in a building that has exactly n floors. You can move between the floors in a lift. Let's number the floors from bottom to top with integers from 1 to n. Now you're on the floor number a. You are very bored, so you want to take the lift. Floor number b has a secret lab, the entry is forbidden. However, you already are in the mood and decide to make k consecutive trips in the lift.

Let us suppose that at the moment you are on the floor number x (initially, you were on floor a). For another trip between floors you choose some floor with number y (y ≠ x) and the lift travels to this floor. As you cannot visit floor b with the secret lab, you decided that the distance from the current floor x to the chosen y must be strictly less than the distance from the current floor x to floor b with the secret lab. Formally, it means that the following inequation must fulfill: |x - y| < |x - b|. After the lift successfully transports you to floor y, you write down number y in your notepad.

Your task is to find the number of distinct number sequences that you could have written in the notebook as the result of k trips in the lift. As the sought number of trips can be rather large, find the remainder after dividing the number by 1000000007 (109 + 7).

Input

The first line of the input contains four space-separated integers n, a, b, k (2 ≤ n ≤ 5000, 1 ≤ k ≤ 5000, 1 ≤ a, b ≤ n, a ≠ b).

Output

Print a single integer — the remainder after dividing the sought number of sequences by 1000000007 (109 + 7).

Examples

Input

5 2 4 1

Output

2

Input

5 2 4 2

Output

2

Input

5 3 4 1

Output

0

Note

Two sequences p1, p2, ..., pk and q1, q2, ..., qk are distinct, if there is such integer j (1 ≤ j ≤ k), that pj ≠ qj.

Notes to the samples:

  1. In the first sample after the first trip you are either on floor 1, or on floor 3, because |1 - 2| < |2 - 4| and |3 - 2| < |2 - 4|.
  2. In the second sample there are two possible sequences: (1, 2); (1, 3). You cannot choose floor 3 for the first trip because in this case no floor can be the floor for the second trip.
  3. In the third sample there are no sought sequences, because you cannot choose the floor for the first trip.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long maxn = 5005;
const long long inf = 1ll << 50;
long long dp[maxn][maxn];
long long psum[maxn];
inline long long get_sum(long long a, long long b) {
  return (psum[b] - psum[a - 1] + mod) % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, a, b, k;
  cin >> n >> a >> b >> k;
  dp[0][a] = 1;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      psum[j] = psum[j - 1] + dp[i - 1][j];
      psum[j] %= mod;
    }
    for (int j = 1; j < b; j++) {
      dp[i][j] = get_sum(1, (b + j - 1) >> 1) - dp[i - 1][j] + mod;
      dp[i][j] %= mod;
    }
    for (int j = b + 1; j <= n; j++) {
      dp[i][j] = get_sum(((b + j) >> 1) + 1, n) - dp[i - 1][j] + mod;
      dp[i][j] %= mod;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += dp[k][i];
    ans %= mod;
  }
  cout << ans << "\n";
  return 0;
}

```


### Prompt

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

You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.

Let's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a.

You can apply the following operations any number of times:

  * Choose some substring of string a (for example, you can choose entire string) and reverse it, paying x coins for it (for example, «0101101» → «0111001»);
  * Choose some substring of string a (for example, you can choose entire string or just one symbol) and replace each symbol to the opposite one (zeros are replaced by ones, and ones — by zeros), paying y coins for it (for example, «0101101» → «0110001»).

You can apply these operations in any order. It is allowed to apply the operations multiple times to the same substring.

What is the minimum number of coins you need to spend to get a string consisting only of ones?

Input

The first line of input contains integers n, x and y (1 ≤ n ≤ 300 000, 0 ≤ x, y ≤ 10^9) — length of the string, cost of the first operation (substring reverse) and cost of the second operation (inverting all elements of substring).

The second line contains the string a of length n, consisting of zeros and ones.

Output

Print a single integer — the minimum total cost of operations you need to spend to get a string consisting only of ones. Print 0, if you do not need to perform any operations.

Examples

Input

5 1 10
01000

Output

11

Input

5 10 1
01000

Output

2

Input

7 2 3
1111111

Output

0

Note

In the first sample, at first you need to reverse substring [1 ... 2], and then you need to invert substring [2 ... 5].

Then the string was changed as follows:

«01000» → «10000» → «11111».

The total cost of operations is 1 + 10 = 11.

In the second sample, at first you need to invert substring [1 ... 1], and then you need to invert substring [3 ... 5].

Then the string was changed as follows:

«01000» → «11000» → «11111».

The overall cost is 1 + 1 = 2.

In the third example, string already consists only of ones, so the answer is 0.

### Response

```cpp
#include <bits/stdc++.h>
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 998244353LL;
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long n, x, y;
  cin >> n >> x >> y;
  string s;
  cin >> s;
  s.erase(unique(s.begin(), s.end()), s.end());
  n = s.size();
  int cnt = 0;
  for (int i = 0; i < s.size(); i++) cnt += (s[i] == '0');
  long long res = cnt * y;
  for (int i = 1; i < cnt; i++) {
    chmin(res, i * x + (cnt - i) * y);
  }
  cout << res << endl;
}

```


### Prompt

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

There are well-known formulas: <image>, <image>, <image>. Also mathematicians found similar formulas for higher degrees.

Find the value of the sum <image> modulo 109 + 7 (so you should find the remainder after dividing the answer by the value 109 + 7).

Input

The only line contains two integers n, k (1 ≤ n ≤ 109, 0 ≤ k ≤ 106).

Output

Print the only integer a — the remainder after dividing the value of the sum by the value 109 + 7.

Examples

Input

4 1

Output

10

Input

4 2

Output

30

Input

4 3

Output

100

Input

4 0

Output

4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
int pre[N], suf[N], inv[N];
inline int power(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) res = 1ll * res * a % mod;
  return res;
}
int main() {
  int n, m, s = 0, ans = 0;
  scanf("%d%d", &n, &m);
  if (m == 0) {
    printf("%d\n", n);
    return 0;
  }
  inv[1] = 1;
  for (int i = 2; i <= m + 1; i++)
    inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
  inv[0] = 1;
  for (int i = 1; i <= m + 1; i++) inv[i] = 1ll * inv[i] * inv[i - 1] % mod;
  pre[0] = n;
  for (int i = 1; i <= m + 1; i++) pre[i] = 1ll * pre[i - 1] * (n - i) % mod;
  suf[m + 1] = n - (m + 1);
  for (int i = m; i >= 0; i--) suf[i] = 1ll * suf[i + 1] * (n - i) % mod;
  for (int i = 0; i <= m + 1; i++) {
    s = (s + power(i, m)) % mod;
    int delta =
        1ll * (i == 0 ? 1 : pre[i - 1]) * (i == m + 1 ? 1 : suf[i + 1]) % mod;
    delta = 1ll * delta * inv[i] % mod * inv[m + 1 - i] % mod;
    if ((m + 1 - i) & 1) delta = mod - delta;
    ans = (ans + 1ll * s * delta % mod) % mod;
  }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time n snacks of distinct sizes will fall on the city, and the residents should build a Snacktower of them by placing snacks one on another. Of course, big snacks should be at the bottom of the tower, while small snacks should be at the top.

Years passed, and once different snacks started to fall onto the city, and the residents began to build the Snacktower.

<image>

However, they faced some troubles. Each day exactly one snack fell onto the city, but their order was strange. So, at some days the residents weren't able to put the new stack on the top of the Snacktower: they had to wait until all the bigger snacks fell. Of course, in order to not to anger miss Fortune again, the residents placed each snack on the top of the tower immediately as they could do it.

Write a program that models the behavior of Ankh-Morpork residents.

Input

The first line contains single integer n (1 ≤ n ≤ 100 000) — the total number of snacks.

The second line contains n integers, the i-th of them equals the size of the snack which fell on the i-th day. Sizes are distinct integers from 1 to n.

Output

Print n lines. On the i-th of them print the sizes of the snacks which the residents placed on the top of the Snacktower on the i-th day in the order they will do that. If no snack is placed on some day, leave the corresponding line empty.

Examples

Input

3
3 1 2

Output

3

2 1

Input

5
4 5 1 2 3

Output

5 4

3 2 1

Note

In the example a snack of size 3 fell on the first day, and the residents immediately placed it. On the second day a snack of size 1 fell, and the residents weren't able to place it because they were missing the snack of size 2. On the third day a snack of size 2 fell, and the residents immediately placed it. Right after that they placed the snack of size 1 which had fallen before.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
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...);
}
const int N = int(1e5) + 10;
bool vis[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> v;
  int last = n;
  for (int i = (int)0; i < (int)n; i++) {
    int x;
    cin >> x;
    vis[x] = 1;
    if (x == last) {
      while (vis[last]) {
        cout << last << " ";
        last--;
      }
    }
    cout << endl;
  }
  return 0;
}

```


### Prompt

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

JOI has a stove in your room. JOI himself is resistant to the cold, so he doesn't need to put on the stove when he is alone in the room, but he needs to put on the stove when there are visitors.

On this day, there are N guests under JOI. The ith (1 \ leq i \ leq N) visitor arrives at time T_i and leaves at time T_i + 1. There can never be more than one visitor at the same time.

JOI can turn the stove on and off at any time. However, each time you turn on the stove, you will consume one match. JOI has only K matches, so he can only stove up to K times. The stove is gone at the beginning of the day.

When the stove is on, fuel is consumed by that amount, so I want to set the time when the stove is on and off and minimize the total time when the stove is on.

Example

Input

3 2
1
3
6

Output

4

### Response

```cpp
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, k; cin >> n >> k;
	vector<long long>v;
	long long a; cin >> a;
	for (int i = 1; i < n; i++) {
		long long b; cin >> b;
		v.push_back(b - a - 1);
		a = b;
	}
	sort(v.begin(), v.end());
	int ans = n;
	for (int i = 0; i < n - k; i++)ans += v[i];
	cout << ans << endl;
	return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area.

Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no empty space left. When you put a logo on the billboard, you should rotate it so that the sides were parallel to the sides of the billboard.

Your task is to determine if it is possible to put the logos of all the three companies on some square billboard without breaking any of the described rules.

Input

The first line of the input contains six positive integers x1, y1, x2, y2, x3, y3 (1 ≤ x1, y1, x2, y2, x3, y3 ≤ 100), where xi and yi determine the length and width of the logo of the i-th company respectively.

Output

If it is impossible to place all the three logos on a square shield, print a single integer "-1" (without the quotes).

If it is possible, print in the first line the length of a side of square n, where you can place all the three logos. Each of the next n lines should contain n uppercase English letters "A", "B" or "C". The sets of the same letters should form solid rectangles, provided that:

  * the sizes of the rectangle composed from letters "A" should be equal to the sizes of the logo of the first company,
  * the sizes of the rectangle composed from letters "B" should be equal to the sizes of the logo of the second company,
  * the sizes of the rectangle composed from letters "C" should be equal to the sizes of the logo of the third company,

Note that the logos of the companies can be rotated for printing on the billboard. The billboard mustn't have any empty space. If a square billboard can be filled with the logos in multiple ways, you are allowed to print any of them.

See the samples to better understand the statement.

Examples

Input

5 1 2 5 5 2

Output

5
AAAAA
BBBBB
BBBBB
CCCCC
CCCCC

Input

4 4 2 6 4 2

Output

6
BBBBBB
BBBBBB
AAAACC
AAAACC
AAAACC
AAAACC

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int x[3], y[3], flag[3], ss[3];
int main() {
  int a = 0, s = 0;
  ;
  for (int i = 0; i < 3; i++) {
    scanf("%d %d", x + i, y + i);
    if (x[i] < y[i]) swap(x[i], y[i]);
    a = max(a, x[i]);
    ss[i] = x[i] * y[i];
    s += x[i] * y[i];
  }
  if (a * a != s) {
    printf("-1");
    return 0;
  }
  printf("%d\n", a);
  int b = a;
  for (int i = 0; i < 3; i++) {
    if (x[i] == a) {
      for (int j = 0; j < y[i]; j++) {
        cout << string(a, 'A' + i);
        printf("\n");
      }
      flag[i] = 1;
      b -= y[i];
    }
  }
  for (int i = 0; i < b; i++) {
    for (int j = 0; j < 3; j++) {
      if (!flag[j]) {
        if (x[j] == b)
          cout << string(y[j], 'A' + j);
        else
          cout << string(x[j], 'A' + j);
      }
    }
    printf("\n");
  }
}

```


### Prompt

Generate a cpp solution to the following problem:

You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.

An integer greater than 1 is composite, if it is not prime, i.e. if it has positive divisors not equal to 1 and the integer itself.

Input

The first line contains single integer q (1 ≤ q ≤ 105) — the number of queries.

q lines follow. The (i + 1)-th line contains single integer ni (1 ≤ ni ≤ 109) — the i-th query.

Output

For each query print the maximum possible number of summands in a valid splitting to composite summands, or -1, if there are no such splittings.

Examples

Input

1
12

Output

3

Input

2
6
8

Output

1
2

Input

3
1
2
3

Output

-1
-1
-1

Note

12 = 4 + 4 + 4 = 4 + 8 = 6 + 6 = 12, but the first splitting has the maximum possible number of summands.

8 = 4 + 4, 6 can't be split into several composite summands.

1, 2, 3 are less than any composite number, so they do not have valid splittings.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T next_int() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') {
    p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return p * x;
}
string next_token() {
  char ch;
  string ans = "";
  do {
    ch = getchar();
  } while (ch <= ' ');
  while (ch > ' ') {
    ans += ch;
    ch = getchar();
  }
  return ans;
}
const long long INF = (long long)1e18;
const int INFINT = (int)1e9 + 227 + 1;
const int MAXN = (int)1e6 + 227 + 1;
const int MOD = (int)1e9 + 7;
const long double EPS = 1e-9;
long long bin_pow(long long a, long long b) {
  if (!b) return 1;
  long long ans = bin_pow(a, b / 2);
  ans = ans * ans % MOD;
  if (b % 2) ans = ans * a % MOD;
  return ans;
}
bool used[MAXN];
void build_prime() {
  for (int i = 2; i < MAXN; i++) {
    if (used[i]) continue;
    for (int j = i + i; j < MAXN; j += i) {
      used[j] = 1;
    }
  }
}
bool check(int a) {
  if (!a) return 1;
  for (int i = 2; i * i <= a; i++)
    if (a % i == 0) return 1;
  return 0;
}
int dp[MAXN];
int full(int n) {
  int ans = n / 4;
  while (ans >= 0 && !check(n - ans * 4)) ans--;
  if (ans != -1 && ans * 4 != n) ans += dp[n - ans * 4];
  return ans;
}
int main() {
  build_prime();
  for (int i = 0; i * i <= MAXN; i++) dp[i] = -INFINT;
  dp[0] = 0;
  for (int j = 2; j * j <= MAXN; j++) {
    if (!used[j]) continue;
    for (int i = 0; i * i <= MAXN; i++) {
      dp[i + j] = max(dp[i + j], dp[i] + 1);
    }
  }
  int test;
  cin >> test;
  while (test--) {
    int n = next_int<int>();
    cout << full(n) << "\n";
  }
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Gaius Julius Caesar, a famous general, loved to line up his soldiers. Overall the army had n1 footmen and n2 horsemen. Caesar thought that an arrangement is not beautiful if somewhere in the line there are strictly more that k1 footmen standing successively one after another, or there are strictly more than k2 horsemen standing successively one after another. Find the number of beautiful arrangements of the soldiers.

Note that all n1 + n2 warriors should be present at each arrangement. All footmen are considered indistinguishable among themselves. Similarly, all horsemen are considered indistinguishable among themselves.

Input

The only line contains four space-separated integers n1, n2, k1, k2 (1 ≤ n1, n2 ≤ 100, 1 ≤ k1, k2 ≤ 10) which represent how many footmen and horsemen there are and the largest acceptable number of footmen and horsemen standing in succession, correspondingly.

Output

Print the number of beautiful arrangements of the army modulo 100000000 (108). That is, print the number of such ways to line up the soldiers, that no more than k1 footmen stand successively, and no more than k2 horsemen stand successively.

Examples

Input

2 1 1 10

Output

1

Input

2 3 1 2

Output

5

Input

2 4 1 1

Output

0

Note

Let's mark a footman as 1, and a horseman as 2.

In the first sample the only beautiful line-up is: 121

In the second sample 5 beautiful line-ups exist: 12122, 12212, 21212, 21221, 22121

### Response

```cpp
#include <bits/stdc++.h>
int dp[213][213][2][13];
int n1, n2, k1, k2;
int main() {
  scanf("%d%d%d%d", &n1, &n2, &k1, &k2);
  dp[1][0][0][1] = dp[0][1][1][1] = 1;
  dp[0][1][0][1] = dp[1][0][1][1] = 0;
  for (int i = 0; i <= n1; i++) {
    for (int j = 0; j <= n2; j++) {
      if (i > 0)
        for (int k = 2; k <= k1; k++) {
          dp[i][j][0][k] = dp[i - 1][j][0][k - 1];
        }
      if (j > 0)
        for (int k = 2; k <= k2; k++) {
          dp[i][j][1][k] = dp[i][j - 1][1][k - 1];
        }
      if (i + j != 1) dp[i][j][1][1] = dp[i][j][0][1] = 0;
      if (i > 0) {
        for (int k = 1; k <= k2; k++) {
          dp[i][j][0][1] += dp[i - 1][j][1][k];
        }
        dp[i][j][0][1] %= 100000000;
      }
      if (j > 0) {
        for (int k = 1; k <= k1; k++) {
          dp[i][j][1][1] += dp[i][j - 1][0][k];
        }
        dp[i][j][1][1] %= 100000000;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= k1; i++) {
    ans += dp[n1][n2][0][i];
    ans %= 100000000;
  }
  for (int i = 1; i <= k2; i++) {
    ans += dp[n1][n2][1][i];
    ans %= 100000000;
  }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

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

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

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

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

Input

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

Output

Output a single integer — the minimum possible X0.

Examples

Input

14

Output

6

Input

20

Output

15

Input

8192

Output

8191

Note

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

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

In the second case, let X0 = 15.

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int x2, t[1010000];
int mx, x1, MIN;
vector<int> s;
int main() {
  t[1] = 1;
  for (int i = 2; i <= 1000010; i++) {
    if (!t[i]) {
      for (int j = 2 * i; j <= 1000010; j += i) t[j] = 1;
    }
  }
  scanf("%d", &x2);
  for (int i = 1; i * i <= x2; i++) {
    if (x2 % i == 0) {
      s.push_back(i);
      s.push_back(x2 / i);
    }
  }
  sort(s.begin(), s.end());
  for (int i = (int)s.size() - 1; i >= 0; i--) {
    if (!t[s[i]]) {
      mx = s[i];
      break;
    }
  }
  MIN = 1e9;
  for (int x1 = x2 - mx + 1; x1 <= x2; x1++) {
    for (int i = 2; i * i <= x1; i++) {
      if (x1 % i == 0) {
        if (!t[x1 / i]) MIN = min(MIN, x1 - x1 / i + 1);
        if (!t[i]) MIN = min(MIN, x1 - i + 1);
      }
    }
  }
  printf("%d\n", MIN);
}

```


### Prompt

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

Ivan has an array consisting of n different integers. He decided to reorder all elements in increasing order. Ivan loves merge sort so he decided to represent his array with one or several increasing sequences which he then plans to merge into one sorted array.

Ivan represent his array with increasing sequences with help of the following algorithm.

While there is at least one unused number in array Ivan repeats the following procedure:

  * iterate through array from the left to the right;
  * Ivan only looks at unused numbers on current iteration;
  * if current number is the first unused number on this iteration or this number is greater than previous unused number on current iteration, then Ivan marks the number as used and writes it down.

For example, if Ivan's array looks like [1, 3, 2, 5, 4] then he will perform two iterations. On first iteration Ivan will use and write numbers [1, 3, 5], and on second one — [2, 4].

Write a program which helps Ivan and finds representation of the given array with one or several increasing sequences in accordance with algorithm described above.

Input

The first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of elements in Ivan's array.

The second line contains a sequence consisting of distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — Ivan's array.

Output

Print representation of the given array in the form of one or more increasing sequences in accordance with the algorithm described above. Each sequence must be printed on a new line.

Examples

Input

5
1 3 2 5 4

Output

1 3 5
2 4

Input

4
4 3 2 1

Output

4
3
2
1

Input

4
10 30 50 101

Output

10 30 50 101

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int n = 0, c = 0, m;
  while (!isdigit(c)) m = c - 45 ? 1 : -1, c = getchar();
  while (isdigit(c)) n = n * 10 + c - 48, c = getchar();
  return m * n;
}
const int N = 200001;
vector<int> ans[N];
int a[N];
int t[4 * N];
void update(int v, int tl, int tr, int id, int x) {
  if (tl == tr) {
    t[v] = x;
    return;
  }
  int tm = (tl + tr) >> 1;
  if (id <= tm) {
    update(2 * v, tl, tm, id, x);
  } else
    update(2 * v + 1, tm + 1, tr, id, x);
  t[v] = min(t[2 * v], t[2 * v + 1]);
}
int get_min(int v, int tl, int tr, int l, int r) {
  if (l == tl && r == tr) {
    return t[v];
  }
  int tm = (tl + tr) >> 1;
  if (r <= tm)
    return get_min(2 * v, tl, tm, l, r);
  else if (l > tm)
    return get_min(2 * v + 1, tm + 1, tr, l, r);
  return min(get_min(2 * v, tl, tm, l, tm),
             get_min(2 * v + 1, tm + 1, tr, tm + 1, r));
}
int us[N];
int main() {
  map<int, int> mp;
  int n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    mp[a[i]];
  }
  int cnt = 0;
  for (auto i : mp) {
    mp[i.first] = ++cnt;
  }
  for (int i = 1; i < 4 * N; i++) t[i] = 1e9;
  int l = 0;
  for (int i = 1; i <= n; i++) {
    int t = mp[a[i]];
    us[t] = a[i];
    int g = get_min(1, 1, n, 1, t);
    if (g == 1e9) {
      ++l;
      g = l;
      ans[g].push_back(t);
    } else {
      int u = ans[g][ans[g].size() - 1];
      update(1, 1, n, u, 1e9);
      ans[g].push_back(t);
    }
    update(1, 1, n, t, g);
  }
  for (int i = 1; i <= l; i++) {
    for (int j : ans[i]) cout << us[j] << " ";
    cout << "\n";
  }
}

```


### Prompt

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

You are given an array a consisting of n integers, and additionally an integer m. You have to choose some sequence of indices b1, b2, ..., bk (1 ≤ b1 < b2 < ... < bk ≤ n) in such a way that the value of <image> is maximized. Chosen sequence can be empty.

Print the maximum possible value of <image>.

Input

The first line contains two integers n and m (1 ≤ n ≤ 35, 1 ≤ m ≤ 109).

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

Output

Print the maximum possible value of <image>.

Examples

Input

4 4
5 2 4 1

Output

3

Input

3 20
199 41 299

Output

19

Note

In the first example you can choose a sequence b = {1, 2}, so the sum <image> is equal to 7 (and that's 3 after taking it modulo 4).

In the second example you can choose a sequence b = {3}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i], a[i] %= m;
  vector<long long> w;
  long long kol = 1 << (n / 2), r = n / 2;
  for (long long mask = 0; mask < kol; ++mask) {
    long long sum = 0;
    for (long long i = 0; i < r; ++i)
      if ((1 << i) & mask) sum += a[i];
    w.emplace_back(sum % m);
  }
  sort((w).begin(), (w).end());
  long long ans = 0, r1 = r;
  kol = 1 << (n - r), r = n - r;
  for (long long mask = 0; mask < kol; ++mask) {
    long long sum = 0;
    for (long long i = 0; i < r; ++i)
      if ((1 << i) & mask) sum += a[i + r1];
    sum %= m;
    auto q = lower_bound((w).begin(), (w).end(), m - sum);
    if (q != w.begin()) q--;
    long long q1 = *q;
    ans = max(ans, (sum + q1) % m);
  }
  cout << ans << '\n';
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

You are given an array a consisting of n integers.

You can remove at most one element from this array. Thus, the final length of the array is n-1 or n.

Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array.

Recall that the contiguous subarray a with indices from l to r is a[l ... r] = a_l, a_{l + 1}, ..., a_r. The subarray a[l ... r] is called strictly increasing if a_l < a_{l+1} < ... < a_r.

Input

The first line of the input contains one integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of elements in a.

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 i-th element of a.

Output

Print one integer — the maximum possible length of the strictly increasing contiguous subarray of the array a after removing at most one element.

Examples

Input

5
1 2 5 3 4

Output

4

Input

2
1 2

Output

2

Input

7
6 5 4 3 2 4 3

Output

2

Note

In the first example, you can delete a_3=5. Then the resulting array will be equal to [1, 2, 3, 4] and the length of its largest increasing subarray will be equal to 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int inf = 1000000005;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> v(n + 2);
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  v[0] = inf;
  v[n + 1] = -1;
  vector<int> l(n + 2, 1);
  vector<int> r(n + 2, 1);
  for (int i = 1; i <= n; i++) {
    if (v[i] > v[i - 1]) {
      l[i] = l[i - 1] + 1;
    }
  }
  for (int i = n; i >= 1; i--) {
    if (v[i] < v[i + 1]) {
      r[i] = r[i + 1] + 1;
    }
  }
  int best = 0;
  for (int i = 1; i <= n; i++) {
    best = max({best, l[i], r[i]});
    if (v[i - 1] < v[i + 1]) {
      best = max(best, l[i - 1] + r[i + 1]);
    }
  }
  cout << best << endl;
}

```


### Prompt

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

Once Petya read a problem about a bracket sequence. He gave it much thought but didn't find a solution. Today you will face it.

You are given string s. It represents a correct bracket sequence. A correct bracket sequence is the sequence of opening ("(") and closing (")") brackets, such that it is possible to obtain a correct mathematical expression from it, inserting numbers and operators between the brackets. For example, such sequences as "(())()" and "()" are correct bracket sequences and such sequences as ")()" and "(()" are not.

In a correct bracket sequence each bracket corresponds to the matching bracket (an opening bracket corresponds to the matching closing bracket and vice versa). For example, in a bracket sequence shown of the figure below, the third bracket corresponds to the matching sixth one and the fifth bracket corresponds to the fourth one.

<image>

You are allowed to color some brackets in the bracket sequence so as all three conditions are fulfilled:

  * Each bracket is either not colored any color, or is colored red, or is colored blue.
  * For any pair of matching brackets exactly one of them is colored. In other words, for any bracket the following is true: either it or the matching bracket that corresponds to it is colored.
  * No two neighboring colored brackets have the same color.

Find the number of different ways to color the bracket sequence. The ways should meet the above-given conditions. Two ways of coloring are considered different if they differ in the color of at least one bracket. As the result can be quite large, print it modulo 1000000007 (109 + 7).

Input

The first line contains the single string s (2 ≤ |s| ≤ 700) which represents a correct bracket sequence.

Output

Print the only number — the number of ways to color the bracket sequence that meet the above given conditions modulo 1000000007 (109 + 7).

Examples

Input

(())

Output

12

Input

(()())

Output

40

Input

()

Output

4

Note

Let's consider the first sample test. The bracket sequence from the sample can be colored, for example, as is shown on two figures below.

<image> <image>

The two ways of coloring shown below are incorrect.

<image> <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 800;
const int mod = 1e9 + 7;
int dp[N][N][3][3];
string s;
stack<int> st;
int p[N], fp[N];
bool judge(int c1, int c2) { return c1 == 0 || c2 == 0 || c1 != c2; }
long long dfs(int l, int r, int lc, int rc) {
  if (dp[l][r][lc][rc] != -1) return dp[l][r][lc][rc];
  if (l + 1 > r) return dp[l][r][lc][rc] = 0;
  if (l == r) return dp[l][r][lc][rc] = 1LL;
  long long ans = 0;
  int k = p[l];
  if (k == r) {
    if ((lc == 0 && rc) || (lc && rc == 0)) {
      if (l + 1 == r) return dp[l][r][lc][rc] = 1LL;
      for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
          if (judge(lc, i) && judge(j, rc)) {
            ans = (ans + dfs(l + 1, r - 1, i, j)) % mod;
          }
        }
      }
    }
  } else if (k < r) {
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (judge(i, j))
          ans = (ans + dfs(l, k, lc, i) * dfs(k + 1, r, j, rc) % mod) % mod;
      }
    }
  }
  return dp[l][r][lc][rc] = ans % mod;
}
int main() {
  cin >> s;
  memset(p, -1, sizeof p);
  memset(fp, -1, sizeof fp);
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '(')
      st.push(i);
    else {
      int pos = st.top();
      st.pop();
      p[pos] = i;
      fp[i] = pos;
    }
  }
  memset(dp, -1, sizeof dp);
  long long ans = 0;
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      ans = (ans + dfs(0, s.size() - 1, i, j)) % mod;
    }
  }
  cout << ans;
  return 0;
}

```


### Prompt

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

You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

Constraints

* All values in input are integers.
* 0 \leq L < R \leq 2 \times 10^9

Input

Input is given from Standard Input in the following format:

L R

Output

Print the minimum possible value of (i \times j) \mbox{ mod } 2019 when i and j are chosen under the given condition.

Examples

Input

2020 2040

Output

2

Input

4 5

Output

20

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	long long a,b;
	cin>>a>>b;
	if(fabs(a-b)>2018){
		cout<<0<<endl;
		return 0;
	}
	ll mi=10000;
	for(ll i=a;i<=b;i++){
		for(ll j=i+1;j<=b;j++){
			if(i*j%2019<mi){
				mi=i*j%2019;
			}
		}
	}
	cout<<mi<<endl;
	return 0;
}
```


### Prompt

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

Mister B once received a gift: it was a book about aliens, which he started read immediately. This book had c pages.

At first day Mister B read v0 pages, but after that he started to speed up. Every day, starting from the second, he read a pages more than on the previous day (at first day he read v0 pages, at second — v0 + a pages, at third — v0 + 2a pages, and so on). But Mister B is just a human, so he physically wasn't able to read more than v1 pages per day.

Also, to refresh his memory, every day, starting from the second, Mister B had to reread last l pages he read on the previous day. Mister B finished the book when he read the last page for the first time.

Help Mister B to calculate how many days he needed to finish the book.

Input

First and only line contains five space-separated integers: c, v0, v1, a and l (1 ≤ c ≤ 1000, 0 ≤ l < v0 ≤ v1 ≤ 1000, 0 ≤ a ≤ 1000) — the length of the book in pages, the initial reading speed, the maximum reading speed, the acceleration in reading speed and the number of pages for rereading.

Output

Print one integer — the number of days Mister B needed to finish the book.

Examples

Input

5 5 10 5 4

Output

1

Input

12 4 12 4 1

Output

3

Input

15 1 100 0 0

Output

15

Note

In the first sample test the book contains 5 pages, so Mister B read it right at the first day.

In the second sample test at first day Mister B read pages number 1 - 4, at second day — 4 - 11, at third day — 11 - 12 and finished the book.

In third sample test every day Mister B read 1 page of the book, so he finished in 15 days.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long c, v0, v1, a, l, ans = 0;
  cin >> c >> v0 >> v1 >> a >> l;
  long long tot = 0;
  while (tot < c) {
    long long add = v0 - l * (ans > 0);
    tot = tot + add;
    v0 = min(v0 + a, v1);
    ans++;
  }
  cout << ans;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

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

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

Mike wants to do the following operations with the tree:

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

Initially all vertices of the tree are empty.

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

Input

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

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

It is guaranteed that the given graph is a tree.

Output

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

Examples

Input

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

Output

0
0
0
1
0
1
0
1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
struct IntervalTree {
  void init(int N) {
    this->N = N;
    it.resize(4 * N + 1, 0);
    lazy.resize(4 * N + 1, -1);
  }
  void lazyUpdate(int p, int L, int R) {
    if (lazy[p] != -1) {
      if (lazy[p] == 0)
        it[p] = 0;
      else
        it[p] = R - L + 1;
      if (L != R) {
        lazy[p * 2] = lazy[p * 2 + 1] = lazy[p];
      }
      lazy[p] = -1;
    }
  }
  void update(int p, int L, int R, int u, int v, int val) {
    lazyUpdate(p, L, R);
    if (R < u || L > v) return;
    if (L >= u && R <= v) {
      lazy[p] = val;
      lazyUpdate(p, L, R);
      return;
    }
    int M = (L + R) >> 1;
    update(p * 2, L, M, u, v, val);
    update(p * 2 + 1, M + 1, R, u, v, val);
    it[p] = it[p * 2] + it[p * 2 + 1];
  }
  int query(int p, int L, int R, int u, int v) {
    lazyUpdate(p, L, R);
    if (R < u || L > v) return -1;
    if (L >= u && R <= v) return it[p];
    int M = (L + R) >> 1;
    int p1 = query(p * 2, L, M, u, v);
    int p2 = query(p * 2 + 1, M + 1, R, u, v);
    if (p1 == -1) return p2;
    if (p2 == -1) return p1;
    return p1 + p2;
  }
  int N;
  vector<int> it, lazy;
};
int L[MAXN], R[MAXN], p[MAXN];
vector<int> adj[MAXN];
int n, m;
void dfs(int u, int pa) {
  L[u] = ++m;
  for (int i = 0; i < int(adj[u].size()); i++) {
    int v = adj[u][i];
    if (v == pa) continue;
    p[v] = u;
    dfs(v, u);
  }
  R[u] = m;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 0);
  IntervalTree it;
  it.init(n);
  int q;
  cin >> q;
  while (q--) {
    int c, v;
    cin >> c >> v;
    if (c == 1) {
      int x = R[v] - L[v] + 1 - it.query(1, 1, n, L[v], R[v]);
      it.update(1, 1, n, L[v], R[v], 1);
      if (x > 0 && v != 1) it.update(1, 1, n, L[p[v]], L[p[v]], 0);
    } else if (c == 2) {
      it.update(1, 1, n, L[v], L[v], 0);
    } else {
      int x = R[v] - L[v] + 1 - it.query(1, 1, n, L[v], R[v]);
      if (x > 0)
        cout << "0\n";
      else
        cout << "1\n";
    }
  }
  return 0;
}

```


### Prompt

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

Maksim has n objects and m boxes, each box has size exactly k. Objects are numbered from 1 to n in order from left to right, the size of the i-th object is a_i.

Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goes from left to right through the objects, and if the i-th object fits in the current box (the remaining size of the box is greater than or equal to a_i), he puts it in the box, and the remaining size of the box decreases by a_i. Otherwise he takes the new empty box and continues the process above. If he has no empty boxes and there is at least one object not in some box then Maksim cannot pack the chosen set of objects.

Maksim wants to know the maximum number of objects he can pack by the algorithm above. To reach this target, he will throw out the leftmost object from the set until the remaining set of objects can be packed in boxes he has. Your task is to say the maximum number of objects Maksim can pack in boxes he has.

Each time when Maksim tries to pack the objects into the boxes, he will make empty all the boxes he has before do it (and the relative order of the remaining set of objects will not change).

Input

The first line of the input contains three integers n, m, k (1 ≤ n, m ≤ 2 ⋅ 10^5, 1 ≤ k ≤ 10^9) — the number of objects, the number of boxes and the size of each box.

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ k), where a_i is the size of the i-th object.

Output

Print the maximum number of objects Maksim can pack using the algorithm described in the problem statement.

Examples

Input

5 2 6
5 2 1 4 2

Output

4

Input

5 1 4
4 2 3 4 1

Output

1

Input

5 3 3
1 2 3 1 1

Output

5

Note

In the first example Maksim can pack only 4 objects. Firstly, he tries to pack all the 5 objects. Distribution of objects will be [5], [2, 1]. Maxim cannot pack the next object in the second box and he has no more empty boxes at all. Next he will throw out the first object and the objects distribution will be [2, 1], [4, 2]. So the answer is 4.

In the second example it is obvious that Maksim cannot pack all the objects starting from first, second, third and fourth (in all these cases the distribution of objects is [4]), but he can pack the last object ([1]).

In the third example Maksim can pack all the objects he has. The distribution will be [1, 2], [3], [1, 1].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int mod1 = 998244353;
long long int mod = 1e9 + 7;
bool comp(long long int x, long long int y) {
  if (x > y) return true;
  return false;
}
long long int INF = 1e18;
long long int a[200005];
void solve() {
  long long int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  long long int cnt = 1;
  long long int i = n - 1;
  while (cnt <= m && i >= 0) {
    long long int sum = a[i];
    while (i - 1 >= 0 && a[i - 1] + sum <= k) {
      sum += a[i - 1];
      --i;
    }
    ++cnt;
    --i;
  }
  cout << n - i - 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Roma found a new character in the game "World of Darkraft - 2". In this game the character fights monsters, finds the more and more advanced stuff that lets him fight stronger monsters.

The character can equip himself with k distinct types of items. Power of each item depends on its level (positive integer number). Initially the character has one 1-level item of each of the k types.

After the victory over the monster the character finds exactly one new randomly generated item. The generation process looks as follows. Firstly the type of the item is defined; each of the k types has the same probability. Then the level of the new item is defined. Let's assume that the level of player's item of the chosen type is equal to t at the moment. Level of the new item will be chosen uniformly among integers from segment [1; t + 1].

From the new item and the current player's item of the same type Roma chooses the best one (i.e. the one with greater level) and equips it (if both of them has the same level Roma choses any). The remaining item is sold for coins. Roma sells an item of level x of any type for x coins.

Help Roma determine the expected number of earned coins after the victory over n monsters.

Input

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

Output

Print a real number — expected number of earned coins after victory over n monsters. The answer is considered correct if its relative or absolute error doesn't exceed 10 - 9.

Examples

Input

1 3

Output

1.0000000000

Input

2 1

Output

2.3333333333

Input

10 2

Output

15.9380768924

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, k;
double f[2][1010];
int main() {
  scanf("%d%d", &n, &k);
  int now = 1;
  int t = min(n, 1000);
  for (int i = 1; i <= n; i++, now ^= 1) {
    for (int j = t; j; j--) {
      f[now][j] = ((f[now ^ 1][j + 1] + j) / (j + 1.0) +
                   j * (f[now ^ 1][j] + (j + 1.0) / 2.0) / (j + 1.0)) /
                      (k * 1.0) +
                  (k - 1) * f[now ^ 1][j] / (k * 1.0);
    }
  }
  printf("%.10lf", f[now ^ 1][1] * k);
  return 0;
}

```


### Prompt

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

Nikola owns a large warehouse which is illuminated by N light bulbs, numbered 1 to N. At the exit of the warehouse, there are S light switches, numbered 1 to S. Each switch swaps the on/off state for some light bulbs, so if a light bulb is off, flipping the switch turns it on, and if the light bulb is on, flipping the switch turns it off.

At the end of the day, Nikola wants to turn all the lights off. To achieve this, he will flip some of the light switches at the exit of the warehouse, but since Nikola is lazy, he wants to flip the _minimum_ number of switches required to turn all the lights off. Since Nikola was not able to calculate the minimum number of switches, he asked you to help him. During a period of D days, Nikola noted which light bulbs were off and which were on at the end of each day. He wants you to tell him the minimum number of switches he needed to flip to turn all the lights off for each of the D days or tell him that it's impossible.

Input

First line contains three integers, N, S and D (1 ≤ N ≤ 10^3, 1 ≤ S ≤ 30, 1 ≤ D ≤ 10^3) – representing number of light bulbs, the number of light switches, and the number of days respectively.

The next S lines contain the description of each light switch as follows: The first number in the line, C_i (1 ≤ C_i ≤ N), represents the number of light bulbs for which the on/off state is swapped by light switch i, the next C_i numbers (sorted in increasing order) represent the indices of those light bulbs.

The next D lines contain the description of light bulbs for each day as follows: The first number in the line, T_i (1 ≤ T_i ≤ N), represents the number of light bulbs which are on at the end of day i, the next T_i numbers (sorted in increasing order) represent the indices of those light bulbs.

Output

Print D lines, one for each day. In the i^{th} line, print the minimum number of switches that need to be flipped on day i, or -1 if it's impossible to turn all the lights off.

Example

Input

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

Output

2
2
3
-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
const long long mod = 998244353;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, s, d;
unsigned long long ok[N];
unsigned long long d1[(1 << 20)], d2[(1 << 10)], a[N];
unordered_map<unsigned long long, int> m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 0; i < N; i++) ok[i] = rng();
  cin >> n >> s >> d;
  for (int i = 0; i < s; i++) {
    int len;
    cin >> len;
    for (int j = 1; j <= len; j++) {
      int x;
      cin >> x;
      a[i] ^= ok[x];
    }
  }
  int c = min(20, s);
  for (int i = 0; i < c; i++) {
    for (int j = 0; j < (1 << i); j++) {
      d1[(1 << i) + j] = (d1[j] ^ a[i]);
    }
  }
  for (int i = 0; i < s - c; i++) {
    for (int j = 0; j < (1 << i); j++) {
      d2[j + (1 << i)] = (d2[j] ^ a[i + c]);
    }
  }
  for (int i = 0; i < (1 << c); i++) {
    unsigned long long res = d1[i];
    if (m.find(res) == m.end()) {
      m[res] = __builtin_popcount(i);
    } else {
      m[res] = min(m[res], __builtin_popcount(i));
    }
  }
  for (int i = 1; i <= d; i++) {
    int len;
    cin >> len;
    unsigned long long a = 0;
    for (int j = 1; j <= len; j++) {
      int x;
      cin >> x;
      a ^= ok[x];
    }
    int ans = 1e9;
    for (int j = 0; j < (1 << s - c); j++) {
      auto c = (a ^ d2[j]);
      if (m.find(c) != m.end()) {
        ans = min(ans, m[c] + __builtin_popcount(j));
      }
    }
    cout << (ans == 1e9 ? -1 : ans) << "\n";
  }
}

```


### Prompt

Create a solution in Cpp for the following problem:

A long time ago there was a land called Dudeland. Dudeland consisted of n towns connected with n - 1 bidirectonal roads. The towns are indexed from 1 to n and one can reach any city from any other city if he moves along the roads of the country. There are m monasteries in Dudeland located in m different towns. In each monastery lives a pilgrim.

At the beginning of the year, each pilgrim writes down which monastery is the farthest from the monastery he is living in. If there is more than one farthest monastery, he lists all of them. On the Big Lebowski day each pilgrim picks one town from his paper at random and starts walking to that town.

Walter hates pilgrims and wants to make as many of them unhappy as possible by preventing them from finishing their journey. He plans to destroy exactly one town that does not contain a monastery. A pilgrim becomes unhappy if all monasteries in his list become unreachable from the monastery he is living in.

You need to find the maximum number of pilgrims Walter can make unhappy. Also find the number of ways he can make this maximal number of pilgrims unhappy: the number of possible towns he can destroy.

Input

The first line contains two integers n (3 ≤ n ≤ 105) and m (2 ≤ m < n). The next line contains m distinct integers representing indices of towns that contain monasteries.

Next n - 1 lines contain three integers each, ai, bi, ci, indicating that there is an edge between towns ai and bi of length ci (1 ≤ ai, bi ≤ n, 1 ≤ ci ≤ 1000, ai ≠ bi).

Output

Output two integers: the maximum number of pilgrims Walter can make unhappy and the number of ways in which he can make his plan come true.

Examples

Input

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

Output

5 1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> path;
bool special[100010];
vector<pair<int, int> > E[100010];
path up[100010];
path down[100010];
int depth[100010];
int par[100010][18];
int add[100010];
int cover[100010];
ostream& operator<<(ostream& out, const pair<int, int>& p) {
  return out << "(" << p.first << "," << p.second << ")";
}
path take_better(const path& a, const path& b, int i) {
  if (a.first > b.first) return a;
  if (a.first < b.first) return b;
  return make_pair(a.first, i);
}
void dfs1(int i, int p) {
  if (special[i])
    down[i] = make_pair(0, i);
  else
    down[i] = make_pair(-1000000000, i);
  par[i][0] = p;
  depth[i] = depth[p] + 1;
  int numE = E[i].size();
  for (int x = 0; x < (numE); ++x) {
    int j = E[i][x].first, c = E[i][x].second;
    if (j == p) continue;
    dfs1(j, i);
    path dd = down[j];
    dd.first += c;
    down[i] = take_better(down[i], dd, i);
  }
}
void dfs2(int i, int p, path withoutMe) {
  up[i] = withoutMe;
  if (special[i]) up[i] = take_better(up[i], make_pair(0, i), i);
  int numE = E[i].size();
  path best = up[i], second = make_pair(-1000000000, i),
       third = make_pair(-1000000000, i);
  for (int x = 0; x < (numE); ++x) {
    int j = E[i][x].first, c = E[i][x].second;
    if (j == p) continue;
    path here = down[j];
    here.first += c;
    if (here >= best) {
      third = second;
      second = best;
      best = here;
    } else if (here >= second) {
      third = second;
      second = here;
    } else if (here >= third) {
      third = here;
    }
  }
  for (int x = 0; x < (numE); ++x) {
    int j = E[i][x].first, c = E[i][x].second;
    if (j == p) continue;
    path withoutHim;
    path goHere = down[j];
    goHere.first += c;
    if (goHere == best)
      withoutHim = take_better(second, third, i);
    else if (goHere == second)
      withoutHim = take_better(best, third, i);
    else
      withoutHim = take_better(best, second, i);
    withoutHim.first += c;
    dfs2(j, i, withoutHim);
  }
}
int nth(int a, int n) {
  assert(n >= 0);
  for (int k = 0; n; n >>= 1, ++k)
    if (n & 1) a = par[a][k];
  return a;
}
int lca(int a, int b) {
  if (depth[a] < depth[b]) swap(a, b);
  a = nth(a, depth[a] - depth[b]);
  assert(depth[a] == depth[b]);
  for (int k = 18 - 1; k >= 0; --k)
    if (par[a][k] != par[b][k]) a = par[a][k], b = par[b][k];
  if (a != b) a = b = par[a][0];
  return a;
}
bool is_ancestor(int a, int b) { return lca(a, b) == a; }
void update(int i, int v) { add[i] += v; }
void add_path(int i, int j) {
  if (is_ancestor(i, j)) {
    update(j, 1);
    update(par[i][0], -1);
  } else if (is_ancestor(j, i)) {
    update(i, 1);
    update(par[j][0], -1);
  } else {
    int k = lca(i, j);
    update(i, 1);
    update(j, 1);
    update(k, -1);
    update(par[k][0], -1);
  }
}
void setup(int N) {
  for (int k = (1); k <= (18 - 1); ++k)
    for (int i = (1); i <= (N); ++i) par[i][k] = par[par[i][k - 1]][k - 1];
  for (int i = (1); i <= (N); ++i) {
    if (!special[i]) continue;
    path p = take_better(up[i], down[i], i);
    int j = p.second;
    add_path(i, j);
  }
}
int dfs3(int i, int p) {
  int sum = add[i];
  int numE = E[i].size();
  for (int x = 0; x < (numE); ++x) {
    int j = E[i][x].first;
    if (j == p) continue;
    sum += dfs3(j, i);
  }
  assert(sum >= 0);
  cover[i] = sum;
  return sum;
}
int main() {
  srand(time(NULL));
  int N, M, a, b, c;
  cin >> N >> M;
  for (int i = (1); i <= (M); ++i) {
    scanf("%d", &a);
    special[a] = true;
  }
  for (int i = (1); i <= (N - 1); ++i) {
    scanf("%d%d%d", &a, &b, &c);
    E[a].push_back(make_pair(b, c));
    E[b].push_back(make_pair(a, c));
  }
  path init(-1000000000, 1);
  dfs1(1, 0);
  dfs2(1, 0, init);
  setup(N);
  dfs3(1, 0);
  int mx = 0;
  int cnt = 0;
  for (int i = (1); i <= (N); ++i) {
    if (special[i]) continue;
    if (cover[i] == mx) {
      cnt++;
    } else if (cover[i] > mx) {
      mx = cover[i];
      cnt = 1;
    }
  }
  cout << mx << " " << cnt << endl;
}

```