### Prompt

Please formulate a Cpp solution to the following problem:

Nukes has an integer that can be represented as the bitwise OR of one or more integers between A and B (inclusive). How many possible candidates of the value of Nukes's integer there are?

Constraints

* 1 ≤ A ≤ B < 2^{60}
* A and B are integers.

Input

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

A
B

Output

Print the number of possible candidates of the value of Nukes's integer.

Examples

Input

7
9

Output

4

Input

65
98

Output

63

Input

271828182845904523
314159265358979323

Output

68833183630578410

### Response

```cpp
#include<iostream>
using namespace std;
long long a,b,r,A;
int main()
{
	cin>>a>>b;
	if(a==b)
	{
		cout<<1;
		return 0;
	}
	for(int i=59;i>=0;i--)
		if((a>>i)!=(b>>i))
			r=i,i=0;
		else if(a>>i&1)
			a^=((long long)1<<i),b^=((long long)1<<i);
	for(int i=0;i<r;i++)
		if(b>>i&1)
			A=((long long)2<<i)-1;
	cout<<((long long)2<<r)+A-a-max(A+1,a)+1;
	return 0;
}
```


### Prompt

Please formulate a Cpp solution to the following problem:

One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. Then she wanted to check if she had arranged the numbers correctly, but at this point her younger sister Maria came and shuffled all numbers. Anna got sick with anger but what's done is done and the results of her work had been destroyed. But please tell Anna: could she have hypothetically completed the task using all those given numbers?

Input

The first line contains an integer n — how many numbers Anna had (3 ≤ n ≤ 105). The next line contains those numbers, separated by a space. All numbers are integers and belong to the range from 1 to 109.

Output

Print the single line "YES" (without the quotes), if Anna could have completed the task correctly using all those numbers (using all of them is necessary). If Anna couldn't have fulfilled the task, no matter how hard she would try, print "NO" (without the quotes).

Examples

Input

4
1 2 3 2

Output

YES

Input

6
1 1 2 2 2 3

Output

YES

Input

6
2 4 1 1 2 2

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int a[n], c[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int b[n + 1];
  memset(b, 0, sizeof(b));
  int first = 0;
  for (int i = 0; i < n; i++) {
    if (i && a[i] - a[i - 1] > 1) {
      cout << "NO";
      return 0;
    }
    if (!i || a[i] != a[i - 1]) {
      first++;
    }
    c[i] = first;
  }
  int l = 1, r = first;
  for (int i = 0; i < n; i++) {
    b[c[i]]++;
  }
  a[0] = first;
  b[first]--;
  for (int i = 1; i < n; i++) {
    int first = a[i - 1];
    if (b[first - 1]) {
      a[i] = first - 1;
      b[first - 1]--;
    } else if (b[first + 1]) {
      a[i] = first + 1;
      b[first + 1]--;
    } else {
      cout << "NO";
      return 0;
    }
  }
  cout << (abs(a[0] - a[n - 1]) == 1 ? "YES" : "NO");
}

