### Prompt

Create a solution in cpp for the following problem:

Little Petya is now fond of data compression algorithms. He has already studied gz, bz, zip algorithms and many others. Inspired by the new knowledge, Petya is now developing the new compression algorithm which he wants to name dis.

Petya decided to compress tables. He is given a table a consisting of n rows and m columns that is filled with positive integers. He wants to build the table a' consisting of positive integers such that the relative order of the elements in each row and each column remains the same. That is, if in some row i of the initial table ai, j < ai, k, then in the resulting table a'i, j < a'i, k, and if ai, j = ai, k then a'i, j = a'i, k. Similarly, if in some column j of the initial table ai, j < ap, j then in compressed table a'i, j < a'p, j and if ai, j = ap, j then a'i, j = a'p, j.

Because large values require more space to store them, the maximum value in a' should be as small as possible.

Petya is good in theory, however, he needs your help to implement the algorithm.

Input

The first line of the input contains two integers n and m (<image>, the number of rows and the number of columns of the table respectively.

Each of the following n rows contain m integers ai, j (1 ≤ ai, j ≤ 109) that are the values in the table.

Output

Output the compressed table in form of n lines each containing m integers.

If there exist several answers such that the maximum number in the compressed table is minimum possible, you are allowed to output any of them.

Examples

Input

2 2
1 2
3 4

Output

1 2
2 3

Input

4 3
20 10 30
50 40 30
50 60 70
90 80 70

Output

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

Note

In the first sample test, despite the fact a1, 2 ≠ a21, they are not located in the same row or column so they may become equal after the compression.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
inline bool Min(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
inline bool Max(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
inline int ni() {
  int a;
  scanf("%d", &a);
  return a;
}
inline ll nl() {
  ll a;
  scanf("%lld", &a);
  return a;
}
inline double nd() {
  double a;
  scanf("%lf", &a);
  return a;
}
inline void pi(int a) { printf("%d ", a); }
inline void pl(ll a) { printf("%lld ", a); }
inline void pd(double a) { printf("%.12lf ", a); }
const int N = 1e6 + 100;
int parent[N];
int rang[N];
int a[N];
int res[N];
int income[N];
vector<int> gp[N];
bool was[N];
vector<int> topo;
void make_set(int v) {
  parent[v] = v;
  rang[v] = 1;
}
int find(int v) {
  if (parent[v] == v) return v;
  return parent[v] = ::find(parent[v]);
}
void union_set(int a, int b) {
  if ((a = find(a)) != (b = find(b))) {
    if (rang[a] < rang[b]) swap(a, b);
    if (rang[a] == rang[b]) rang[a]++;
    parent[b] = a;
  }
}
void dfs(int v) {
  res[v] = 1;
  was[v] = true;
  for (int next : gp[v])
    if (!was[next]) dfs(next);
  for (int next : gp[v]) Max(res[v], res[next] + 1);
}
void solve() {
  int n = ni();
  int m = ni();
  for (int i = 0; i < (int)(n * m); ++i) a[i] = ni();
  for (int i = 0; i < (int)(n * m); ++i) make_set(i);
  for (int i = 0; i < (int)(n); ++i) {
    vector<pii> v;
    for (int j = 0; j < (int)(m); ++j)
      v.push_back(make_pair(a[i * m + j], i * m + j));
    sort((v).rbegin(), (v).rend());
    for (int j = 0; j < (int)(m - 1); ++j)
      if (v[j].first == v[j + 1].first) union_set(v[j].second, v[j + 1].second);
  }
  for (int j = 0; j < (int)(m); ++j) {
    vector<pii> v;
    for (int i = 0; i < (int)(n); ++i)
      v.push_back(make_pair(a[i * m + j], i * m + j));
    sort((v).rbegin(), (v).rend());
    for (int i = 0; i < (int)(n - 1); ++i)
      if (v[i].first == v[i + 1].first) union_set(v[i].second, v[i + 1].second);
  }
  for (int i = 0; i < (int)(n); ++i) {
    vector<pii> v;
    for (int j = 0; j < (int)(m); ++j)
      v.push_back(make_pair(a[i * m + j], find(i * m + j)));
    sort((v).rbegin(), (v).rend());
    for (int j = 0; j < (int)(m - 1); ++j)
      if (v[j].first != v[j + 1].first)
        gp[v[j].second].push_back(v[j + 1].second), income[v[j + 1].second]++;
  }
  for (int j = 0; j < (int)(m); ++j) {
    vector<pii> v;
    for (int i = 0; i < (int)(n); ++i)
      v.push_back(make_pair(a[i * m + j], find(i * m + j)));
    sort((v).rbegin(), (v).rend());
    for (int i = 0; i < (int)(n - 1); ++i)
      if (v[i].first != v[i + 1].first)
        gp[v[i].second].push_back(v[i + 1].second), income[v[i + 1].second]++;
  }
  for (int i = 0; i < (int)(n * m); ++i)
    if (find(i) == i and income[i] == 0) dfs(i);
  for (int i = 0; i < (int)(n * m); ++i) {
    printf("%d ", res[find(i)]);
    if ((i + 1) % m == 0) puts("");
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  srand((int)clock());
  solve();
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

You are given an integer k and a tree T with n nodes (n is even).

Let dist(u, v) be the number of edges on the shortest path from node u to node v in T.

Let us define a undirected weighted complete graph G = (V, E) as following:

  * V = \\{x ∣ 1 ≤ x ≤ n \} i.e. the set of integers from 1 to n
  * E = \{(u, v, w) ∣ 1 ≤ u, v ≤ n, u ≠ v, w = dist(u, v) \} i.e. there is an edge between every pair of distinct nodes, the weight being the distance between their respective nodes in T

Your task is simple, find a perfect matching in G with total edge weight k (1 ≤ k ≤ n^2).

Input

The first line of input contains two integers n, k (2 ≤ n ≤ 100 000, n is even, 1 ≤ k ≤ n^2): number of nodes and the total edge weight of the perfect matching you need to find.

The i-th of the following n - 1 lines contains two integers v_i, u_i (1 ≤ v_i, u_i ≤ n) denoting an edge between v_i and u_i in T. It is guaranteed that the given graph is a tree.

Output

If there are no matchings that satisfy the above condition, output "NO" (without quotes) on a single line.

Otherwise, you should output "YES" (without quotes) on the first line of output.

You should then output n/2 lines, the i-th line containing p_i, q_i (1 ≤ p_i, q_i ≤ n): the i-th pair of the matching.

Examples

Input

4 2
1 2
2 3
3 4

Output

YES
2 1
3 4

Input

4 4
1 2
2 3
3 4

Output

YES
3 1
2 4

Note

A tree is a connected acyclic undirected graph.

A matching is set of pairwise non-adjacent edges, none of which are loops; that is, no two edges share a common vertex.

A perfect matching is a matching which matches all vertices of the graph; that is, every vertex of the graph is incident to exactly one edge of the matching.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, sz[100010], head[100010], o = 0;
pair<int, int> res[100010];
long long k, mn = 0, mx = 0;
struct edge {
  int to, link;
} e[200010];
void add_edge(int u, int v) {
  e[++o].to = v, e[o].link = head[u], head[u] = o;
  e[++o].to = u, e[o].link = head[v], head[v] = o;
}
void dfs(int u, int pre) {
  sz[u] = 1;
  for (int i = head[u]; i; i = e[i].link) {
    if (e[i].to == pre) continue;
    dfs(e[i].to, u);
    sz[u] += sz[e[i].to];
  }
}
list<int> work(int u, int pre) {
  list<int> tmp;
  tmp.push_back(u);
  for (int i = head[u]; i; i = e[i].link) {
    if (e[i].to == pre) continue;
    tmp.splice(tmp.end(), work(e[i].to, u));
  }
  int size = (tmp.size() - sz[u]) >> 1;
  for (int i = 0; i < size; i++) {
    res[i].first = tmp.front();
    res[size - i - 1].second = tmp.back();
    tmp.pop_front();
    tmp.pop_back();
  }
  for (int i = 0; i < size; i++) printf("%d %d\n", res[i].first, res[i].second);
  return tmp;
}
int main() {
  scanf("%d%lld", &n, &k);
  for (int i = 1, u, v; i < n; i++) scanf("%d%d", &u, &v), add_edge(u, v);
  dfs(1, 0);
  for (int i = 1; i <= n; i++)
    mx += (sz[i] = min(sz[i], n - sz[i])), mn += (sz[i] & 1);
  if (k < mn || k > mx || (mx - k) % 2 != 0) return puts("NO"), 0;
  int l = 0, r = n >> 1, mid;
  long long ans = -1;
  while (l <= r) {
    mid = (l + r) >> 1;
    long long tmp = 0;
    for (int i = 2; i <= n; i++) {
      if (sz[i] <= mid)
        tmp += sz[i];
      else
        tmp += mid - ((sz[i] - mid) & 1);
    }
    if (tmp >= k) {
      r = mid - 1;
      ans = tmp;
    } else
      l = mid + 1;
  }
  for (int i = 2; i <= n; i++) {
    if (sz[i] > l) sz[i] = l - ((sz[i] - l) & 1);
    if (sz[i] == l && ans > k) sz[i] -= 2, ans -= 2;
  }
  puts("YES");
  work(1, 0);
}

```


### Prompt

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

Old timers of Summer Informatics School can remember previous camps in which each student was given a drink of his choice on the vechorka (late-evening meal). Or may be the story was more complicated?

There are n students living in a building, and for each of them the favorite drink a_i is known. So you know n integers a_1, a_2, ..., a_n, where a_i (1 ≤ a_i ≤ k) is the type of the favorite drink of the i-th student. The drink types are numbered from 1 to k.

There are infinite number of drink sets. Each set consists of exactly two portions of the same drink. In other words, there are k types of drink sets, the j-th type contains two portions of the drink j. The available number of sets of each of the k types is infinite.

You know that students will receive the minimum possible number of sets to give all students exactly one drink. Obviously, the number of sets will be exactly ⌈ n/2 ⌉, where ⌈ x ⌉ is x rounded up.

After students receive the sets, they will distribute their portions by their choice: each student will get exactly one portion. Note, that if n is odd then one portion will remain unused and the students' teacher will drink it.

What is the maximum number of students that can get their favorite drink if ⌈ n/2 ⌉ sets will be chosen optimally and students will distribute portions between themselves optimally?

Input

The first line of the input contains two integers n and k (1 ≤ n, k ≤ 1 000) — the number of students in the building and the number of different drinks.

The next n lines contain student's favorite drinks. The i-th line contains a single integer from 1 to k — the type of the favorite drink of the i-th student.

Output

Print exactly one integer — the maximum number of students that can get a favorite drink.

Examples

Input

5 3
1
3
1
1
2

Output

4

Input

10 3
2
1
3
2
3
3
1
3
1
2

Output

9

Note

In the first example, students could choose three sets with drinks 1, 1 and 2 (so they will have two sets with two drinks of the type 1 each and one set with two drinks of the type 2, so portions will be 1, 1, 1, 1, 2, 2). This way all students except the second one will get their favorite drinks.

Another possible answer is sets with drinks 1, 2 and 3. In this case the portions will be 1, 1, 2, 2, 3, 3. Then all the students except one will gain their favorite drinks. The only student that will not gain the favorite drink will be a student with a_i = 1 (i.e. the first, the third or the fourth).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(k + 1, 0);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x]++;
  }
  int ok = 0;
  int ost = 0;
  for (int i = 1; i < k + 1; i++) {
    ok += a[i] - a[i] % 2;
    if (a[i] % 2 != 0) ost++;
  }
  ost = (ost + 1) / 2;
  ok += ost;
  cout << ok;
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

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

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

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

Notes

Constraints

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

Input

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

Output

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

In the second line, print the number of comparisons.

Example

Input

10
8 5 9 2 6 3 7 1 10 4

Output

1 2 3 4 5 6 7 8 9 10
34

### Response

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

using namespace std;

int mergeSort(int left, int right)
{
  if(left + 1 < right) {
    int mid = (left + right) >> 1;
    return (mergeSort(left, mid) + mergeSort(mid, right) + right - left);
  } else {
    return (0);
  }
}

int main()
{
  int N, A[500000];
  scanf("%d", &N);
  for(int i = 0; i < N; i++) scanf("%d", &A[i]);
  sort(A, A + N);
  for(int i = 0; i < N; i++) {
    if(i > 0) putchar(' ');
    printf("%d", A[i]);
  }
  putchar('\n');
  printf("%d\n", mergeSort(0, N));
}
```


### Prompt

Generate a CPP solution to the following problem:

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

<image>

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

Input

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

The number of datasets does not exceed 50.

Output

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

Example

Input

1
3

Output

2
7

### Response

```cpp
#include <stdio.h>
#include<math.h>
#include <string.h>
#include <ctype.h>

int main(){
int n,f,i;
while(scanf("%d",&n)!=EOF){
f=2;
for(i=2;i<=n;i++){
f+=i;
}
printf("%d\n",f);
}

return 0;
}
```


### Prompt

Please formulate a Cpp solution to the following problem:

Everybody knows that the capital of Berland is connected to Bercouver (the Olympic capital) by a direct road. To improve the road's traffic capacity, there was placed just one traffic sign, limiting the maximum speed. Traffic signs in Berland are a bit peculiar, because they limit the speed only at that point on the road where they are placed. Right after passing the sign it is allowed to drive at any speed.

It is known that the car of an average Berland citizen has the acceleration (deceleration) speed of a km/h2, and has maximum speed of v km/h. The road has the length of l km, and the speed sign, limiting the speed to w km/h, is placed d km (1 ≤ d < l) away from the capital of Berland. The car has a zero speed at the beginning of the journey. Find the minimum time that an average Berland citizen will need to get from the capital to Bercouver, if he drives at the optimal speed.

The car can enter Bercouver at any speed.

Input

The first line of the input file contains two integer numbers a and v (1 ≤ a, v ≤ 10000). The second line contains three integer numbers l, d and w (2 ≤ l ≤ 10000; 1 ≤ d < l; 1 ≤ w ≤ 10000).

Output

Print the answer with at least five digits after the decimal point.

Examples

Input

1 1
2 1 3

Output

2.500000000000

Input

5 70
200 170 40

Output

8.965874696353

### Response

```cpp
#include <bits/stdc++.h>
int main(void) {
  double a, v, l, d, w, t = 0;
  scanf("%lf%lf%lf%lf%lf", &a, &v, &l, &d, &w);
  if (2 * a * d <= w * w || w >= v) {
    if (l * a * 2 >= v * v) {
      t += v / a;
      t += (l - v * v / (2 * a)) / v;
    } else {
      t += sqrt(2 * l / a);
    }
  } else if (2 * a * d >= 2 * v * v - w * w) {
    t += v / a;
    t += (v - w) / a;
    t += (d - (2 * v * v - w * w) / (2 * a)) / v;
    if (2 * a * (l - d) > v * v - w * w) {
      t += (v - w) / a;
      t += (l - d - (v * v - w * w) / (2 * a)) / v;
    } else {
      t += sqrt(2 * (l - d) / a + w * w / (a * a)) - w / a;
    }
  } else {
    t += (sqrt(a * d + w * w / 2) + sqrt(a * d + w * w / 2) - w) / a;
    if (2 * a * (l - d) > v * v - w * w) {
      t += (v - w) / a;
      t += (l - d - (v * v - w * w) / (2 * a)) / v;
    } else {
      t += sqrt(2 * (l - d) / a + w * w / (a * a)) - w / a;
    }
  }
  printf("%f\n", t);
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

You are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj.

Input

The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the sizes of arrays a and b.

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

The third line contains m integers — the elements of array b ( - 109 ≤ bj ≤ 109).

Output

Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value bj.

Examples

Input

5 4
1 3 5 7 9
6 4 2 8

Output

3 2 1 4

Input

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

Output

4 2 4 2 5

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, a1, b1, u;
  cin >> n >> m;
  vector<long long> a(n);
  vector<long long> b(m);
  for (int i = 0; i < n; i++) {
    cin >> a1;
    a[i] = a1;
  }
  for (int i = 0; i < m; i++) {
    cin >> b1;
    b[i] = b1;
  }
  sort(a.begin(), a.end());
  u = 0;
  for (int i = 0; i < m; i++) {
    u = upper_bound(a.begin(), a.end(), b[i]) - a.begin();
    cout << u << " ";
  }
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

A brave princess in a poor country's tomboy is married to another country for a political marriage. However, a villain who is trying to kill the princess is releasing a thug on the way to his wife.

You have already decided on a safe route to safely deliver the princess to the other country, but with the wish of the princess to take a path that she has never taken before ~ ~ selfish ~ ~ I decided to take another road. So you decided to re-determine the path the princess would take while looking at the map.

All roads are highways that connect post stations. For convenience, the starting point and the destination point are also used as post stations. However, the new road had security problems. There is a high possibility that thugs and thugs trying to make the princess dead will attack.

It is advisable to hire an escort to follow such a dangerous road. Escort can be hired at the post station and can protect the princess on a road-by-road basis. You will not be attacked by bandits or thugs while the escort is guarding, but you will be charged 1 gold per distance. Therefore, in order to hire an escort, it is a condition that the distance to the next post station is not longer than the amount of money you have.

Now, under the given budget L, consider minimizing the number of bandits and thugs attacking the princess before she reaches her destination safely. Your job is to find that minimized number of people. It is assumed that you will not be attacked while you are at the post station.

Input

The input consists of multiple datasets. Each dataset has the following format.

> N M L
> A1 B1 D1 E1
> A2 B2 D2 E2
> ...
> AM BM DM EM

The first line is given three non-negative integers N (2 ≤ N ≤ 100), M, L (0 ≤ L ≤ 100). These integers represent the number of post stations, the number of roads, and the budget for hiring escorts. The post stations are assigned numbers from 1 to N, the starting point is assigned a number of 1, and the destination is assigned a number of N.

In the following M lines, road information is given to each line, one for each line. Road information is given by the four integers Ai, Bi (1 ≤ Ai <Bi ≤ N), Di (1 ≤ Di ≤ 100) Ei (0 ≤ Ei ≤ 10000). These represent the number of post stations at the start and end of the road, the distance of the road, and the number of people attacked by bandits and thugs, respectively.

Roads are bidirectional, and there is at most one road for a group of post stations. In addition, it is guaranteed that you can always move from the starting point to the destination.

The end of the input is indicated by a single line containing three zeros separated by blanks.

Output

For each dataset, output the minimum number of people attacked by bandits and thugs to each line. The output must not contain extra blanks or line breaks.

Sample Input

3 2 10
1 2 8 6
2 3 10 3
3 2 10
1 2 3 8
2 3 7 7
3 3 10
1 3 17 6
1 2 2 4
2 3 9 13
4 4 5
1 3 9 3
1 4 7 25
2 3 8 2
2 4 9 3
0 0 0

Output for the Sample Input

3
0
Four
8

Example

Input

3 2 10
1 2 8 6
2 3 10 3
3 2 10
1 2 3 8
2 3 7 7
3 3 10
1 3 17 6
1 2 2 4
2 3 9 13
4 4 5
1 3 9 3
1 4 7 25
2 3 8 2
2 4 9 3
0 0 0

Output

3
0
4
8

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, l;
int V;

int vv(int v, int mon)
{
    return v * (l + 1) + mon;
}

vector<int> dijkstra(int s, vector<vector<pair<int, int>>> &edge)
{
    const int INF = 1e9;
    vector<int> d(V, INF);
    d[s] = 0;
    priority_queue<pair<int, int>,vector<pair<int,int>>,greater<pair<int,int>>> que; //cost v
    que.push(make_pair(0, s));

    while (!que.empty())
    {
        auto st = que.top();
        que.pop();
        int v = st.second;

        int cost = st.first;

        if (d[v] < cost)
            continue;
        for (int i = 0; i < edge[v].size(); i++)
        {
            int to = edge[v][i].second;
            if (cost + edge[v][i].first < d[to])
            {
                d[to] = cost + edge[v][i].first;
                que.push(make_pair(d[to], to));
            }
        }
    }
    return d;
}

int main()
{
    while (true)
    {
        cin >> n >> m >> l;
        if (n == 0)
            break;
        V = n * (l + 1);
        vector<vector<pair<int, int>>> edge(V); //cost,to
        for(int i=0;i<n;i++){
            for(int j=1;j<=l;j++){
                edge[vv(i,j)].push_back(make_pair(0,vv(i,j-1)));
            }
        }
        for (int i = 0; i < m; i++)
        {
            int a, b, d, e;
            cin >> a >> b >> d >> e;
            a--, b--;
            for (int j = 0; j <= l; j++)
            {
                edge[vv(a, j)].push_back(make_pair(e, vv(b, j)));
                edge[vv(b, j)].push_back(make_pair(e, vv(a, j)));
                if (j - d >= 0)
                {
                    edge[vv(a, j)].push_back(make_pair(0, vv(b, j - d)));
                    edge[vv(b, j)].push_back(make_pair(0, vv(a, j - d)));
                }
            }
        }
        vector<int> d = dijkstra(vv(0, l), edge);
        int res = d[vv(n-1,0)];
        cout << res << endl;
    }
    return 0;
}
```


### Prompt

Create a solution in CPP for the following problem:

Initially Ildar has an empty array. He performs n steps. On each step he takes a subset of integers already added to the array and appends the mex of this subset to the array.

The mex of an multiset of integers is the smallest non-negative integer not presented in the multiset. For example, the mex of the multiset [0, 2, 3] is 1, while the mex of the multiset [1, 2, 1] is 0.

More formally, on the step m, when Ildar already has an array a_1, a_2, …, a_{m-1}, he chooses some subset of indices 1 ≤ i_1 < i_2 < … < i_k < m (possibly, empty), where 0 ≤ k < m, and appends the mex(a_{i_1}, a_{i_2}, … a_{i_k}) to the end of the array.

After performing all the steps Ildar thinks that he might have made a mistake somewhere. He asks you to determine for a given array a_1, a_2, …, a_n the minimum step t such that he has definitely made a mistake on at least one of the steps 1, 2, …, t, or determine that he could have obtained this array without mistakes.

Input

The first line contains a single integer n (1 ≤ n ≤ 100 000) — the number of steps Ildar made.

The second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 10^9) — the array Ildar obtained.

Output

If Ildar could have chosen the subsets on each step in such a way that the resulting array is a_1, a_2, …, a_n, print -1.

Otherwise print a single integer t — the smallest index of a step such that a mistake was made on at least one step among steps 1, 2, …, t.

Examples

Input

4
0 1 2 1

Output

-1

Input

3
1 0 1

Output

1

Input

4
0 1 2 239

Output

4

Note

In the first example it is possible that Ildar made no mistakes. Here is the process he could have followed.

  * 1-st step. The initial array is empty. He can choose an empty subset and obtain 0, because the mex of an empty set is 0. Appending this value to the end he gets the array [0].
  * 2-nd step. The current array is [0]. He can choose a subset [0] and obtain an integer 1, because mex(0) = 1. Appending this value to the end he gets the array [0,1].
  * 3-rd step. The current array is [0,1]. He can choose a subset [0,1] and obtain an integer 2, because mex(0,1) = 2. Appending this value to the end he gets the array [0,1,2].
  * 4-th step. The current array is [0,1,2]. He can choose a subset [0] and obtain an integer 1, because mex(0) = 1. Appending this value to the end he gets the array [0,1,2,1].

Thus, he can get the array without mistakes, so the answer is -1.

In the second example he has definitely made a mistake on the very first step, because he could not have obtained anything different from 0.

In the third example he could have obtained [0, 1, 2] without mistakes, but 239 is definitely wrong.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int testCase;
string s;
int iinf = 1e9 + 1;
long long inf = 1e16 + 1;
void solve() {
  long long n;
  cin >> n;
  long long m, x;
  cin >> m;
  if (m) {
    cout << 1;
    return;
  }
  for (int i = 1; i < n; i++) {
    cin >> x;
    if (x > m) {
      if (x - m > 1) {
        cout << i + 1;
        return;
      }
      m = x;
    }
  }
  cout << -1;
}
int main() {
  testCase = 1;
  while (testCase--) {
    solve();
    cout << "\n";
  }
}

```


### Prompt

Please formulate a cpp solution to the following problem:

You are given an array a consisting of positive integers and q queries to this array. There are two types of queries:

  * 1 l r x — for each index i such that l ≤ i ≤ r set ai = x.
  * 2 l r — find the minimum among such ai that l ≤ i ≤ r.

We decided that this problem is too easy. So the array a is given in a compressed form: there is an array b consisting of n elements and a number k in the input, and before all queries a is equal to the concatenation of k arrays b (so the size of a is n·k).

Input

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

The second line contains n integers — elements of the array b (1 ≤ bi ≤ 109).

The third line contains one integer q (1 ≤ q ≤ 105).

Then q lines follow, each representing a query. Each query is given either as 1 l r x — set all elements in the segment from l till r (including borders) to x (1 ≤ l ≤ r ≤ n·k, 1 ≤ x ≤ 109) or as 2 l r — find the minimum among all elements in the segment from l till r (1 ≤ l ≤ r ≤ n·k).

Output

For each query of type 2 print the answer to this query — the minimum on the corresponding segment.

Examples

Input

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

Output

1
3

Input

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

Output

1
5
1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct fast_ios {
  fast_ios() {
    cin.tie(nullptr), ios::sync_with_stdio(false),
        cout << fixed << setprecision(20);
  };
} fast_ios_;
template <class T>
auto add = [](T a, T b) -> T { return a + b; };
template <class T>
auto f_max = [](T a, T b) -> T { return max(a, b); };
template <class T>
auto f_min = [](T a, T b) -> T { return min(a, b); };
template <class T>
using V = vector<T>;
using Vl = V<long long int>;
using VVl = V<Vl>;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (int i = 0; i < (int)v.size(); i++)
    os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& in : v) is >> in;
  return is;
}
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long int ceil(long long int a, long long int b) { return (a + b - 1) / b; }
long long int digit(long long int a) { return (long long int)log10(a); }
long long int e_dist(pair<long long int, long long int> a,
                     pair<long long int, long long int> b) {
  return abs(a.first - b.first) * abs(a.first - b.first) +
         abs(a.second - b.second) * abs(a.second - b.second);
}
long long int m_dist(pair<long long int, long long int> a,
                     pair<long long int, long long int> b) {
  return abs(a.first - b.first) + abs(a.second - b.second);
}
bool check_overflow(long long int a, long long int b, long long int limit) {
  if (b == 0) return false;
  return a > limit / b;
}
void Worshall_Floyd(VVl& g) {
  for (long long int k = (0), k_end_ = (((long long int)(g).size()));
       k < k_end_; ++k)
    for (long long int i = (0), i_end_ = (((long long int)(g).size()));
         i < i_end_; ++i)
      for (long long int j = (0), j_end_ = (((long long int)(g).size()));
           j < j_end_; ++j)
        chmin(g[i][j], g[i][k] + g[k][j]);
}
const long long int MOD1000000007 = 1000000007, MOD998244353 = 998244353;
long long int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1},
              dy[8] = {0, 1, 0, -1, -1, -1, 1, 1};
bool YN(bool flag) {
  cout << (flag ? "YES" : "NO") << '\n';
  return flag;
}
bool yn(bool flag) {
  cout << (flag ? "Yes" : "No") << '\n';
  return flag;
}
struct Edge {
  long long int from, to;
  long long int cost;
  Edge() {}
  Edge(long long int u, long long int v, long long int c) {
    cost = c;
    from = u;
    to = v;
  }
  bool operator<(const Edge& e) const { return cost < e.cost; }
};
struct WeightedEdge {
  long long int to;
  long long int cost;
  WeightedEdge(long long int v, long long int c = 1) {
    to = v;
    cost = c;
  }
  bool operator<(const WeightedEdge& e) const { return cost < e.cost; }
};
using WeightedGraph = V<V<WeightedEdge>>;
template <class S, S (*op)(S, S), S (*e)(), class F, S (*mapping)(F, S),
          F (*composition)(F, F), F (*id)()>
struct lazy_segtree {
 public:
  lazy_segtree() : lazy_segtree(0) {}
  lazy_segtree(int n) : lazy_segtree(std::vector<S>(n, e())) {}
  lazy_segtree(const std::vector<S>& v) : _n(int(v.size())) {
    int x = 0;
    while ((1U << x) < (unsigned int)(_n)) x++;
    log = x;
    size = 1 << log;
    d = std::vector<S>(2 * size, e());
    lz = std::vector<F>(size, id());
    for (int i = 0; i < _n; i++) d[size + i] = v[i];
    for (int i = size - 1; i >= 1; i--) {
      update(i);
    }
  }
  void set(int p, S x) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    d[p] = x;
    for (int i = 1; i <= log; i++) update(p >> i);
  }
  S get(int p) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    return d[p];
  }
  S prod(int l, int r) {
    assert(0 <= l && l <= r && r <= _n);
    if (l == r) return e();
    l += size;
    r += size;
    for (int i = log; i >= 1; i--) {
      if (((l >> i) << i) != l) push(l >> i);
      if (((r >> i) << i) != r) push(r >> i);
    }
    S sml = e(), smr = e();
    while (l < r) {
      if (l & 1) sml = op(sml, d[l++]);
      if (r & 1) smr = op(d[--r], smr);
      l >>= 1;
      r >>= 1;
    }
    return op(sml, smr);
  }
  S all_prod() { return d[1]; }
  void apply(int p, F f) {
    assert(0 <= p && p < _n);
    p += size;
    for (int i = log; i >= 1; i--) push(p >> i);
    d[p] = mapping(f, d[p]);
    for (int i = 1; i <= log; i++) update(p >> i);
  }
  void apply(int l, int r, F f) {
    assert(0 <= l && l <= r && r <= _n);
    if (l == r) return;
    l += size;
    r += size;
    for (int i = log; i >= 1; i--) {
      if (((l >> i) << i) != l) push(l >> i);
      if (((r >> i) << i) != r) push((r - 1) >> i);
    }
    {
      int l2 = l, r2 = r;
      while (l < r) {
        if (l & 1) all_apply(l++, f);
        if (r & 1) all_apply(--r, f);
        l >>= 1;
        r >>= 1;
      }
      l = l2;
      r = r2;
    }
    for (int i = 1; i <= log; i++) {
      if (((l >> i) << i) != l) update(l >> i);
      if (((r >> i) << i) != r) update((r - 1) >> i);
    }
  }
  template <bool (*g)(S)>
  int max_right(int l) {
    return max_right(l, [](S x) { return g(x); });
  }
  template <class G>
  int max_right(int l, G g) {
    assert(0 <= l && l <= _n);
    assert(g(e()));
    if (l == _n) return _n;
    l += size;
    for (int i = log; i >= 1; i--) push(l >> i);
    S sm = e();
    do {
      while (l % 2 == 0) l >>= 1;
      if (!g(op(sm, d[l]))) {
        while (l < size) {
          push(l);
          l = (2 * l);
          if (g(op(sm, d[l]))) {
            sm = op(sm, d[l]);
            l++;
          }
        }
        return l - size;
      }
      sm = op(sm, d[l]);
      l++;
    } while ((l & -l) != l);
    return _n;
  }
  template <bool (*g)(S)>
  int min_left(int r) {
    return min_left(r, [](S x) { return g(x); });
  }
  template <class G>
  int min_left(int r, G g) {
    assert(0 <= r && r <= _n);
    assert(g(e()));
    if (r == 0) return 0;
    r += size;
    for (int i = log; i >= 1; i--) push((r - 1) >> i);
    S sm = e();
    do {
      r--;
      while (r > 1 && (r % 2)) r >>= 1;
      if (!g(op(d[r], sm))) {
        while (r < size) {
          push(r);
          r = (2 * r + 1);
          if (g(op(d[r], sm))) {
            sm = op(d[r], sm);
            r--;
          }
        }
        return r + 1 - size;
      }
      sm = op(d[r], sm);
    } while ((r & -r) != r);
    return 0;
  }

 private:
  int _n, size, log;
  std::vector<S> d;
  std::vector<F> lz;
  void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
  void all_apply(int k, F f) {
    d[k] = mapping(f, d[k]);
    if (k < size) lz[k] = composition(f, lz[k]);
  }
  void push(int k) {
    all_apply(2 * k, lz[k]);
    all_apply(2 * k + 1, lz[k]);
    lz[k] = id();
  }
};
template <typename Monoid>
struct SegmentTree {
  using F = function<Monoid(Monoid, Monoid)>;
  int sz;
  vector<Monoid> seg;
  const F f;
  const Monoid M1;
  SegmentTree(int n, const F f, const Monoid& M1) : f(f), M1(M1) {
    sz = 1;
    while (sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }
  void set(int k, const Monoid& x) { seg[k + sz] = x; }
  void build() {
    for (int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
  void update(int k, const Monoid& x) {
    k += sz;
    seg[k] = x;
    while (k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if (a & 1) L = f(L, seg[a++]);
      if (b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
  Monoid operator[](const int& k) const { return seg[k + sz]; }
  template <typename C>
  int find_subtree(int a, const C& check, Monoid& M, bool type) {
    while (a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if (check(nxt))
        a = 2 * a + type;
      else
        M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }
  template <typename C>
  int find_first(int a, const C& check) {
    Monoid L = M1;
    if (a <= 0) {
      if (check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if (a & 1) {
        Monoid nxt = f(L, seg[a]);
        if (check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }
  template <typename C>
  int find_last(int b, const C& check) {
    Monoid R = M1;
    if (b >= sz) {
      if (check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for (b += sz; a < b; a >>= 1, b >>= 1) {
      if (b & 1) {
        Monoid nxt = f(seg[--b], R);
        if (check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};
using S = long long;
using F = long long;
const S INF = 8e18;
const F ID = 8e18;
S op(S a, S b) { return std::min(a, b); }
S e() { return INF; }
S mapping(F f, S x) { return (f == ID ? x : f); }
F composition(F f, F g) { return (f == ID ? g : f); }
F id() { return ID; }
long long int N, K, Q;
int main() {
  cin >> N >> K;
  Vl arr(N);
  cin >> arr;
  cin >> Q;
  VVl query(Q);
  set<long long int> xs;
  for (long long int i = (0), i_end_ = (Q); i < i_end_; ++i) {
    Vl tmp;
    long long int t, l, r, x;
    cin >> t >> l >> r;
    l--;
    tmp.push_back(t);
    tmp.push_back(l);
    tmp.push_back(r);
    xs.insert(l);
    xs.insert(r);
    if (t == 1) {
      cin >> x;
      tmp.push_back(x);
    }
    query[i] = tmp;
  }
  xs.insert(0);
  xs.insert(N * K);
  long long int idx = 0;
  Vl nums;
  map<long long int, long long int> fx;
  for (long long int v : xs) fx[v] = idx, nums.push_back(v), idx++;
  Vl vec(idx - 1, INF - 100);
  {
    SegmentTree<long long int> _seg(N, f_min<long long int>, INF - 100);
    for (long long int i = (0), i_end_ = (N); i < i_end_; ++i)
      _seg.set(i, arr[i]);
    _seg.build();
    for (long long int i = (0), i_end_ = (idx - 1); i < i_end_; ++i) {
      long long int l = nums[i], r = nums[i + 1];
      if (l % N > r % N)
        chmin(vec[i], min(_seg.query(l % N, N), _seg.query(0, r % N)));
      else
        chmin(vec[i], _seg.query(l % N, r % N));
      if (r - l >= N) chmin(vec[i], _seg.query(0, N));
    }
  }
  lazy_segtree<S, op, e, F, mapping, composition, id> seg(vec);
  for (long long int i = (0), i_end_ = (Q); i < i_end_; ++i) {
    if (query[i][0] == 1) {
      seg.apply(fx[query[i][1]], fx[query[i][2]], query[i][3]);
    } else {
      cout << seg.prod(fx[query[i][1]], fx[query[i][2]]) << '\n';
    }
  }
}

```


### Prompt

Create a solution in cpp for the following problem:

You are given two integers a and b. You can perform a sequence of operations: during the first operation you choose one of these numbers and increase it by 1; during the second operation you choose one of these numbers and increase it by 2, and so on. You choose the number of these operations yourself.

For example, if a = 1 and b = 3, you can perform the following sequence of three operations:

  1. add 1 to a, then a = 2 and b = 3;
  2. add 2 to b, then a = 2 and b = 5;
  3. add 3 to a, then a = 5 and b = 5.

Calculate the minimum number of operations required to make a and b equal.

Input

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

The only line of each test case contains two integers a and b (1 ≤ a, b ≤ 10^9).

Output

For each test case print one integer — the minimum numbers of operations required to make a and b equal.

Example

Input

3
1 3
11 11
30 20

Output

3
0
4

Note

First test case considered in the statement.

In the second test case integers a and b are already equal, so you don't need to perform any operations.

In the third test case you have to apply the first, the second, the third and the fourth operation to b (b turns into 20 + 1 + 2 + 3 + 4 = 30).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 100;
const int MAXN = 1000000;
long long func(long long m) { return (m * (m + 1)) / 2; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  for (int _ = 0; _ < t; ++_) {
    long long a, b;
    cin >> a >> b;
    long long x = abs(a - b);
    long long r = 1e9;
    long long l = -1;
    while (r - l != 1) {
      long long m = (l + r) / 2;
      if (func(m) >= x)
        r = m;
      else
        l = m;
    }
    while (abs(func(r) - x) % 2 != 0) ++r;
    cout << r << "\n";
  }
  cerr << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
  return 0;
}

```


### Prompt

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

Short Phrase

A Short Phrase (aka. Tanku) is a fixed verse, inspired by Japanese poetry Tanka and Haiku. It is a sequence of words, each consisting of lowercase letters 'a' to 'z', and must satisfy the following condition:

> (The Condition for a Short Phrase)
>  The sequence of words can be divided into five sections such that the total number of the letters in the word(s) of the first section is five, that of the second is seven, and those of the rest are five, seven, and seven, respectively.

The following is an example of a Short Phrase.

>
>     do the best
>     and enjoy today
>     at acm icpc
>

In this example, the sequence of the nine words can be divided into five sections (1) "do" and "the", (2) "best" and "and", (3) "enjoy", (4) "today" and "at", and (5) "acm" and "icpc" such that they have 5, 7, 5, 7, and 7 letters in this order, respectively. This surely satisfies the condition of a Short Phrase.

Now, Short Phrase Parnassus published by your company has received a lot of contributions. By an unfortunate accident, however, some irrelevant texts seem to be added at beginnings and ends of contributed Short Phrases. Your mission is to write a program that finds the Short Phrase from a sequence of words that may have an irrelevant prefix and/or a suffix.

Input

The input consists of multiple datasets, each in the following format.

> n
>  w1
>  ...
>  wn
>

Here, n is the number of words, which is a positive integer not exceeding 40; wi is the i-th word, consisting solely of lowercase letters from 'a' to 'z'. The length of each word is between 1 and 10, inclusive. You can assume that every dataset includes a Short Phrase.

The end of the input is indicated by a line with a single zero.

Output

For each dataset, output a single line containing i where the first word of the Short Phrase is wi. When multiple Short Phrases occur in the dataset, you should output the first one.

Sample Input

9
do
the
best
and
enjoy
today
at
acm
icpc
14
oh
yes
by
far
it
is
wow
so
bad
to
me
you
know
hey
15
abcde
fghijkl
mnopq
rstuvwx
yzz
abcde
fghijkl
mnopq
rstuvwx
yz
abcde
fghijkl
mnopq
rstuvwx
yz
0

Output for the Sample Input

1
2
6

Example

Input

9
do
the
best
and
enjoy
today
at
acm
icpc
14
oh
yes
by
far
it
is
wow
so
bad
to
me
you
know
hey
15
abcde
fghijkl
mnopq
rstuvwx
yzz
abcde
fghijkl
mnopq
rstuvwx
yz
abcde
fghijkl
mnopq
rstuvwx
yz
0

Output

1
2
6

### Response

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

int main() {
  int n;

  constexpr int check[] = {5, 7, 5, 7, 7};

LOOP:
  while (std::cin >> n, n != 0) {
    std::vector<std::string> v(n);

    for (int i = 0; i < n; ++i) {
      std::cin >> v[i];
    }

    for (int i = 0; i < n; ++i) {
      int cnt = 0, idx = 0;
      for (int j = i; j < n; ++j) {
        cnt += v[j].size();
        if (cnt == check[idx]) {
          cnt = 0;
          idx++;
        }
        if (idx == 5) {
          std::cout << i + 1 << std::endl;
          goto LOOP;
        }
      }
    }
  }
}

```


### Prompt

Create a solution in Cpp for the following problem:

A ladies' shop has recently opened in the city of Ultima Thule. To get ready for the opening, the shop bought n bags. Each bag is characterised by the total weight ai of the items you can put there. The weird thing is, you cannot use these bags to put a set of items with the total weight strictly less than ai. However the weights of the items that will be sold in the shop haven't yet been defined. That's what you should determine right now.

Your task is to find the set of the items' weights p1, p2, ..., pk (1 ≤ p1 < p2 < ... < pk), such that:

  1. Any bag will be used. That is, for any i (1 ≤ i ≤ n) there will be such set of items that their total weight will equal ai. We assume that there is the infinite number of items of any weight. You can put multiple items of the same weight in one bag.
  2. For any set of items that have total weight less than or equal to m, there is a bag into which you can put this set. Similarly, a set of items can contain multiple items of the same weight.
  3. Of all sets of the items' weights that satisfy points 1 and 2, find the set with the minimum number of weights. In other words, value k should be as small as possible.

Find and print the required set.

Input

The first line contains space-separated integers n and m (1 ≤ n, m ≤ 106). The second line contains n distinct space-separated integers a1, a2, ..., an (1 ≤ a1 < a2 < ... < an ≤ m) — the bags' weight limits.

Output

In the first line print "NO" (without the quotes) if there isn't set pi, that would meet the conditions.

Otherwise, in the first line print "YES" (without the quotes), in the second line print an integer k (showing how many numbers are in the suitable set with the minimum number of weights), in the third line print k space-separated integers p1, p2, ..., pk (1 ≤ p1 < p2 < ... < pk). If there are multiple solutions, print any of them.

Examples

Input

6 10
5 6 7 8 9 10

Output

YES
5
5 6 7 8 9

Input

1 10
1

Output

NO

Input

1 10
6

Output

YES
1
6

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int readint() {
  int a = 0;
  char c = getchar(), f = 1;
  for (; c < '0' or c > '9'; c = getchar())
    if (c == '-') f = -f;
  for (; '0' <= c and c <= '9'; c = getchar())
    a = (a << 3) + (a << 1) + (c ^ 48);
  return a * f;
}
inline void writeint(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) writeint(x / 10);
  putchar(x % 10 + '0');
}
inline int qkpow(long long base, int q, int Mod) {
  long long ans = 1;
  base %= Mod;
  for (; q; q >>= 1, base = base * base % Mod)
    if (q & 1) ans = ans * base % Mod;
  return ans;
}
const int MaxN = 4000005;
int omg[MaxN];
void NTT(int a[], int n, int Mod, int g, int opt) {
  omg[0] = 1;
  for (int i = 1; i < n; ++i) omg[i] = 1ll * omg[i - 1] * g % Mod;
  int logN = 0;
  while ((1 << logN) < n) ++logN;
  for (int i = 0; i < n; ++i) {
    int t = 0;
    for (int j = 0; (i >> j) != 0; ++j)
      if (i >> j & 1) t |= 1 << (logN - j - 1);
    if (t < i) swap(a[t], a[i]);
  }
  for (int len = 2; len <= n; len <<= 1)
    for (int *p = a; p != a + n; p += len)
      for (int i = 0; i < (len >> 1); ++i) {
        int t =
            1ll * omg[(n / len * i * opt + n) % n] * p[i + (len >> 1)] % Mod;
        p[i + (len >> 1)] = (p[i] - t + Mod) % Mod, p[i] = (p[i] + t) % Mod;
      }
  if (opt == -1) {
    int inv = qkpow(n, Mod - 2, Mod);
    for (int i = 0; i < n; ++i) a[i] = 1ll * a[i] * inv % Mod;
  }
}
int n, m, f[MaxN], F[MaxN];
void input() {
  n = readint(), m = readint();
  for (int i = 1; i <= n; ++i) f[readint()] = 1;
  f[0] = 1;
}
void solve() {
  int N = 1;
  while (N <= (m << 1)) N <<= 1;
  const int Mod = 998244353, g = qkpow(3, (Mod - 1) / N, Mod);
  for (int i = 0; i <= m; ++i) F[i] = f[i];
  NTT(f, N, Mod, g, 1);
  for (int i = 0; i < N; ++i) f[i] = 1ll * f[i] * f[i] % Mod;
  NTT(f, N, Mod, g, -1);
  bool ok = true;
  for (int i = 1; i <= m; ++i)
    if (F[i] == 0 and f[i] >= 1) ok = false;
  if (not ok)
    puts("NO");
  else {
    puts("YES");
    int k = 0;
    for (int i = 1; i <= m; ++i)
      if (F[i] == 1 and f[i] == 2) ++k;
    writeint(k), putchar('\n');
    for (int i = 1; i <= m; ++i)
      if (F[i] == 1 and f[i] == 2) writeint(i), putchar(' ');
    putchar('\n');
  }
}
int main() {
  input(), solve();
  return 0;
}

```


### Prompt

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

Under the command "Save Sergeant Ryan," Aiz's rescue team fought fierce battles with enemy forces in the floating city of Lee, Germany. They successfully joined the sergeant, but there were many enemy tanks and they could not call a rescue herio. So, in order to confuse the enemy tanks, they decided to carry out an operation to blow up all the bridges in the city.

The operation was immediately communicated to HQ and preparations for a rescue helicopter were underway. In order to fly the rescue herio, you have to predict when all the bridges will be blown up. As a military programmer, your mission is to calculate the time the rescue team will need to blow up all the bridges.

The floating city is made up of N islands, with a bridge between the islands. All the islands are connected in a tree shape (see the figure below). There is only one route from one island to another. It takes a fixed amount of time to cross each bridge, and it is possible to cross the bridge in either direction at that time.

Rescue units do not have the means to move on the water, such as boats, so the only way to move between islands is through a bridge. Rescue units can instantly blow up the bridges adjacent to the island at that time. What is the minimum time required for a rescue unit to blow up all the bridges? However, we do not consider the travel time within the island.

Create a program that inputs the number of islands and information on each bridge and outputs the minimum time required to blow up all the bridges. Each island is represented by a number from 1 to N. There are N-1 bridges. The bridge information consists of the numbers (a, b) of the two islands adjacent to the bridge and the time t required to cross the bridge. Rescue units shall start on the island with island number 1.

<image>

Input

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

N
a1 b1 t1
a2 b2 t2
::
aN-1 bN-1 tN-1

All inputs are given as integers. The number of islands N (2 ≤ N ≤ 20) is given on the first line.

The following N-1 line gives information on the i-th bridge. ai, bi, ti (1 ≤ ti ≤ 500) means that we can move between island ai and island bi in time ti through the i-th bridge.

The number of datasets does not exceed 100.

Output

For each dataset, print the minimum time required to blow up all the bridges on one line.

Example

Input

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

Output

12

### Response

```cpp
// 2011/01/10 Tazoe

#include <iostream>
using namespace std;

void swp(int abt[20][3], int i, int j)
{
	abt[19][0] = abt[i][0];  abt[19][1] = abt[i][1];  abt[19][2] = abt[i][2];
	abt[i][0] = abt[j][0];  abt[i][1] = abt[j][1];  abt[i][2] = abt[j][2];
	abt[j][0] = abt[19][0];  abt[j][1] = abt[19][1];  abt[j][2] = abt[19][2];
}

void DFS(int abt[20][3], int N, int a, int t, int& t_max)
{
	if(t_max<t)
		t_max = t;

	for(int i=0; i<N-1; i++)
		if(abt[i][0]==a)
			DFS(abt, N, abt[i][1], t+abt[i][2], t_max);
}

int main()
{
	while(true){
		int N;
		cin >> N;
		if(N==0)
			break;

		int abt[20][3];
		for(int i=0; i<N-1; i++)
			cin >> abt[i][0] >> abt [i][1] >> abt[i][2];

		int que[20] = {1};
		int quh = 0;
		int qut = 1;
		for(int i=0; i<N-1; i++){
			bool flg = false;
			for(int j=i; j<N-1; j++){
				if(abt[j][0]!=que[quh]&&abt[j][1]!=que[quh])
					continue;
				if(abt[j][1]==que[quh]){
					int tmp = abt[j][0];
					abt[j][0] = abt[j][1];
					abt[j][1] = tmp;
				}
				swp(abt, i, j);
				que[qut++] = abt[i][1];
				flg = true;
				break;
			}
			if(!flg){
				quh++;
				i--;
			}
		}

		for(int i=0; i<N-1; i++){
			bool flg = false;
			for(int j=i+1; j<N-1; j++)
				if(abt[i][1]==abt[j][0]){
					flg = true;
					break;
				}
			if(flg)
				abt[i][2] *= 2;
			else
				abt[i][2] = 0;
		}

		int t_max = -1;
		DFS(abt, N, 1, 0, t_max);

		int sum = 0;
		for(int i=0; i<N-1; i++)
			sum += abt[i][2];
		sum -= t_max/2;

		cout << sum << endl;
	}

	return 0;
}
```


### Prompt

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

Consider a rooted tree. A rooted tree has one special vertex called the root. All edges are directed from the root. Vertex u is called a child of vertex v and vertex v is called a parent of vertex u if there exists a directed edge from v to u. A vertex is called a leaf if it doesn't have children and has a parent.

Let's call a rooted tree a spruce if its every non-leaf vertex has at least 3 leaf children. You are given a rooted tree, check whether it's a spruce.

The definition of a rooted tree can be found [here](https://goo.gl/1dqvzz).

Input

The first line contains one integer n — the number of vertices in the tree (3 ≤ n ≤ 1 000). Each of the next n - 1 lines contains one integer pi (1 ≤ i ≤ n - 1) — the index of the parent of the i + 1-th vertex (1 ≤ pi ≤ i).

Vertex 1 is the root. It's guaranteed that the root has at least 2 children.

Output

Print "Yes" if the tree is a spruce and "No" otherwise.

Examples

Input

4
1
1
1

Output

Yes

Input

7
1
1
1
2
2
2

Output

No

Input

8
1
1
1
1
3
3
3

Output

Yes

Note

The first example:

<image>

The second example:

<image>

It is not a spruce, because the non-leaf vertex 1 has only 2 leaf children.

The third example:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int outdegree[1050], leafCount[1050];
vector<int> arr[1050];
bool dfs(int node, int par = -1) {
  int size = 0;
  for (int child : arr[node]) {
    if (child != par) {
      if (!dfs(child, node)) {
        return false;
      }
    }
    if (outdegree[child] == 0) {
      size++;
    }
  }
  if (size >= 3 || (size == 0 && arr[node].size() == 0)) {
    return true;
  } else {
    return false;
  }
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, a;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a;
    outdegree[a]++;
    arr[a].push_back(i + 1);
  }
  if (dfs(1)) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}

```


### Prompt

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

Three-valued logic is a logic system that has, in addition to "true" and "false", "unknown" as a valid value. In the following, logical values "false", "unknown" and "true" are represented by 0, 1 and 2 respectively.

Let "-" be a unary operator (i.e. a symbol representing one argument function) and let both "*" and "+" be binary operators (i.e. symbols representing two argument functions). These operators represent negation (NOT), conjunction (AND) and disjunction (OR) respectively. These operators in three-valued logic can be defined in Table C-1.

Table C-1: Truth tables of three-valued logic operators
-X| | (X*Y)| | (X+Y) | <image>|  | <image>|  | <image> |
---|---|---|---|---|---

Let P, Q and R be variables ranging over three-valued logic values. For a given formula, you are asked to answer the number of triples (P,Q,R) that satisfy the formula, that is, those which make the value of the given formula 2. A formula is one of the following form (X and Y represent formulas).

* Constants: 0, 1 or 2
* Variables: P, Q or R
* Negations: -X
* Conjunctions: (X*Y)
* Disjunctions: (X+Y)

Note that conjunctions and disjunctions of two formulas are always parenthesized.

For example, when formula (P*Q) is given as an input, the value of this formula is 2 when and only when (P,Q,R) is (2,2,0), (2,2,1) or (2,2,2). Therefore, you should output 3.

Input

The input consists of one or more lines. Each line contains a formula. A formula is a string which consists of 0, 1, 2, P, Q, R, -, *, +, (, ). Other characters such as spaces are not contained. The grammar of formulas is given by the following BNF.

<formula> ::= 0 | 1 | 2 | P | Q | R |
-<formula> | (<formula>*<formula>) | (<formula>+<formula>)

All the formulas obey this syntax and thus you do not have to care about grammatical errors. Input lines never exceed 80 characters.

Finally, a line which contains only a "." (period) comes, indicating the end of the input.

Output

You should answer the number (in decimal) of triples (P,Q,R) that make the value of the given formula 2. One line containing the number should be output for each of the formulas, and no other characters should be output.

Sample Input

(P*Q)
(--R+(P*Q))
(P*-P)
2
1
(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))
.

Output for the Sample Input

3
11
0
27
0
7

Example

Input

(P*Q)
(--R+(P*Q))
(P*-P)
2
1
(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))
.

Output

3
11
0
27
0
7

### Response

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

class Solve {
private:
	int product[3][3]{
		{0, 0, 0},
		{0, 1, 1},
		{0, 1, 2}
	};
	int sum[3][3]{
		{0, 1, 2},
		{1, 1, 2},
		{2, 2, 2}
	};
	int denial[3]{2, 1, 0};

	std::string formula;
	int variant[3]{};
	int f_i{};

	int calcVal()
	{
		if (formula[f_i] == '(')
			return interpretBinaryOperation();
		else if (formula[f_i] == '-')
		{
			f_i++;
			return denial[calcVal()];
		}
		else if ('P' <= formula[f_i] && formula[f_i] <= 'R')
		{
			f_i++;
			return variant[formula[f_i - 1] - 'P'];
		}
		else
		{
			f_i++;
			return formula[f_i - 1] - '0';
		}
	}

	int interpretBinaryOperation()
	{
		f_i++;
		int left{calcVal()};
		int ope{};
		if (formula[f_i] == '*') ope = 1;
		f_i++;
		int right{calcVal()};
		f_i++;

		if (ope) return product[left][right];
		else return sum[left][right];
	}

public:
	bool is_last_query{};
	Solve()
	{
		std::cin >> formula;
		if (formula[0] == '.')
		{
			is_last_query = true;
			return;
		}
		int count{};
		for (variant[0] = 0; variant[0] < 3; variant[0]++)
			for (variant[1] = 0; variant[1] < 3; variant[1]++)
				for (variant[2] = 0; variant[2] < 3; variant[2]++)
				{
					f_i = 0;
					if (calcVal() == 2)
						count++;
				}
		printf("%d\n", count);
	}

};

int main()
{
	while (!Solve().is_last_query);

	return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.

Constraints

* 2 ≤ |S| ≤ 26, where |S| denotes the length of S.
* S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If all the characters in S are different, print `yes` (case-sensitive); otherwise, print `no`.

Examples

Input

uncopyrightable

Output

yes

Input

different

Output

no

Input

no

Output

yes

### Response

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

int main() {
  string a;
  cin >> a;
  set<char> b;
  for (char c: a) b.insert(c);
  puts(a.size()==b.size() ? "yes" : "no");
}
```


### Prompt

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

There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue will have to visit his office exactly ai times. We will assume that an examination takes much more time than making tests and other extra procedures, and therefore we will assume that once an animal leaves the room, it immediately gets to the end of the queue to the doctor. Of course, if the animal has visited the doctor as many times as necessary, then it doesn't have to stand at the end of the queue and it immediately goes home.

Doctor plans to go home after receiving k animals, and therefore what the queue will look like at that moment is important for him. Since the doctor works long hours and she can't get distracted like that after all, she asked you to figure it out.

Input

The first line of input data contains two space-separated integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 1014). In the second line are given space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).

Output

If the doctor will overall carry out less than k examinations, print a single number "-1" (without quotes). Otherwise, print the sequence of numbers — number of animals in the order in which they stand in the queue.

Note that this sequence may be empty. This case is present in pretests. You can just print nothing or print one "End of line"-character. Both will be accepted.

Examples

Input

3 3
1 2 1

Output

2

Input

4 10
3 3 2 1

Output

-1

Input

7 10
1 3 3 1 2 3 1

Output

6 2 3

Note

In the first sample test:

  * Before examination: {1, 2, 3}
  * After the first examination: {2, 3}
  * After the second examination: {3, 2}
  * After the third examination: {2}

In the second sample test:

  * Before examination: {1, 2, 3, 4, 5, 6, 7}
  * After the first examination: {2, 3, 4, 5, 6, 7}
  * After the second examination: {3, 4, 5, 6, 7, 2}
  * After the third examination: {4, 5, 6, 7, 2, 3}
  * After the fourth examination: {5, 6, 7, 2, 3}
  * After the fifth examination: {6, 7, 2, 3, 5}
  * After the sixth examination: {7, 2, 3, 5, 6}
  * After the seventh examination: {2, 3, 5, 6}
  * After the eighth examination: {3, 5, 6, 2}
  * After the ninth examination: {5, 6, 2, 3}
  * After the tenth examination: {6, 2, 3}

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  set<pair<int, int> > line;
  int n;
  long long k;
  long long s = 0;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    line.insert(make_pair(x, i));
    s += x;
  }
  if (s < k) {
    cout << -1 << endl;
    return 0;
  }
  long long passed = 0;
  while (!line.empty() && k >= line.size() * (line.begin()->first - passed)) {
    k -= (long long)line.size() * (line.begin()->first - passed);
    passed = line.begin()->first;
    while (!line.empty() && line.begin()->first <= passed)
      line.erase(line.begin());
  }
  if (line.empty()) return 0;
  passed += k / line.size();
  k %= line.size();
  vector<pair<int, int> > res;
  res.reserve(line.size());
  while (!line.empty()) {
    res.push_back(make_pair(line.begin()->second, line.begin()->first));
    line.erase(line.begin());
  }
  sort(res.begin(), res.end());
  for (int i = 0; i < k; ++i)
    if (res[i].second <= passed + 1) res[i].first = -1;
  for (int i = 0; i < res.size(); ++i)
    if (res[(k + i) % res.size()].first != -1)
      cout << res[(k + i) % res.size()].first + 1 << ' ';
  cout << endl;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

There is a strange peculiarity: if you connect the cities of Rostov, Taganrog and Shakhty, peculiarly, you get a triangle

«Unbelievable But True»

Students from many different parts of Russia and abroad come to Summer Informatics School. You marked the hometowns of the SIS participants on a map.

Now you decided to prepare an interesting infographic based on this map. The first thing you chose to do is to find three cities on this map, such that they form a triangle with area S.

Input

The first line of input contains two integers n and S (3 ≤ n ≤ 2000, 1 ≤ S ≤ 2 ⋅ 10^{18}) — the number of cities on the map and the area of the triangle to be found.

The next n lines contain descriptions of the cities, one per line. Each city is described by its integer coordinates x_i, y_i (-10^9 ≤ x_i, y_i ≤ 10^9).

It is guaranteed that all cities are located at distinct points. It is also guaranteed that no three cities lie on the same line.

Output

If the solution doesn't exist — print «No».

Otherwise, print «Yes», followed by three pairs of coordinates (x, y) — the locations of the three cities, which form the triangle of area S.

Examples

Input

3 7
0 0
3 0
0 4

Output

No

Input

4 3
0 0
2 0
1 2
1 3

Output

Yes
0 0
1 3
2 0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
class Obj {
 public:
  long long i, j;
  int ind;
  long double ang;
  Obj(long long a, long long b, int d, long double c) {
    i = a;
    j = b;
    ind = d;
    ang = c;
  }
  bool operator<(const Obj &o) const { return ang < o.ang; }
};
long long x[2000];
long long y[2000];
long double area(long double x1, long double y1, long double x2, long double y2,
                 long double x3, long double y3) {
  long double ret =
      (x2 - x1) * (y2 + y1) + (x3 - x2) * (y2 + y3) + (x1 - x3) * (y1 + y3);
  return ret / 2.0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long double s;
  cin >> n >> s;
  vector<Obj> li;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  long double eps = 0.1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        continue;
      }
      li.push_back(Obj(i, j, 69, atan2(y[j] - y[i], x[j] - x[i])));
    }
  }
  sort(li.begin(), li.end());
  long double start = 0.6969694242;
  vector<Obj> li2;
  long double sx = cos(start) * 696969.0;
  long double sy = sin(start) * 696969.0;
  int pos[n];
  for (int i = 0; i < n; i++) {
    li2.push_back(Obj(x[i], y[i], i, area(0.0, 0.0, sy, sx, y[i], x[i])));
  }
  int ar[n];
  sort(li2.begin(), li2.end());
  for (int i = 0; i < n; i++) {
    pos[li2[i].ind] = i;
    ar[i] = li2[i].ind;
  }
  int first = 0;
  long double best = li[0].ang - start;
  for (int i = 1; i < li.size(); i++) {
    long double now = li[i].ang - start;
    if (best < 0.0 && now > 0.0) {
      best = now;
      first = i;
    } else if (now > 0.0 && now < best) {
      first = i;
      best = now;
    }
  }
  for (int i = first; i < li.size(); i++) {
    int a = (int)li[i].i;
    int b = (int)li[i].j;
    swap(pos[a], pos[b]);
    swap(ar[pos[a]], ar[pos[b]]);
    int lo = max(pos[a], pos[b]) + 1;
    int hi = n - 1;
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      long double are =
          abs(area(y[a], x[a], y[b], x[b], y[ar[mid]], x[ar[mid]]));
      if (abs(are - s) < eps) {
        cout << "Yes" << endl;
        cout << x[a] << " " << y[a] << endl;
        cout << x[b] << " " << y[b] << endl;
        cout << x[ar[mid]] << " " << y[ar[mid]] << endl;
        return 0;
      }
      if (are > s) {
        hi = mid - 1;
      } else {
        lo = mid + 1;
      }
    }
    lo = 0;
    hi = min(pos[a], pos[b]) - 1;
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      long double are =
          abs(area(y[a], x[a], y[b], x[b], y[ar[mid]], x[ar[mid]]));
      if (abs(are - s) < eps) {
        cout << "Yes" << endl;
        cout << x[a] << " " << y[a] << endl;
        cout << x[b] << " " << y[b] << endl;
        cout << x[ar[mid]] << " " << y[ar[mid]] << endl;
        return 0;
      }
      if (are > s) {
        lo = mid + 1;
      } else {
        hi = mid - 1;
      }
    }
  }
  for (int i = 0; i < first; i++) {
    int a = (int)li[i].i;
    int b = (int)li[i].j;
    swap(pos[a], pos[b]);
    swap(ar[pos[a]], ar[pos[b]]);
    int lo = max(pos[a], pos[b]) + 1;
    int hi = n - 1;
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      long double are =
          abs(area(y[a], x[a], y[b], x[b], y[ar[mid]], x[ar[mid]]));
      if (abs(are - s) < eps) {
        cout << "Yes" << endl;
        cout << x[a] << " " << y[a] << endl;
        cout << x[b] << " " << y[b] << endl;
        cout << x[ar[mid]] << " " << y[ar[mid]] << endl;
        return 0;
      }
      if (are > s) {
        hi = mid - 1;
      } else {
        lo = mid + 1;
      }
    }
    lo = 0;
    hi = min(pos[a], pos[b]) - 1;
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      long double are =
          abs(area(y[a], x[a], y[b], x[b], y[ar[mid]], x[ar[mid]]));
      if (abs(are - s) < eps) {
        cout << "Yes" << endl;
        cout << x[a] << " " << y[a] << endl;
        cout << x[b] << " " << y[b] << endl;
        cout << x[ar[mid]] << " " << y[ar[mid]] << endl;
        return 0;
      }
      if (are > s) {
        lo = mid + 1;
      } else {
        hi = mid - 1;
      }
    }
  }
  cout << "No" << endl;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters.

There is a filler word ogo in Oleg's speech. All words that can be obtained from ogo by adding go several times to the end of it are also considered to be fillers. For example, the words ogo, ogogo, ogogogo are fillers, but the words go, og, ogog, ogogog and oggo are not fillers.

The fillers have maximal size, for example, for ogogoo speech we can't consider ogo a filler and goo as a normal phrase. We should consider ogogo as a filler here.

To print the interview, Polycarp has to replace each of the fillers with three asterisks. Note that a filler word is replaced with exactly three asterisks regardless of its length.

Polycarp has dealt with this problem in no time. Can you do the same? The clock is ticking!

Input

The first line contains a positive integer n (1 ≤ n ≤ 100) — the length of the interview.

The second line contains the string s of length n, consisting of lowercase English letters.

Output

Print the interview text after the replacement of each of the fillers with "***". It is allowed for the substring "***" to have several consecutive occurences.

Examples

Input

7
aogogob

Output

a***b

Input

13
ogogmgogogogo

Output

***gmg***

Input

9
ogoogoogo

Output

*********

Note

The first sample contains one filler word ogogo, so the interview for printing is "a***b".

The second sample contains two fillers ogo and ogogogo. Thus, the interview is transformed to "***gmg***".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s, s1;
  bool g = false;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      if (i + 2 < n) {
        if (s[i + 1] == 'g' && s[i + 2] == 'o') {
          i += 2;
          s1 += "***";
          g = true;
        } else
          s1 += s[i];
      } else {
        s1 += s[i];
      }
    } else if (s[i] == 'g') {
      if (i + 1 < n) {
        if (s[i + 1] == 'o' && g)
          i++;
        else {
          g = false;
          s1 += s[i];
        }
      } else
        s1 += s[i];
    } else {
      g = false;
      s1 += s[i];
    }
  }
  cout << s1 << endl;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Little Petya loves training spiders. Petya has a board n × m in size. Each cell of the board initially has a spider sitting on it. After one second Petya chooses a certain action for each spider, and all of them humbly perform its commands. There are 5 possible commands: to stay idle or to move from current cell to some of the four side-neighboring cells (that is, one command for each of the four possible directions). Petya gives the commands so that no spider leaves the field. It is allowed for spiders to pass through each other when they crawl towards each other in opposite directions. All spiders crawl simultaneously and several spiders may end up in one cell. Petya wants to know the maximum possible number of spider-free cells after one second.

Input

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 40, n·m ≤ 40) — the board sizes.

Output

In the first line print the maximum number of cells without spiders.

Examples

Input

1 1

Output

0

Input

2 3

Output

4

Note

In the first sample the only possible answer is:

s

In the second sample one of the possible solutions is:

    rdl
    rul

s denotes command "stay idle", l, r, d, u denote commands "crawl left", "crawl right", "crawl down", "crawl up", correspondingly.

### Response

```cpp
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:60000000")
using namespace std;
const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
template <class T>
T sqr(T x) {
  return x * x;
}
int n, m;
long long g[40];
long long rest[41];
const int dx[5] = {0, 1, -1, 0, 0};
const int dy[5] = {0, 0, 0, 1, -1};
int best;
void go(long long mask, int cur, int cura) {
  if (cura >= best) return;
  if (cur >= n * m) return;
  if (mask == (1LL << (n * m)) - 1) {
    best = cura;
    return;
  }
  if ((mask | rest[cur]) != (1LL << (n * m)) - 1) return;
  go(mask | g[cur], cur + 1, cura + 1);
  go(mask, cur + 1, cura);
}
int main() {
  cin >> n >> m;
  memset(g, 0, sizeof(g));
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(m); j++) {
      int num1 = i * m + j;
      for (int k = 0; k < (int)(5); k++) {
        int x = i + dx[k];
        int y = j + dy[k];
        if (0 <= x && x < n && 0 <= y && y < m) {
          int num2 = x * m + y;
          g[num1] |= (1LL << num2);
        }
      }
    }
  memset(rest, 0, sizeof(rest));
  for (int i = (int)(n * m) - 1; i >= 0; i--) rest[i] = rest[i + 1] | g[i];
  best = n * m;
  go(0, 0, 0);
  cout << n * m - best << endl;
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

This is a harder version of the problem. In this version, n ≤ 50 000.

There are n distinct points in three-dimensional space numbered from 1 to n. The i-th point has coordinates (x_i, y_i, z_i). The number of points n is even.

You'd like to remove all n points using a sequence of n/2 snaps. In one snap, you can remove any two points a and b that have not been removed yet and form a perfectly balanced pair. A pair of points a and b is perfectly balanced if no other point c (that has not been removed yet) lies within the axis-aligned minimum bounding box of points a and b.

Formally, point c lies within the axis-aligned minimum bounding box of points a and b if and only if min(x_a, x_b) ≤ x_c ≤ max(x_a, x_b), min(y_a, y_b) ≤ y_c ≤ max(y_a, y_b), and min(z_a, z_b) ≤ z_c ≤ max(z_a, z_b). Note that the bounding box might be degenerate.

Find a way to remove all points in n/2 snaps.

Input

The first line contains a single integer n (2 ≤ n ≤ 50 000; n is even), denoting the number of points.

Each of the next n lines contains three integers x_i, y_i, z_i (-10^8 ≤ x_i, y_i, z_i ≤ 10^8), denoting the coordinates of the i-th point.

No two points coincide.

Output

Output n/2 pairs of integers a_i, b_i (1 ≤ a_i, b_i ≤ n), denoting the indices of points removed on snap i. Every integer between 1 and n, inclusive, must appear in your output exactly once.

We can show that it is always possible to remove all points. If there are many solutions, output any of them.

Examples

Input

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

Output

3 6
5 1
2 4

Input

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

Output

4 5
1 6
2 7
3 8

Note

In the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on z = 0 plane). Note that order of removing matters: for example, points 5 and 1 don't form a perfectly balanced pair initially, but they do after point 3 is removed.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const long long INF = 1e9;
const long long LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct pt {
  int x, y, z, id;
  bool operator<(const pt& p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    if (z != p.z) return z < p.z;
    return id < p.id;
  }
};
const int N = 1 << 17;
int n;
pt a[N];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = (0); i < (n); ++i) {
    cin >> a[i].x >> a[i].y >> a[i].z;
    a[i].id = i + 1;
  }
  map<int, vector<pt>> mp;
  for (int i = (0); i < (n); ++i) mp[a[i].x].push_back(a[i]);
  for (auto& i : mp) sort(i.second.begin(), i.second.end());
  vector<pair<int, int>> ans;
  for (auto& i : mp) {
    map<int, vector<pt>> mp2;
    for (auto x : i.second) mp2[x.y].push_back(x);
    for (auto& x : mp2) {
      for (int y = 0; y < (int)((x.second).size()) - 1; y += 2)
        ans.push_back({x.second[y].id, x.second[y + 1].id});
      reverse(x.second.begin(), x.second.end());
      x.second.resize((int)((x.second).size()) % 2);
    }
    vector<pt> vec;
    for (auto x : mp2)
      for (auto y : x.second) vec.push_back(y);
    for (int y = 0; y < (int)((vec).size()) - 1; y += 2)
      ans.push_back({vec[y].id, vec[y + 1].id});
    reverse(vec.begin(), vec.end());
    vec.resize((int)((vec).size()) % 2);
    i.second = vec;
  }
  vector<pt> vec;
  for (auto i : mp)
    for (auto j : i.second) vec.push_back(j);
  for (int x = 0; x < (int)((vec).size()); x += 2)
    ans.push_back({vec[x].id, vec[x + 1].id});
  assert((int)((ans).size()) == n / 2);
  for (int i = (0); i < (n >> 1); ++i)
    cout << ans[i].first << ' ' << ans[i].second << '\n';
  cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

