### Prompt

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

Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where

  * <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive.
  * <hostname> — is a sequence of word separated by periods (characters «.»), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.
  * <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <resource> is between 1 and 16, inclusive.

The content of square brackets is optional — it can be present or can be absent.

There are the samples of correct Jabber IDs: mike@codeforces.com, 007@en.codeforces.com/contest.

Your task is to write program which checks if given string is a correct Jabber ID.

Input

The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.

Output

Print YES or NO.

Examples

Input

mike@codeforces.com

Output

YES

Input

john.smith@codeforces.ru/contest.icpc/12

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string ID;
  getline(cin, ID);
  int size = ID.size();
  int a = ID.find('@');
  int b = ID.find('/');
  if (a > 16 || a <= 0) {
    std::cout << "NO";
    return 0;
  }
  if (ID.find('.') == a + 1) {
    std::cout << "NO";
    return 0;
  }
  if (b > 0) {
    int c = b - a;
    if (c > 33 || c <= 0) {
      std::cout << "NO";
      return 0;
    }
    if (size - b > 17 || size - b <= 1) {
      std::cout << "NO";
      return 0;
    }
    if (ID.rfind('.') == b - 1) {
      std::cout << "NO";
      return 0;
    }
  } else if (ID.rfind('.') == size - 1 || size - a <= 1) {
    std::cout << "NO";
    return 0;
  }
  if (a > 0) {
    for (int i = 0; i < a; ++i) {
      if ((ID[i] < 'a' || ID[i] > 'z') && (ID[i] != '_') &&
          (ID[i] < 'A' || ID[i] > 'Z') && (ID[i] < '0' || ID[i] > '9')) {
        std::cout << "NO";
        return 0;
      }
    }
  }
  if (b > 0) {
    for (int i = a + 1; i < b; ++i) {
      if ((ID[i] < 'a' || ID[i] > 'z') && (ID[i] != '_') && ID[i] != '.' &&
          (ID[i] < 'A' || ID[i] > 'Z') && (ID[i] < '0' || ID[i] > '9')) {
        std::cout << "NO";
        return 0;
      }
      if (ID[i] == ID[i + 1] && ID[i] == '.') {
        std::cout << "NO";
        return 0;
      }
      for (int i = b + 1; i < size; ++i) {
        if ((ID[i] < 'a' || ID[i] > 'z') && (ID[i] != '_') &&
            (ID[i] < 'A' || ID[i] > 'Z') && (ID[i] < '0' || ID[i] > '9')) {
          std::cout << "NO";
          return 0;
        }
      }
    }
  } else {
    for (int i = a + 1; i < size; ++i) {
      if ((ID[i] < 'a' || ID[i] > 'z') && (ID[i] != '_') && ID[i] != '.' &&
          (ID[i] < 'A' || ID[i] > 'Z') && (ID[i] < '0' || ID[i] > '9')) {
        std::cout << "NO";
        return 0;
      }
      if (ID[i] == ID[i + 1] && ID[i] == '.') {
        std::cout << "NO";
        return 0;
      }
    }
  }
  std::cout << "YES";
}

```


### Prompt

Please create a solution in cpp to the following problem:

The polar bears have discovered a gigantic circular piece of floating ice with some mystic carvings on it. There are n lines carved on the ice. Each line connects two points on the boundary of the ice (we call these points endpoints). The endpoints are numbered 1, 2, ..., 2n counter-clockwise along the circumference. No two lines share an endpoint.

Now a group of 6 polar bears (Alice, Bob, Carol, Dave, Eve, Frank) are going to build caves on the endpoints. Each polar bear would build a cave and live in it. No two polar bears can build a cave on the same endpoints. Alice and Bob is a pair of superstitious lovers. They believe the lines are carved by aliens (or humans, which are pretty much the same thing to polar bears), and have certain spiritual power. Therefore they want to build their caves on two endpoints which are connected by a line. The same for Carol and Dave, Eve and Frank.

The distance between two caves X and Y is defined as one plus minimum number of other caves one need to pass through in order to travel from X to Y along the boundary of the ice (endpoints without caves are not counted).

To ensure fairness, the distances between the three pairs of lovers have to be the same (that is, the distance between Alice and Bob, the distance between Carol and Dave, and the distance between Eve and Frank are the same).

The figures below show two different configurations, where the dots on the circle are the endpoints. The configuration on the left is not valid. Although each pair of lovers (A and B, C and D, E and F) is connected a line, the distance requirement is not satisfied. The distance between A and B is 2 (one can go from A to B in the clockwise direction passing through F). The distance between E and F is also 2. However, the distance between C and D is 1 (one can go from C to D in the counter-clockwise direction without passing through any other caves). The configuration on the right is valid. All three pairs have the same distance 1.

<image>

Count the number of ways to build the caves under the requirements. Two configurations are considered the same if the same set of 6 endpoints are used.

Input

The first line contains integer n(3 ≤ n ≤ 105) — the number of lines.

Each of the following n lines contains two integers ai, bi (1 ≤ ai, bi ≤ 2n), which means that there is a line carved on the ice connecting the ai–th and bi–th endpoint.

It's guaranteed that each endpoints touches exactly one line.

Output

Print the number of ways to build the caves.

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

Examples

Input

4
5 4
1 2
6 7
8 3

Output

2

Input

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

Output

6

Note

The second sample corresponds to the figure in the problem statement.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int read() {
  char ch = '!';
  int res = 0, f = 0;
  while (!isdigit(ch)) {
    ch = getchar();
    if (ch == '-') f = 1;
  }
  while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar();
  return f ? -res : res;
}
const int N = 4e5 + 100;
int n, mch[N], arr[N], sum[N][2];
pair<int, int> q[N];
long long ans;
void mdf(int x, int val) {
  while (x <= 2 * n) arr[x] += val, x += (x & -x);
}
int qry(int x) {
  int res = 0;
  while (x) res += arr[x], x -= (x & -x);
  return res;
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    int p = read(), q = read();
    mch[p] = q, mch[q] = p;
  }
  n <<= 1;
  for (int i = 1; i <= n; ++i)
    if (i < mch[i])
      q[mch[i]] = pair<int, int>(i, i), q[i + n] = pair<int, int>(mch[i], -i);
  for (int i = 1; i <= n * 2; ++i) {
    if (q[i].first || q[i].second) {
      int id = abs(q[i].second), t = q[i].second > 0;
      sum[id][t] = qry(i) - qry(q[i].first);
    }
    if (i <= n) {
      if (mch[i] < i) mdf(mch[i], 1);
    } else {
      if (mch[i - n] < i - n)
        mdf(mch[i - n] + n, 1);
      else
        mdf(mch[i - n], 1);
    }
  }
  for (int i = 1; i <= n; ++i)
    if (i < mch[i])
      ans +=
          2ll * sum[i][0] * sum[i][1] +
          1ll * (n / 2 - sum[i][0] - sum[i][1] - 1) * (sum[i][0] + sum[i][1]);
  ans = 1ll * (n / 2) * (n / 2 - 1) * (n / 2 - 2) / 6 - ans / 2;
  cout << ans;
  return 0;
}

```


### Prompt

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

Spiders are Om Nom's old enemies. They love eating candies as much as he does and that's why they keep trying to keep the monster away from his favorite candies. They came up with an evil plan to trap Om Nom.

<image>

Let's consider a rope structure consisting of n nodes and n - 1 ropes connecting the nodes. The structure is connected, thus, the ropes and the nodes form a tree. Each rope of the formed structure is associated with its length. A candy is tied to node x of the structure. Om Nom really wants to eat this candy.

The y spiders are trying to stop him from doing it. They decided to entangle the candy and some part of the structure into a web, thus attaching the candy to as large as possible part of the rope structure.

Each spider can use his web to cover all ropes on the path between two arbitrary nodes a and b. Thus, y spiders can cover the set of ropes which is a union of y paths in the given tree. These y paths can arbitrarily intersect each other. The spiders want the following conditions to be hold:

  * the node containing the candy is adjacent to at least one rope covered with a web
  * the ropes covered with the web form a connected structure (what's the idea of covering with a web the ropes that are not connected with the candy?)
  * the total length of the ropes covered with web is as large as possible

The spiders haven't yet decided to what node of the structure they will tie the candy and how many spiders will cover the structure with web, so they asked you to help them. Help them calculate the optimal plan for multiple values of x and y.

Input

The first line contains numbers n and q (1 ≤ n, q ≤ 105) — the number of nodes in the structure and the number of questions that the spiders want to ask you.

The next n - 1 lines determine the rope structure. The i-th line contains three integers ui, vi, li (1 ≤ ui, vi ≤ n, ui ≠ vi, 1 ≤ li ≤ 1000), showing that there is a rope of length li between nodes ui and vi.

Next q lines describe the spiders' questions. As they want you to answer their question online, they encoded their messages in a special manner.

Each of the next q lines contains two numbers xi, yi. In the first question of the spiders x = x1, y = y1.

To calculate values x and y in the spiders' i-th (2 ≤ i ≤ q) question, you need to use the following formulas:

<image>

<image>

where Ansi - 1 is the total length of the ropes covered by a web in the answer for the (i - 1)-th question.

The following inequality holds: 1 ≤ xi, yi ≤ n.

Output

For each question of the spiders print on a separate line a single integer Ansi — the total length of the ropes covered with web in the optimal plan.

Examples

Input

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

Output

14
13
17

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5;
int fst[N], nxt[N], mm, n, q, dis[N];
struct Edge {
  int v, w;
} e[N];
void ade(int u, int v, int w) {
  e[++mm] = (Edge){v, w}, nxt[mm] = fst[u], fst[u] = mm;
}
int dfs(int u, int fa) {
  int ans = u;
  for (int i = fst[u]; i; i = nxt[i]) {
    int v = e[i].v;
    if (v == fa) continue;
    dis[v] = dis[u] + e[i].w;
    int t = dfs(v, u);
    if (dis[t] > dis[ans]) ans = t;
  }
  return ans;
}
struct TREE {
  int dep[N], len[N], son[N], fa[N][20], id[N], sum[N], tn, tp[N];
  pair<int, int> tmp[N];
  void dfs1(int u, int Fa) {
    fa[u][0] = Fa;
    for (int i = 1; i <= 16; i++) fa[u][i] = fa[fa[u][i - 1]][i - 1];
    for (int i = fst[u]; i; i = nxt[i]) {
      int v = e[i].v;
      if (v == Fa) continue;
      dep[v] = dep[u] + e[i].w;
      dfs1(v, u);
      len[v] += e[i].w;
      if (len[v] > len[u]) len[u] = len[v], son[u] = v;
    }
  }
  void dfs2(int u, int top) {
    tp[u] = top;
    if (son[u]) dfs2(son[u], top);
    for (int i = fst[u]; i; i = nxt[i]) {
      int v = e[i].v;
      if (v == son[u] || v == fa[u][0]) continue;
      dfs2(v, v);
    }
  }
  static int cmp(const pair<int, int> &a, const pair<int, int> &b) {
    return a > b;
  }
  void build(int root) {
    dfs1(root, 0);
    dfs2(root, root);
    tn = 0;
    for (int i = 1; i <= n; i++)
      if (tp[i] == i) tmp[++tn] = make_pair(len[i], i);
    sort(tmp + 1, tmp + tn + 1, cmp);
    for (int i = 1; i <= tn; i++) sum[i] = sum[i - 1] + tmp[i].first;
    for (int i = 1; i <= tn; i++) id[tmp[i].second] = i;
    for (int i = 1; i <= n; i++) id[i] = id[tp[i]];
  }
  int getfa(int u, int K) {
    for (int i = 16; i >= 0; i--)
      if (fa[u][i] && id[fa[u][i]] > K) u = fa[u][i];
    return fa[u][0];
  }
  int query(int x, int y) {
    y = 2 * y - 1;
    if (id[x] <= y) return sum[min(y, tn)];
    int u = getfa(x, y - 1), ans = sum[y - 1] + dep[x] - dep[u] + len[son[x]];
    u = getfa(x, y);
    return max(ans, sum[y] - len[son[u]] + dep[x] - dep[u] + len[son[x]]);
  }
} s1, s2;
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1, u, v, w; i < n; i++)
    scanf("%d%d%d", &u, &v, &w), ade(u, v, w), ade(v, u, w);
  int L = dfs(1, 0), R = dfs(L, 0);
  s1.build(L), s2.build(R);
  int lstans = 0;
  for (int i = 1, x, y; i <= q; i++) {
    scanf("%d%d", &x, &y);
    x = (x + lstans - 1) % n + 1, y = (y + lstans - 1) % n + 1;
    printf("%d\n", lstans = max(s1.query(x, y), s2.query(x, y)));
  }
}

