### Prompt

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

Innopolis University scientists continue to investigate the periodic table. There are n·m known elements and they form a periodic table: a rectangle with n rows and m columns. Each element can be described by its coordinates (r, c) (1 ≤ r ≤ n, 1 ≤ c ≤ m) in the table.

Recently scientists discovered that for every four different elements in this table that form a rectangle with sides parallel to the sides of the table, if they have samples of three of the four elements, they can produce a sample of the fourth element using nuclear fusion. So if we have elements in positions (r1, c1), (r1, c2), (r2, c1), where r1 ≠ r2 and c1 ≠ c2, then we can produce element (r2, c2).

<image>

Samples used in fusion are not wasted and can be used again in future fusions. Newly crafted elements also can be used in future fusions.

Innopolis University scientists already have samples of q elements. They want to obtain samples of all n·m elements. To achieve that, they will purchase some samples from other laboratories and then produce all remaining elements using an arbitrary number of nuclear fusions in some order. Help them to find the minimal number of elements they need to purchase.

Input

The first line contains three integers n, m, q (1 ≤ n, m ≤ 200 000; 0 ≤ q ≤ min(n·m, 200 000)), the chemical table dimensions and the number of elements scientists already have.

The following q lines contain two integers ri, ci (1 ≤ ri ≤ n, 1 ≤ ci ≤ m), each describes an element that scientists already have. All elements in the input are different.

Output

Print the minimal number of elements to be purchased.

Examples

Input

2 2 3
1 2
2 2
2 1

Output

0

Input

1 5 3
1 3
1 1
1 5

Output

2

Input

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

Output

1

Note

For each example you have a picture which illustrates it.

The first picture for each example describes the initial set of element samples available. Black crosses represent elements available in the lab initially.

The second picture describes how remaining samples can be obtained. Red dashed circles denote elements that should be purchased from other labs (the optimal solution should minimize the number of red circles). Blue dashed circles are elements that can be produced with nuclear fusion. They are numbered in order in which they can be produced.

Test 1

We can use nuclear fusion and get the element from three other samples, so we don't need to purchase anything.

<image>

Test 2

We cannot use any nuclear fusion at all as there is only one row, so we have to purchase all missing elements.

<image>

Test 3

There are several possible solutions. One of them is illustrated below.

Note that after purchasing one element marked as red it's still not possible to immidiately produce the middle element in the bottom row (marked as 4). So we produce the element in the left-top corner first (marked as 1), and then use it in future fusions.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int pa[400001] = {};
int size[400001] = {};
int find_pa(int c) { return pa[c] = pa[c] == c ? c : find_pa(pa[c]); }
void add_edge(int i, int j) {
  int p1 = find_pa(i), p2 = find_pa(j);
  if (size[p1] < size[p2]) swap(p1, p2);
  pa[p2] = p1;
  size[p1] += size[p2];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, n, m, q, r, c, ans = -1;
  cin >> n >> m >> q;
  for (i = 1; i <= n + m; i++) {
    pa[i] = i;
    size[i] = 1;
  }
  for (i = 0; i < q; i++) {
    cin >> r >> c;
    add_edge(r, n + c);
  }
  for (i = 1; i <= n + m; i++)
    if (pa[i] == i) ans++;
  cout << ans;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.

Number x is considered close to number n modulo m, if:

  * it can be obtained by rearranging the digits of number n,
  * it doesn't have any leading zeroes,
  * the remainder after dividing number x by m equals 0.

Roman is a good mathematician, but the number of such numbers is too huge for him. So he asks you to help him.

Input

The first line contains two integers: n (1 ≤ n < 1018) and m (1 ≤ m ≤ 100).

Output

In a single line print a single integer — the number of numbers close to number n modulo m.

Examples

Input

104 2

Output

3

Input

223 4

Output

1

Input

7067678 8

Output

47

Note

In the first sample the required numbers are: 104, 140, 410.

In the second sample the required number is 232.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long dp[(1 << 18)][101], n, m;
long long v[22], gigi;
string str;
int main() {
  ios::sync_with_stdio(false);
  cin >> str >> m;
  n = str.size();
  for (int i = str.size() - 1; i >= 0; i--) {
    if (i == str.size() - 1)
      v[i] = 1;
    else
      v[i] = v[i + 1] * 10;
  }
  dp[0][0] = 1;
  for (int mask = 0; mask <= (1 << n) - 1; mask++) {
    for (int r = 0; r <= m - 1; r++) {
      int can[10], p = 0;
      for (int i = 0; i <= 9; i++) can[i] = -1;
      for (int i = 0; i <= n - 1; i++) {
        if (mask & (1 << i)) {
          p++;
          continue;
        }
        int c = str[i] - '0';
        can[c] = i;
      }
      for (int i = 0; i <= 9; i++) {
        if (!mask && !i) continue;
        if (can[i] == -1) continue;
        long long newMask = mask | (1 << can[i]), nr = (r + (i * v[p])) % m;
        dp[newMask][nr] += dp[mask][r];
      }
    }
  }
  cout << dp[(1 << n) - 1][0] << endl;
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

JOI Park

In preparation for the Olympic Games in IOI in 20XX, the JOI Park in IOI will be developed. There are N squares in JOI Park, and the squares are numbered from 1 to N. There are M roads connecting the squares, and the roads are numbered from 1 to M. The road i (1 ≤ i ≤ M) connects the square Ai and the square Bi in both directions, and the length is Di. You can follow several paths from any square to any square.

In the maintenance plan, first select an integer X of 0 or more, and connect all the squares (including square 1) whose distance from square 1 is X or less to each other by an underpass. However, the distance between the square i and the square j is the minimum value of the sum of the lengths of the roads taken when going from the square i to the square j. In the maintenance plan, the integer C for the maintenance cost of the underpass is fixed. The cost of developing an underpass is C x X.

Next, remove all the roads connecting the plazas connected by the underpass. There is no cost to remove the road. Finally, repair all the roads that remained unremoved. The cost of repairing a road of length d is d. There is no underpass in JOI Park before the implementation of the maintenance plan. Find the minimum sum of the costs of developing the JOI Park.

Task

Given the information on the JOI Park Square and an integer for the underpass maintenance cost, create a program to find the minimum sum of the costs for the JOI Park maintenance.

input

Read the following data from standard input.

* On the first line, the integers N, M, and C are written with blanks as delimiters. This means that there are N squares, M roads, and the integer for the underpass maintenance cost is C.
* On the i-th line (1 ≤ i ≤ M) of the following M lines, the integers Ai, Bi, and Di are written separated by blanks. This means that the road i connects the square Ai and the square Bi, and the length is Di.

output

Output an integer representing the minimum sum of the costs of developing the JOI park to the standard output on one line.

Limits

All input data satisfy the following conditions.

* 2 ≤ N ≤ 100 000.
* 1 ≤ M ≤ 200 000.
* 1 ≤ C ≤ 100 000.
* 1 ≤ Ai ≤ N (1 ≤ i ≤ M).
* 1 ≤ Bi ≤ N (1 ≤ i ≤ M).
* Ai ≠ Bi (1 ≤ i ≤ M).
* (Ai, Bi) ≠ (Aj, Bj) and (Ai, Bi) ≠ (Bj, Aj) (1 ≤ i <j ≤ M).
* 1 ≤ Di ≤ 100 000 (1 ≤ i ≤ M).
* With the input data given, it is guaranteed that you can go from any square to any square by following several paths.

Input / output example

Input example 1

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

Output example 1

14

In this input example, when X = 3, the sum of the maintenance costs when all the squares (square 1, square 2, square 3) whose distance from square 1 is 3 or less are connected to each other by an underpass. Is 2 × 3 + 3 + 5 = 14. This is the minimum value.

Input example 2

5 4 10
one two Three
2 3 4
3 4 3
4 5 5

Output example 2

15

In this input example, the sum of maintenance costs is minimized when X = 0.

Input example 3

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

Output example 3

Ten

In this input example, when all the squares are connected to each other by an underpass with X = 5, the sum of the maintenance costs is minimized.

The question text and the data used for the automatic referee are the question text and the test data for scoring, which are created and published by the Japan Committee for Information Olympics.

Example

Input

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

Output

14

### Response

```cpp
#include <cstdio>
#include <algorithm>
#include <queue>
#include <utility>
#include <vector>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
#define INF 30000000000000000ll
#define fi first
#define sec second
#define pb push_back
ll dist[100100];
ll ava[100100];
vector<P> vec;
int N,M;
ll C;
struct edge
{
	int to;
	ll cost;
	edge(int to,ll cost):to(to),cost(cost){}
};
vector<edge> g[100100];
void dijkstra()
{
	for(int i=0;i<N;i++)dist[i]=INF;
	dist[0]=0;
	priority_queue<P,vector<P>,greater<P> > q;
	q.push(P(0ll,0));
	while(!q.empty())
	{
		P a = q.top();
		q.pop();
		int v = a.sec;
		for(int i=0;i<g[v].size();i++)
		{
			edge e = g[v][i];
			if(dist[e.to]>dist[v]+e.cost)
			{
				dist[e.to]=dist[v]+e.cost;
				q.push(P(dist[e.to],e.to));
			}
		}
	}
	return;
}
int main()
{
	ll sum = 0ll;
	scanf("%d %d %lld",&N,&M,&C);
	for(int i=0;i<M;i++)
	{
		int a,b;
		ll c;
		scanf("%d %d %lld",&a,&b,&c);
		a--;b--;
		sum+=c;
		g[a].pb(edge(b,c));
		g[b].pb(edge(a,c));
	}
	dijkstra();
	for(int i=0;i<N;i++)vec.pb(P(dist[i],i));
	sort(vec.begin(),vec.end());
	ll ans = INF;
	for(int i=0;i<N;i++)
	{
		int v = vec[i].sec;
		//cout << v << endl;
		sum -= ava[v];
		ans = min(C*vec[i].fi+sum,ans);
		//cout << C*vec[i].fi << ' ' << sum << endl;
		for(int j=0;j<g[v].size();j++)
		{
			edge e = g[v][j];
			ava[e.to]+=e.cost;
		}
	}
	printf("%lld\n",ans);
	return 0;
}
```


### Prompt

Generate a Cpp solution to the following problem:

Another dull quarantine day was going by when BThero decided to start researching matrices of size n × m. The rows are numerated 1 through n from top to bottom, and the columns are numerated 1 through m from left to right. The cell in the i-th row and j-th column is denoted as (i, j).

For each cell (i, j) BThero had two values:

  1. The cost of the cell, which is a single positive integer.
  2. The direction of the cell, which is one of characters L, R, D, U. Those characters correspond to transitions to adjacent cells (i, j - 1), (i, j + 1), (i + 1, j) or (i - 1, j), respectively. No transition pointed outside of the matrix.

Let us call a cell (i_2, j_2) reachable from (i_1, j_1), if, starting from (i_1, j_1) and repeatedly moving to the adjacent cell according to our current direction, we will, sooner or later, visit (i_2, j_2).

BThero decided to create another matrix from the existing two. For a cell (i, j), let us denote S_{i, j} as a set of all reachable cells from it (including (i, j) itself). Then, the value at the cell (i, j) in the new matrix will be equal to the sum of costs of all cells in S_{i, j}.

After quickly computing the new matrix, BThero immediately sent it to his friends. However, he did not save any of the initial matrices! Help him to restore any two valid matrices, which produce the current one.

Input

The first line of input file contains a single integer T (1 ≤ T ≤ 100) denoting the number of test cases. The description of T test cases follows.

First line of a test case contains two integers n and m (1 ≤ n ⋅ m ≤ 10^5).

Each of the following n lines contain exactly m integers — the elements of the produced matrix. Each element belongs to the segment [2, 10^9].

It is guaranteed that ∑{(n ⋅ m)} over all test cases does not exceed 10^5.

Output

For each test case, if an answer does not exist, print a single word NO. Otherwise, print YES and both matrices in the same format as in the input.

  * The first matrix should be the cost matrix and the second matrix should be the direction matrix.
  * All integers in the cost matrix should be positive.
  * All characters in the direction matrix should be valid. No direction should point outside of the matrix.

Example

Input

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

Output

YES
1 1 1 1
2 1 1 1
3 2 1 1
R D L L
D R D L
U L R U
NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N];
int n, m;
int p[5][2] = {0, 0, -1, 0, 1, 0, 0, 1, 0, -1};
bool lim[N];
int link[N], used[N];
int to[10 * N], lst[N], nxt[10 * N], cnt;
int ans[N];
char d[N];
int C(int x, int y) { return x * m + y; }
pair<int, int> C(int x) {
  return x < 0 | x >= n * m ? make_pair(-1, -1) : make_pair(x / m, x % m);
}
bool dfs(int u, int cas) {
  for (int k = lst[u]; k != 0; k = nxt[k]) {
    int v = to[k];
    if (used[v] != cas) {
      used[v] = cas;
      if (link[v] == -1 || dfs(link[v], cas)) {
        link[u] = v;
        link[v] = u;
        return 1;
      } else {
        if (lim[link[v]] == 0) {
          link[link[v]] = -1;
          link[u] = v;
          link[v] = u;
          return 1;
        }
      }
    }
  }
  return 0;
}
void Add(int u, int v) {
  cnt++, nxt[cnt] = lst[u], to[cnt] = v, lst[u] = cnt;
  cnt++, nxt[cnt] = lst[v], to[cnt] = u, lst[v] = cnt;
}
char T(int x, int y, int xx, int yy) {
  if (yy == y + 1) return 'R';
  if (yy == y - 1) return 'L';
  if (xx == x - 1) return 'U';
  if (xx == x + 1) return 'D';
}
void Find(int u) {
  pair<int, int> cor = C(u);
  int x = cor.first, y = cor.second;
  if (link[u] == -1) {
    for (int k = 1; k <= 4; k++) {
      int xx = x + p[k][0], yy = y + p[k][1];
      if (xx < 0 || xx >= n || yy < 0 || yy >= m || a[C(xx, yy)] >= a[u])
        continue;
      d[u] = T(x, y, xx, yy);
      ans[u] = a[u] - a[C(xx, yy)];
      break;
    }
  } else {
    int xx, yy;
    pair<int, int> corr;
    corr = C(link[u]);
    xx = corr.first, yy = corr.second;
    d[u] = T(x, y, xx, yy);
    if (ans[link[u]])
      ans[u] = a[u] - ans[link[u]];
    else
      ans[u] = 1;
  }
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d %d", &n, &m);
    for (int i = 0; i <= n * m - 1; i++) link[i] = -1;
    for (int i = 0; i <= n * m - 1; i++) scanf("%d", &a[i]);
    bool ok = 1;
    for (int i = 0; i <= n * m - 1; i++) {
      pair<int, int> xy = C(i);
      bool flag = 0;
      int num = 0;
      for (int k = 1; k <= 4; k++) {
        int x = xy.first + p[k][0], y = xy.second + p[k][1];
        if (x < 0 || x >= n || y < 0 || y >= m || a[C(x, y)] > a[i]) continue;
        flag = 1;
        if (a[C(x, y)] == a[i] && C(x, y) < i)
          Add(C(x, y), i);
        else if (a[C(x, y)] != a[i])
          num++;
      }
      if (!flag) {
        ok = 0;
        break;
      }
      if (num == 0) lim[i] = 1;
    }
    if (!ok) {
      printf("NO\n");
      continue;
    }
    int cas = 0;
    for (int i = 0; i <= n * m - 1; i++) {
      if (!lim[i]) continue;
      if (link[i] == -1 && !dfs(i, ++cas)) {
        ok = 0;
        break;
      }
    }
    if (!ok) {
      printf("NO\n");
      continue;
    }
    for (int i = 0; i <= n * m - 1; i++)
      if (ans[i] == 0) Find(i);
    printf("YES\n");
    for (int i = 0; i <= n - 1; i++) {
      for (int j = 0; j <= m - 1; j++) printf("%d ", ans[C(i, j)]);
      printf("\n");
    }
    for (int i = 0; i <= n - 1; i++) {
      for (int j = 0; j <= m - 1; j++) printf("%c ", d[C(i, j)]);
      printf("\n");
    }
    cnt = 0;
    for (int i = 0; i <= n * m - 1; i++)
      lim[i] = ans[i] = d[i] = used[i] = lst[i] = 0, link[i] = -1;
  }
}

