### Prompt

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

Maxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discount systems.

There are m types of discounts. We assume that the discounts are indexed from 1 to m. To use the discount number i, the customer takes a special basket, where he puts exactly qi items he buys. Under the terms of the discount system, in addition to the items in the cart the customer can receive at most two items from the supermarket for free. The number of the "free items" (0, 1 or 2) to give is selected by the customer. The only condition imposed on the selected "free items" is as follows: each of them mustn't be more expensive than the cheapest item out of the qi items in the cart.

Maxim now needs to buy n items in the shop. Count the minimum sum of money that Maxim needs to buy them, if he use the discount system optimally well.

Please assume that the supermarket has enough carts for any actions. Maxim can use the same discount multiple times. Of course, Maxim can buy items without any discounts.

Input

The first line contains integer m (1 ≤ m ≤ 105) — the number of discount types. The second line contains m integers: q1, q2, ..., qm (1 ≤ qi ≤ 105).

The third line contains integer n (1 ≤ n ≤ 105) — the number of items Maxim needs. The fourth line contains n integers: a1, a2, ..., an (1 ≤ ai ≤ 104) — the items' prices.

The numbers in the lines are separated by single spaces.

Output

In a single line print a single integer — the answer to the problem.

Examples

Input

1
2
4
50 50 100 100

Output

200

Input

2
2 3
5
50 50 50 50 50

Output

150

Input

1
1
7
1 1 1 1 1 1 1

Output

3

Note

In the first sample Maxim needs to buy two items that cost 100 and get a discount for two free items that cost 50. In that case, Maxim is going to pay 200.

In the second sample the best strategy for Maxim is to buy 3 items and get 2 items for free using the discount. In that case, Maxim is going to pay 150.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int m;
  cin >> m;
  int min;
  cin >> min;
  int tmp;
  for (int i = 0; i < m - 1; i++) {
    cin >> tmp;
    if (tmp < min) {
      min = tmp;
    }
  }
  int n;
  cin >> n;
  int *goods = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> goods[i];
  }
  sort(goods, goods + n);
  reverse(goods, goods + n);
  int summ = 0, pos = 0;
  while (pos < n) {
    int j = 0;
    while (pos < n && j < min) {
      summ += goods[pos];
      j++;
      pos++;
    }
    j = 0;
    while (pos < n && j < 2) pos++, j++;
  }
  cout << summ << endl;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

After destroying all of Voldemort's Horcruxes, Harry and Voldemort are up for the final battle. They each cast spells from their wands and the spells collide.

The battle scene is Hogwarts, which can be represented in the form of a tree. There are, in total, n places in Hogwarts joined using n - 1 undirected roads.

Ron, who was viewing this battle between Harry and Voldemort, wondered how many triplets of places (u, v, w) are there such that if Harry is standing at place u and Voldemort is standing at place v, their spells collide at a place w. This is possible for a triplet only when u, v and w are distinct, and there exist paths from u to w and from v to w which do not pass through the same roads.

Now, due to the battle havoc, new paths are being added all the time. You have to tell Ron the answer after each addition.

Formally, you are given a tree with n vertices and n - 1 edges. q new edges are being added between the nodes of the tree. After each addition you need to tell the number of triplets (u, v, w) such that u, v and w are distinct and there exist two paths, one between u and w, another between v and w such that these paths do not have an edge in common.

Input

First line contains an integer n (1 ≤ n ≤ 105), the number of places in Hogwarts.

Each of the next n - 1 lines contains two space separated integers u and v (1 ≤ u, v ≤ n) indicating a road between places u and v. It is guaranteed that the given roads form a connected tree.

Next line contains a single integer q (1 ≤ q ≤ 105), the number of new edges being added.

Each of the next q lines contains two space separated integers u and v (1 ≤ u, v ≤ n) representing the new road being added.

Note that it is possible that a newly added road connects places that were connected by a road before. Also, a newly added road may connect a place to itself.

Output

In the first line print the value for the number of triplets before any changes occurred.

After that print q lines, a single integer ansi in each line containing the value for the number of triplets after i-th edge addition.

Examples

Input

3
1 2
2 3
1
2 3

Output

2
4

Input

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

Output

6
18
24

Input

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

Output

20
60

Note

In the first sample case, for the initial tree, we have (1, 3, 2) and (3, 1, 2) as the only possible triplets (u, v, w).

After addition of edge from 2 to 3, we have (1, 3, 2), (3, 1, 2), (1, 2, 3) and (2, 1, 3) as the possible triplets.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, q;
long long ans = 0;
vector<int> graph[100005];
int depth[100005];
int parent[100005];
int weight[100005];
int ancestor[100005][17];
int comp[100005];
vector<int> comp_members[100005];
int comp_root[100005];
long long ansv[100005];
void merge_comp(int a, int b) {
  if (comp_members[a].size() > comp_members[b].size()) swap(a, b);
  ans -= (long long)(comp_members[a].size()) * ansv[a];
  ans -= (long long)(comp_members[b].size()) * ansv[b];
  for (int i = 0; i < comp_members[a].size(); i++) {
    int x = comp_members[a][i];
    comp_members[b].push_back(x);
    comp[x] = b;
  }
  if (depth[comp_root[a]] < depth[comp_root[b]]) {
    long long up_p2_sum = ((long long)(n - 1) * (long long)((n - 1) - 1)) -
                          ansv[a] -
                          ((long long)(weight[comp_root[b]]) *
                           (long long)((weight[comp_root[b]]) - 1));
    ansv[b] += ((long long)(n - weight[comp_root[b]]) *
                (long long)((n - weight[comp_root[b]]) - 1)) -
               up_p2_sum;
    comp_root[b] = comp_root[a];
  } else {
    long long down_p2_sum = ((long long)(n - 1) * (long long)((n - 1) - 1)) -
                            ansv[a] -
                            ((long long)(n - weight[comp_root[a]]) *
                             (long long)((n - weight[comp_root[a]]) - 1));
    ansv[b] += ((long long)(weight[comp_root[a]]) *
                (long long)((weight[comp_root[a]]) - 1)) -
               down_p2_sum;
  }
  ans += (long long)(comp_members[b].size()) * ansv[b];
  comp_members[a].clear();
}
void merge_chain(int from, int to) {
  while (comp[from] != comp[to]) {
    from = comp_root[comp[from]];
    merge_comp(comp[from], comp[parent[from]]);
  }
}
void dfs(int node, int prt) {
  ansv[node] += ((long long)(n - 1) * (long long)((n - 1) - 1));
  depth[node] = depth[prt] + 1;
  parent[node] = prt;
  weight[node] = 1;
  for (int i = 0; i < graph[node].size(); i++) {
    int nxt = graph[node][i];
    if (nxt == prt) continue;
    dfs(nxt, node);
    weight[node] += weight[nxt];
    ansv[node] -= ((long long)(weight[nxt]) * (long long)((weight[nxt]) - 1));
  }
  long long above = n - weight[node];
  ansv[node] -= ((long long)(above) * (long long)((above)-1));
  ans += ansv[node];
}
int lca(int A, int B) {
  if (depth[A] < depth[B]) swap(A, B);
  for (int i = 0; i < 17; i++) {
    if ((depth[A] - depth[B]) & (1 << i)) A = ancestor[A][i];
  }
  if (A == B) return A;
  for (int i = 17 - 1; i >= 0; i--) {
    if (ancestor[A][i] != ancestor[B][i]) {
      A = ancestor[A][i];
      B = ancestor[B][i];
    }
  }
  return parent[A];
}
void inputtree(int siz, int root = 1) {
  for (int i = 1; i < siz; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  dfs(root, 0);
  for (int i = 1; i <= siz; i++) ancestor[i][0] = parent[i];
  for (int pwr = 1; pwr < 17; pwr++) {
    for (int i = 1; i <= siz; i++) {
      ancestor[i][pwr] = ancestor[ancestor[i][pwr - 1]][pwr - 1];
    }
  }
}
int main() {
  scanf("%d", &n);
  inputtree(n);
  for (int i = 1; i <= n; i++) {
    comp[i] = i;
    comp_members[i].push_back(i);
    comp_root[i] = i;
  }
  printf("%lld\n", ans);
  scanf("%d", &q);
  for (int qry = 1; qry <= q; qry++) {
    int u, v;
    scanf("%d%d", &u, &v);
    int lcanode = lca(u, v);
    merge_chain(u, lcanode);
    merge_chain(v, lcanode);
    printf("%lld\n", ans);
  }
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.

A snake is a pattern on a n by m table. Denote c-th cell of r-th row as (r, c). The tail of the snake is located at (1, 1), then it's body extends to (1, m), then goes down 2 rows to (3, m), then goes left to (3, 1) and so on.

Your task is to draw this snake for Fox Ciel: the empty cells should be represented as dot characters ('.') and the snake cells should be filled with number signs ('#').

Consider sample tests in order to understand the snake pattern.

Input

The only line contains two integers: n and m (3 ≤ n, m ≤ 50).

n is an odd number.

Output

Output n lines. Each line should contain a string consisting of m characters. Do not output spaces.

Examples

Input

3 3

Output

###
..#
###

Input

3 4

Output

####
...#
####

Input

5 3

Output

###
..#
###
#..
###

Input

9 9

Output

#########
........#
#########
#........
#########
........#
#########
#........
#########

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (i % 2 == 1) {
        if (i % 4 == 1)
          if (j == m - 1)
            cout << '#';
          else
            cout << '.';
        else if (j == 0)
          cout << '#';
        else
          cout << '.';
      } else
        cout << '#';
    }
    cout << endl;
  }
}