```


### Prompt

Please create a solution in Cpp to the following problem:

problem

Cryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet.

The ciphertext consists of the $ N $ character string $ S $, and the $ S_i $ character determines the direction of movement from the current location. The direction of movement is as follows.

* A ~ M: Go north one square.
* N ~ Z: Go south one square.
* a ~ m: Go east one square.
* n ~ z: Go west one square.

By the way, xryuseix wanted to tell yryuseiy-chan where to meet for a date with a ciphertext, but he noticed that the ciphertext was redundant.

For example, suppose you have the ciphertext "ANA". It goes north by $ 1 $, south by $ 1 $, and then north by $ 1 $. This is equivalent to the ciphertext that goes north by $ 1 $. , "ANA" = "A", which can be simplified. Xryuseix wanted to simplify the ciphertext so that yryuseiy would not make a detour.

So you decided to write a program to simplify the ciphertext instead of xryuseix. Note that "simplify the ciphertext" means "the shortest ciphertext that goes to the same destination as the original ciphertext." To make. "

output

The length of the ciphertext after simplification on the $ 1 $ line, output the ciphertext on the $ 2 $ line. If there are multiple possible ciphertexts as an answer, any of them may be output. Also, each line Output a line break at the end of.

Example

Input

5
ANazA

Output

1
A

### Response

```cpp
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int main(){
  int N;
  string s;

  cin >> N >> s;

  int x = 0, y = 0;

  for(int i=0; i<N; i++) {
    if ('A' <= s[i] && s[i] <= 'M') y--;
    if ('N' <= s[i] && s[i] <= 'Z') y++;
    if ('a' <= s[i] && s[i] <= 'm') x++;
    if ('n' <= s[i] && s[i] <= 'z') x--;
  }

  string ans;

  for(int i=0; i<abs(y); i++) {
    if (y < 0) ans += "A";
    else ans += "Z";
  }

  for(int i=0; i<abs(x); i++) {
    if (x > 0) ans += "a";
    else ans += "z";
  }

  cout << ans.size() << endl;
  cout << ans << endl;

  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Vasya bought the collected works of a well-known Berland poet Petya in n volumes. The volumes are numbered from 1 to n. He thinks that it does not do to arrange the book simply according to their order. Vasya wants to minimize the number of the disposition’s divisors — the positive integers i such that for at least one j (1 ≤ j ≤ n) is true both: j mod i = 0 and at the same time p(j) mod i = 0, where p(j) is the number of the tome that stands on the j-th place and mod is the operation of taking the division remainder. Naturally, one volume can occupy exactly one place and in one place can stand exactly one volume.

Help Vasya — find the volume disposition with the minimum number of divisors.

Input

The first line contains number n (1 ≤ n ≤ 100000) which represents the number of volumes and free places.

Output

Print n numbers — the sought disposition with the minimum divisor number. The j-th number (1 ≤ j ≤ n) should be equal to p(j) — the number of tome that stands on the j-th place. If there are several solutions, print any of them.

Examples

Input

2

Output

2 1

Input

3

Output

1 3 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
template <class T>
T _max(T x, T y) {
  return x > y ? x : y;
}
template <class T>
T _min(T x, T y) {
  return x < y ? x : y;
}
template <class T>
T _abs(T x) {
  return (x < 0) ? -x : x;
}
template <class T>
T _mod(T x, T y) {
  return (x > 0) ? x % y : ((x % y) + y) % y;
}
template <class T>
void _swap(T& x, T& y) {
  T t = x;
  x = y;
  y = t;
}
template <class T>
void getmax(T& x, T y) {
  x = (y > x) ? y : x;
}
template <class T>
void getmin(T& x, T y) {
  x = (x < 0 || y < x) ? y : x;
}
int TS, cas = 1;
const int M = 100000 + 5;
int n;
int ret[M];
void run() {
  int i, j;
  for (i = 1, j = 2; i <= n; i += 2, j += 2) ret[i] = j;
  for (i = 2, j = 3; i <= n; i += 2, j += 2) ret[i] = j;
  ret[n] = 1;
  for (i = 1; i <= n; i++) printf("%d%c", ret[i], (i == n) ? '\n' : ' ');
}
void preSof() {}
int main() {
  preSof();
  while ((~scanf("%d", &n))) run();
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

There is a tree with N vertices numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.

Initially, each edge is painted blue. Takahashi will convert this blue tree into a red tree, by performing the following operation N-1 times:

* Select a simple path that consists of only blue edges, and remove one of those edges.
* Then, span a new red edge between the two endpoints of the selected path.

His objective is to obtain a tree that has a red edge connecting vertices c_i and d_i, for each i.

Determine whether this is achievable.

Constraints

* 2 ≤ N ≤ 10^5
* 1 ≤ a_i,b_i,c_i,d_i ≤ N
* a_i ≠ b_i
* c_i ≠ d_i
* Both input graphs are trees.

Input

Input is given from Standard Input in the following format:

N
a_1 b_1
:
a_{N-1} b_{N-1}
c_1 d_1
:
c_{N-1} d_{N-1}

Output

Print `YES` if the objective is achievable; print `NO` otherwise.

Examples

Input

3
1 2
2 3
1 3
3 2

Output

YES

Input

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

Output

YES

Input

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

Output

NO

### Response

```cpp
//Great to know you're toned in
#include <bits/stdc++.h>
using namespace std;

const int N = 100100;

int n;
set<int> g[N];
int p[N];

int get(int x) {
    if (p[x] == -1) {
        return x;
    }
    return p[x] = get(p[x]);
}

int main() {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].insert(b);
        g[b].insert(a);
    }

    vector<pair<int, int>> cand;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (g[a].count(b)) {
            cand.emplace_back(a, b);
        }
        g[a].insert(b);
        g[b].insert(a);
    }

    fill_n(p, n, -1);
    int cnt = 0;
    while (!cand.empty()) {
        int a, b;
        tie(a, b) = cand.back();
        cand.pop_back();
        a = get(a);
        b = get(b);
        if (a == b) {
            continue;
        }

        cnt++;

        if (g[a].size() > g[b].size()) {
            swap(a, b);
        }

        p[a] = b;

        g[a].erase(b);
        g[b].erase(a);
        for (int x: g[a]) {
            g[x].erase(a);
            if (g[x].count(b)) {
                cand.emplace_back(x, b);
            }
            g[x].insert(b);
            g[b].insert(x);
        }
        set<int>().swap(g[a]);
    }

    if (cnt == n - 1) {
        cout << "YES";
    } else {
        cout << "NO";
    }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

You are given a forest — an undirected graph with n vertices such that each its connected component is a tree.

The diameter (aka "longest shortest path") of a connected undirected graph is the maximum number of edges in the shortest path between any pair of its vertices.

You task is to add some edges (possibly zero) to the graph so that it becomes a tree and the diameter of the tree is minimal possible.

If there are multiple correct answers, print any of them.

Input

The first line contains two integers n and m (1 ≤ n ≤ 1000, 0 ≤ m ≤ n - 1) — the number of vertices of the graph and the number of edges, respectively.

Each of the next m lines contains two integers v and u (1 ≤ v, u ≤ n, v ≠ u) — the descriptions of the edges.

It is guaranteed that the given graph is a forest.

Output

In the first line print the diameter of the resulting tree.

Each of the next (n - 1) - m lines should contain two integers v and u (1 ≤ v, u ≤ n, v ≠ u) — the descriptions of the added edges.

The resulting graph should be a tree and its diameter should be minimal possible.

For m = n - 1 no edges are added, thus the output consists of a single integer — diameter of the given tree.

If there are multiple correct answers, print any of them.

Examples

Input

4 2
1 2
2 3

Output

2
4 2

Input

2 0

Output

1
1 2

Input

3 2
1 3
2 3

Output

2

Note

In the first example adding edges (1, 4) or (3, 4) will lead to a total diameter of 3. Adding edge (2, 4), however, will make it 2.

Edge (1, 2) is the only option you have for the second example. The diameter is 1.

You can't add any edges in the third example. The diameter is already 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 100;
int N, M;
bitset<MAXN> v;
vector<int> a[MAXN];
;
int p[MAXN], d[MAXN];
queue<int> x;
array<int, 2> far(int n) {
  while (not x.empty()) x.pop();
  x.push(n);
  int r;
  p[n] = -1, d[n] = 0;
  while (not x.empty()) {
    r = x.front();
    x.pop();
    v[r] = true;
    for (int u : a[r]) {
      if (p[r] == u) continue;
      p[u] = r, d[u] = d[r] + 1;
      x.push(u);
    }
  }
  return {r, d[r]};
}
array<int, 2> center(int n) {
  array<int, 2> s = far(far(n).at(0));
  int r = s.at(0);
  for (int i = 0; i << 1 < s.at(1); i++, r = p[r])
    ;
  return {r, s.at(1)};
}
vector<array<int, 2> > T;
int max(int a, int b, int c) {
  if (a < b) a = b;
  if (a < c) a = c;
  return a;
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0, u, w; i < M; i++) {
    scanf("%d%d", &u, &w);
    a[u].push_back(w);
    a[w].push_back(u);
  }
  if (M + 1 == N) {
    printf("%d\n", far(far(1).at(0)).at(1));
    return 0;
  }
  for (int i = 1; i <= N; i++) v[i] = false;
  for (int i = 1; i <= N; i++)
    if (not v[i]) T.push_back(center(i));
  assert(T.size() > 1);
  sort(T.begin(), T.end(), [](const array<int, 2>& z, const array<int, 2>& y) {
    return z.at(1) > y.at(1);
  });
  if (T.size() == 2) {
    printf(
        "%d\n%d %d\n",
        max(T[0].at(1), ((1 + T[0].at(1)) >> 1) + 1 + ((1 + T[1].at(1)) >> 1)),
        T[0].at(0), T[1].at(0));
  } else {
    printf("%d\n", max(T[0].at(1),
                       ((1 + T[0].at(1)) >> 1) + 1 + ((1 + T[1].at(1)) >> 1),
                       ((1 + T[1].at(1)) >> 1) + 2 + ((1 + T[2].at(1)) >> 1)));
    for (int i = 1; i < T.size(); i++)
      printf("%d %d\n", T[0].at(0), T[i].at(0));
  }
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

A kindergarten teacher Natalia Pavlovna has invented a new ball game. This game not only develops the children's physique, but also teaches them how to count.

The game goes as follows. Kids stand in circle. Let's agree to think of the children as numbered with numbers from 1 to n clockwise and the child number 1 is holding the ball. First the first child throws the ball to the next one clockwise, i.e. to the child number 2. Then the child number 2 throws the ball to the next but one child, i.e. to the child number 4, then the fourth child throws the ball to the child that stands two children away from him, i.e. to the child number 7, then the ball is thrown to the child who stands 3 children away from the child number 7, then the ball is thrown to the child who stands 4 children away from the last one, and so on. It should be mentioned that when a ball is thrown it may pass the beginning of the circle. For example, if n = 5, then after the third throw the child number 2 has the ball again. Overall, n - 1 throws are made, and the game ends.

The problem is that not all the children get the ball during the game. If a child doesn't get the ball, he gets very upset and cries until Natalia Pavlovna gives him a candy. That's why Natalia Pavlovna asks you to help her to identify the numbers of the children who will get the ball after each throw.

Input

The first line contains integer n (2 ≤ n ≤ 100) which indicates the number of kids in the circle.

Output

In the single line print n - 1 numbers which are the numbers of children who will get the ball after each throw. Separate the numbers by spaces.

Examples

Input

10

Output

2 4 7 1 6 2 9 7 6

Input

3

Output

2 1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int p = 1;
  for (int i = 1; i < n; i++) {
    p += i;
    p %= n;
    if (!p) p = n;
    printf("%d ", p);
  }
}

```


### Prompt

Generate a CPP solution to the following problem:

Create a program that inputs the test result data of the visual acuity test and outputs the number of people who apply to each judgment based on the following visual acuity judgment table for each of the left and right eyesight.

Judgment | Sight
--- | ---
A | 1.1 or above
B | 0.6 or more and less than 1.1
C | 0.2 or more and less than 0.6
D | less than 0.2

Input

The input is given in the following format:

l1 r1
l2 r2
l3 r3
::
::

On line i, the real number li, which represents the left visual acuity of the i-th person, and the real number ri, which represents the right visual acuity, are given, separated by blanks. However, visual acuity is 0.1 or more and 2.0 or less, and is given in 0.1 increments.

The number of lines of input does not exceed 40.

Output

Please output the judgment table in the following format.

Line 1 Left eyesight is the number of people A Right eyesight is the number of people (separated by blanks)
2nd line The number of people whose left eyesight is B The number of people whose right eyesight is B (separated by blanks)
3rd line The number of people whose left eyesight is C
4th line Number of people with left eyesight D Number of people with right eyesight D (separated by blanks)

Example

Input

1.0 1.2
0.8 1.5
1.2 0.7
2.0 2.0

Output

2 3
2 1
0 0
0 0

### Response

```cpp
#include<iostream>

using namespace std;

int main(){

	double left, right;

	int A[2] = {};
	int B[2] = {};
	int C[2] = {};
	int D[2] = {};

	while( cin >> left >> right ) {

	if( left >= 1.1) A[0] ++;
	if( 0.6 <= left && left < 1.1) B[0] ++;
	if( 0.2 <= left && left < 0.6) C[0] ++;
	if( left < 0.2) D[0] ++;

	if( right >= 1.1) A[1] ++;
	if( 0.6 <= right && right < 1.1) B[1] ++;
	if( 0.2 <= right && right < 0.6) C[1] ++;
	if( right < 0.2) D[1] ++;

}
	cout << A[0] << " " << A[1] << "\n";
	cout << B[0] << " " << B[1] << "\n";
	cout << C[0] << " " << C[1] << "\n";
	cout << D[0] << " " << D[1] << "\n";
  	return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

There are N cubes stacked vertically on a desk.

You are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is `0`, and blue if that character is `1`.

You can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.

At most how many cubes can be removed?

Constraints

* 1 \leq N \leq 10^5
* |S| = N
* Each character in S is `0` or `1`.

Input

Input is given from Standard Input in the following format:

S

Output

Print the maximum number of cubes that can be removed.

Examples

Input

0011

Output

4

Input

11011010001011

Output

12

Input

0

Output

0

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a=0,b=0;
	for(int i=0;i<(int)s.size();i++){
		if(s[i]=='0')a++;
		else b++;
	}
	cout<<min(a,b)*2<<endl;
	return 0;
}
```


### Prompt

Develop a solution in CPP to the problem described below:

DZY has a sequence a, consisting of n integers.

We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.

Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change one number to any integer you want) from the subsegment to make the subsegment strictly increasing.

You only need to output the length of the subsegment you find.

Input

The first line contains integer n (1 ≤ n ≤ 105). The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Output

In a single line print the answer to the problem — the maximum length of the required subsegment.

Examples

Input

6
7 2 3 1 5 6

Output

5

Note

You can choose subsegment a2, a3, a4, a5, a6 and change its 3rd element (that is a4) to 4.

### Response

```cpp
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
const double pi = 3.1415926535897932384626433832795028841971;
const double EPS = 1E-9;
const signed long long INF64 = (signed long long)1E18;
const int INF = 1000000000;
static inline bool get(int &v) {
  int s = 1, c;
  while (!isdigit(c = getchar()) && c != '-') {
    if (c == EOF) break;
  }
  if (c == EOF) return 0;
  if (c == '-')
    s = 0, v = 0;
  else
    v = c ^ 48;
  for (; isdigit(c = getchar()); v = (v << 1) + (v << 3) + (c ^ 48))
    ;
  v = (s ? v : -v);
  return 1;
}
const int maxn = 100005;
int e[maxn];
int up[maxn], down[maxn];
void run() {
  ios::sync_with_stdio(false);
  int n, ans = 1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> e[i];
  }
  up[0] = 1;
  for (int i = 1; i < n; i++) {
    if (e[i] > e[i - 1])
      up[i] = up[i - 1] + 1;
    else
      up[i] = 1;
    ans = max(ans, up[i]);
  }
  down[n - 1] = 1;
  for (int i = n - 2; i >= 0; i--) {
    if (e[i] < e[i + 1])
      down[i] = down[i + 1] + 1;
    else
      down[i] = 1;
    ans = max(ans, down[i]);
  }
  if (n > 1) {
    ans = max(up[n - 2] + 1, ans);
    ans = max(down[1] + 1, ans);
  }
  for (int i = 1; i < n - 1; i++) {
    ans = max(ans, down[i + 1] + 1);
    ans = max(ans, up[i - 1] + 1);
    if (e[i - 1] + 1 < e[i + 1]) {
      ans = max(ans, up[i - 1] + down[i + 1] + 1);
    }
  }
  cout << ans << endl;
}
int main() {
  run();
  return 0;
}

```


### Prompt

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

Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetically than x (read statement for better understanding). You can make hacks in these problems independently.

Koa the Koala has two strings A and B of the same length n (|A|=|B|=n) consisting of the first 20 lowercase English alphabet letters (ie. from a to t).

In one move Koa:

  1. selects some subset of positions p_1, p_2, …, p_k (k ≥ 1; 1 ≤ p_i ≤ n; p_i ≠ p_j if i ≠ j) of A such that A_{p_1} = A_{p_2} = … = A_{p_k} = x (ie. all letters on this positions are equal to some letter x).

  2. selects a letter y (from the first 20 lowercase letters in English alphabet) such that y>x (ie. letter y is strictly greater alphabetically than x).

  3. sets each letter in positions p_1, p_2, …, p_k to letter y. More formally: for each i (1 ≤ i ≤ k) Koa sets A_{p_i} = y.

Note that you can only modify letters in string A.

Koa wants to know the smallest number of moves she has to do to make strings equal to each other (A = B) or to determine that there is no way to make them equal. Help her!

Input

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

The first line of each test case contains one integer n (1 ≤ n ≤ 10^5) — the length of strings A and B.

The second line of each test case contains string A (|A|=n).

The third line of each test case contains string B (|B|=n).

Both strings consists of the first 20 lowercase English alphabet letters (ie. from a to t).

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

Output

For each test case:

Print on a single line the smallest number of moves she has to do to make strings equal to each other (A = B) or -1 if there is no way to make them equal.

Example

Input

5
3
aab
bcc
4
cabc
abcb
3
abc
tsr
4
aabd
cccd
5
abcbd
bcdda

Output

2
-1
3
2
-1

Note

  * In the 1-st test case Koa:
    1. selects positions 1 and 2 and sets A_1 = A_2 =  b (\color{red}{aa}b → \color{blue}{bb}b).
    2. selects positions 2 and 3 and sets A_2 = A_3 =  c (b\color{red}{bb} → b\color{blue}{cc}).

  * In the 2-nd test case Koa has no way to make string A equal B.

  * In the 3-rd test case Koa:
    1. selects position 1 and sets A_1 =  t (\color{red}{a}bc → \color{blue}{t}bc).
    2. selects position 2 and sets A_2 =  s (t\color{red}{b}c → t\color{blue}{s}c).
    3. selects position 3 and sets A_3 =  r (ts\color{red}{c} → ts\color{blue}{r}).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
template <typename T>
void chkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
void chkmin(T &x, T y) {
  x = min(x, y);
}
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
int n;
char s[MAXN], t[MAXN];
int main() {
  int T;
  read(T);
  while (T--) {
    read(n);
    scanf("\n%s", s + 1);
    scanf("\n%s", t + 1);
    int ans = 0;
    for (int i = 1; i <= n; i++)
      if (s[i] > t[i]) ans = -1;
    if (ans == -1) {
      puts("-1");
      continue;
    }
    while (true) {
      char c = 'z', d = 'z';
      for (int i = 1; i <= n; i++)
        if (s[i] < t[i]) {
          if (s[i] < c) {
            c = s[i];
            d = t[i];
          } else if (s[i] == c)
            chkmin(d, t[i]);
        }
      if (c == 'z') break;
      ans++;
      for (int i = 1; i <= n; i++)
        if (s[i] < t[i] && s[i] == c) s[i] = d;
    }
    printf("%d\n", ans);
  }
  return 0;
}

```


### Prompt

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

The fact that any positive integer has a representation as the sum of at most four positive squares (i.e. squares of positive integers) is known as Lagrange’s Four-Square Theorem. The first published proof of the theorem was given by Joseph-Louis Lagrange in 1770. Your mission however is not to explain the original proof nor to discover a new proof but to show that the theorem holds for some specific numbers by counting how many such possible representations there are.

For a given positive integer n, you should report the number of all representations of n as the sum of at most four positive squares. The order of addition does not matter, e.g. you should consider 42 + 32 and 32 + 42 are the same representation.

For example, let’s check the case of 25. This integer has just three representations 12 +22 +22 +42 , 32 + 42 , and 52 . Thus you should report 3 in this case. Be careful not to count 42 + 32 and 32 + 42 separately.

Input

The input is composed of at most 255 lines, each containing a single positive integer less than 215 , followed by a line containing a single zero. The last line is not a part of the input data.

Output

The output should be composed of lines, each containing a single integer. No other characters should appear in the output.

The output integer corresponding to the input integer n is the number of all representations of n as the sum of at most four positive squares.

Example

Input

1
25
2003
211
20007
0

Output

1
3
48
7
738

### Response

```cpp
#include <iostream>
/*???????????????????????§??????????????°?????????????????????
???????????????????????????????????°??§dp[0][sq]???????????£??\???????????????
sq??\????????°??¨?????????????????????????????°???????¨???????????????????
2????????\????????¢????????????????????????????????§?????????????¨????????????°??????
*/
using namespace std;

const int N = 32770;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int dp[4][N+1] = {};
	for(int i = 1;i*i <= N;i++){
		for(int j = 0;j < 3;j++){
			int sq = i*i;
			if(j == 0)dp[0][sq] = 1;
			for(int k = 1;k <= N;k++){
				if(k + sq >= N)continue;
				dp[j + 1][k + sq] += dp[j][k];
			}
		}
	}
	int n;
	while(cin >> n,n){
		cout << dp[0][n] + dp[1][n] + dp[2][n] + dp[3][n] << endl;
	}
  return 0;
}
```


### Prompt

Create a solution in Cpp for the following problem:

It's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh.

In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the first move he removes the first and the second integer from from the board, on the second move he removes the first and the second integer of the remaining sequence from the board, and so on. Bimokh stops when the board contains less than two numbers. When Bimokh removes numbers x and y from the board, he gets gcd(x, y) points. At the beginning of the game Bimokh has zero points.

Mashmokh wants to win in the game. For this reason he wants his boss to get exactly k points in total. But the guy doesn't know how choose the initial sequence in the right way.

Please, help him. Find n distinct integers a1, a2, ..., an such that his boss will score exactly k points. Also Mashmokh can't memorize too huge numbers. Therefore each of these integers must be at most 109.

Input

The first line of input contains two space-separated integers n, k (1 ≤ n ≤ 105; 0 ≤ k ≤ 108).

Output

If such sequence doesn't exist output -1 otherwise output n distinct space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Examples

Input

5 2

Output

1 2 3 4 5

Input

5 3

Output

2 4 3 7 1

Input

7 2

Output

-1

Note

gcd(x, y) is greatest common divisor of x and y.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  if (n == 1 && k == 0) {
    cout << "1\n";
    return 0;
  }
  if (n / 2 > k) {
    cout << "-1" << '\n';
    return 0;
  }
  if (n == 1 && k > 1) {
    cout << "-1\n";
    return 0;
  }
  if (n == 1 && k == 1) {
    cout << "-1\n";
    return 0;
  }
  int a = 0, b = 0;
  if (n > 1) {
    if (n / 2 != k) {
      a = k - n / 2 + 1;
      b = 2 * a;
    } else {
      a = 2;
      b = 3;
    }
    cout << a << ' ' << b;
    n -= 2;
  }
  int i = 0;
  for (i = 2; n > 1; i += 2) {
    if (i == a || (i + 1) == a || i == b || (i + 1) == b) {
      i--;
      continue;
    }
    cout << ' ' << i << ' ' << i + 1;
    n -= 2;
  }
  if (n == 1) {
    if (a == 1 || b == 1) {
      while (1) {
        if (a != i && b != i) {
          cout << ' ' << i;
          break;
        }
        i++;
      }
    } else
      cout << ' ' << '1';
  }
  cout << '\n';
  return 0;
}

```