```


### Prompt

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

Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II.

* insert  $k$: Insert a node containing $k$ as key into $T$.
* find $k$: Report whether $T$ has a node containing $k$.
* delete $k$: Delete a node containing $k$.
* print: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.

The operation delete $k$ for deleting a given node $z$ containing key $k$ from $T$ can be implemented by an algorithm which considers the following cases:

1. If $z$ has no children, we modify its parent $z.p$ to replace $z$ with NIL as its child (delete $z$).
2. If $z$ has only a single child, we "splice out" $z$ by making a new link between its child and its parent.
3. If $z$ has two children, we splice out $z$'s successor $y$ and replace $z$'s key with $y$'s key.

Constraints

* The number of operations $\leq 500,000$
* The number of print operations $\leq 10$.
* $-2,000,000,000 \leq key \leq 2,000,000,000$
* The height of the binary tree does not exceed 100 if you employ the above pseudo code.
* The keys in the binary search tree are all different.

Input

In the first line, the number of operations $m$ is given. In the following $m$ lines, operations represented by insert $k$, find $k$, delete $k$ or print are given.

Output

For each find $k$ operation, print "yes" if $T$ has a node containing $k$, "no" if not.

In addition, for each print operation, print a list of keys obtained by inorder tree walk and preorder tree walk in a line respectively. Put a space character before each key

Example

Input

18
insert 8
insert 2
insert 3
insert 7
insert 22
insert 1
find 1
find 2
find 3
find 4
find 5
find 6
find 7
find 8
print
delete 3
delete 7
print

Output

yes
yes
yes
no
no
no
yes
yes
 1 2 3 7 8 22
 8 2 1 3 7 22
 1 2 8 22
 8 2 1 22

### Response

```cpp
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstdlib>
using namespace std;
struct Node{int key; Node *p,*l,*r;};
Node *null,*root;

void insert(int k){
Node *x,*y,*z;
	y=null;
	x=root;
	z=(Node*)malloc(sizeof(Node));
	z->key=k;
	z->l=null;
	z->r=null;
	while(x!=null){
	    y=x;
		if(z->key<x->key)
		x=x->l;
		else
		x=x->r;
	}
	z->p=y;
	if(y==null)
	root=z;
	else if(z->key>y->key)
	y->r=z;
	else
	y->l=z;
}
void in_p(Node *u){
	if(u==null)
	return;
	in_p(u->l);
	printf(" %d",u->key);
	in_p(u->r);
}
void pre_p(Node *u){
	if(u==null)
	return ;
	printf(" %d",u->key);
	pre_p(u->l);
	pre_p(u->r);
}
void print(){
	in_p(root);
	printf("\n");
	pre_p(root);
	printf("\n");
}
bool find(Node *a,int k){
	if(a==null)
	return false;
	    else if(a->key==k)
		return true;
		else if(a->key>k)
	     find(a->l,k);
	    else
	    find(a->r,k);
	}
	Node* getmin(Node *x){
	while(x->l!=null)
	x=x->l;
	return x;
}
Node* getS(Node *x){
	if(x->r!=null)
	return getmin(x->r);
	Node *y;
	y=x->p;
	while(y!=null&&x==y->r){
	x=y;
		y=y->p;
	}
	return y;
}

void Delete(int k){
Node *y,*z,*x;
	x=null;
	z=root;
	while(z->key!=k&&z!=null){
		if(k>z->key)
		z=z->r;
		else
		z=z->l;
	}
	if(z->l==null || z->r==null)
	y=z;
else
	y=getS(z);
	if(y->l!=null)
	x=y->l;
	else
	x=y->r;
	if(x!=null)
	x->p=y->p;
	if(y->p==null)
	root=x;
	else if(y==y->p->l)
	y->p->l=x;
	else
	y->p->r=x;
	if(y!=z)
	z->key=y->key;
	free(y);
}

int main(){
	int i,n,key;
	string com;
	scanf("%d",&n);

	for(i=0;i<n;i++){
		cin>>com;
		if(com=="insert"){
			scanf("%d",&key);
			insert(key);
		}
		else if(com=="find"){
			scanf("%d",&key);
			if(find(root,key))
			printf("yes\n");
			else
			printf("no\n");
		}
		else if(com=="delete"){
			scanf("%d",&key);
			Delete(key);
		}
		else
		print();
	}

	return 0;
}

```


### Prompt

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

There are S sheep and W wolves.

If the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.

If the wolves will attack the sheep, print `unsafe`; otherwise, print `safe`.

Constraints

* 1 \leq S \leq 100
* 1 \leq W \leq 100

Input

Input is given from Standard Input in the following format:

S W

Output

If the wolves will attack the sheep, print `unsafe`; otherwise, print `safe`.

Examples

Input

4 5

Output

unsafe

Input

100 2

Output

safe

Input

10 10

Output

unsafe

### Response

```cpp
#include<iostream>
int main(){
	short s,w;
	std::cin>>s>>w;
	if(w>=s) printf("unsafe");
	else printf("safe");
	return 0;
}
```


### Prompt

Create a solution in cpp for the following problem:

Tomorrow is a difficult day for Polycarp: he has to attend a lectures and b practical classes at the university! Since Polycarp is a diligent student, he is going to attend all of them.

While preparing for the university, Polycarp wonders whether he can take enough writing implements to write all of the lectures and draw everything he has to during all of the practical classes. Polycarp writes lectures using a pen (he can't use a pencil to write lectures!); he can write down c lectures using one pen, and after that it runs out of ink. During practical classes Polycarp draws blueprints with a pencil (he can't use a pen to draw blueprints!); one pencil is enough to draw all blueprints during d practical classes, after which it is unusable.

Polycarp's pencilcase can hold no more than k writing implements, so if Polycarp wants to take x pens and y pencils, they will fit in the pencilcase if and only if x + y ≤ k.

Now Polycarp wants to know how many pens and pencils should he take. Help him to determine it, or tell that his pencilcase doesn't have enough room for all the implements he needs tomorrow!

Note that you don't have to minimize the number of writing implements (though their total number must not exceed k).

Input

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

Each test case is described by one line containing five integers a, b, c, d and k, separated by spaces (1 ≤ a, b, c, d, k ≤ 100) — the number of lectures Polycarp has to attend, the number of practical classes Polycarp has to attend, the number of lectures which can be written down using one pen, the number of practical classes for which one pencil is enough, and the number of writing implements that can fit into Polycarp's pencilcase, respectively.

In hacks it is allowed to use only one test case in the input, so t = 1 should be satisfied.

Output

For each test case, print the answer as follows:

If the pencilcase can't hold enough writing implements to use them during all lectures and practical classes, print one integer -1. Otherwise, print two non-negative integers x and y — the number of pens and pencils Polycarp should put in his pencilcase. If there are multiple answers, print any of them. Note that you don't have to minimize the number of writing implements (though their total number must not exceed k).

Example

Input

3
7 5 4 5 8
7 5 4 5 2
20 53 45 26 4

Output

7 1
-1
1 3

Note

There are many different answers for the first test case; x = 7, y = 1 is only one of them. For example, x = 3, y = 1 is also correct.

x = 1, y = 3 is the only correct answer for the third test case.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void fast();
long long int ar[200005];
long long int n, a, b, c, d, m, k, q, mod;
vector<long long int> v;
int32_t main() {
  fast();
  long long int t = 1;
  cin >> t;
  while (t--) {
    cin >> a >> b >> c >> d >> k;
    long long int req1 = 0, req2 = 0;
    req1 += a / c;
    if (a % c != 0) req1++;
    req2 += b / d;
    if (b % d != 0) req2++;
    if ((req1 + req2) <= k) {
      cout << req1 << " " << k - req1 << "\n";
    } else
      cout << "-1"
           << "\n";
  }
  return 0;
}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

```