```


### Prompt

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

The Little Elephant loves the LCM (least common multiple) operation of a non-empty set of positive integers. The result of the LCM operation of k positive integers x1, x2, ..., xk is the minimum positive integer that is divisible by each of numbers xi.

Let's assume that there is a sequence of integers b1, b2, ..., bn. Let's denote their LCMs as lcm(b1, b2, ..., bn) and the maximum of them as max(b1, b2, ..., bn). The Little Elephant considers a sequence b good, if lcm(b1, b2, ..., bn) = max(b1, b2, ..., bn).

The Little Elephant has a sequence of integers a1, a2, ..., an. Help him find the number of good sequences of integers b1, b2, ..., bn, such that for all i (1 ≤ i ≤ n) the following condition fulfills: 1 ≤ bi ≤ ai. As the answer can be rather large, print the remainder from dividing it by 1000000007 (109 + 7).

Input

The first line contains a single positive integer n (1 ≤ n ≤ 105) — the number of integers in the sequence a. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 105) — sequence a.

Output

In the single line print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

Examples

Input

4
1 4 3 2

Output

15

Input

2
6 3

Output

13

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, M = 1e9 + 7;
int n, a[N];
long long bigmod(long long b, long long p) {
  long long t = 1;
  for (; p; b = (b * b) % M, p >>= 1)
    if (p & 1) t = (t * b) % M;
  return t;
}
long long go(int now) {
  vector<int> div;
  for (int i = 1; i * i <= now; i++) {
    if (now % i == 0) {
      div.push_back(i);
      if (i * i != now) div.push_back(now / i);
    }
  }
  div.push_back(N);
  sort(div.begin(), div.end());
  long long last = 1, cur = 1;
  for (int i = 0; i < div.size() - 1; i++) {
    int x = lower_bound(a, a + n, div[i]) - a;
    int y = lower_bound(a, a + n, div[i + 1]) - a;
    long long tmp = bigmod(i + 1, y - x);
    cur *= tmp;
    cur %= M;
  }
  int sz = div.size() - 2;
  div.erase(div.begin() + sz);
  for (int i = 0; i < div.size() - 1; i++) {
    int x = lower_bound(a, a + n, div[i]) - a;
    int y = lower_bound(a, a + n, div[i + 1]) - a;
    long long tmp = bigmod(i + 1, y - x);
    last *= tmp;
    last %= M;
  }
  return (cur - last + M) % M;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long ans = 1;
  for (int i = 1; i < N; i++) {
    ans += go(i);
    ans %= M;
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

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

Given an integer x. Your task is to find out how many positive integers n (1 ≤ n ≤ x) satisfy $$$n ⋅ a^n ≡ b   (mod\;p), where a, b, p$$$ are all known constants.

Input

The only line contains four integers a,b,p,x (2 ≤ p ≤ 10^6+3, 1 ≤ a,b < p, 1 ≤ x ≤ 10^{12}). It is guaranteed that p is a prime.

Output

Print a single integer: the number of possible answers n.

Examples

Input

2 3 5 8

Output

2

Input

4 6 7 13

Output

1

Input

233 233 10007 1

Output

1

Note

In the first sample, we can see that n=2 and n=8 are possible answers.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int p;
int a, b;
long long x, l, rez;
int lgpow(int b, int e, int MOD) {
  int p = 1;
  while (e) {
    if (e & 1) {
      p = 1LL * p * b % MOD;
    }
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return p;
}
int main() {
  cin >> a >> b >> p >> x;
  for (int r1 = 0; r1 < p - 1; r1++) {
    int r2 = 1LL * lgpow(lgpow(a, p - 2, p), r1, p) * b % p;
    long long n =
        (1LL * r1 * p + 1LL * r2 * (p - 1) * (p - 1)) % (1LL * (p - 1) * p);
    if (n > x) {
      continue;
    }
    long long l = (x - n) / (1LL * (p) * (p - 1)) + 1;
    rez += l;
  }
  cout << rez;
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Silver Fox is fighting with N monsters.

The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i.

Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health.

Silver Fox wins when all the monsters' healths become 0 or below.

Find the minimum number of bombs needed to win.

Constraints

* 1 \leq N \leq 2 \times 10^5
* 0 \leq D \leq 10^9
* 1 \leq A \leq 10^9
* 0 \leq X_i \leq 10^9
* 1 \leq H_i \leq 10^9
* X_i are distinct.
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N D A
X_1 H_1
:
X_N H_N

Output

Print the minimum number of bombs needed to win.

Examples

Input

3 3 2
1 2
5 4
9 2

Output

2

Input

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

Output

5

Input

3 0 1
300000000 1000000000
100000000 1000000000
200000000 1000000000

Output

3000000000

### Response

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

using namespace std;

typedef long long ll;
typedef pair <int, int> P;
int main(){

  ll n,d,a;
  cin >>n>>d>>a;
  vector<pair<ll,ll> >x;
  for (ll i=0; i<n; i++){
    ll x1,h1;
    cin>>x1>>h1;
    x.push_back(make_pair(x1,h1));
  }
  queue <pair<ll, ll> > q;
  ll cnt=0;
  ll damage=0;
  sort(x.begin(), x.end());

  for (ll i=0; i<n; i++){

    while(q.size() && q.front().first<x[i].first){
      damage-=q.front().second;
      q.pop();
    }
    if (x[i].second<=damage) continue;

    ll attack=ceil(double(x[i].second-damage)/a);
    cnt+=attack;
    q.push(make_pair(x[i].first+2*d,attack*a));

    damage+=attack*a;

}
cout<<cnt<<endl;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game.

Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards except for Borya himself. Borya knows which cards he has but he knows nothing about the order they lie in. Note that Borya can have multiple identical cards (and for each of the 25 types of cards he knows exactly how many cards of this type he has).

The aim of the other players is to achieve the state when Borya knows the color and number value of each of his cards. For that, other players can give him hints. The hints can be of two types: color hints and value hints.

A color hint goes like that: a player names some color and points at all the cards of this color.

Similarly goes the value hint. A player names some value and points at all the cards that contain the value.

Determine what minimum number of hints the other players should make for Borya to be certain about each card's color and value.

Input

The first line contains integer n (1 ≤ n ≤ 100) — the number of Borya's cards. The next line contains the descriptions of n cards. The description of each card consists of exactly two characters. The first character shows the color (overall this position can contain five distinct letters — R, G, B, Y, W). The second character shows the card's value (a digit from 1 to 5). Borya doesn't know exact order of the cards they lie in.

Output

Print a single integer — the minimum number of hints that the other players should make.

Examples

Input

2
G3 G3

Output

0

Input

4
G4 R4 R3 B3

Output

2

Input

5
B1 Y1 W1 G1 R1

Output

4

Note

In the first sample Borya already knows for each card that it is a green three.

In the second sample we can show all fours and all red cards.

In the third sample you need to make hints about any four colors.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
vector<bitset<10>> cards;
bool query(int hint) {
  bitset<10> hintBit(hint);
  vector<int> noHint, oneHint[10];
  for (int i = 0; i < n; i++) {
    bitset<10> matched = hintBit & cards[i];
    if (matched.count() == 1) {
      for (int j = 0; j < 10; j++)
        if (matched.test(j)) oneHint[j].push_back(i);
    } else if (matched.count() == 0)
      noHint.push_back(i);
  }
  for (int i = 0; i < 10; i++)
    for (int j = 1; j < oneHint[i].size(); j++)
      if (cards[oneHint[i][0]] != cards[oneHint[i][j]]) return false;
  for (int i = 1; i < noHint.size(); i++)
    if (cards[noHint[0]] != cards[noHint[i]]) return false;
  return true;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    bitset<10> now(0);
    switch (str[0]) {
      case 'R':
        now[0] = true;
        break;
      case 'G':
        now[1] = true;
        break;
      case 'B':
        now[2] = true;
        break;
      case 'Y':
        now[3] = true;
        break;
      case 'W':
        now[4] = true;
        break;
    }
    now[str[1] - '0' + 4] = true;
    cards.push_back(now);
  }
  size_t ans = 999;
  for (int i = 0; i < (1 << 10); i++)
    if (query(i)) ans = min(ans, bitset<10>(i).count());
  cout << ans;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

You are going to eat X red apples and Y green apples.
You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C.
Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively.
From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible.
Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.

Constraints

* 1 \leq X \leq A \leq 10^5
* 1 \leq Y \leq B \leq 10^5
* 1 \leq C \leq 10^5
* 1 \leq p_i \leq 10^9
* 1 \leq q_i \leq 10^9
* 1 \leq r_i \leq 10^9
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

X Y A B C
p_1 p_2 ... p_A
q_1 q_2 ... q_B
r_1 r_2 ... r_C

Output

Print the maximum possible sum of the deliciousness of the eaten apples.

Examples

Input

1 2 2 2 1
2 4
5 1
3

Output

12

Input

2 2 2 2 2
8 6
9 1
2 1

Output

25

Input

2 2 4 4 4
11 12 13 14
21 22 23 24
1 2 3 4

Output

74

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	long long red[a],blue[b],i;
	for(i=0 ; i<a ; i++) cin>>red[i];
	for(i=0 ; i<b ; i++) cin>>blue[i];
	vector <long long> res;
	for(i=0 ; i<c ; i++){
		long long x;
		cin>>x;
		res.push_back(x);
	}
	sort(red,red+a,greater<long long>());
	sort(blue,blue+b,greater<long long>());
	for(i=0 ; i<x ; i++) res.push_back(red[i]);
	for(i=0 ; i<y ; i++) res.push_back(blue[i]);
	sort(res.begin(),res.end(),greater <long long> ());
	long long ans=0;
	for(i=0 ; i<x+y ; i++) ans+=res[i];
	cout<<ans<<endl;
	return 0;
}
```


### Prompt

Please create a solution in cpp to the following problem:

Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.

To compress the string, you have to represent s as a concatenation of several non-empty strings: s = t_{1} t_{2} … t_{k}. The i-th of these strings should be encoded with one of the two ways:

  * if |t_{i}| = 1, meaning that the current string consists of a single character, you can encode it paying a coins;
  * if t_{i} is a substring of t_{1} t_{2} … t_{i - 1}, then you can encode it paying b coins.

A string x is a substring of a string y if x can be obtained from y by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.

So your task is to calculate the minimum possible number of coins you need to spend in order to compress the given string s.

Input

The first line contains three positive integers, separated by spaces: n, a and b (1 ≤ n, a, b ≤ 5000) — the length of the string, the cost to compress a one-character string and the cost to compress a string that appeared before.

The second line contains a single string s, consisting of n lowercase English letters.

Output

Output a single integer — the smallest possible number of coins you need to spend to compress s.

Examples

Input

3 3 1
aba

Output

7

Input

4 1 1
abcd

Output

4

Input

4 10 1
aaaa

Output

12

Note

In the first sample case, you can set t_{1} = 'a', t_{2} = 'b', t_{3} = 'a' and pay 3 + 3 + 1 = 7 coins, since t_{3} is a substring of t_{1}t_{2}.

In the second sample, you just need to compress every character by itself.

In the third sample, you set t_{1} = t_{2} = 'a', t_{3} = 'aa' and pay 10 + 1 + 1 = 12 coins, since t_{2} is a substring of t_{1} and t_{3} is a substring of t_{1} t_{2}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int lcs[5005][5005], n, a, b, f[5005];
char s[5005];
inline int read() {
  int ret = 0, ff = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') ff = -ff;
    ch = getchar();
  }
  while (isdigit(ch)) {
    ret = (ret << 3) + (ret << 1) + (ch ^ 48);
    ch = getchar();
  }
  return ret * ff;
}
signed main() {
  n = read(), a = read(), b = read();
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      lcs[i][j] = (s[i] == s[j]) ? lcs[i - 1][j - 1] + 1 : 0;
  memset(f, 0x3f, sizeof(f));
  f[0] = 0;
  for (int i = 1; i <= n; i++) {
    f[i] = f[i - 1] + a;
    for (int j = i - 1; j >= 1; j--)
      f[i] = min(f[i], f[i - min(lcs[i][j], i - j)] + b);
  }
  printf("%d", f[n]);
  return 0;
}

