### Prompt

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

An old document says that a Ninja House in Kanazawa City was in fact a defensive fortress, which was designed like a maze. Its rooms were connected by hidden doors in a complicated manner, so that any invader would become lost. Each room has at least two doors.

The Ninja House can be modeled by a graph, as shown in Figure l. A circle represents a room. Each line connecting two circles represents a door between two rooms.

<image> Figure l. Graph Model of Ninja House.  |  Figure 2. Ninja House exploration.
---|---

I decided to draw a map, since no map was available. Your mission is to help me draw a map from the record of my exploration.

I started exploring by entering a single entrance that was open to the outside. The path I walked is schematically shown in Figure 2, by a line with arrows. The rules for moving between rooms are described below.

After entering a room, I first open the rightmost door and move to the next room. However, if the next room has already been visited, I close the door without entering, and open the next rightmost door, and so on. When I have inspected all the doors of a room, I go back through the door I used to enter the room.

I have a counter with me to memorize the distance from the first room. The counter is incremented when I enter a new room, and decremented when I go back from a room. In Figure 2, each number in parentheses is the value of the counter when I have entered the room, i.e., the distance from the first room. In contrast, the numbers not in parentheses represent the order of my visit.

I take a record of my exploration. Every time I open a door, I record a single number, according to the following rules.

1. If the opposite side of the door is a new room, I record the number of doors in that room, which is a positive number.
2. If it is an already visited room, say R, I record ``the distance of R from the first room'' minus ``the distance of the current room from the first room'', which is a negative number.

In the example shown in Figure 2, as the first room has three doors connecting other rooms, I initially record ``3''. Then when I move to the second, third, and fourth rooms, which all have three doors, I append ``3 3 3'' to the record. When I skip the entry from the fourth room to the first room, the distance difference ``-3'' (minus three) will be appended, and so on. So, when I finish this exploration, its record is a sequence of numbers ``3 3 3 3 -3 3 2 -5 3 2 -5 -3''.

There are several dozens of Ninja Houses in the city. Given a sequence of numbers for each of these houses, you should produce a graph for each house.

Input

The first line of the input is a single integer n, indicating the number of records of Ninja Houses I have visited. You can assume that n is less than 100. Each of the following n records consists of numbers recorded on one exploration and a zero as a terminator. Each record consists of one or more lines whose lengths are less than 1000 characters. Each number is delimited by a space or a newline. You can assume that the number of rooms for each Ninja House is less than 100, and the number of doors in each room is less than 40.

Output

For each Ninja House of m rooms, the output should consist of m lines. The j-th line of each such m lines should look as follows:

i r1 r2  ... rki

where r1, ... , rki should be rooms adjoining room i, and ki should be the number of doors in room i. Numbers should be separated by exactly one space character. The rooms should be numbered from 1 in visited order. r1, r2, ... , rki should be in ascending order. Note that the room i may be connected to another room through more than one door. In this case, that room number should appear in r1, ... , rki as many times as it is connected by different doors.

Example

Input

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

Output

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

### Response

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

using namespace std;

namespace {

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }

    vector<int> R;
    void input() {
        R.clear();
        while (true) {
            int x; cin >> x;
            if (x == 0) break;
            R.push_back(x);
        }
    }

    vector< vector<int> > G;
    int N;
    vector<int> Z;

    void dfs(int v, int& c, int d, vector<int>& x, int& nv) {
        if (c == R.size()) return;
        //cout << v << " " << c << " " << d << " " << x << endl;
        int p = x[d];
        x[d] = v;
        while (c < R.size() && Z[v] > 0) {
            int r = R[c];
            if (r > 0) {
                G[v].push_back(nv);
                G[nv].push_back(v);
                Z[v]--; Z[nv]--;
                c++;
                int n = nv; nv++;
                dfs(n, c, d + 1, x, nv);
            } else {
                int n = x[d + r];
                //cout << "connect " << v << " " << n << endl;
                G[v].push_back(n);
                G[n].push_back(v);
                Z[v]--; Z[n]--;
                c++;
            }
        }
        x[d] = p;
    }

    void solve() {
        Z.clear();
        for (int i = 0; i < R.size(); i++) {
            int r = R[i];
            if (r > 0) {
                Z.push_back(r);
            }
        }
        N = int(Z.size());
        G.clear(); G.resize(N);
        vector<int> x(N, -1);
        int c = 1;
        int nv = 1;
        dfs(0, c, 0, x, nv);
        for (int i = 0; i < N; i++) {
            sort(G[i].begin(), G[i].end());
            int M = G[i].size();
            cout << i + 1;
            for (int j = 0; j < M; j++) {
                cout << " " << G[i][j] + 1;
            }
            cout << endl;
        }
    }
}

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        input(); solve();
    }
    return 0;
}
```


### Prompt

Please formulate a CPP solution to the following problem:

Polycarpus is the director of a large corporation. There are n secretaries working for the corporation, each of them corresponds via the famous Spyke VoIP system during the day. We know that when two people call each other via Spyke, the Spyke network assigns a unique ID to this call, a positive integer session number.

One day Polycarpus wondered which secretaries are talking via the Spyke and which are not. For each secretary, he wrote out either the session number of his call or a 0 if this secretary wasn't talking via Spyke at that moment.

Help Polycarpus analyze these data and find out the number of pairs of secretaries that are talking. If Polycarpus has made a mistake in the data and the described situation could not have taken place, say so.

Note that the secretaries can correspond via Spyke not only with each other, but also with the people from other places. Also, Spyke conferences aren't permitted — that is, one call connects exactly two people.

Input

The first line contains integer n (1 ≤ n ≤ 103) — the number of secretaries in Polycarpus's corporation. The next line contains n space-separated integers: id1, id2, ..., idn (0 ≤ idi ≤ 109). Number idi equals the number of the call session of the i-th secretary, if the secretary is talking via Spyke, or zero otherwise.

Consider the secretaries indexed from 1 to n in some way.

Output

Print a single integer — the number of pairs of chatting secretaries, or -1 if Polycarpus's got a mistake in his records and the described situation could not have taken place.

Examples

Input

6
0 1 7 1 7 10

Output

2

Input

3
1 1 1

Output

-1

Input

1
0

Output

0

Note

In the first test sample there are two Spyke calls between secretaries: secretary 2 and secretary 4, secretary 3 and secretary 5.

In the second test sample the described situation is impossible as conferences aren't allowed.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> S;
int x1, x2;
int main() {
  int n, c, ans = 0, l;
  long long a[1000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] != 0) {
      c = 0;
      for (int j = i; j < n; j++) {
        if (a[i] == a[j]) c++;
      }
      if (c > 2) {
        cout << "-1";
        return 0;
      }
      if (c == 2) ans++;
    }
  }
  cout << ans;
  return 0;
  return 0;
}

```


### Prompt

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

You are the gym teacher in the school.

There are n students in the row. And there are two rivalling students among them. The first one is in position a, the second in position b. Positions are numbered from 1 to n from left to right.

Since they are rivals, you want to maximize the distance between them. If students are in positions p and s respectively, then distance between them is |p - s|.

You can do the following operation at most x times: choose two adjacent (neighbouring) students and swap them.

Calculate the maximum distance between two rivalling students after at most x swaps.

Input

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

The only line of each test case contains four integers n, x, a and b (2 ≤ n ≤ 100, 0 ≤ x ≤ 100, 1 ≤ a, b ≤ n, a ≠ b) — the number of students in the row, the number of swaps which you can do, and positions of first and second rivaling students respectively.

Output

For each test case print one integer — the maximum distance between two rivaling students which you can obtain.

Example

Input

3
5 1 3 2
100 33 100 1
6 0 2 3

Output

2
99
1

Note

In the first test case you can swap students in positions 3 and 4. And then the distance between the rivals is equal to |4 - 2| = 2.

In the second test case you don't have to swap students.

In the third test case you can't swap students.

### Response

```cpp
#include <bits/stdc++.h>
const int len = 1e9 + 7;
using namespace std;
void solve() {
  int n, x, a, b, d = 0;
  cin >> n >> x >> a >> b;
  int i = min(a, b), j = max(a, b);
  if (x == 0) {
    cout << abs(a - b) << "\n";
    return;
  }
  while (x--) {
    if (i > 1) {
      i--;
    } else if (j < n) {
      j++;
    }
    d = max(d, abs(i - j));
  }
  cout << d << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

There are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates.

You can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the currency of Japan). It is not possible to build other types of roads.

Your objective is to build roads so that it will be possible to travel between every pair of towns by traversing roads. At least how much money is necessary to achieve this?

Constraints

* 2 ≤ N ≤ 10^5
* 0 ≤ x_i,y_i ≤ 10^9
* All input values 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 minimum necessary amount of money in order to build roads so that it will be possible to travel between every pair of towns by traversing roads.

Examples

Input

3
1 5
3 9
7 8

Output

3

Input

6
8 3
4 9
12 19
18 1
13 5
7 6

Output

8

### Response

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

using namespace std;

constexpr int N = 100005;

struct Edege{
  int u, v, w;
  bool operator < (const Edege &b) const{
    return w < b.w;
  }
};

struct Node{
  int id, x;
  bool operator < (const Node &b) const {
    return x < b.x;
  }
};

int fa[N], cnt;
Node a[N], b[N];
Edege e[N * 3];

void add(int u, int v, int w){
  e[cnt].u = u;
  e[cnt].v = v;
  e[cnt++].w = w;
}

int findFa(int u){
  if(fa[u] != u){
    fa[u] = findFa(fa[u]);
  }
  return fa[u];
}

int main(){
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i){
    fa[i] = i;
  }
  cnt = 1;
  for(int i = 1; i <= n; ++i){
    a[i].id = b[i].id = i;
    scanf("%d%d", &a[i].x, &b[i].x);
  }
  sort(a + 1, a + n + 1);
  for(int i = 2; i <= n; ++i){
    add(a[i].id, a[i - 1].id, a[i].x - a[i - 1].x);
  }
  sort(b + 1, b + n + 1);
  for(int i = 2; i <= n; ++i){
    add(b[i].id, b[i - 1].id, b[i].x - b[i - 1].x);
  }
  sort(e + 1, e + cnt + 1);
  long long tempAns = 0;
  for(int i = 1; i < cnt; ++i){
    int u = e[i].u, v = e[i].v, w = e[i].w;
    u = findFa(u);
    v = findFa(v);
    if(u != v){
      tempAns += w;
      fa[v] = u;
    }
  }
  cout << tempAns << endl;
  return 0;
}

```


### Prompt

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

<image>

At the request of a friend who started learning abacus, you decided to create a program to display the abacus beads. Create a program that takes a certain number as input and outputs a row of abacus beads. However, the number of digits of the abacus to be displayed is 5 digits, and the arrangement of beads from 0 to 9 is as follows using'*' (half-width asterisk),''(half-width blank), and'=' (half-width equal). It shall be expressed as.