### Prompt

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

Let's define a non-oriented connected graph of n vertices and n - 1 edges as a beard, if all of its vertices except, perhaps, one, have the degree of 2 or 1 (that is, there exists no more than one vertex, whose degree is more than two). Let us remind you that the degree of a vertex is the number of edges that connect to it.

Let each edge be either black or white. Initially all edges are black.

You are given the description of the beard graph. Your task is to analyze requests of the following types:

  * paint the edge number i black. The edge number i is the edge that has this number in the description. It is guaranteed that by the moment of this request the i-th edge is white
  * paint the edge number i white. It is guaranteed that by the moment of this request the i-th edge is black
  * find the length of the shortest path going only along the black edges between vertices a and b or indicate that no such path exists between them (a path's length is the number of edges in it)

The vertices are numbered with integers from 1 to n, and the edges are numbered with integers from 1 to n - 1.

Input

The first line of the input contains an integer n (2 ≤ n ≤ 105) — the number of vertices in the graph. Next n - 1 lines contain edges described as the numbers of vertices vi, ui (1 ≤ vi, ui ≤ n, vi ≠ ui) connected by this edge. It is guaranteed that the given graph is connected and forms a beard graph, and has no self-loops or multiple edges.

The next line contains an integer m (1 ≤ m ≤ 3·105) — the number of requests. Next m lines contain requests in the following form: first a line contains an integer type, which takes values from 1 to 3, and represents the request type.

If type = 1, then the current request is a request to paint the edge black. In this case, in addition to number type the line should contain integer id (1 ≤ id ≤ n - 1), which represents the number of the edge to paint.

If type = 2, then the current request is a request to paint the edge white, its form is similar to the previous request.

If type = 3, then the current request is a request to find the distance. In this case, in addition to type, the line should contain two integers a, b (1 ≤ a, b ≤ n, a can be equal to b) — the numbers of vertices, the distance between which must be found.

The numbers in all lines are separated by exactly one space. The edges are numbered in the order in which they are given in the input.

Output

For each request to "find the distance between vertices a and b" print the result. If there is no path going only along the black edges between vertices a and b, then print "-1" (without the quotes). Print the results in the order of receiving the requests, separate the numbers with spaces or line breaks.

Examples

Input

3
1 2
2 3
7
3 1 2
3 1 3
3 2 3
2 2
3 1 2
3 1 3
3 2 3

Output

1
2
1
1
-1
-1

Input

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

Output

3
-1
3
2

Note

In the first sample vertices 1 and 2 are connected with edge number 1, and vertices 2 and 3 are connected with edge number 2. Before the repainting edge number 2 each vertex is reachable from each one along the black edges. Specifically, the shortest path between 1 and 3 goes along both edges.

If we paint edge number 2 white, vertex 3 will end up cut off from other vertices, that is, no path exists from it to any other vertex along the black edges.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct node {
  int y, w, next;
} path[100005 * 2];
int first[100005], p;
inline void add(int x, int y, int w) {
  path[p].y = y;
  path[p].w = w;
  path[p].next = first[x];
  first[x] = p++;
}
int fa[100005][18], dep[100005], bg[100005], ed[100005], idx;
int stn[100005];
void dfs(int x, int r, int d) {
  fa[x][0] = r;
  dep[x] = d;
  for (int i = 1; i < 18; i++) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  int v;
  bg[x] = ++idx;
  for (int i = first[x]; i != -1; i = path[i].next) {
    v = path[i].y;
    if (v == r) continue;
    stn[path[i].w] = v;
    dfs(v, x, d + 1);
  }
  ed[x] = idx;
}
int n;
int d[100005 * 2];
inline int lowbit(int x) { return x & (-x); }
void update(int x, int data) {
  for (int i = x; i <= idx; i += lowbit(i)) d[i] += data;
}
int query(int x) {
  int ret = 0;
  for (int i = x; i > 0; i -= lowbit(i)) ret += d[i];
  return ret;
}
int lca(int x, int y) {
  if (dep[x] > dep[y]) swap(x, y);
  int d = dep[y] - dep[x];
  for (int i = 17; i >= 0; i--)
    if (d & (1 << i)) y = fa[y][i];
  if (x == y) return y;
  for (int i = 17; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) {
      x = fa[x][i];
      y = fa[y][i];
    }
  return fa[x][0];
}
void solve(int x, int y) {
  int fa = lca(x, y);
  int s1 = query(bg[x]) - query(bg[fa]);
  int s2 = query(bg[y]) - query(bg[fa]);
  if (s1 != dep[x] - dep[fa] || s2 != dep[y] - dep[fa])
    printf("-1\n");
  else
    printf("%d\n", dep[x] - dep[fa] + dep[y] - dep[fa]);
}
int state[100005];
int main() {
  int x, y, f;
  while (scanf("%d", &n) != EOF) {
    memset(first, -1, sizeof(first));
    p = 0;
    for (int i = 1; i < n; i++) {
      scanf("%d %d", &x, &y);
      add(x, y, i);
      add(y, x, i);
    }
    idx = 0;
    dfs(1, 0, 0);
    memset(d, 0, sizeof(d));
    for (int i = 1; i < n; i++) {
      update(bg[stn[i]], 1);
      update(ed[stn[i]] + 1, -1);
      state[i] = 1;
    }
    int m;
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) {
      scanf("%d", &f);
      if (f == 1) {
        scanf("%d", &x);
        if (state[x] == 0) {
          state[x] = 1;
          update(bg[stn[x]], 1);
          update(ed[stn[x]] + 1, -1);
        }
      } else if (f == 2) {
        scanf("%d", &x);
        if (state[x] == 1) {
          state[x] = 0;
          update(bg[stn[x]], -1);
          update(ed[stn[x]] + 1, 1);
        }
      } else {
        scanf("%d %d", &x, &y);
        solve(x, y);
      }
    }
  }
  return 0;
}