```


### Prompt

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

You want to perform the combo on your opponent in one popular fighting game. The combo is the string s consisting of n lowercase Latin letters. To perform the combo, you have to press all buttons in the order they appear in s. I.e. if s="abca" then you have to press 'a', then 'b', 'c' and 'a' again.

You know that you will spend m wrong tries to perform the combo and during the i-th try you will make a mistake right after p_i-th button (1 ≤ p_i < n) (i.e. you will press first p_i buttons right and start performing the combo from the beginning). It is guaranteed that during the m+1-th try you press all buttons right and finally perform the combo.

I.e. if s="abca", m=2 and p = [1, 3] then the sequence of pressed buttons will be 'a' (here you're making a mistake and start performing the combo from the beginning), 'a', 'b', 'c', (here you're making a mistake and start performing the combo from the beginning), 'a' (note that at this point you will not perform the combo because of the mistake), 'b', 'c', 'a'.

Your task is to calculate for each button (letter) the number of times you'll press it.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases.

Then t test cases follow.

The first line of each test case contains two integers n and m (2 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ m ≤ 2 ⋅ 10^5) — the length of s and the number of tries correspondingly.

The second line of each test case contains the string s consisting of n lowercase Latin letters.

The third line of each test case contains m integers p_1, p_2, ..., p_m (1 ≤ p_i < n) — the number of characters pressed right during the i-th try.

It is guaranteed that the sum of n and the sum of m both does not exceed 2 ⋅ 10^5 (∑ n ≤ 2 ⋅ 10^5, ∑ m ≤ 2 ⋅ 10^5).

It is guaranteed that the answer for each letter does not exceed 2 ⋅ 10^9.

Output

For each test case, print the answer — 26 integers: the number of times you press the button 'a', the number of times you press the button 'b', ..., the number of times you press the button 'z'.

Example

Input

3
4 2
abca
1 3
10 5
codeforces
2 8 3 2 9
26 10
qwertyuioplkjhgfdsazxcvbnm
20 10 1 2 3 5 10 5 9 4

Output

4 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 9 4 5 3 0 0 0 0 0 0 0 0 9 0 0 3 1 0 0 0 0 0 0 0
2 1 1 2 9 2 2 2 5 2 2 2 1 1 5 4 11 8 2 7 5 1 10 1 5 2

Note

The first test case is described in the problem statement. Wrong tries are "a", "abc" and the final try is "abca". The number of times you press 'a' is 4, 'b' is 2 and 'c' is 2.

In the second test case, there are five wrong tries: "co", "codeforc", "cod", "co", "codeforce" and the final try is "codeforces". The number of times you press 'c' is 9, 'd' is 4, 'e' is 5, 'f' is 3, 'o' is 9, 'r' is 3 and 's' is 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
const int mod = 1e9 + 7;
int a[N], b[N];
int dp[N][10] = {0};
int mark[N] = {0};
map<int, int> mp;
int t = 1, cas = 1, ans[30], n, m, p, k;
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> m;
    string s;
    cin >> s;
    for (int i = 0; i < m; i++) {
      cin >> a[i];
    }
    memset(mark, 0, sizeof(mark));
    memset(ans, 0, sizeof(ans));
    sort(a, a + m);
    for (int i = 0; i < n; i++) {
      mark[s[i] - 'a']++;
      int pos = m - (lower_bound(a, a + m, i + 1) - a);
      ans[s[i] - 'a'] += pos;
    }
    for (int i = 0; i < 26; i++) cout << ans[i] + mark[i] << " ";
    cout << "\n";
  }
  return 0;
}

```


### Prompt

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

Berland is facing dark times again. The army of evil lord Van de Mart is going to conquer the whole kingdom. To the council of war called by the Berland's king Valery the Severe came n knights. After long discussions it became clear that the kingdom has exactly n control points (if the enemy conquers at least one of these points, the war is lost) and each knight will occupy one of these points.

Berland is divided into m + 1 regions with m fences, and the only way to get from one region to another is to climb over the fence. Each fence is a circle on a plane, no two fences have common points, and no control point is on the fence. You are given k pairs of numbers ai, bi. For each pair you have to find out: how many fences a knight from control point with index ai has to climb over to reach control point bi (in case when Van de Mart attacks control point bi first). As each knight rides a horse (it is very difficult to throw a horse over a fence), you are to find out for each pair the minimum amount of fences to climb over.

Input

The first input line contains three integers n, m, k (1 ≤ n, m ≤ 1000, 0 ≤ k ≤ 100000). Then follow n lines, each containing two integers Kxi, Kyi ( - 109 ≤ Kxi, Kyi ≤ 109) — coordinates of control point with index i. Control points can coincide.

Each of the following m lines describes fence with index i with three integers ri, Cxi, Cyi (1 ≤ ri ≤ 109,  - 109 ≤ Cxi, Cyi ≤ 109) — radius and center of the circle where the corresponding fence is situated.

Then follow k pairs of integers ai, bi (1 ≤ ai, bi ≤ n), each in a separate line — requests that you have to answer. ai and bi can coincide.

Output

Output exactly k lines, each containing one integer — the answer to the corresponding request.

Examples

Input

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

Output

1

Input

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

Output

3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1005;
long long x[maxn], y[maxn], xx[maxn], yy[maxn], r[maxn], num[maxn][maxn];
int main() {
  long long n, m, k;
  scanf("%lld%lld%lld", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &x[i], &y[i]);
  for (int i = 1; i <= m; i++) scanf("%lld%lld%lld", &r[i], &xx[i], &yy[i]);
  long long d;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      d = (x[i] - xx[j]) * (x[i] - xx[j]) + (y[i] - yy[j]) * (y[i] - yy[j]);
      if (d < r[j] * r[j]) num[i][j] = 1;
    }
  }
  long long a, b, sum;
  while (k--) {
    sum = 0;
    scanf("%lld%lld", &a, &b);
    for (int i = 1; i <= m; i++)
      if (num[a][i] != num[b][i]) sum++;
    printf("%lld\n", sum);
  }
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.

After struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.

Ujan has two distinct strings s and t of length n consisting of only of lowercase English characters. He wants to make them equal. Since Ujan is lazy, he will perform the following operation exactly once: he takes two positions i and j (1 ≤ i,j ≤ n, the values i and j can be equal or different), and swaps the characters s_i and t_j. Can he succeed?

Note that he has to perform this operation exactly once. He has to perform this operation.

Input

The first line contains a single integer k (1 ≤ k ≤ 10), the number of test cases.

For each of the test cases, the first line contains a single integer n (2 ≤ n ≤ 10^4), the length of the strings s and t.

Each of the next two lines contains the strings s and t, each having length exactly n. The strings consist only of lowercase English letters. It is guaranteed that strings are different.

Output

For each test case, output "Yes" if Ujan can make the two strings equal and "No" otherwise.

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

Example

Input

4
5
souse
houhe
3
cat
dog
2
aa
az
3
abc
bca

Output

Yes
No
No
No

Note

In the first test case, Ujan can swap characters s_1 and t_4, obtaining the word "house".

In the second test case, it is not possible to make the strings equal using exactly one swap of s_i and t_j.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string a;
    string b;
    cin >> a;
    cin >> b;
    char ch1, ch2;
    int s1, s2;
    for (int i = 0, j = 0; i < n; i++, j++) {
      if (a[i] != b[j]) {
        s1 = i;
        ch1 = a[s1];
        break;
      }
    }
    for (int i = 0, j = 0; i < n; i++, j++) {
      if (a[i] != b[j]) {
        s2 = j;
        ch2 = b[s2];
      }
    }
    for (int i = 0; i < n; i++) {
      if (a[i] == ch1) {
        a[s1] = ch2;
        break;
      }
    }
    for (int i = 0; i < n; i++) {
      if (b[i] == ch2) {
        b[s2] = ch1;
        break;
      }
    }
    if (a == b) {
      cout << "Yes" << endl;
    } else
      cout << "No" << endl;
  }
}