<image>

Input

Multiple test cases are given. Up to 5 digits (integer) are given on one line for each test case.

The number of test cases does not exceed 1024.

Output

Output the abacus bead arrangement for each test case. Insert a blank line between the test cases.

Example

Input

2006
1111

Output

****
    *
=====
 *  *
****
* ***
*****
*****

*****

=====
 ****
*
*****
*****
*****

### Response

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

int main()
{
  int n;
  bool first = true;
  while (cin >> n) {
    vector<string> ans(8, "");
    for (int keta = 0; keta < 5; ++keta) {
      int d = n % 10;

      if (d >= 5) {
	ans[0] = " " + ans[0];
	ans[1] = "*" + ans[1];
      } else {
	ans[0] = "*" + ans[0];
	ans[1] = " " + ans[1];
      }
      ans[2] += "=";

      for (int i = 0; i < 5; ++i) {
	if (i == d%5)
	  ans[i+3] = " " + ans[i+3];
	else
	  ans[i+3] = "*" + ans[i+3];
      }

      n /= 10;
    }
    if (!first)
      cout << endl;
    for (unsigned int i = 0; i < ans.size(); ++i)
      cout << ans[i] << endl;
    first = false;
  }
  return 0;
}
```


### Prompt

Generate a CPP solution to the following problem:

There is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note that the sequence is 0-indexed.)

For every integer K satisfying 1 \leq K \leq 2^N-1, solve the following problem:

* Let i and j be integers. Find the maximum value of A_i + A_j where 0 \leq i < j \leq 2^N-1 and (i or j) \leq K. Here, or denotes the bitwise OR.

Constraints

* 1 \leq N \leq 18
* 1 \leq A_i \leq 10^9
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_0 A_1 ... A_{2^N-1}

Output

Print 2^N-1 lines. In the i-th line, print the answer of the problem above for K=i.

Examples

Input

2
1 2 3 1

Output

3
4
5

Input

3
10 71 84 33 6 47 23 25

Output

81
94
155
155
155
155
155

Input

4
75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32

Output

101
120
147
156
156
178
194
194
194
194
194
194
194
194
194

### Response

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

const int N = 1 << 18;
using P = pair<int, int>;
P a[N];

P calc(P a, P b) {
  vector<int> v{a.first, a.second, b.first, b.second};
  sort(begin(v), end(v));
  return P(v[3], v[2]);
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n; cin >> n;
  int m = 1 << n;
  int mask = m - 1;
  for(int i = 0; i < m; i++) {
    int x; cin >> x;
    a[i^mask] = P(x, -1e9);
  }
  for(int i = 0; i < n; i++) for(int b = 0; b < (1 << n); b++)
    if(!(b & (1 << i))) a[b] = calc(a[b], a[b | (1 << i)]);
  int ma = 0;
  for(int i = 1; i < m; i++) cout << (ma = max(a[i^mask].first + a[i^mask].second, ma)) << endl;
  return 0;
}

```


### Prompt

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

There is a robot staying at X=0 on the Ox axis. He has to walk to X=n. You are controlling this robot and controlling how he goes. The robot has a battery and an accumulator with a solar panel.

The i-th segment of the path (from X=i-1 to X=i) can be exposed to sunlight or not. The array s denotes which segments are exposed to sunlight: if segment i is exposed, then s_i = 1, otherwise s_i = 0.

The robot has one battery of capacity b and one accumulator of capacity a. For each segment, you should choose which type of energy storage robot will use to go to the next point (it can be either battery or accumulator). If the robot goes using the battery, the current charge of the battery is decreased by one (the robot can't use the battery if its charge is zero). And if the robot goes using the accumulator, the current charge of the accumulator is decreased by one (and the robot also can't use the accumulator if its charge is zero).

If the current segment is exposed to sunlight and the robot goes through it using the battery, the charge of the accumulator increases by one (of course, its charge can't become higher than it's maximum capacity).

If accumulator is used to pass some segment, its charge decreases by 1 no matter if the segment is exposed or not.

You understand that it is not always possible to walk to X=n. You want your robot to go as far as possible. Find the maximum number of segments of distance the robot can pass if you control him optimally.

Input

The first line of the input contains three integers n, b, a (1 ≤ n, b, a ≤ 2 ⋅ 10^5) — the robot's destination point, the battery capacity and the accumulator capacity, respectively.

The second line of the input contains n integers s_1, s_2, ..., s_n (0 ≤ s_i ≤ 1), where s_i is 1 if the i-th segment of distance is exposed to sunlight, and 0 otherwise.

Output

Print one integer — the maximum number of segments the robot can pass if you control him optimally.

Examples

Input

5 2 1
0 1 0 1 0

Output

5

Input

6 2 1
1 0 0 1 0 1

Output

3

Note

In the first example the robot can go through the first segment using the accumulator, and charge levels become b=2 and a=0. The second segment can be passed using the battery, and charge levels become b=1 and a=1. The third segment can be passed using the accumulator, and charge levels become b=1 and a=0. The fourth segment can be passed using the battery, and charge levels become b=0 and a=1. And the fifth segment can be passed using the accumulator.

In the second example the robot can go through the maximum number of segments using battery two times and accumulator one time in any order.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, b, a;
  cin >> n >> b >> a;
  int full = a;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a == 0 && b == 0) break;
    if (a == 0) {
      b--;
      if (v[i] == 1 && a < full) a++;
    } else if (b == 0) {
      a--;
    } else {
      if (v[i] == 1) {
        if (a == full) {
          a--;
        } else {
          b--;
          if (a < full) a++;
        }
      } else {
        a--;
      }
    }
    ans++;
  }
  cout << ans;
}

```


### Prompt

Generate a CPP solution to the following problem:

You are given a rooted tree with n vertices, the root of the tree is the vertex 1. Each vertex has some non-negative price. A leaf of the tree is a non-root vertex that has degree 1.

Arkady and Vasily play a strange game on the tree. The game consists of three stages. On the first stage Arkady buys some non-empty set of vertices of the tree. On the second stage Vasily puts some integers into all leaves of the tree. On the third stage Arkady can perform several (possibly none) operations of the following kind: choose some vertex v he bought on the first stage and some integer x, and then add x to all integers in the leaves in the subtree of v. The integer x can be positive, negative of zero.

A leaf a is in the subtree of a vertex b if and only if the simple path between a and the root goes through b.

Arkady's task is to make all integers in the leaves equal to zero. What is the minimum total cost s he has to pay on the first stage to guarantee his own win independently of the integers Vasily puts on the second stage? Also, we ask you to find all such vertices that there is an optimal (i.e. with cost s) set of vertices containing this one such that Arkady can guarantee his own win buying this set on the first stage.

Input

The first line contains a single integer n (2 ≤ n ≤ 200 000) — the number of vertices in the tree.

The second line contains n integers c_1, c_2, …, c_n (0 ≤ c_i ≤ 10^9), where c_i is the price of the i-th vertex.

Each of the next n - 1 lines contains two integers a and b (1 ≤ a, b ≤ n), denoting an edge of the tree.

Output

In the first line print two integers: the minimum possible cost s Arkady has to pay to guarantee his own win, and the number of vertices k that belong to at least one optimal set.

In the second line print k distinct integers in increasing order the indices of the vertices that belong to at least one optimal set.

Examples

Input

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

Output

4 3
2 4 5

Input

3
1 1 1
1 2
1 3

Output

2 3
1 2 3

Note

In the second example all sets of two vertices are optimal. So, each vertex is in at least one optimal set.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
int n, w[N];
vector<int> G[N];
int fa[N], l[N], r[N];
int fnd(int x) { return x == fa[x] ? x : fa[x] = fnd(fa[x]); }
struct E {
  int u, v, c, w;
  bool operator<(const E &z) const { return w < z.w; }
} e[N];
int k;
void dfs(int u, int f) {
  l[u] = n, r[u] = 0;
  for (int v : G[u])
    if (v != f) dfs(v, u), l[u] = min(l[u], l[v]), r[u] = max(r[u], r[v]);
  if (G[u].size() == 1 && f) l[u] = r[u] = ++k;
  e[u] = (E){l[u], r[u] + 1, u, w[u]};
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (int i = 1, u, v; i < n; i++)
    scanf("%d%d", &u, &v), G[u].push_back(v), G[v].push_back(u);
  dfs(1, 0);
  long long ans = 0;
  sort(e + 1, e + n + 1);
  static bool ex[N];
  int ct = 0;
  for (int i = 1, j; i <= n; i = j) {
    j = i;
    while (e[j].w == e[i].w) ++j;
    for (int k = i; k < j; k++) {
      int u = fnd(e[k].u), v = fnd(e[k].v);
      if (u != v) ex[e[k].c] = true, ++ct;
    }
    for (int k = i; k < j; k++) {
      int u = fnd(e[k].u), v = fnd(e[k].v);
      if (u != v) fa[u] = v, ans += e[k].w;
    }
  }
  cout << ans << " " << ct << '\n';
  for (int i = 1; i <= n; i++)
    if (ex[i]) cout << i << " ";
  return 0;
}

```


### Prompt

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

Students love to celebrate their holidays. Especially if the holiday is the day of the end of exams!

Despite the fact that Igor K., unlike his groupmates, failed to pass a programming test, he decided to invite them to go to a cafe so that each of them could drink a bottle of... fresh cow milk. Having entered the cafe, the m friends found n different kinds of milk on the menu, that's why they ordered n bottles — one bottle of each kind. We know that the volume of milk in each bottle equals w.

When the bottles were brought in, they decided to pour all the milk evenly among the m cups, so that each got a cup. As a punishment for not passing the test Igor was appointed the person to pour the milk. He protested that he was afraid to mix something up and suggested to distribute the drink so that the milk from each bottle was in no more than two different cups. His friends agreed but they suddenly faced the following problem — and what is actually the way to do it?

Help them and write the program that will help to distribute the milk among the cups and drink it as quickly as possible!

Note that due to Igor K.'s perfectly accurate eye and unswerving hands, he can pour any fractional amount of milk from any bottle to any cup.

Input

The only input data file contains three integers n, w and m (1 ≤ n ≤ 50, 100 ≤ w ≤ 1000, 2 ≤ m ≤ 50), where n stands for the number of ordered bottles, w stands for the volume of each of them and m stands for the number of friends in the company.

Output

Print on the first line "YES" if it is possible to pour the milk so that the milk from each bottle was in no more than two different cups. If there's no solution, print "NO".

If there is a solution, then print m more lines, where the i-th of them describes the content of the i-th student's cup. The line should consist of one or more pairs that would look like "b v". Each such pair means that v (v > 0) units of milk were poured into the i-th cup from bottle b (1 ≤ b ≤ n). All numbers b on each line should be different.

