### Prompt

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

Let's define a string <x> as an opening tag, where x is any small letter of the Latin alphabet. Each opening tag matches a closing tag of the type </x>, where x is the same letter.

Tegs can be nested into each other: in this case one opening and closing tag pair is located inside another pair.

Let's define the notion of a XML-text:

  * an empty string is a XML-text
  * if s is a XML-text, then s'=+s+ also is a XML-text, where a is any small Latin letter
  * if s1, s2 are XML-texts, then s1+s2 also is a XML-text

You are given a XML-text (it is guaranteed that the text is valid), your task is to print in the following form:

  * each tag (opening and closing) is located on a single line
  * print before the tag 2 * h spaces, where h is the level of the tag's nestedness.

Input

The input data consists on the only non-empty string — the XML-text, its length does not exceed 1000 characters. It is guaranteed that the text is valid. The text contains no spaces.

Output

Print the given XML-text according to the above-given rules.

Examples

Input

<c></c>

Output

    <c>
    </c>

Input

<d><c></c></d>

Output

  <d>
    <c>
    </c>
  </d>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int nest = 0, n;
  n = s.length();
  for (int i = 0; i < n; i++) {
    string s1 = "";
    while (s[i] != '>') s1 += s[i], i++;
    s1 += s[i];
    int k = 0;
    if (s1[1] == '/') nest--;
    while (k < 2 * nest) cout << " ", k++;
    cout << s1 << endl;
    if (s1[1] != '/') nest++;
  }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`.

When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases.

Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds.

Now, he goes through the following process:

* Submit the code.
* Wait until the code finishes execution on all the cases.
* If the code fails to correctly solve some of the M cases, submit it again.
* Repeat until the code correctly solve all the cases in one submission.

Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).

Constraints

* All input values are integers.
* 1 \leq N \leq 100
* 1 \leq M \leq {\rm min}(N, 5)

Input

Input is given from Standard Input in the following format:

N M

Output

Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9.

Examples

Input

1 1

Output

3800

Input

10 2

Output

18400

Input

100 5

Output

608000

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, m, l;
  cin >> n >> m;
  l = ((n - m) + 19 * m) * pow(2, m) * 100;
  cout << l;
}
```


### Prompt

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

The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.

You are given a regular polygon with 2 ⋅ n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.

Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.

You can rotate 2n-gon and/or the square.

Input

The first line contains a single integer T (1 ≤ T ≤ 200) — the number of test cases.

Next T lines contain descriptions of test cases — one per line. Each line contains single even integer n (2 ≤ n ≤ 200). Don't forget you need to embed 2n-gon, not an n-gon.

Output

Print T real numbers — one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.

Example

Input

3
2
4
200

Output

1.000000000
2.414213562
127.321336469

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, flag = 0;
  char ch = getchar();
  if (ch == '-') flag = 1;
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x *= 10, x += ch - '0', ch = getchar();
  if (flag) return -x;
  return x;
}
int main() {
  int test;
  cin >> test;
  while (test--) {
    double i;
    double sum = 0;
    int n;
    cin >> n;
    double t = tan(acos(-1) / (2 * n));
    printf("%.9lf\n", 1 / t);
  }
}

```


### Prompt

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

Consider the following experiment. You have a deck of m cards, and exactly one card is a joker. n times, you do the following: shuffle the deck, take the top card of the deck, look at it and return it into the deck.

Let x be the number of times you have taken the joker out of the deck during this experiment. Assuming that every time you shuffle the deck, all m! possible permutations of cards are equiprobable, what is the expected value of x^k? Print the answer modulo 998244353.

Input

The only line contains three integers n, m and k (1 ≤ n, m < 998244353, 1 ≤ k ≤ 5000).

Output

Print one integer — the expected value of x^k, taken modulo 998244353 (the answer can always be represented as an irreducible fraction a/b, where b mod 998244353 ≠ 0; you have to print a ⋅ b^{-1} mod 998244353).

Examples

Input

1 1 1

Output

1

Input

1 1 5000

Output

1

Input

2 2 2

Output

499122178

Input

998244352 1337 5000

Output

326459680

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353, MAXN = 5050;
int qpow(int x, int y) {
  if (y < 0) return qpow(qpow(x, -y), mod - 2);
  int ret = 1;
  while (y) {
    if (y & 1) ret = 1ll * ret * x % mod;
    x = 1ll * x * x % mod;
    y >>= 1;
  }
  return ret;
}
int s2[MAXN][MAXN], rua[MAXN], p2[MAXN];
int n, m, t;
int main() {
  scanf("%d%d%d", &n, &m, &t);
  int i, j;
  rua[0] = 1;
  s2[0][0] = 1;
  p2[0] = qpow(2, n);
  for (i = 1; i <= t; i++)
    rua[i] = 1ll * rua[i - 1] * (n - i + 1) % mod, p2[i] = qpow(m, n - i);
  for (i = 1; i <= t; i++)
    for (j = 1; j <= i; j++)
      s2[i][j] = (1ll * j * s2[i - 1][j] % mod + s2[i - 1][j - 1]) % mod;
  int ans = 0;
  for (i = 0; i <= t; i++)
    ans = (ans + 1ll * s2[t][i] * rua[i] % mod * p2[i] % mod) % mod;
  ans = 1ll * ans * qpow(m, -n) % mod;
  printf("%d\n", (ans + mod) % mod);
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

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

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

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

Input

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

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

Output

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

Examples

Input

6 3 10
7 2 7 7 4 2

Output

YES

Input

6 2 3
4 5 3 13 4 10

Output

YES

Input

3 2 5
10 16 22

Output

NO

Note

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

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 10;
const long long M = 59049 + 10;
const long long inf = 1e16 + 7;
const long long Mod = 1e9 + 7;
const double eps = 1e-6;
int T;
int n, k, d;
int a[N];
int sum[N];
int f[N];
int main() {
  scanf("%d%d%d", &n, &k, &d);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  sort(a + 1, a + n + 1);
  int l = 1;
  sum[1] = 1;
  for (int i = 1; i <= n; ++i) {
    while (a[l] + d < a[i]) l++;
    if (i - k + 1 >= l) {
      if (sum[i - k + 1] - sum[l - 1] >= 1) f[i + 1] = 1;
    }
    sum[i + 1] = sum[i] + f[i + 1];
  }
  if (f[n + 1])
    puts("YES");
  else
    puts("NO");
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Polycarp is writing the prototype of a graphic editor. He has already made up his mind that the basic image transformations in his editor will be: rotate the image 90 degrees clockwise, flip the image horizontally (symmetry relative to the vertical line, that is, the right part of the image moves to the left, and vice versa) and zooming on the image. He is sure that that there is a large number of transformations that can be expressed through these three.

He has recently stopped implementing all three transformations for monochrome images. To test this feature, he asked you to write a code that will consecutively perform three actions with a monochrome image: first it will rotate the image 90 degrees clockwise, then it will flip the image horizontally and finally, it will zoom in twice on the image (that is, it will double all the linear sizes).

Implement this feature to help Polycarp test his editor.

Input

The first line contains two integers, w and h (1 ≤ w, h ≤ 100) — the width and height of an image in pixels. The picture is given in h lines, each line contains w characters — each character encodes the color of the corresponding pixel of the image. The line consists only of characters "." and "*", as the image is monochrome.

Output

Print 2w lines, each containing 2h characters — the result of consecutive implementing of the three transformations, described above.

Examples

Input

3 2
.*.
.*.

Output

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

Input

9 20
**.......
****.....
******...
*******..
..******.
....****.
......***
*.....***
*********
*********
*********
*********
....**...
...****..
..******.
.********
****..***
***...***
**.....**
*.......*

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, j, a, b;
  char ara[200][200];
  cin >> a >> b;
  m = a;
  n = b;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m * 2; j++) {
      cin >> ara[i][j];
      ara[i][j + 1] = ara[i][j];
      j++;
    }
  }
  for (i = 0; i < 2 * m; i++) {
    for (j = 0; j < n; j++) {
      cout << ara[j][i];
      cout << ara[j][i];
    }
    cout << endl;
  }
}

```


### Prompt

Please create a solution in CPP to the following problem:

Your friend has n cards.

You know that each card has a lowercase English letter on one side and a digit on the other.

Currently, your friend has laid out the cards on a table so only one side of each card is visible.

You would like to know if the following statement is true for cards that your friend owns: "If a card has a vowel on one side, then it has an even digit on the other side." More specifically, a vowel is one of 'a', 'e', 'i', 'o' or 'u', and even digit is one of '0', '2', '4', '6' or '8'.

For example, if a card has 'a' on one side, and '6' on the other side, then this statement is true for it. Also, the statement is true, for example, for a card with 'b' and '4', and for a card with 'b' and '3' (since the letter is not a vowel). The statement is false, for example, for card with 'e' and '5'. You are interested if the statement is true for all cards. In particular, if no card has a vowel, the statement is true.

To determine this, you can flip over some cards to reveal the other side. You would like to know what is the minimum number of cards you need to flip in the worst case in order to verify that the statement is true.

Input

The first and only line of input will contain a string s (1 ≤ |s| ≤ 50), denoting the sides of the cards that you can see on the table currently. Each character of s is either a lowercase English letter or a digit.

Output

Print a single integer, the minimum number of cards you must turn over to verify your claim.

Examples

Input

ee

Output

2

Input

z

Output

0

Input

0ay1

Output

2

Note

In the first sample, we must turn over both cards. Note that even though both cards have the same letter, they could possibly have different numbers on the other side.

In the second sample, we don't need to turn over any cards. The statement is vacuously true, since you know your friend has no cards with a vowel on them.

In the third sample, we need to flip the second and fourth cards.

### Response