There are N points on the 2D plane, i-th of which is located on (x_i, y_i). There can be multiple points that share the same coordinate. What is the maximum possible Manhattan distance between two distinct points?

Here, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.

Constraints

* 2 \leq N \leq 2 \times 10^5
* 1 \leq x_i,y_i \leq 10^9
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
x_2 y_2
:
x_N y_N

Output

Print the answer.

Examples

Input

3
1 1
2 4
3 2

Output

4

Input

2
1 1
1 1

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int q,x,y;
long long mx1=INT_MIN,mx2=INT_MIN,mn1=INT_MAX,mn2=INT_MAX;
int main()
{
    cin >> q;
    while(q--)
    {   cin>>x>>y;
        if(y+x>mx1)mx1=y+x;
        if(y-x>mx2)mx2=y-x;
        if(y+x<mn1)mn1=y+x;
        if(y-x<mn2)mn2=y-x;
    }
    cout<< max(abs(mx1-mn1), abs(mx2-mn2));
}

```


### Prompt

Please create a solution in cpp to the following problem:

Over time, Alexey's mail box got littered with too many letters. Some of them are read, while others are unread.

Alexey's mail program can either show a list of all letters or show the content of a single letter. As soon as the program shows the content of an unread letter, it becomes read letter (if the program shows the content of a read letter nothing happens). In one click he can do any of the following operations:

  * Move from the list of letters to the content of any single letter.
  * Return to the list of letters from single letter viewing mode.
  * In single letter viewing mode, move to the next or to the previous letter in the list. You cannot move from the first letter to the previous one or from the last letter to the next one.

The program cannot delete the letters from the list or rearrange them.

Alexey wants to read all the unread letters and go watch football. Now he is viewing the list of all letters and for each letter he can see if it is read or unread. What minimum number of operations does Alexey need to perform to read all unread letters?

Input

The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of letters in the mailbox.

The second line contains n space-separated integers (zeros and ones) — the state of the letter list. The i-th number equals either 1, if the i-th number is unread, or 0, if the i-th letter is read.

Output

Print a single number — the minimum number of operations needed to make all the letters read.

Examples

Input

5
0 1 0 1 0

Output

3

Input

5
1 1 0 0 1

Output

4

Input

2
0 0

Output

0

Note

In the first sample Alexey needs three operations to cope with the task: open the second letter, move to the third one, move to the fourth one.

In the second sample the action plan: open the first letter, move to the second letter, return to the list, open the fifth letter.

In the third sample all letters are already read.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int num[N];
int main() {
  int n;
  scanf("%d", &n);
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &num[i]);
    sum += num[i];
  }
  int cnt = 0;
  if (!sum) {
    printf("0");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (num[i] && num[i] == num[i - 1] + 1)
      cnt += 2;
    else if (num[i] && num[i] == num[i - 1])
      cnt += 1;
  }
  printf("%d\n", cnt - 1);
  return 0;
}

```