```


### Prompt

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

I guess there's not much point in reminding you that Nvodsk winters aren't exactly hot. That increased the popularity of the public transport dramatically. The route of bus 62 has exactly n stops (stop 1 goes first on its way and stop n goes last). The stops are positioned on a straight line and their coordinates are 0 = x1 < x2 < ... < xn.

Each day exactly m people use bus 62. For each person we know the number of the stop where he gets on the bus and the number of the stop where he gets off the bus. A ticket from stop a to stop b (a < b) costs xb - xa rubles. However, the conductor can choose no more than one segment NOT TO SELL a ticket for. We mean that conductor should choose C and D (С <= D) and sell a ticket for the segments [A, C] and [D, B], or not sell the ticket at all. The conductor and the passenger divide the saved money between themselves equally. The conductor's "untaxed income" is sometimes interrupted by inspections that take place as the bus drives on some segment of the route located between two consecutive stops. The inspector fines the conductor by c rubles for each passenger who doesn't have the ticket for this route's segment.

You know the coordinated of all stops xi; the numbers of stops where the i-th passenger gets on and off, ai and bi (ai < bi); the fine c; and also pi — the probability of inspection on segment between the i-th and the i + 1-th stop. The conductor asked you to help him make a plan of selling tickets that maximizes the mathematical expectation of his profit.

Input

The first line contains three integers n, m and c (2 ≤ n ≤ 150 000, 1 ≤ m ≤ 300 000, 1 ≤ c ≤ 10 000).

The next line contains n integers xi (0 ≤ xi ≤ 109, x1 = 0, xi < xi + 1) — the coordinates of the stops on the bus's route.

The third line contains n - 1 integer pi (0 ≤ pi ≤ 100) — the probability of inspection in percents on the segment between stop i and stop i + 1.

Then follow m lines that describe the bus's passengers. Each line contains exactly two integers ai and bi (1 ≤ ai < bi ≤ n) — the numbers of stops where the i-th passenger gets on and off.

Output

Print the single real number — the maximum expectation of the conductor's profit. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if <image>.

Examples

Input

3 3 10
0 10 100
100 0
1 2
2 3
1 3

Output

90.000000000

Input

10 8 187
0 10 30 70 150 310 630 1270 2550 51100
13 87 65 0 100 44 67 3 4
1 10
2 9
3 8
1 5
6 10
2 7
4 10
4 5

Output

76859.990000000

Note

A comment to the first sample:

The first and third passengers get tickets from stop 1 to stop 2. The second passenger doesn't get a ticket. There always is inspection on the segment 1-2 but both passengers have the ticket for it. There never is an inspection on the segment 2-3, that's why the second passenger gets away with the cheating. Our total profit is (0 + 90 / 2 + 90 / 2) = 90.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 150005;
struct seg {
  int l, r;
  double sum, maxl, maxr, _max;
} tree[MAXN * 4];
double A[MAXN];
void update(int fa) {
  if (tree[fa].l + 1 >= tree[fa].r) return;
  tree[fa].sum = tree[2 * (fa)].sum + tree[2 * (fa) + 1].sum;
  tree[fa].maxl =
      max(tree[2 * (fa)].maxl, tree[2 * (fa)].sum + tree[2 * (fa) + 1].maxl);
  tree[fa].maxr = max(tree[2 * (fa) + 1].maxr,
                      tree[2 * (fa) + 1].sum + tree[2 * (fa)].maxr);
  tree[fa]._max = max(tree[2 * (fa)]._max, tree[2 * (fa) + 1]._max);
  tree[fa]._max =
      max(tree[fa]._max, tree[2 * (fa)].maxr + tree[2 * (fa) + 1].maxl);
}
void buildTree(int fa, int l, int r) {
  int mid = (l + r) >> 1;
  tree[fa].l = l;
  tree[fa].r = r;
  if (r - l <= 1) {
    tree[fa].sum = A[l];
    tree[fa].maxl = tree[fa].maxr = tree[fa]._max = A[l];
    return;
  }
  buildTree(2 * (fa), l, mid);
  buildTree(2 * (fa) + 1, mid, r);
  update(fa);
}
seg combine(seg a, seg b) {
  seg res;
  res.l = a.l;
  res.r = b.r;
  res.sum = a.sum + b.sum;
  res.maxl = max(a.maxl, a.sum + b.maxl);
  res.maxr = max(b.maxr, b.sum + a.maxr);
  res._max = max(a._max, b._max);
  res._max = max(res._max, a.maxr + b.maxl);
  return res;
}
seg query(int fa, int l, int r) {
  int mid = (tree[fa].l + tree[fa].r) >> 1;
  if (tree[fa].l == l && tree[fa].r == r) {
    seg res;
    res.l = tree[fa].l;
    res.r = tree[fa].r;
    res.sum = tree[fa].sum;
    res.maxl = tree[fa].maxl;
    res.maxr = tree[fa].maxr;
    res._max = tree[fa]._max;
    return res;
  }
  if (r <= mid) {
    return query(2 * (fa), l, r);
  } else if (l >= mid) {
    return query(2 * (fa) + 1, l, r);
  } else {
    seg segL = query(2 * (fa), l, mid);
    seg segR = query(2 * (fa) + 1, mid, r);
    seg res = combine(segL, segR);
    return res;
  }
}
int N, M, C;
double P[MAXN], D[MAXN];
int main() {
  scanf("%d %d %d", &N, &M, &C);
  for (int i = 1; i <= N; ++i) {
    scanf("%lf", &D[i]);
  }
  for (int i = 1; i < N; ++i) {
    scanf("%lf", &P[i]);
  }
  for (int i = 1; i < N; ++i) {
    A[i] = (D[i + 1] - D[i]) / 2 - P[i] / 100 * C;
  }
  buildTree(1, 1, N);
  int l, r;
  double ans = 0;
  for (int i = 1; i <= M; ++i) {
    scanf("%d %d", &l, &r);
    seg s = query(1, l, r);
    ans += max(s._max, 0.0);
  }
  printf("%.9lf\n", ans);
}

```


### Prompt

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

Demiurges Shambambukli and Mazukta love to watch the games of ordinary people. Today, they noticed two men who play the following game.

There is a rooted tree on n nodes, m of which are leaves (a leaf is a nodes that does not have any children), edges of the tree are directed from parent to children. In the leaves of the tree integers from 1 to m are placed in such a way that each number appears exactly in one leaf.

Initially, the root of the tree contains a piece. Two players move this piece in turns, during a move a player moves the piece from its current nodes to one of its children; if the player can not make a move, the game ends immediately. The result of the game is the number placed in the leaf where a piece has completed its movement. The player who makes the first move tries to maximize the result of the game and the second player, on the contrary, tries to minimize the result. We can assume that both players move optimally well.

Demiurges are omnipotent, so before the game they can arbitrarily rearrange the numbers placed in the leaves. Shambambukli wants to rearrange numbers so that the result of the game when both players play optimally well is as large as possible, and Mazukta wants the result to be as small as possible. What will be the outcome of the game, if the numbers are rearranged by Shambambukli, and what will it be if the numbers are rearranged by Mazukta? Of course, the Demiurges choose the best possible option of arranging numbers.

Input

The first line contains a single integer n — the number of nodes in the tree (1 ≤ n ≤ 2·105).

Each of the next n - 1 lines contains two integers ui and vi (1 ≤ ui, vi ≤ n) — the ends of the edge of the tree; the edge leads from node ui to node vi. It is guaranteed that the described graph is a rooted tree, and the root is the node 1.

Output

Print two space-separated integers — the maximum possible and the minimum possible result of the game.

Examples

Input

5
1 2
1 3
2 4
2 5

Output

3 2

Input

6
1 2
1 3
3 4
1 5
5 6

Output

3 3

Note

Consider the first sample. The tree contains three leaves: 3, 4 and 5. If we put the maximum number 3 at node 3, then the first player moves there and the result will be 3. On the other hand, it is easy to see that for any rearrangement the first player can guarantee the result of at least 2.

In the second sample no matter what the arragment is the first player can go along the path that ends with a leaf with number 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int dp[200000][2];
int sz[200000];
int n;
int INF = 1 << 30;
vector<int> g[200000];
void solve(int v, int ver, int h, int par) {
  if (g[v].size() == 1 && par != -1) {
    dp[v][ver] = 1;
    sz[v] = 1;
    return;
  }
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (to == par) continue;
    solve(to, ver, h + 1, v);
    if (ver == 0) sz[v] += sz[to];
  }
  if (ver == 0) {
    int lefts = 0;
    int maxCan = INF;
    int minCan = 1;
    for (int i = 0; i < g[v].size(); i++) {
      int to = g[v][i];
      if (to == par) continue;
      maxCan = min(maxCan, sz[to] - dp[to][ver]);
      minCan += dp[to][ver] - 1;
    }
    if (h % 2 == 0)
      dp[v][ver] = sz[v] - maxCan;
    else
      dp[v][ver] = minCan;
  } else {
    int minCan = INF;
    int maxCan = 0;
    for (int i = 0; i < g[v].size(); i++) {
      int to = g[v][i];
      if (to == par) continue;
      minCan = min(minCan, dp[to][ver]);
      maxCan += sz[to] - dp[to][ver];
    }
    if (h % 2 == 0)
      dp[v][ver] = sz[v] - maxCan;
    else
      dp[v][ver] = minCan;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  if (n == 1) {
    cout << "1 1";
    return 0;
  }
  for (int i = 1; i < n; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    g[l].push_back(r);
    g[r].push_back(l);
  }
  solve(0, 0, 0, -1);
  solve(0, 1, 0, -1);
  cout << dp[0][0] << " " << dp[0][1] << endl;
  return 0;
}

```


### Prompt

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

Sonya was unable to think of a story for this problem, so here comes the formal description.

You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array strictly increasing by making the minimum possible number of operations. You are allowed to change elements in any way, they can become negative or equal to 0.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 3000) — the length of the array.

Next line contains n integer ai (1 ≤ ai ≤ 109).

Output

Print the minimum number of operation required to make the array strictly increasing.

Examples

Input

7
2 1 5 11 5 9 11

Output

9

Input

5
5 4 3 2 1

Output

12

Note

In the first sample, the array is going to look as follows:

2 3 5 6 7 9 11

|2 - 2| + |1 - 3| + |5 - 5| + |11 - 6| + |5 - 7| + |9 - 9| + |11 - 11| = 9

And for the second sample:

1 2 3 4 5

|5 - 1| + |4 - 2| + |3 - 3| + |2 - 4| + |1 - 5| = 12

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int xx[] = {0, 0, 1, -1};
long long int yy[] = {1, -1, 0, 0};
int main() {
  long long int n;
  cin >> n;
  long long int a[n + 1], b[n + 1];
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] -= i;
  }
  priority_queue<long long int> pq;
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++) {
    pq.push(a[i]);
    if (pq.top() > a[i]) {
      long long int to = pq.top();
      pq.pop();
      ans += to - a[i];
      pq.push(a[i]);
    }
  }
  cout << ans << endl;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

The courier charges for a courier company are set according to size and weight as shown in the table below.

A size | B size | C size | D size | E size | F size
--- | --- | --- | --- | --- | --- | ---
Size | 60 cm or less | 80 cm or less | 100 cm or less | 120 cm or less | 140 cm or less | 160 cm or less
Weight | 2kg or less | 5kg or less | 10kg or less | 15kg or less | 20kg or less | 25kg or less
Price | 600 yen | 800 yen | 1000 yen | 1200 yen | 1400 yen | 1600 yen

The size is the sum of the three sides (length, width, height). For example, a baggage that is 120 cm in size and weighs less than 15 kg will be D size (1,200 yen). Even if the size is 120 cm or less, if the weight exceeds 15 kg and 20 kg or less, it will be E size.

Please create a program that outputs the total charge by inputting the information of the luggage brought in in one day. Luggage that exceeds F size is excluded and is not included in the total price.

Input

A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:

n
x1 y1 h1 w1
x2 y2 h2 w2
::
xn yn hn wn

The number of packages n (1 ≤ n ≤ 10000) on the first line, followed by the i-th package on the n lines: vertical length xi, horizontal length yi, height hi, weight wi (1 ≤ xi, yi , hi, wi ≤ 200) are given on one line, separated by blanks.

The number of datasets does not exceed 20.

Output

Outputs the total package charge for each dataset on one line.

Example

Input

2
50 25 5 5
80 60 10 30
3
10 15 25 24
5 8 12 5
30 30 30 18
0

Output

800
3800

### Response

```cpp
#include <iostream>

using namespace std;
int price[6] = {600, 800, 1000, 1200, 1400, 1600};

void solve()
{
	int n;
	while(cin >> n, n)
	{
		int x, y, h, w;
		int pos1 = 0;
		int pos2 = 0;
		int sum = 0;
		while(n--)
		{
			cin >> x >> y >> h >> w;
			int size = x + y + h;
			if(size <= 60)
			{
				pos1 = 0;
			}
			else if(size <= 80)
			{
				pos1 = 1;
			}
			else if(size <= 100)
			{
				pos1 = 2;
			}
			else if(size <= 120)
			{
				pos1 = 3;
			}
			else if(size <= 140)
			{
				pos1 = 4;
			}
			else if(size <= 160)
			{
				pos1 = 5;
			}
			else
			{
				pos1 = 6;
			}

			if(w <= 2)
			{
				pos2 = 0;
			}
			else if(w <= 5)
			{
				pos2 = 1;
			}
			else if(w <= 10)
			{
				pos2 = 2;
			}
			else if(w <= 15)
			{
				pos2 = 3;
			}
			else if(w <= 20)
			{
				pos2 = 4;
			}
			else if(w <= 25)
			{
				pos2 = 5;
			}
			else
			{
				pos2 = 6;
			}
			if(pos1 < pos2)
			{
				swap(pos1, pos2);
			}
			if(pos1 == 6)
			{
				continue;
			}
			sum += price[pos1];
		}
		cout << sum << endl;
	}
}