```cpp
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
const int N = 1000 * 1000 + 100;
const long long MOD = 1e9 + 7;
const long long INC = INT_MAX;
const long long EPS = LLONG_MAX;
const long long INF = ULLONG_MAX;
long long minim = INF;
long long maxim = -INF;
long long cnt = 0, ans = 0;
vector<int> dp(N);
bool u = false, U[N];
int a[N], b[N], c[N];
int A[N / 1000][N / 1000];
string s, t;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string cur = "aeiou";
  cin >> s;
  for (auto i : s) {
    for (auto j : cur)
      if (j == i) {
        ++cnt;
        continue;
      }
    if (isdigit(i)) {
      if (i % 2 == 1) ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Masha lives in a multi-storey building, where floors are numbered with positive integers. Two floors are called adjacent if their numbers differ by one. Masha decided to visit Egor. Masha lives on the floor x, Egor on the floor y (not on the same floor with Masha).

The house has a staircase and an elevator. If Masha uses the stairs, it takes t_1 seconds for her to walk between adjacent floors (in each direction). The elevator passes between adjacent floors (in each way) in t_2 seconds. The elevator moves with doors closed. The elevator spends t_3 seconds to open or close the doors. We can assume that time is not spent on any action except moving between adjacent floors and waiting for the doors to open or close. If Masha uses the elevator, it immediately goes directly to the desired floor.

Coming out of the apartment on her floor, Masha noticed that the elevator is now on the floor z and has closed doors. Now she has to choose whether to use the stairs or use the elevator.

If the time that Masha needs to get to the Egor's floor by the stairs is strictly less than the time it will take her using the elevator, then she will use the stairs, otherwise she will choose the elevator.

Help Mary to understand whether to use the elevator or the stairs.

Input

The only line contains six integers x, y, z, t_1, t_2, t_3 (1 ≤ x, y, z, t_1, t_2, t_3 ≤ 1000) — the floor Masha is at, the floor Masha wants to get to, the floor the elevator is located on, the time it takes Masha to pass between two floors by stairs, the time it takes the elevator to pass between two floors and the time it takes for the elevator to close or open the doors.

It is guaranteed that x ≠ y.

Output

If the time it will take to use the elevator is not greater than the time it will take to use the stairs, print «YES» (without quotes), otherwise print «NO> (without quotes).

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

Examples

Input

5 1 4 4 2 1

Output

YES

Input

1 6 6 2 1 1

Output

NO

Input

4 1 7 4 1 2

Output

YES

Note

In the first example:

If Masha goes by the stairs, the time she spends is 4 ⋅ 4 = 16, because she has to go 4 times between adjacent floors and each time she spends 4 seconds.

If she chooses the elevator, she will have to wait 2 seconds while the elevator leaves the 4-th floor and goes to the 5-th. After that the doors will be opening for another 1 second. Then Masha will enter the elevator, and she will have to wait for 1 second for the doors closing. Next, the elevator will spend 4 ⋅ 2 = 8 seconds going from the 5-th floor to the 1-st, because the elevator has to pass 4 times between adjacent floors and spends 2 seconds each time. And finally, it will take another 1 second before the doors are open and Masha can come out.

Thus, all the way by elevator will take 2 + 1 + 1 + 8 + 1 = 13 seconds, which is less than 16 seconds, so Masha has to choose the elevator.

In the second example, it is more profitable for Masha to use the stairs, because it will take 13 seconds to use the elevator, that is more than the 10 seconds it will takes to go by foot.

In the third example, the time it takes to use the elevator is equal to the time it takes to walk up by the stairs, and is equal to 12 seconds. That means Masha will take the elevator.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int My_abs(int x) { return x < 0 ? -x : x; }
int main() {
  int x, y, z, t1, t2, t3;
  int a, b;
  scanf("%d%d%d%d%d%d", &x, &y, &z, &t1, &t2, &t3);
  a = t1 * My_abs(y - x);
  b = t2 * (My_abs(x - z) + My_abs(x - y)) + 3 * t3;
  if (b <= a)
    printf("YES");
  else
    printf("NO");
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Given a tree with n (1 ≤ n ≤ 200,000) nodes and a list of q (1 ≤ q ≤ 100,000) queries, process the queries in order and output a value for each output query. The given tree is connected and each node on the tree has a weight wi (-10,000 ≤ wi ≤ 10,000).

Each query consists of a number ti (ti = 1, 2), which indicates the type of the query , and three numbers ai, bi and ci (1 ≤ ai, bi ≤ n, -10,000 ≤ ci ≤ 10,000). Depending on the query type, process one of the followings:

* (ti = 1: modification query) Change the weights of all nodes on the shortest path between ai and bi (both inclusive) to ci.

* (ti = 2: output query) First, create a list of weights on the shortest path between ai and bi (both inclusive) in order. After that, output the maximum sum of a non-empty continuous subsequence of the weights on the list. ci is ignored for output queries.

Input

The first line contains two integers n and q. On the second line, there are n integers which indicate w1, w2, ... , wn.

Each of the following n - 1 lines consists of two integers si and ei (1 ≤ si, ei ≤ n), which means that there is an edge between si and ei.

Finally the following q lines give the list of queries, each of which contains four integers in the format described above. Queries must be processed one by one from top to bottom.

Output

For each output query, output the maximum sum in one line.

Examples

Input

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

Output

6
3
-4

Input

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

Output

12
10
10
19

Input

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

Output

20
9
29
27
10
12
1
18
-2
-3

### Response

```cpp
#include <cassert>
#include <utility>
#include <vector>

template <typename ValueMonoid, typename OperatorMonoid, class Modify>
class LinkCutTree {
public:
	using value_type = ValueMonoid;
	using operator_type = OperatorMonoid;

private:
	struct node_t {
		node_t *left, *right, *par;
		value_type value, sum;
		operator_type lazy;
		bool isroot, reversed;
		node_t()
			: left(nullptr), right(nullptr), par(nullptr), value(), sum(), lazy(),
			isroot(1), reversed(0) {}
		bool isleft() const { return par->left == this; }
		void assign(const operator_type &data) { lazy = lazy + data; }
		void haulL(node_t *const t) {
			left = t;
			if (t)
				t->par = this;
		}
		void haulR(node_t *const t) {
			right = t;
			if (t)
				t->par = this;
		}
	};
	value_type reflect(const node_t *const t) const {
		if (!t)
			return value_type();
		if (t->reversed)
			return m(~t->sum, t->lazy);
		return m(t->sum, t->lazy);
	}
	void recalc(node_t *const t) {
		t->sum = reflect(t->left) + t->value + reflect(t->right);
	}
	void splay(node_t *const t) {
		node_t *p, *pp = t, *x = t->par;
		while (!t->isroot) {
			if (x->left == pp)
				x->left = t;
			else
				x->right = t;
			p = t->par;
			if (p->isroot) {
				t->par = p->par;
				std::swap(t->isroot, p->isroot);
				if (p->left == t) {
					p->haulL(t->right);
					t->haulR(p);
				}
				else {
					p->haulR(t->left);
					t->haulL(p);
				}
				recalc(p);
				break;
			}
			pp = p->par;
			x = pp->par;
			std::swap(t->isroot, pp->isroot);
			if (t->isleft()) {
				if (p->isleft()) {
					pp->haulL(p->right);
					p->haulR(pp);
				}
				else {
					pp->haulR(t->left);
					t->haulL(pp);
				}
				p->haulL(t->right);
				t->haulR(p);
			}
			else {
				if (p->isleft()) {
					pp->haulL(t->right);
					t->haulR(pp);
				}
				else {
					pp->haulR(p->left);
					p->haulL(pp);
				}
				p->haulR(t->left);
				t->haulL(p);
			}
			recalc(pp);
			recalc(p);
			t->par = x;
		}
	}
	void push(node_t *const t) {
		if (t->left)
			t->left->assign(t->lazy);
		if (t->right)
			t->right->assign(t->lazy);
		t->value = m(t->value, t->lazy);
		t->lazy = operator_type();
		if (!t->reversed)
			return;
		std::swap(t->left, t->right);
		if (t->left)
			t->left->reversed ^= 1;
		if (t->right)
			t->right->reversed ^= 1;
		t->value = ~t->value;
		t->reversed = 0;
	}
	void propagate(node_t *const t) {
		node_t *x = t->par, *prev = t;
		while (x) {
			std::swap(x->par, prev);
			std::swap(x, prev);
		}
		while (x != t) {
			std::swap(x, prev);
			push(x);
			std::swap(x->par, prev);
		}
	}
	void expose(node_t *const n) {
		propagate(n);
		node_t *x = n, *prev = nullptr;
		while (x) {
			splay(x);
			if (x->right)
				x->right->isroot = 1;
			x->right = prev;
			if (prev)
				prev->isroot = 0;
			recalc(x);
			prev = x;
			x = x->par;
		}
		splay(n);
		recalc(n);
	}
	using container_type = std::vector<node_t>;

public:
	using size_type = typename container_type::size_type;

private:
	container_type tree;
	const Modify m;
	void reroot(const size_type v) {
		expose(&tree[v]);
		tree[v].reversed ^= 1;
	}

public:
	explicit LinkCutTree(const size_type size, const Modify &m = Modify())
		: tree(size), m(m) {}
	explicit LinkCutTree(const std::vector<value_type> &a,
		const Modify &m = Modify())
		: tree(a.size()), m(m) {
		for (size_type i = 0; i < a.size(); ++i)
			tree[i].value = tree[i].sum = a[i];
	}
	void link(const size_type child, const size_type parent) {
		assert(child < size());
		assert(parent < size());
		reroot(child);
		tree[child].par = &tree[parent];
	}
	void cut(const size_type child) {
		assert(child < size());
		node_t *const n = &tree[child];
		expose(n);
		if (n->left) {
			n->left->isroot = 1;
			n->left->par = nullptr;
		}
		n->left = nullptr;
		n->sum = n->value;
	}
	void update(const size_type u, const size_type v, const operator_type &data) {
		assert(u < size());
		assert(v < size());
		reroot(u);
		expose(&tree[v]);
		tree[v].assign(data);
	}
	value_type path(const size_type u, const size_type v) {
		assert(u < size());
		assert(v < size());
		reroot(u);
		expose(&tree[v]);
		return tree[v].sum;
	}
	size_type size() const noexcept { return tree.size(); }
	bool empty() const noexcept { return tree.empty(); }
};

#include<algorithm>
struct Ass {
	int a;
	bool f;
	Ass() :f(1) {}
	Ass(int a) :a(a), f(0) {}
	Ass operator+(const Ass &o)const {
		return o.f ? *this : o;
	}
};
struct Line {
	int all, l, r, max, siz;
	bool f;
	Line() :f(1) {}
	Line(int all, int l, int r, int max, int siz, bool f = 0) :
		all(all), l(l), r(r), max(max), siz(siz), f(f) {}
	Line operator~()const { return Line(all, r, l, max, siz, f); }
	Line operator+(const Line &o)const {
		if (f) return o;
		if (o.f) return *this;
		return Line(
			all + o.all,
			std::max(l, o.l > 0 ? all + o.l : all),
			std::max(o.r, r > 0 ? r + o.all : o.all),
			std::max(std::max(max, o.max), r + o.l),
			siz + o.siz
		);
	}
};
struct hoge {
	Line operator()(const Line &x, const Ass &y)const {
		if (y.f || x.f) return x;
		if (y.a > 0)
			return Line(y.a*x.siz, y.a*x.siz, y.a*x.siz, y.a*x.siz, x.siz);
		else
			return Line(y.a*x.siz, y.a, y.a, y.a, x.siz);
	}
};