```


### Prompt

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

Medicine faculty of Berland State University has just finished their admission campaign. As usual, about 80\% of applicants are girls and majority of them are going to live in the university dormitory for the next 4 (hopefully) years.

The dormitory consists of n rooms and a single mouse! Girls decided to set mouse traps in some rooms to get rid of the horrible monster. Setting a trap in room number i costs c_i burles. Rooms are numbered from 1 to n.

Mouse doesn't sit in place all the time, it constantly runs. If it is in room i in second t then it will run to room a_i in second t + 1 without visiting any other rooms inbetween (i = a_i means that mouse won't leave room i). It's second 0 in the start. If the mouse is in some room with a mouse trap in it, then the mouse get caught into this trap.

That would have been so easy if the girls actually knew where the mouse at. Unfortunately, that's not the case, mouse can be in any room from 1 to n at second 0.

What it the minimal total amount of burles girls can spend to set the traps in order to guarantee that the mouse will eventually be caught no matter the room it started from?

Input

The first line contains as single integers n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of rooms in the dormitory.

The second line contains n integers c_1, c_2, ..., c_n (1 ≤ c_i ≤ 10^4) — c_i is the cost of setting the trap in room number i.

The third line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n) — a_i is the room the mouse will run to the next second after being in room i.

Output

Print a single integer — the minimal total amount of burles girls can spend to set the traps in order to guarantee that the mouse will eventually be caught no matter the room it started from.

Examples

Input

5
1 2 3 2 10
1 3 4 3 3

Output

3

Input

4
1 10 2 10
2 4 2 2

Output

10

Input

7
1 1 1 1 1 1 1
2 2 2 3 6 7 6

Output

2

Note

In the first example it is enough to set mouse trap in rooms 1 and 4. If mouse starts in room 1 then it gets caught immideately. If mouse starts in any other room then it eventually comes to room 4.

In the second example it is enough to set mouse trap in room 2. If mouse starts in room 2 then it gets caught immideately. If mouse starts in any other room then it runs to room 2 in second 1.

Here are the paths of the mouse from different starts from the third example:

  * 1 → 2 → 2 → ...;
  * 2 → 2 → ...;
  * 3 → 2 → 2 → ...;
  * 4 → 3 → 2 → 2 → ...;
  * 5 → 6 → 7 → 6 → ...;
  * 6 → 7 → 6 → ...;
  * 7 → 6 → 7 → ...;

So it's enough to set traps in rooms 2 and 6.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, c[300000], sl, d[300000], e[300000], cnt, Low[300000], Num[300000],
    Count, SL[300000];
vector<long long> a[200005], v[200005];
bool fre[200100];
stack<long long> st;
void visit(int u) {
  Low[u] = Num[u] = ++cnt;
  st.push(u);
  for (int i = 0; i < a[u].size(); i++) {
    long long v = a[u][i];
    if (Num[v])
      Low[u] = min(Low[u], Num[v]);
    else {
      visit(v);
      Low[u] = min(Low[u], Low[v]);
    }
  }
  if (Num[u] == Low[u]) {
    Count++;
    e[Count] = 1e12;
    int v, sl2 = 0;
    do {
      v = st.top();
      st.pop();
      Num[v] = Low[v] = 1e12;
      d[v] = Count;
      e[Count] = min(e[Count], c[v]);
      sl2++;
    } while (v != u);
    SL[Count] = sl2;
  }
}
void dfs(long long u) {
  for (int i = 0; i < a[u].size(); i++) {
    long long v = a[u][i];
    if (d[v] != d[u]) {
      if (SL[d[v]] > 1 && SL[d[u]] > 1) e[u] = min(e[u], e[v]);
      d[v] = d[u], dfs(v);
    }
  }
}
int main() {
  cnt = 0;
  memset(fre, true, sizeof fre);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i <= n; i++) {
    long long foo;
    cin >> foo;
    if (i != foo) a[foo].push_back(i);
  }
  long long res = 0;
  for (int i = 1; i <= n; i++)
    if (!Num[i]) visit(i);
  memset(fre, true, sizeof fre);
  for (int i = 1; i <= n; i++) dfs(i);
  for (int i = 1; i <= n; i++) {
    if (fre[d[i]]) res += e[d[i]], fre[d[i]] = false;
  }
  cout << res;
  return 0;
}

```


### Prompt

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

Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with the task.

Input

The single line contains an integer n (1 ≤ n ≤ 106) — the sum of digits of the required lucky number.

Output

Print on the single line the result — the minimum lucky number, whose sum of digits equals n. If such number does not exist, print -1.

Examples

Input

11

Output

47

Input