```


### Prompt

Please create a solution in cpp to the following problem:

You have a knapsack with the capacity of W. There are also n items, the i-th one has weight w_i.

You want to put some of these items into the knapsack in such a way that their total weight C is at least half of its size, but (obviously) does not exceed it. Formally, C should satisfy: ⌈ W/2⌉ ≤ C ≤ W.

Output the list of items you will put into the knapsack or determine that fulfilling the conditions is impossible.

If there are several possible lists of items satisfying the conditions, you can output any. Note that you don't have to maximize the sum of weights of items in the knapsack.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^4). Description of the test cases follows.

The first line of each test case contains integers n and W (1 ≤ n ≤ 200 000, 1≤ W ≤ 10^{18}).

The second line of each test case contains n integers w_1, w_2, ..., w_n (1 ≤ w_i ≤ 10^9) — weights of the items.

The sum of n over all test cases does not exceed 200 000.

Output

For each test case, if there is no solution, print a single integer -1.

If there exists a solution consisting of m items, print m in the first line of the output and m integers j_1, j_2, ..., j_m (1 ≤ j_i ≤ n, all j_i are distinct) in the second line of the output — indices of the items you would like to pack into the knapsack.

If there are several possible lists of items satisfying the conditions, you can output any. Note that you don't have to maximize the sum of weights items in the knapsack.

Example

Input

3
1 3
3
6 2
19 8 19 69 9 4
7 12
1 1 1 17 1 1 1

Output

1
1
-1
6
1 2 3 5 6 7

Note

In the first test case, you can take the item of weight 3 and fill the knapsack just right.

In the second test case, all the items are larger than the knapsack's capacity. Therefore, the answer is -1.

In the third test case, you fill the knapsack exactly in half.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct node {
  long long int p;
  long long int q;
};
vector<long long int> v;
struct node a[200005];
bool ram(struct node x, struct node y) { return x.p < y.p; }
int main() {
  long long int b[200005], x, y, z, i, flag, l, j;
  cin >> x;
  while (x--) {
    cin >> y >> z;
    a[0].p = 0;
    for (i = 1; i <= y; i++) {
      cin >> a[i].p;
      a[i].q = i;
    }
    sort(a, a + y + 1, ram);
    b[0] = 0;
    for (i = 1; i <= y; i++) b[i] = a[i].p + b[i - 1];
    i = 0;
    j = 1;
    while (i < j && j <= y && i <= y) {
      if (b[j] - b[i] >= ((z + 1) / 2) && b[j] - b[i] <= z) {
        for (int k = i + 1; k <= j; k++) v.push_back(a[k].q);
        break;
      } else if (b[j] - b[i] > z)
        i++;
      else if (b[j] - b[i] < (z + 1) / 2)
        j++;
    }
    if (v.size() == 0)
      cout << -1 << endl;
    else {
      cout << v.size() << endl;
      for (auto k : v) cout << k << " ";
      cout << endl;
    }
    v.clear();
  }
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

You play a strategic video game (yeah, we ran out of good problem legends). In this game you control a large army, and your goal is to conquer n castles of your opponent.

Let's describe the game process in detail. Initially you control an army of k warriors. Your enemy controls n castles; to conquer the i-th castle, you need at least a_i warriors (you are so good at this game that you don't lose any warriors while taking over a castle, so your army stays the same after the fight). After you take control over a castle, you recruit new warriors into your army — formally, after you capture the i-th castle, b_i warriors join your army. Furthermore, after capturing a castle (or later) you can defend it: if you leave at least one warrior in a castle, this castle is considered defended. Each castle has an importance parameter c_i, and your total score is the sum of importance values over all defended castles. There are two ways to defend a castle:

  * if you are currently in the castle i, you may leave one warrior to defend castle i;
  * there are m one-way portals connecting the castles. Each portal is characterised by two numbers of castles u and v (for each portal holds u > v). A portal can be used as follows: if you are currently in the castle u, you may send one warrior to defend castle v.

Obviously, when you order your warrior to defend some castle, he leaves your army.

You capture the castles in fixed order: you have to capture the first one, then the second one, and so on. After you capture the castle i (but only before capturing castle i + 1) you may recruit new warriors from castle i, leave a warrior to defend castle i, and use any number of portals leading from castle i to other castles having smaller numbers. As soon as you capture the next castle, these actions for castle i won't be available to you.

If, during some moment in the game, you don't have enough warriors to capture the next castle, you lose. Your goal is to maximize the sum of importance values over all defended castles (note that you may hire new warriors in the last castle, defend it and use portals leading from it even after you capture it — your score will be calculated afterwards).

Can you determine an optimal strategy of capturing and defending the castles?

Input

The first line contains three integers n, m and k (1 ≤ n ≤ 5000, 0 ≤ m ≤ min((n(n - 1))/(2), 3 ⋅ 10^5), 0 ≤ k ≤ 5000) — the number of castles, the number of portals and initial size of your army, respectively.

Then n lines follow. The i-th line describes the i-th castle with three integers a_i, b_i and c_i (0 ≤ a_i, b_i, c_i ≤ 5000) — the number of warriors required to capture the i-th castle, the number of warriors available for hire in this castle and its importance value.

Then m lines follow. The i-th line describes the i-th portal with two integers u_i and v_i (1 ≤ v_i < u_i ≤ n), meaning that the portal leads from the castle u_i to the castle v_i. There are no two same portals listed.

It is guaranteed that the size of your army won't exceed 5000 under any circumstances (i. e. k + ∑_{i = 1}^{n} b_i ≤ 5000).

Output

If it's impossible to capture all the castles, print one integer -1.

Otherwise, print one integer equal to the maximum sum of importance values of defended castles.

Examples

Input

4 3 7
7 4 17
3 0 8
11 2 0
13 3 5
3 1
2 1
4 3

Output

5

Input

4 3 7
7 4 17
3 0 8
11 2 0
13 3 5
3 1
2 1
4 1

Output

22

Input

4 3 7
7 4 17
3 0 8
11 2 0
14 3 5
3 1
2 1
4 3

Output

-1

Note

The best course of action in the first example is as follows:

  1. capture the first castle;
  2. hire warriors from the first castle, your army has 11 warriors now;
  3. capture the second castle;
  4. capture the third castle;
  5. hire warriors from the third castle, your army has 13 warriors now;
  6. capture the fourth castle;
  7. leave one warrior to protect the fourth castle, your army has 12 warriors now.

This course of action (and several other ones) gives 5 as your total score.

The best course of action in the second example is as follows:

  1. capture the first castle;
  2. hire warriors from the first castle, your army has 11 warriors now;
  3. capture the second castle;
  4. capture the third castle;
  5. hire warriors from the third castle, your army has 13 warriors now;
  6. capture the fourth castle;
  7. leave one warrior to protect the fourth castle, your army has 12 warriors now;
  8. send one warrior to protect the first castle through the third portal, your army has 11 warriors now.

This course of action (and several other ones) gives 22 as your total score.

In the third example it's impossible to capture the last castle: you need 14 warriors to do so, but you can accumulate no more than 13 without capturing it.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n, m, k, a[N], b[N], c[N], mx[N], dp[N];
vector<int> G[N];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    mx[i] = i;
  }
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d%d", &u, &v);
    mx[v] = max(mx[v], u);
  }
  for (int i = 1; i <= n; i++) G[mx[i]].push_back(c[i]);
  for (int i = k + 1; i < N; i++) dp[i] = -1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < a[i]; j++) dp[j] = -1;
    for (int j = N - 1; j >= b[i]; j--) dp[j] = dp[j - b[i]];
    for (auto v : G[i]) {
      for (int j = 0; j < N - 1; j++) {
        if (dp[j + 1] == -1) continue;
        dp[j] = max(dp[j], dp[j + 1] + v);
      }
    }
  }
  int ans = -1;
  for (int i = 0; i < N; i++) ans = max(ans, dp[i]);
  printf("%d\n", ans);
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

When Petya went to school, he got interested in large numbers and what they were called in ancient times. For instance, he learned that the Russian word "tma" (which now means "too much to be counted") used to stand for a thousand and "tma tmyschaya" (which literally means "the tma of tmas") used to stand for a million.

Petya wanted to modernize the words we use for numbers and invented a word petricium that represents number k. Moreover, petricium la petricium stands for number k2, petricium la petricium la petricium stands for k3 and so on. All numbers of this form are called petriciumus cifera, and the number's importance is the number of articles la in its title.

Petya's invention brought on a challenge that needed to be solved quickly: does some number l belong to the set petriciumus cifera? As Petya is a very busy schoolboy he needs to automate the process, he asked you to solve it.

Input

The first input line contains integer number k, the second line contains integer number l (2 ≤ k, l ≤ 231 - 1).

Output

You should print in the first line of the output "YES", if the number belongs to the set petriciumus cifera and otherwise print "NO". If the number belongs to the set, then print on the seconds line the only number — the importance of number l.

Examples

Input

5
25

Output

YES
1

Input

3
8

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
int n, k, s;
int main() {
  scanf("%d%d", &k, &n);
  while (n > k && n % k == 0) {
    s++;
    n /= k;
  }
  if (n != k)
    printf("NO\n");
  else
    printf("YES\n%d\n", s);
}

```