#include<cstdio>
#include<vector>
int main(void) {
	int nn, q;
	scanf("%d %d", &nn, &q);
	const int n = nn;
	std::vector<Line> d;
	int w;
	for (int i = 0;i < n;++i) {
		scanf("%d", &w);
		d.emplace_back(w, w, w, w, 1);
	}
	LinkCutTree<Line, Ass, hoge> T(d);
	int s, e;
	for (int i = 1;i < n;++i) {
		scanf("%d %d", &s, &e);
		T.link(s-1, e-1);
	}
	int t, a, b;
	Ass c(0);
	while (q--) {
		scanf("%d %d %d %d", &t, &a, &b, &c.a);
		if (t == 1)
			T.update(a - 1, b - 1, c);
		else
			printf("%d\n", T.path(a - 1, b - 1).max);
	}
	return 0;
}

```


### Prompt

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

Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a_i votes for Elodreip, than he will get exactly k - a_i votes from this person. Of course 0 ≤ k - a_i holds.

Awruk knows that if he loses his life is over. He has been speaking a lot with his friends and now he knows a_1, a_2, ..., a_n — how many votes for Elodreip each student wants to give. Now he wants to change the number k to win the elections. Of course he knows that bigger k means bigger chance that somebody may notice that he has changed something and then he will be disqualified.

So, Awruk knows a_1, a_2, ..., a_n — how many votes each student will give to his opponent. Help him select the smallest winning number k. In order to win, Awruk needs to get strictly more votes than Elodreip.

Input

The first line contains integer n (1 ≤ n ≤ 100) — the number of students in the school.

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 100) — the number of votes each student gives to Elodreip.

Output

Output the smallest integer k (k ≥ max a_i) which gives Awruk the victory. In order to win, Awruk needs to get strictly more votes than Elodreip.

Examples

Input

5
1 1 1 5 1

Output

5

Input

5
2 2 3 2 2

Output

5

Note

In the first example, Elodreip gets 1 + 1 + 1 + 5 + 1 = 9 votes. The smallest possible k is 5 (it surely can't be less due to the fourth person), and it leads to 4 + 4 + 4 + 0 + 4 = 16 votes for Awruk, which is enough to win.

In the second example, Elodreip gets 11 votes. If k = 4, Awruk gets 9 votes and loses to Elodreip.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n], mx = -1, sum = 0, sum1 = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mx = max(mx, arr[i]);
    sum += arr[i];
  }
  for (int i = 0; i < n; i++) {
    arr[i] = mx - arr[i];
    sum1 += arr[i];
  }
  int ans = mx;
  while (sum1 <= sum) {
    ans++;
    sum1 += n;
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

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

You've gotten an n × m sheet of squared paper. Some of its squares are painted. Let's mark the set of all painted squares as A. Set A is connected. Your task is to find the minimum number of squares that we can delete from set A to make it not connected.

A set of painted squares is called connected, if for every two squares a and b from this set there is a sequence of squares from the set, beginning in a and ending in b, such that in this sequence any square, except for the last one, shares a common side with the square that follows next in the sequence. An empty set and a set consisting of exactly one square are connected by definition.

Input

The first input line contains two space-separated integers n and m (1 ≤ n, m ≤ 50) — the sizes of the sheet of paper.

Each of the next n lines contains m characters — the description of the sheet of paper: the j-th character of the i-th line equals either "#", if the corresponding square is painted (belongs to set A), or equals "." if the corresponding square is not painted (does not belong to set A). It is guaranteed that the set of all painted squares A is connected and isn't empty.

Output

On the first line print the minimum number of squares that need to be deleted to make set A not connected. If it is impossible, print -1.

Examples

Input

5 4
####
#..#
#..#
#..#
####

Output

2

Input

5 5
#####
#...#
#####
#...#
#####

Output

2

Note

In the first sample you can delete any two squares that do not share a side. After that the set of painted squares is not connected anymore.

The note to the second sample is shown on the figure below. To the left there is a picture of the initial set of squares. To the right there is a set with deleted squares. The deleted squares are marked with crosses.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int DIM = 55;
char arr[DIM][DIM];
bitset<DIM> mrk[DIM];
const int dx[5] = {0, -1, 0, 1, 0};
const int dy[5] = {0, 0, 1, 0, -1};
void dfs(int x, int y, int &nr) {
  mrk[x][y] = 1;
  nr++;
  for (int d = 1; d <= 4; d++) {
    int xx = x + dx[d];
    int yy = y + dy[d];
    if (mrk[xx][yy] == 0 && arr[xx][yy] == '#') dfs(xx, yy, nr);
  }
  return;
}
int main(void) {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    cin >> (arr[i] + 1);
    for (int j = 1; j <= m; j++) cnt += (arr[i][j] == '#');
  }
  if (cnt <= 2) {
    cout << -1 << endl;
    return 0;
  }
  int mnm = 2;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (arr[i][j] == '#') {
        arr[i][j] = '.';
        for (int k = 1; k <= n; k++) mrk[k].reset();
        int nr = 0;
        for (int ii = 1; ii <= n && nr == 0; ii++) {
          for (int jj = 1; jj <= m && nr == 0; jj++) {
            if (arr[ii][jj] == '#') dfs(ii, jj, nr);
          }
        }
        mnm = min(mnm, 2 - (cnt - 1 != nr));
        arr[i][j] = '#';
      }
    }
  }
  cout << mnm << endl;
  return 0;
}

```


### Prompt

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

For a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequnece (LIS) in A.

An increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 ≤ i0 < i1 < ... < ik < n and ai0 < ai1 < ... < aik.

Constraints

* 1 ≤ n ≤ 100000
* 0 ≤ ai ≤ 109

Input

n
a0
a1
:
an-1

In the first line, an integer n is given. In the next n lines, elements of A are given.

Output

The length of the longest increasing subsequence of A.

Examples

Input

5
5
1
3
2
4

Output

3

Input

3
1
1
1

Output

1

### Response

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

using namespace std;

int main() {

    int n, len = 0;

    cin >> n;

    int num[n], dp[n];

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

    dp[0] = num[0];
    for(int i = 1; i < n; ++i) {
        if(dp[len] < num[i]) {
            dp[++len] = num[i];
        } else {
            *lower_bound(dp, dp + len, num[i]) = num[i];
        }
    }

    cout << len + 1 << endl;

}
```


### Prompt

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

Input

The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane.

Each of the next n lines contains two real coordinates xi and yi of the <image> point, specified with exactly 2 fractional digits. All coordinates are between  - 1000 and 1000, inclusive.

Output

Output a single real number θ — the answer to the problem statement. The absolute or relative error of your answer should be at most 10 - 2.

Examples

Input

8
-2.14 2.06
-1.14 2.04
-2.16 1.46
-2.14 0.70
-1.42 0.40
-0.94 -0.48
-1.42 -1.28
-2.16 -1.62

Output

5.410

Input

5
2.26 1.44
2.28 0.64
2.30 -0.30
1.58 0.66
3.24 0.66

Output

5.620

Input

8
6.98 2.06
6.40 1.12
5.98 0.24
5.54 -0.60
7.16 0.30
7.82 1.24
8.34 0.24
8.74 -0.76

Output

5.480

Input

5
10.44 2.06
10.90 0.80
11.48 -0.48
12.06 0.76
12.54 2.06

Output

6.040

Input

8
16.94 2.42
15.72 2.38
14.82 1.58
14.88 0.50
15.76 -0.16
16.86 -0.20
17.00 0.88
16.40 0.92

Output

6.040

Input

7
20.62 3.00
21.06 2.28
21.56 1.36
21.66 0.56
21.64 -0.52
22.14 2.32
22.62 3.04

Output

6.720

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  double sum = 0;
  for (int i = 1; i <= n; i++) {
    double x, y;
    cin >> x >> y;
    sum += y;
  }
  sum = sum / (double)n;
  sum += 5;
  printf("%.3lf\n", sum);
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

There are n employees working in company "X" (let's number them from 1 to n for convenience). Initially the employees didn't have any relationships among each other. On each of m next days one of the following events took place:

  * either employee y became the boss of employee x (at that, employee x didn't have a boss before);
  * or employee x gets a packet of documents and signs them; then he gives the packet to his boss. The boss signs the documents and gives them to his boss and so on (the last person to sign the documents sends them to the archive);
  * or comes a request of type "determine whether employee x signs certain documents".

Your task is to write a program that will, given the events, answer the queries of the described type. At that, it is guaranteed that throughout the whole working time the company didn't have cyclic dependencies.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 105) — the number of employees and the number of events.

Each of the next m lines contains the description of one event (the events are given in the chronological order). The first number of the line determines the type of event t (1 ≤ t ≤ 3).

  * If t = 1, then next follow two integers x and y (1 ≤ x, y ≤ n) — numbers of the company employees. It is guaranteed that employee x doesn't have the boss currently.
  * If t = 2, then next follow integer x (1 ≤ x ≤ n) — the number of the employee who got a document packet.
  * If t = 3, then next follow two integers x and i (1 ≤ x ≤ n; 1 ≤ i ≤ [number of packets that have already been given]) — the employee and the number of the document packet for which you need to find out information. The document packets are numbered started from 1 in the chronological order.

It is guaranteed that the input has at least one query of the third type.

Output

For each query of the third type print "YES" if the employee signed the document package and "NO" otherwise. Print all the words without the quotes.

Examples

Input

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

Output

YES
NO
YES

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
const int MAXN = 100000 + 9;
int n, nq;
vector<vector<int> > G;
int P[MAXN][(17 + 9)];
int L[MAXN];
void init() { memset(P, -1, sizeof P); }
void DFS(int u = 0, int p = -1) {
  P[u][0] = p;
  L[u] = p == -1 ? 0 : L[p] + 1;
  for (int i = 0, sz = G[u].size(); i < sz; i++) {
    int v = G[u][i];
    DFS(v, u);
  }
}
void build_P() {
  for (int j = 1; (1 << j) < n; j++) {
    for (int i = 0; i < n; i++) {
      if (P[i][j - 1] != -1) {
        P[i][j] = P[P[i][j - 1]][j - 1];
      }
    }
  }
}
int LCA(int u, int v) {
  if (L[u] < L[v]) swap(u, v);
  int lg = 0;
  while ((1 << lg) <= L[u]) lg++;
  lg--;
  for (int j = lg; j >= 0; j--)
    if (P[u][j] != -1 && L[P[u][j]] >= L[v]) u = P[u][j];
  if (u == v) return u;
  for (int j = lg; j >= 0; j--)
    if (P[u][j] != -1 && P[u][j] != P[v][j]) u = P[u][j], v = P[v][j];
  return P[u][0];
}
struct Query {
  int node, file;
  Query() {}
  Query(int nnode, int nfile) { node = nnode, file = nfile; }
};
Query qu[MAXN];
int rep[MAXN];
int lower[MAXN], upper[MAXN];
void join(int x, int y) {
  assert(rep[x] == x);
  rep[x] = y;
}
int find_rep(int x) {
  if (x == rep[x]) return x;
  return rep[x] = find_rep(rep[x]);
}
void sign(int x, int f) {
  lower[f] = x;
  x = find_rep(x);
  upper[f] = x;
}
bool areTogether(int x, int y) { return find_rep(x) == find_rep(y); }
int main() {
  read_file();
  while (scanf("%d%d", &n, &nq) != -1) {
    for (int i = 0; i < n; i++) rep[i] = i;
    G.assign(n, vector<int>());
    int curFile = 0;
    int m = 0;
    while (nq--) {
      int type;
      scanf("%d", &type);
      if (type == 1) {
        int x, y;
        scanf("%d%d", &x, &y);
        x--, y--;
        join(x, y);
        G[y].push_back(x);
      } else if (type == 2) {
        int x;
        scanf("%d", &x);
        x--;
        sign(x, curFile);
        curFile++;
      } else {
        int x, file;
        scanf("%d%d", &x, &file);
        x--, file--;
        qu[m] = Query(x, file);
        m++;
      }
    }
    init();
    for (int i = 0; i < n; i++) {
      if (rep[i] == i) DFS(i, -1);
    }
    build_P();
    for (int i = 0; i < m; i++) {
      int node = qu[i].node;
      int file = qu[i].file;
      string ans = "NO";
      int lo = lower[file];
      int hi = upper[file];
      if (areTogether(node, lo) && LCA(lo, node) == node) {
        if (L[node] <= L[lo] && L[node] >= L[hi]) ans = "YES";
      }
      printf("%s\n", ans.c_str());
    }
  }
}

```