If there are several variants to solve the problem, print any of them. Print the real numbers with no less than 6 digits after the decimal point.

Examples

Input

2 500 3

Output

YES
1 333.333333
2 333.333333
2 166.666667 1 166.666667

Input

4 100 5

Output

YES
3 20.000000 4 60.000000
1 80.000000
4 40.000000 2 40.000000
3 80.000000
2 60.000000 1 20.000000

Input

4 100 7

Output

NO

Input

5 500 2

Output

YES
4 250.000000 5 500.000000 2 500.000000
3 500.000000 1 500.000000 4 250.000000

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int nbottles, ncups;
  double bvolume, cvolume;
  cin >> nbottles >> bvolume >> ncups;
  cvolume = double(nbottles) * bvolume / ncups;
  if (nbottles < ncups && nbottles % (ncups - nbottles) != 0) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << '\n';
  cout.precision(6);
  int poured = 0, left;
  for (int i = 1; i <= nbottles; i++) {
    left = nbottles - poured;
    poured += ncups;
    if (poured < nbottles)
      cout << i << ' ' << fixed << bvolume << ' ';
    else {
      cout << i << ' ' << fixed << (left * bvolume) / ncups << '\n';
      poured -= nbottles;
      for (; poured >= nbottles; poured -= nbottles)
        cout << i << ' ' << cvolume << '\n';
      if (poured > 0)
        cout << i << ' ' << fixed << (poured * bvolume) / ncups << ' ';
    }
  }
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

There are n castles in the Lannister's Kingdom and some walls connect two castles, no two castles are connected by more than one wall, no wall connects a castle to itself.

Sir Jaime Lannister has discovered that Daenerys Targaryen is going to attack his kingdom soon. Therefore he wants to defend his kingdom. He has k liters of a strange liquid. He wants to distribute that liquid among the castles, so each castle may contain some liquid (possibly zero or non-integer number of liters). After that the stability of a wall is defined as follows: if the wall connects two castles a and b, and they contain x and y liters of that liquid, respectively, then the strength of that wall is x·y.

Your task is to print the maximum possible sum of stabilities of the walls that Sir Jaime Lannister can achieve.

Input

The first line of the input contains two integers n and k (1 ≤ n ≤ 40, 1 ≤ k ≤ 1000).

Then n lines follows. The i-th of these lines contains n integers ai, 1, ai, 2, ..., ai, n (<image>). If castles i and j are connected by a wall, then ai, j = 1. Otherwise it is equal to 0.

It is guaranteed that ai, j = aj, i and ai, i = 0 for all 1 ≤ i, j ≤ n.

Output

Print the maximum possible sum of stabilities of the walls that Sir Jaime Lannister can achieve.

Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

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

Examples

Input

3 1
0 1 0
1 0 0
0 0 0

Output

0.250000000000

Input

4 4
0 1 0 1
1 0 1 0
0 1 0 1
1 0 1 0

Output

4.000000000000

Note

In the first sample, we can assign 0.5, 0.5, 0 liters of liquid to castles 1, 2, 3, respectively, to get the maximum sum (0.25).

In the second sample, we can assign 1.0, 1.0, 1.0, 1.0 liters of liquid to castles 1, 2, 3, 4, respectively, to get the maximum sum (4.0)

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 50;
int n, m, k, Max[1 << 20];
bitset<N> go[N], now;
void dfs(int p, int cnt, bitset<N> now) {
  if (p == n) {
    int S = 0;
    for (int i = 0; i < m; i++)
      if (now[i]) S |= (1 << i);
    Max[S] = max(Max[S], cnt);
    return;
  }
  dfs(p + 1, cnt, now);
  if (now[p]) dfs(p + 1, cnt + 1, now & go[p]);
}
int ans;
void solve(int p, int cnt, int S, bitset<N> now) {
  if (p == m) return void(ans = max(ans, cnt + Max[S]));
  solve(p + 1, cnt, S, now);
  if (now[p]) solve(p + 1, cnt + 1, S | (1 << p), now & go[p]);
}
int main() {
  scanf("%d%d", &n, &k);
  if (n == 0) return printf("%.12lf\n", 0.0), 0;
  for (int i = 0; i < n; i++) {
    int x;
    for (int j = 0; j < n; j++) scanf("%d", &x), go[i][j] = x;
  }
  m = n >> 1;
  for (int i = 0; i < n; i++) now[i] = 1;
  dfs(m, 0, now);
  for (int i = 0; i < m; i++)
    for (int S = 0; S < (1 << m); S++)
      if (S >> i & 1) Max[S ^ (1 << i)] = max(Max[S ^ (1 << i)], Max[S]);
  solve(0, 0, 0, now);
  printf("%.12lf\n", 0.5 * k * k * (ans - 1) / ans);
  return 0;
}

```


### Prompt

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

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

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

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

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

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

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

Input

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

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

Output

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

Examples

Input

5
1 3 2 5 4

Output

1 3 5
2 4

Input

4
4 3 2 1

Output

4
3
2
1

Input

4
10 30 50 101

Output

10 30 50 101

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
long long dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
long long expo(long long n, long long m, long long p) {
  long long r = 1;
  n = n % p;
  while (m > 0) {
    if (m % 2) r = (r * n) % p;
    n = (n * n) % p;
    m = m / 2;
  }
  return r % p;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
vector<long long> z_function(string s) {
  long long n = (long long)s.length();
  vector<long long> z(n);
  for (long long i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
  return z;
}
vector<long long> adj[200005];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, d = 0;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  adj[d++].push_back(a[0]);
  set<long long> s;
  s.insert(a[0]);
  map<long long, long long> p;
  p[a[0]] = 0;
  for (long long i = 1; i < n; i++) {
    auto it = s.lower_bound(a[i]);
    if (it == s.begin()) {
      s.insert(a[i]);
      adj[d].push_back(a[i]);
      p[a[i]] = d++;
    } else {
      it--;
      adj[p[*it]].push_back(a[i]);
      p[a[i]] = p[*it];
      s.erase(it);
      s.insert(a[i]);
    }
  }
  for (long long i = 0; i < d; i++) {
    for (long long j = 0; j < adj[i].size(); j++) {
      cout << adj[i][j] << ' ';
    }
    cout << '\n';
  }
}

```


### Prompt

Please formulate a cpp solution to the following problem:

The legendary Farmer John is throwing a huge party, and animals from all over the world are hanging out at his house. His guests are hungry, so he instructs his cow Bessie to bring out the snacks! Moo!

There are n snacks flavors, numbered with integers 1, 2, …, n. Bessie has n snacks, one snack of each flavor. Every guest has exactly two favorite flavors. The procedure for eating snacks will go as follows:

  * First, Bessie will line up the guests in some way.
  * Then in this order, guests will approach the snacks one by one.
  * Each guest in their turn will eat all remaining snacks of their favorite flavor. In case no favorite flavors are present when a guest goes up, they become very sad.

Help Bessie to minimize the number of sad guests by lining the guests in an optimal way.

Input

The first line contains integers n and k (2 ≤ n ≤ 10^5, 1 ≤ k ≤ 10^5), the number of snacks and the number of guests.

The i-th of the following k lines contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ n, x_i ≠ y_i), favorite snack flavors of the i-th guest.

Output

Output one integer, the smallest possible number of sad guests.

Examples

Input

5 4
1 2
4 3
1 4
3 4

Output

1

Input

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

Output

0

Note

In the first example, Bessie can order the guests like this: 3, 1, 2, 4. Guest 3 goes first and eats snacks 1 and 4. Then the guest 1 goes and eats the snack 2 only, because the snack 1 has already been eaten. Similarly, the guest 2 goes up and eats the snack 3 only. All the snacks are gone, so the guest 4 will be sad.

In the second example, one optimal ordering is 2, 1, 3, 5, 4. All the guests will be satisfied.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a, b, n, m, parent[100005], ans;
int findpar(int x) {
  if (parent[x] != x) parent[x] = findpar(parent[x]);
  return parent[x];
}
bool disjoint(int x, int y) {
  x = findpar(x);
  y = findpar(y);
  if (x == y)
    return false;
  else {
    parent[y] = x;
    return true;
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) parent[i] = i;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    if (!disjoint(a, b)) ans++;
  }
  cout << ans << endl;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

During the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these beliefs, and you now wonder if the followers of each religion could coexist in peace.

The Word of Universe is a long word containing the lowercase English characters only. At each moment of time, each of the religion beliefs could be described by a word consisting of lowercase English characters.

The three religions can coexist in peace if their descriptions form disjoint subsequences of the Word of Universe. More formally, one can paint some of the characters of the Word of Universe in three colors: 1, 2, 3, so that each character is painted in at most one color, and the description of the i-th religion can be constructed from the Word of Universe by removing all characters that aren't painted in color i.

The religions however evolve. In the beginning, each religion description is empty. Every once in a while, either a character is appended to the end of the description of a single religion, or the last character is dropped from the description. After each change, determine if the religions could coexist in peace.

Input

The first line of the input contains two integers n, q (1 ≤ n ≤ 100 000, 1 ≤ q ≤ 1000) — the length of the Word of Universe and the number of religion evolutions, respectively. The following line contains the Word of Universe — a string of length n consisting of lowercase English characters.