### Prompt

Create a solution in CPP for the following problem:

For the multiset of positive integers s=\\{s_1,s_2,...,s_k\}, define the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) of s as follow:

  * \gcd(s) is the maximum positive integer x, such that all integers in s are divisible on x.
  * lcm(s) is the minimum positive integer x, that divisible on all integers from s.

For example, \gcd(\{8,12\})=4,\gcd(\{12,18,6\})=6 and lcm(\{4,6\})=12. Note that for any positive integer x, \gcd(\\{x\})=lcm(\\{x\})=x.

Orac has a sequence a with length n. He come up with the multiset t=\{lcm(\\{a_i,a_j\})\ |\ i<j\}, and asked you to find the value of \gcd(t) for him. In other words, you need to calculate the GCD of LCMs of all pairs of elements in the given sequence.

Input

The first line contains one integer n\ (2≤ n≤ 100 000).

The second line contains n integers, a_1, a_2, …, a_n (1 ≤ a_i ≤ 200 000).

Output

Print one integer: \gcd(\{lcm(\\{a_i,a_j\})\ |\ i<j\}).

Examples

Input

2
1 1

Output

1

Input

4
10 24 40 80

Output

40

Input

10
540 648 810 648 720 540 594 864 972 648

Output

54

Note

For the first example, t=\{lcm(\{1,1\})\}=\{1\}, so \gcd(t)=1.

For the second example, t=\{120,40,80,120,240,80\}, and it's not hard to see that \gcd(t)=40.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, i, a[100005], suf[100005];
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = n; i >= 1; i--) suf[i] = gcd(suf[i + 1], a[i]);
  ll ans = 0;
  for (i = 1; i <= n - 1; i++)
    ans = gcd(ans, a[i] / gcd(a[i], suf[i + 1]) * suf[i + 1]);
  cout << ans << endl;
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

You are given a sequence of numbers a1, a2, ..., an, and a number m.

Check if it is possible to choose a non-empty subsequence aij such that the sum of numbers in this subsequence is divisible by m.

Input

The first line contains two numbers, n and m (1 ≤ n ≤ 106, 2 ≤ m ≤ 103) — the size of the original sequence and the number such that sum should be divisible by it.

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

Output

In the single line print either "YES" (without the quotes) if there exists the sought subsequence, or "NO" (without the quotes), if such subsequence doesn't exist.

Examples

Input

3 5
1 2 3

Output

YES

Input

1 6
5

Output

NO

Input

4 6
3 1 1 3

Output

YES

Input

6 6
5 5 5 5 5 5

Output

YES

Note

In the first sample test you can choose numbers 2 and 3, the sum of which is divisible by 5.

In the second sample test the single non-empty subsequence of numbers is a single number 5. Number 5 is not divisible by 6, that is, the sought subsequence doesn't exist.

In the third sample test you need to choose two numbers 3 on the ends.

In the fourth sample test you can take the whole subsequence.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  int r, i;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long int a[1000100];
long long int b[1000100];
long long int c[10001];
int main() {
  long long int i, j, n, m, k, x;
  scanf("%lld", &n);
  scanf("%lld", &m);
  set<long long int> s1;
  map<long long int, long long int> mp;
  int f = 0;
  for (i = (0); i < (n); i++) {
    scanf("%lld", &a[i]);
    k = a[i] % m;
    if (k == 0) {
      f = 1;
    }
    if (f == 0) {
      if (i == 0) {
        s1.insert(k);
        mp[k] = 1;
      } else {
        long long int ar[1001];
        j = 0;
        long long int v1 = a[i] % m;
        if (v1 == 0) {
          f = 1;
        } else {
          ar[j++] = v1;
        }
        set<long long int>::iterator it;
        for (it = s1.begin(); it != s1.end(); it++) {
          long long int po = *it;
          long long int vv = (po + a[i]) % m;
          if (vv == 0) {
            f = 1;
            break;
          }
          ar[j++] = vv;
        }
        if (f == 0) {
          int i1;
          for (i1 = 0; i1 < j; i1++) {
            s1.insert(ar[i1]);
            mp[ar[i1]] = 1;
          }
        }
      }
    }
  }
  if (f == 1)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}

```


### Prompt

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

You have an array a consisting of n integers. Each integer from 1 to n appears exactly once in this array.

For some indices i (1 ≤ i ≤ n - 1) it is possible to swap i-th element with (i + 1)-th, for other indices it is not possible. You may perform any number of swapping operations any order. There is no limit on the number of times you swap i-th element with (i + 1)-th (if the position is not forbidden).

Can you make this array sorted in ascending order performing some sequence of swapping operations?

Input

The first line contains one integer n (2 ≤ n ≤ 200000) — the number of elements in the array.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 200000) — the elements of the array. Each integer from 1 to n appears exactly once.

The third line contains a string of n - 1 characters, each character is either 0 or 1. If i-th character is 1, then you can swap i-th element with (i + 1)-th any number of times, otherwise it is forbidden to swap i-th element with (i + 1)-th.

Output

If it is possible to sort the array in ascending order using any sequence of swaps you are allowed to make, print YES. Otherwise, print NO.

Examples

Input

6
1 2 5 3 4 6
01110

Output

YES

Input

6
1 2 5 3 4 6
01010

Output

NO

Note

In the first example you may swap a3 and a4, and then swap a4 and a5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int v[n];
  for (int i = 0; i < n; i++) cin >> v[i];
  vector<pair<int, int> > to_sort;
  int l = -1;
  for (int i = 0; i < n - 1; i++) {
    char c;
    cin >> c;
    if (c == '1') {
      if (l == -1) l = i;
    } else {
      if (l != -1) sort(v + l, v + i + 1);
      l = -1;
    }
  }
  if (l != -1 && l < n) sort(v + l, v + n);
  bool ordered = true;
  for (int i = 1; i < n; i++)
    if (v[i - 1] > v[i]) ordered = false;
  if (ordered)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

```


### Prompt

Create a solution in CPP for the following problem:

Amugae is in a very large round corridor. The corridor consists of two areas. The inner area is equally divided by n sectors, and the outer area is equally divided by m sectors. A wall exists between each pair of sectors of same area (inner or outer), but there is no wall between the inner area and the outer area. A wall always exists at the 12 o'clock position.

<image>

The inner area's sectors are denoted as (1,1), (1,2), ..., (1,n) in clockwise direction. The outer area's sectors are denoted as (2,1), (2,2), ..., (2,m) in the same manner. For a clear understanding, see the example image above.

Amugae wants to know if he can move from one sector to another sector. He has q questions.

For each question, check if he can move between two given sectors.

Input

The first line contains three integers n, m and q (1 ≤ n, m ≤ 10^{18}, 1 ≤ q ≤ 10^4) — the number of sectors in the inner area, the number of sectors in the outer area and the number of questions.

Each of the next q lines contains four integers s_x, s_y, e_x, e_y (1 ≤ s_x, e_x ≤ 2; if s_x = 1, then 1 ≤ s_y ≤ n, otherwise 1 ≤ s_y ≤ m; constraints on e_y are similar). Amague wants to know if it is possible to move from sector (s_x, s_y) to sector (e_x, e_y).

Output

For each question, print "YES" if Amugae can move from (s_x, s_y) to (e_x, e_y), and "NO" otherwise.

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

Example

Input

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

Output

YES
NO
YES

Note

Example is shown on the picture in the statement.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 7;
long long n, m, q;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  scanf("%lld%lld%lld", &n, &m, &q);
  long long d = gcd(n, m);
  long long t1 = n / d;
  long long t2 = m / d;
  while (q--) {
    long long x, y, a, b;
    scanf("%lld%lld%lld%lld", &x, &y, &a, &b);
    if (n == 1 || m == 1) {
      printf("YES\n");
      continue;
    }
    if (x == a) {
      if (x == 1) {
        if ((y - 1) / t1 == (b - 1) / t1)
          printf("YES\n");
        else
          printf("NO\n");
      } else {
        if ((y - 1) / t2 == (b - 1) / t2)
          printf("YES\n");
        else
          printf("NO\n");
      }
    } else {
      if (x == 1) {
        if ((y - 1) / t1 == (b - 1) / t2)
          printf("YES\n");
        else
          printf("NO\n");
      } else {
        if ((y - 1) / t2 == (b - 1) / t1)
          printf("YES\n");
        else
          printf("NO\n");
      }
    }
  }
}