### Prompt

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

There are many interesting tasks on domino tilings. For example, an interesting fact is known. Let us take a standard chessboard (8 × 8) and cut exactly two squares out of it. It turns out that the resulting board can always be tiled using dominoes 1 × 2, if the two cut out squares are of the same color, otherwise it is impossible.

Petya grew bored with dominoes, that's why he took a chessboard (not necessarily 8 × 8), cut some squares out of it and tries to tile it using triminoes. Triminoes are reactangles 1 × 3 (or 3 × 1, because triminoes can be rotated freely), also the two extreme squares of a trimino are necessarily white and the square in the middle is black. The triminoes are allowed to put on the chessboard so that their squares matched the colors of the uncut squares of the chessboard, and also the colors must match: the black squares must be matched with the black ones only and the white ones — with the white squares. The triminoes must not protrude above the chessboard or overlap each other. All the uncut squares of the board must be covered with triminoes.

Help Petya find out if it is possible to tile his board using triminos in the described way and print one of the variants of tiling.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 1000) — the board size. Next n lines contain m symbols each and represent the board description. If some position contains ".", then the square in this position has been cut out. Symbol "w" stands for a white square, "b" stands for a black square. It is guaranteed that through adding the cut squares can result in a correct chessboard (i.e. with alternating black and white squares), thought, perhaps, of a non-standard size.

Output

If at least one correct tiling exists, in the first line print "YES" (without quotes), and then — the tiling description. The description must contain n lines, m symbols in each. The cut out squares, as well as in the input data, are marked by ".". To denote triminoes symbols "a", "b", "c", "d" can be used, and all the three squares of each trimino must be denoted by the same symbol. If two triminoes share a side, than they must be denoted by different symbols. Two triminoes not sharing a common side can be denoted by one and the same symbol (c.f. sample).

If there are multiple correct ways of tiling, it is allowed to print any. If it is impossible to tile the board using triminoes or the correct tiling, for which four symbols "a", "b", "c", "d" would be enough, doesn't exist, print "NO" (without quotes) in the first line.

Examples

Input

6 10
.w.wbw.wbw
wbwbw.w.w.
bw.wbwbwbw
w.wbw.wbwb
...wbw.w.w
..wbw.wbw.

Output

YES
.a.aaa.ccc
baccc.c.a.
ba.dddcbab
b.aaa.cbab
...bbb.b.b
..ccc.ddd.

Input

2 2
wb
bw

Output

NO

Input

1 3
wbw

Output

YES
bbb

Input

1 3
...

Output

YES
...

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
char E[1005][1005];
char D[1005][1005];
char getc1() {
  char c = getchar();
  while (c != '.' && c != 'w' && c != 'b') c = getchar();
  return c;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    E[i][0] = '.';
    for (int j = 1; j <= m; j++) {
      E[i][j] = getc1();
      if (D[i][j] && E[i][j] == '.') {
        puts("NO");
        return 0;
      }
      if (D[i][j]) E[i][j] = '.';
    }
    for (int j = 1; j <= m; j++) {
      if (E[i][j] == 'b' && E[i][j - 1] == '.') {
        puts("NO");
        return 0;
      }
      if (E[i][j] == 'w' && E[i][j - 1] == '.') {
        if (E[i][j + 1] == 'b') {
          if (E[i][j + 2] == 'w') {
            E[i][j] = E[i][j + 1] = E[i][j + 2] = '.';
            D[i][j] = D[i][j + 1] = D[i][j + 2] = (i % 2 ? 'a' : 'b') - '.';
          } else {
            puts("NO");
            return 0;
          }
        } else {
          E[i][j] = '.';
          D[i][j] = D[i + 1][j] = D[i + 2][j] = (j % 2 ? 'c' : 'd') - '.';
          if (i + 2 > n) {
            puts("NO");
            return 0;
          }
        }
      }
    }
  }
  puts("YES");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) putchar(D[i][j] + '.');
    putchar(10);
  }
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Anton goes to school, his favorite lessons are arraystudying. He usually solves all the tasks pretty fast, but this time the teacher gave him a complicated one: given two arrays b and c of length n, find array a, such that:

<image>

where a and b means bitwise AND, while a or b means bitwise OR.

Usually Anton is good in arraystudying, but this problem is too hard, so Anton asks you to help.

Input

The first line of the input contains a single integers n (1 ≤ n ≤ 200 000) — the size of arrays b and c.

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

Third line contains n integers ci (0 ≤ ci ≤ 109) — elements of the array c.

Output

If there is no solution, print  - 1.

Otherwise, the only line of the output should contain n non-negative integers ai — elements of the array a. If there are multiple possible solutions, you may print any of them.

Examples

Input

4
6 8 4 4
16 22 10 10

Output

3 5 1 1

Input

5
8 25 14 7 16
19 6 9 4 25

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
const double pi = acos(-1.0);
const double eps = 1e-9;
const int inf = 2 * 1e9;
const int base = 2011;
const int raz = (int)2e5 + 5;
const double deg = pi / 180;
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  long long b[n], c[n], sb, sc;
  sb = sc = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &b[i]);
    sb += b[i];
  }
  for (int i = 0; i < n; i++) {
    scanf("%lld", &c[i]);
    sc += c[i];
  }
  long long sm = (sb + sc) / (2 * n);
  long long a[n];
  for (int i = 0; i < n; i++) {
    a[i] = (b[i] + c[i] - sm) / n;
    if (a[i] < 0) {
      printf("-1");
      return 0;
    }
  }
  bool bt[31][n];
  long long sbt[31];
  memset(bt, 0, sizeof(bt));
  memset(sbt, 0, sizeof(sbt));
  for (int i = 0; i < 31; i++)
    for (int j = 0; j < n; j++)
      if ((a[j] & (1LL << i))) bt[i][j] = 1;
  for (int i = 0; i < 31; i++) {
    sbt[i] = 0;
    for (int j = 0; j < n; j++) sbt[i] += bt[i][j];
  }
  long long cb, cc;
  for (int i = 0; i < n; i++) {
    cb = cc = 0;
    for (int bit = 0; bit < 31; bit++) {
      if (bt[bit][i]) {
        cb += sbt[bit] << bit;
        cc += n << bit;
      } else
        cc += sbt[bit] << bit;
    }
    if (cb != b[i] or cc != c[i]) {
      printf("-1");
      return 0;
    }
  }
  for (int i = 0; i < n; i++) printf("%lld ", a[i]);
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

N players will participate in a tennis tournament. We will call them Player 1, Player 2, \ldots, Player N.

The tournament is round-robin format, and there will be N(N-1)/2 matches in total. Is it possible to schedule these matches so that all of the following conditions are satisfied? If the answer is yes, also find the minimum number of days required.

* Each player plays at most one matches in a day.
* Each player i (1 \leq i \leq N) plays one match against Player A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} in this order.

Constraints

* 3 \leq N \leq 1000
* 1 \leq A_{i, j} \leq N
* A_{i, j} \neq i
* A_{i, 1}, A_{i, 2}, \ldots, A_{i, N-1} are all different.

Input

Input is given from Standard Input in the following format:

N
A_{1, 1} A_{1, 2} \ldots A_{1, N-1}
A_{2, 1} A_{2, 2} \ldots A_{2, N-1}
:
A_{N, 1} A_{N, 2} \ldots A_{N, N-1}

Output

If it is possible to schedule all the matches so that all of the conditions are satisfied, print the minimum number of days required; if it is impossible, print `-1`.

Examples

Input

3
2 3
1 3
1 2

Output

3

Input

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

Output

4

Input

3
2 3
3 1
1 2

Output

-1

### Response

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

const int maxn = 1e6 + 10;
vector <int> adj[maxn];
int v[1010];
int indeg[maxn];
int dp[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		fill(v, v + n, 0);
		for (int j = 0; j < n - 1; j++){
			cin >> v[j];
			v[j] --;
		}
		for (int j = 0; j < n - 2; j++){
			adj[min(i, v[j]) * n + max(i, v[j])].push_back(min(i, v[j + 1]) * n + max(i, v[j + 1]));
			indeg[min(i, v[j + 1]) * n + max(i, v[j + 1])] ++;
		}
	}
	queue <int> Q;
	for (int i = 0; i < n * n; i++){
		if (!indeg[i])
			Q.push(i);
	}
	vector <int> TS;
	while (Q.size()){
		int v = Q.front();
		Q.pop();
		TS.push_back(v);
		for (auto u: adj[v]){
			indeg[u] --;
			if (!indeg[u])
				Q.push(u);
			dp[u] = max(dp[u], dp[v] + 1);
		}
	}
	if (TS.size() != n * n){
		cout << -1;
		return 0;
	}
	cout << *(max_element(dp, dp + n * n)) + 1;
}