Each of the following line describes a single evolution and is in one of the following formats:

  * + i c (i ∈ \{1, 2, 3\}, c ∈ \{a, b, ..., z\}: append the character c to the end of i-th religion description.
  * - i (i ∈ \{1, 2, 3\}) – remove the last character from the i-th religion description. You can assume that the pattern is non-empty.

You can assume that no religion will have description longer than 250 characters.

Output

Write q lines. The i-th of them should be YES if the religions could coexist in peace after the i-th evolution, or NO otherwise.

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

Examples

Input

6 8
abdabc
+ 1 a
+ 1 d
+ 2 b
+ 2 c
+ 3 a
+ 3 b
+ 1 c
- 2

Output

YES
YES
YES
YES
YES
YES
NO
YES

Input

6 8
abbaab
+ 1 a
+ 2 a
+ 3 a
+ 1 b
+ 2 b
+ 3 b
- 1
+ 2 z

Output

YES
YES
YES
YES
YES
NO
YES
NO

Note

In the first example, after the 6th evolution the religion descriptions are: ad, bc, and ab. The following figure shows how these descriptions form three disjoint subsequences of the Word of Universe:

<image>

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
const int maxn = (long long)1e5 + 5;
const int inf = 0x3f3f3f3f;
char a[4][255], s[maxn];
int len[4];
int nxt[maxn][27];
int last[maxn];
int dp[255][255][255];
inline void f(int x, int y, int z) {
  dp[x][y][z] = inf;
  if (x && dp[x - 1][y][z] != inf)
    dp[x][y][z] = min(dp[x][y][z], nxt[dp[x - 1][y][z]][a[1][x] - 'a']);
  if (y && dp[x][y - 1][z] != inf)
    dp[x][y][z] = min(dp[x][y][z], nxt[dp[x][y - 1][z]][a[2][y] - 'a']);
  if (z && dp[x][y][z - 1] != inf)
    dp[x][y][z] = min(dp[x][y][z], nxt[dp[x][y][z - 1]][a[3][z] - 'a']);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, q;
  cin >> n >> q;
  cin >> (s + 1);
  memset(last, inf, sizeof(last));
  for (int i = n; ~i; --i) {
    for (int j = 0; j < 26; ++j) nxt[i][j] = last[j];
    if (i) last[s[i] - 'a'] = i;
  }
  while (q--) {
    string opt;
    cin >> opt;
    if (opt == "+") {
      int t;
      cin >> t >> opt;
      a[t][++len[t]] = opt[0];
      if (t == 1)
        for (int i = 0; i <= len[2]; ++i)
          for (int j = 0; j <= len[3]; ++j) f(len[1], i, j);
      if (t == 2)
        for (int i = 0; i <= len[1]; ++i)
          for (int j = 0; j <= len[3]; ++j) f(i, len[2], j);
      if (t == 3)
        for (int i = 0; i <= len[1]; ++i)
          for (int j = 0; j <= len[2]; ++j) f(i, j, len[3]);
    } else {
      int t;
      cin >> t;
      --len[t];
    }
    cout << (dp[len[1]][len[2]][len[3]] <= n ? "YES" : "NO") << '\n';
  }
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

E869120 is initially standing at the origin (0, 0) in a two-dimensional plane.

He has N engines, which can be used as follows:

* When E869120 uses the i-th engine, his X- and Y-coordinate change by x_i and y_i, respectively. In other words, if E869120 uses the i-th engine from coordinates (X, Y), he will move to the coordinates (X + x_i, Y + y_i).
* E869120 can use these engines in any order, but each engine can be used at most once. He may also choose not to use some of the engines.

He wants to go as far as possible from the origin. Let (X, Y) be his final coordinates. Find the maximum possible value of \sqrt{X^2 + Y^2}, the distance from the origin.

Constraints

* 1 \leq N \leq 100
* -1 \ 000 \ 000 \leq x_i \leq 1 \ 000 \ 000
* -1 \ 000 \ 000 \leq y_i \leq 1 \ 000 \ 000
* 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 maximum possible final distance from the origin, as a real value. Your output is considered correct when the relative or absolute error from the true answer is at most 10^{-10}.

Examples

Input

3
0 10
5 -5
-5 -5

Output

10.000000000000000000000000000000000000000000000000

Input

5
1 1
1 0
0 1
-1 0
0 -1

Output

2.828427124746190097603377448419396157139343750753

Input

5
1 1
2 2
3 3
4 4
5 5

Output

21.213203435596425732025330863145471178545078130654

Input

3
0 0
0 1
1 0

Output

1.414213562373095048801688724209698078569671875376

Input

1
90447 91000

Output

128303.000000000000000000000000000000000000000000000000

Input

2
96000 -72000
-72000 54000

Output

120000.000000000000000000000000000000000000000000000000

Input

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

Output

148.660687473185055226120082139313966514489855137208

### Response

```cpp
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long double ld;
ld x[110],y[110],ans = 0;
vector<pair<ld,pair<ld,ld>>> p;
ld pi = 3.1415926535;
int main(){
	cout.precision(30);
	int i,j,k,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i] >> y[i];
			p.push_back({atan2(x[i],y[i]),{x[i],y[i]}});
	}
	sort(p.begin(),p.end());
	for(i=0;i<n;i++){
		for(j=i;j<i + n;j++){
			ld xx = 0,yy = 0;
			for(k=i;k<=j;k++){
				xx += p[k%n].second.first;
				yy += p[k%n].second.second;
			}
			ans = max(ans,xx*xx + yy*yy);
		}
	}
	cout << sqrt(ans) << endl;
}
```


### Prompt

Please formulate a CPP solution to the following problem:

Fox Ciel is playing a card game with her friend Jiro.

Jiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known that position of all Ciel's cards is Attack.

Now is Ciel's battle phase, Ciel can do the following operation many times:

  1. Choose one of her cards X. This card mustn't be chosen before.
  2. If Jiro has no alive cards at that moment, he gets the damage equal to (X's strength). Otherwise, Ciel needs to choose one Jiro's alive card Y, then:
    * If Y's position is Attack, then (X's strength)  ≥  (Y's strength) must hold. After this attack, card Y dies, and Jiro gets the damage equal to (X's strength) - (Y's strength).
    * If Y's position is Defense, then (X's strength)  > (Y's strength) must hold. After this attack, card Y dies, but Jiro gets no damage.

Ciel can end her battle phase at any moment (so, she can use not all her cards). Help the Fox to calculate the maximal sum of damage Jiro can get.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of cards Jiro and Ciel have.

Each of the next n lines contains a string position and an integer strength (0 ≤ strength ≤ 8000) — the position and strength of Jiro's current card. Position is the string "ATK" for attack, and the string "DEF" for defense.

Each of the next m lines contains an integer strength (0 ≤ strength ≤ 8000) — the strength of Ciel's current card.

Output

Output an integer: the maximal damage Jiro can get.

Examples

Input

2 3
ATK 2000
DEF 1700
2500
2500
2500

Output

3000

Input

3 4
ATK 10
ATK 100
ATK 1000
1
11
101
1001

Output

992

Input

2 4
DEF 0
ATK 0
0
0
1
1

Output

1

Note

In the first test case, Ciel has 3 cards with same strength. The best strategy is as follows. First she uses one of these 3 cards to attack "ATK 2000" card first, this attack destroys that card and Jiro gets 2500 - 2000 = 500 damage. Then she uses the second card to destroy the "DEF 1700" card. Jiro doesn't get damage that time. Now Jiro has no cards so she can use the third card to attack and Jiro gets 2500 damage. So the answer is 500 + 2500 = 3000.

In the second test case, she should use the "1001" card to attack the "ATK 100" card, then use the "101" card to attack the "ATK 10" card. Now Ciel still has cards but she can choose to end her battle phase. The total damage equals (1001 - 100) + (101 - 10) = 992.

In the third test case note that she can destroy the "ATK 0" card by a card with strength equal to 0, but she can't destroy a "DEF 0" card with that card.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int best_attack(vector<int> attacker, vector<int> attacked) {
  int ans = 0;
  int attacker_n = attacker.size();
  int card_n = attacked.size();
  sort(attacker.begin(), attacker.end());
  sort(attacked.begin(), attacked.end());
  for (int n = 1; n <= card_n; ++n) {
    int lost = 0;
    for (int i = 1; i <= n; ++i) {
      if (attacker_n - i >= 0 && attacker[attacker_n - i] >= attacked[n - i]) {
        lost += attacker[attacker_n - i] - attacked[n - i];
      }
    }
    if (lost > ans) {
      ans = lost;
    }
  }
  return ans;
}
int best_over_attack(vector<int> attacker, vector<int> attacked) {
  int ans = 0;
  int attacker_n = attacker.size();
  int card_n = attacked.size();
  sort(attacker.begin(), attacker.end());
  sort(attacked.begin(), attacked.end());
  for (int i = 1; i <= card_n; ++i) {
    if (attacker[attacker_n - i] >= attacked[card_n - i]) {
      ans += attacker[attacker_n - i] - attacked[card_n - i];
    } else {
      return -1;
    }
  }
  for (int i = 0; i < attacker_n - card_n; ++i) {
    ans += attacker[i];
  }
  return ans;
}
int main() {
  int an, bn;
  scanf("%d%d", &an, &bn);
  vector<int> attacked_atk;
  vector<int> attacked_def;
  vector<int> attacker(bn);
  for (int i = 0; i < an; ++i) {
    char type[4];
    int str;
    scanf("%s%d", type, &str);
    if (type[0] == 'A') {
      attacked_atk.push_back(str);
    } else {
      attacked_def.push_back(str);
    }
  }
  for (int i = 0; i < bn; ++i) {
    scanf("%d", &attacker[i]);
  }
  int ans = best_attack(attacker, attacked_atk);
  if (bn > an) {
    sort(attacker.begin(), attacker.end());
    bool destroyable = true;
    for (auto def : attacked_def) {
      auto finded = lower_bound(attacker.begin(), attacker.end(), def + 1);
      if (finded != attacker.end()) {
        attacker.erase(finded);
      } else {
        destroyable = false;
        break;
      }
    }
    if (destroyable) {
      int ans2 = best_over_attack(attacker, attacked_atk);
      if (ans2 >= 0 && ans2 > ans) {
        ans = ans2;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

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

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

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

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

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

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

Input

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

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

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

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

Output

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

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

Example

Input

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

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
const int maxn = 1e5 + 10;
char dir[4] = {'R', 'L', 'D', 'U'};
vector<vector<int> > a, ind, nxt;
pair<int, int> rh[maxn];
vector<int> vect[maxn], pos_undo;
int nxt2[maxn], pos[maxn], n, m, mt[maxn], cnt, r;
bool outside(int x, int y) {
  if (x > n || x < 1 || y > m || y < 1) return true;
  return false;
}
void add_edge(int x, int y) {
  vect[x].push_back(y);
  vect[y].push_back(x);
}
bool srt(int x, int y) { return nxt2[x] < nxt2[y]; }
int kuhn(int x, int tip) {
  if (pos[x]) return 0;
  pos[x] = 1;
  pos_undo.push_back(x);
  for (int i = 0; i < vect[x].size(); i++) {
    int id = vect[x][i];
    if (tip == 1 && nxt2[id] == 1) break;
    if (mt[id] == -1 || kuhn(mt[id], tip)) {
      mt[id] = x;
      mt[x] = id;
      return 1;
    }
  }
  return 0;
}
void random_matching() {
  for (int i = 1; i <= cnt; i++) {
    if (mt[i] != -1) continue;
    if (nxt2[i] != 0) continue;
    for (int j = 0; j < vect[i].size(); j++) {
      int id = vect[i][j];
      if (mt[id] != -1) continue;
      if (nxt2[id] != 0) continue;
      mt[i] = id;
      mt[id] = i;
      r -= 2;
      break;
    }
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &n, &m);
    a.clear();
    nxt.clear();
    ind.clear();
    a.resize(n + 2, vector<int>(m + 2));
    nxt.resize(n + 2, vector<int>(m + 2));
    ind.resize(n + 2, vector<int>(m + 2));
    cnt = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        scanf("%d", &a[i][j]);
        nxt[i][j] = -1;
        nxt2[cnt] = 0;
        ind[i][j] = ++cnt;
        rh[cnt] = {i, j};
        mt[cnt] = -1;
        vect[cnt].clear();
      }
    int fucked = 0;
    r = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        int e = 0;
        for (int k = 0; k < 4; k++) {
          int idx = i + dx[k];
          int idy = j + dy[k];
          if (outside(idx, idy)) continue;
          if (a[idx][idy] < a[i][j]) {
            nxt[i][j] = k;
            nxt2[ind[i][j]] = 1;
          } else if (a[idx][idy] == a[i][j]) {
            e = 1;
            if ((i + j) % 2) add_edge(ind[i][j], ind[idx][idy]);
          }
        }
        if (e == 0 && nxt[i][j] == -1) fucked = 1;
        if (nxt[i][j] == -1) r++;
      }
    if (fucked) {
      printf("NO\n");
      continue;
    }
    for (int i = 1; i <= cnt; i++) sort(vect[i].begin(), vect[i].end(), srt);
    random_matching();
    for (int i = 1; i <= cnt; i++) {
      if (nxt[rh[i].first][rh[i].second] != -1 || mt[i] != -1) continue;
      if (kuhn(i, 1)) r -= 2;
      for (int j = 0; j < pos_undo.size(); j++) pos[pos_undo[j]] = 0;
      pos_undo.clear();
    }
    for (int i = 1; i <= cnt; i++) {
      if (nxt[rh[i].first][rh[i].second] != -1 || mt[i] != -1) continue;
      if (kuhn(i, 0)) r -= 1;
      for (int j = 0; j < pos_undo.size(); j++) pos[pos_undo[j]] = 0;
      pos_undo.clear();
    }
    if (r > 0) {
      printf("NO\n");
      continue;
    }
    printf("YES\n");
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (mt[ind[i][j]] != -1) {
          if ((i + j) % 2)
            printf("%d ", a[i][j] / 2 + (a[i][j] % 2));
          else
            printf("%d ", a[i][j] / 2);
        } else {
          printf("%d ", a[i][j] - a[i + dx[nxt[i][j]]][j + dy[nxt[i][j]]]);
        }
      }
      printf("\n");
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (mt[ind[i][j]] != -1) {
          for (int k = 0; k < 4; k++) {
            int idx = i + dx[k];
            int idy = j + dy[k];
            if (ind[idx][idy] == mt[ind[i][j]]) {
              printf("%c ", dir[k]);
              break;
            }
          }
        } else {
          printf("%c ", dir[nxt[i][j]]);
        }
      }
      printf("\n");
    }
  }
  return 0;
}