```


### Prompt

Generate a CPP solution to the following problem:

You are given sequence a1, a2, ..., an and m queries lj, rj (1 ≤ lj ≤ rj ≤ n). For each query you need to print the minimum distance between such pair of elements ax and ay (x ≠ y), that:

  * both indexes of the elements lie within range [lj, rj], that is, lj ≤ x, y ≤ rj;
  * the values of the elements are equal, that is ax = ay.

The text above understands distance as |x - y|.

Input

The first line of the input contains a pair of integers n, m (1 ≤ n, m ≤ 5·105) — the length of the sequence and the number of queries, correspondingly.

The second line contains the sequence of integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).

Next m lines contain the queries, one per line. Each query is given by a pair of numbers lj, rj (1 ≤ lj ≤ rj ≤ n) — the indexes of the query range limits.

Output

Print m integers — the answers to each query. If there is no valid match for some query, please print -1 as an answer to this query.

Examples

Input

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

Output

1
-1
2

Input

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

Output

2
2
3
-1
2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9, maxn = (int)1e5 + 1;
const double eps = (double)1e-8;
const int mod = (int)1000000009;
int x, l, r, a[1000006], b[1000006], n, m, ans;
vector<pair<int, int> > p[2000006];
map<int, int> ma;
void build(int v, int l, int r) {
  if (l == r) {
    if (b[l] > 0) p[v].push_back(make_pair(b[l], b[l] - l));
    return;
  }
  int m, to1, to2;
  m = (l + r) / 2;
  to1 = v * 2;
  to2 = v * 2 + 1;
  build(to1, l, m);
  build(to2, m + 1, r);
  for (int i = 0; i < p[to1].size(); i++) p[v].push_back(p[to1][i]);
  for (int i = 0; i < p[to2].size(); i++) p[v].push_back(p[to2][i]);
  sort(p[v].begin(), p[v].begin() + p[v].size());
  for (int i = 1; i < p[v].size(); i++)
    p[v][i].second = (min(p[v][i].second, p[v][i - 1].second));
  return;
}
void dzen(int v, int l, int r, int tl, int tr) {
  if (r < tl || l > tr) return;
  int m;
  if (l >= tl && r <= tr) {
    l = 0;
    r = p[v].size() - 1;
    if (r == -1) return;
    while (l < r) {
      m = (l + r) / 2;
      if (p[v][m].first >= tr)
        r = m;
      else
        l = m + 1;
    }
    l = min((int)p[v].size() - 1, l);
    if (p[v][l].first > tr) l--;
    if (l >= 0) {
      x = p[v][l].second;
      if (ans == -1 || ans > x) ans = x;
    }
    return;
  }
  m = (l + r) / 2;
  dzen(2 * v, l, m, tl, tr);
  dzen(2 * v + 1, m + 1, r, tl, tr);
  return;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &(a[i]));
    x = ma[a[i]];
    if (x > 0) b[x] = i;
    ma[a[i]] = i;
  }
  build(1, 1, n);
  while (m--) {
    scanf("%d", &(l));
    scanf("%d", &(r));
    ans = -1;
    dzen(1, 1, n, l, r);
    cout << ans;
    printf("\n");
  }
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Denis was very sad after Nastya rejected him. So he decided to walk through the gateways to have some fun. And luck smiled at him! When he entered the first courtyard, he met a strange man who was selling something.

Denis bought a mysterious item and it was... Random permutation generator! Denis could not believed his luck.

When he arrived home, he began to study how his generator works and learned the algorithm. The process of generating a permutation consists of n steps. At the i-th step, a place is chosen for the number i (1 ≤ i ≤ n). The position for the number i is defined as follows:

  * For all j from 1 to n, we calculate r_j — the minimum index such that j ≤ r_j ≤ n, and the position r_j is not yet occupied in the permutation. If there are no such positions, then we assume that the value of r_j is not defined.
  * For all t from 1 to n, we calculate count_t — the number of positions 1 ≤ j ≤ n such that r_j is defined and r_j = t.
  * Consider the positions that are still not occupied by permutation and among those we consider the positions for which the value in the count array is maximum.
  * The generator selects one of these positions for the number i. The generator can choose any position.

Let's have a look at the operation of the algorithm in the following example:

<image>

Let n = 5 and the algorithm has already arranged the numbers 1, 2, 3 in the permutation. Consider how the generator will choose a position for the number 4:

  * The values of r will be r = [3, 3, 3, 4, ×], where × means an indefinite value.
  * Then the count values will be count = [0, 0, 3, 1, 0].
  * There are only two unoccupied positions in the permutation: 3 and 4. The value in the count array for position 3 is 3, for position 4 it is 1.
  * The maximum value is reached only for position 3, so the algorithm will uniquely select this position for number 4.

Satisfied with his purchase, Denis went home. For several days without a break, he generated permutations. He believes that he can come up with random permutations no worse than a generator. After that, he wrote out the first permutation that came to mind p_1, p_2, …, p_n and decided to find out if it could be obtained as a result of the generator.

Unfortunately, this task was too difficult for him, and he asked you for help. It is necessary to define whether the written permutation could be obtained using the described algorithm if the generator always selects the position Denis needs.

Input

The first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases. Then the descriptions of the test cases follow.

The first line of the test case contains a single integer n (1 ≤ n ≤ 10^5) — the size of the permutation.

The second line of the test case contains n different integers p_1, p_2, …, p_n (1 ≤ p_i ≤ n) — the permutation written by Denis.

It is guaranteed that the sum of n over all test cases doesn't exceed 10^5.

Output

Print "Yes" if this permutation could be obtained as a result of the generator. Otherwise, print "No".

All letters can be displayed in any case.

Example

Input

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

Output

Yes
Yes
No
Yes
No

Note

Let's simulate the operation of the generator in the first test.

At the 1 step, r = [1, 2, 3, 4, 5], count = [1, 1, 1, 1, 1]. The maximum value is reached in any free position, so the generator can choose a random position from 1 to 5. In our example, it chose 5.

At the 2 step, r = [1, 2, 3, 4, ×], count = [1, 1, 1, 1, 0]. The maximum value is reached in positions from 1 to 4, so the generator can choose a random position among them. In our example, it chose 1.

At the 3 step, r = [2, 2, 3, 4, ×], count = [0, 2, 1, 1, 0]. The maximum value is 2 and is reached only at the 2 position, so the generator will choose this position.

At the 4 step, r = [3, 3, 3, 4, ×], count = [0, 0, 3, 1, 0]. The maximum value is 3 and is reached only at the 3 position, so the generator will choose this position.

At the 5 step, r = [4, 4, 4, 4, ×], count = [0, 0, 0, 4, 0]. The maximum value is 4 and is reached only at the 4 position, so the generator will choose this position.

In total, we got a permutation of 2, 3, 4, 5, 1, that is, a generator could generate it.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long t[1000000];
long long a[1000000], f[1000000];
void build(long long v, long long tl, long long tr) {
  if (tl == tr) {
    t[v] = 0;
  } else {
    long long tm = (tl + tr) / 2;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v] = 0;
  }
}
void update(long long v, long long tl, long long tr, long long pos,
            long long new_val) {
  if (tl == tr) {
    t[v] = new_val;
  } else {
    long long tm = (tl + tr) / 2;
    if (pos <= tm)
      update(v * 2, tl, tm, pos, new_val);
    else
      update(v * 2 + 1, tm + 1, tr, pos, new_val);
    t[v] = max(t[v * 2], t[v * 2 + 1]);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long q, n, i, j, c, k, m, x, y;
  cin >> q;
  while (q--) {
    cin >> n;
    for (i = 0; i < n; i++) cin >> x, a[x] = i;
    for (i = 0; i < n; i++) {
      f[i] = 0;
    }
    build(1, 0, n - 1);
    c = 1;
    for (i = 1; i <= n; i++) {
      m = t[1];
      if (f[a[i]] == m) {
        update(1, 0, n - 1, a[i], -1);
        if (a[i] != n - 1) {
          if (f[a[i] + 1] != -1) {
            f[a[i] + 1] = f[a[i]] + 1;
            update(1, 0, n - 1, a[i] + 1, f[a[i]] + 1);
          }
        }
        f[a[i]] = -1;
      } else {
        c = 0;
      }
    }
    if (c)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}

```


### Prompt

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

Argus was charged with guarding Io, which is not an ordinary cow. Io is quite an explorer, and she wanders off rather frequently, making Argus' life stressful. So the cowherd decided to construct an enclosed pasture for Io.

There are n trees growing along the river, where Argus tends Io. For this problem, the river can be viewed as the OX axis of the Cartesian coordinate system, and the n trees as points with the y-coordinate equal 0. There is also another tree growing in the point (0, 1).

Argus will tie a rope around three of the trees, creating a triangular pasture. Its exact shape doesn't matter to Io, but its area is crucial to her. There may be many ways for Argus to arrange the fence, but only the ones which result in different areas of the pasture are interesting for Io. Calculate the number of different areas that her pasture may have. Note that the pasture must have nonzero area.

Input

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

In the first line of each test case there is a single integer n (1 ≤ n ≤ 50) denoting the number of trees growing along the river. Next line contains n distinct integers x_1 < x_2 < … < x_{n - 1} < x_n (1 ≤ x_i ≤ 50), the x-coordinates of trees growing along the river.

Output

In a single line output an integer, the number of different nonzero areas that triangles with trees as vertices may have.

Example

Input

8
4
1 2 4 5
3
1 3 5
3
2 6 8
2
1 2
1
50
5
3 4 5 6 8
3
1 25 26
6
1 2 4 8 16 32

Output

4
2
3
1
0
5
3
15

Note

In the first test case, we have 6 non-degenerate triangles with the following areas: 0.5, 0.5, 1, 1.5, 1.5 and 2. The pasture can have 4 different areas, and thus 4 is the answer.

In the second test case, we have 3 non-degenerate triangles with the following areas: 1, 1 and 2. The pasture can have 2 different areas, so 2 is the answer.

The following two drawings present the situation in the second test case. The blue triangles in the first drawing have area 1. The red triangle in the second drawing has area 2.

<image>

### Response

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

using namespace std;

const int N = 55;

int T;
int n;
int a[N];

int main() {
	scanf("%d", &T);
	while (T --) {
		scanf("%d", &n);
		for (int i = 0; i < n; ++i) scanf("%d", &a[i]);

		set<int> ans;
		for (int i = 0; i < n - 1; ++i) {
			for (int j = i + 1; j < n; ++j) {
				ans.insert(a[j] - a[i]);
			}
		}

		printf("%d\n", ans.size());
	}

	return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Grandma Laura came to the market to sell some apples. During the day she sold all the apples she had. But grandma is old, so she forgot how many apples she had brought to the market.

She precisely remembers she had n buyers and each of them bought exactly half of the apples she had at the moment of the purchase and also she gave a half of an apple to some of them as a gift (if the number of apples at the moment of purchase was odd), until she sold all the apples she had.

So each buyer took some integral positive number of apples, but maybe he didn't pay for a half of an apple (if the number of apples at the moment of the purchase was odd).

For each buyer grandma remembers if she gave a half of an apple as a gift or not. The cost of an apple is p (the number p is even).

Print the total money grandma should have at the end of the day to check if some buyers cheated her.

Input

The first line contains two integers n and p (1 ≤ n ≤ 40, 2 ≤ p ≤ 1000) — the number of the buyers and the cost of one apple. It is guaranteed that the number p is even.

The next n lines contains the description of buyers. Each buyer is described with the string half if he simply bought half of the apples and with the string halfplus if grandma also gave him a half of an apple as a gift.

It is guaranteed that grandma has at least one apple at the start of the day and she has no apples at the end of the day.

Output

Print the only integer a — the total money grandma should have at the end of the day.

Note that the answer can be too large, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.

Examples

Input

2 10
half
halfplus

Output

15

Input

3 10
halfplus
halfplus
halfplus

Output

55

Note

In the first sample at the start of the day the grandma had two apples. First she sold one apple and then she sold a half of the second apple and gave a half of the second apple as a present to the second buyer.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p;
  string a[101000];
  cin >> n >> p;
  long long num = 0, ans = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = n; i >= 1; i--) {
    num *= 2;
    if (a[i] == "halfplus") num += 1;
    ans += num * p;
  }
  cout << ans / 2 << endl;
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