```


### Prompt

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

The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But any scientific claim sounds a lot more reasonable if there are some numbers involved, so they have decided to actually calculate some value which would represent how high the temperatures are.

Mathematicians of Berland State University came up with a special heat intensity value. This value is calculated as follows:

Suppose we want to analyze the segment of n consecutive days. We have measured the temperatures during these n days; the temperature during i-th day equals a_i.

We denote the average temperature of a segment of some consecutive days as the arithmetic mean of the temperature measures during this segment of days. So, if we want to analyze the average temperature from day x to day y, we calculate it as \frac{∑ _{i = x}^{y} a_i}{y - x + 1} (note that division is performed without any rounding). The heat intensity value is the maximum of average temperatures over all segments of not less than k consecutive days. For example, if analyzing the measures [3, 4, 1, 2] and k = 3, we are interested in segments [3, 4, 1], [4, 1, 2] and [3, 4, 1, 2] (we want to find the maximum value of average temperature over these segments).

You have been hired by Berland State University to write a program that would compute the heat intensity value of a given period of days. Are you up to this task?

Input

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 5000) — the number of days in the given period, and the minimum number of days in a segment we consider when calculating heat intensity value, respectively.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 5000) — the temperature measures during given n days.

Output

Print one real number — the heat intensity value, i. e., the maximum of average temperatures over all segments of not less than k consecutive days.

Your answer will be considered correct if the following condition holds: |res - res_0| < 10^{-6}, where res is your answer, and res_0 is the answer given by the jury's solution.

Example

Input

4 3
3 4 1 2

Output

2.666666666666667

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, k;
double maxx = 0;
int a[10005], s[10005];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s[i] = s[i - 1] + a[i];
    if (i >= k) maxx = max(double(s[i] * 1.0 / i), maxx);
  }
  for (int i = k + 1; i <= n; i++) {
    int j = 1;
    while (i - j >= k) {
      maxx = max(double((s[i] - s[j]) * 1.0 / (i - j)), maxx);
      j++;
    }
  }
  printf("%.15lf", maxx);
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

On a chessboard with a width of n and a height of n, rows are numbered from bottom to top from 1 to n, columns are numbered from left to right from 1 to n. Therefore, for each cell of the chessboard, you can assign the coordinates (r,c), where r is the number of the row, and c is the number of the column.

The white king has been sitting in a cell with (1,1) coordinates for a thousand years, while the black king has been sitting in a cell with (n,n) coordinates. They would have sat like that further, but suddenly a beautiful coin fell on the cell with coordinates (x,y)...

Each of the monarchs wanted to get it, so they decided to arrange a race according to slightly changed chess rules:

As in chess, the white king makes the first move, the black king makes the second one, the white king makes the third one, and so on. However, in this problem, kings can stand in adjacent cells or even in the same cell at the same time.

The player who reaches the coin first will win, that is to say, the player who reaches the cell with the coordinates (x,y) first will win.

Let's recall that the king is such a chess piece that can move one cell in all directions, that is, if the king is in the (a,b) cell, then in one move he can move from (a,b) to the cells (a + 1,b), (a - 1,b), (a,b + 1), (a,b - 1), (a + 1,b - 1), (a + 1,b + 1), (a - 1,b - 1), or (a - 1,b + 1). Going outside of the field is prohibited.

Determine the color of the king, who will reach the cell with the coordinates (x,y) first, if the white king moves first.

Input

The first line contains a single integer n (2 ≤ n ≤ 10^{18}) — the length of the side of the chess field.

The second line contains two integers x and y (1 ≤ x,y ≤ n) — coordinates of the cell, where the coin fell.

Output

In a single line print the answer "White" (without quotes), if the white king will win, or "Black" (without quotes), if the black king will win.

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

Examples

Input

4
2 3

Output

White

Input

5
3 5

Output

Black

Input

2
2 2

Output

Black

Note

An example of the race from the first sample where both the white king and the black king move optimally:

  1. The white king moves from the cell (1,1) into the cell (2,2).
  2. The black king moves form the cell (4,4) into the cell (3,3).
  3. The white king moves from the cell (2,2) into the cell (2,3). This is cell containing the coin, so the white king wins.

<image>

An example of the race from the second sample where both the white king and the black king move optimally:

  1. The white king moves from the cell (1,1) into the cell (2,2).
  2. The black king moves form the cell (5,5) into the cell (4,4).
  3. The white king moves from the cell (2,2) into the cell (3,3).
  4. The black king moves from the cell (4,4) into the cell (3,5). This is the cell, where the coin fell, so the black king wins.

<image>

In the third example, the coin fell in the starting cell of the black king, so the black king immediately wins.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, x, y;
int main() {
  cin >> n;
  cin >> x >> y;
  if (x + y <= n + 1)
    cout << "White";
  else
    cout << "Black";
}

```


### Prompt

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

Breaking Good is a new video game which a lot of gamers want to have. There is a certain level in the game that is really difficult even for experienced gamers.

Walter William, the main character of the game, wants to join a gang called Los Hermanos (The Brothers). The gang controls the whole country which consists of n cities with m bidirectional roads connecting them. There is no road is connecting a city to itself and for any two cities there is at most one road between them. The country is connected, in the other words, it is possible to reach any city from any other city using the given roads.

The roads aren't all working. There are some roads which need some more work to be performed to be completely functioning.

The gang is going to rob a bank! The bank is located in city 1. As usual, the hardest part is to escape to their headquarters where the police can't get them. The gang's headquarters is in city n. To gain the gang's trust, Walter is in charge of this operation, so he came up with a smart plan.

First of all the path which they are going to use on their way back from city 1 to their headquarters n must be as short as possible, since it is important to finish operation as fast as possible.

Then, gang has to blow up all other roads in country that don't lay on this path, in order to prevent any police reinforcements. In case of non-working road, they don't have to blow up it as it is already malfunctional.

If the chosen path has some roads that doesn't work they'll have to repair those roads before the operation.

Walter discovered that there was a lot of paths that satisfied the condition of being shortest possible so he decided to choose among them a path that minimizes the total number of affected roads (both roads that have to be blown up and roads to be repaired).

Can you help Walter complete his task and gain the gang's trust?

Input

The first line of input contains two integers n, m (2 ≤ n ≤ 105, <image>), the number of cities and number of roads respectively.

In following m lines there are descriptions of roads. Each description consists of three integers x, y, z (1 ≤ x, y ≤ n, <image>) meaning that there is a road connecting cities number x and y. If z = 1, this road is working, otherwise it is not.

Output

In the first line output one integer k, the minimum possible number of roads affected by gang.

In the following k lines output three integers describing roads that should be affected. Each line should contain three integers x, y, z (1 ≤ x, y ≤ n, <image>), cities connected by a road and the new state of a road. z = 1 indicates that the road between cities x and y should be repaired and z = 0 means that road should be blown up.

You may output roads in any order. Each affected road should appear exactly once. You may output cities connected by a single road in any order. If you output a road, it's original state should be different from z.

After performing all operations accroding to your plan, there should remain working only roads lying on some certain shortest past between city 1 and n.

If there are multiple optimal answers output any.

Examples

Input

2 1
1 2 0

Output

1
1 2 1

Input

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

Output

3
1 2 0
1 3 1
2 3 0

Input

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

Output

3
2 3 0
1 5 0
6 8 1

Note

In the first test the only path is 1 - 2

In the second test the only shortest path is 1 - 3 - 4

In the third test there are multiple shortest paths but the optimal is 1 - 4 - 6 - 8

### Response

```cpp
#include <bits/stdc++.h>
using std::multiset;
const int N = 100010, M = N << 1;
int tot = 1, head[N], next[M], to[M], c[M], f1[N], f2[N];
int n, m, fa[N], fe[N];
void add(int x, int y, int z) {
  to[++tot] = y;
  next[tot] = head[x];
  head[x] = tot;
  c[tot] = z;
}
struct lr {
  int x, f1, f2;
  bool operator<(const lr &a) const {
    return f1 != a.f1 ? f1 < a.f1 : f2 < a.f2;
  }
} t;
struct E {
  int x, y, ty;
  void print() { printf("%d %d %d\n", x, y, ty); }
} e[N];
multiset<lr> info;
bool vis[N];
int main() {
  int ans = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int x, y, ty;
    scanf("%d%d%d", &x, &y, &ty);
    add(x, y, !ty);
    add(y, x, !ty);
    ans += ty;
    e[i] = (E){x, y, !ty};
  }
  memset(f1, 63, sizeof f1);
  memset(f2, 63, sizeof f2);
  int S = 1;
  info.insert((lr){S, f1[S] = 0, f2[S] = 0});
  while (!info.empty()) {
    auto it = info.begin();
    t = *it;
    info.erase(it);
    if (vis[t.x]) continue;
    vis[t.x] = 1;
    for (int i = head[t.x]; i; i = next[i]) {
      if (f1[to[i]] > f1[t.x] + 1) {
        info.insert(
            (lr){to[i], f1[to[i]] = f1[t.x] + 1, f2[to[i]] = f2[t.x] + c[i]});
        fa[to[i]] = t.x;
        fe[to[i]] = i >> 1;
      } else if (f1[to[i]] == f1[t.x] + 1 && f2[to[i]] > f2[t.x] + c[i]) {
        info.insert((lr){to[i], f1[to[i]], f2[to[i]] = f2[t.x] + c[i]});
        fa[to[i]] = t.x;
        fe[to[i]] = i >> 1;
      }
    }
  }
  memset(vis, 0, sizeof vis);
  for (int i = n; i != 1; i = fa[i]) vis[fe[i]] = 1;
  printf("%d\n", ans - f1[n] + 2 * f2[n]);
  for (int i = 1; i <= m; ++i) {
    if (!vis[i] && !e[i].ty)
      e[i].print();
    else if (vis[i] && e[i].ty)
      e[i].print();
  }
}

```


### Prompt

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

There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet — the memory manager is among them. According to the developers' plan, in the first release the memory manager will be very simple and rectilinear. It will support three operations:

  * alloc n — to allocate n bytes of the memory and return the allocated block's identifier x;
  * erase x — to erase the block with the identifier x;
  * defragment — to defragment the free memory, bringing all the blocks as close to the beginning of the memory as possible and preserving their respective order;

The memory model in this case is very simple. It is a sequence of m bytes, numbered for convenience from the first to the m-th.