### Prompt

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

Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers).

The key in football is to divide into teams fairly before the game begins. There are n boys playing football in the yard (including Petya), each boy's football playing skill is expressed with a non-negative characteristic ai (the larger it is, the better the boy plays).

Let's denote the number of players in the first team as x, the number of players in the second team as y, the individual numbers of boys who play for the first team as pi and the individual numbers of boys who play for the second team as qi. Division n boys into two teams is considered fair if three conditions are fulfilled:

  * Each boy plays for exactly one team (x + y = n).
  * The sizes of teams differ in no more than one (|x - y| ≤ 1).
  * The total football playing skills for two teams differ in no more than by the value of skill the best player in the yard has. More formally: <image>

Your task is to help guys divide into two teams fairly. It is guaranteed that a fair division into two teams always exists.

Input

The first line contains the only integer n (2 ≤ n ≤ 105) which represents the number of guys in the yard. The next line contains n positive space-separated integers, ai (1 ≤ ai ≤ 104), the i-th number represents the i-th boy's playing skills.

Output

On the first line print an integer x — the number of boys playing for the first team. On the second line print x integers — the individual numbers of boys playing for the first team. On the third line print an integer y — the number of boys playing for the second team, on the fourth line print y integers — the individual numbers of boys playing for the second team. Don't forget that you should fulfil all three conditions: x + y = n, |x - y| ≤ 1, and the condition that limits the total skills.