int main()
{
	solve();
	return(0);
}
```


### Prompt

Generate a cpp solution to the following problem:

The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.

A Bitlandish string is a string made only of characters "0" and "1".

BitHaval (the mayor of Bitland) loves to play with Bitlandish strings. He takes some Bitlandish string a, and applies several (possibly zero) operations to it. In one operation the mayor may take any two adjacent characters of a string, define one of them as x and the other one as y. Then he calculates two values p and q: p = x xor y, q = x or y. Then he replaces one of the two taken characters by p and the other one by q.

The xor operation means the bitwise excluding OR operation. The or operation is the bitwise OR operation.

So for example one operation can transform string 11 to string 10 or to string 01. String 1 cannot be transformed into any other string.

You've got two Bitlandish strings a and b. Your task is to check if it is possible for BitHaval to transform string a to string b in several (possibly zero) described operations.

Input

The first line contains Bitlandish string a, the second line contains Bitlandish string b. The strings can have different lengths.

It is guaranteed that the given strings only consist of characters "0" and "1". The strings are not empty, their length doesn't exceed 106.

Output

Print "YES" if a can be transformed into b, otherwise print "NO". Please do not print the quotes.

Examples

Input

11
10

Output

YES

Input

1
01

Output

NO

Input

000
101

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s, t;
  cin >> s >> t;
  if (s.size() != t.size()) {
    cout << "NO" << '\n';
    return;
  }
  int first = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    first += s[i] == '1';
  }
  int second = 0;
  for (int i = 0; i < (int)t.size(); i++) {
    second += t[i] == '1';
  }
  cout << ((first > 0) ^ (second > 0) ? "NO" : "YES") << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}

```


### Prompt

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

Finally it is a day when Arthur has enough money for buying an apartment. He found a great option close to the center of the city with a nice price.

Plan of the apartment found by Arthur looks like a rectangle n × m consisting of squares of size 1 × 1. Each of those squares contains either a wall (such square is denoted by a symbol "*" on the plan) or a free space (such square is denoted on the plan by a symbol ".").

Room in an apartment is a maximal connected area consisting of free squares. Squares are considered adjacent if they share a common side.

The old Arthur dream is to live in an apartment where all rooms are rectangles. He asks you to calculate minimum number of walls you need to remove in order to achieve this goal. After removing a wall from a square it becomes a free square. While removing the walls it is possible that some rooms unite into a single one.

Input

The first line of the input contains two integers n, m (1 ≤ n, m ≤ 2000) denoting the size of the Arthur apartments.

Following n lines each contain m symbols — the plan of the apartment.

If the cell is denoted by a symbol "*" then it contains a wall.

If the cell is denoted by a symbol "." then it this cell is free from walls and also this cell is contained in some of the rooms.

Output

Output n rows each consisting of m symbols that show how the Arthur apartment plan should look like after deleting the minimum number of walls in order to make each room (maximum connected area free from walls) be a rectangle.

If there are several possible answers, output any of them.

Examples

Input

5 5
.*.*.
*****
.*.*.
*****
.*.*.

Output

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

Input

6 7
***.*.*
..*.*.*
*.*.*.*
*.*.*.*
..*...*
*******

Output

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

Input

4 5
.....
.....
..***
..*..

Output

.....
.....
.....
.....

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int DIM = 2e3 + 5;
const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int cnt[DIM][DIM];
char mat[DIM][DIM];
deque<pair<int, int>> que;
int main(void) {
  int n, m;
  cin >> n >> m;
  cnt[n + 1][m + 1] = numeric_limits<int>::max();
  for (int i = 1; i <= n; i++) {
    cin >> (mat[i] + 1);
    for (int j = 1; j <= m; j++) {
      if (mat[i][j] == '*') {
        cnt[i][j]++;
        cnt[i + 1][j + 1]++;
        cnt[i + 1][j]++;
        cnt[i][j + 1]++;
      }
      cnt[i][1] = cnt[i][m + 1] = numeric_limits<int>::max();
      cnt[1][j] = cnt[n + 1][j] = numeric_limits<int>::max();
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (mat[i][j] == '.') continue;
      if (cnt[i][j] == 1 || cnt[i + 1][j + 1] == 1 || cnt[i + 1][j] == 1 ||
          cnt[i][j + 1] == 1)
        que.push_back(make_pair(i, j));
    }
  }
  for (; que.empty() == false; que.pop_front()) {
    pair<int, int> x = que.front();
    if (mat[x.first][x.second] == '.') continue;
    mat[x.first][x.second] = '.';
    cnt[x.first][x.second]--;
    cnt[x.first + 1][x.second + 1]--;
    cnt[x.first + 1][x.second]--;
    cnt[x.first][x.second + 1]--;
    for (int d = 0; d <= 7; d++) {
      pair<int, int> y = make_pair(x.first + dx[d], x.second + dy[d]);
      if (y.first < 1 || y.second < 1) continue;
      if (y.first > n || y.second > m) continue;
      if (cnt[y.first][y.second] == 1 || cnt[y.first + 1][y.second + 1] == 1 ||
          cnt[y.first + 1][y.second] == 1 || cnt[y.first][y.second + 1] == 1)
        que.push_back(y);
    }
  }
  for (int i = 1; i <= n; i++) cout << (mat[i] + 1) << endl;
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:

* The graph is simple and connected.
* There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.

It can be proved that at least one such graph exists under the constraints of this problem.

Constraints

* All values in input are integers.
* 3 \leq N \leq 100

Input

Input is given from Standard Input in the following format:

N

Output

In the first line, print the number of edges, M, in the graph you made. In the i-th of the following M lines, print two integers a_i and b_i, representing the endpoints of the i-th edge.

The output will be judged correct if the graph satisfies the conditions.

Example

Input

3

Output

2
1 3
2 3

### Response

```cpp

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100+10;
int n,cnt;
int main(){
	//freopen("a.in","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)if(i+j!=(!(n&1))+n) cnt++;
	cout<<cnt<<endl;
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)if(i+j!=(!(n&1))+n) printf("%d %d\n",i,j);
}
```


### Prompt

Generate a Cpp solution to the following problem:

Recently Monocarp got a job. His working day lasts exactly m minutes. During work, Monocarp wants to drink coffee at certain moments: there are n minutes a_1, a_2, ..., a_n, when he is able and willing to take a coffee break (for the sake of simplicity let's consider that each coffee break lasts exactly one minute).

However, Monocarp's boss doesn't like when Monocarp takes his coffee breaks too often. So for the given coffee break that is going to be on minute a_i, Monocarp must choose the day in which he will drink coffee during the said minute, so that every day at least d minutes pass between any two coffee breaks. Monocarp also wants to take these n coffee breaks in a minimum possible number of working days (he doesn't count days when he is not at work, and he doesn't take coffee breaks on such days). Take into account that more than d minutes pass between the end of any working day and the start of the following working day.

For each of the n given minutes determine the day, during which Monocarp should take a coffee break in this minute. You have to minimize the number of days spent.

Input

The first line contains three integers n, m, d (1 ≤ n ≤ 2⋅10^{5}, n ≤ m ≤ 10^{9}, 1 ≤ d ≤ m) — the number of coffee breaks Monocarp wants to have, the length of each working day, and the minimum number of minutes between any two consecutive coffee breaks.

The second line contains n distinct integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ m), where a_i is some minute when Monocarp wants to have a coffee break.

Output

In the first line, write the minimum number of days required to make a coffee break in each of the n given minutes.

In the second line, print n space separated integers. The i-th of integers should be the index of the day during which Monocarp should have a coffee break at minute a_i. Days are numbered from 1. If there are multiple optimal solutions, you may print any of them.

Examples

Input

4 5 3
3 5 1 2

Output

3
3 1 1 2

Input

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

Output

2
2 1 1 2 2 1 2 1 1 2

Note

In the first example, Monocarp can take two coffee breaks during the first day (during minutes 1 and 5, 3 minutes will pass between these breaks). One break during the second day (at minute 2), and one break during the third day (at minute 3).

In the second example, Monocarp can determine the day of the break as follows: if the minute when he wants to take a break is odd, then this break is on the first day, if it is even, then this break is on the second day.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
long long a[N], ans[N];
pair<long long, long long> b[N];
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    q;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, m, d, k;
  cin >> n >> m >> d;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = {a[i], i};
  }
  sort(b + 1, b + n + 1);
  k = 0;
  for (int i = 1; i <= n; i++) {
    if (q.empty()) {
      ans[b[i].second] = ++k;
      q.push({b[i].first, k});
    } else {
      pair<long long, long long> t = q.top();
      if (t.first + d >= b[i].first) {
        ans[b[i].second] = ++k;
        q.push({b[i].first, k});
      } else {
        q.pop();
        ans[b[i].second] = t.second;
        q.push({b[i].first, t.second});
      }
    }
  }
  cout << k << '\n';
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " \n"[i == n];
  }
}

```


### Prompt

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

For an array a of integers let's denote its maximal element as max(a), and minimal as min(a). We will call an array a of k integers interesting if max(a) - min(a) ≥ k. For example, array [1, 3, 4, 3] isn't interesting as max(a) - min(a) = 4 - 1 = 3 < 4 while array [7, 3, 0, 4, 3] is as max(a) - min(a) = 7 - 0 = 7 ≥ 5.

You are given an array a of n integers. Find some interesting nonempty subarray of a, or tell that it doesn't exist.

An array b is a subarray of an array a if b can be obtained from a by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. In particular, an array is a subarray of itself.

Input

The first line contains integer number t (1 ≤ t ≤ 10 000). Then t test cases follow.

The first line of each test case contains a single integer n (2≤ n ≤ 2⋅ 10^5) — the length of the array.

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

It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.

Output

For each test case, output "NO" in a separate line if there is no interesting nonempty subarray in a.

Otherwise, output "YES" in a separate line. In the next line, output two integers l and r (1≤ l ≤ r ≤ n) — bounds of the chosen subarray. If there are multiple answers, print any.

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

Example

Input

3
5
1 2 3 4 5
4
2 0 1 9
2
2019 2020

Output

NO
YES
1 4
NO

Note

In the second test case of the example, one of the interesting subarrays is a = [2, 0, 1, 9]: max(a) - min(a) = 9 - 0 = 9 ≥ 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[200005];
    int minn = 1000000000, maxx = 0;
    int l, r;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int flag = 0;
    for (int i = 1; i < n; i++)
      if (abs(a[i] - a[i + 1]) >= 2) {
        l = i;
        r = i + 1;
        flag = 1;
        break;
      }
    if (flag) {
      cout << "YES" << endl;
      cout << l << " " << r << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}

```