This is the easy version of the problem. The difference is the constraint on the sum of lengths of strings and the number of test cases. You can make hacks only if you solve all versions of this task.

You are given a string s, consisting of lowercase English letters. Find the longest string, t, which satisfies the following conditions:

  * The length of t does not exceed the length of s.
  * t is a palindrome.
  * There exists two strings a and b (possibly empty), such that t = a + b ( "+" represents concatenation), and a is prefix of s while b is suffix of s.

Input

The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000), the number of test cases. The next t lines each describe a test case.

Each test case is a non-empty string s, consisting of lowercase English letters.

It is guaranteed that the sum of lengths of strings over all test cases does not exceed 5000.

Output

For each test case, print the longest string which satisfies the conditions described above. If there exists multiple possible solutions, print any of them.

Example

Input

5
a
abcdfdcecba
abbaxyzyx
codeforces
acbba

Output

a
abcdfdcba
xyzyx
c
abba

Note

In the first test, the string s = "a" satisfies all conditions.

In the second test, the string "abcdfdcba" satisfies all conditions, because:

  * Its length is 9, which does not exceed the length of the string s, which equals 11.
  * It is a palindrome.
  * "abcdfdcba" = "abcdfdc" + "ba", and "abcdfdc" is a prefix of s while "ba" is a suffix of s.

It can be proven that there does not exist a longer string which satisfies the conditions.

In the fourth test, the string "c" is correct, because "c" = "c" + "" and a or b can be empty. The other possible solution for this test is "s".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool pal(string s) {
  string rs = s;
  reverse(rs.begin(), rs.end());
  return rs == s;
}
int longest_palindrome_prefix(const string &s) {
  string kmprev = s;
  std::reverse(kmprev.begin(), kmprev.end());
  string kmp = s + "#" + kmprev;
  vector<int> lps(kmp.size(), 0);
  for (int i = 1; i < (int)lps.size(); ++i) {
    int prev_idx = lps[i - 1];
    while (prev_idx > 0 && kmp[i] != kmp[prev_idx]) {
      prev_idx = lps[prev_idx - 1];
    }
    lps[i] = prev_idx + (kmp[i] == kmp[prev_idx] ? 1 : 0);
  }
  return lps[lps.size() - 1];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string s, res;
    cin >> s;
    int len = s.length();
    if (len == 1) {
      cout << s << endl;
      continue;
    }
    int l = 0;
    int r = len - 1;
    while (l < r) {
      if (s[l] == s[r]) {
        res += s[l];
        l++;
        r--;
      } else
        break;
    }
    if (l >= r) {
      cout << s << endl;
      continue;
    }
    string revres = res;
    reverse(revres.begin(), revres.end());
    string rem;
    for (int i = l; i <= r; i++) rem += s[i];
    string revrem = rem;
    reverse(revrem.begin(), revrem.end());
    int l1 = longest_palindrome_prefix(rem);
    int l2 = longest_palindrome_prefix(revrem);
    string the_rest;
    string ans;
    if (l1 >= l2) {
      the_rest = rem.substr(0, l1);
      ans = res + the_rest + revres;
    } else {
      the_rest = revrem.substr(0, l2);
      reverse(the_rest.begin(), the_rest.end());
      ans = res + the_rest + revres;
    }
    cout << ans << endl;
  }
}

```


### Prompt

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

It is the year 2969. 1000 years have passed from the moon landing. Meanwhile, the humanity colonized the Hyperspace™ and lived in harmony.

Until we realized that we were not alone.

Not too far away from the Earth, the massive fleet of aliens' spaceships is preparing to attack the Earth. For the first time in a while, the humanity is in real danger. Crisis and panic are everywhere. The scientists from all around the solar system have met and discussed the possible solutions. However, no progress has been made.

The Earth's last hope is YOU!

Fortunately, the Earth is equipped with very powerful defense systems made by MDCS. There are N aliens' spaceships which form the line. The defense system consists of three types of weapons:

  * SQL rockets – every SQL rocket can destroy at most one spaceship in the given set.
  * Cognition beams – every Cognition beam has an interval [l,r] and can destroy at most one spaceship in that interval.
  * OMG bazooka – every OMG bazooka has three possible targets, however, each bazooka can destroy either zero or exactly two spaceships. In addition, due to the smart targeting system, the sets of the three possible targets of any two different OMG bazookas are disjoint (that means that every ship is targeted with at most one OMG bazooka).

Your task is to make a plan of the attack which will destroy the largest possible number of spaceships. Every destroyed spaceship should be destroyed with exactly one weapon.

Input

The first line contains two integers: the number of your weapons N (1≤ N≤ 5000) and the number of spaceships M (1≤ M≤ 5000).

In the next N lines, each line starts with one integer that represents type (either 0, 1 or 2). If the type is 0, then the weapon is SQL rocket, the rest of the line contains strictly positive number K (∑{K} ≤ 100 000) and array k_i (1≤ k_i≤ M) of K integers. If the type is 1, then the weapon is Cognition beam, the rest of the line contains integers l and r (1≤ l≤ r≤ M). If the type is 2 then the weapon is OMG bazooka, the rest of the line contains distinct numbers a, b and c  (1 ≤ a,b,c ≤ M).

Output

The first line should contain the maximum number of destroyed spaceships — X.

In the next X lines, every line should contain two numbers A and B, where A is an index of the weapon and B is an index of the spaceship which was destroyed by the weapon A.

Example

Input

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

Output

4
2 1
3 2
1 4
2 5

Note

SQL rocket can destroy only 4th spaceship. OMG Bazooka can destroy two of 1st, 4th or 5th spaceship, and Cognition beam can destroy any spaceship from the interval [1,4]. The maximum number of destroyed spaceship is 4, and one possible plan is that SQL rocket should destroy 4th spaceship, OMG bazooka should destroy 1st and 5th spaceship and Cognition beam should destroy 2nd spaceship.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int iinf = 1 << 29;
const int inf = iinf;
const long long mod = 1e9 + 7;
const int maxn = 5005;
void GG() {
  cout << "No\n";
  exit(0);
}
long long mpow(long long a, long long n, long long mo = mod) {
  long long re = 1;
  while (n > 0) {
    if (n & 1) re = re * a % mo;
    a = a * a % mo;
    n >>= 1;
  }
  return re;
}
long long inv(long long b, long long mo = mod) {
  if (b == 1) return b;
  return (mo - mo / b) * inv(mo % b) % mo;
}
struct Edge {
  int to, rev;
  long long cap, flow = 0;
  Edge(int to, int rev, long long cap) : to(to), rev(rev), cap(cap) {}
};
struct Dinic {
  vector<vector<Edge> > g;
  int n;
  int second, t;
  vector<int> level, ptr;
  Dinic(int n, int second, int t) : n(n), second(second), t(t) {
    level.resize(n, -1);
    ptr.resize(n);
    g.resize(n);
  }
  void add(int v, int u, long long cap) {
    g[v].push_back({u, (int)g[u].size(), cap});
    g[u].push_back({v, (int)g[v].size() - 1, 0});
  }
  bool bfs() {
    queue<int> q({second});
    level[second] = 0;
    while (!q.empty() && level[t] == -1) {
      int v = q.front();
      q.pop();
      for (auto &e : g[v]) {
        if (e.cap - e.flow == 0) continue;
        int u = e.to;
        if (level[u] == -1) {
          level[u] = level[v] + 1;
          q.push(u);
        }
      }
    }
    return level[t] != -1;
  }
  long long dfs(int v, long long amt) {
    if (amt == 0 || v == t) return amt;
    for (; ptr[v] < (int)g[v].size(); ptr[v]++) {
      Edge &e = g[v][ptr[v]];
      int u = e.to;
      if (level[u] == level[v] + 1) {
        long long tt = dfs(u, min(amt, e.cap - e.flow));
        if (tt == 0) continue;
        e.flow += tt;
        g[e.to][e.rev].flow -= tt;
        return tt;
      }
    }
    return 0;
  }
  long long mf() {
    long long re = 0;
    while (bfs()) {
      while (long long amt = dfs(second, inf)) re += amt;
      fill(level.begin(), level.end(), -1);
      fill(ptr.begin(), ptr.end(), 0);
    }
    return re;
  }
};
int seg[maxn];
int dmax = 5e4 + 10;
int sgst = 1e4 + 5;
int S = dmax - 1, T = dmax - 2;
Dinic dd(dmax, S, T);
void BUILD(int o, int l, int r) {
  int mid = (l + r) / 2;
  if (l > r) return;
  if (l == r) {
    dd.add(o / 2 + sgst, l + 5000, inf);
    return;
  } else if (o != 1) {
    dd.add(o / 2 + sgst, o + sgst, inf);
  }
  BUILD(o * 2, l, mid);
  BUILD(o * 2 + 1, mid + 1, r);
}
int from = -1;
void ADD(int o, int l, int r, int L, int R) {
  if (l > R || r < L) return;
  if (l >= L && r <= R) {
    if (l == r) {
      dd.add(from, l + 5000, 1);
      return;
    }
    dd.add(from, o + sgst, 1);
    return;
  }
  int mid = (l + r) / 2;
  ADD(o * 2, l, mid, L, R);
  ADD(o * 2 + 1, mid + 1, r, L, R);
}
int TOP[maxn];
bool cancel[maxn * 3];
int dofe(int at, int p) {
  if (at <= sgst && at >= 5000) return at;
  for (Edge &e : dd.g[at]) {
    if (e.flow >= 1 && e.to != p) {
      int mo = dofe(e.to, at);
      if (mo != -1) {
        e.flow--;
        return mo;
      }
    }
  }
  return -1;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  BUILD(1, 0, m - 1);
  for (int i = 0; i < (n); i++) {
    int TP;
    cin >> TP;
    TOP[i] = TP;
    if (TP == 0) {
      dd.add(S, i, 1);
      int K;
      cin >> K;
      for (int j = 0; j < (K); j++) {
        int to;
        cin >> to;
        dd.add(i, to - 1 + 5000, 1);
      }
    }
    if (TP == 1) {
      int l, r;
      cin >> l >> r;
      from = i;
      dd.add(S, i, 1);
      ADD(1, 0, m - 1, l - 1, r - 1);
    }
    if (TP == 2) {
      int a, b, c;
      cin >> a >> b >> c;
      dd.add(S, i, 2);
      dd.add(i, a + 5000 - 1, 1);
      dd.add(i, b + 5000 - 1, 1);
      dd.add(i, c + 5000 - 1, 1);
    }
  }
  for (int i = 0; i < (m); i++) {
    dd.add(i + 5000, T, 1);
  }
  cout << dd.mf() << '\n';
  for (Edge &e : dd.g[S]) {
    if (TOP[e.to] == 2) {
      for (Edge &e2 : dd.g[e.to]) {
        if (e2.to != S && e2.flow == 1) {
          cout << e.to + 1 << ' ' << e2.to + 1 - 5000 << '\n';
        } else if (e2.to != S && e.flow == 1 && e2.flow != 1) {
          e.flow++;
          cout << e.to + 1 << ' ' << e2.to + 1 - 5000 << '\n';
          cancel[e2.to] = 1;
        }
      }
    }
  }
  for (Edge &e : dd.g[S]) {
    if (TOP[e.to] == 0) {
      for (Edge &e2 : dd.g[e.to]) {
        if (e2.to != S && e2.flow == 1 && !cancel[e2.to]) {
          cout << e.to + 1 << ' ' << e2.to + 1 - 5000 << '\n';
        }
      }
    } else if (TOP[e.to] == 1) {
      int endp = dofe(e.to, S);
      if (endp != S && endp != -1 && !cancel[endp]) {
        cout << e.to + 1 << ' ' << endp + 1 - 5000 << '\n';
      }
    }
  }
}

```