10

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double pi = acos(-1.0);
const int inf = (int)1e9;
const double eps = 1e-6;
const int ss = (int)1e6 + 3;
const int base = inf;
bool pred(const pair<int, int>& i, const pair<int, int>& j) {
  if (i.first == j.first) {
    return i.second > j.second;
  } else {
    return i.first > j.first;
  }
}
bool pred1(const string& i, const string& j) { return i.size() > j.size(); }
int main() {
  int n;
  cin >> n;
  int x = 0;
  int y = 0;
  int mn = inf;
  int kol = 0;
  while (n >= 0) {
    if (n % 4 == 0) {
      int now = n / 4;
      now += kol;
      if (now < mn) {
        mn = now;
        x = n / 4;
        y = kol;
      }
      if (now == mn && kol < y) {
        x = n / 4;
        y = kol;
      }
    }
    ++kol;
    n -= 7;
  }
  if (mn == inf) {
    cout << -1;
  } else {
    for (int i = 0; i < x; ++i) cout << 4;
    for (int i = 0; i < y; ++i) cout << 7;
  }
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Arkady's code contains n variables. Each variable has a unique name consisting of lowercase English letters only. One day Arkady decided to shorten his code.

He wants to replace each variable name with its non-empty prefix so that these new names are still unique (however, a new name of some variable can coincide with some old name of another or same variable). Among such possibilities he wants to find the way with the smallest possible total length of the new names.

A string a is a prefix of a string b if you can delete some (possibly none) characters from the end of b and obtain a.

Please find this minimum possible total length of new names.

Input

The first line contains a single integer n (1 ≤ n ≤ 10^5) — the number of variables.

The next n lines contain variable names, one per line. Each name is non-empty and contains only lowercase English letters. The total length of these strings is not greater than 10^5. The variable names are distinct.

Output

Print a single integer — the minimum possible total length of new variable names.

Examples

Input

3
codeforces
codehorses
code

Output

6

Input

5
abba
abb
ab
aa
aacada

Output

11

Input

3
telegram
digital
resistance

Output

3

Note

In the first example one of the best options is to shorten the names in the given order as "cod", "co", "c".

In the second example we can shorten the last name to "aac" and the first name to "a" without changing the other names.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 77, L = 26;
int n, S[N][L], t = 1, H[N], A;
char s[N];
multiset<int> D[N];
void insert() {
  int m = strlen(s), id = 1;
  for (int i = 0; i < m; i++) {
    if (S[id][s[i] - 'a'] == 0) {
      ++t;
      S[id][s[i] - 'a'] = t;
    }
    id = S[id][s[i] - 'a'];
  }
  H[id]++;
  A += m;
}
void dfs(int v) {
  for (int i = 0; i < L; i++) {
    if (S[v][i] == 0) {
      continue;
    }
    dfs(S[v][i]);
    for (auto x : D[S[v][i]]) {
      D[v].insert(x + 1);
    }
  }
  if (H[v]) {
    D[v].insert(0);
  } else if (v > 1) {
    int P = *D[v].rbegin();
    A -= P;
    D[v].erase(D[v].find(P));
    D[v].insert(0);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", &s);
    insert();
  }
  dfs(1);
  printf("%d\n", A);
  return 0;
}

```


### Prompt

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

Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from doesn't exceed some value of d meters, and a throw is worth 3 points if the distance is larger than d meters, where d is some non-negative integer.

Vasya would like the advantage of the points scored by the first team (the points of the first team minus the points of the second team) to be maximum. For that he can mentally choose the value of d. Help him to do that.

Input

The first line contains integer n (1 ≤ n ≤ 2·105) — the number of throws of the first team. Then follow n integer numbers — the distances of throws ai (1 ≤ ai ≤ 2·109).

Then follows number m (1 ≤ m ≤ 2·105) — the number of the throws of the second team. Then follow m integer numbers — the distances of throws of bi (1 ≤ bi ≤ 2·109).

Output

Print two numbers in the format a:b — the score that is possible considering the problem conditions where the result of subtraction a - b is maximum. If there are several such scores, find the one in which number a is maximum.

Examples

Input

3
1 2 3
2
5 6

Output

9:6

Input

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

Output

15:10

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> va(n);
  for (int i = 0; i < n; ++i) cin >> va[i];
  int m;
  cin >> m;
  vector<int> vb(m);
  for (int i = 0; i < m; ++i) cin >> vb[i];
  sort(va.begin(), va.end());
  sort(vb.begin(), vb.end());
  int best = INT_MIN;
  int sela, selb;
  for (int i = 0; i <= n; ++i) {
    int a = 2 * i + 3 * (n - i);
    int j = i < n ? lower_bound(vb.begin(), vb.end(), va[i]) - vb.begin() : m;
    int b = 2 * j + 3 * (m - j);
    if (a - b > best) {
      best = a - b;
      sela = a;
      selb = b;
    }
  }
  cout << sela << ":" << selb << endl;
}

```


### Prompt

Generate a cpp solution to the following problem:

problem

A city in Canada where JOI lives is divided into a grid pattern by w roads that extend straight in the north-south direction and h roads that extend straight in the east-west direction.

The w roads in the north-south direction are numbered 1, 2, ..., w in order from the west. In addition, h roads in the east-west direction are numbered 1, 2, ..., h in order from the south. The intersection of the i-th north-south road from the west and the j-th east-west road from the south is represented by (i, j).

JOI lives near the intersection (1, 1) and drives to a company near the intersection (w, h). Cars can only move along the road. JOI travels only to the east or north to shorten his commute time. The city also has the following traffic rules to reduce traffic accidents:

* A car that turns at an intersection cannot turn at the intersection immediately after that.

That is, it is not permissible to go one block after turning at an intersection and turn again. At this time, how many possible commuting routes for Mr. JOI?

Given w and h, create a program that outputs the remainder of JOI's number of commuting routes divided by 100000.

input

The input consists of multiple datasets. Each dataset consists of one line, and two integers w, h (2 ≤ w ≤ 100, 2 ≤ h ≤ 100) are written, separated by a blank. w represents the number of roads in the north-south direction, and h represents the number of roads in the east-west direction.

When both w and h are 0, it indicates the end of input. The number of data sets does not exceed 5.

output

For each data set, the remainder of JOI's number of commuting routes divided by 100000 is output on one line.

Example

Input

3 4
15 15
0 0

Output

5
43688

### Response

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

int main(){
	static int w,h,dp[100+2][100+2][2][2];
	for(int i=0;i<102;i++){
		for(int j=0;j<102;j++){
			for(int k=0;k<4;k++){
				dp[i][j][(k-k%2)/2][k%2]=0;
			}
		}
	}
	dp[3][1][0][0]=1;
	dp[2][2][0][1]=1;
	dp[2][2][1][0]=1;
	dp[1][3][1][1]=1;
	for(int i=1;i<101;i++){
		for(int j=max(1,5-i);j<101;j++){
			dp[i][j][0][0]=(dp[i-1][j][0][0]+dp[i-1][j][1][0])%100000;
			dp[i][j][0][1]=dp[i][j-1][0][0]%100000;
			dp[i][j][1][0]=dp[i-1][j][1][1]%100000;
			dp[i][j][1][1]=(dp[i][j-1][0][1]+dp[i][j-1][1][1])%100000;
		}
	}
	while(1){
	scanf("%d%d",&w,&h);
	if(w==0&&h==0)break;
	printf("%d\n",(dp[w][h][0][0]+dp[w][h][0][1]+dp[w][h][1][0]+dp[w][h][1][1])%100000);
	}
}
```


### Prompt

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

A programming competition site AtCode regularly holds programming contests.

The next contest on AtCode is called ABC, which is rated for contestants with ratings less than 1200.

The contest after the ABC is called ARC, which is rated for contestants with ratings less than 2800.

The contest after the ARC is called AGC, which is rated for all contestants.

Takahashi's rating on AtCode is R. What is the next contest rated for him?

Constraints

* 0 ≤ R ≤ 4208
* R is an integer.

Input

Input is given from Standard Input in the following format:

R

Output

Print the name of the next contest rated for Takahashi (`ABC`, `ARC` or `AGC`).

Examples

Input

1199

Output

ABC

Input

1200

Output

ARC

Input

4208

Output

AGC

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n<1200) cout<<"ABC";
  else if(n>=2800) cout<<"AGC";
  else cout<<"ARC";
}
```


### Prompt

Construct a Cpp code solution to the problem outlined:

You're given an array a of length 2n. Is it possible to reorder it in such way so that the sum of the first n elements isn't equal to the sum of the last n elements?

Input

The first line contains an integer n (1 ≤ n ≤ 1000), where 2n is the number of elements in the array a.

The second line contains 2n space-separated integers a_1, a_2, …, a_{2n} (1 ≤ a_i ≤ 10^6) — the elements of the array a.

Output

If there's no solution, print "-1" (without quotes). Otherwise, print a single line containing 2n space-separated integers. They must form a reordering of a. You are allowed to not change the order.

Examples

Input

3
1 2 2 1 3 1

Output

2 1 3 1 1 2

Input

1
1 1

Output

-1

Note

In the first example, the first n elements have sum 2+1+3=6 while the last n elements have sum 1+1+2=4. The sums aren't equal.

In the second example, there's no solution.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans1 = 0, ans2 = 0;
  cin >> n;
  int arr[2 * n];
  for (int i = 0; i < 2 * n; i++) cin >> arr[i];
  sort(arr, arr + (2 * n));
  for (int i = 0; i < 2 * n; i++) {
    if (i < n)
      ans1 += arr[i];
    else
      ans2 += arr[i];
  }
  if (ans1 == ans2)
    cout << "-1";
  else
    for (int i = 0; i < 2 * n; i++) cout << arr[i] << " ";
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Paladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each of these paths connects some pair of settlements and is bidirectional. Moreover, it is possible to reach any settlement from any other one by traversing one or several paths.

The distance between two settlements is the minimum number of paths that have to be crossed to get from one settlement to the other one. Manao knows that the Book of Evil has got a damage range d. This means that if the Book of Evil is located in some settlement, its damage (for example, emergence of ghosts and werewolves) affects other settlements at distance d or less from the settlement where the Book resides.

Manao has heard of m settlements affected by the Book of Evil. Their numbers are p1, p2, ..., pm. Note that the Book may be affecting other settlements as well, but this has not been detected yet. Manao wants to determine which settlements may contain the Book. Help him with this difficult task.

Input

The first line contains three space-separated integers n, m and d (1 ≤ m ≤ n ≤ 100000; 0 ≤ d ≤ n - 1). The second line contains m distinct space-separated integers p1, p2, ..., pm (1 ≤ pi ≤ n). Then n - 1 lines follow, each line describes a path made in the area. A path is described by a pair of space-separated integers ai and bi representing the ends of this path.

Output

Print a single number — the number of settlements that may contain the Book of Evil. It is possible that Manao received some controversial information and there is no settlement that may contain the Book. In such case, print 0.

Examples

Input

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

Output

3

Note

Sample 1. The damage range of the Book of Evil equals 3 and its effects have been noticed in settlements 1 and 2. Thus, it can be in settlements 3, 4 or 5.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N(100010);
int n, m, d;
bool evil[N];
int d1[N], d2[N], up[N], fa[N];
vector<int> g[N];
void dp(int x) {
  for (int i = int(0); i < int(g[x].size()); ++i)
    if (g[x][i] != fa[x]) {
      fa[g[x][i]] = x;
      dp(g[x][i]);
      if (d1[x] < d1[g[x][i]]) {
        d2[x] = d1[x];
        d1[x] = d1[g[x][i]];
      } else
        d2[x] = max(d2[x], d1[g[x][i]]);
    }
  if (d1[x] != -1) ++d1[x];
  if (d2[x] != -1) ++d2[x];
  if (!evil[x]) return;
  if (d1[x] < 0) {
    d2[x] = d1[x];
    d1[x] = 0;
  } else
    d2[x] = max(d2[x], 0);
}
void dp2(int x) {
  if (evil[x]) up[x] = max(up[x], 0);
  for (int i = int(0); i < int(g[x].size()); ++i)
    if (g[x][i] != fa[x]) {
      int tmp = up[x], y = g[x][i];
      if (d1[y] == -1 || d1[x] != d1[y] + 1)
        tmp = max(tmp, d1[x]);
      else
        tmp = max(tmp, d2[x]);
      if (tmp != -1) ++tmp;
      up[g[x][i]] = tmp;
      dp2(g[x][i]);
    }
}
int main() {
  cin >> n >> m >> d;
  memset(d1, -1, sizeof(d1));
  memset(d2, -1, sizeof(d2));
  memset(up, -1, sizeof(up));
  for (int i = int(0); i < int(m); ++i) {
    int p;
    scanf("%d", &p);
    evil[p] = true;
  }
  for (int i = int(1); i < int(n); ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dp(1);
  dp2(1);
  int ans = 0;
  for (int i = int(1); i < int(n + 1); ++i)
    if (max(up[i], d1[i]) <= d) ++ans;
  cout << ans << endl;
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

The Happy Farm 5 creators decided to invent the mechanism of cow grazing. The cows in the game are very slow and they move very slowly, it can even be considered that they stand still. However, carnivores should always be chased off them.

For that a young player Vasya decided to make the shepherd run round the cows along one and the same closed path. It is very important that the cows stayed strictly inside the area limited by the path, as otherwise some cows will sooner or later be eaten. To be absolutely sure in the cows' safety, Vasya wants the path completion time to be minimum.

The new game is launched for different devices, including mobile phones. That's why the developers decided to quit using the arithmetics with the floating decimal point and use only the arithmetics of integers. The cows and the shepherd in the game are represented as points on the plane with integer coordinates. The playing time is modeled by the turns. During every turn the shepherd can either stay where he stands or step in one of eight directions: horizontally, vertically, or diagonally. As the coordinates should always remain integer, then the length of a horizontal and vertical step is equal to 1, and the length of a diagonal step is equal to <image>. The cows do not move. You have to minimize the number of moves the shepherd needs to run round the whole herd.

Input

The first line contains an integer N which represents the number of cows in the herd (1 ≤ N ≤ 105). Each of the next N lines contains two integers Xi and Yi which represent the coordinates of one cow of (|Xi|, |Yi| ≤ 106). Several cows can stand on one point.

Output

Print the single number — the minimum number of moves in the sought path.

Examples

Input

4
1 1
5 1
5 3
1 3

Output

16

Note

Picture for the example test: The coordinate grid is painted grey, the coordinates axes are painted black, the cows are painted red and the sought route is painted green.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct vec {
  long long x, y;
  vec() {}
  vec(long long x, long long y) : x(x), y(y) {}
  bool operator<(vec const &b) const { return x == b.x ? y < b.y : x < b.x; }
  long long operator^(vec const &b) const { return x * b.y - y * b.x; }
  vec operator-(vec const &b) const { return vec(x - b.x, y - b.y); }
};
void convexHull(vec p[], int N, vec s[], int &m) {
  sort(p, p + N);
  m = 0;
  for (int i = 0; i < N; i++) {
    while ((m > 1) && ((p[i] - s[m]) ^ (s[m - 1] - s[m])) <= 0) m--;
    s[++m] = p[i];
  }
  for (int i = N - 2; i >= 0; i--) {
    while (((p[i] - s[m]) ^ (s[m - 1] - s[m])) <= 0) m--;
    s[++m] = p[i];
  }
}
vec p[(int)4e5 + 1], s[(int)4e5 + 1];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    p[i * 4] = vec(x + 1, y);
    p[i * 4 + 1] = vec(x - 1, y);
    p[i * 4 + 2] = vec(x, y + 1);
    p[i * 4 + 3] = vec(x, y - 1);
  }
  int m;
  convexHull(p, 4 * n, s, m);
  long long ans = 0;
  for (int i = 2; i <= m; i++)
    ans += max(abs(s[i].x - s[i - 1].x), abs(s[i].y - s[i - 1].y));
  cout << ans << "\n";
}

```


### Prompt

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

Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution to the following problem:

Find k integers such that the sum of two to the power of each number equals to the number n and the largest integer in the answer is as small as possible. As there may be multiple answers, you are asked to output the lexicographically largest one.

To be more clear, consider all integer sequence with length k (a1, a2, ..., ak) with <image>. Give a value <image> to each sequence. Among all sequence(s) that have the minimum y value, output the one that is the lexicographically largest.

For definitions of powers and lexicographical order see notes.

Input

The first line consists of two integers n and k (1 ≤ n ≤ 1018, 1 ≤ k ≤ 105) — the required sum and the length of the sequence.

Output

Output "No" (without quotes) in a single line if there does not exist such sequence. Otherwise, output "Yes" (without quotes) in the first line, and k numbers separated by space in the second line — the required sequence.

It is guaranteed that the integers in the answer sequence fit the range [ - 1018, 1018].

Examples

Input

23 5

Output

Yes
3 3 2 1 0

Input

13 2

Output

No

Input

1 2

Output

Yes
-1 -1

Note

Sample 1:

23 + 23 + 22 + 21 + 20 = 8 + 8 + 4 + 2 + 1 = 23

Answers like (3, 3, 2, 0, 1) or (0, 1, 2, 3, 3) are not lexicographically largest.

Answers like (4, 1, 1, 1, 0) do not have the minimum y value.

Sample 2:

It can be shown there does not exist a sequence with length 2.

Sample 3:

<image>

Powers of 2:

If x > 0, then 2x = 2·2·2·...·2 (x times).

If x = 0, then 2x = 1.

If x < 0, then <image>.

Lexicographical order:

Given two different sequences of the same length, (a1, a2, ... , ak) and (b1, b2, ... , bk), the first one is smaller than the second one for the lexicographical order, if and only if ai < bi, for the first i where ai and bi differ.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void calc1(int rest, int cur, int rk) {
  long long invlarge = 1;
  invlarge <<= (-cur);
  long long q = rest * invlarge;
  if (q == rk) {
    for (int i = 0; i < q; i++) cout << cur << " ";
    cout << endl;
    return;
  }
  for (int i = 1; i < q; i++) cout << cur << " ";
  for (int i = q; i < rk; i++) {
    cur--;
    cout << cur << " ";
  }
  cout << cur << endl;
}
void calc0(long long rest, int cur, int rk) {
  if (rk == 0) {
    cout << endl;
    return;
  }
  if (cur <= 0) {
    calc1(rest, cur, rk);
    return;
  }
  long long large = 1;
  large <<= cur;
  long long q = rest / large, r = rest % large;
  for (int i = 0; i < q - 1; i++) cout << cur << " ";
  if (r > 0 || rk == q) {
    if (q > 0) cout << cur << " ";
    calc0(r, cur - 1, rk - q);
  } else
    calc0(large, cur - 1, rk - q + 1);
}
int main() {
  ios::sync_with_stdio(false);
  long long n;
  int k;
  cin >> n >> k;
  long long tmp = n;
  int num1 = 0;
  while (tmp > 0) {
    if (tmp & 1) num1++;
    tmp >>= 1;
  }
  if (num1 > k) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  double lf = log((double)n / k) / log(2);
  int le = (int)lf, ri = log(n) / log(2);
  if (lf > (1e-8) + le) le++;
  if (le <= 0) {
    calc1(n, le, k);
    return 0;
  }
  int f, q;
  long long large, r;
  for (f = le; f <= ri; f++) {
    large = 1;
    large <<= f;
    q = n / large;
    r = n % large, tmp = r;
    num1 = 0;
    while (tmp > 0) {
      if (tmp & 1) num1++;
      tmp >>= 1;
    }
    if (num1 <= k - q) break;
  }
  calc0(n, f, k);
}

```


### Prompt

Generate a CPP solution to the following problem:

The new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced the following problem at the work.

Given a sequence of n integers p1, p2, ..., pn. You are to choose k pairs of integers:

[l1, r1], [l2, r2], ..., [lk, rk] (1 ≤ l1 ≤ r1 < l2 ≤ r2 < ... < lk ≤ rk ≤ n; ri - li + 1 = m),

in such a way that the value of sum <image> is maximal possible. Help George to cope with the task.

Input

The first line contains three integers n, m and k (1 ≤ (m × k) ≤ n ≤ 5000). The second line contains n integers p1, p2, ..., pn (0 ≤ pi ≤ 109).

Output

Print an integer in a single line — the maximum possible value of sum.

Examples

Input

5 2 1
1 2 3 4 5

Output

9

Input

7 1 3
2 10 7 18 5 33 0

Output

61

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long inp[5010], dp[5010][5010], sumtotal[5010], srange[5010];
int main(int argc, char const *argv[]) {
  int n, m, k;
  cin >> n >> m >> k;
  sumtotal[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> inp[i];
    sumtotal[i] += sumtotal[i - 1] + inp[i];
  }
  for (int i = m; i <= n; i++) {
    srange[i] = sumtotal[i] - sumtotal[i - m];
  }
  for (int i = 1; i <= k; i++) {
    for (int j = m; j <= n; j++) {
      dp[j][i] = max(dp[j - m][i - 1] + srange[j], dp[j - 1][i]);
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}

```


### Prompt

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

There is a grid with H rows and W columns, where each square is painted black or white.

You are given H strings S_1, S_2, ..., S_H, each of length W. If the square at the i-th row from the top and the j-th column from the left is painted black, the j-th character in the string S_i is `#`; if that square is painted white, the j-th character in the string S_i is `.`.

Find the number of pairs of a black square c_1 and a white square c_2 that satisfy the following condition:

* There is a path from the square c_1 to the square c_2 where we repeatedly move to a vertically or horizontally adjacent square through an alternating sequence of black and white squares: black, white, black, white...

Constraints

* 1 \leq H, W \leq 400
* |S_i| = W (1 \leq i \leq H)
* For each i (1 \leq i \leq H), the string S_i consists of characters `#` and `.`.

Input

Input is given from Standard Input in the following format:

H W
S_1
S_2
:
S_H

Output

Print the answer.

Examples

Input

3 3
.#.
..#
#..

Output

10

Input

3 3
.#.
..#
..

Output

10

Input

2 4
....
....

Output

0

Input

4 3

...

Output

6

### Response

```cpp
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
using namespace std;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
vector<string>g;
vector<vector<bool>>used;
int cnt = 0;
int dfs(int y,int x){
    used[y][x] = true;
    char c = g[y][x];
    if(c == '#')cnt++;
    int cal = (c == '.');
    rep(k,4){
        int ny = y + dy[k];
        int nx = x + dx[k];
        if(valid(nx, ny) and c != g[ny][nx] and !used[ny][nx]){
            cal += dfs(ny,nx);
        }
    }
    return cal;
}
signed main(){
    cin >> H >> W;
    g = vector<string>(H);
    used = vector<vector<bool>>(H,vector<bool>(W,false));
    for(auto & s :g) cin >> s;
    int ans = 0;
    rep(i,H)rep(j,W)if(g[i][j] == '#' and !used[i][j]){
        ans += dfs(i,j) * cnt;
        cnt = 0;
    }
    cout << ans << endl;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Kenkoooo found a simple connected graph. The vertices are numbered 1 through n. The i-th edge connects Vertex u_i and v_i, and has a fixed integer s_i.

Kenkoooo is trying to write a positive integer in each vertex so that the following condition is satisfied:

* For every edge i, the sum of the positive integers written in Vertex u_i and v_i is equal to s_i.

Find the number of such ways to write positive integers in the vertices.

Constraints

* 2 \leq n \leq 10^5
* 1 \leq m \leq 10^5
* 1 \leq u_i < v_i \leq n
* 2 \leq s_i \leq 10^9
* If i\neq j, then u_i \neq u_j  or v_i \neq v_j.
* The graph is connected.
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

n m
u_1 v_1 s_1
:
u_m v_m s_m

Output

Print the number of ways to write positive integers in the vertices so that the condition is satisfied.

Examples

Input

3 3
1 2 3
2 3 5
1 3 4

Output

1

Input

4 3
1 2 6
2 3 7
3 4 5

Output

3

Input

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

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N,M;

struct edge{
  int to;
  i64 s;
};

vector<edge> G[101010];

int main(){
  cin >> N >> M;
  rep(i,0,M - 1){
    int u,v;
    i64 s;
    cin >> u >> v;
    cin >> s;
    G[u].push_back({v,s});
    G[v].push_back({u,s});
  }

  queue<int> que;
  que.push(1);

  vector<i64> op(101010,0);
  vector<i64> C(101010,0);

  i64 bottom = 0;
  i64 up = 1e18;

  i64 A;
  bool defined = false;

  op[1] = 1;

  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(auto e : G[v]){
      if(op[e.to] == 0){
        op[e.to] = op[v] * -1;
        C[e.to] = e.s - C[v];
        if(op[e.to] == 1){
          bottom = max(bottom , -C[e.to]);
        }
        else{
          up = min(up , C[e.to]);
        }
        que.push(e.to);
      }
      else if(op[e.to] == op[v]){
        i64 c = C[e.to] + C[v];
        if(abs(e.s - c) % 2 == 1){
          cout << 0 << endl;
          return 0;
        }

        i64 a = op[v] * (e.s - c) / 2;
        if(a <= 0){
          cout << 0 << endl;
          return 0;
        }
        if(!defined){
          A = a;
          defined = true;
        }
        else if(A != a){
          cout << 0 << endl;
          return 0;
        }
      }
      else if(C[e.to] + C[v] != e.s){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  if(defined){
    cout << ((bottom < A) && (A < up)) << endl;
  }
  else{
    cout << max(0LL,up - bottom - 1) << endl;
  }
}

```


### Prompt

Create a solution in CPP for the following problem:

D: Sontaku (Surmise)

Some twins like even numbers.

Count how many even numbers are in $ N $ integers $ A_1, A_2, A_3, \ dots, A_N $.

input

The integer $ N $ is given on the first line.

On the second line, $ N $ integers $ A_1, A_2, A_3, \ dots, A_N $ are given, separated by blanks.

output

Output an even number. However, insert a line break at the end.

Constraint

* $ N $ is an integer greater than or equal to $ 1 $ and less than or equal to $ 100 $
* $ A_1, A_2, A_3, \ dots, A_N $ are integers between $ 1 $ and $ 100 $

Input example 1

Five
4 3 5 2 6

Output example 1

3

$ A_1 = 4 $, $ A_4 = 2 $ and $ A_5 = 6 $ are even numbers. Therefore, the even number is $ 3 $.

Input example 2

3
2 2 2

Output example 2

3

Even if the numbers are the same, if the positions in $ A_1, A_2, A_3, \ dots, A_N $ are different, they are counted as different numbers.

Example

Input

5
4 3 5 2 6

Output

3

### Response

```cpp
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    int n, t, sum = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &t);
        if (!(t & 1)) sum++;
    }
    printf("%d\n", sum);
    return 0;
}

```


### Prompt

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

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

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

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

Consider sample tests in order to understand the snake pattern.

Input

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

n is an odd number.

Output

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

Examples

Input

3 3

Output

###
..#
###

Input

3 4

Output

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

Input

5 3

Output

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

Input

9 9

Output

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

### Response

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

```


### Prompt

Create a solution in Cpp for the following problem:

You must have heard of the two brothers dreaming of ruling the world. With all their previous plans failed, this time they decided to cooperate with each other in order to rule the world.

As you know there are n countries in the world. These countries are connected by n - 1 directed roads. If you don't consider direction of the roads there is a unique path between every pair of countries in the world, passing through each road at most once.

Each of the brothers wants to establish his reign in some country, then it's possible for him to control the countries that can be reached from his country using directed roads.

The brothers can rule the world if there exists at most two countries for brothers to choose (and establish their reign in these countries) so that any other country is under control of at least one of them. In order to make this possible they want to change the direction of minimum number of roads. Your task is to calculate this minimum number of roads.

Input

The first line of input contains an integer n (1 ≤ n ≤ 3000). Each of the next n - 1 lines contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi) saying there is a road from country ai to country bi.

Consider that countries are numbered from 1 to n. It's guaranteed that if you don't consider direction of the roads there is a unique path between every pair of countries in the world, passing through each road at most once.

Output

In the only line of output print the minimum number of roads that their direction should be changed so that the brothers will be able to rule the world.

Examples

Input

4
2 1
3 1
4 1

Output

1

Input

5
2 1
2 3
4 3
4 5

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000 + 2;
vector<int> v[maxn], v_[maxn];
int n;
int dp[maxn][2];
int vis[maxn];
int par[maxn];
inline pair<int, int> DFS(int st) {
  vis[st] = 1;
  dp[st][0] = dp[st][1] = 0;
  for (int i = 0; i < v[st].size(); ++i)
    if (vis[v[st][i]] == 0) {
      pair<int, int> hlp = DFS(v[st][i]);
      dp[st][0] += hlp.first;
      dp[st][1] = min(dp[st][1], 1 + hlp.second - hlp.first);
    }
  for (int i = 0; i < v_[st].size(); ++i)
    if (vis[v_[st][i]] == 0) {
      par[v_[st][i]] = 1;
      pair<int, int> hlp = DFS(v_[st][i]);
      dp[st][0] += hlp.first + 1;
      dp[st][1] = min(dp[st][1], -1 + hlp.second - hlp.first);
    }
  dp[st][1] += dp[st][0];
  return pair<int, int>(dp[st][0], dp[st][1]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n - 1; ++i) {
    int v1, v2;
    cin >> v1 >> v2;
    v[v1].push_back(v2);
    v_[v2].push_back(v1);
  }
  int ans = 100000;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) vis[j] = 0;
    for (int j = 1; j <= n; ++j) par[j] = 0;
    DFS(i);
    ans = min(ans, dp[i][0]);
    for (int j = 1; j <= n; ++j)
      if (i != j) ans = min(ans, dp[i][0] - dp[j][0] + dp[j][1] - par[j]);
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

problem

Taro often shop at JOI general stores. At JOI general stores, there are enough coins of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen, and we always pay the change so that the number of coins is the smallest. Create a program to find the number of coins included in the change you receive when Taro goes shopping at the JOI general store and puts out one 1000 yen bill at the cash register.

For example, in the case of input example 1, 4 must be output as shown in the figure below.

<image>

input

The input consists of multiple datasets. Each dataset consists of one line, and only one amount (an integer of 1 or more and less than 1000) paid by Taro is written. The input data ends with one zero line.

The number of datasets does not exceed 5.

output

Output the number of coins included in the change for each dataset on one line.

Examples

Input

380
1
0

Output

4
15

Input

None

Output

None

### Response

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

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

n=1000-n;
int ans=0;
ans=ans+n/500;
n=n%500;

ans=ans+n/100;
n=n%100;

ans=ans+n/50;
n=n%50;

ans=ans+n/10;
n=n%10;

ans=ans+n/5;
n=n%5;
ans=ans+n;
cout<<ans<<endl;
}
	return 0;
}
```


### Prompt

Construct a Cpp code solution to the problem outlined:

Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more.

Dima felt so grateful to Inna about the present that he decided to buy her n hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to n from left to right and started feeding them with carrots. Inna was determined to feed each hare exactly once. But in what order should she feed them?

Inna noticed that each hare radiates joy when she feeds it. And the joy of the specific hare depends on whether Inna fed its adjacent hares before feeding it. Inna knows how much joy a hare radiates if it eats when either both of his adjacent hares are hungry, or one of the adjacent hares is full (that is, has been fed), or both of the adjacent hares are full. Please note that hares number 1 and n don't have a left and a right-adjacent hare correspondingly, so they can never have two full adjacent hares.

Help Inna maximize the total joy the hares radiate. :)

Input

The first line of the input contains integer n (1 ≤ n ≤ 3000) — the number of hares. Then three lines follow, each line has n integers. The first line contains integers a1 a2 ... an. The second line contains b1, b2, ..., bn. The third line contains c1, c2, ..., cn. The following limits are fulfilled: 0 ≤ ai, bi, ci ≤ 105.

Number ai in the first line shows the joy that hare number i gets if his adjacent hares are both hungry. Number bi in the second line shows the joy that hare number i radiates if he has exactly one full adjacent hare. Number сi in the third line shows the joy that hare number i radiates if both his adjacent hares are full.

Output

In a single line, print the maximum possible total joy of the hares Inna can get by feeding them.

Examples

Input

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

Output

13

Input

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

Output

44

Input

3
1 1 1
1 2 1
1 1 1

Output

4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct z {
  int zero;
  int one;
  int two;
};
z za[3010];
int d0[3010];
int d1[3010];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> za[i].zero;
  }
  for (int i = 1; i <= n; i++) {
    cin >> za[i].one;
  }
  for (int i = 1; i <= n; i++) {
    cin >> za[i].two;
  }
  d0[1] = za[1].zero;
  d1[1] = za[1].one;
  for (int i = 2; i <= n; i++) {
    d0[i] = max(d0[i - 1] + za[i].one, d1[i - 1] + za[i].zero);
    d1[i] = max(d0[i - 1] + za[i].two, d1[i - 1] + za[i].one);
  }
  cout << d0[n] << endl;
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Alexander exactly one e-card. Let us number his friends by numbers from 1 to n in the order in which they send the cards. Let's introduce the same numbering for the cards, that is, according to the numbering the i-th friend sent to Alexander a card number i.

Alexander also sends cards to friends, but he doesn't look for the new cards on the Net. He simply uses the cards previously sent to him (sometimes, however, he does need to add some crucial details). Initially Alexander doesn't have any cards. Alexander always follows the two rules:

  1. He will never send to a firend a card that this friend has sent to him.
  2. Among the other cards available to him at the moment, Alexander always chooses one that Alexander himself likes most.

Alexander plans to send to each friend exactly one card. Of course, Alexander can send the same card multiple times.

Alexander and each his friend has the list of preferences, which is a permutation of integers from 1 to n. The first number in the list is the number of the favorite card, the second number shows the second favorite, and so on, the last number shows the least favorite card.

Your task is to find a schedule of sending cards for Alexander. Determine at which moments of time Alexander must send cards to his friends, to please each of them as much as possible. In other words, so that as a result of applying two Alexander's rules, each friend receives the card that is preferred for him as much as possible.

Note that Alexander doesn't choose freely what card to send, but he always strictly follows the two rules.

Input

The first line contains an integer n (2 ≤ n ≤ 300) — the number of Alexander's friends, equal to the number of cards. Next n lines contain his friends' preference lists. Each list consists of n different integers from 1 to n. The last line contains Alexander's preference list in the same format.

Output

Print n space-separated numbers: the i-th number should be the number of the friend, whose card Alexander receives right before he should send a card to the i-th friend. If there are several solutions, print any of them.

Examples

Input

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

Output

2 1 1 4

Note

In the sample, the algorithm of actions Alexander and his friends perform is as follows:

  1. Alexander receives card 1 from the first friend.
  2. Alexander sends the card he has received (at the moment he only has one card, and therefore it is the most preferable for him) to friends with the numbers 2 and 3.
  3. Alexander receives card 2 from the second friend, now he has two cards — 1 and 2.
  4. Alexander sends a card to the first friend. Despite the fact that Alexander likes card 1 more, he sends card 2 as he cannot send a friend the card sent by that very friend.
  5. Alexander receives card 3 from the third friend.
  6. Alexander receives card 4 from the fourth friend.
  7. Among the cards Alexander has number 3 is his favorite and he sends it to the fourth friend.

Note that Alexander can send cards to multiple friends at a time (in this case the second and the third one). Alexander can send card 3 to the fourth friend after he receives the third card or after he receives the fourth card (both variants are correct).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int prep[300][300];
int my_prev[300];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &prep[i][j]);
  for (int i = 0; i < n; i++) scanf("%d", &my_prev[i]);
  int my_prev_pos[301] = {0};
  for (int i = 0; i < n; i++) my_prev_pos[my_prev[i]] = i;
  int res[300] = {0};
  for (int i = 0; i < n; i++) {
    int opp_pos[301] = {0};
    for (int j = 0; j < n; j++) opp_pos[prep[i][j]] = j;
    int best_pos = 999;
    int best_num = 999;
    int opp_best_pos = 999;
    int opp_best_num = 999;
    for (int j = 1; j <= n; j++) {
      if (i + 1 == j) continue;
      if (my_prev_pos[j] < best_pos) {
        best_pos = my_prev_pos[j];
        best_num = j;
        if (opp_pos[best_num] < opp_best_pos) {
          opp_best_pos = opp_pos[best_num];
          opp_best_num = best_num;
        }
      }
    }
    res[i] = opp_best_num;
  }
  for (int i = 0; i < n; i++) printf("%d ", res[i]);
  printf("\n");
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