```


### Prompt

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

The Resistance is trying to take control over as many planets of a particular solar system as possible. Princess Heidi is in charge of the fleet, and she must send ships to some planets in order to maximize the number of controlled planets.

The Galaxy contains N planets, connected by bidirectional hyperspace tunnels in such a way that there is a unique path between every pair of the planets.

A planet is controlled by the Resistance if there is a Resistance ship in its orbit, or if the planet lies on the shortest path between some two planets that have Resistance ships in their orbits.

Heidi has not yet made up her mind as to how many ships to use. Therefore, she is asking you to compute, for every K = 1, 2, 3, ..., N, the maximum number of planets that can be controlled with a fleet consisting of K ships.

Input

The first line of the input contains an integer N (1 ≤ N ≤ 105) – the number of planets in the galaxy.

The next N - 1 lines describe the hyperspace tunnels between the planets. Each of the N - 1 lines contains two space-separated integers u and v (1 ≤ u, v ≤ N) indicating that there is a bidirectional hyperspace tunnel between the planets u and v. It is guaranteed that every two planets are connected by a path of tunnels, and that each tunnel connects a different pair of planets.

Output

On a single line, print N space-separated integers. The K-th number should correspond to the maximum number of planets that can be controlled by the Resistance using a fleet of K ships.

Examples

Input

3
1 2
2 3

Output

1 3 3

Input

4
1 2
3 2
4 2

Output

1 3 4 4

Note

Consider the first example. If K = 1, then Heidi can only send one ship to some planet and control it. However, for K ≥ 2, sending ships to planets 1 and 3 will allow the Resistance to control all planets.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  char ch = getchar();
  bool f = false;
  while (!isdigit(ch)) {
    if (ch == '-') {
      f = true;
    }
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  x = f ? -x : x;
  return;
}
template <typename T>
inline void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 ^ 48);
  return;
}
const int N = 1e5 + 5;
int n, ans;
int head[N], nex[N << 1], to[N << 1], idx;
int root, dep[N], len[N], son[N];
int edge[N], cnt;
void add(int u, int v) {
  nex[++idx] = head[u];
  to[idx] = v;
  head[u] = idx;
  return;
}
void dfs1(int x, int fa) {
  dep[x] = dep[fa] + 1;
  if (dep[x] > dep[root]) root = x;
  for (int i = head[x]; i; i = nex[i]) {
    int y = to[i];
    if (y == fa) continue;
    dfs1(y, x);
  }
  return;
}
void dfs2(int x, int fa) {
  for (int i = head[x]; i; i = nex[i]) {
    int y = to[i];
    if (y == fa) continue;
    dfs2(y, x);
    if (len[y] > len[son[x]]) son[x] = y;
  }
  len[x] = len[son[x]] + 1;
  for (int i = head[x]; i; i = nex[i]) {
    int y = to[i];
    if (y == fa || y == son[x]) continue;
    edge[++cnt] = len[y];
  }
  return;
}
int main() {
  read(n);
  for (int i = 1; i < n; i++) {
    int u, v;
    read(u), read(v);
    add(u, v);
    add(v, u);
  }
  dfs1(1, 0);
  dfs2(root, 0);
  sort(edge + 1, edge + cnt + 1);
  write(1), putchar(' ');
  ans = len[root];
  for (int i = cnt; i >= 1; i--) {
    write(ans), putchar(' ');
    ans += edge[i];
  }
  for (int i = 1; i <= n - cnt - 1; i++) write(ans), putchar(' ');
  return 0;
}

```


### Prompt

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

International Abbreviation Olympiad takes place annually starting from 1989. Each year the competition receives an abbreviation of form IAO'y, where y stands for some number of consequent last digits of the current year. Organizers always pick an abbreviation with non-empty string y that has never been used before. Among all such valid abbreviations they choose the shortest one and announce it to be the abbreviation of this year's competition.

For example, the first three Olympiads (years 1989, 1990 and 1991, respectively) received the abbreviations IAO'9, IAO'0 and IAO'1, while the competition in 2015 received an abbreviation IAO'15, as IAO'5 has been already used in 1995.

You are given a list of abbreviations. For each of them determine the year it stands for.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the number of abbreviations to process.

Then n lines follow, each containing a single abbreviation. It's guaranteed that each abbreviation contains at most nine digits.

Output

For each abbreviation given in the input, find the year of the corresponding Olympiad.

Examples

Input

5
IAO'15
IAO'2015
IAO'1
IAO'9
IAO'0

Output

2015
12015
1991
1989
1990

Input

4
IAO'9
IAO'99
IAO'999
IAO'9999

Output

1989
1999
2999
9999

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string s;
string cur;
string go;
void solve() {
  getline(cin, s);
  s = s.substr(4, 123123);
  cur = "1988";
  for (int i = 1; i <= (int)s.size(); i++) {
    go = cur;
    for (int j = 0; j < i; j++) {
      if ((int)go.size() - 1 - j < 0) {
        go = s[(int)s.size() - 1 - j] + go;
      } else {
        go[(int)go.size() - 1 - j] = s[(int)s.size() - 1 - j];
      }
    }
    if (go[0] == '0') {
      go = "1" + go;
    }
    if ((int)go.size() > (int)cur.size()) {
      cur = go;
      continue;
    }
    bool bigger = false;
    for (int j = 0; j < (int)go.size(); j++) {
      if (go[j] > cur[j]) {
        bigger = true;
        break;
      }
      if (go[j] < cur[j]) {
        break;
      }
    }
    if (bigger) {
      cur = go;
      continue;
    }
    int f = (int)go.size() - i;
    int can = -1;
    for (int j = f - 1; j >= 0; j--) {
      if (cur[j] < '9') {
        can = j;
        break;
      }
    }
    if (can == -1) {
      for (int j = 0; j < f; j++) {
        go[j] = '0';
      }
      go = "1" + go;
    } else {
      go[can] = cur[can] + 1;
      for (int j = can + 1; j < f; j++) {
        go[j] = '0';
      }
    }
    cur = go;
  }
  cout << cur << endl;
}
int main() {
  int tn;
  scanf("%d\n", &tn);
  while (tn--) {
    solve();
  }
  return 0;
}

```


### Prompt

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

Dima, Inna and Seryozha have gathered in a room. That's right, someone's got to go. To cheer Seryozha up and inspire him to have a walk, Inna decided to cook something.

Dima and Seryozha have n fruits in the fridge. Each fruit has two parameters: the taste and the number of calories. Inna decided to make a fruit salad, so she wants to take some fruits from the fridge for it. Inna follows a certain principle as she chooses the fruits: the total taste to the total calories ratio of the chosen fruits must equal k. In other words, <image> , where aj is the taste of the j-th chosen fruit and bj is its calories.

Inna hasn't chosen the fruits yet, she is thinking: what is the maximum taste of the chosen fruits if she strictly follows her principle? Help Inna solve this culinary problem — now the happiness of a young couple is in your hands!

Inna loves Dima very much so she wants to make the salad from at least one fruit.

Input

The first line of the input contains two integers n, k (1 ≤ n ≤ 100, 1 ≤ k ≤ 10). The second line of the input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the fruits' tastes. The third line of the input contains n integers b1, b2, ..., bn (1 ≤ bi ≤ 100) — the fruits' calories. Fruit number i has taste ai and calories bi.

Output

If there is no way Inna can choose the fruits for the salad, print in the single line number -1. Otherwise, print a single integer — the maximum possible sum of the taste values of the chosen fruits.

Examples

Input

3 2
10 8 1
2 7 1

Output

18

Input

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

Output

-1

Note

In the first test sample we can get the total taste of the fruits equal to 18 if we choose fruit number 1 and fruit number 2, then the total calories will equal 9. The condition <image> fulfills, that's exactly what Inna wants.

In the second test sample we cannot choose the fruits so as to follow Inna's principle.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int base = 1000000007;
int n, k, res = 0;
pair<int, int> a[103];
map<int, int> b, c;
map<int, int>::iterator it;
int main() {
  int i, j;
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> a[i].first;
  for (i = 1; i <= n; i++) {
    cin >> a[i].second;
    a[i].second = a[i].first - k * a[i].second;
  }
  b[0] = 0;
  for (i = 1; i <= n; i++)
    for (it = (c = b).begin(); it != c.end(); it++)
      b[it->first + a[i].second] =
          max(b[it->first + a[i].second], a[i].first + it->second);
  if (b[0])
    cout << b[0];
  else
    cout << -1;
  return 0;
}

```


### Prompt

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

On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others.