### Prompt

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

Given is a string S of length N-1. Each character in S is `<` or `>`.

A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \leq i \leq N-1):

* If S_i= `<`: a_i<a_{i+1}
* If S_i= `>`: a_i>a_{i+1}

Find the minimum possible sum of the elements of a good sequence of N non-negative integers.

Constraints

* 2 \leq N \leq 5 \times 10^5
* S is a string of length N-1 consisting of `<` and `>`.

Input

Input is given from Standard Input in the following format:

S

Output

Find the minimum possible sum of the elements of a good sequence of N non-negative integers.

Examples

Input

<>>

Output

3

Input

<>>><<><<<<<>>><

Output

28

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 500000 + 10;
char s[N];
int main(){
    scanf("%s",s);
    int n = strlen(s);
    long long ans = 0;
    for(int i=0;i<n;i++){
        int x = 0, y = 0;
        while(i+x<n&&s[i+x]=='<') x++;
        while(i+x+y<n&&s[i+x+y]=='>') y++;
        i += x + y - 1;
        if(x>y) swap(x,y);
        y++;
        ans += 1ll * x * (x-1) / 2 + 1ll * y * (y-1) / 2;
    }
    printf("%lld\n",ans);
}

```


### Prompt

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

Your math teacher gave you the following problem:

There are n segments on the x-axis, [l_1; r_1], [l_2; r_2], …, [l_n; r_n]. The segment [l; r] includes the bounds, i.e. it is a set of such x that l ≤ x ≤ r. The length of the segment [l; r] is equal to r - l.

Two segments [a; b] and [c; d] have a common point (intersect) if there exists x that a ≤ x ≤ b and c ≤ x ≤ d. For example, [2; 5] and [3; 10] have a common point, but [5; 6] and [1; 4] don't have.

You should add one segment, which has at least one common point with each of the given segments and as short as possible (i.e. has minimal length). The required segment can degenerate to be a point (i.e a segment with length zero). The added segment may or may not be among the given n segments.

In other words, you need to find a segment [a; b], such that [a; b] and every [l_i; r_i] have a common point for each i, and b-a is minimal.

Input

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

The first line of each test case contains one integer n (1 ≤ n ≤ 10^{5}) — the number of segments. The following n lines contain segment descriptions: the i-th of them contains two integers l_i,r_i (1 ≤ l_i ≤ r_i ≤ 10^{9}).

The sum of all values n over all the test cases in the input doesn't exceed 10^5.

Output

For each test case, output one integer — the smallest possible length of the segment which has at least one common point with all given segments.

Example

Input

4
3
4 5
5 9
7 7
5
11 19
4 17
16 16
3 12
14 17
1
1 10
1
1 1

Output

2
4
0
0

Note

In the first test case of the example, we can choose the segment [5;7] as the answer. It is the shortest segment that has at least one common point with all given segments.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    int n;
    cin >> n;
    int mn = 1e9 + 1, mx = 0;
    for (int i = 0; i < n; ++i) {
      int a, b;
      cin >> a >> b;
      mn = min(mn, b);
      mx = max(mx, a);
    }
    cout << max(0, mx - mn) << '\n';
  }
}

```


### Prompt

Generate a Cpp solution to the following problem:

Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1) and (x, y–1).

Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.

Input

The first line contains an integer n (1 ≤ n ≤ 1000).

Output

On the first line print an integer, the maximum number of Coders that can be placed on the chessboard.

On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'.

If there are multiple correct answers, you can print any.

Examples

Input

2

Output

2
C.
.C

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double Pi = acos(-1);
using namespace std;
int debug = 01;
int main() {
  int n;
  cin >> n;
  char g[n][n];
  cout << (n * n + 1) / 2 << "\n";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if ((i + j) & 1)
        cout << ".";
      else
        cout << "C";
    }
    cout << "\n";
  }
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

In number world, two different numbers are friends if they have a lot in common, but also each one has unique perks.

More precisely, two different numbers a and b are friends if gcd(a,b), (a)/(gcd(a,b)), (b)/(gcd(a,b)) can form sides of a triangle.

Three numbers a, b and c can form sides of a triangle if a + b > c, b + c > a and c + a > b.

In a group of numbers, a number is lonely if it doesn't have any friends in that group.

Given a group of numbers containing all numbers from 1, 2, 3, ..., n, how many numbers in that group are lonely?

Input

The first line contains a single integer t (1 ≤ t ≤ 10^6) - number of test cases.

On next line there are t numbers, n_i (1 ≤ n_i ≤ 10^6) - meaning that in case i you should solve for numbers 1, 2, 3, ..., n_i.

Output

For each test case, print the answer on separate lines: number of lonely numbers in group 1, 2, 3, ..., n_i.

Example

Input

3
1 5 10

Output

1
3
3

Note

For first test case, 1 is the only number and therefore lonely.

For second test case where n=5, numbers 1, 3 and 5 are lonely.

For third test case where n=10, numbers 1, 5 and 7 are lonely.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int nmax = 1000005;
vector<int> is_prime(nmax + 1, 1);
vector<int> prefix(nmax + 1, 0);
void prime() {
  is_prime[0] = is_prime[1] = 0;
  for (int i = 2; i * i <= nmax; i++) {
    for (int j = i * i; j <= nmax; j += i) is_prime[j] = 0;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  prime();
  for (int i = 2; i <= nmax; i++) prefix[i] = prefix[i - 1] + is_prime[i];
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    cout << prefix[n] - prefix[(int)sqrt(n)] + 1 << "\n";
  }
}

```


### Prompt

Generate a Cpp solution to the following problem:

Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.

There is a sequence a that consists of n integers a1, a2, ..., an. Let's denote f(l, r, x) the number of indices k such that: l ≤ k ≤ r and ak = x. His task is to calculate the number of pairs of indicies i, j (1 ≤ i < j ≤ n) such that f(1, i, ai) > f(j, n, aj).

Help Pashmak with the test.

Input

The first line of the input contains an integer n (1 ≤ n ≤ 106). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Output

Print a single integer — the answer to the problem.

Examples

Input

7
1 2 1 1 2 2 1

Output

8

Input

3
1 1 1

Output

1

Input

5
1 2 3 4 5

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline bool isLow(char ch) {
  if (ch >= 'a' && ch <= 'z') return true;
  return false;
}
inline bool isUpp(char ch) {
  if (ch >= 'A' && ch <= 'Z') return true;
  return false;
}
inline bool isDig(char ch) {
  if (ch >= '0' && ch <= '9') return true;
  return false;
}
inline bool are_equal(double a, double b) {
  return fabs(a - b) < numeric_limits<double>::epsilon();
}
inline bool greater_than(double a, double b) {
  return (a - b) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) *
                    numeric_limits<double>::epsilon());
}
inline bool less_than(double a, double b) {
  return (b - a) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) *
                    numeric_limits<double>::epsilon());
}
template <typename T>
string toString(T x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
template <typename T>
T SOD(T n) {
  __typeof(n) sum = 0, i = 1;
  for (; i * i <= n; i++)
    sum += (n % i) ? 0 : ((((i) * (i)) == n) ? i : i + n / i);
  return sum;
}
template <typename T>
T stringToT(string s, T a) {
  T p;
  istringstream ss(s);
  ss >> p;
  return p;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (int i = 0; i < v.size(); i++) {
    os << v[i];
    if (i != (int)v.size() - 1) os << ", ";
  }
  os << "]";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  os << "[";
  for (auto it : v) {
    os << it;
    if (it != *v.rbegin()) os << ", ";
  }
  os << "]";
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v) {
  for (auto it : v) os << it.first << " : " << it.second << '\n';
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v) {
  os << "(" << v.first << ", " << v.second << ")";
  return os;
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res *= a;
    a = ((a) * (a));
    b >>= 1;
  }
  return res;
}
long long bigmod(long long a, long long b, long long m) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = ((res % m) * (a % m)) % m;
    }
    a = ((a % m) * (a % m)) % m;
    b >>= 1;
  }
  return res;
}
long long modInverse(long long a, long long m) { return bigmod(a, m - 2, m); }
const int mod = 1e9 + 7;
const int mx = 1000001;
long long n, ara[mx], c = 1;
long long a[mx], b[mx];
long long tree[mx << 2];
map<long long, long long> ms;
void add(int p, int l, int r, int idx, int v) {
  if (l == r) {
    tree[p] += v;
    return;
  }
  if (idx <= (l + r) / 2)
    add((p << 1), l, (l + r) / 2, idx, v);
  else
    add((p << 1) + 1, (l + r) / 2 + 1, r, idx, v);
  tree[p] = tree[(p << 1)] + tree[(p << 1) + 1];
}
long long get(int p, int l, int r, int i, int j) {
  if (l > r || i > r || j < l) return 0LL;
  if (l >= i && r <= j) return tree[p];
  return get((p << 1), l, (l + r) / 2, i, j) +
         get((p << 1) + 1, (l + r) / 2 + 1, r, i, j);
}
int main() {
  scanf("%lld", &n);
  for (__typeof(n - 1) i = (0); i <= (n - 1); i++) {
    long long x;
    scanf("%lld", &x);
    if (ms[x] == 0) ms[x] = c++;
    ara[i] = ms[x];
  }
  for (int i = 0; i < n; i++) {
    add(1, 1, mx - 1, ara[i], 1);
    a[i] = get(1, 1, mx - 1, ara[i], ara[i]);
  }
  memset(tree, 0, sizeof(tree));
  for (int i = n - 1; i >= 0; i--) {
    add(1, 1, mx - 1, ara[i], 1);
    b[i] = get(1, 1, mx - 1, ara[i], ara[i]);
  }
  memset(tree, 0, sizeof(tree));
  for (int i = 0; i < n; i++) add(1, 1, mx - 1, b[i], 1);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    add(1, 1, mx - 1, b[i], -1);
    ans += get(1, 1, mx - 1, 1, a[i] - 1);
  }
  printf("%lld\n", ans);
  return 0;
}

```


### Prompt

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

Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count the number of possible pictures that Paul can take.

Two pictures are considered to be different if the coordinates of corresponding rectangles are different.

Input

The first line of input contains four space-separated integers r, c, n, k (1 ≤ r, c, n ≤ 3000, 1 ≤ k ≤ min(n, 10)) — the number of rows and columns of the string section, the total number of violas, and the minimum number of violas Paul would like in his photograph, respectively.

The next n lines each contain two integers xi and yi (1 ≤ xi ≤ r, 1 ≤ yi ≤ c): the position of the i-th viola. It is guaranteed that no location appears more than once in the input.

Output

Print a single integer — the number of photographs Paul can take which include at least k violas.

Examples

Input

2 2 1 1
1 2

Output

4

Input

3 2 3 3
1 1
3 1
2 2

Output

1

Input

3 2 3 2
1 1
3 1
2 2

Output

4

Note

We will use '*' to denote violinists and '#' to denote violists.