You are given an array a of n integers. Define the cost of some array t as follows:

$$$cost(t) = ∑_{x ∈ set(t) } last(x) - first(x),$$$

where set(t) is the set of all values in t without repetitions, first(x), and last(x) are the indices of the first and last occurrence of x in t, respectively. In other words, we compute the distance between the first and last occurrences for each distinct element and sum them up.

You need to split the array a into k consecutive segments such that each element of a belongs to exactly one segment and the sum of the cost of individual segments is minimum.

Input

The first line contains two integers n, k (1 ≤ n ≤ 35 000, 1 ≤ k ≤ min(n,100)).

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

Output

Output the minimum sum of the cost of individual segments.

Examples

Input

7 2
1 6 6 4 6 6 6

Output

3

Input

7 4
5 5 5 5 2 3 3

Output

1

Note

In the first example, we can divide the array into [1,6,6,4] and [6,6,6]. Cost of [1,6,6,4] will be (1-1) + (3 - 2) + (4-4) = 1 and cost of [6,6,6] will be 3-1 = 2. Total cost would be 1 + 2 = 3.

In the second example, divide the array into [5,5],[5],[5,2,3] and [3]. Total Cost would be 1 + 0 + 0 + 0 = 1.

### Response

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

#define ll long long

const int N = 35005;
const int K = 101;