Seating in the class looks like a rectangle, where n rows with m pupils in each.

The teacher asks pupils in the following order: at first, she asks all pupils from the first row in the order of their seating, then she continues to ask pupils from the next row. If the teacher asked the last row, then the direction of the poll changes, it means that she asks the previous row. The order of asking the rows looks as follows: the 1-st row, the 2-nd row, ..., the n - 1-st row, the n-th row, the n - 1-st row, ..., the 2-nd row, the 1-st row, the 2-nd row, ...

The order of asking of pupils on the same row is always the same: the 1-st pupil, the 2-nd pupil, ..., the m-th pupil.

During the lesson the teacher managed to ask exactly k questions from pupils in order described above. Sergei seats on the x-th row, on the y-th place in the row. Sergei decided to prove to the teacher that pupils are asked irregularly, help him count three values:

  1. the maximum number of questions a particular pupil is asked,
  2. the minimum number of questions a particular pupil is asked,
  3. how many times the teacher asked Sergei.

If there is only one row in the class, then the teacher always asks children from this row.

Input

The first and the only line contains five integers n, m, k, x and y (1 ≤ n, m ≤ 100, 1 ≤ k ≤ 1018, 1 ≤ x ≤ n, 1 ≤ y ≤ m).

Output

Print three integers:

  1. the maximum number of questions a particular pupil is asked,
  2. the minimum number of questions a particular pupil is asked,
  3. how many times the teacher asked Sergei.

Examples

Input

1 3 8 1 1

Output

3 2 3

Input

4 2 9 4 2

Output

2 1 1

Input

5 5 25 4 3

Output

1 1 1

Input

100 100 1000000000000000000 100 100

Output

101010101010101 50505050505051 50505050505051

Note

The order of asking pupils in the first test:

  1. the pupil from the first row who seats at the first table, it means it is Sergei;
  2. the pupil from the first row who seats at the second table;
  3. the pupil from the first row who seats at the third table;
  4. the pupil from the first row who seats at the first table, it means it is Sergei;
  5. the pupil from the first row who seats at the second table;
  6. the pupil from the first row who seats at the third table;
  7. the pupil from the first row who seats at the first table, it means it is Sergei;
  8. the pupil from the first row who seats at the second table;

The order of asking pupils in the second test:

  1. the pupil from the first row who seats at the first table;
  2. the pupil from the first row who seats at the second table;
  3. the pupil from the second row who seats at the first table;
  4. the pupil from the second row who seats at the second table;
  5. the pupil from the third row who seats at the first table;
  6. the pupil from the third row who seats at the second table;
  7. the pupil from the fourth row who seats at the first table;
  8. the pupil from the fourth row who seats at the second table, it means it is Sergei;
  9. the pupil from the third row who seats at the first table;

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long vis[220][220], k;
const long long INF = 2e18;
int n, m, nn, mod, rest, x, y;
long long mx, mn, q;
int main() {
  cin >> n >> m >> k >> x >> y;
  if (n == 1) {
    q = k / m;
    rest = k % m;
    for (int i = 1; i <= m; i++) vis[1][i] = q;
    for (int i = 1; i <= rest; i++) vis[1][i]++;
    mx = 0, mn = INF;
    for (int i = 1; i <= m; i++) {
      mx = max(vis[1][i], mx);
      mn = min(vis[1][i], mn);
    }
    cout << mx << " " << mn << " " << vis[x][y] << endl;
  } else {
    nn = n * 2 - 2;
    mod = nn * m;
    q = k / (1ll * mod);
    rest = k % mod;
    for (int i = 1; i <= mod; i++) {
      int jj = ((i - 1) % m) + 1;
      int ii = (i - 1) / m + 1;
      if (ii > n) ii = 2 * n - ii;
      assert(ii <= n);
      assert(jj <= m);
      vis[ii][jj] += q;
    }
    for (int i = 1; i <= rest; i++) {
      int jj = ((i - 1) % m) + 1;
      int ii = (i - 1) / m + 1;
      if (ii > n) ii = 2 * n - ii;
      assert(ii <= n);
      assert(jj <= m);
      vis[ii][jj] += 1;
    }
    mx = 0, mn = INF;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        mx = max(vis[i][j], mx);
        mn = min(vis[i][j], mn);
      }
    }
    cout << mx << " " << mn << " " << vis[x][y] << endl;
  }
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.

Over the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbered from 1 to m. His greenhouse is very narrow and can be viewed as an infinite line, with each plant occupying a single point on that line.

Emuskald has discovered that each species thrives at a different temperature, so he wants to arrange m - 1 borders that would divide the greenhouse into m sections numbered from 1 to m from left to right with each section housing a single species. He is free to place the borders, but in the end all of the i-th species plants must reside in i-th section from the left.

Of course, it is not always possible to place the borders in such way, so Emuskald needs to replant some of his plants. He can remove each plant from its position and place it anywhere in the greenhouse (at any real coordinate) with no plant already in it. Since replanting is a lot of stress for the plants, help Emuskald find the minimum number of plants he has to replant to be able to place the borders.

Input

The first line of input contains two space-separated integers n and m (1 ≤ n, m ≤ 5000, n ≥ m), the number of plants and the number of different species. Each of the following n lines contain two space-separated numbers: one integer number si (1 ≤ si ≤ m), and one real number xi (0 ≤ xi ≤ 109), the species and position of the i-th plant. Each xi will contain no more than 6 digits after the decimal point.

It is guaranteed that all xi are different; there is at least one plant of each species; the plants are given in order "from left to the right", that is in the ascending order of their xi coordinates (xi < xi + 1, 1 ≤ i < n).

Output

Output a single integer — the minimum number of plants to be replanted.

Examples

Input

3 2
2 1
1 2.0
1 3.100

Output

1

Input

3 3
1 5.0
2 5.5
3 6.0

Output

0

Input

6 3
1 14.284235
2 17.921382
1 20.328172
3 20.842331
1 25.790145
1 27.204125

Output

2

Note

In the first test case, Emuskald can replant the first plant to the right of the last plant, so the answer is 1.

In the second test case, the species are already in the correct order, so no replanting is needed.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10;
int dp[maxn][maxn], a[maxn], ans;
int main() {
  ios_base::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    double fake;
    cin >> a[i] >> fake;
  }
  for (int i = 1; i <= n; i++) {
    for (int type = 1; type <= k; type++) dp[i][type] = dp[i - 1][type];
    for (int type = 1; type <= a[i]; type++)
      dp[i][a[i]] = max(dp[i][a[i]], dp[i - 1][type] + 1);
    ans = max(ans, dp[i][a[i]]);
  }
  cout << n - ans << endl;
  return 0;
}

```


### Prompt

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

You have a description of a lever as string s. We'll represent the string length as record |s|, then the lever looks as a horizontal bar with weights of length |s| - 1 with exactly one pivot. We will assume that the bar is a segment on the Ox axis between points 0 and |s| - 1.

The decoding of the lever description is given below.

  * If the i-th character of the string equals "^", that means that at coordinate i there is the pivot under the bar.
  * If the i-th character of the string equals "=", that means that at coordinate i there is nothing lying on the bar.
  * If the i-th character of the string equals digit c (1-9), that means that at coordinate i there is a weight of mass c on the bar.

Your task is, given the lever description, print if it will be in balance or not. Assume that the bar doesn't weight anything. Assume that the bar initially is in balance then all weights are simultaneously put on it. After that the bar either tilts to the left, or tilts to the right, or is in balance.

Input

The first line contains the lever description as a non-empty string s (3 ≤ |s| ≤ 106), consisting of digits (1-9) and characters "^" and "=". It is guaranteed that the line contains exactly one character "^". It is guaranteed that the pivot of the lever isn't located in any end of the lever bar.

To solve the problem you may need 64-bit integer numbers. Please, do not forget to use them in your programs.

Output

Print "left" if the given lever tilts to the left, "right" if it tilts to the right and "balance", if it is in balance.

Examples

Input

=^==

Output

balance

Input

9===^==1

Output

left

Input

2==^7==

Output

right

Input

41^52==

Output

balance

Note

As you solve the problem, you may find the following link useful to better understand how a lever functions: http://en.wikipedia.org/wiki/Lever.

The pictures to the examples:

<image> <image> <image> <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin >> s;
  int bas = 0;
  for (int i = 0; i < s.size(); ++i)
    if (s[i] == '^') bas = i;
  long long cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < bas; ++i)
    if (s[i] != '=') cnt1 = cnt1 + (bas - i) * (s[i] - '0');
  for (int i = bas; i < s.size(); ++i)
    if (s[i] != '=' && s[i] != '^') cnt2 = cnt2 + (i - bas) * (s[i] - '0');
  if (cnt1 > cnt2) {
    cout << "left" << endl;
    return 0;
  }
  if (cnt2 > cnt1) {
    cout << "right" << endl;
    return 0;
  }
  cout << "balance" << endl;
  return 0;
}

```


### Prompt

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

Tax Rate Changed

VAT (value-added tax) is a tax imposed at a certain rate proportional to the sale price.

Our store uses the following rules to calculate the after-tax prices.

* When the VAT rate is x%, for an item with the before-tax price of p yen, its after-tax price of the item is p (100+x) / 100 yen, fractions rounded off.
* The total after-tax price of multiple items paid at once is the sum of after-tax prices of the items.

The VAT rate is changed quite often. Our accountant has become aware that "different pairs of items that had the same total after-tax price may have different total after-tax prices after VAT rate changes." For example, when the VAT rate rises from 5% to 8%, a pair of items that had the total after-tax prices of 105 yen before can now have after-tax prices either of 107, 108, or 109 yen, as shown in the table below.

Before-tax prices of two items| After-tax price with 5% VAT| After-tax price with 8% VAT
---|---|---
20, 80| 21 + 84 = 105| 21 + 86 = 107
2, 99| 2 + 103 = 105| 2 + 106 = 108
13, 88| 13 + 92 = 105| 14 + 95 = 109

Our accountant is examining effects of VAT-rate changes on after-tax prices. You are asked to write a program that calculates the possible maximum total after-tax price of two items with the new VAT rate, knowing their total after-tax price before the VAT rate change.

Input

The input consists of multiple datasets. Each dataset is in one line, which consists of three integers x, y, and s separated by a space. x is the VAT rate in percent before the VAT-rate change, y is the VAT rate in percent after the VAT-rate change, and s is the sum of after-tax prices of two items before the VAT-rate change. For these integers, 0 < x < 100, 0 < y < 100, 10 < s < 1000, and x ≠ y hold. For before-tax prices of items, all possibilities of 1 yen through s-1 yen should be considered.

The end of the input is specified by three zeros separated by a space.

Output

For each dataset, output in a line the possible maximum total after-tax price when the VAT rate is changed to y%.

Sample Input