If there are multiple ways to solve the problem, print any of them.

The boys are numbered starting from one in the order in which their skills are given in the input data. You are allowed to print individual numbers of boys who belong to the same team in any order.

Examples

Input

3
1 2 1

Output

2
1 2
1
3

Input

5
2 3 3 1 1

Output

3
4 1 3
2
5 2

Note

Let's consider the first sample test. There we send the first and the second boy to the first team and the third boy to the second team. Let's check all three conditions of a fair division. The first limitation is fulfilled (all boys play), the second limitation on the sizes of groups (|2 - 1| = 1 ≤ 1) is fulfilled, the third limitation on the difference in skills ((2 + 1) - (1) = 2 ≤ 2) is fulfilled.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using vec = vector<pair<int, int> >;
int main() {
  int n;
  scanf("%d", &n);
  vec v(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i].first);
    v[i].second = i + 1;
  }
  sort(v.begin(), v.end());
  int f = n / 2 + (n & 1);
  printf("%d\n", f);
  for (int i = 0; i < n; i += 2) {
    printf("%d ", v[i].second);
  }
  printf("\n%d\n", n / 2);
  for (int i = 1; i < n; i += 2) {
    printf("%d ", v[i].second);
  }
  puts("");
  return 0;
}

```


### Prompt

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

Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit.

For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not.

You have n cards with digits, and you want to use them to make as many phone numbers as possible. Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do not necessarily have to be distinct.

Input

The first line contains an integer n — the number of cards with digits that you have (1 ≤ n ≤ 100).

The second line contains a string of n digits (characters "0", "1", ..., "9") s_1, s_2, …, s_n. The string will not contain any other characters, such as leading or trailing spaces.

Output

If at least one phone number can be made from these cards, output the maximum number of phone numbers that can be made. Otherwise, output 0.

Examples

Input

11
00000000008

Output

1

Input

22
0011223344556677889988

Output

2

Input

11
31415926535

Output

0

Note

In the first example, one phone number, "8000000000", can be made from these cards.

In the second example, you can make two phone numbers from the cards, for example, "80123456789" and "80123456789".

In the third example you can't make any phone number from the given cards.

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  int n, count = 0, i, len;
  char num[105];
  scanf("%d ", &n);
  gets(num);
  len = strlen(num);
  if (n >= 11) {
    for (i = 0; i < len; i++) {
      if (num[i] == '8') {
        n -= 11;
        if (n >= 0) {
          count++;
          continue;
        } else
          break;
      }
    }
    printf("%d\n", count);
  } else
    printf("%d\n", 0);
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Takahashi will play a game using a piece on an array of squares numbered 1, 2, \cdots, N. Square i has an integer C_i written on it. Also, he is given a permutation of 1, 2, \cdots, N: P_1, P_2, \cdots, P_N.

Now, he will choose one square and place the piece on that square. Then, he will make the following move some number of times between 1 and K (inclusive):

* In one move, if the piece is now on Square i (1 \leq i \leq N), move it to Square P_i. Here, his score increases by C_{P_i}.

Help him by finding the maximum possible score at the end of the game. (The score is 0 at the beginning of the game.)

Constraints

* 2 \leq N \leq 5000
* 1 \leq K \leq 10^9
* 1 \leq P_i \leq N
* P_i \neq i
* P_1, P_2, \cdots, P_N are all different.
* -10^9 \leq C_i \leq 10^9
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
P_1 P_2 \cdots P_N
C_1 C_2 \cdots C_N

Output

Print the maximum possible score at the end of the game.

Examples

Input

5 2
2 4 5 1 3
3 4 -10 -8 8

Output

8

Input

2 3
2 1
10 -7

Output

13

Input

3 3
3 1 2
-1000 -2000 -3000

Output

-1000

Input

10 58
9 1 6 7 8 4 3 2 10 5
695279662 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719

Output

29507023469

### Response

```cpp
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n), c(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> c[i];
  rep(i, n) p[i]--;

  ll ans = -1e18;
  rep(si, n) {
    int x = si;  // current position
    vector<int> s;
    ll tot = 0;
    while (true) {
      x = p[x];
      s.push_back(c[x]);
      tot += c[x];
      if (x == si) break;
    }
    int l = s.size();  // length of cycle
    ll t = 0;
    rep(i, l) {
      t += s[i];
      if (i + 1> k) break;
      ll now = t;
      if (tot > 0) {
        ll e = (k - i - 1) / l;
        now += tot * e;
      }
      ans = max(ans, now);
    }
  }

  cout << ans << endl;
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Just to remind, girls in Arpa's land are really nice.

Mehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some weight wi and some beauty bi. Also each Hos may have some friends. Hoses are divided in some friendship groups. Two Hoses x and y are in the same friendship group if and only if there is a sequence of Hoses a1, a2, ..., ak such that ai and ai + 1 are friends for each 1 ≤ i < k, and a1 = x and ak = y.

<image>

Arpa allowed to use the amphitheater of palace to Mehrdad for this party. Arpa's amphitheater can hold at most w weight on it.

Mehrdad is so greedy that he wants to invite some Hoses such that sum of their weights is not greater than w and sum of their beauties is as large as possible. Along with that, from each friendship group he can either invite all Hoses, or no more than one. Otherwise, some Hoses will be hurt. Find for Mehrdad the maximum possible total beauty of Hoses he can invite so that no one gets hurt and the total weight doesn't exceed w.

Input

The first line contains integers n, m and w (1 ≤ n ≤ 1000, <image>, 1 ≤ w ≤ 1000) — the number of Hoses, the number of pair of friends and the maximum total weight of those who are invited.

The second line contains n integers w1, w2, ..., wn (1 ≤ wi ≤ 1000) — the weights of the Hoses.

The third line contains n integers b1, b2, ..., bn (1 ≤ bi ≤ 106) — the beauties of the Hoses.

The next m lines contain pairs of friends, the i-th of them contains two integers xi and yi (1 ≤ xi, yi ≤ n, xi ≠ yi), meaning that Hoses xi and yi are friends. Note that friendship is bidirectional. All pairs (xi, yi) are distinct.

Output

Print the maximum possible total beauty of Hoses Mehrdad can invite so that no one gets hurt and the total weight doesn't exceed w.

Examples

Input

3 1 5
3 2 5
2 4 2
1 2

Output

6

Input

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

Output

7

Note

In the first sample there are two friendship groups: Hoses {1, 2} and Hos {3}. The best way is to choose all of Hoses in the first group, sum of their weights is equal to 5 and sum of their beauty is 6.

In the second sample there are two friendship groups: Hoses {1, 2, 3} and Hos {4}. Mehrdad can't invite all the Hoses from the first group because their total weight is 12 > 11, thus the best way is to choose the first Hos from the first group and the only one from the second group. The total weight will be 8, and the total beauty will be 7.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int q, n;
long long int sum, ans;
long long int powe(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = (res * a);
    }
    a = (a * a);
    b /= 2;
  }
  return res;
}
long long int power(long long int a, long long int b, long long int M) {
  a %= M;
  long long int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = (res * a) % M;
    }
    a = (a * a) % M;
    b /= 2;
  }
  return res;
}
long long int extendedEuclid(long long int A, long long int B, long long int &x,
                             long long int &y) {
  if (B == 0) {
    x = 1;
    y = 0;
    return A;
  } else {
    long long int x1, y1;
    long long int gcd = extendedEuclid(B, A % B, x1, y1);
    y = x1 - (A / B) * y1;
    x = y1;
    return gcd;
  }
}
long long int mi(long long int A, long long int M) {
  long long int x, y;
  extendedEuclid(A, M, x, y);
  if (x < 0) {
    x += M;
  }
  return x;
}
vector<bool> sieve(1000020, true);
void Sieve() {
  sieve[0] = false;
  sieve[1] = false;
  for (long long int i = 2; i * i <= 1000020; i++) {
    if (sieve[i] == true) {
      for (long long int j = i * i; j < 1000020; j += i) sieve[j] = false;
    }
  }
}
long long int sieve_spf[1000010];
long long int n1 = 1000000;
void Sieve_spf() {
  for (int i = 0; i < n1; i++) sieve_spf[i] = i;
  sieve_spf[0] = -1;
  sieve_spf[1] = 1;
  for (int i = 2; i < n1; i += 2) sieve_spf[i] = 2;
  for (long long int i = 3; i < n1; i += 2) {
    if (sieve_spf[i] == i) {
      for (long long int j = (i * i); j < n1; j += i) {
        if (sieve_spf[j] == j) sieve_spf[j] = i;
      }
    }
  }
}
const int nax = 3e5 + 5;
long long int fact[nax];
void F() {
  fact[0] = 1;
  for (int i = 1; i < nax; i++) {
    fact[i] = fact[i - 1] * i;
  }
}
long long int nCr(long long int n, long long int r) {
  long long int res = 1;
  for (int i = 0; i < r; i++) {
    res *= (n - i);
  }
  return res / fact[r];
}
void the_happiest_place_on_earth() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
}
bool comp(const pair<long long int, long long int> &a,
          const pair<long long int, long long int> &b) {
  return (a.first < b.first || a.first == b.first && a.second < b.second);
}
const int N = 1010;
long long int a[N], b[N], c[N], p[N], par[N], Size[N], present[N], color[N],
    dp[N];