int a[N];

int dp[K][N];

int color[N],d[N];
int cut_value[N];

int get_cost(int l,int r) {
  assert(l<=r);
  return dp[1][r] - dp[1][l-1] - cut_value[l];
}

void dnc(int k,int l,int r,int x,int y) {
  if(l>r) return;
  int mid = x+y>>1;
  int v;
  for(int i=min(y,mid);i>=x;--i) {
    //
  }
  dnc(k,l,mid,x,v),
  dnc(k,mid+1,r,v,y);
}

int seg[N*4],lazy[N*4];

void init(int k,int pos,int l,int r) {
  lazy[pos] = 0;
  if(l==r) {
    seg[pos] = dp[k-1][l];
    return;
  }
  int mid = l+r>>1;
  init(k,pos*2,l,mid),
  init(k,pos*2+1,mid+1,r);
  seg[pos] = min(seg[pos*2],seg[pos*2+1]);
}

void push(int pos,int l,int r) {
  if(lazy[pos]!=0) {
    seg[pos] += lazy[pos];
    if(l!=r) {
      lazy[pos*2] += lazy[pos];
      lazy[pos*2+1] += lazy[pos];
    }
    lazy[pos] = 0;
  }
}

void update(int pos,int l,int r,int ql,int qr,int val) {
  push(pos,l,r);
  if(r<ql || qr<l) {
    return;
  }
  if(ql<=l && r<=qr) {
    lazy[pos] = val;
    push(pos,l,r);
    return;
  }
  int mid = (l+r)/2;
  update(pos*2,l,mid,ql,qr,val);
  update(pos*2+1,mid+1,r,ql,qr,val);
  seg[pos] = min(seg[pos*2],seg[pos*2+1]);
}
int query(int pos,int l,int r,int ql,int qr) {
  push(pos,l,r);
  if(r<ql || qr<l) {
    return 1e9;
  }
  if(ql<=l && r<=qr) {
    return seg[pos];
  }
  int mid = (l+r)/2;
  return min(query(pos*2,l,mid,ql,qr),query(pos*2+1,mid+1,r,ql,qr));
}

void solve2() {
  int n,k;
  scanf("%d %d ", &n,&k);

  for(int i=1;i<=n;++i) {
    scanf("%d ", &a[i]);
  }

  int value = 0;
  for(int i=1;i<=n;++i) {
    if(color[a[i]]) {
      value += i - color[a[i]];
    }
    color[a[i]] = i;
    dp[1][i] = value;
  }
  for(int i=k;i;--i) dp[i][0] = 1e9;

  for(int i=2;i<=k;++i) {
    init(i,1,0,n);
    for(int j=1;j<=n;++j) color[j] = 0;
    for(int j=1;j<=n;++j) {
      if(color[a[j]]) {
        update(1,0,n,0,color[a[j]]-1, j-color[a[j]]);
      }
      color[a[j]] = j;
      dp[i][j] = query(1,0,n,0,j-1);
    }
  }

  printf("%d\n", dp[k][n]);
}

void solve() {
    // int t;
    // scanf("%d",&t);
    // while(t--)
    solve2();
}

inline bool exists_test0 (const std::string& name);
inline bool exists_test1 (const std::string& name);
int main() {
#ifdef LOCAL
  string file_name = "input.txt";
  assert(exists_test0(file_name));
  assert(exists_test1(file_name));
  freopen("input.txt","r",stdin);
#endif
  solve();
  return 0;
}

/*
0. Enough array size? Enough array size? Integer overflow?

1. Think TWICE, Code ONCE!
Are there any counterexamples to your algo?

2. Be careful about the BOUNDARIES!
N=1? P=1? Something about 0?

3. Do not make STUPID MISTAKES!
Time complexity? Memory usage? Precision error?

4. Be careful to use wrong variable.
*/
inline bool exists_test0 (const std::string& name) {
    ifstream f(name.c_str());
    return f.good();
}