5 8 105
8 5 105
1 2 24
99 98 24
12 13 26
1 22 23
1 13 201
13 16 112
2 24 50
1 82 61
1 84 125
1 99 999
99 1 999
98 99 999
1 99 11
99 1 12
0 0 0

Output for the Sample Input

109
103
24
24
26
27
225
116
62
111
230
1972
508
1004
20
7

Hints

In the following table, an instance of a before-tax price pair that has the maximum after-tax price after the VAT-rate change is given for each dataset of the sample input.

Dataset| Before-tax prices| After-tax price with y% VAT
---|---|---
5 8 105 |  13, 88|  14 + 95 = 109
8 5 105 |  12, 87|  12 + 91 = 103
1 2 24 |  1, 23|  1 + 23 = 24
99 98 24 |  1, 12|  1 + 23 = 24
12 13 26 |  1, 23|  1 + 25 = 26
1 22 23 |  1, 22|  1 + 26 = 27
1 13 201 |  1,199|  1 +224 = 225
13 16 112|  25, 75|  29 + 87 = 116
2 24 50 |  25, 25|  31 + 31 = 62
1 82 61 |  11, 50|  20 + 91 = 111
1 84 125 |  50, 75|  92 +138 = 230
1 99 999 |  92,899| 183+1789 =1972
99 1 999 |  1,502|  1 +507 = 508
98 99 999|  5,500|  9 +995 =1004
1 99 11 |  1, 10|  1 + 19 = 20
99 1 12 |  1, 6|  1 + 6 = 7

Example

Input

5 8 105
8 5 105
1 2 24
99 98 24
12 13 26
1 22 23
1 13 201
13 16 112
2 24 50
1 82 61
1 84 125
1 99 999
99 1 999
98 99 999
1 99 11
99 1 12
0 0 0

Output

109
103
24
24
26
27
225
116
62
111
230
1972
508
1004
20
7

### Response

```cpp
#include<iostream>
using namespace std;
int main(){
  while(1){
    int x,y,s,ans=0,a,b,m;
    cin>>x>>y>>s;
    if(x==0)break;
    for(a=1;a<s;a++)
      for(b=a;a+b<=s;b++){
	m=a*(100+y)/100+b*(100+y)/100;
	if(a*(100+x)/100+b*(100+x)/100==s&&ans<m)ans=m;
      }
    cout<<ans<<endl;
  }
  return 0;
}
```


### Prompt

Create a solution in cpp for the following problem:

A tree is a connected graph that doesn't contain any cycles.

The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.

You are given a tree with n vertices and a positive number k. Find the number of distinct pairs of the vertices which have a distance of exactly k between them. Note that pairs (v, u) and (u, v) are considered to be the same pair.

Input

The first line contains two integers n and k (1 ≤ n ≤ 50000, 1 ≤ k ≤ 500) — the number of vertices and the required distance between the vertices.

Next n - 1 lines describe the edges as "ai bi" (without the quotes) (1 ≤ ai, bi ≤ n, ai ≠ bi), where ai and bi are the vertices connected by the i-th edge. All given edges are different.

Output

Print a single integer — the number of distinct pairs of the tree's vertices which have a distance of exactly k between them.

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

Examples

Input

5 2
1 2
2 3
3 4
2 5

Output

4

Input

5 3
1 2
2 3
3 4
4 5

Output

2

Note

In the first sample the pairs of vertexes at distance 2 from each other are (1, 3), (1, 5), (3, 5) and (2, 4).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int const MAXN = 500 * 100 + 10;
vector<int> adj[MAXN];
int p[MAXN], dp[MAXN][500 + 10], h[MAXN], n, k;
long long ans;
bool vis[MAXN];
void dfs(int i) {
  dp[i][0] = 1;
  vis[i] = true;
  for (int j = 0; j < adj[i].size(); j++) {
    if (!vis[adj[i][j]]) {
      h[adj[i][j]] = h[i] + 1;
      p[adj[i][j]] = i;
      dfs(adj[i][j]);
      for (int l = 1; l < k; l++) {
        dp[i][l] += dp[adj[i][j]][l - 1];
      }
    }
  }
  return;
}
int main() {
  cin >> n >> k;
  int a, b;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < k; j++) {
      for (int l = 0; l < adj[i].size(); l++) {
        if (p[i] != adj[i][l]) {
          ans += 1ll * dp[adj[i][l]][j - 1] *
                 (dp[i][k - j] - dp[adj[i][l]][k - j - 1]);
        }
      }
    }
  }
  ans /= 2;
  for (int i = 1; i <= n; i++) {
    if (h[i] >= k) ans++;
  }
  cout << ans;
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

The goal of the 15 puzzle problem is to complete pieces on $4 \times 4$ cells where one of the cells is empty space.

In this problem, the space is represented by 0 and pieces are represented by integers from 1 to 15 as shown below.

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

You can move a piece toward the empty space at one step. Your goal is to make the pieces the following configuration in the shortest move (fewest steps).

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

Write a program which reads an initial state of the puzzle and prints the fewest steps to solve the puzzle.

Constraints

* The given puzzle is solvable in at most 45 steps.

Input

The $4 \times 4$ integers denoting the pieces or space are given.

Output

Print the fewest steps in a line.

Example

Input

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

Output

8

### Response