### Prompt

Generate a CPP solution to the following problem:

Vasya often uses public transport. The transport in the city is of two types: trolleys and buses. The city has n buses and m trolleys, the buses are numbered by integers from 1 to n, the trolleys are numbered by integers from 1 to m.

Public transport is not free. There are 4 types of tickets:

  1. A ticket for one ride on some bus or trolley. It costs c1 burles;
  2. A ticket for an unlimited number of rides on some bus or on some trolley. It costs c2 burles;
  3. A ticket for an unlimited number of rides on all buses or all trolleys. It costs c3 burles;
  4. A ticket for an unlimited number of rides on all buses and trolleys. It costs c4 burles.

Vasya knows for sure the number of rides he is going to make and the transport he is going to use. He asked you for help to find the minimum sum of burles he will have to spend on the tickets.

Input

The first line contains four integers c1, c2, c3, c4 (1 ≤ c1, c2, c3, c4 ≤ 1000) — the costs of the tickets.

The second line contains two integers n and m (1 ≤ n, m ≤ 1000) — the number of buses and trolleys Vasya is going to use.

The third line contains n integers ai (0 ≤ ai ≤ 1000) — the number of times Vasya is going to use the bus number i.

The fourth line contains m integers bi (0 ≤ bi ≤ 1000) — the number of times Vasya is going to use the trolley number i.

Output

Print a single number — the minimum sum of burles Vasya will have to spend on the tickets.

Examples

Input

1 3 7 19
2 3
2 5
4 4 4

Output

12

Input

4 3 2 1
1 3
798
1 2 3

Output

1

Input

100 100 8 100
3 5
7 94 12
100 1 47 0 42

Output

16

Note

In the first sample the profitable strategy is to buy two tickets of the first type (for the first bus), one ticket of the second type (for the second bus) and one ticket of the third type (for all trolleys). It totals to (2·1) + 3 + 7 = 12 burles.

In the second sample the profitable strategy is to buy one ticket of the fourth type.

In the third sample the profitable strategy is to buy two tickets of the third type: for all buses and for all trolleys.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long powm(long long base, long long exp, long long mod = 1000000007) {
  long long ans = 1;
  while (exp) {
    if (exp & 1) ans = (ans * base) % mod;
    exp >>= 1, base = (base * base) % mod;
  }
  return ans;
}
long long a[100005], b[100005];
int main() {
  long long c1, c2, c3, c4, n, m;
  cin >> c1 >> c2 >> c3 >> c4 >> n >> m;
  for (long long i = 1; i < n + 1; i++) cin >> a[i];
  for (long long i = 1; i < m + 1; i++) cin >> b[i];
  long long ans = c4, ans1 = 0, ans2 = 0;
  for (long long i = 1; i < n + 1; i++) ans1 += min(c1 * a[i], c2);
  for (long long i = 1; i < m + 1; i++) ans2 += min(c1 * b[i], c2);
  ans = min(ans, ans1 + ans2);
  ans = min(ans, ans1 + c3);
  ans = min(ans, ans2 + c3);
  ans = min(ans, c3 + c3);
  cout << ans;
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

A colored stripe is represented by a horizontal row of n square cells, each cell is pained one of k colors. Your task is to repaint the minimum number of cells so that no two neighbouring cells are of the same color. You can use any color from 1 to k to repaint the cells.

Input

The first input line contains two integers n and k (1 ≤ n ≤ 5·105; 2 ≤ k ≤ 26). The second line contains n uppercase English letters. Letter "A" stands for the first color, letter "B" stands for the second color and so on. The first k English letters may be used. Each letter represents the color of the corresponding cell of the stripe.

Output

Print a single integer — the required minimum number of repaintings. In the second line print any possible variant of the repainted stripe.

Examples

Input

6 3
ABBACC

Output

2
ABCACA

Input

3 2
BBB

Output

1
BAB

### Response

```cpp
#include <bits/stdc++.h>
const int inf = 1500000000;
const int d = 1e9 + 7;
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (k == 2) {
      int c1, c2;
      c1 = c2 = 0;
      for (int i = 0; i < s.size(); i++) {
        if (s[i] != 'A' + (i % 2)) {
          c1++;
        }
        if (s[i] != 'A' + (1 - (i % 2))) {
          c2++;
        }
      }
      cout << min(c1, c2) << endl;
      if (c1 < c2) {
        for (int i = 0; i < s.size(); i++) {
          cout << (char)('A' + (i % 2));
        }
      } else {
        for (int i = 0; i < s.size(); i++) {
          cout << (char)('A' + (1 - i % 2));
        }
      }
      continue;
    }
    int ctr = 0;
    for (int i = 0; i < s.size() - 1; i++) {
      if (s[i] == s[i + 1]) {
        ctr++;
        bool choice[26];
        for (int i = 0; i < 26; i++) {
          choice[i] = true;
        }
        choice[s[i] - 'A'] = false;
        if (i + 2 < s.size()) choice[s[i + 2] - 'A'] = false;
        for (int j = 0; j < 3; j++) {
          if (choice[j] == true) {
            s[i + 1] = 'A' + j;
            break;
          }
        }
      }
    }
    cout << ctr << endl;
    cout << s << endl;
  }
  return 0;
}

```


### Prompt

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

After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.

The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.

A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of 7 because its subribbon a appears 7 times, and the ribbon abcdabc has the beauty of 2 because its subribbon abc appears twice.

The rules are simple. The game will have n turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after n turns wins the treasure.

Could you find out who is going to be the winner if they all play optimally?

Input

The first line contains an integer n (0 ≤ n ≤ 10^{9}) — the number of turns.

Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than 10^{5} uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.

Output

Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".

Examples

Input

3
Kuroo
Shiro
Katie

Output

Kuro

Input

7
treasurehunt
threefriends
hiCodeforces

Output

Shiro

Input

1
abcabc
cbabac
ababca

Output

Katie

Input

15
foPaErcvJ
mZaxowpbt
mkuOlaHRE

Output

Draw

Note

In the first example, after 3 turns, Kuro can change his ribbon into ooooo, which has the beauty of 5, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most 4, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.

In the fourth example, since the length of each of the string is 9 and the number of turn is 15, everyone can change their ribbons in some way to reach the maximal beauty of 9 by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  string a, b, c;
  vector<vector<long long> > arr(3, vector<long long>((26 * 2) + 1, 0));
  cin >> n;
  cin >> a >> b >> c;
  long long len = a.length();
  for (long long i = 0; i < len; i++) {
    char cur = a[i];
    if (cur >= 'a') {
      arr[0][cur - 97]++;
    } else {
      arr[0][cur - 65 + 26]++;
    }
  }
  for (long long i = 0; i < len; i++) {
    char cur = b[i];
    if (cur >= 'a') {
      arr[1][cur - 97]++;
    } else {
      arr[1][cur - 65 + 26]++;
    }
  }
  for (long long i = 0; i < len; i++) {
    char cur = c[i];
    if (cur >= 'a') {
      arr[2][cur - 97]++;
    } else {
      arr[2][cur - 65 + 26]++;
    }
  }
  for (long long i = 0; i < 52; i++) {
    if (arr[0][i] > arr[0][52]) {
      arr[0][52] = arr[0][i];
    }
    if (arr[1][i] > arr[1][52]) {
      arr[1][52] = arr[1][i];
    }
    if (arr[2][i] > arr[2][52]) {
      arr[2][52] = arr[2][i];
    }
  }
  long long x = arr[0][52], y = arr[1][52], z = arr[2][52];
  if (n == 1 && x == len) {
    x = len - 1;
  } else if (x + n >= len) {
    x = len;
  } else {
    x += n;
  }
  if (n == 1 && y == len) {
    y = len - 1;
  } else if (y + n >= len) {
    y = len;
  } else {
    y += n;
  }
  if (n == 1 && z == len) {
    z = len - 1;
  } else if (z + n >= len) {
    z = len;
  } else {
    z += n;
  }
  if (x > y && x > z) {
    cout << "Kuro\n";
  } else if (y > x && y > z) {
    cout << "Shiro\n";
  } else if (z > x && z > y) {
    cout << "Katie\n";
  } else {
    cout << "Draw\n";
  }
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

We have N cards. A number a_i is written on the i-th card.
Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.
The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.

Constraints

* N is an integer between 1 and 100 (inclusive).
* a_i \ (1 \leq i \leq N) is an integer between 1 and 100 (inclusive).

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 a_3 ... a_N

Output

Print Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.

Examples

Input

2
3 1

Output

2

Input

3
2 7 4

Output

5

Input

4
20 18 2 18

Output

18

### Response

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin >> a[i];
  sort(a.rbegin(),a.rend());
  int sum=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      sum+=a[i];
    }
    else sum-=a[i];
  }
  cout << sum;
}

```


### Prompt

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

Snuke is having a barbeque party.

At the party, he will make N servings of Skewer Meal.

<image>

Example of a serving of Skewer Meal

He has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i. Also, he has an infinite supply of ingredients.

To make a serving of Skewer Meal, he picks 2 skewers and threads ingredients onto those skewers. Let the length of the shorter skewer be x, then the serving can hold the maximum of x ingredients.

What is the maximum total number of ingredients that his N servings of Skewer Meal can hold, if he uses the skewers optimally?

Constraints

* 1≦N≦100
* 1≦L_i≦100
* For each i, L_i is an integer.

Input

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

N
L_1 L_2 ... L_{2N}

Output

Print the maximum total number of ingredients that Snuke's N servings of Skewer Meal can hold.

Examples

Input

2
1 3 1 2

Output

3

Input

5
100 1 2 3 14 15 58 58 58 29

Output

135

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int a[201];
int main(){
	cin>>n;
	for(int i=1;i<=2*n;i++)
		cin>>a[i];
	sort(a+1,a+1+2*n);
	for(int i=1;i<=2*n;i+=2)
		ans+=a[i];
	cout<<ans;
	return 0;
}
```


### Prompt

Construct a CPP code solution to the problem outlined:

You are given two strings A and B representing essays of two students who are suspected cheaters. For any two strings C, D we define their similarity score S(C,D) as 4⋅ LCS(C,D) - |C| - |D|, where LCS(C,D) denotes the length of the Longest Common Subsequence of strings C and D.

You believe that only some part of the essays could have been copied, therefore you're interested in their substrings.

Calculate the maximal similarity score over all pairs of substrings. More formally, output maximal S(C, D) over all pairs (C, D), where C is some substring of A, and D is some substring of B.

If X is a string, |X| denotes its length.

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

A string a is a subsequence of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters.

Pay attention to the difference between the substring and subsequence, as they both appear in the problem statement.