inline bool exists_test1 (const std::string& name) {
    if (FILE *file = fopen(name.c_str(), "r")) {
        fclose(file);
        return true;
    } else {
        return false;
    }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

We have N points in a two-dimensional plane.
The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i).
Let us consider a rectangle whose sides are parallel to the coordinate axes that contains K or more of the N points in its interior.
Here, points on the sides of the rectangle are considered to be in the interior.
Find the minimum possible area of such a rectangle.

Constraints

* 2 \leq K \leq N \leq 50
* -10^9 \leq x_i,y_i \leq 10^9 (1 \leq i \leq N)
* x_i≠x_j (1 \leq i<j \leq N)
* y_i≠y_j (1 \leq i<j \leq N)
* All input values are integers. (Added at 21:50 JST)

Input

Input is given from Standard Input in the following format:

N K
x_1 y_1
:
x_{N} y_{N}

Output

Print the minimum possible area of a rectangle that satisfies the condition.

Examples

Input

4 4
1 4
3 3
6 2
8 1

Output

21

Input

4 2
0 0
1 1
2 2
3 3

Output

1

Input

4 3
-1000000000 -1000000000
1000000000 1000000000
-999999999 999999999
999999999 -999999999

Output

3999999996000000001

### Response

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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>x(n),y(n);
    rep(i,n)cin>>x[i]>>y[i];
    ll ans=LONG_LONG_MAX;
    rep(a,n)rep(b,n)rep(c,n)rep(d,n){
        int L=x[a],R=x[b],D=y[c],U=y[d];
        if(R<L||U<D)continue;
        int cnt=0;
        rep(v,n){
            if(L<=x[v]&&x[v]<=R&&D<=y[v]&&y[v]<=U)cnt++;
        }
        if(cnt>=k)ans=min(ans,(ll)(R-L)*(U-D));
    }
    cout<<ans<<endl;
}
```


### Prompt

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

You are given two circles. Find the area of their intersection.

Input

The first line contains three integers x1, y1, r1 ( - 109 ≤ x1, y1 ≤ 109, 1 ≤ r1 ≤ 109) — the position of the center and the radius of the first circle.

The second line contains three integers x2, y2, r2 ( - 109 ≤ x2, y2 ≤ 109, 1 ≤ r2 ≤ 109) — the position of the center and the radius of the second circle.

Output

Print the area of the intersection of the circles. The answer will be considered correct if the absolute or relative error doesn't exceed 10 - 6.

Examples

Input

0 0 4
6 0 4

Output

7.25298806364175601379

Input

0 0 5
11 0 5

Output

0.00000000000000000000

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long double r2, d, r1, s;
long double x1, yy1, a, x2, yy2;
long double tam;
void home() {}
void in() {
  cin >> x1 >> yy1 >> r1 >> x2 >> yy2 >> r2;
  d = sqrt((x2 - x1) * (x2 - x1) + (yy2 - yy1) * (yy2 - yy1));
  if (r1 + r2 <= d) {
    cout << 0;
    return;
  }
  long double r = min(r1, r2);
  long double PI = acos(-1);
  if (fabs(r2 - r1) >= d) {
    cout << fixed << setprecision(20) << PI * r * r;
    return;
  }
  tam = r2 * r2 + d * d - r1 * r1;
  s = 2 * r2 * d;
  a = acos(tam / s);
  s = a * r2 * r2;
  long double z = sin(a);
  long double z1 = cos(a);
  long double t = r2 * r2 * z * z1;
  s -= t;
  tam = r1 * r1 + d * d - r2 * r2;
  tam /= 2 * r1 * d;
  a = acos(tam);
  z = sin(a);
  z1 = cos(a);
  t = r1 * r1 * z * z1;
  s += a * r1 * r1 - t;
  cout << setprecision(20) << s;
}
int main() {
  home();
  in();
}

```


### Prompt

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

Shubham has a binary string s. A binary string is a string containing only characters "0" and "1".

He can perform the following operation on the string any amount of times:

  * Select an index of the string, and flip the character at that index. This means, if the character was "0", it becomes "1", and vice versa.

A string is called good if it does not contain "010" or "101" as a subsequence — for instance, "1001" contains "101" as a subsequence, hence it is not a good string, while "1000" doesn't contain neither "010" nor "101" as subsequences, so it is a good string.

What is the minimum number of operations he will have to perform, so that the string becomes good? It can be shown that with these operations we can make any string good.

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

Input

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

Each of the next t lines contains a binary string s (1 ≤ |s| ≤ 1000).

Output

For every string, output the minimum number of operations required to make it good.

Example

Input

7
001
100
101
010
0
1
001100

Output

0
0
1
1
0
0
2

Note

In test cases 1, 2, 5, 6 no operations are required since they are already good strings.

For the 3rd test case: "001" can be achieved by flipping the first character — and is one of the possible ways to get a good string.

For the 4th test case: "000" can be achieved by flipping the second character — and is one of the possible ways to get a good string.

For the 7th test case: "000000" can be achieved by flipping the third and fourth characters — and is one of the possible ways to get a good string.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long bin_exp(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * a;
    a = a * a;
    n = n >> 1;
  }
  return res;
}
long long bin_exp_modulo(long long a, long long n, long long m) {
  if (a == 0) return 0;
  long long res = 1;
  a = a % m;
  while (n) {
    if (n & 1) res = ((res % m) * (a % m)) % m;
    a = ((a % m) * (a % m)) % m;
    n = n >> 1;
  }
  return res % m;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
void work() {
  string str;
  cin >> str;
  int n = str.length();
  string zero = "", one = "";
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    zero = "";
    one = "";
    for (int j = 0; j < n; ++j) {
      if (j <= i) {
        zero += "0";
        one += "1";
      } else {
        zero += "1";
        one += "0";
      }
    }
    int zz = 0, oo = 0;
    for (int j = 0; j < n; ++j) {
      if (str[j] != zero[j]) ++zz;
      if (str[j] != one[j]) ++oo;
    }
    if (i == 0)
      ans = min(zz, oo);
    else
      ans = min({ans, zz, oo});
  }
  cout << ans;
}
int main() {
  int test;
  cin >> test;
  for (int i = 0; i < test; ++i) {
    work();
    cout << "\n";
  }
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

There is a tree with N vertices numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.

Initially, each edge is painted blue. Takahashi will convert this blue tree into a red tree, by performing the following operation N-1 times:

* Select a simple path that consists of only blue edges, and remove one of those edges.
* Then, span a new red edge between the two endpoints of the selected path.

His objective is to obtain a tree that has a red edge connecting vertices c_i and d_i, for each i.

Determine whether this is achievable.

Constraints

* 2 ≤ N ≤ 10^5
* 1 ≤ a_i,b_i,c_i,d_i ≤ N
* a_i ≠ b_i
* c_i ≠ d_i
* Both input graphs are trees.

Input

Input is given from Standard Input in the following format:

N
a_1 b_1
:
a_{N-1} b_{N-1}
c_1 d_1
:
c_{N-1} d_{N-1}

Output

Print `YES` if the objective is achievable; print `NO` otherwise.

Examples

Input

3
1 2
2 3
1 3
3 2

Output

YES

Input

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

Output

YES

Input

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

Output

NO

### Response

```cpp
#include <set>
#include <queue>
#include <cstdio>
#include <algorithm>

using namespace std;

const int N=1e5+10;

int n,f[N];
set<int>B[N],R[N];
queue< pair<int,int> >Q;

void Init()
{
	scanf("%d",&n);
	int a,b;
	for (int i=1;i<n;++i)
	{
		scanf("%d%d",&a,&b);
		B[a].insert(b); B[b].insert(a);
	}
	for (int i=1;i<n;++i)
	{
		scanf("%d%d",&a,&b);
		R[a].insert(b); R[b].insert(a);
		if (B[a].count(b)) Q.push(make_pair(a,b));
	}
}

int find(int a) { return a==f[a]?a:f[a]=find(f[a]); }

void Union(int x,int y)
{
	if (R[x].size()>R[y].size()) swap(x,y);
	f[x]=y;
	for (auto a:R[x]) if (B[a].count(y)) Q.push(make_pair(a,y));
	for (auto a:B[x]) if (R[a].count(y)) Q.push(make_pair(a,y));
	for (auto a:R[x]) { R[a].erase(x); R[a].insert(y); R[y].insert(a); }
	for (auto a:B[x]) { B[a].erase(x); B[a].insert(y); B[y].insert(a); }
}

void Solve()
{
	for (int i=1;i<=n;++i) f[i]=i;
	int cnt=0;
	while (!Q.empty())
	{
		int x=Q.front().first,y=Q.front().second; Q.pop();
		x=find(x); y=find(y);
		if (x==y)  continue;
		++cnt;
		R[x].erase(y); R[y].erase(x); B[x].erase(y); B[y].erase(x);
		Union(x,y);
	}
	if (cnt==n-1) printf("YES\n");
	else printf("NO\n");
}

int main()
{
	Init();
	Solve();
	return 0;
}
```


### Prompt

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

There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the appropriate coordinates of vertices.

Input

The first line contains two integers a, b (1 ≤ a, b ≤ 1000), separated by a single space.

Output

In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers — the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute value.

Examples

Input

1 1

Output

NO

Input

5 5

Output

YES
2 1
5 5
-2 4

Input

5 10

Output

YES
-10 4
-2 -2
1 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool isPerfectSquare(long long int n) {
  for (long long int i = 1; i * i <= n; i++) {
    if ((n % i == 0) && (n / i == i)) {
      return true;
    }
  }
  return false;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int a, b;
  cin >> a >> b;
  for (long long int i = 1; i < a; i++) {
    if (isPerfectSquare(a * a - i * i)) {
      long long int y = sqrt(a * a - i * i);
      long long int temp = gcd(i, y);
      long long int bx = -y / temp, by = i / temp;
      long long int modB = sqrt(bx * bx + by * by);
      if (modB && b % modB == 0) {
        if (y != by * (b / modB)) {
          cout << "YES\n0 0" << endl;
          cout << i << " " << y << endl;
          cout << bx * (b / modB) << " " << by * (b / modB) << endl;
          return 0;
        }
      }
    }
  }
  cout << "NO" << endl;
}

```


### Prompt

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

The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/nginx///sbin are equivalent. The character '/' (or some sequence of such characters) at the end of the path is required only in case of the path to the root directory, which can be represented as single character '/'.

A path called normalized if it contains the smallest possible number of characters '/'.

Your task is to transform a given path to the normalized form.

Input

The first line of the input contains only lowercase Latin letters and character '/' — the path to some directory. All paths start with at least one character '/'. The length of the given line is no more than 100 characters, it is not empty.

Output

The path in normalized form.

Examples

Input

//usr///local//nginx/sbin

Output

/usr/local/nginx/sbin

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int M = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long int n = s.length();
  bool ok[n];
  memset(ok, true, sizeof(ok));
  long long int it = n - 1;
  while (s[it] == '/' && it >= 1) {
    ok[it] = 0;
    it--;
  }
  for (long long int i = 0; i < s.length(); ++i) {
    if (s[i] == '/') {
      long long int j = i + 1;
      while (s[j] == '/') {
        ok[j] = 0;
        j++;
      }
      i = j - 1;
    }
  }
  for (long long int i = 0; i < n; ++i) {
    if (ok[i]) cout << s[i];
  }
}

```