```cpp
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
#define N 4
int dy[4] = {1, 0, -1, 0};
int dx[4] = {0, 1, 0, -1};
int MDT[N*N][N*N];
struct Puzzle {
  vector<int> f;
  int space;
  int cost;
  int MD;
  int estimated;
  bool operator < (const Puzzle &s) const {
    return estimated > s.estimated;
  }
};
int getAllMD(Puzzle pz){
  int sum = 0;
  for(int i = 0; i < N * N; i++) {
    if(pz.f[i]==0) continue;
    sum += MDT[i][pz.f[i]-1];
  }
  return sum;
}
map<vector<int>, bool> checked;
priority_queue<Puzzle> que;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  // A* -> estimated = cost(これまでのコスト) + MD(今の状態と最終状態の差(ここではマンハッタン距離の総和))
  // マンハッタン距離計算
  for(int i = 0; i < N * N; i++) {
    for(int j = 0; j < N * N; j++) {
      MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
    }
  }
  Puzzle start;
  start.f.resize(N*N);
  FOR(i,0,N*N){
    cin >> start.f[i];
    if(start.f[i] == 0) {
      start.space = i;
    }
  }
  start.cost = 0;
  start.MD = getAllMD(start);
  start.estimated = start.cost + start.MD;
  que.push(start);
  checked[start.f] = true;

  while(!que.empty()){
    Puzzle now = que.top();
    que.pop();
    if(now.MD == 0) {
      cout << now.cost << endl;
      return 0;
    }
    checked[now.f] = true;
    int x = now.space % N;
    int y = now.space / N;
    FOR(i,0,4){
      int ny = y + dy[i];
      int nx = x + dx[i];
      if(ny < 0 || ny >= N || nx < 0 || nx >= N) continue;
      Puzzle next = now;
      next.space = ny * N + nx;
      next.cost++;
      next.MD -= MDT[ny * N + nx][next.f[ny * N + nx]-1]; // 空白になったので
      next.MD += MDT[y * N + x][next.f[ny * N + nx]-1];
      swap(next.f[ny * N + nx], next.f[y * N + x]);
      next.estimated = next.cost + next.MD;
      if(!checked[next.f] && next.estimated <= 45){
        que.push(next);
      }
    }
  }
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Om Nom really likes candies and doesn't like spiders as they frequently steal candies. One day Om Nom fancied a walk in a park. Unfortunately, the park has some spiders and Om Nom doesn't want to see them at all.

<image>

The park can be represented as a rectangular n × m field. The park has k spiders, each spider at time 0 is at some cell of the field. The spiders move all the time, and each spider always moves in one of the four directions (left, right, down, up). In a unit of time, a spider crawls from his cell to the side-adjacent cell in the corresponding direction. If there is no cell in the given direction, then the spider leaves the park. The spiders do not interfere with each other as they move. Specifically, one cell can have multiple spiders at the same time.

Om Nom isn't yet sure where to start his walk from but he definitely wants:

  * to start walking at time 0 at an upper row cell of the field (it is guaranteed that the cells in this row do not contain any spiders);
  * to walk by moving down the field towards the lowest row (the walk ends when Om Nom leaves the boundaries of the park).

We know that Om Nom moves by jumping. One jump takes one time unit and transports the little monster from his cell to either a side-adjacent cell on the lower row or outside the park boundaries.

Each time Om Nom lands in a cell he sees all the spiders that have come to that cell at this moment of time. Om Nom wants to choose the optimal cell to start the walk from. That's why he wonders: for each possible starting cell, how many spiders will he see during the walk if he starts from this cell? Help him and calculate the required value for each possible starting cell.

Input

The first line contains three integers n, m, k (2 ≤ n, m ≤ 2000; 0 ≤ k ≤ m(n - 1)).

Each of the next n lines contains m characters — the description of the park. The characters in the i-th line describe the i-th row of the park field. If the character in the line equals ".", that means that the corresponding cell of the field is empty; otherwise, the character in the line will equal one of the four characters: "L" (meaning that this cell has a spider at time 0, moving left), "R" (a spider moving right), "U" (a spider moving up), "D" (a spider moving down).

It is guaranteed that the first row doesn't contain any spiders. It is guaranteed that the description of the field contains no extra characters. It is guaranteed that at time 0 the field contains exactly k spiders.

Output

Print m integers: the j-th integer must show the number of spiders Om Nom will see if he starts his walk from the j-th cell of the first row. The cells in any row of the field are numbered from left to right.

Examples

Input

3 3 4
...
R.L
R.U

Output

0 2 2

Input

2 2 2
..
RL

Output

1 1

Input

2 2 2
..
LR

Output

0 0

Input

3 4 8
....
RRLL
UUUU

Output

1 3 3 1

Input

2 2 2
..
UU

Output

0 0

Note

Consider the first sample. The notes below show how the spider arrangement changes on the field over time:

    ...        ...        ..U       ...
    R.L   ->   .*U   ->   L.R   ->  ...
    R.U        .R.        ..R       ...

Character "*" represents a cell that contains two spiders at the same time.

  * If Om Nom starts from the first cell of the first row, he won't see any spiders.
  * If he starts from the second cell, he will see two spiders at time 1.
  * If he starts from the third cell, he will see two spiders: one at time 1, the other one at time 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct __s {
  __s() {
    if (1) {
      ios_base::Init i;
      cin.sync_with_stdio(0);
      cin.tie(0);
    }
  }
  ~__s() {
    if (!1)
      fprintf(stderr, "Execution time: %.3lf s.\n",
              (double)clock() / CLOCKS_PER_SEC);
    long long n;
    cin >> n;
  }
} __S;
long long n, m, k;
string s[2222];
long long a[2222];
int main(void) {
  cin >> n >> m >> k;
  for (long long i = 0; i < (long long)(n); i++) {
    cin >> s[i];
  }
  for (long long i = 0; i < (long long)(n); i++) {
    for (long long j = 0; j < (long long)(m); j++) {
      if (s[i][j] == 'L') {
        if (j >= i) a[j - i]++;
      } else if (s[i][j] == 'R') {
        if (j + i < m) a[j + i]++;
      } else if (s[i][j] == 'U') {
        if (i % 2 == 0) a[j]++;
      }
    }
  }
  for (long long i = 0; i < (long long)(m); i++) {
    cout << a[i] << " ";
  }
  cout << '\n';
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Arya has n opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means if one day at least one of Arya's opponents is absent at the school, then Arya will beat all present opponents. Otherwise, if all opponents are present, then they will beat Arya.

For each opponent Arya knows his schedule — whether or not he is going to present on each particular day. Tell him the maximum number of consecutive days that he will beat all present opponents.

Note, that if some day there are no opponents present, Arya still considers he beats all the present opponents.

Input

The first line of the input contains two integers n and d (1 ≤ n, d ≤ 100) — the number of opponents and the number of days, respectively.

The i-th of the following d lines contains a string of length n consisting of characters '0' and '1'. The j-th character of this string is '0' if the j-th opponent is going to be absent on the i-th day.

Output

Print the only integer — the maximum number of consecutive days that Arya will beat all present opponents.

Examples

Input

2 2
10
00

Output

2

Input

4 1
0100

Output

1

Input

4 5
1101
1111
0110
1011
1111

Output

2

Note

In the first and the second samples, Arya will beat all present opponents each of the d days.

In the third sample, Arya will beat his opponents on days 1, 3 and 4 and his opponents will beat him on days 2 and 5. Thus, the maximum number of consecutive winning days is 2, which happens on days 3 and 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d, k = 0, x = 0, sum = 0;
  string s;
  while ((scanf("%d%d", &n, &d)) != EOF) {
    k = 0;
    x = 0;
    sum = 0;
    while (d--) {
      cin >> s;
      sum = 0;
      int l = s.size();
      for (int j = 0; j < l; j++) {
        sum += (s[j] - '0');
      }
      if (sum == n) {
        x = max(x, k);
        k = 0;
      } else
        k++;
    }
    x = max(x, k);
    printf("%d\n", x);
  }
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Print all subsets of a set $S$, which contains $0, 1, ... n-1$ as elements. Note that we represent $0, 1, ... n-1$ as 00...0001, 00...0010, 00...0100, ..., 10...0000 in binary respectively and the integer representation of a subset is calculated by bitwise OR of existing elements.

Constraints

* $1 \leq n \leq 18$

Input

The input is given in the following format.

$n$

Output

Print subsets ordered by their decimal integers. Print a subset in a line in the following format.

$d$: $e_0$ $e_1$ ...

Print ':' after the integer value $d$, then print elements $e_i$ in the subset in ascending order. Seprate two adjacency elements by a space character.

Example

Input

4

Output

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

### Response

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, pow(2LL, N)) {
        cout << i << ":";
        REP(j, N) {
            if ((i >> j) & 1)
                cout << " " << j;
        }
        cout << endl;
    }
    return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties:

  * G has exactly n vertices, numbered from 1 to n.
  * For all pairs of vertices i and j, where i ≠ j, there is an edge connecting them if and only if characters si and sj are either equal or neighbouring in the alphabet. That is, letters in pairs "a"-"b" and "b"-"c" are neighbouring, while letters "a"-"c" are not.

Vasya painted the resulting graph near the string and then erased the string. Next day Vasya's friend Petya came to a lecture and found some graph at his desk. He had heard of Vasya's adventure and now he wants to find out whether it could be the original graph G, painted by Vasya. In order to verify this, Petya needs to know whether there exists a string s, such that if Vasya used this s he would produce the given graph G.

Input

The first line of the input contains two integers n and m <image> — the number of vertices and edges in the graph found by Petya, respectively.

Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of vertexes appear in this list no more than once.

Output

In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise.

If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the graph built using this string must coincide with G. If there are multiple possible answers, you may print any of them.

Examples

Input

2 1
1 2

Output

Yes
aa

Input

4 3
1 2
1 3
1 4

Output

No

Note

In the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions.

In the second sample the first vertex is connected to all three other vertices, but these three vertices are not connected with each other. That means that they must correspond to distinct letters that are not adjacent, but that is impossible as there are only two such letters: a and c.

### Response

```cpp
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 505;
int n, m;
int vis[maxn], flag;
int con[maxn][maxn];
vector<int> edge[maxn];
void input() {
  memset(con, 0, sizeof(con));
  memset(vis, -1, sizeof(vis));
  int i, j, k;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &j, &k);
    con[k][j] = con[j][k] = 1;
  }
}
void dfs(int x, int f) {
  if (flag == 0) return;
  int i, sz = edge[x].size();
  if (sz == 0) return;
  if (f != -1) {
    if (vis[x] == -1)
      vis[x] = f;
    else if (vis[x] != f) {
      flag = 0;
      return;
    } else {
      return;
    }
  } else {
    if (vis[x] == -1) vis[x] = 1;
  }
  for (i = 0; i < sz; i++) {
    dfs(edge[x][i], 1 - vis[x]);
  }
}
void solve() {
  int i, j, k;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (i == j) continue;
      if (con[i][j] == 0) {
        edge[i].push_back(j);
      }
    }
  }
  flag = 1;
  for (i = 1; i <= n; i++) {
    if (vis[i] != -1) continue;
    dfs(i, -1);
    if (flag == 0) {
      puts("No");
      return;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (i == j) continue;
      if (con[i][j] == 1) {
        if (vis[i] == -1 || vis[j] == -1) continue;
        if (abs(vis[i] - vis[j]) == 1) {
          puts("No");
          return;
        }
      }
    }
  }
  puts("Yes");
  for (i = 1; i <= n; i++) {
    if (vis[i] == -1) {
      cout << "b";
    } else if (vis[i] == 0) {
      cout << "a";
    } else {
      cout << "c";
    }
  }
  return;
}
int main() {
  input();
  solve();
  return 0;
}

```


### Prompt

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

You are given a string s consisting of n lowercase Latin letters. Polycarp wants to remove exactly k characters (k ≤ n) from the string s. Polycarp uses the following algorithm k times:

  * if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
  * if there is at least one letter 'b', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
  * ...
  * remove the leftmost occurrence of the letter 'z' and stop the algorithm.

This algorithm removes a single letter from the string. Polycarp performs this algorithm exactly k times, thus removing exactly k characters.

Help Polycarp find the resulting string.

Input

The first line of input contains two integers n and k (1 ≤ k ≤ n ≤ 4 ⋅ 10^5) — the length of the string and the number of letters Polycarp will remove.

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

Output

Print the string that will be obtained from s after Polycarp removes exactly k letters using the above algorithm k times.

If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).

Examples

Input

15 3
cccaabababaccbc

Output

cccbbabaccbc

Input

15 9
cccaabababaccbc

Output

cccccc

Input

1 1
u

Output

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int len, k;
void sw(string &str, int k) {
  string ss = str.substr(0, k + 1);
  reverse(ss.begin(), ss.end());
  for (int i = 0; i <= k; i++) str[i] = ss[i];
}
int main() {
  string str;
  scanf("%d", &len);
  scanf("%d", &k);
  cin >> str;
  map<char, int> make_pair;
  for (int i = 0; i < len; ++i) {
    make_pair[str[i]] += 1;
  }
  char lim;
  bool flag = true;
  int del = 0;
  long long int sum = 0;
  char i;
  for (i = 'a'; i <= 'z'; ++i) {
    sum += make_pair[i];
    if (sum == k) {
      lim = i;
      del = 0;
      break;
    }
    if (sum > k) {
      lim = i - 1;
      sum -= make_pair[i];
      del = k - sum;
      break;
    }
  }
  if (i > 'z' && sum <= k) {
    cout << "\n";
    return 0;
  }
  for (int i = 0; i < len; ++i) {
    if (str[i] >= 'a' && str[i] <= lim) str[i] = '?';
  }
  int p = 0;
  for (int i = 0; p < del && i < len; ++i) {
    if (str[i] == lim + 1) {
      str[i] = '?';
      ++p;
    }
  }
  for (int i = 0; i < len; ++i) {
    if (str[i] != '?') cout << str[i];
  }
  cout << "\n";
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

There are n distinct points on a coordinate line, the coordinate of i-th point equals to x_i. Choose a subset of the given set of points such that the distance between each pair of points in a subset is an integral power of two. It is necessary to consider each pair of points, not only adjacent. Note that any subset containing one element satisfies the condition above. Among all these subsets, choose a subset with maximum possible size.

In other words, you have to choose the maximum possible number of points x_{i_1}, x_{i_2}, ..., x_{i_m} such that for each pair x_{i_j}, x_{i_k} it is true that |x_{i_j} - x_{i_k}| = 2^d where d is some non-negative integer number (not necessarily the same for each pair of points).

Input

The first line contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of points.

The second line contains n pairwise distinct integers x_1, x_2, ..., x_n (-10^9 ≤ x_i ≤ 10^9) — the coordinates of points.

Output

In the first line print m — the maximum possible number of points in a subset that satisfies the conditions described above.

In the second line print m integers — the coordinates of points in the subset you have chosen.

If there are multiple answers, print any of them.

Examples

Input

6
3 5 4 7 10 12

Output

3
7 3 5

Input

5
-1 2 5 8 11

Output

1
8

Note

In the first example the answer is [7, 3, 5]. Note, that |7-3|=4=2^2, |7-5|=2=2^1 and |3-5|=2=2^1. You can't find a subset having more points satisfying the required property.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 34;
const int N = (int)1e6 + 34;
struct K {
  int sum, ni, nx;
  K(int s, int i, int x) {
    sum = s;
    ni = i;
    nx = x;
  }
  bool operator<(const K &a) const {
    return (sum == a.sum ? ni < a.ni : sum < a.sum);
  }
};
void solve() {
  set<long long> s;
  int n;
  cin >> n;
  vector<long long> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
    s.insert(x);
  }
  vector<long long> ans = {a[0]};
  for (int deg = 0; deg < 31; deg++) {
    long long len = (1 << deg);
    for (int i = 0; i < n; i++) {
      if (s.find(a[i] + len) != s.end() && (int)ans.size() < 2) {
        ans = {a[i], a[i] + len};
      }
      if (s.find(a[i] + len) != s.end() && s.find(a[i] + len * 2) != s.end() &&
          (int)ans.size() < 3) {
        ans = {a[i], a[i] + len, a[i] + len * 2};
      }
    }
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < (int)ans.size(); i++) {
    cout << ans[i] << " ";
  }
  cout << "\n";
}
int main() {
  solve();
  return 0;
}

```