The first operation alloc n takes as the only parameter the size of the memory block that is to be allocated. While processing this operation, a free block of n successive bytes is being allocated in the memory. If the amount of such blocks is more than one, the block closest to the beginning of the memory (i.e. to the first byte) is prefered. All these bytes are marked as not free, and the memory manager returns a 32-bit integer numerical token that is the identifier of this block. If it is impossible to allocate a free block of this size, the function returns NULL.

The second operation erase x takes as its parameter the identifier of some block. This operation frees the system memory, marking the bytes of this block as free for further use. In the case when this identifier does not point to the previously allocated block, which has not been erased yet, the function returns ILLEGAL_ERASE_ARGUMENT.

The last operation defragment does not have any arguments and simply brings the occupied memory sections closer to the beginning of the memory without changing their respective order.

In the current implementation you are to use successive integers, starting with 1, as identifiers. Each successful alloc operation procession should return following number. Unsuccessful alloc operations do not affect numeration.

You are to write the implementation of the memory manager. You should output the returned value for each alloc command. You should also output ILLEGAL_ERASE_ARGUMENT for all the failed erase commands.

Input

The first line of the input data contains two positive integers t and m (1 ≤ t ≤ 100;1 ≤ m ≤ 100), where t — the amount of operations given to the memory manager for processing, and m — the available memory size in bytes. Then there follow t lines where the operations themselves are given. The first operation is alloc n (1 ≤ n ≤ 100), where n is an integer. The second one is erase x, where x is an arbitrary 32-bit integer numerical token. The third operation is defragment.

Output

Output the sequence of lines. Each line should contain either the result of alloc operation procession , or ILLEGAL_ERASE_ARGUMENT as a result of failed erase operation procession. Output lines should go in the same order in which the operations are processed. Successful procession of alloc operation should return integers, starting with 1, as the identifiers of the allocated blocks.

Examples

Input

6 10
alloc 5
alloc 3
erase 1
alloc 6
defragment
alloc 6

Output

1
2
NULL
3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int l[101], r[101], n, x, t, cnt;
bool a[101], al[101];
bool canput(int l, int r) {
  for (int i = l; i <= r; i++) {
    if (a[i]) return 0;
  }
  return 1;
}
void alloc() {
  cin >> x;
  for (int i = 1; i <= n - x + 1; i++) {
    if (canput(i, i + x - 1)) {
      cout << ++cnt << endl;
      l[cnt] = i, r[cnt] = i + x - 1;
      for (int j = l[cnt]; j <= r[cnt]; j++) a[j] = 1;
      al[cnt] = 1;
      return;
    }
  }
  printf("NULL\n");
  return;
}
void erase() {
  cin >> x;
  if (x > cnt || x < 1 || !al[x]) {
    printf("ILLEGAL_ERASE_ARGUMENT\n");
    return;
  }
  for (int j = l[x]; j <= r[x]; j++) a[j] = 0;
  l[x] = r[x] = 0;
  al[x] = 0;
  return;
}
void deflagment() {
  for (int i = 1; i <= cnt; i++) {
    if (al[i]) {
      for (int j = l[i]; j <= r[i]; j++) a[j] = 0;
      while (a[l[i] - 1] == 0 && l[i] > 1) {
        l[i]--;
        r[i]--;
      }
      for (int j = l[i]; j <= r[i]; j++) a[j] = 1;
    }
  }
  return;
}
int main() {
  cin >> t >> n;
  for (int i = 1; i <= t; i++) {
    string s;
    cin >> s;
    if (s[0] == 'a') alloc();
    if (s[0] == 'e') erase();
    if (s[0] == 'd') deflagment();
  }
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself, decides he wants to shuffle the guests around because he thinks this will create a vacancy (a room without a guest).

For any integer k and positive integer n, let kmod n denote the remainder when k is divided by n. More formally, r=kmod n is the smallest non-negative integer such that k-r is divisible by n. It always holds that 0≤ kmod n≤ n-1. For example, 100mod 12=4 and (-1337)mod 3=1.

Then the shuffling works as follows. There is an array of n integers a_0,a_1,…,a_{n-1}. Then for each integer k, the guest in room k is moved to room number k+a_{kmod n}.

After this shuffling process, determine if there is still exactly one guest assigned to each room. That is, there are no vacancies or rooms with multiple guests.

Input

Each test consists of multiple test cases. The first line contains a single integer t (1≤ t≤ 10^4) — the number of test cases. Next 2t lines contain descriptions of test cases.

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

The second line of each test case contains n integers a_0,a_1,…,a_{n-1} (-10^9≤ a_i≤ 10^9).

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

Output

For each test case, output a single line containing "YES" if there is exactly one guest assigned to each room after the shuffling process, or "NO" otherwise. You can print each letter in any case (upper or lower).

Example

Input

6
1
14
2
1 -1
4
5 5 5 1
3
3 2 1
2
0 1
5
-239 -2 -100 -3 -11

Output

YES
YES
YES
NO
NO
YES

Note

In the first test case, every guest is shifted by 14 rooms, so the assignment is still unique.

In the second test case, even guests move to the right by 1 room, and odd guests move to the left by 1 room. We can show that the assignment is still unique.

In the third test case, every fourth guest moves to the right by 1 room, and the other guests move to the right by 5 rooms. We can show that the assignment is still unique.

In the fourth test case, guests 0 and 1 are both assigned to room 3.

In the fifth test case, guests 1 and 2 are both assigned to room 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long x = 0, f = 0, j, q = 1, i, n, m, k;
  cin >> q;
  while (q--) {
    x = 0;
    cin >> n;
    vector<long long> a(n);
    unordered_map<long long, long long> m;
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i <= n - 1; i++) m[(i + (a[i] % n) + n) % n]++;
    for (auto i : m)
      if (i.second > 1) x = -1;
    if (x == 0)
      cout << "YES";
    else
      cout << "NO";
    cout << "\n";
  }
}

```


### Prompt

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

Emuskald is a well-known illusionist. One of his trademark tricks involves a set of magical boxes. The essence of the trick is in packing the boxes inside other boxes.

From the top view each magical box looks like a square with side length equal to 2k (k is an integer, k ≥ 0) units. A magical box v can be put inside a magical box u, if side length of v is strictly less than the side length of u. In particular, Emuskald can put 4 boxes of side length 2k - 1 into one box of side length 2k, or as in the following figure:

<image>

Emuskald is about to go on tour performing around the world, and needs to pack his magical boxes for the trip. He has decided that the best way to pack them would be inside another magical box, but magical boxes are quite expensive to make. Help him find the smallest magical box that can fit all his boxes.

Input

The first line of input contains an integer n (1 ≤ n ≤ 105), the number of different sizes of boxes Emuskald has. Each of following n lines contains two integers ki and ai (0 ≤ ki ≤ 109, 1 ≤ ai ≤ 109), which means that Emuskald has ai boxes with side length 2ki. It is guaranteed that all of ki are distinct.

Output

Output a single integer p, such that the smallest magical box that can contain all of Emuskald’s boxes has side length 2p.

Examples

Input

2
0 3
1 5

Output

3

Input

1
0 4

Output

1

Input

2
1 10
2 2

Output

3

Note

Picture explanation. If we have 3 boxes with side length 2 and 5 boxes with side length 1, then we can put all these boxes inside a box with side length 4, for example, as shown in the picture.

In the second test case, we can put all four small boxes into a box with side length 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void pack(int &k, int &a, int nk, int na) {
  int tk = k, ta = a;
  while (tk < nk && ta > 1) {
    tk++;
    ta = (ta + 3) / 4;
  }
  k = nk;
  if (ta <= na) {
    a = na;
  } else {
    a = ta;
  }
}
int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    int k, a;
    cin >> k >> a;
    v.push_back(make_pair(k, a));
  }
  sort(v.begin(), v.end());
  int k = 0, a = 0;
  for (int i = 0; i < (int)(v.size()); i++) {
    pack(k, a, v[i].first, v[i].second);
  }
  do {
    k++;
    a = (a + 3) / 4;
  } while (a > 1);
  cout << k << endl;
  return EXIT_SUCCESS;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Programmer Vasya is studying a new programming language &K*. The &K* language resembles the languages of the C family in its syntax. However, it is more powerful, which is why the rules of the actual C-like languages are unapplicable to it. To fully understand the statement, please read the language's description below carefully and follow it and not the similar rules in real programming languages.

There is a very powerful system of pointers on &K* — you can add an asterisk to the right of the existing type X — that will result in new type X * . That is called pointer-definition operation. Also, there is the operation that does the opposite — to any type of X, which is a pointer, you can add an ampersand — that will result in a type &X, to which refers X. That is called a dereference operation.

The &K* language has only two basic data types — void and errtype. Also, the language has operators typedef and typeof.

  * The operator "typedef A B" defines a new data type B, which is equivalent to A. A can have asterisks and ampersands, and B cannot have them. For example, the operator typedef void** ptptvoid will create a new type ptptvoid, that can be used as void**.
  * The operator "typeof A" returns type of A, brought to void, that is, returns the type void**...*, equivalent to it with the necessary number of asterisks (the number can possibly be zero). That is, having defined the ptptvoid type, as shown above, the typeof ptptvoid operator will return void**.

An attempt of dereferencing of the void type will lead to an error: to a special data type errtype. For errtype the following equation holds true: errtype* = &errtype = errtype. An attempt to use the data type that hasn't been defined before that will also lead to the errtype.

Using typedef, we can define one type several times. Of all the definitions only the last one is valid. However, all the types that have been defined earlier using this type do not change.

Let us also note that the dereference operation has the lower priority that the pointer operation, in other words &T *  is always equal to T.

Note, that the operators are executed consecutively one by one. If we have two operators "typedef &void a" and "typedef a* b", then at first a becomes errtype, and after that b becomes errtype* = errtype, but not &void* = void (see sample 2).

Vasya does not yet fully understand this powerful technology, that's why he asked you to help him. Write a program that analyzes these operators.

Input

The first line contains an integer n (1 ≤ n ≤ 100) — the number of operators. Then follow n lines with operators. Each operator is of one of two types: either "typedef A B", or "typeof A". In the first case the B type differs from void and errtype types, and besides, doesn't have any asterisks and ampersands.

All the data type names are non-empty lines of no more than 20 lowercase Latin letters. The number of asterisks and ampersands separately in one type in any operator does not exceed 10, however if we bring some types to void with several asterisks, their number may exceed 10.

Output

For every typeof operator print on the single line the answer to that operator — the type that the given operator returned.

Examples

Input

5
typedef void* ptv
typeof ptv
typedef &&ptv node
typeof node
typeof &ptv

Output

void*
errtype
void

Input

17
typedef void* b
typedef b* c
typeof b
typeof c
typedef &b b
typeof b
typeof c
typedef &&b* c
typeof c
typedef &b* c
typeof c
typedef &void b
typeof b
typedef b******* c
typeof c
typedef &&b* c
typeof c

Output

void*
void**
void
void**
errtype
void
errtype
errtype
errtype

Note

Let's look at the second sample.

After the first two queries typedef the b type is equivalent to void*, and с — to void**.

The next query typedef redefines b — it is now equal to &b = &void* = void. At that, the с type doesn't change.

After that the с type is defined as &&b* = &&void* = &void = errtype. It doesn't influence the b type, that's why the next typedef defines c as &void* = void.

Then the b type is again redefined as &void = errtype.

Please note that the c type in the next query is defined exactly as errtype******* = errtype, and not &void******* = void******. The same happens in the last typedef.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF32 = 1E9;
const long long INF64 = 4E18;
const long long M = 1E9 + 7;
const double EPS = 1E-9;
const double PI = 2 * acos(0);
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& p) {
  os << "[ ";
  for (T x : p) os << x << " ";
  os << "]" << '\n';
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& p) {
  os << "{ ";
  for (T x : p) os << x << " ";
  os << "}" << '\n';
  return os;
}
template <typename Tk, typename Tv>
ostream& operator<<(ostream& os, const map<Tk, Tv>& p) {
  os << "{ ";
  for (pair<Tk, Tv> x : p) os << x << " ";
  os << "}" << '\n';
  return os;
}
template <typename Tk, typename Tv>
ostream& operator<<(ostream& os, const pair<Tk, Tv>& p) {
  os << "{" << p.first << ',' << p.second << "}";
  return os;
}
void strip(string& old_type, int& star, int& amper) {
  int start = -1, length = 0;
  for (int i = 0; i < (int)old_type.size(); ++i) {
    if (old_type[i] == '*') {
      star++;
    } else if (old_type[i] == '&') {
      amper++;
    } else {
      if (start == -1) start = i;
      length++;
    }
  }
  old_type = old_type.substr(start, length);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  if (fopen("tupni.txt", "r")) {
    freopen("tupni.txt", "r", stdin);
    freopen("tuptuo.txt", "w", stdout);
  }
  int n;
  cin >> n;
  map<string, int> cnt;
  cnt["void"] = 0;
  for (int t = 0; t < n; ++t) {
    string query;
    cin >> query;
    if (query == "typeof") {
      string expression;
      cin >> expression;
      int star = 0, amper = 0;
      strip(expression, star, amper);
      if ((cnt.find(expression) != cnt.end()) and cnt[expression] != -1) {
        int value = cnt[expression] + star - amper;
        if (value < 0) {
          cout << "errtype" << '\n';
        } else {
          cout << "void" << string(value, '*') << '\n';
        }
      } else {
        cout << "errtype" << '\n';
      }
    } else {
      string old_type, new_type;
      cin >> old_type >> new_type;
      int star = 0, amper = 0;
      strip(old_type, star, amper);
      if ((cnt.find(old_type) != cnt.end()) and cnt[old_type] != -1) {
        cnt[new_type] = cnt[old_type] + star - amper;
        if (cnt[new_type] < 0) {
          cnt[new_type] = -1;
        }
      } else {
        cnt[new_type] = -1;
      }
    }
  }
  return 0;
}

```