In the first sample, the orchestra looks as follows:

    *#
    **

Paul can take a photograph of just the viola, the 1 × 2 column containing the viola, the 2 × 1 row containing the viola, or the entire string section, for 4 pictures total.

In the second sample, the orchestra looks as follows:

    #*
    *#
    #*

Paul must take a photograph of the entire section.

In the third sample, the orchestra looks the same as in the second sample.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 3000 + 77;
int n, tr, tc, k, Qx[N], Qy[N], a[N], nxt[N], prv[N], nw, Tr[12], Tl[12];
vector<int> C[N];
long long A, B;
inline int Calc() {
  int r = 1;
  int ans = a[1];
  int t = 0;
  for (int l = 1; l <= tr; l++) {
    while (ans < k) {
      r++;
      ans += a[r];
    }
    t += r - l;
    ans -= a[l];
  }
  return t;
}
inline void Decrease(int id) {
  memset(Tr, 0, sizeof(Tr));
  memset(Tl, 0, sizeof(Tl));
  int nd = id, val = 0;
  while (val < k) {
    Tl[val] = nd - prv[nd];
    nd = prv[nd];
    val += a[nd];
  }
  nd = id;
  val = 0;
  while (val < k) {
    Tr[val] = nxt[nd] - nd;
    nd = nxt[nd];
    val += a[nd];
  }
  for (int i = 0; i < k; i++) {
    if (k - i - a[id] < 0) {
      break;
    }
    nw += Tl[i] * Tr[k - i - a[id]];
  }
  a[id]--;
  if (a[id] == 0) {
    nxt[prv[id]] = nxt[id];
    prv[nxt[id]] = prv[id];
  }
}
inline void Solve(int s) {
  memset(a, 0, sizeof(a));
  memset(nxt, 0, sizeof(nxt));
  memset(prv, 0, sizeof(prv));
  a[0] = a[tr + 1] = k;
  for (int i = s; i <= tc; i++) {
    for (auto x : C[i]) {
      a[x]++;
    }
  }
  prv[1] = 0;
  nxt[tr] = tr + 1;
  for (int i = 2; i <= tr; i++) {
    prv[i] = prv[i - 1];
    if (a[i - 1]) {
      prv[i] = i - 1;
    }
  }
  for (int i = tr - 1; i > 0; i--) {
    nxt[i] = nxt[i + 1];
    if (a[i + 1]) {
      nxt[i] = i + 1;
    }
  }
  nw = Calc();
  A += nw;
  for (int i = tc; i > s; i--) {
    for (auto x : C[i]) {
      Decrease(x);
    }
    A += nw;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> tr >> tc >> n >> k;
  B = tr * (tr + 1) / 2;
  B *= tc * (tc + 1) / 2;
  for (int i = 1; i <= n; i++) {
    cin >> Qx[i] >> Qy[i];
    C[Qy[i]].push_back(Qx[i]);
  }
  for (int i = 1; i <= tc; i++) {
    Solve(i);
  }
  cout << B - A;
  return 0;
}

```


### Prompt

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

The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her n students and give each of them a jigsaw puzzle (which, as wikipedia states, is a tiling puzzle that requires the assembly of numerous small, often oddly shaped, interlocking and tessellating pieces).

The shop assistant told the teacher that there are m puzzles in the shop, but they might differ in difficulty and size. Specifically, the first jigsaw puzzle consists of f1 pieces, the second one consists of f2 pieces and so on.

Ms. Manana doesn't want to upset the children, so she decided that the difference between the numbers of pieces in her presents must be as small as possible. Let A be the number of pieces in the largest puzzle that the teacher buys and B be the number of pieces in the smallest such puzzle. She wants to choose such n puzzles that A - B is minimum possible. Help the teacher and find the least possible value of A - B.

Input

The first line contains space-separated integers n and m (2 ≤ n ≤ m ≤ 50). The second line contains m space-separated integers f1, f2, ..., fm (4 ≤ fi ≤ 1000) — the quantities of pieces in the puzzles sold in the shop.

Output

Print a single integer — the least possible difference the teacher can obtain.

Examples

Input

4 6
10 12 10 7 5 22

Output

5

Note

Sample 1. The class has 4 students. The shop sells 6 puzzles. If Ms. Manana buys the first four puzzles consisting of 10, 12, 10 and 7 pieces correspondingly, then the difference between the sizes of the largest and the smallest puzzle will be equal to 5. It is impossible to obtain a smaller difference. Note that the teacher can also buy puzzles 1, 3, 4 and 5 to obtain the difference 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c = 999;
  cin >> a >> b;
  int arr[50];
  for (int c = 0; c < b; c++) cin >> arr[c];
  sort(arr, arr + b);
  for (int f = 0; f <= b - a; f++) {
    if (arr[f + a - 1] - arr[f] >= 0) c = min(c, arr[f + a - 1] - arr[f]);
  }
  cout << c;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from 1 to n and then 3n times takes a random pair of different elements and swaps them. Alex envies Petr and tries to imitate him in all kind of things. Alex has also come up with a problem about random permutation. He generates a random permutation just like Petr but swaps elements 7n+1 times instead of 3n times. Because it is more random, OK?!

You somehow get a test from one of these problems and now you want to know from which one.

Input

In the first line of input there is one integer n (10^{3} ≤ n ≤ 10^{6}).

In the second line there are n distinct integers between 1 and n — the permutation of size n from the test.

It is guaranteed that all tests except for sample are generated this way: First we choose n — the size of the permutation. Then we randomly choose a method to generate a permutation — the one of Petr or the one of Alex. Then we generate a permutation using chosen method.

Output

If the test is generated via Petr's method print "Petr" (without quotes). If the test is generated via Alex's method print "Um_nik" (without quotes).

Example

Input

5
2 4 5 1 3

Output

Petr

Note

Please note that the sample is not a valid test (because of limitations for n) and is given only to illustrate input/output format. Your program still has to print correct answer to this test to get AC.

Due to randomness of input hacks in this problem are forbidden.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e6;
int n, arr[mxN];
int getSum(int BITree[], int index) {
  int sum = 0;
  while (index > 0) {
    sum += BITree[index];
    index -= index & (-index);
  }
  return sum;
}
void updateBIT(int BITree[], int n, int index, int val) {
  while (index <= n) {
    BITree[index] += val;
    index += index & (-index);
  }
}
long long getInvCount(int n) {
  long long invcount = 0;
  int maxElement = 0;
  for (int i = 0; i < n; i++)
    if (maxElement < arr[i]) maxElement = arr[i];
  int BIT[maxElement + 1];
  for (int i = 1; i <= maxElement; i++) BIT[i] = 0;
  for (int i = n - 1; i >= 0; i--) {
    invcount += getSum(BIT, arr[i] - 1);
    updateBIT(BIT, maxElement, arr[i], 1);
  }
  return invcount;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  long long ic = getInvCount(n);
  if (ic % 2 == n % 2)
    cout << "Petr";
  else
    cout << "Um_nik";
  return 0;
}

```


### Prompt

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

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;
struct Rectangle {
  int left_x;
  int right_x;
  int down_y;
  int up_y;
  Rectangle() {}
  Rectangle(int left_x, int right_x, int down_y, int up_y)
      : left_x(left_x), right_x(right_x), down_y(down_y), up_y(up_y) {}
};
const int MAX_N = 100100;
Rectangle v[MAX_N];
int Round(int x) {
  if (x == 0) {
    return 1;
  }
  return (x + 1) / 2;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    v[i] = Rectangle(x1, x2, y1, y2);
  }
  vector<int> left(n);
  vector<int> right(n);
  vector<int> down(n);
  vector<int> up(n);
  for (int i = 0; i < n; ++i) {
    left[i] = (v[i].left_x + v[i].right_x);
    right[i] = (v[i].left_x + v[i].right_x);
    down[i] = (v[i].down_y + v[i].up_y);
    up[i] = (v[i].down_y + v[i].up_y);
  }
  sort(left.begin(), left.end());
  sort(right.rbegin(), right.rend());
  sort(down.begin(), down.end());
  sort(up.rbegin(), up.rend());
  int t = min(11, n);
  long long answer = (long long)1e18;
  for (int l = 0; l < t; ++l) {
    for (int r = 0; r < t; ++r) {
      for (int d = 0; d < t; ++d) {
        for (int u = 0; u < t; ++u) {
          if (left[l] <= right[r] && down[d] <= up[u] &&
              l + r + u + d <= 2 * k && l + r <= k && u + d <= k) {
            int result = 0;
            for (int i = 0; i < n; ++i) {
              if (left[l] > (v[i].left_x + v[i].right_x) ||
                  right[r] < (v[i].left_x + v[i].right_x) ||
                  down[d] > (v[i].down_y + v[i].up_y) ||
                  up[u] < (v[i].down_y + v[i].up_y)) {
                ++result;
              }
            }
            if (result <= k) {
              answer = min(answer, (long long)Round(right[r] - left[l]) *
                                       Round(up[u] - down[d]));
            }
          }
        }
      }
    }
  }
  cout << answer;
  return 0;
}

```


### Prompt

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

Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins.

Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer x (2·x + 1 ≤ n) and take a coin from each chest with numbers x, 2·x, 2·x + 1. It may turn out that some chest has no coins, in this case the player doesn't take a coin from this chest. The game finishes when all chests get emptied.

Polycarpus isn't a greedy scrooge. Polycarpys is a lazy slob. So he wonders in what minimum number of moves the game can finish. Help Polycarpus, determine the minimum number of moves in which the game can finish. Note that Polycarpus counts not only his moves, he also counts Vasily's moves.

Input

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of chests with coins. The second line contains a sequence of space-separated integers: a1, a2, ..., an (1 ≤ ai ≤ 1000), where ai is the number of coins in the chest number i at the beginning of the game.

Output

Print a single integer — the minimum number of moves needed to finish the game. If no sequence of turns leads to finishing the game, print -1.

Examples

Input

1
1

Output

-1

Input

3
1 2 3

Output

3

Note

In the first test case there isn't a single move that can be made. That's why the players won't be able to empty the chests.

In the second sample there is only one possible move x = 1. This move should be repeated at least 3 times to empty the third chest.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, a[1500], i, ans, x;
int main() {
  while (scanf("%d", &n) == 1) {
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    ans = 0;
    for (i = n; i > 0; i--) {
      if (i * 2 + 1 > n) continue;
      x = max(a[i * 2], a[i * 2 + 1]);
      ans += x;
      a[i * 2] = 0;
      a[i * 2 + 1] = 0;
      a[i] -= x;
      if (a[i] < 0) a[i] = 0;
    }
    bool flag = 0;
    for (i = 1; i <= n; i++)
      if (a[i]) {
        if (i * 2 + 1 <= n)
          ans += a[i];
        else
          flag = 1;
      }
    if (flag)
      puts("-1");
    else
      printf("%d\n", ans);
  }
  return 0;
}

```