### Prompt

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

Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques and tactics of the squad he was in charge of. But time went by and one day Sir Lancelot had a major argument with the Fairy Godmother (there were rumors that the argument occurred after the general spoke badly of the Godmother's flying techniques. That seemed to hurt the Fairy Godmother very deeply).

As the result of the argument, the Godmother put a rather strange curse upon the general. It sounded all complicated and quite harmless: "If the squared distance between some two soldiers equals to 5, then those soldiers will conflict with each other!"

The drill exercises are held on a rectangular n × m field, split into nm square 1 × 1 segments for each soldier. Thus, the square of the distance between the soldiers that stand on squares (x1, y1) and (x2, y2) equals exactly (x1 - x2)2 + (y1 - y2)2. Now not all nm squad soldiers can participate in the drill exercises as it was before the Fairy Godmother's curse. Unless, of course, the general wants the soldiers to fight with each other or even worse... For example, if he puts a soldier in the square (2, 2), then he cannot put soldiers in the squares (1, 4), (3, 4), (4, 1) and (4, 3) — each of them will conflict with the soldier in the square (2, 2).

Your task is to help the general. You are given the size of the drill exercise field. You are asked to calculate the maximum number of soldiers that can be simultaneously positioned on this field, so that no two soldiers fall under the Fairy Godmother's curse.

Input

The single line contains space-separated integers n and m (1 ≤ n, m ≤ 1000) that represent the size of the drill exercise field.

Output

Print the desired maximum number of warriors.

Examples

Input

2 4

Output

4

Input

3 4

Output

6

Note

In the first sample test Sir Lancelot can place his 4 soldiers on the 2 × 4 court as follows (the soldiers' locations are marked with gray circles on the scheme):

<image>

In the second sample test he can place 6 soldiers on the 3 × 4 site in the following manner:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main() {
  int n, m;
  cin >> n >> m;
  int best;
  if (n == 1) {
    best = m;
  } else if (m == 1) {
    best = n;
  } else if (n == 2) {
    if (m % 4 == 1) {
      best = m + 1;
    } else {
      best = ceil((double)m / 4) * 4;
    }
  } else if (m == 2) {
    if (n % 4 == 1) {
      best = n + 1;
    } else {
      best = ceil((double)n / 4) * 4;
    }
  } else if (m >= 3 && n >= 3) {
    best = ceil((double)n * m / 2);
  } else {
    assert(0);
  }
  cout << best;
}

```


### Prompt

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

Example

Input

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

Output

1 3

### Response

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

struct Edge{
    int s,d;
};
using Graph=vector<vector<int>>;
map<pair<int,int>,int> mp2;
int cntBridge(const Graph& g){
    int n=g.size();
    vector<int> pre(n,-1),low(n,-1);
    int k=0;
    int res=0;
    int root=0;
    function<int(int,int)> dfs=[&](int v,int pv){
        if(pre[v]!=-1) return low[v];
        pre[v]=k++;
        low[v]=pre[v];
        for(auto &to:g[v]){
            if(to!=pv){
                if(pre[to]==-1){
                    low[v]=min(low[v],dfs(to,v));
                    if(low[to]==pre[to] && to!=root){
                        if(mp2[{v,to}]==1){
                            res++;
                            //cerr<<v<<" "<<to<<endl;
                        }
                    }
                }
                else{
                    low[v]=min(low[v],dfs(to,v));
                }
            }
        }
        return low[v];
    };
    vector<int> f(n,0);
    for(int i=0;i<n;i++){
        if(pre[i]==-1){
            root=i;
            dfs(i,-1);
            f[i]=1;
        }
    }
    return res;
}
int main(){
    int n,m;
    cin>>n>>m;
    map<int,vector<Edge>> mp;
    for(int i=0;i<m;i++){
        int s,d,c;
        cin>>s>>d>>c;
        s--,d--;
        mp[c].push_back({s,d});
    }
    Graph g(n);
    int cnt=0;
    int sum=0;

    vector<int> rank(n);
    vector<int> par(n);
    iota(par.begin(),par.end(),0);
    function<int(int)> find=[&](int x){
        if(par[x]==x) return x;
        else return par[x]=find(par[x]);
    };
    auto unite=[&](int x,int y){
        x=find(x),y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]) par[x]=y;
        else{
            if(rank[x]==rank[y]) rank[x]++;
            par[y]=x;
        }
    };

    for(auto &e:mp){
        int c=e.first;
        vector<Edge> edges=e.second;
        Graph g(n);
        for(auto &e:edges){
            int x=find(e.s),y=find(e.d);
            if(x==y) continue;
            //cerr<<"#"<<x<<" "<<y<<endl;
            mp2[{x,y}]++;
            mp2[{y,x}]++;
            //cerr<<mp2[{x,y}]<<endl;
            //cerr<<mp2[{y,x}]<<endl;
            g[x].push_back(y);
            g[y].push_back(x);
        }
        int x=cntBridge(g);
        cnt+=x;
        sum+=x*c;
        for(auto &e:edges) unite(e.s,e.d);
    }
    cout<<cnt<<" "<<sum<<endl;
    return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner obtains 3 points. In the case of a draw, they obtain 1 point each.

Write a program which reads a sequence of cards Taro and Hanako have and reports the final scores of the game.

Constraints

* n ≤ 1000
* The length of the string ≤ 100

Input

In the first line, the number of cards n is given. In the following n lines, the cards for n turns are given respectively. For each line, the first string represents the Taro's card and the second one represents Hanako's card.

Output

Print the final scores of Taro and Hanako respectively. Put a single space character between them.

Example

Input

3
cat dog
fish fish
lion tiger

Output

1 7

### Response

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

int main(){

	int n;
	cin >> n;
	int t = 0;
	int h = 0;
	for (int i = 0; i < n; i++){
		string a, b;
		cin >> a>> b;
		if (a == b){
			t++;
			h++;

		}
		else if(a>b){
			t += 3;
		}
		else if (a < b){
			h += 3;
		}
	}
	cout << t << ' ' << h << endl;
	return 0;

}

```


### Prompt

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

Constraints

* All values in input are integers.
* 1\leq N, M\leq 12
* 1\leq X\leq 10^5
* 1\leq C_i \leq 10^5
* 0\leq A_{i, j} \leq 10^5

Input

Input is given from Standard Input in the following format:

N M X
C_1 A_{1,1} A_{1,2} \cdots A_{1,M}
C_2 A_{2,1} A_{2,2} \cdots A_{2,M}
\vdots
C_N A_{N,1} A_{N,2} \cdots A_{N,M}

Output

If the objective is not achievable, print `-1`; otherwise, print the minimum amount of money needed to achieve it.

Examples

Input

3 3 10
60 2 2 4
70 8 7 9
50 2 3 9

Output

120

Input

3 3 10
100 3 1 4
100 1 5 9
100 2 6 5

Output

-1

Input

8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2

Output

1067

### Response

```cpp
#include <stdio.h>

int ans = 123456789;
int check[20];
int S = 0;
int a,b,c;
int x[20],y[20][20];
void func(int k)
{
	if(k>a)
	{
		for(int j=1;j<=b;j++) if(check[j]<c) return;
		ans = ans<S?ans:S;
		return;
	}

	func(k+1);
	S += x[k];
	for(int j=1;j<=b;j++) check[j] += y[k][j];
	func(k+1);
	for(int j=1;j<=b;j++) check[j] -= y[k][j];
	S -= x[k];
}

int main()
{
	scanf("%d%d%d",&a,&b,&c);
	for(int i=1;i<=a;i++)
	{
		scanf("%d",&x[i]);
		for(int j=1;j<=b;j++) scanf("%d",&y[i][j]);
	}

	func(1);
	printf("%d",ans==123456789?-1:ans);
}
```


### Prompt

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

Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 1 to n from top to bottom and the columns — from 1 to m, from left to right. We'll represent the cell on the intersection of the i-th row and j-th column as (i, j). Just as is expected, some cells of the giant candy matrix contain candies. Overall the matrix has p candies: the k-th candy is at cell (xk, yk).

The time moved closer to dinner and Inna was already going to eat p of her favourite sweets from the matrix, when suddenly Sereja (for the reason he didn't share with anyone) rotated the matrix x times clockwise by 90 degrees. Then he performed the horizontal rotate of the matrix y times. And then he rotated the matrix z times counterclockwise by 90 degrees. The figure below shows how the rotates of the matrix looks like.

<image>

Inna got really upset, but Duma suddenly understood two things: the candies didn't get damaged and he remembered which cells contained Inna's favourite sweets before Sereja's strange actions. Help guys to find the new coordinates in the candy matrix after the transformation Sereja made!

Input

The first line of the input contains fix integers n, m, x, y, z, p (1 ≤ n, m ≤ 109; 0 ≤ x, y, z ≤ 109; 1 ≤ p ≤ 105).

Each of the following p lines contains two integers xk, yk (1 ≤ xk ≤ n; 1 ≤ yk ≤ m) — the initial coordinates of the k-th candy. Two candies can lie on the same cell.

Output

For each of the p candies, print on a single line its space-separated new coordinates.

Examples

Input

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

Output

1 3
1 2
1 1
2 3
2 2
2 1
3 3
3 2
3 1

Note

Just for clarity. Horizontal rotating is like a mirroring of the matrix. For matrix:

    QWER      REWQ
    ASDF  ->  FDSA
    ZXCV      VCXZ

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int n, m, x, y, z, bM, bN;
void reset() {
  n = bN;
  m = bM;
}
void rotateClockWise(pair<long long int, long long int> &in) {
  for (int i = 0; i < x; i++) {
    long long int x = in.first, y = in.second;
    in.second = n + 1 - x;
    in.first = y;
    swap(n, m);
  }
}
void rotateCounterClockWise(pair<long long int, long long int> &in) {
  for (int i = 0; i < z; i++) {
    long long int x = in.first, y = in.second;
    in.first = m + 1 - y;
    in.second = x;
    swap(n, m);
  }
}
void rotateHorizontal(pair<long long int, long long int> &in) {
  in.second = m + 1 - in.second;
}
int main() {
  ios::sync_with_stdio(false);
  pair<long long int, long long int> inp;
  int p;
  cin >> n >> m >> x >> y >> z >> p;
  x %= 4ll;
  y %= 2ll;
  z %= 4ll;
  bN = n;
  bM = m;
  while (p--) {
    cin >> inp.first >> inp.second;
    rotateClockWise(inp);
    if (y != 0) rotateHorizontal(inp);
    rotateCounterClockWise(inp);
    cout << inp.first << " " << inp.second << "\n";
    reset();
  }
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Adam Ivan is working as a system administrator at Soy Group, Inc. He is now facing at a big trouble: a number of computers under his management have been infected by a computer virus. Unfortunately, anti-virus system in his company failed to detect this virus because it was very new.

Adam has identified the first computer infected by the virus and collected the records of all data packets sent within his network. He is now trying to identify which computers have been infected. A computer is infected when receiving any data packet from any infected computer. The computer is not infected, on the other hand, just by sending data packets to infected computers.

It seems almost impossible for him to list all infected computers by hand, because the size of the packet records is fairly large. So he asked you for help: write a program that can identify infected computers.

Input

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

N M
t1 s1 d1
t2 s2 d2
...
tM sM dM

N is the number of computers; M is the number of data packets; ti (1 ≤ i ≤ M) is the time when the i-th data packet is sent; si and di (1 ≤ i ≤ M) are the source and destination computers of the i-th data packet respectively. The first infected computer is indicated by the number 1; the other computers are indicated by unique numbers between 2 and N.

The input meets the following constraints: 0 < N ≤ 20000, 0 ≤ M ≤ 20000, and 0 ≤ ti ≤ 109 for 1 ≤ i ≤ N; all ti 's are different; and the source and destination of each packet are always different.

The last dataset is followed by a line containing two zeros. This line is not a part of any dataset and should not be processed.

Output

For each dataset, print the number of computers infected by the computer virus.

Example

Input

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

Output

3
1

### Response

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

using namespace std;

struct packet {
    int time, src, dst;
};

bool operator<(const packet& a, const packet& b)
{
    return a.time<b.time;
}

int main()
{
    int n, m;
    while(cin >> n >> m, n|m)
    {
        set<int> infected;
        infected.insert(1);
        packet ps[m];
        for(int i=0; i<m; i++)
        {
            cin >> ps[i].time >> ps[i].src >> ps[i].dst;
        }
        sort(ps, ps+m);
        for(int i=0; i<m; i++)
        {
            if(infected.find(ps[i].src)!=infected.end())
            {
                infected.insert(ps[i].dst);
            }
        }
        cout << infected.size() << endl;
    }

}
```


### Prompt

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

Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.

Alice initially has a token on some cell on the line, and Bob tries to guess where it is.

Bob guesses a sequence of line cell numbers x_1, x_2, …, x_k in order. In the i-th question, Bob asks Alice if her token is currently on cell x_i. That is, Alice can answer either "YES" or "NO" to each Bob's question.

At most one time in this process, before or after answering a question, Alice is allowed to move her token from her current cell to some adjacent cell. Alice acted in such a way that she was able to answer "NO" to all of Bob's questions.

Note that Alice can even move her token before answering the first question or after answering the last question. Alice can also choose to not move at all.

You are given n and Bob's questions x_1, …, x_k. You would like to count the number of scenarios that let Alice answer "NO" to all of Bob's questions.

Let (a,b) denote a scenario where Alice starts at cell a and ends at cell b. Two scenarios (a_i, b_i) and (a_j, b_j) are different if a_i ≠ a_j or b_i ≠ b_j.

Input

The first line contains two integers n and k (1 ≤ n,k ≤ 10^5) — the number of cells and the number of questions Bob asked.

The second line contains k integers x_1, x_2, …, x_k (1 ≤ x_i ≤ n) — Bob's questions.

Output

Print a single integer, the number of scenarios that let Alice answer "NO" to all of Bob's questions.

Examples

Input

5 3
5 1 4

Output

9

Input

4 8
1 2 3 4 4 3 2 1

Output

0

Input

100000 1
42

Output

299997

Note

The notation (i,j) denotes a scenario where Alice starts at cell i and ends at cell j.

In the first example, the valid scenarios are (1, 2), (2, 1), (2, 2), (2, 3), (3, 2), (3, 3), (3, 4), (4, 3), (4, 5). For example, (3,4) is valid since Alice can start at cell 3, stay there for the first three questions, then move to cell 4 after the last question.

(4,5) is valid since Alice can start at cell 4, stay there for the first question, the move to cell 5 for the next two questions. Note that (4,5) is only counted once, even though there are different questions that Alice can choose to do the move, but remember, we only count each pair of starting and ending positions once.

In the second example, Alice has no valid scenarios.

In the last example, all (i,j) where |i-j| ≤ 1 except for (42, 42) are valid scenarios.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int first[100010], last[100010];
int q[100010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int i, j;
  int cnt = 0;
  int n, k;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    first[i] = INT_MAX;
    last[i] = -1;
  }
  for (i = 0; i < k; i++) {
    cin >> q[i];
    q[i]--;
    last[q[i]] = max(last[q[i]], i);
    first[q[i]] = min(first[q[i]], i);
  }
  for (i = 0; i < n; i++) {
    if (first[i] == INT_MAX) cnt++;
    if (i < n - 1) {
      if (first[i + 1] > last[i]) cnt++;
    }
    if (i > 0) {
      if (first[i - 1] > last[i]) cnt++;
    }
  }
  cout << cnt << endl;
}

```


### Prompt

Generate a CPP solution to the following problem:

Each employee of the "Blake Techologies" company uses a special messaging app "Blake Messenger". All the stuff likes this app and uses it constantly. However, some important futures are missing. For example, many users want to be able to search through the message history. It was already announced that the new feature will appear in the nearest update, when developers faced some troubles that only you may help them to solve.

All the messages are represented as a strings consisting of only lowercase English letters. In order to reduce the network load strings are represented in the special compressed form. Compression algorithm works as follows: string is represented as a concatenation of n blocks, each block containing only equal characters. One block may be described as a pair (li, ci), where li is the length of the i-th block and ci is the corresponding letter. Thus, the string s may be written as the sequence of pairs <image>.

Your task is to write the program, that given two compressed string t and s finds all occurrences of s in t. Developers know that there may be many such occurrences, so they only ask you to find the number of them. Note that p is the starting position of some occurrence of s in t if and only if tptp + 1...tp + |s| - 1 = s, where ti is the i-th character of string t.

Note that the way to represent the string in compressed form may not be unique. For example string "aaaa" may be given as <image>, <image>, <image>...

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of blocks in the strings t and s, respectively.

The second line contains the descriptions of n parts of string t in the format "li-ci" (1 ≤ li ≤ 1 000 000) — the length of the i-th part and the corresponding lowercase English letter.

The second line contains the descriptions of m parts of string s in the format "li-ci" (1 ≤ li ≤ 1 000 000) — the length of the i-th part and the corresponding lowercase English letter.

Output

Print a single integer — the number of occurrences of s in t.

Examples

Input

5 3
3-a 2-b 4-c 3-a 2-c
2-a 2-b 1-c

Output

1

Input

6 1
3-a 6-b 7-a 4-c 8-e 2-a
3-a

Output

6

Input

5 5
1-h 1-e 1-l 1-l 1-o
1-w 1-o 1-r 1-l 1-d

Output

0

Note

In the first sample, t = "aaabbccccaaacc", and string s = "aabbc". The only occurrence of string s in string t starts at position p = 2.

In the second sample, t = "aaabbbbbbaaaaaaacccceeeeeeeeaa", and s = "aaa". The occurrences of s in t start at positions p = 1, p = 10, p = 11, p = 12, p = 13 and p = 14.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long n, m;
string str1;
string str2;
long long curcnt = 0;
char curchar = '$';
long long ans = 0;
char fchar;
long long fcnt;
char lchar;
long long lcnt;
void getZarr(string str, long long Z[]) {
  long long n = str.length();
  long long L, R, k;
  L = R = 0;
  for (long long i = 1; i < n; ++i) {
    if (i > R) {
      L = R = i;
      while (R < n && str[R - L] == str[R]) R++;
      Z[i] = R - L;
      R--;
    } else {
      k = i - L;
      if (Z[k] < R - i + 1)
        Z[i] = Z[k];
      else {
        L = i;
        while (R < n && str[R - L] == str[R]) R++;
        Z[i] = R - L;
        R--;
      }
    }
  }
}
void search(string text, string pattern) {
  string concat = pattern + "$" + text;
  long long l = concat.length();
  long long Z[l];
  getZarr(concat, Z);
  char llchar = '$';
  long long llnum = 0;
  long long cur = 0;
  for (long long i = 0; i < 100; ++i) concat += '$';
  for (long long i = 0; i < l; ++i) {
    if (isalpha(concat[i]) || concat[i] == '$') {
      llchar = concat[i];
      llnum = cur;
      cur = 0;
    } else {
      cur *= 10;
      cur += concat[i] - '0';
    }
    if (Z[i] == pattern.length()) {
      if (llchar != fchar) {
        continue;
      }
      if (llnum < fcnt) {
        continue;
      }
      long long lllol = i + Z[i];
      long long num = 0;
      while (isdigit(concat[lllol]) && lllol < l) {
        num *= 10;
        num += concat[lllol] - '0';
        lllol++;
      }
      char tmp = concat[lllol];
      if (tmp != lchar) {
        continue;
      }
      if (num < lcnt) {
        continue;
      }
      ++ans;
    }
  }
}
vector<pair<char, long long> > arr1;
vector<pair<char, long long> > arr2;
void brute() {
  if (arr2.size() == 1) {
    for (auto it : arr1) {
      if (it.first == arr2[0].first) {
        ans += max(0LL, it.second - arr2[0].second + 1);
      }
    }
  } else {
    char lst = '$';
    long long cnt = 0;
    for (auto it : arr1) {
      if (lst == arr2[0].first && it.first == arr2[1].first) {
        ans += (cnt >= arr2[0].second) && (it.second >= arr2[1].second);
      }
      lst = it.first;
      cnt = it.second;
    }
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i) {
    long long tmp;
    char x1;
    char x2;
    cin >> tmp >> x1 >> x2;
    if (x2 == curchar) {
      curcnt += tmp;
    } else {
      if (curchar != '$') {
        str1 += to_string(curcnt);
        str1 += curchar;
        arr1.emplace_back(make_pair(curchar, curcnt));
      }
      curchar = x2;
      curcnt = tmp;
    }
  }
  str1 += to_string(curcnt);
  str1 += curchar;
  arr1.emplace_back(make_pair(curchar, curcnt));
  curcnt = 0;
  curchar = '$';
  bool ok = 0;
  for (long long i = 1; i <= m; ++i) {
    long long tmp;
    char x1;
    char x2;
    cin >> tmp >> x1 >> x2;
    if (x2 == curchar) {
      curcnt += tmp;
    } else {
      if (curchar != '$') {
        if (ok) {
          str2 += to_string(curcnt);
          str2 += curchar;
        } else {
          ok = 1;
          fchar = curchar;
          fcnt = curcnt;
        }
        arr2.emplace_back(make_pair(curchar, curcnt));
      }
      curchar = x2;
      curcnt = tmp;
    }
  }
  if (ok) {
    str2 += to_string(curcnt);
    str2 += curchar;
    lchar = curchar;
    lcnt = curcnt;
  } else {
    ok = 1;
    fchar = curchar;
    fcnt = curcnt;
  }
  arr2.emplace_back(make_pair(curchar, curcnt));
  if (arr2.size() <= 2) {
    brute();
    return 0;
  }
  str2.pop_back();
  while (isdigit(str2.back())) {
    str2.pop_back();
  }
  search(str1, str2);
  cout << ans;
}

```


### Prompt

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

Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.

Pavel drew a grid maze with all empty cells forming a connected area. That is, you can go from any empty cell to any other one. Pavel doesn't like it when his maze has too little walls. He wants to turn exactly k empty cells into walls so that all the remaining cells still formed a connected area. Help him.

Input

The first line contains three integers n, m, k (1 ≤ n, m ≤ 500, 0 ≤ k < s), where n and m are the maze's height and width, correspondingly, k is the number of walls Pavel wants to add and letter s represents the number of empty cells in the original maze.

Each of the next n lines contains m characters. They describe the original maze. If a character on a line equals ".", then the corresponding cell is empty and if the character equals "#", then the cell is a wall.

Output

Print n lines containing m characters each: the new maze that fits Pavel's requirements. Mark the empty cells that you transformed into walls as "X", the other cells must be left without changes (that is, "." and "#").

It is guaranteed that a solution exists. If there are multiple solutions you can output any of them.

Examples

Input

3 4 2
#..#
..#.
#...

Output

#.X#
X.#.
#...

Input

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

Output

#XXX
#X#.
X#..
...#
.#.#

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[502][502];
int n, m, k;
int cnt;
class Graph {
  int V;
  list<int> *adj;
  void DFSUtil(int v, bool visited[]);

 public:
  Graph(int V);
  void addEdge(int v, int w);
  void DFS(int v);
};
Graph::Graph(int V) {
  this->V = V;
  adj = new list<int>[V];
}
void Graph::addEdge(int v, int w) {
  adj[v].push_back(w);
  adj[w].push_back(v);
}
void Graph::DFSUtil(int v, bool visited[]) {
  visited[v] = true;
  cnt--;
  list<int>::iterator i;
  for (i = adj[v].begin(); i != adj[v].end() && cnt > 0; ++i)
    if (!visited[*i]) DFSUtil(*i, visited);
}
void Graph::DFS(int v) {
  bool *visited = new bool[V];
  for (int i = 0; i < V; i++) visited[i] = false;
  DFSUtil(v, visited);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == -1)
        printf("#");
      else {
        if (visited[a[i][j]])
          printf(".");
        else
          printf("X");
      }
    }
    printf("\n");
  }
}
int main() {
  int i, j;
  cin >> n >> m >> k;
  string str;
  int node = 0;
  for (i = 1; i <= n; i++) {
    cin >> str;
    for (j = 1; j <= m; j++) {
      if (str[j - 1] == '#')
        a[i][j] = -1;
      else {
        a[i][j] = node;
        node++;
      }
    }
  }
  cnt = node - k;
  Graph g(node + 1);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (a[i][j] >= 0) {
        if (a[i + 1][j] >= 0) {
          g.addEdge(a[i][j], a[i + 1][j]);
        }
        if (a[i][j + 1] >= 0) {
          g.addEdge(a[i][j], a[i][j + 1]);
        }
      }
    }
  }
  g.DFS(0);
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves.

Tablecity can be represented as 1000 × 2 grid, where every cell represents one district. Each district has its own unique name “(X, Y)”, where X and Y are the coordinates of the district in the grid. The thief’s movement is as

Every hour the thief will leave the district (X, Y) he is currently hiding in, and move to one of the districts: (X - 1, Y), (X + 1, Y), (X - 1, Y - 1), (X - 1, Y + 1), (X + 1, Y - 1), (X + 1, Y + 1) as long as it exists in Tablecity.

Below is an example of thief’s possible movements if he is located in district (7,1):

<image>

Albert has enough people so that every hour he can pick any two districts in Tablecity and fully investigate them, making sure that if the thief is located in one of them, he will get caught. Albert promised the President that the thief will be caught in no more than 2015 hours and needs your help in order to achieve that.

Input

There is no input for this problem.

Output

The first line of output contains integer N – duration of police search in hours. Each of the following N lines contains exactly 4 integers Xi1, Yi1, Xi2, Yi2 separated by spaces, that represent 2 districts (Xi1, Yi1), (Xi2, Yi2) which got investigated during i-th hour. Output is given in chronological order (i-th line contains districts investigated during i-th hour) and should guarantee that the thief is caught in no more than 2015 hours, regardless of thief’s initial position and movement.

  * N ≤ 2015
  * 1 ≤ X ≤ 1000
  * 1 ≤ Y ≤ 2

Examples

Input

В этой задаче нет примеров ввода-вывода.
This problem doesn't have sample input and output.

Output

Смотрите замечание ниже.
See the note below.

Note

Let's consider the following output:

2

5 1 50 2

8 1 80 2

This output is not guaranteed to catch the thief and is not correct. It is given to you only to show the expected output format. There exists a combination of an initial position and a movement strategy such that the police will not catch the thief.

Consider the following initial position and thief’s movement:

In the first hour, the thief is located in district (1,1). Police officers will search districts (5,1) and (50,2) and will not find him.

At the start of the second hour, the thief moves to district (2,2). Police officers will search districts (8,1) and (80,2) and will not find him.

Since there is no further investigation by the police, the thief escaped!

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cout << 2000 << '\n';
  for (long long i = 1; i <= 1000; i++)
    cout << i << " " << 1 << " " << i << " " << 2 << '\n';
  for (int i = 1000; i >= 1; i--)
    cout << i << " " << 1 << " " << i << " " << 2 << '\n';
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

For a positive integer X, let f(X) be the number of positive divisors of X.

Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Constraints

* 1 \leq N \leq 10^7

Input

Input is given from Standard Input in the following format:

N

Output

Print the value \sum_{K=1}^N K\times f(K).

Examples

Input

4

Output

23

Input

100

Output

26879

Input

10000000

Output

838627288460105

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,x,i,sum=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        x=(n/i);
        sum=sum+i*((x*(x+1))/2);
    }
    cout<<sum<<"\n";
}

```


### Prompt

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

A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.

The next prime number after x is the smallest prime number greater than x. For example, the next prime number after 2 is 3, and the next prime number after 3 is 5. Note that there is exactly one next prime number after each number. So 5 is not the next prime number for 2.

One cold April morning Panoramix predicted that soon Kakofonix will break free from his straitjacket, and this will be a black day for the residents of the Gallic countryside.

Panoramix's prophecy tells that if some day Asterix and Obelix beat exactly x Roman soldiers, where x is a prime number, and next day they beat exactly y Roman soldiers, where y is the next prime number after x, then it's time to wait for Armageddon, for nothing can shut Kakofonix up while he sings his infernal song.

Yesterday the Gauls beat n Roman soldiers and it turned out that the number n was prime! Today their victims were a troop of m Romans (m > n). Determine whether the Gauls should wait for the black day after today's victory of Asterix and Obelix?

Input

The first and only input line contains two positive integers — n and m (2 ≤ n < m ≤ 50). It is guaranteed that n is prime.

Pretests contain all the cases with restrictions 2 ≤ n < m ≤ 4.

Output

Print YES, if m is the next prime number after n, or NO otherwise.

Examples

Input

3 5

Output

YES

Input

7 11

Output

YES

Input

7 9

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return (a * (b / gcd(a, b))); }
bool isPrime(int n) {
  if (n == 2) return true;
  if (n < 2 || (n & 1) != 1) return false;
  for (int i = 3; i * i <= n; i += 2)
    if (n % i == 0) return false;
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  if (isPrime(m) != true)
    cout << "NO" << endl;
  else {
    for (int i = n + 1; i <= m; ++i) {
      if (isPrime(i) == true) {
        if (i == m)
          cout << "YES" << endl;
        else
          cout << "NO" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }
  return 0;
}

```


### Prompt

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

Vova again tries to play some computer card game.

The rules of deck creation in this game are simple. Vova is given an existing deck of n cards and a magic number k. The order of the cards in the deck is fixed. Each card has a number written on it; number ai is written on the i-th card in the deck.

After receiving the deck and the magic number, Vova removes x (possibly x = 0) cards from the top of the deck, y (possibly y = 0) cards from the bottom of the deck, and the rest of the deck is his new deck (Vova has to leave at least one card in the deck after removing cards). So Vova's new deck actually contains cards x + 1, x + 2, ... n - y - 1, n - y from the original deck.

Vova's new deck is considered valid iff the product of all numbers written on the cards in his new deck is divisible by k. So Vova received a deck (possibly not a valid one) and a number k, and now he wonders, how many ways are there to choose x and y so the deck he will get after removing x cards from the top and y cards from the bottom is valid?

Input

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

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the numbers written on the cards.

Output

Print the number of ways to choose x and y so the resulting deck is valid.

Examples

Input

3 4
6 2 8

Output

4

Input

3 6
9 1 14

Output

1

Note

In the first example the possible values of x and y are:

  1. x = 0, y = 0;
  2. x = 1, y = 0;
  3. x = 2, y = 0;
  4. x = 0, y = 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long a[500000];
long long n, k;
vector<long long> m;
void build(long long i, long long s, long long e) {
  if (s == e) {
    a[i] = m[s] % k;
    return;
  }
  long long mid = (s + e) / 2;
  build(2 * i + 1, s, mid);
  build(2 * i + 2, mid + 1, e);
  a[i] = (a[2 * i + 1] * a[2 * i + 2]) % k;
}
long long query(long long i, long long s, long long e, long long l,
                long long r) {
  if (s > r || l > e) return 1;
  if (s >= l && r >= e) return a[i];
  long long mid = (s + e) / 2;
  return (query(2 * i + 1, s, mid, l, r) * query(2 * i + 2, mid + 1, e, l, r)) %
         k;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  m.resize(n);
  for (long long i = 0; i < n; i++) cin >> m[i];
  build(0, 0, n - 1);
  long long p = 0, ans = 0;
  for (long long i = 0; i < n; i++) {
    if (i > p) p = i;
    while (p < n && query(0, 0, n - 1, i, p) != 0) p++;
    if (p != n)
      ans += (n - p);
    else
      break;
  }
  cout << ans;
}

```


### Prompt

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

Wilbur is playing with a set of n points on the coordinate plane. All points have non-negative integer coordinates. Moreover, if some point (x, y) belongs to the set, then all points (x', y'), such that 0 ≤ x' ≤ x and 0 ≤ y' ≤ y also belong to this set.

Now Wilbur wants to number the points in the set he has, that is assign them distinct integer numbers from 1 to n. In order to make the numbering aesthetically pleasing, Wilbur imposes the condition that if some point (x, y) gets number i, then all (x',y') from the set, such that x' ≥ x and y' ≥ y must be assigned a number not less than i. For example, for a set of four points (0, 0), (0, 1), (1, 0) and (1, 1), there are two aesthetically pleasing numberings. One is 1, 2, 3, 4 and another one is 1, 3, 2, 4.

Wilbur's friend comes along and challenges Wilbur. For any point he defines it's special value as s(x, y) = y - x. Now he gives Wilbur some w1, w2,..., wn, and asks him to find an aesthetically pleasing numbering of the points in the set, such that the point that gets number i has it's special value equal to wi, that is s(xi, yi) = yi - xi = wi.

Now Wilbur asks you to help him with this challenge.

Input

The first line of the input consists of a single integer n (1 ≤ n ≤ 100 000) — the number of points in the set Wilbur is playing with.

Next follow n lines with points descriptions. Each line contains two integers x and y (0 ≤ x, y ≤ 100 000), that give one point in Wilbur's set. It's guaranteed that all points are distinct. Also, it is guaranteed that if some point (x, y) is present in the input, then all points (x', y'), such that 0 ≤ x' ≤ x and 0 ≤ y' ≤ y, are also present in the input.

The last line of the input contains n integers. The i-th of them is wi ( - 100 000 ≤ wi ≤ 100 000) — the required special value of the point that gets number i in any aesthetically pleasing numbering.

Output

If there exists an aesthetically pleasant numbering of points in the set, such that s(xi, yi) = yi - xi = wi, then print "YES" on the first line of the output. Otherwise, print "NO".

If a solution exists, proceed output with n lines. On the i-th of these lines print the point of the set that gets number i. If there are multiple solutions, print any of them.

Examples

Input

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

Output

YES
0 0
1 0
2 0
0 1
1 1

Input

3
1 0
0 0
2 0
0 1 2

Output

NO

Note

In the first sample, point (2, 0) gets number 3, point (0, 0) gets number one, point (1, 0) gets number 2, point (1, 1) gets number 5 and point (0, 1) gets number 4. One can easily check that this numbering is aesthetically pleasing and yi - xi = wi.

In the second sample, the special values of the points in the set are 0,  - 1, and  - 2 while the sequence that the friend gives to Wilbur is 0, 1, 2. Therefore, the answer does not exist.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct node {
  long long val;
  node() { val = 0; }
  node(long long val) : val(val) {}
};
node tree[4 * 100000];
node combine(node a, node b) {
  node res;
  res.val = max(a.val, b.val);
  return res;
}
void range_update(long long root, long long l, long long r, long long a,
                  long long val) {
  if (l == r && l == a) {
    tree[root].val = max(val, tree[root].val);
    return;
  }
  long long m = (l + r) / 2;
  if (a <= m)
    range_update(2 * root, l, m, a, val);
  else
    range_update(2 * root + 1, m + 1, r, a, val);
  tree[root] = combine(tree[2 * root], tree[2 * root + 1]);
}
node query(long long root, long long l, long long r, long long a, long long b) {
  if (l == a && r == b) return tree[root];
  long long m = (l + r) / 2;
  if (b <= m)
    return query(2 * root, l, m, a, b);
  else if (m < a)
    return query(2 * root + 1, m + 1, r, a, b);
  else {
    node left = query(2 * root, l, m, a, m);
    node right = query(2 * root + 1, m + 1, r, m + 1, b);
    node ans = combine(left, right);
    return ans;
  }
}
struct Point {
  long long x, y;
  Point() {}
  Point(long long x, long long y) : x(x), y(y) {}
};
bool cmp(const Point& a, const Point& b) {
  return a.x < b.x || (a.x == b.x && a.y <= b.y);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<Point> v(n);
  map<long long, queue<long long> > m;
  for (long long i = 0; i < n; i++) {
    cin >> v[i].x >> v[i].y;
  }
  vector<long long> w(n);
  vector<Point> ans(n);
  for (long long i = 0; i < n; i++) {
    cin >> w[i];
    m[w[i]].push(i);
  }
  sort(v.begin(), v.end(), cmp);
  bool ok = true;
  for (long long i = 0; i < n && ok; i++) {
    if (m[v[i].y - v[i].x].empty())
      ok = false;
    else if (query(1, 0, 100000 - 1, 0, v[i].y).val >
             m[v[i].y - v[i].x].front())
      ok = false;
    else {
      ans[m[v[i].y - v[i].x].front()] = v[i];
      range_update(1, 0, 100000 - 1, v[i].y, m[v[i].y - v[i].x].front());
      m[v[i].y - v[i].x].pop();
    }
  }
  if (ok) {
    cout << "YES" << '\n';
    for (long long i = 0; i < n; i++) {
      cout << ans[i].x << " " << ans[i].y << '\n';
    }
  } else
    cout << "NO" << '\n';
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

You are planning to build housing on a street. There are n spots available on the street on which you can build a house. The spots are labeled from 1 to n from left to right. In each spot, you can build a house with an integer height between 0 and h.

In each spot, if a house has height a, you will gain a^2 dollars from it.

The city has m zoning restrictions. The i-th restriction says that the tallest house from spots l_i to r_i (inclusive) must be at most x_i.

You would like to build houses to maximize your profit. Determine the maximum profit possible.

Input

The first line contains three integers n, h, and m (1 ≤ n,h,m ≤ 50) — the number of spots, the maximum height, and the number of restrictions.

Each of the next m lines contains three integers l_i, r_i, and x_i (1 ≤ l_i ≤ r_i ≤ n, 0 ≤ x_i ≤ h) — left and right limits (inclusive) of the i-th restriction and the maximum possible height in that range.

Output

Print a single integer, the maximum profit you can make.

Examples

Input

3 3 3
1 1 1
2 2 3
3 3 2

Output

14

Input

4 10 2
2 3 8
3 4 7

Output

262

Note

In the first example, there are 3 houses, the maximum height of a house is 3, and there are 3 restrictions. The first restriction says the tallest house between 1 and 1 must be at most 1. The second restriction says the tallest house between 2 and 2 must be at most 3. The third restriction says the tallest house between 3 and 3 must be at most 2.

In this case, it is optimal to build houses with heights [1, 3, 2]. This fits within all the restrictions. The total profit in this case is 1^2 + 3^2 + 2^2 = 14.

In the second example, there are 4 houses, the maximum height of a house is 10, and there are 2 restrictions. The first restriction says the tallest house from 2 to 3 must be at most 8. The second restriction says the tallest house from 3 to 4 must be at most 7.

In this case, it's optimal to build houses with heights [10, 8, 7, 7]. We get a profit of 10^2+8^2+7^2+7^2 = 262. Note that there are two restrictions on house 3 and both of them must be satisfied. Also, note that even though there isn't any explicit restrictions on house 1, we must still limit its height to be at most 10 (h=10).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > a;
int y[55];
int main() {
  int n, h, m, l, r, x;
  cin >> n >> h >> m;
  for (int i = 0; i < n; i++) y[i] = h;
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> x;
    l--;
    r--;
    for (int j = l; j <= r; j++) y[j] = min(y[j], x);
  }
  int v = 0;
  for (int i = 0; i < n; i++) v += y[i] * y[i];
  cout << v << endl;
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

Takahashi's house has only one socket.

Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.

One power strip with A sockets can extend one empty socket into A empty sockets.

Find the minimum number of power strips required.

Constraints

* All values in input are integers.
* 2 \leq A \leq 20
* 1 \leq B \leq 20

Input

Input is given from Standard Input in the following format:

A B

Output

Print the minimum number of power strips required.

Examples

Input

4 10

Output

3

Input

8 9

Output

2

Input

8 8

Output

1

### Response

```cpp
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (b - 1 + a - 2) / (a - 1);
}
```


### Prompt

Create a solution in CPP for the following problem:

In AtCoder city, there are five antennas standing in a straight line. They are called Antenna A, B, C, D and E from west to east, and their coordinates are a, b, c, d and e, respectively.
Two antennas can communicate directly if the distance between them is k or less, and they cannot if the distance is greater than k.
Determine if there exists a pair of antennas that cannot communicate directly.
Here, assume that the distance between two antennas at coordinates p and q (p < q) is q - p.

Constraints

* a, b, c, d, e and k are integers between 0 and 123 (inclusive).
* a < b < c < d < e

Input

Input is given from Standard Input in the following format:

a
b
c
d
e
k

Output

Print `:(` if there exists a pair of antennas that cannot communicate directly, and print `Yay!` if there is no such pair.

Examples

Input

1
2
4
8
9
15

Output

Yay!

Input

15
18
26
35
36
18

Output

:(

### Response

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

using namespace std;

int main() {
	int a,b,c,d,e,k;
	cin >> a >> b >> c >> d >> e >> k;

	cout << (((e - a) > k) ? ":(" : "Yay!");

	return 0;
}
```


### Prompt

Construct a cpp code solution to the problem outlined:

You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:

  1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 ≤ i ≤ n) of array s equals <image>. The operation x mod y means that we take the remainder of the division of number x by number y.
  2. Then we write the contents of the array s to the array a. Element number i (1 ≤ i ≤ n) of the array s becomes the i-th element of the array a (ai = si).

You task is to find array a after exactly k described operations are applied.

Input

The first line contains two space-separated integers n and k (1 ≤ n ≤ 2000, 0 ≤ k ≤ 109). The next line contains n space-separated integers a1, a2, ..., an — elements of the array a (0 ≤ ai ≤ 109).

Output

Print n integers — elements of the array a after the operations are applied to it. Print the elements in the order of increasing of their indexes in the array a. Separate the printed numbers by spaces.

Examples

Input

3 1
1 2 3

Output

1 3 6

Input

5 0
3 14 15 92 6

Output

3 14 15 92 6

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[2014];
int C[2014];
const int mod = 1e9 + 7;
int binpow(long long a, int x) {
  long long res = 1;
  while (x) {
    if (x & 1) res = res * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return res;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> a[i];
  C[0] = 1;
  for (int i = 1; i < 2014; ++i) {
    C[i] = C[i - 1] * 1ll * (k + i - 1) % mod;
    C[i] = C[i] * 1ll * binpow(i, mod - 2) % mod;
  }
  for (int i = 0; i < n; ++i) {
    long long res = 0;
    for (int j = i; j > -1; --j) {
      res = res + a[j] * 1ll * (C[i - j]);
      res %= mod;
    }
    cout << res << ' ';
  }
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Given is a lowercase English letter C that is not `z`. Print the letter that follows C in alphabetical order.

Constraints

* C is a lowercase English letter that is not `z`.

Input

Input is given from Standard Input in the following format:

C

Output

Print the letter that follows C in alphabetical order.

Examples

Input

a

Output

b

Input

y

Output

z

### Response

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

int main(){
  char ch;
  cin>>ch;
  cout<<(char)(ch+1);
}
```


### Prompt

Please create a solution in CPP to the following problem:

There are some beautiful girls in Arpa’s land as mentioned before.

Once Arpa came up with an obvious problem:

Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that <image>, where <image> is bitwise xor operation (see notes for explanation).

<image>

Immediately, Mehrdad discovered a terrible solution that nobody trusted. Now Arpa needs your help to implement the solution to that problem.

Input

First line contains two integers n and x (1 ≤ n ≤ 105, 0 ≤ x ≤ 105) — the number of elements in the array and the integer x.

Second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the elements of the array.

Output

Print a single integer: the answer to the problem.

Examples

Input

2 3
1 2

Output

1

Input

6 1
5 1 2 3 4 1

Output

2

Note

In the first sample there is only one pair of i = 1 and j = 2. <image> so the answer is 1.

In the second sample the only two pairs are i = 3, j = 4 (since <image>) and i = 1, j = 5 (since <image>).

A bitwise xor takes two bit integers of equal length and performs the logical xor operation on each pair of corresponding bits. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1. You can read more about bitwise xor operation here: <https://en.wikipedia.org/wiki/Bitwise_operation#XOR>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, x;
  cin >> n >> x;
  long long ar[n];
  map<long long, long long> mp;
  for (long long i = 0; i < n; i++) {
    cin >> ar[i];
    mp[ar[i]]++;
  }
  long long cnt = 0;
  for (long long i = 0; i < n; i++) {
    long long tm = ar[i] ^ x;
    if (mp[tm] > 0 && mp[ar[i]] > 0 && tm != ar[i]) {
      cnt += (mp[ar[i]] * mp[tm]);
      mp[ar[i]] = 0, mp[tm] = 0;
    } else if (tm == ar[i] && mp[tm] >= 2) {
      cnt += (mp[tm] * (mp[tm] - 1)) / 2;
      mp[ar[i]] = 0, mp[tm] = 0;
    }
  }
  cout << cnt << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(NULL);
  solve();
  return 0;
}

```


### Prompt

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

Let a and b be some non-negative integers. Let's define strange addition of a and b as following:

  1. write down the numbers one under another and align them by their least significant digit;
  2. add them up digit by digit and concatenate the respective sums together.

Assume that both numbers have an infinite number of leading zeros.

For example, let's take a look at a strange addition of numbers 3248 and 908:

<image>

You are given a string c, consisting of n digits from 0 to 9. You are also given m updates of form:

  * x~d — replace the digit at the x-th position of c with a digit d.

Note that string c might have leading zeros at any point of time.

After each update print the number of pairs (a, b) such that both a and b are non-negative integers and the result of a strange addition of a and b is equal to c.

Note that the numbers of pairs can be quite large, so print them modulo 998244353.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 5 ⋅ 10^5) — the length of the number c and the number of updates.

The second line contains a string c, consisting of exactly n digits from 0 to 9.

Each of the next m lines contains two integers x and d (1 ≤ x ≤ n, 0 ≤ d ≤ 9) — the descriptions of updates.

Output

Print m integers — the i-th value should be equal to the number of pairs (a, b) such that both a and b are non-negative integers and the result of a strange addition of a and b is equal to c after i updates are applied.

Note that the numbers of pairs can be quite large, so print them modulo 998244353.

Example

Input

2 3
14
2 4
2 1
1 0

Output

15
12
2

Note

After the first update c is equal to 14. The pairs that sum up to 14 are: (0, 14), (1, 13), (2, 12), (3, 11), (4, 10), (5, 9), (6, 8), (7, 7), (8, 6), (9, 5), (10, 4), (11, 3), (12, 2), (13, 1), (14, 0).

After the second update c is equal to 11.

After the third update c is equal to 01.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void chkmin(T &a, const T &b) {
  a = a < b ? a : b;
}
template <typename T>
inline void chkmax(T &a, const T &b) {
  a = a > b ? a : b;
}
const int MAXN = 500005, MAXT = 1 << 20, MOD = 998244353;
struct Mat {
  long long a[2][2];
  Mat() { memset(a, 0, sizeof(a)); }
  const long long *operator[](int x) const { return a[x]; }
  long long *operator[](int x) { return a[x]; }
  Mat operator*(const Mat &b) const {
    Mat res;
    res[0][0] = (a[0][0] * b[0][0] + a[0][1] * b[1][0]) % MOD;
    res[0][1] = (a[0][0] * b[0][1] + a[0][1] * b[1][1]) % MOD;
    res[1][0] = (a[1][0] * b[0][0] + a[1][1] * b[1][0]) % MOD;
    res[1][1] = (a[1][0] * b[0][1] + a[1][1] * b[1][1]) % MOD;
    return res;
  }
} nd[MAXT];
int num[100], n, Q;
char str[MAXN];
void calc(Mat &m, int p) {
  m[0][0] = 0, m[1][0] = 1;
  m[1][1] = str[p] + 1;
  m[0][1] = str[p - 1] != 0 ? num[str[p - 1] * 10 + str[p]] : 0;
}
void build(int l, int r, int k) {
  if (l == r) return calc(nd[k], l);
  int mid = (l + r) >> 1;
  build(l, mid, k << 1);
  build(mid + 1, r, k << 1 | 1);
  nd[k] = nd[k << 1] * nd[k << 1 | 1];
}
void modify(int a, int b, int l = 1, int r = n, int k = 1) {
  if (a > r || b < l) return;
  if (l == r) return calc(nd[k], l);
  int mid = (l + r) >> 1;
  modify(a, b, l, mid, k << 1);
  modify(a, b, mid + 1, r, k << 1 | 1);
  nd[k] = nd[k << 1] * nd[k << 1 | 1];
}
int main() {
  scanf("%d%d", &n, &Q);
  scanf("%s", str + 1);
  for (int i = 1; i <= n; i++) str[i] -= '0';
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      if (i + j >= 10) ++num[i + j];
  build(1, n, 1);
  while (Q--) {
    int x, d;
    scanf("%d%d", &x, &d);
    str[x] = d;
    modify(x, min(n, x + 1));
    printf("%lld\n", nd[1][1][1]);
  }
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

You are given a tree consisting exactly of n vertices. Tree is a connected undirected graph with n-1 edges. Each vertex v of this tree has a value a_v assigned to it.

Let dist(x, y) be the distance between the vertices x and y. The distance between the vertices is the number of edges on the simple path between them.

Let's define the cost of the tree as the following value: firstly, let's fix some vertex of the tree. Let it be v. Then the cost of the tree is ∑_{i = 1}^{n} dist(i, v) ⋅ a_i.

Your task is to calculate the maximum possible cost of the tree if you can choose v arbitrarily.

Input

The first line contains one integer n, the number of vertices in the tree (1 ≤ n ≤ 2 ⋅ 10^5).

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 2 ⋅ 10^5), where a_i is the value of the vertex i.

Each of the next n - 1 lines describes an edge of the tree. Edge i is denoted by two integers u_i and v_i, the labels of vertices it connects (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i).

It is guaranteed that the given edges form a tree.

Output

Print one integer — the maximum possible cost of the tree if you can choose any vertex as v.

Examples

Input

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

Output

121

Input

1
1337

Output

0

Note

Picture corresponding to the first example: <image>

You can choose the vertex 3 as a root, then the answer will be 2 ⋅ 9 + 1 ⋅ 4 + 0 ⋅ 1 + 3 ⋅ 7 + 3 ⋅ 10 + 4 ⋅ 1 + 4 ⋅ 6 + 4 ⋅ 5 = 18 + 4 + 0 + 21 + 30 + 4 + 24 + 20 = 121.

In the second example tree consists only of one vertex so the answer is always 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int fun(vector<int> v[], long long int a[], long long int b[],
                  long long int d[], int ver, int par) {
  d[ver] = 0;
  for (int i = 0; i < v[ver].size(); i++) {
    if (v[ver][i] != par) d[ver] = d[ver] + fun(v, a, b, d, v[ver][i], ver);
  }
  return d[ver] + b[ver] + a[ver];
}
long long int fun1(vector<int> v[], long long int a[], long long int b[],
                   int ver, int par) {
  b[ver] = 0;
  for (int i = 0; i < v[ver].size(); i++) {
    if (v[ver][i] != par) b[ver] = b[ver] + fun1(v, a, b, v[ver][i], ver);
  }
  return b[ver] + a[ver];
}
void dfs(vector<int> v[], long long int a[], long long int b[],
         long long int c[], long long int d[], long long int x, int ver,
         int par, long long int ans[]) {
  long long int y;
  ans[ver] = d[ver] + x;
  for (int i = 0; i < v[ver].size(); i++) {
    if (v[ver][i] != par) {
      y = x + d[ver] - d[(v[ver][i])] - b[(v[ver][i])] - (2 * a[(v[ver][i])]) +
          c[(v[ver][i])];
      dfs(v, a, b, c, d, y, (v[ver][i]), ver, ans);
    }
  }
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  long long int a[n + 1], b[n + 1], c[n + 1], d[n + 1], ans[n + 1], sum = 0;
  for (int i = 1; i < n + 1; i++) {
    scanf("%lld", &a[i]);
    sum += a[i];
  }
  vector<int> v[n + 1];
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  b[0] = fun1(v, a, b, 1, 0);
  for (int i = 1; i < n + 1; i++) c[i] = sum - b[i];
  d[0] = fun(v, a, b, d, 1, 0);
  dfs(v, a, b, c, d, 0ll, 1, 0, ans);
  x = 1;
  for (int i = 1; i < n + 1; i++) {
    if (ans[x] < ans[i]) x = i;
  }
  printf("%lld ", ans[x]);
  printf("\n");
}

```


### Prompt

Create a solution in CPP for the following problem:

Write a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.

Input

Input consists of several datasets. Each dataset has an integer n (1 ≤ n ≤ 999,999) in a line.

The number of datasets is less than or equal to 30.

Output

For each dataset, prints the number of prime numbers.

Example

Input

10
3
11

Output

4
2
5

### Response

```cpp
#include <stdio.h>

int main(){
	int n;
	while(scanf("%d", &n) != EOF){
		int *arr = new int[n + 1];

		for(int i = 2; i <= n; i++){
			if(arr[i] == 0){
				for(int j = 2*i; j <= n; j += i){
					arr[j] = 1;
				}
			}
		}

		int cnt = 0;
		for(int i = 2; i <= n; i++){
			if(arr[i] == 0){
				cnt++;
			}
		}
		delete [] arr;

		printf("%d\n", cnt);
	}
	return 0;
}
```


### Prompt

Please create a solution in CPP to the following problem:

The Zoo in the Grid Kingdom is represented by an infinite grid. The Zoo has n observation binoculars located at the OX axis. For each i between 1 and n, inclusive, there exists a single binocular located at the point with coordinates (i, 0). There are m flamingos in the Zoo, located at points with positive coordinates. The flamingos are currently sleeping and you can assume that they don't move.

In order to get a good view over the flamingos, each of the binoculars can be independently rotated to face any angle (not necessarily integer). Then, the binocular can be used to observe all flamingos that is located at the straight line passing through the binocular at the angle it is set. In other words, you can assign each binocular a direction corresponding to any straight line passing through the binocular, and the binocular will be able to see all flamingos located on that line.

Today, some kids from the prestigious Codeforces kindergarten went on a Field Study to the Zoo. Their teacher would like to set each binocular an angle to maximize the number of flamingos that can be seen by the binocular. The teacher is very interested in the sum of these values over all binoculars. Please help him find this sum.

Input

The first line contains two space-separated integers n and m (1 ≤ n ≤ 106, 1 ≤ m ≤ 250), denoting the number of binoculars and the number of flamingos, respectively.

Then m lines follow, the i-th line will contain two space-separated integers xi and yi (1 ≤ xi, yi ≤ 109), which means that the i-th flamingo is located at point (xi, yi).

All flamingos will be located at distinct points.

Output

Print a single integer denoting the maximum total number of flamingos that can be seen by all the binoculars.

Examples

Input

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

Output

11

Note

This picture shows the answer to the example test case.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m;
int ans[1000020];
struct Punto {
  long long x, y;
};
Punto Dots[1000];
bool areColineal(Punto A, Punto B, Punto C) {
  return (C.y - B.y) * (B.x - A.x) == (B.y - A.y) * (C.x - B.x);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> Dots[i].x >> Dots[i].y;
  }
  for (long long i = 0; i < n + 1; i++) ans[i] = 1;
  for (long long i = 0; i < m; i++) {
    for (int j = i + 1; j < m; j++) {
      Punto A = Dots[i];
      Punto B = Dots[j];
      int cont = 2;
      for (int k = j + 1; k < m; k++) {
        if (areColineal(A, B, Dots[k])) {
          cont++;
        }
      }
      if (A.y != B.y) {
        if ((A.y * (A.x - B.x)) % (A.y - B.y) == 0) {
          long long corte = A.x - (A.y * (A.x - B.x)) / (A.y - B.y);
          if (corte >= 1 && corte <= n) {
            ans[corte] = max(ans[corte], cont);
          }
        }
      }
    }
  }
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    sum += ans[i + 1];
  }
  cout << sum << "\n";
  return 0;
}

```


### Prompt

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

Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a proper glance and started experimenting right away. After a while Mike observed that the wires ended up entangled and now have to be untangled again.

The device is powered by two wires "plus" and "minus". The wires run along the floor from the wall (on the left) to the device (on the right). Both the wall and the device have two contacts in them on the same level, into which the wires are plugged in some order. The wires are considered entangled if there are one or more places where one wire runs above the other one. For example, the picture below has four such places (top view):

<image>

Mike knows the sequence in which the wires run above each other. Mike also noticed that on the left side, the "plus" wire is always plugged into the top contact (as seen on the picture). He would like to untangle the wires without unplugging them and without moving the device. Determine if it is possible to do that. A wire can be freely moved and stretched on the floor, but cannot be cut.

To understand the problem better please read the notes to the test samples.

Input

The single line of the input contains a sequence of characters "+" and "-" of length n (1 ≤ n ≤ 100000). The i-th (1 ≤ i ≤ n) position of the sequence contains the character "+", if on the i-th step from the wall the "plus" wire runs above the "minus" wire, and the character "-" otherwise.

Output

Print either "Yes" (without the quotes) if the wires can be untangled or "No" (without the quotes) if the wires cannot be untangled.

Examples

Input

-++-

Output

Yes

Input

+-

Output

No

Input

++

Output

Yes

Input

-

Output

No

Note

The first testcase corresponds to the picture in the statement. To untangle the wires, one can first move the "plus" wire lower, thus eliminating the two crosses in the middle, and then draw it under the "minus" wire, eliminating also the remaining two crosses.

In the second testcase the "plus" wire makes one full revolution around the "minus" wire. Thus the wires cannot be untangled:

<image>

In the third testcase the "plus" wire simply runs above the "minus" wire twice in sequence. The wires can be untangled by lifting "plus" and moving it higher:

<image>

In the fourth testcase the "minus" wire runs above the "plus" wire once. The wires cannot be untangled without moving the device itself:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string s;
int n, j;
bool f(bool positive) {
  ++j;
  if (positive) {
    while (j < n and s[j] == '-') {
      if (not f(false)) return false;
    }
    if (j >= n) return false;
    ++j;
  } else {
    while (j < n and s[j] == '+') {
      if (not f(true)) return false;
    }
    if (j >= n) return false;
    ++j;
  }
  return true;
}
int main() {
  cin >> s;
  n = s.length();
  if (n % 2 == 1)
    cout << "No" << endl;
  else {
    j = 0;
    bool b = true;
    while (b and j < n) {
      if (s[j] == '+')
        b = f(true);
      else
        b = f(false);
    }
    if (b)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

```


### Prompt

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

Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Meanwhile his little brother Yusuf came and started to press the keys randomly. Unfortunately Max has forgotten the number which he had calculated. The only thing he knows is that the number is divisible by 4.

You are given a string s consisting of digits (the number on the display of the calculator after Yusuf randomly pressed the keys). Your task is to find the number of substrings which are divisible by 4. A substring can start with a zero.

A substring of a string is a nonempty sequence of consecutive characters.

For example if string s is 124 then we have four substrings that are divisible by 4: 12, 4, 24 and 124. For the string 04 the answer is three: 0, 4, 04.

As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.

Input

The only line contains string s (1 ≤ |s| ≤ 3·105). The string s contains only digits from 0 to 9.

Output

Print integer a — the number of substrings of the string s that are divisible by 4.

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

Examples

Input

124

Output

4

Input

04

Output

3

Input

5810438174

Output

9

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int i, j;
  string s;
  cin >> s;
  int n = s.length();
  long long int dp[n + 1][4], ans = 0;
  memset(dp, 0, sizeof dp);
  dp[1][(s[0] - '0') % 4] = 1;
  for (i = 2; i <= n; i++) {
    if ((s[i - 1] - '0') % 4 == 0) {
      dp[i][0] = dp[i - 1][0] + dp[i - 1][2] + 1;
      dp[i][2] = dp[i - 1][1] + dp[i - 1][3];
    } else if ((s[i - 1] - '0') % 4 == 1) {
      dp[i][1] = dp[i - 1][0] + dp[i - 1][2] + 1;
      dp[i][3] = dp[i - 1][1] + dp[i - 1][3];
    } else if ((s[i - 1] - '0') % 4 == 2) {
      dp[i][0] = dp[i - 1][1] + dp[i - 1][3];
      dp[i][2] = dp[i - 1][2] + dp[i - 1][0] + 1;
    } else {
      dp[i][3] = dp[i - 1][0] + dp[i - 1][2] + 1;
      dp[i][1] = dp[i - 1][1] + dp[i - 1][3];
    }
  }
  for (i = 1; i <= n; i++) ans += dp[i][0];
  cout << ans;
}

```


### Prompt

Generate a cpp solution to the following problem:

There is a set consisting of N distinct integers. The i-th smallest element in this set is S_i. We want to divide this set into two sets, X and Y, such that:

* The absolute difference of any two distinct elements in X is A or greater.
* The absolute difference of any two distinct elements in Y is B or greater.

How many ways are there to perform such division, modulo 10^9 + 7? Note that one of X and Y may be empty.

Constraints

* All input values are integers.
* 1 ≦ N ≦ 10^5
* 1 ≦ A , B ≦ 10^{18}
* 0 ≦ S_i ≦ 10^{18}(1 ≦ i ≦ N)
* S_i < S_{i+1}(1 ≦ i ≦ N - 1)

Input

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

N A B
S_1
:
S_N

Output

Print the number of the different divisions under the conditions, modulo 10^9 + 7.

Examples

Input

5 3 7
1
3
6
9
12

Output

5

Input

7 5 3
0
2
4
7
8
11
15

Output

4

Input

8 2 9
3
4
5
13
15
22
26
32

Output

13

Input

3 3 4
5
6
7

Output

0

### Response

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

const int N = 1e5 + 15;
const int mod = 1e9 + 7;

int n, f[2][N], s[2][N], g[2][N];
long long a[N], x[2];

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> x[0] >> x[1];
    for (int i = 1; i <= n; ++i) cin >> a[i];
    a[n + 1] = a[n] + max(x[0], x[1]);
    for (int i = 0; i <= 1; ++i) {
        for (int j = 1; j <= n; ++j) {
            g[i][j] = j;
            if (a[j] - a[j - 1] >= x[i]) {
                g[i][j] = g[i][j - 1];
            }
        }
    }
    s[0][0] = s[1][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= 1; ++j) {
            int tmp = lower_bound(a + 1, a + n + 2, a[i + 1] - x[j ^ 1] + 1) - a - 1;
            if (tmp == i) tmp--;
            if (g[j][i] - 1 <= tmp) {
                f[j][i] = s[j ^ 1][tmp];
                if (g[j][i] >= 2) {
                    f[j][i] = (f[j][i] - s[j ^ 1][g[j][i] - 2] + mod) % mod;
                }
            }
            s[j][i] = (s[j][i - 1] + f[j][i]) % mod;
            //cout << f[j][i] << ' ' << j << ' ' << i << '\n';
        }
    }
    cout << (f[0][n] + f[1][n]) % mod;
}

```


### Prompt

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

zscoder loves simple strings! A string t is called simple if every pair of adjacent characters are distinct. For example ab, aba, zscoder are simple whereas aa, add are not simple.

zscoder is given a string s. He wants to change a minimum number of characters so that the string s becomes simple. Help him with this task!

Input

The only line contains the string s (1 ≤ |s| ≤ 2·105) — the string given to zscoder. The string s consists of only lowercase English letters.

Output

Print the simple string s' — the string s after the minimal number of changes. If there are multiple solutions, you may output any of them.

Note that the string s' should also consist of only lowercase English letters.

Examples

Input

aab

Output

bab

Input

caaab

Output

cabab

Input

zscoder

Output

zscoder

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string s;
int check(int pos, char x) {
  if (s[pos - 1] != x && s[pos + 1] != x)
    return 1;
  else
    return 0;
}
int main() {
  int i, j, k;
  cin >> s;
  for (i = 1; i < s.length(); i++) {
    if (s[i] == s[i - 1]) {
      if (check(i, 'a')) s[i] = 'a';
      if (check(i, 'b')) s[i] = 'b';
      if (check(i, 'c')) s[i] = 'c';
    }
  }
  for (i = 0; i < s.length(); i++) {
    cout << s[i];
  }
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Drazil is playing a math game with Varda.

Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>.

First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions:

1. x doesn't contain neither digit 0 nor digit 1.

2. <image> = <image>.

Help friends find such number.

Input

The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a.

The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes.

Output

Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation.

Examples

Input

4
1234

Output

33222

Input

3
555

Output

555

Note

In the first case, <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, a, b;
  cin >> n >> a;
  vector<long long int> ans;
  while (a > 0) {
    long long int x = a % 10;
    if (x == 2 || x == 3 || x == 5 || x == 7)
      ans.push_back(x);
    else if (x == 4)
      ans.push_back(3), ans.push_back(2), ans.push_back(2);
    else if (x == 6)
      ans.push_back(3), ans.push_back(5);
    else if (x == 8)
      ans.push_back(7), ans.push_back(2), ans.push_back(2), ans.push_back(2);
    else if (x == 9)
      ans.push_back(7), ans.push_back(3), ans.push_back(3), ans.push_back(2);
    a /= 10;
  }
  sort(ans.rbegin(), ans.rend());
  for (int i = 0; i < ans.size(); i++) cout << ans[i];
  cout << endl;
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

In Republic of AtCoder, Snuke Chameleons (Family: Chamaeleonidae, Genus: Bartaberia) are very popular pets. Ringo keeps N Snuke Chameleons in a cage.

A Snuke Chameleon that has not eaten anything is blue. It changes its color according to the following rules:

* A Snuke Chameleon that is blue will change its color to red when the number of red balls it has eaten becomes strictly larger than the number of blue balls it has eaten.
* A Snuke Chameleon that is red will change its color to blue when the number of blue balls it has eaten becomes strictly larger than the number of red balls it has eaten.

Initially, every Snuke Chameleon had not eaten anything. Ringo fed them by repeating the following process K times:

* Grab either a red ball or a blue ball.
* Throw that ball into the cage. Then, one of the chameleons eats it.

After Ringo threw in K balls, all the chameleons were red. We are interested in the possible ways Ringo could have thrown in K balls. How many such ways are there? Find the count modulo 998244353. Here, two ways to throw in balls are considered different when there exists i such that the color of the ball that are thrown in the i-th throw is different.

Constraints

* 1 \leq N,K \leq 5 \times 10^5
* N and K are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the possible ways Ringo could have thrown in K balls, modulo 998244353.

Examples

Input

2 4

Output

7

Input

3 7

Output

57

Input

8 3

Output

0

Input

8 10

Output

46

Input

123456 234567

Output

857617983

### Response

```cpp
#include <cstdio>
#include <iostream>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
const int N=500000;
const int mod=998244353;
int n, m, ans, f[N+1], F[N+1];
void inc(int&a,int b){(a+=b)%=mod;}
int C(int n,int m){
	if(n<m||n<0||m<0)return 0;
	return 1LL*f[n]*F[m]%mod*F[n-m]%mod;
}
int mi(int a,int b){
	int s=1;
	for(;b;b>>=1,a=1LL*a*a%mod)
		if(b&1)s=1LL*s*a%mod;
	return s;
}
int main(){
	scanf("%d%d", &n, &m);
	f[0] = 1;
	ref(i, 1, N)f[i] = 1LL*f[i-1]*i%mod;
	F[N] = mi(f[N],mod-2);
	def(i, N, 1)F[i-1] = 1LL*F[i]*i%mod;
	if(!(m&1)&&m/2>=n)
		inc(ans, C(m-1,m/2) - C(m-1,m-n+1));
	ref(i, m/2+1, m){
		if(2*i-m >= n) inc(ans, C(m,i));else
		if(i >= n) inc(ans, C(m,i) - C(m,2*i+1-n));
	}
	cout<<((ans+mod)%mod)<<endl;
}
```


### Prompt

Generate a CPP solution to the following problem:

One university has just found out about a sport programming contest called ACM ICPC v2.0. This contest doesn't differ much from the well-known ACM ICPC, for example, the participants are not allowed to take part in the finals more than two times. However, there is one notable difference: the teams in the contest should consist of exactly n participants.

Having taken part in several ACM ICPC v2.0 finals and having not won any medals, the students and the university governors realized that it's high time they changed something about the preparation process. Specifically, as the first innovation it was decided to change the teams' formation process. Having spent considerable amount of time on studying the statistics of other universities' performance, they managed to receive some interesting information: the dependence between the probability of winning a medal and the number of team members that participated in the finals in the past. More formally, we know n + 1 real numbers p0 ≤ p1 ≤ ... ≤ pn, where pi is the probability of getting a medal on the finals if the team has i participants of previous finals, and other n - i participants arrived to the finals for the first time.

Despite such useful data, the university governors are unable to determine such team forming tactics that would provide the maximum probability of winning a medal at ACM ICPC v2.0 finals on average (we are supposed to want to provide such result to the far future and we are also supposed to have an endless supply of students). And how about you, can you offer such optimal tactic? At the first stage the university governors want to know the value of maximum average probability.

More formally, suppose that the university sends a team to the k-th world finals. The team has ak participants of previous finals (0 ≤ ak ≤ n). Since each person can participate in the finals no more than twice, the following condition must be true: <image>. Your task is to choose sequence <image> so that the limit Ψ exists and it's value is maximal:

<image>

As <image> is an infinite sequence, you should only print the maximum value of the Ψ limit.

Input

The first line contains an integer n (3 ≤ n ≤ 100), n is the number of team participants. The second line contains n + 1 real numbers with no more than 6 digits after decimal point pi (0 ≤ i ≤ n, 0 ≤ pi ≤ 1) — the probability of that the team will win a medal if it contains i participants who has already been on the finals. Also the condition pi ≤ pi + 1 should be fulfilled for all 0 ≤ i ≤ n - 1.

Output

Print the only real number — the expected average number of medals won per year if the optimal strategy is used. The result may have absolute or relative error 10 - 6.

Examples

Input

3
0.115590 0.384031 0.443128 0.562356

Output

0.4286122500

Input

3
1 1 1 1

Output

0.9999999999

Note

In the second test, no matter what participants the team contains, it is doomed to be successful.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 222;
int n;
double p[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i <= n; ++i) {
    scanf("%lf", p + i);
  }
  double ans = 0.0;
  for (int i = 0; i * 2 <= n; ++i) {
    ans = max(ans, p[i]);
  }
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      int ii = n - 2 * i;
      int jj = n - 2 * j;
      if (ii > 0 && jj < 0) {
        ans = max(ans, (p[i] * -jj + p[j] * ii) / (double)(ii - jj));
      }
    }
  }
  printf("%.8f\n", ans);
  return 0;
}

```