vector<int> adj[N], v[N];
int get(int a) { return par[a] = (a == par[a]) ? a : get(par[a]); }
void Union(int a, int b) {
  a = get(a);
  b = get(b);
  if (a != b) {
    if (Size[a] < Size[b]) swap(a, b);
    Size[a] += Size[b];
    par[b] = a;
  }
}
long long int m, w;
void testcase() {
  cin >> n >> m >> w;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) par[i] = i, Size[i] = 1;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    Union(x, y);
  }
  map<long long int, long long int> W, B;
  for (int i = 1; i <= n; i++) {
    W[get(i)] += a[i];
    B[get(i)] += b[i];
    v[get(i)].push_back(i);
  }
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    if (get(i) == i) {
      for (long long int j = w; j >= 0; j--) {
        for (auto x : v[i])
          if (j >= a[x]) dp[j] = max(dp[j], dp[j - a[x]] + b[x]);
        if (j >= W[i]) dp[j] = max(dp[j], dp[j - W[i]] + B[i]);
      }
    }
  }
  cout << dp[w];
  return;
}
int main() {
  the_happiest_place_on_earth();
  the_happiest_place_on_earth();
  q = 1;
  int t = 0;
  while (q--) {
    testcase();
  }
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different sorts of heuristics.

Polycarp needed to write a code that could, given two words, check whether they could have been obtained from the same word as a result of typos. Polycarpus suggested that the most common typo is skipping exactly one letter as you type a word.

Implement a program that can, given two distinct words S and T of the same length n determine how many words W of length n + 1 are there with such property that you can transform W into both S, and T by deleting exactly one character. Words S and T consist of lowercase English letters. Word W also should consist of lowercase English letters.

Input

The first line contains integer n (1 ≤ n ≤ 100 000) — the length of words S and T.

The second line contains word S.

The third line contains word T.

Words S and T consist of lowercase English letters. It is guaranteed that S and T are distinct words.

Output

Print a single integer — the number of distinct words W that can be transformed to S and T due to a typo.

Examples

Input

7
reading
trading

Output

1

Input

5
sweet
sheep

Output

0

Input

3
toy
try

Output

2

Note

In the first sample test the two given words could be obtained only from word "treading" (the deleted letters are marked in bold).

In the second sample test the two given words couldn't be obtained from the same word by removing one letter.

In the third sample test the two given words could be obtained from either word "tory" or word "troy".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, ans, i, lg, rg, pf, sf;
char s[MAXN];
char t[MAXN];
bool ok;
int main() {
  srand(time(0));
  scanf("%d%s%s", &n, s + 1, t + 1);
  pf = 0;
  while (pf < n && s[pf + 1] == t[pf + 1]) pf++;
  sf = 0;
  while (sf < n && s[n - sf] == t[n - sf]) sf++;
  lg = pf + 1;
  rg = n - sf;
  ok = 1;
  for (i = 1; i <= rg - lg; i++) {
    if (s[lg + i - 1] != t[lg + i]) {
      ok = 0;
      break;
    }
  }
  ans += ok;
  ok = 1;
  for (i = 1; i <= rg - lg; i++) {
    if (s[lg + i] != t[lg + i - 1]) {
      ok = 0;
      break;
    }
  }
  ans += ok;
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

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

We all know that GukiZ often plays with arrays.

Now he is thinking about this problem: how many arrays a, of length n, with non-negative elements strictly less then 2l meet the following condition: <image>? Here operation <image> means bitwise AND (in Pascal it is equivalent to and, in C/C++/Java/Python it is equivalent to &), operation <image> means bitwise OR (in Pascal it is equivalent to <image>, in C/C++/Java/Python it is equivalent to |).

Because the answer can be quite large, calculate it modulo m. This time GukiZ hasn't come up with solution, and needs you to help him!

Input

First and the only line of input contains four integers n, k, l, m (2 ≤ n ≤ 1018, 0 ≤ k ≤ 1018, 0 ≤ l ≤ 64, 1 ≤ m ≤ 109 + 7).

Output

In the single line print the number of arrays satisfying the condition above modulo m.

Examples

Input

2 1 2 10

Output

3

Input

2 1 1 3

Output

1

Input

3 3 2 10

Output

9

Note

In the first sample, satisfying arrays are {1, 1}, {3, 1}, {1, 3}.

In the second sample, only satisfying array is {1, 1}.

In the third sample, satisfying arrays are {0, 3, 3}, {1, 3, 2}, {1, 3, 3}, {2, 3, 1}, {2, 3, 3}, {3, 3, 0}, {3, 3, 1}, {3, 3, 2}, {3, 3, 3}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long MOD;
vector<long long> mult(vector<long long> a, vector<long long> b) {
  vector<long long> temp;
  long long t = ((a[0] * b[0]) % MOD + (a[1] * b[2]) % MOD) % MOD;
  temp.push_back((t + MOD) % MOD);
  t = ((a[0] * b[1]) % MOD + (a[1] * b[3]) % MOD) % MOD;
  temp.push_back((t + MOD) % MOD);
  t = ((a[2] * b[0]) % MOD + (a[3] * b[2]) % MOD) % MOD;
  temp.push_back((t + MOD) % MOD);
  t = ((a[2] * b[1]) % MOD + (a[3] * b[3]) % MOD) % MOD;
  temp.push_back((t + MOD) % MOD);
  return temp;
}
vector<long long> power(vector<long long> a, long long b) {
  vector<long long> pow_a = a, res;
  res.push_back(1);
  res.push_back(0);
  res.push_back(0);
  res.push_back(1);
  while (b > 0) {
    if (b & 1) res = mult(res, pow_a);
    b /= 2;
    pow_a = mult(pow_a, pow_a);
  }
  return res;
}
long long power(long long a, long long b) {
  long long pow_a = a % MOD, res = 1;
  while (b > 0) {
    if (b & 1) res = (res * pow_a) % MOD;
    b /= 2;
    pow_a = (pow_a * pow_a) % MOD;
  }
  res = (res + MOD) % MOD;
  return res;
}
int main() {
  long long n, k, l;
  cin >> n >> k >> l >> MOD;
  long long tem = k, c = 0;
  while (tem > 0) {
    tem /= 2;
    c++;
  }
  if (c > l) {
    cout << "0" << endl;
    return 0;
  }
  vector<long long> temp = vector<long long>(4, 1);
  temp[0] = 0;
  temp = power(temp, n - 1);
  long long fn = (temp[2] + 2 * temp[3]) % MOD;
  fn = (fn + MOD) % MOD;
  long long fn2 = (power(2, n) - fn + MOD) % MOD;
  fn2 = (fn2 + MOD) % MOD;
  long long ans = 1;
  for (__typeof(l) i = (0); i != (l); i++) {
    if (k % 2 == 0)
      ans = (ans * fn) % MOD;
    else
      ans = (ans * fn2) % MOD;
    k /= 2;
  }
  ans %= MOD;
  cout << ans << endl;
  return 0;
}

```