### Prompt

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

Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement.

Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve.

A wonder strikes Tommy. How many regions are formed by the circles on the sky? We consider the sky as a flat plane. A region is a connected part of the plane with positive area, whose bound consists of parts of bounds of the circles and is a curve or several curves without self-intersections, and that does not contain any curve other than its boundaries. Note that exactly one of the regions extends infinitely.

Input

The first line of input contains one integer n (1 ≤ n ≤ 3), denoting the number of circles.

The following n lines each contains three space-separated integers x, y and r ( - 10 ≤ x, y ≤ 10, 1 ≤ r ≤ 10), describing a circle whose center is (x, y) and the radius is r. No two circles have the same x, y and r at the same time.

Output

Print a single integer — the number of regions on the plane.

Examples

Input

3
0 0 1
2 0 1
4 0 1

Output

4

Input

3
0 0 2
3 0 2
6 0 2

Output

6

Input

3
0 0 2
2 0 2
1 1 2

Output

8

Note

For the first example,

<image>

For the second example,

<image>

For the third example,

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
double INF = 1e100;
double EPS = 1e-9;
struct PT {
  double x, y;
  PT() {}
  PT(double x, double y) : x(x), y(y) {}
  PT(const PT &p) : x(p.x), y(p.y) {}
  PT operator+(const PT &p) const { return PT(x + p.x, y + p.y); }
  PT operator-(const PT &p) const { return PT(x - p.x, y - p.y); }
  PT operator*(double c) const { return PT(x * c, y * c); }
  PT operator/(double c) const { return PT(x / c, y / c); }
};
double dot(PT p, PT q) { return p.x * q.x + p.y * q.y; }
double dist2(PT p, PT q) { return dot(p - q, p - q); }
double cross(PT p, PT q) { return p.x * q.y - p.y * q.x; }
PT RotateCCW90(PT p) { return PT(-p.y, p.x); }
PT RotateCW90(PT p) { return PT(p.y, -p.x); }
PT RotateCCW(PT p, double t) {
  return PT(p.x * cos(t) - p.y * sin(t), p.x * sin(t) + p.y * cos(t));
}
vector<PT> CircleCircleIntersection(PT a, PT b, double r, double R) {
  vector<PT> ret;
  double d = sqrt(dist2(a, b));
  if (d > r + R || d + min(r, R) < max(r, R)) return ret;
  double x = (d * d - R * R + r * r) / (2 * d);
  double y = sqrt(r * r - x * x);
  PT v = (b - a) / d;
  ret.push_back(a + v * x + RotateCCW90(v) * y);
  if (y > 0) ret.push_back(a + v * x - RotateCCW90(v) * y);
  return ret;
}
const int N = 505;
int vis[N];
int edge[N][N];
PT C[N];
double R[N];
int compare(PT a, PT b) {
  return abs(a.x - b.x) < EPS and abs(a.y - b.y) < EPS;
}
bool cmp(PT a, PT b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}
int uniq(vector<PT> &V) {
  sort(V.begin(), V.end(), cmp);
  if (V.size() == 0) return 0;
  int ans = 1;
  for (int i = 1; i < V.size(); i++) {
    if (compare(V[i], V[i - 1]) == 0) ans++;
  }
  return ans;
}
void dfs(int u) {
  vis[u] = 1;
  for (int i = 1; i <= 500; i++) {
    if (edge[u][i] == 1 and vis[i] == 0) {
      dfs(i);
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> C[i].x >> C[i].y >> R[i];
  }
  int ans = 0;
  vector<PT> all;
  int e = 0, v = 0, c = 0;
  for (int i = 1; i <= n; i++) {
    vector<PT> V;
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      vector<PT> inter = CircleCircleIntersection(C[i], C[j], R[i], R[j]);
      if (inter.size() > 0) edge[i][j] = 1;
      for (int k = 0; k < inter.size(); k++)
        V.push_back(inter[k]), all.push_back(inter[k]);
    }
    e += uniq(V);
  }
  v = uniq(all);
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      dfs(i);
      c++;
    }
  }
  printf("%d\n", e - v + c + 1);
}

```


### Prompt

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

<image>

Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.

The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.

Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.

Input

In the first string, the number of games n (1 ≤ n ≤ 350000) is given.

Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.

Output

For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise.

You can output each letter in arbitrary case (upper or lower).

Example

Input

6
2 4
75 45
8 8
16 16
247 994
1000000000 1000000

Output

Yes
Yes
Yes
No
No
Yes

Note

First game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.

The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;
ll INF = 1LL << 60;
ll HI = 1000005;
ll cubic_root(ll x) {
  ll lo = 0, hi = HI;
  while (lo < hi) {
    ll m = lo + ((hi - lo + 1) / 2);
    if (m * m * m > x)
      hi = m - 1;
    else
      lo = m;
  }
  return lo;
}
ll a, b, ab, cuberoot;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  while (n--) {
    cin >> a >> b;
    ab = a * b;
    cuberoot = cubic_root(ab);
    if (cuberoot * cuberoot * cuberoot != ab) {
      cout << "No\n";
      continue;
    }
    if (a % cuberoot == 0 && b % cuberoot == 0) {
      cout << "Yes\n";
      continue;
    }
    cout << "No\n";
  }
}

```


### Prompt

Create a solution in cpp for the following problem:

Maxim wants to buy an apartment in a new house at Line Avenue of Metropolis. The house has n apartments that are numbered from 1 to n and are arranged in a row. Two apartments are adjacent if their indices differ by 1. Some of the apartments can already be inhabited, others are available for sale.

Maxim often visits his neighbors, so apartment is good for him if it is available for sale and there is at least one already inhabited apartment adjacent to it. Maxim knows that there are exactly k already inhabited apartments, but he doesn't know their indices yet.

Find out what could be the minimum possible and the maximum possible number of apartments that are good for Maxim.

Input

The only line of the input contains two integers: n and k (1 ≤ n ≤ 109, 0 ≤ k ≤ n).

Output

Print the minimum possible and the maximum possible number of apartments good for Maxim.

Example

Input

6 3

Output

1 3

Note