### Prompt

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

You have a bag of size n. Also you have m boxes. The size of i-th box is a_i, where each a_i is an integer non-negative power of two.

You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.

For example, if n = 10 and a = [1, 1, 32] then you have to divide the box of size 32 into two parts of size 16, and then divide the box of size 16. So you can fill the bag with boxes of size 1, 1 and 8.

Calculate the minimum number of divisions required to fill the bag of size n.

Input

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

The first line of each test case contains two integers n and m (1 ≤ n ≤ 10^{18}, 1 ≤ m ≤ 10^5) — the size of bag and the number of boxes, respectively.

The second line of each test case contains m integers a_1, a_2, ... , a_m (1 ≤ a_i ≤ 10^9) — the sizes of boxes. It is guaranteed that each a_i is a power of two.

It is also guaranteed that sum of all m over all test cases does not exceed 10^5.

Output

For each test case print one integer — the minimum number of divisions required to fill the bag of size n (or -1, if it is impossible).

Example

Input

3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8

Output

2
-1
0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long cas;
  scanf("%lld", &cas);
  while (cas--) {
    long long res[64];
    memset(res, 0, sizeof(res));
    long long n, m;
    cin >> n >> m;
    long long sum = 0;
    for (long long i = 0; i < m; i++) {
      long long t;
      scanf("%lld", &t);
      long long tmp = 0;
      sum += t;
      while (t) {
        if (t & 1) res[tmp]++;
        t >>= 1;
        tmp++;
      }
    }
    long long tmp = 0;
    long long ans = 0;
    if (sum < n) {
      cout << -1 << endl;
      continue;
    }
    while (n) {
      if (n & 1) {
        if (res[tmp]) {
          res[tmp]--;
          res[tmp + 1] += res[tmp] / 2;
        } else {
          for (long long i = tmp; i < 64; i++) {
            if (res[i]) {
              res[i]--;
              ans += (i - tmp);
              n >>= (i - tmp);
              tmp = i;
              break;
            }
          }
          continue;
        }
      } else {
        res[tmp + 1] += res[tmp] / 2;
      }
      n >>= 1;
      tmp++;
    }
    cout << ans << endl;
  }
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

User ainta loves to play with cards. He has a cards containing letter "o" and b cards containing letter "x". He arranges the cards in a row, and calculates the score of the deck by the formula below.

  1. At first, the score is 0.
  2. For each block of contiguous "o"s with length x the score increases by x2.
  3. For each block of contiguous "x"s with length y the score decreases by y2.

For example, if a = 6, b = 3 and ainta have arranged the cards in the order, that is described by string "ooxoooxxo", the score of the deck equals 22 - 12 + 32 - 22 + 12 = 9. That is because the deck has 5 blocks in total: "oo", "x", "ooo", "xx", "o".

User ainta likes big numbers, so he wants to maximize the score with the given cards. Help ainta make the score as big as possible. Note, that he has to arrange all his cards.

Input

The first line contains two space-separated integers a and b (0 ≤ a, b ≤ 105; a + b ≥ 1) — the number of "o" cards and the number of "x" cards.

Output

In the first line print a single integer v — the maximum score that ainta can obtain.

In the second line print a + b characters describing the deck. If the k-th card of the deck contains "o", the k-th character must be "o". If the k-th card of the deck contains "x", the k-th character must be "x". The number of "o" characters must be equal to a, and the number of "x " characters must be equal to b. If there are many ways to maximize v, print any.

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

Examples

Input

2 3

Output

-1
xoxox

Input

4 0

Output

16
oooo

Input

0 4

Output

-16
xxxx

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T Max(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
inline T Min(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
inline void CheckMax(T &a, T b) {
  if (a < b) a = b;
}
template <typename T>
inline void CheckMin(T &a, T b) {
  if (a > b) a = b;
}
long long a, b, ans;
long long add(long long n, long long p) { return (n - p) * (n - p) + p; }
long long add2(long long n, long long p) {
  long long d = n / p, m = n % p;
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    ans += (d + 1) * (d + 1);
  }
  for (int i = m; i < p; i++) {
    ans += d * d;
  }
  return ans;
}
long long sub(int p, int &type) {
  if ((b / (p + 2)) && a >= p + 1) {
    type = 2;
    return add2(b, p + 2);
  } else if (b / (p + 1)) {
    type = 1;
    return add2(b, p + 1);
  } else {
    type = 0;
    return add2(b, p);
  }
}
void work() {
  if (b == 0) {
    cout << a * a << endl;
    for (int i = 1; i <= a; i++) cout << "o";
    cout << endl;
    return;
  }
  if (a == 0) {
    cout << -b * b << endl;
    for (int i = 1; i <= b; i++) cout << "x";
    cout << endl;
    return;
  }
  int num;
  if (a > b) {
    num = b;
  } else {
    num = a - 1;
  }
  int anstype, cnt;
  ans = 0;
  for (int i = 0; i <= num; i++) {
    long long tmp = add(a, i);
    int type;
    tmp -= sub(i, type);
    if (i == 0) {
      ans = tmp;
      anstype = type;
      cnt = i;
    } else if (tmp > ans) {
      ans = tmp;
      anstype = type;
      cnt = i;
    }
  }
  cout << ans << endl;
  vector<int> va, vb, vc;
  va.push_back(a - cnt);
  for (int i = 0; i < cnt; i++) {
    va.push_back(1);
  }
  int p1 = cnt + anstype;
  for (int i = 0; i < p1; i++) {
    vb.push_back(b / p1);
  }
  for (int i = 0; i < b % p1; i++) {
    vb[i] = vb[i] + 1;
  }
  int pb = 0, pa = 0;
  if (anstype == 2) {
    for (int i = 0; i < vb[0]; i++) cout << "x";
    pb++;
  }
  for (int i = 0; i < va[0]; i++) cout << "o";
  for (int i = 0; i < cnt; i++) {
    for (int j = 0; j < vb[pb]; j++) cout << "x";
    pb++;
    for (int j = 0; j < va[i + 1]; j++) cout << "o";
  }
  if (anstype == 2 || anstype == 1) {
    for (int i = 0; i < vb[pb]; i++) cout << "x";
  }
  cout << endl;
}
int main() {
  cin >> a >> b;
  work();
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the path u-v.

It is expected that one of the vertices will be invaded by aliens from outer space. Snuke wants to immediately identify that vertex when the invasion happens. To do so, he has decided to install an antenna on some vertices.

First, he decides the number of antennas, K (1 ≤ K ≤ N). Then, he chooses K different vertices, x_0, x_1, ..., x_{K - 1}, on which he installs Antenna 0, 1, ..., K - 1, respectively. If Vertex v is invaded by aliens, Antenna k (0 ≤ k < K) will output the distance d(x_k, v). Based on these K outputs, Snuke will identify the vertex that is invaded. Thus, in order to identify the invaded vertex no matter which one is invaded, the following condition must hold:

* For each vertex u (0 ≤ u < N), consider the vector (d(x_0, u), ..., d(x_{K - 1}, u)). These N vectors are distinct.

Find the minumum value of K, the number of antennas, when the condition is satisfied.

Constraints

* 2 ≤ N ≤ 10^5
* 0 ≤ a_i, b_i < N
* The given graph is a tree.

Input

Input is given from Standard Input in the following format:

N
a_0 b_0
a_1 b_1
:
a_{N - 2} b_{N - 2}

Output

Print the minumum value of K, the number of antennas, when the condition is satisfied.

Examples

Input

5
0 1
0 2
0 3
3 4

Output

2

Input

2
0 1

Output

1

Input

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

Output

3

### Response

```cpp
#include <cstdio>
#include <vector>

const int N = 100000;

int n;
std::vector<int> tree[N];

int dfs(int p, int u)
{
    int result = 0, zeros = 0;
    for (int v : tree[u]) {
        if (v == p) {
            continue;
        }
        int r = dfs(u, v);
        result += r;
        zeros += !r;
    }
    return result + std::max(zeros - 1, 0);
}

int main()
{
    scanf("%d", &n);
    for (int i = 0, a, b; i < n - 1; ++ i) {
        scanf("%d%d", &a, &b);
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    int r = 0;
    while (r < n && tree[r].size() < 3) {
        r ++;
    }
    if (r == n) {
        puts("1");
    } else {
        printf("%d\n", dfs(-1, r));
    }
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Berland scientists face a very important task - given the parts of short DNA fragments, restore the dinosaur DNA! The genome of a berland dinosaur has noting in common with the genome that we've used to: it can have 26 distinct nucleotide types, a nucleotide of each type can occur at most once. If we assign distinct English letters to all nucleotides, then the genome of a Berland dinosaur will represent a non-empty string consisting of small English letters, such that each letter occurs in it at most once.

Scientists have n genome fragments that are represented as substrings (non-empty sequences of consecutive nucleotides) of the sought genome.

You face the following problem: help scientists restore the dinosaur genome. It is guaranteed that the input is not contradictory and at least one suitable line always exists. When the scientists found out that you are a strong programmer, they asked you in addition to choose the one with the minimum length. If there are multiple such strings, choose any string.

Input

The first line of the input contains a positive integer n (1 ≤ n ≤ 100) — the number of genome fragments.

Each of the next lines contains one descriptions of a fragment. Each fragment is a non-empty string consisting of distinct small letters of the English alphabet. It is not guaranteed that the given fragments are distinct. Fragments could arbitrarily overlap and one fragment could be a substring of another one.

It is guaranteed that there is such string of distinct letters that contains all the given fragments as substrings.

Output

In the single line of the output print the genome of the minimum length that contains all the given parts. All the nucleotides in the genome must be distinct. If there are multiple suitable strings, print the string of the minimum length. If there also are multiple suitable strings, you can print any of them.

Examples

Input

3
bcd
ab
cdef

Output

abcdef

Input

4
x
y
z
w

Output

xyzw

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const long double pie = 3.1415926535897932384626;
const long long mod = 1e9 + 7;
const int N = 26;
bool present[N];
int in_deg[N];
vector<int> g[N];
bool vis[N];
void dfs(int node) {
  char c = 'a' + node;
  cout << c;
  vis[node] = 1;
  for (auto &i : g[node]) {
    if (vis[i]) continue;
    ;
    dfs(i);
  }
}
void solve(int test_case) {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int z = s.size();
    for (auto c : s) {
      int indx = c - 'a';
      present[indx] = 1;
    }
    for (int j = 0; j < z - 1; j++) {
      int a = s[j] - 'a';
      int b = s[j + 1] - 'a';
      g[a].push_back(b);
      in_deg[b]++;
    }
  }
  for (int i = 0; i < N; i++) {
    if (present[i] == false) continue;
    ;
    if (in_deg[i]) continue;
    ;
    dfs(i);
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  for (int i = 1; i <= t; i++) solve(i);
  return 0;
}

```