You may wish to read the [Wikipedia page about the Longest Common Subsequence problem](https://en.wikipedia.org/wiki/Longest_common_subsequence_problem).

Input

The first line contains two positive integers n and m (1 ≤ n, m ≤ 5000) — lengths of the two strings A and B.

The second line contains a string consisting of n lowercase Latin letters — string A.

The third line contains a string consisting of m lowercase Latin letters — string B.

Output

Output maximal S(C, D) over all pairs (C, D), where C is some substring of A, and D is some substring of B.

Examples

Input

4 5
abba
babab

Output

5

Input

8 10
bbbbabab
bbbabaaaaa

Output

12

Input

7 7
uiibwws
qhtkxcn

Output

0

Note

For the first case:

abb from the first string and abab from the second string have LCS equal to abb.

The result is S(abb, abab) = (4 ⋅ |abb|) - |abb| - |abab| = 4 ⋅ 3 - 3 - 4 = 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  c_p_c();
  long long n, m;
  cin >> n >> m;
  string str1;
  string str2;
  cin >> str1;
  cin >> str2;
  vector<vector<long long> > dp(n + 1, vector<long long>(m + 1, 0));
  for (long long i = n - 1; i >= 0; i--) {
    for (long long j = m - 1; j >= 0; j--) {
      if (i == n or j == m) {
        dp[i][j] = 0;
        continue;
      }
      if (str1[i] == str2[j]) {
        dp[i][j] = 2 + dp[i + 1][j + 1];
      }
      dp[i][j] = max(dp[i + 1][j] - 1, dp[i][j]);
      dp[i][j] = max(dp[i][j + 1] - 1, dp[i][j]);
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) ans = max(ans, dp[i][j]);
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

You are given four integers: H, W, h and w (1 ≤ h ≤ H, 1 ≤ w ≤ W). Determine whether there exists a matrix such that all of the following conditions are held, and construct one such matrix if the answer is positive:

* The matrix has H rows and W columns.
* Each element of the matrix is an integer between -10^9 and 10^9 (inclusive).
* The sum of all the elements of the matrix is positive.
* The sum of all the elements within every subrectangle with h rows and w columns in the matrix is negative.

Constraints

* 1 ≤ h ≤ H ≤ 500
* 1 ≤ w ≤ W ≤ 500

Input

Input is given from Standard Input in the following format:

H W h w

Output

If there does not exist a matrix that satisfies all of the conditions, print `No`.

Otherwise, print `Yes` in the first line, and print a matrix in the subsequent lines in the following format:

a_{11} ... a_{1W}
:
a_{H1} ... a_{HW}

Here, a_{ij} represents the (i,\ j) element of the matrix.

Examples

Input

3 3 2 2

Output

Yes
1 1 1
1 -4 1
1 1 1

Input

2 4 1 2

Output

No

Input

3 4 2 3

Output

Yes
2 -5 8 7
3 -5 -4 -5
2 1 -1 7

### Response

```cpp
#include<stdio.h>
int main(){int H,W,h,w;scanf("%d%d%d%d",&H,&W,&h,&w);if(H%h||W%w){puts("Yes");for(int i=1;i<=H;++i,puts("")) for(int j=1;j<=W;++j)printf("%d ",(i%h||j%w)?1000:-1000*(h*w-1)-1);}else puts("No");return 0;}
```


### Prompt

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

You are given n strings a_1, a_2, …, a_n: all of them have the same length m. The strings consist of lowercase English letters.

Find any string s of length m such that each of the given n strings differs from s in at most one position. Formally, for each given string a_i, there is no more than one position j such that a_i[j] ≠ s[j].

Note that the desired string s may be equal to one of the given strings a_i, or it may differ from all the given strings.

For example, if you have the strings abac and zbab, then the answer to the problem might be the string abab, which differs from the first only by the last character, and from the second only by the first.

Input

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

Each test case starts with a line containing two positive integers n (1 ≤ n ≤ 10) and m (1 ≤ m ≤ 10) — the number of strings and their length.

Then follow n strings a_i, one per line. Each of them has length m and consists of lowercase English letters.

Output

Print t answers to the test cases. Each answer (if it exists) is a string of length m consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).

Example

Input

5
2 4
abac
zbab
2 4
aaaa
bbbb
3 3
baa
aaa
aab
2 2
ab
bb
3 1
a
b
c

Output

abab
-1
aaa
ab
z

Note

The first test case was explained in the statement.

In the second test case, the answer does not exist.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 5;
const double EPS = 1e-9;
int main() {
  long long TC;
  cin >> TC;
  while (TC--) {
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    for (auto &i : a) cin >> i;
    auto makeset = [&](string s) {
      set<string> sset;
      for (int i = 0; i < m; i++)
        for (char ch = 'a'; ch <= 'z'; ch++) {
          string t = s;
          t[i] = ch;
          sset.insert(t);
        }
      return sset;
    };
    set<string> sset = makeset(a[0]);
    for (int i = 1; i < n; i++) {
      set<string> tempset = makeset(a[i]), intersect;
      set_intersection(tempset.begin(), tempset.end(), sset.begin(), sset.end(),
                       inserter(intersect, intersect.begin()));
      sset = intersect;
    }
    if (sset.size())
      cout << *sset.begin() << '\n';
    else
      cout << -1 << '\n';
  }
}

```


### Prompt

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

Codeforces is a wonderful platform and one its feature shows how much someone contributes to the community. Every registered user has contribution — an integer number, not necessarily positive. There are n registered users and the i-th of them has contribution ti.

Limak is a little polar bear and he's new into competitive programming. He doesn't even have an account in Codeforces but he is able to upvote existing blogs and comments. We assume that every registered user has infinitely many blogs and comments.

  * Limak can spend b minutes to read one blog and upvote it. Author's contribution will be increased by 5.
  * Limak can spend c minutes to read one comment and upvote it. Author's contribution will be increased by 1.

Note that it's possible that Limak reads blogs faster than comments.

Limak likes ties. He thinks it would be awesome to see a tie between at least k registered users. To make it happen he is going to spend some time on reading and upvoting. After that, there should exist an integer value x that at least k registered users have contribution exactly x.

How much time does Limak need to achieve his goal?

Input

The first line contains four integers n, k, b and c (2 ≤ k ≤ n ≤ 200 000, 1 ≤ b, c ≤ 1000) — the number of registered users, the required minimum number of users with the same contribution, time needed to read and upvote a blog, and time needed to read and upvote a comment, respectively.

The second line contains n integers t1, t2, ..., tn (|ti| ≤ 109) where ti denotes contribution of the i-th registered user.

Output

Print the minimum number of minutes Limak will spend to get a tie between at least k registered users.

Examples

Input

4 3 100 30
12 2 6 1

Output

220

Input

4 3 30 100
12 2 6 1

Output

190

Input

6 2 987 789
-8 42 -4 -65 -8 -8

Output

0

Note

In the first sample, there are 4 registered users and Limak wants a tie between at least 3 of them. Limak should behave as follows.

  * He spends 100 minutes to read one blog of the 4-th user and increase his contribution from 1 to 6.
  * Then he spends 4·30 = 120 minutes to read four comments of the 2-nd user and increase his contribution from 2 to 6 (four times it was increaded by 1).

In the given scenario, Limak spends 100 + 4·30 = 220 minutes and after that each of users 2, 3, 4 has contribution 6.

In the second sample, Limak needs 30 minutes to read a blog and 100 minutes to read a comment. This time he can get 3 users with contribution equal to 12 by spending 100 + 3·30 = 190 minutes:

  * Spend 2·30 = 60 minutes to read two blogs of the 1-st user to increase his contribution from 2 to 12.
  * Spend 30 + 100 minutes to read one blog and one comment of the 3-rd user. His contribution will change from 6 to 6 + 5 + 1 = 12.

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
int a, b, c, d, n, m, k;
int mas[200002];
pair<int, int> fx[200002];
long long solve(int md) {
  multiset<long long> s1, s2;
  long long sum = 0;
  long long add1 = 0, add2 = 0;
  for (int _n((n)-1), i(0); i <= _n; i++) {
    int t = mas[i] % 5;
    fx[i].first = mas[i];
    fx[i].second = 0;
    while (t != md) {
      ++t;
      if (t == 5) t = 0;
      ++fx[i].first;
      fx[i].second += c;
    }
    fx[i].first /= 5;
  }
  auto upd = [&]() {
    while ((int)s1.size() > k) {
      long long t = *s1.rbegin() + add1;
      s1.erase(--s1.end());
      s2.insert(t - add2);
      sum -= t;
    }
    while (1) {
      if (s2.empty()) break;
      long long mn2 = *s2.begin() + add2;
      long long mx1 = *s1.rbegin() + add1;
      if (mn2 < mx1) {
        sum -= mx1;
        sum += mn2;
        s1.erase(--s1.end());
        s2.erase(s2.begin());
        s1.insert(mn2 + add1);
        s2.insert(mx1 + add2);
      } else
        break;
    }
  };
  long long ans = 8LL * 1000000000 * 1000000000;
  for (int _n((n)-1), i(0); i <= _n; i++) {
    s1.insert(fx[i].second - add1);
    sum += fx[i].second;
    upd();
    if (s1.size() == k && sum < ans) {
      ans = sum;
    }
    if (i == n - 1) break;
    long long delta = (long long)fx[i + 1].first - (long long)fx[i].first;
    add1 += (long long)delta * b;
    add2 += (long long)delta * b;
    sum += (long long)s1.size() * delta * b;
  }
  return ans;
}
int main() {
  scanf("%d%d%d%d", &n, &k, &b, &c);
  b = min(b, c * 5);
  for (int _n((n)-1), i(0); i <= _n; i++) {
    scanf("%d", &mas[i]);
  }
  sort(mas, mas + n);
  int mn = mas[0];
  for (int _n((n)-1), i(0); i <= _n; i++) {
    mas[i] -= mn;
  }
  long long ans = 8LL * 1000000000 * 1000000000;
  for (int _n((5) - 1), md(0); md <= _n; md++) {
    long long cur = solve(md);
    if (cur < ans) ans = cur;
  }
  cout << ans << endl;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Vasya has a multiset s consisting of n integer numbers. Vasya calls some number x nice if it appears in the multiset exactly once. For example, multiset \{1, 1, 2, 3, 3, 3, 4\} contains nice numbers 2 and 4.

Vasya wants to split multiset s into two multisets a and b (one of which may be empty) in such a way that the quantity of nice numbers in multiset a would be the same as the quantity of nice numbers in multiset b (the quantity of numbers to appear exactly once in multiset a and the quantity of numbers to appear exactly once in multiset b).

Input

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

The second line contains n integers s_1, s_2, ... s_n~(1 ≤ s_i ≤ 100) — the multiset s.

Output

If there exists no split of s to satisfy the given requirements, then print "NO" in the first line.

Otherwise print "YES" in the first line.

The second line should contain a string, consisting of n characters. i-th character should be equal to 'A' if the i-th element of multiset s goes to multiset a and 'B' if if the i-th element of multiset s goes to multiset b. Elements are numbered from 1 to n in the order they are given in the input.

If there exist multiple solutions, then print any of them.

Examples

Input

4
3 5 7 1

Output

YES
BABA

Input

3
3 5 1

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
inline void rvi(vector<int>& v, int n) {
  int temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    v.push_back(temp);
  }
}
inline void rvll(vector<long long int>& v, int n) {
  long long int temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    v.push_back(temp);
  }
}
inline void prvi(vector<int>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
inline void prvll(vector<long long int>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
inline void prmii(map<int, int>& m) {
  for (auto x : m) {
    cout << x.first << " " << x.second << endl;
  }
}
inline vector<long long int> prefixsum(vector<int>& a) {
  vector<long long int> b;
  b.push_back(a[0]);
  for (int i = 1; i < a.size(); i++) {
    b.push_back(a[i] + b[i - 1]);
  }
  return b;
}
inline vector<long long int> suffixsum(vector<int>& a) {
  vector<long long int> b((a.size()));
  b[(a.size()) - 1] = a[(a.size()) - 1];
  for (int i = (a.size()) - 1 - 1; i >= 0; i--) {
    b[i] = a[i] + b[i + 1];
  }
  return b;
}
inline vector<long long int> prefixsum(vector<long long int>& a) {
  vector<long long int> b;
  b.push_back(a[0]);
  for (int i = 1; i < a.size(); i++) {
    b.push_back(a[i] + b[i - 1]);
  }
  return b;
}
inline vector<long long int> suffixsum(vector<long long int>& a) {
  vector<long long int> b((a.size()));
  b[(a.size()) - 1] = a[(a.size()) - 1];
  for (int i = (a.size()) - 1 - 1; i >= 0; i--) {
    b[i] = a[i] + b[i + 1];
  }
  return b;
}
void solve();
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<char> b(n);
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  int count = 0;
  int flag = 0;
  for (auto x : mp) {
    if (x.second == 1) {
      count++;
    } else if ((x.second) >= 3) {
      flag = 1;
    } else {
      ;
    }
  }
  if ((count % 2) != 0 && flag == 0) {
    cout << "NO" << endl;
  } else if (mp.size() == 1) {
    if (((mp[a[0]])) == 1) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
      for (int i = 0; i < n; i++) {
        if ((i & 1) == 0) {
          b[i] = 'A';
        } else {
          b[i] = 'A';
        }
      }
      for (int i = 0; i < n; i++) {
        cout << b[i];
      }
      cout << endl;
      return;
    }
  } else {
    cout << "YES" << endl;
    if (flag == 0 || (count % 2) == 0) {
      int check = 0;
      for (int i = 0; i < n; i++) {
        if (mp[a[i]] == 1) {
          if ((check & 1) == 0) {
            b[i] = 'A';
            check++;
          } else {
            b[i] = 'B';
            check++;
          }
        } else {
          b[i] = 'A';
        }
      }
    } else {
      int check = 0;
      for (int i = 0; i < n; i++) {
        if (mp[a[i]] == 1) {
          if ((check & 1) == 0) {
            b[i] = 'A';
            check++;
          } else {
            b[i] = 'B';
            check++;
          }
        } else {
          b[i] = 'A';
        }
      }
      int val;
      for (auto x : mp) {
        if ((x.second >= 3)) {
          val = x.first;
          break;
        }
      }
      for (int i = 0; i < n; i++) {
        if (a[i] == val) {
          b[i] = 'B';
          break;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      cout << b[i];
    }
    cout << endl;
  }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Little Victor adores the sets theory. Let us remind you that a set is a group of numbers where all numbers are pairwise distinct. Today Victor wants to find a set of integers S that has the following properties:

  * for all x <image> the following inequality holds l ≤ x ≤ r;
  * 1 ≤ |S| ≤ k;
  * lets denote the i-th element of the set S as si; value <image> must be as small as possible.

Help Victor find the described set.

Input

The first line contains three space-separated integers l, r, k (1 ≤ l ≤ r ≤ 1012; 1 ≤ k ≤ min(106, r - l + 1)).

Output

Print the minimum possible value of f(S). Then print the cardinality of set |S|. Then print the elements of the set in any order.

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

Examples

Input

8 15 3

Output

1
2
10 11

Input

8 30 7

Output

0
5
14 9 28 11 16

Note

Operation <image> represents the operation of bitwise exclusive OR. In other words, it is the XOR operation.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long l, r, k;
long long a[1000010];
int d1;
struct node {
  long long w;
  long long b[5];
  int cnt;
};
node b[20];
long long c[5];
bool cmp(node a, node b) { return a.w < b.w; }
void dfs(long long l, long long r, int cent, long long v) {
  if (l > r) {
    if (!cent) return;
    b[d1].cnt = cent;
    for (int i = 0; i < cent; i++) b[d1].b[i] = c[i];
    b[d1++].w = v;
    return;
  }
  c[cent] = l;
  dfs(l + 1, r, cent + 1, v ^ l);
  dfs(l + 1, r, cent, v);
}
int main() {
  while (cin >> l >> r >> k) {
    long long ans, x;
    int d = 0, i, j;
    if (k == 1) {
      ans = l;
      a[d++] = l;
    } else {
      if (r - l < 4) {
        d1 = 0;
        dfs(l, r, 0, 0);
        sort(b, b + d1, cmp);
        for (i = 0; i < d1; i++)
          if (b[i].cnt <= k) {
            ans = b[i].w;
            for (j = 0; j < b[i].cnt; j++) a[d++] = b[i].b[j];
            break;
          }
      } else {
        if (k == 2) {
          for (x = l; x <= r; x++)
            if (x % 2 == 0) break;
          ans = 1;
          a[d++] = x;
          a[d++] = x + 1;
        } else if (k >= 4) {
          for (x = l; x <= r; x++)
            if (x % 2 == 0) break;
          ans = 0;
          a[d++] = x;
          a[d++] = x + 1;
          a[d++] = x + 2;
          a[d++] = x + 3;
        } else {
          long long now = l;
          int bi = 0;
          while (now) {
            now >>= 1;
            bi++;
          }
          now = 3;
          while (--bi) now <<= 1;
          if (now <= r) {
            ans = 0;
            a[d++] = now;
            a[d++] = now ^ l;
            a[d++] = l;
          } else {
            for (x = l; x <= r; x++)
              if (x % 2 == 0) break;
            ans = 1;
            a[d++] = x;
            a[d++] = x + 1;
          }
        }
      }
    }
    cout << ans << endl << d << endl;
    for (i = 0; i < d - 1; i++) cout << a[i] << ' ';
    cout << a[i] << endl;
  }
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

There are M chairs arranged in a line. The coordinate of the i-th chair (1 ≤ i ≤ M) is i.

N people of the Takahashi clan played too much games, and they are all suffering from backaches. They need to sit in chairs and rest, but they are particular about which chairs they sit in. Specifically, the i-th person wishes to sit in a chair whose coordinate is not greater than L_i, or not less than R_i. Naturally, only one person can sit in the same chair.

It may not be possible for all of them to sit in their favorite chairs, if nothing is done. Aoki, who cares for the health of the people of the Takahashi clan, decides to provide additional chairs so that all of them can sit in chairs at their favorite positions.

Additional chairs can be placed at arbitrary real coordinates. Find the minimum required number of additional chairs.

Constraints

* 1 ≤ N,M ≤ 2 × 10^5
* 0 ≤ L_i < R_i ≤ M + 1(1 ≤ i ≤ N)
* All input values are integers.

Input

Input is given from Standard Input in the following format:

N M
L_1 R_1
:
L_N R_N

Output

Print the minimum required number of additional chairs.

Examples

Input

4 4
0 3
2 3
1 3
3 4

Output

0

Input

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

Output

2

Input

3 1
1 2
1 2
1 2

Output

2

Input

6 6
1 6
1 6
1 5
1 5
2 6
2 6

Output

2

### Response

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

int N, M, L[200009], R[200009];
vector<int>vec[200009];
priority_queue<int, vector<int>, greater<int>>Q;

int main() {
	cin >> N >> M; M++;
	for (int i = 1; i <= N; i++) {
		cin >> L[i] >> R[i]; vec[L[i]].push_back(R[i]);
	}
	for (int i = M; i > N; i--) {
		for (int j : vec[i]) Q.push(M - j);
	}
	int P = M - 1;
	for (int i = N; i >= 1; i--) {
		for (int j : vec[i]) Q.push(M - j);
		if (!Q.empty()) { Q.pop(); P--; }
	}
	for (int j : vec[0]) Q.push(M - j);

	vector<int>v; while (!Q.empty()) { v.push_back(Q.top()); Q.pop(); }
	int B = 1, cnt = v.size();
	for (int i = 0; i < v.size(); i++) {
		if (B > P) break;
		if (B <= v[i]) { B++; cnt--; }
	}
	cout << cnt << endl;
	return 0;
}
```


### Prompt

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

Vanya got an important task — he should enumerate books in the library and label each book with its number. Each of the n books should be assigned with a number from 1 to n. Naturally, distinct books should be assigned distinct numbers.

Vanya wants to know how many digits he will have to write down as he labels the books.

Input

The first line contains integer n (1 ≤ n ≤ 109) — the number of books in the library.

Output

Print the number of digits needed to number all the books.

Examples

Input

13

Output

17

Input

4

Output

4

Note

Note to the first test. The books get numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, which totals to 17 digits.

Note to the second sample. The books get numbers 1, 2, 3, 4, which totals to 4 digits.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long i, n, x, m, k, ans;
int main() {
  cin >> n;
  x = n;
  while (x) {
    x /= 10;
    m++;
  }
  ans = n * m + m - 1;
  k = 1;
  for (i = 0; i < m - 1; i++) {
    k *= 10;
    ans -= k;
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the i-th minute of the day.

Metropolis airport is the main transport hub of Metropolia, so it is difficult to keep the schedule intact. This is exactly the case today: because of technical issues, no flights were able to depart during the first k minutes of the day, so now the new departure schedule must be created.

All n scheduled flights must now depart at different minutes between (k + 1)-th and (k + n)-th, inclusive. However, it's not mandatory for the flights to depart in the same order they were initially scheduled to do so — their order in the new schedule can be different. There is only one restriction: no flight is allowed to depart earlier than it was supposed to depart in the initial schedule.

Helen knows that each minute of delay of the i-th flight costs airport ci burles. Help her find the order for flights to depart in the new schedule that minimizes the total cost for the airport.

Input

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 300 000), here n is the number of flights, and k is the number of minutes in the beginning of the day that the flights did not depart.

The second line contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 107), here ci is the cost of delaying the i-th flight for one minute.

Output

The first line must contain the minimum possible total cost of delaying the flights.

The second line must contain n different integers t1, t2, ..., tn (k + 1 ≤ ti ≤ k + n), here ti is the minute when the i-th flight must depart. If there are several optimal schedules, print any of them.

Example

Input

5 2
4 2 1 10 2

Output

20
3 6 7 4 5

Note

Let us consider sample test. If Helen just moves all flights 2 minutes later preserving the order, the total cost of delaying the flights would be (3 - 1)·4 + (4 - 2)·2 + (5 - 3)·1 + (6 - 4)·10 + (7 - 5)·2 = 38 burles.

However, the better schedule is shown in the sample answer, its cost is (3 - 1)·4 + (6 - 2)·2 + (7 - 3)·1 + (4 - 4)·10 + (5 - 5)·2 = 20 burles.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') {
    x *= 10;
    x += c - '0';
    c = getchar();
  }
}
inline void reads(string& s) {
  char c = getchar();
  while (c < 'a' || c > 'z') c = getchar();
  while (c >= 'a' && c <= 'z') {
    s += c;
    c = getchar();
  }
}
const string YES = "YES";
const string NO = "NO";
void out(int x) {
  if (x == 0) {
    cout << NO << endl;
    exit(0);
  }
  if (x == 1) {
    cout << YES << endl;
    exit(0);
  }
}
const int N = 300300;
int c[N];
int ans[N];
priority_queue<pair<int, int>> st;
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < k; i++) st.push({c[i], -i});
  int ans[n];
  long long sum = 0;
  for (int j = k; j < k + n; j++) {
    if (j < n) {
      st.push({c[j], -j});
    }
    if (st.size() == 0) {
      while (true) {
      }
    }
    auto it = st.top();
    st.pop();
    auto cur = it;
    cur.second *= -1;
    ans[cur.second] = j + 1;
    sum += 1ll * cur.first * (j - cur.second);
  }
  cout << sum << endl;
  for (int i = 0; i < n; i++) cout << ans[i] << ' ';
  return 0;
}

```