In the sample test, the number of good apartments could be minimum possible if, for example, apartments with indices 1, 2 and 3 were inhabited. In this case only apartment 4 is good. The maximum possible number could be, for example, if apartments with indices 1, 3 and 5 were inhabited. In this case all other apartments: 2, 4 and 6 are good.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, k;
int main() {
  scanf("%lld%lld", &n, &k);
  if (k == 0 || k == n) {
    printf("0 0\n");
    return 0;
  }
  long long minx = 1;
  long long maxx = 0;
  if (3 * k < n) {
    maxx = 2 * k;
  } else {
    long long d = n / 3;
    maxx += 2 * d;
    if (n % 3 == 2) maxx++;
    if (n % 3 != 0) d++;
    maxx -= k - d;
  }
  printf("%lld %lld\n", minx, maxx);
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

In some country live wizards. They love to ride trolleybuses.

A city in this country has a trolleybus depot with n trolleybuses. Every day the trolleybuses leave the depot, one by one and go to the final station. The final station is at a distance of d meters from the depot. We know for the i-th trolleybus that it leaves at the moment of time ti seconds, can go at a speed of no greater than vi meters per second, and accelerate with an acceleration no greater than a meters per second squared. A trolleybus can decelerate as quickly as you want (magic!). It can change its acceleration as fast as you want, as well. Note that the maximum acceleration is the same for all trolleys.

Despite the magic the trolleys are still powered by an electric circuit and cannot overtake each other (the wires are to blame, of course). If a trolleybus catches up with another one, they go together one right after the other until they arrive at the final station. Also, the drivers are driving so as to arrive at the final station as quickly as possible.

You, as head of the trolleybuses' fans' club, are to determine for each trolley the minimum time by which it can reach the final station. At the time of arrival at the destination station the trolleybus does not necessarily have zero speed. When a trolley is leaving the depot, its speed is considered equal to zero. From the point of view of physics, the trolleybuses can be considered as material points, and also we should ignore the impact on the speed of a trolley bus by everything, except for the acceleration and deceleration provided by the engine.

Input

The first input line contains three space-separated integers n, a, d (1 ≤ n ≤ 105, 1 ≤ a, d ≤ 106) — the number of trolleybuses, their maximum acceleration and the distance from the depot to the final station, correspondingly.

Next n lines contain pairs of integers ti vi (0 ≤ t1 < t2... < tn - 1 < tn ≤ 106, 1 ≤ vi ≤ 106) — the time when the i-th trolleybus leaves the depot and its maximum speed, correspondingly. The numbers in the lines are separated by spaces.

Output

For each trolleybus print a single line the time it arrives to the final station. Print the times for the trolleybuses in the order in which the trolleybuses are given in the input. The answer will be accepted if the absolute or relative error doesn't exceed 10 - 4.

Examples

Input

3 10 10000
0 10
5 11
1000 1

Output

1000.5000000000
1000.5000000000
11000.0500000000

Input

1 2 26
28 29

Output

33.0990195136

Note

In the first sample the second trolleybus will catch up with the first one, that will happen at distance 510.5 meters from the depot. The trolleybuses will go the remaining 9489.5 meters together at speed 10 meters per second. As a result, both trolleybuses will arrive to the final station by the moment of time 1000.5 seconds. The third trolleybus will not catch up with them. It will arrive to the final station by the moment of time 11000.05 seconds.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, a, d;
double pret = 0;
int main(void) {
  int t, v;
  double curt;
  scanf("%d%d%d", &n, &a, &d);
  while (n--) {
    scanf("%d%d", &t, &v);
    double dis1 = ((double)v) * v / a / 2;
    if (dis1 >= d) {
      curt = sqrt(((double)2 * d) / a);
    } else {
      curt = ((double)v) / a + (d - dis1) / v;
    }
    curt += t;
    if (curt < pret) {
      curt = pret;
    }
    printf("%.10lf\n", curt);
    pret = curt;
  }
  scanf("%*d");
  return 0;
}

```


### Prompt

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

As a result of Pinky and Brain's mysterious experiments in the Large Hadron Collider some portals or black holes opened to the parallel dimension. And the World Evil has crept to the veil between their world and ours. Brain quickly evaluated the situation and he understood that the more evil tentacles creep out and become free, the higher is the possibility that Brain will rule the world.

The collider's constriction is a rectangular grid rolled into a cylinder and consisting of n rows and m columns such as is shown in the picture below:

<image>

In this example n = 4, m = 5. Dotted lines are corridores that close each column to a ring, i. e. connect the n-th and the 1-th rows of the grid.

In the leftmost column of the grid the portals are situated and the tentacles of the World Evil are ready to creep out from there. In the rightmost column the exit doors are located. The tentacles can only get out through those doors. The segments joining the nodes of the grid are corridors.

Brain would be glad to let all the tentacles out but he faces a problem: the infinite number of tentacles can creep out of the portals, every tentacle possesses infinite length and some width and the volume of the corridors are, unfortunately, quite limited. Brain could approximately evaluate the maximal number of tentacles that will be able to crawl through every corridor.

Now help the mice to determine the maximal number of tentacles of the World Evil that will crawl out of the Large Hadron Collider.

Input

The first line of the input file contains two integers n and m (2 ≤ n ≤ 5, 2 ≤ m ≤ 105). They are the sizes of the Large Hadron Collider grid. The next m - 1 lines contain n numbers each. They are the horizontal corridors' capacities. The next m lines contain n numbers each. They are the vertical corridors' capacities. Corridors are described from left to right and from top to bottom. Every n-th vertical corridor connects nodes of the n-th and 1-th rows. A corridor's capacity is a non-negative integer that does not exceed 109.

Output

Print a single number, the number of the World Evil tentacles Pinky and Brain will command.

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

Examples

Input

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

Output

7

Input

2 2
9 2
2 3
6 1

Output

11

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N(5), M(100010);
const long long INF(1LL << 60);
int n, m;
int st[1 << N][1 << N];
long long f[2][1 << N];
int hor[M][N], ver[M][N];
int bit(int x, int y) { return (x >> y) & 1; }
int pre(int x) { return (x + n - 1) % n; }
int nxt(int x) { return (x + 1) % n; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = int(0); i < int(m - 1); ++i)
    for (int j = int(0); j < int(n); ++j) scanf("%d", &hor[i][j]);
  for (int i = int(0); i < int(m); ++i)
    for (int j = int(0); j < int(n); ++j) scanf("%d", &ver[i][j]);
  for (int i = int(0); i < int(1 << n); ++i) f[0][i] = INF;
  f[0][(1 << n) - 1] = 0;
  int c = 0;
  for (int i = int(0); i < int(1 << n); ++i)
    for (int j = int(0); j < int(1 << n); ++j) {
      int s = i;
      for (int k = int(0); k < int(n); ++k)
        if (bit(s, k)) {
          for (int x = k; !bit(s, nxt(x)) && bit(j, x); x = nxt(x), s |= 1 << x)
            ;
          for (int x = k; !bit(s, pre(x)) && bit(j, pre(x));
               x = pre(x), s |= 1 << x)
            ;
        }
      st[i][j] = s;
    }
  for (int i = int(0); i < int(m - 1); ++i) {
    for (int j = int(0); j < int(1 << n); ++j) f[c ^ 1][j] = INF;
    for (int j = int(0); j < int(1 << n); ++j) {
      long long w = 0;
      for (int k = int(0); k < int(n); ++k)
        if (!bit(j, k)) w += hor[i][k];
      for (int k = int(0); k < int(1 << n); ++k)
        f[c ^ 1][j & k] = min(f[c ^ 1][j & k], f[c][k] + w);
    }
    c ^= 1;
    for (int j = int(0); j < int(1 << n); ++j) f[c ^ 1][j] = INF;
    for (int j = int(0); j < int(1 << n); ++j) {
      long long w = 0;
      for (int k = int(0); k < int(n); ++k)
        if (!bit(j, k)) w += ver[i + 1][k];
      for (int k = int(0); k < int(1 << n); ++k)
        f[c ^ 1][st[k][j]] = min(f[c ^ 1][st[k][j]], f[c][k] + w);
    }
    c ^= 1;
  }
  cout << f[c][0] << endl;
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments.

He chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numbered from 1 to n in a clockwise way. PolandBall repeats the following process n times, starting from the vertex 1:

Assume you've ended last operation in vertex x (consider x = 1 if it is the first operation). Draw a new segment from vertex x to k-th next vertex in clockwise direction. This is a vertex x + k or x + k - n depending on which of these is a valid index of polygon's vertex.

Your task is to calculate number of polygon's sections after each drawing. A section is a clear area inside the polygon bounded with drawn diagonals or the polygon's sides.

Input

There are only two numbers in the input: n and k (5 ≤ n ≤ 106, 2 ≤ k ≤ n - 2, gcd(n, k) = 1).

Output

You should print n values separated by spaces. The i-th value should represent number of polygon's sections after drawing first i lines.

Examples

Input

5 2

Output

2 3 5 8 11

Input

10 3

Output

2 3 4 6 9 12 16 21 26 31

Note

The greatest common divisor (gcd) of two integers a and b is the largest positive integer that divides both a and b without a remainder.

For the first sample testcase, you should output "2 3 5 8 11". Pictures below correspond to situations after drawing lines.

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:255000000")
bool firstout = 1;
vector<string> split(const string &s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\n';
  err(++it, args...);
}
template <class T>
T &minn(T &a, T b) {
  if (b < a) a = b;
  return a;
}
template <class T>
T &maxx(T &a, T b) {
  if (a < b) a = b;
  return a;
}
int &madd(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
int &msub(int &a, int b) {
  a -= b;
  if (a < 0) a += 1000000007;
  return a;
}
int &mmult(int &a, int b) { return a = (long long)a * b % 1000000007; }
int mdiv(long long a, long long b, long long m) {
  a = (a % m + m) % m;
  b = (b % m + m) % m;
  if (a % b == 0) return a / b;
  return (a + m * mdiv(-a, m, b)) / b;
}
int n, m, q;
int nt;
int L[4012345], R[4012345];
int A[4012345];
int B[4012345];
int fndt(int i, int l, int r) {
  maxx(l, L[i]);
  minn(r, R[i]);
  if (l > r) return 0;
  if (L[i] == l && R[i] == r) return A[i];
  return fndt(i + i, l, r) + fndt(i + i + 1, l, r);
}
int main() {
  int i, j, k;
  char c;
  int a, d;
  int ts;
  for (ts = 1; scanf("%"
                     "d",
                     &(n)) > 0;
       ++ts) {
    scanf(
        "%"
        "d",
        &(m));
    nt = n;
    if (m > n / 2) m = n - m;
    for (; nt & (nt - 1); ++nt)
      ;
    for (i = (0); i < (nt + nt); ++i) A[i] = 0;
    for (i = (nt); i < (nt + nt); ++i) L[i] = R[i] = i - nt;
    for (i = (nt)-1; i >= (1); --i) L[i] = L[i + i], R[i] = R[i + i + 1];
    for (i = (0); i < (n); ++i) B[i] = 0;
    long long res = 1;
    for (i = 0; !B[i]; i = (i + m) % n) {
      int l = (i + 1) % n;
      j = (i + m - 1) % n;
      ++res;
      if (l <= j)
        res += fndt(1, l, j);
      else
        res += fndt(1, l, n) + fndt(1, 0, j);
      printf((firstout) ? "%"
                          "I64d"
                        : " %"
                          "I64d",
             (res)),
          firstout = 0;
      j = nt + i;
      for (; j; j /= 2) ++A[j];
      j = nt + (i + m) % n;
      for (; j; j /= 2) ++A[j];
      B[i] = 1;
    }
    printf("\n"), firstout = 1;
  }
  return 0;
}

```