### Prompt

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

Fox Ciel has a robot on a 2D plane. Initially it is located in (0, 0). Fox Ciel code a command to it. The command was represented by string s. Each character of s is one move operation. There are four move operations at all:

  * 'U': go up, (x, y)  →  (x, y+1);
  * 'D': go down, (x, y)  →  (x, y-1);
  * 'L': go left, (x, y)  →  (x-1, y);
  * 'R': go right, (x, y)  →  (x+1, y).

The robot will do the operations in s from left to right, and repeat it infinite times. Help Fox Ciel to determine if after some steps the robot will located in (a, b).

Input

The first line contains two integers a and b, ( - 109 ≤ a, b ≤ 109). The second line contains a string s (1 ≤ |s| ≤ 100, s only contains characters 'U', 'D', 'L', 'R') — the command.

Output

Print "Yes" if the robot will be located at (a, b), and "No" otherwise.

Examples

Input

2 2
RU

Output

Yes

Input

1 2
RU

Output

No

Input

-1 1000000000
LRRLU

Output

Yes

Input

0 0
D

Output

Yes

Note

In the first and second test case, command string is "RU", so the robot will go right, then go up, then right, and then up and so on.

The locations of its moves are (0, 0)  →  (1, 0)  →  (1, 1)  →  (2, 1)  →  (2, 2)  →  ...

So it can reach (2, 2) but not (1, 2).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a, b, x, y;
bool solve(int c, int d) {
  if (x == 0 and y == 0) return c == a and d == b;
  if (x == 0) return c == a and (b - d) / y >= 0 and (b - d) % y == 0;
  if (y == 0) return d == b and (a - c) / x >= 0 and (a - c) % x == 0;
  return (a - c) / x >= 0 and (a - c) % x == 0 and (b - d) / y >= 0 and
         (b - d) % y == 0 and (b - d) / y == (a - c) / x;
}
int main() {
  string s;
  cin >> a >> b >> s;
  x = 0;
  y = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'U')
      ++y;
    else if (s[i] == 'D')
      --y;
    else if (s[i] == 'L')
      --x;
    else
      ++x;
  }
  bool ok = (a == 0 and b == 0);
  int c = 0, d = 0;
  for (int i = 0; i < s.size() and not ok; ++i) {
    if (s[i] == 'U')
      ++d;
    else if (s[i] == 'D')
      --d;
    else if (s[i] == 'L')
      --c;
    else
      ++c;
    ok = solve(c, d);
  }
  cout << (ok ? "Yes" : "No") << endl;
}

```


### Prompt

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

George loves graphs. Most of all, he loves interesting graphs. We will assume that a directed graph is interesting, if it meets the following criteria:

  * The graph doesn't contain any multiple arcs;
  * There is vertex v (we'll call her the center), such that for any vertex of graph u, the graph contains arcs (u, v) and (v, u). Please note that the graph also contains loop (v, v).
  * The outdegree of all vertexes except for the center equals two and the indegree of all vertexes except for the center equals two. The outdegree of vertex u is the number of arcs that go out of u, the indegree of vertex u is the number of arcs that go in u. Please note that the graph can contain loops.

However, not everything's that simple. George got a directed graph of n vertices and m arcs as a present. The graph didn't have any multiple arcs. As George loves interesting graphs, he wants to slightly alter the presented graph and transform it into an interesting one. In one alteration he can either remove an arbitrary existing arc from the graph or add an arbitrary arc to the graph.

George wonders: what is the minimum number of changes that he needs to obtain an interesting graph from the graph he's got as a present? Help George and find the answer to the question.

Input

The first line contains two space-separated integers n and m (2 ≤ n ≤ 500, 1 ≤ m ≤ 1000) — the number of vertices and arcs in the presented graph.

Each of the next m lines contains two space-separated integers ai, bi (1 ≤ ai, bi ≤ n) — the descriptions of the graph's arcs. Pair (ai, bi) means that the graph contains an arc from vertex number ai to vertex number bi. It is guaranteed that the presented graph doesn't contain multiple arcs.

Assume that the grah vertices are numbered 1 through n.

Output

Print a single integer — the answer to George's question.

Examples

Input

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

Output

0

Input

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

Output

1

Input

3 1
2 2

Output

6

Note

For more information about directed graphs, please visit: http://en.wikipedia.org/wiki/Directed_graph

In the first sample the graph already is interesting, its center is vertex 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 502;
bool marked[MAXN];
int match[2][MAXN];
vector<int> adj[MAXN];
int n, m;
int degs[MAXN];
bool dfs(int v, int forb) {
  if (marked[v]) return false;
  marked[v] = true;
  for (int i = 0; i < (int)adj[v].size(); i++) {
    int u = adj[v][i];
    if (u == forb) continue;
    if (match[1][u] == -1 || dfs(match[1][u], forb)) {
      match[0][v] = u;
      match[1][u] = v;
      return true;
    }
  }
  return false;
}
int matching(int forb) {
  memset(match, -1, sizeof match);
  int ans = 0;
  for (int j = 0; j < n; j++) {
    bool found = false;
    memset(marked, 0, sizeof marked);
    for (int i = 1; i <= n; i++)
      if (i != forb && !marked[i] && match[0][i] == -1 && dfs(i, forb)) {
        ans++;
        found = true;
      }
    if (!found) break;
  }
  return ans;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    degs[a]++;
    if (a != b) degs[b]++;
  }
  int ans = 1e9;
  for (int i = 1; i <= n; i++) {
    int mat = matching(i);
    ans = min(ans, (2 * n - 1) - degs[i] + (m - degs[i]) - mat + (n - 1) - mat);
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Let's denote a function

<image>

You are given an array a consisting of n integers. You have to calculate the sum of d(ai, aj) over all pairs (i, j) such that 1 ≤ i ≤ j ≤ n.

Input

The first line contains one integer n (1 ≤ n ≤ 200000) — the number of elements in a.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — elements of the array.

Output

Print one integer — the sum of d(ai, aj) over all pairs (i, j) such that 1 ≤ i ≤ j ≤ n.

Examples

Input

5
1 2 3 1 3

Output

4

Input

4
6 6 5 5

Output

0

Input

4
6 6 4 4

Output

-8

Note

In the first example:

  1. d(a1, a2) = 0;
  2. d(a1, a3) = 2;
  3. d(a1, a4) = 0;
  4. d(a1, a5) = 2;
  5. d(a2, a3) = 0;
  6. d(a2, a4) = 0;
  7. d(a2, a5) = 0;
  8. d(a3, a4) = - 2;
  9. d(a3, a5) = 0;
  10. d(a4, a5) = 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
map<long long, long long> mm;
long long a[2000006];
int main() {
  int n;
  cin >> n;
  long double ans = 0;
  long double sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ans += (a[i] * (i - 1 - mm[a[i] - 1] - mm[a[i] + 1] - mm[a[i]]) -
            (sum - (mm[a[i] - 1] * (a[i] - 1) + mm[a[i] + 1] * (a[i] + 1) +
                    mm[a[i]] * (a[i]))));
    mm[a[i]]++;
    sum += a[i];
  }
  cout << fixed << setprecision(0) << ans << endl;
  return 0;
}

```


### Prompt

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

All-Berland programming contest comes to an end. In total, n teams participated in it. Like in ACM-ICPC, current results stopped refreshing one hour before the contest ends. So at the Award Ceremony, results are partially known. For each team the value ai is given — the number of points the i-th team has earned before the last hour of the contest. Besides that, the Jury has evaluated all submissions sent during the last hour and knows values di — the number of points earned by the i-th team during the last hour (these values can be negative, which means that a team can lose points).

Before the contest, each team got unique id from 1 to n. According to the contest rules, a team with more points takes a higher place. If two or more teams have equal number of points, the team with lower id will take the higher place. So no two teams can share the same place.

The Award Ceremony proceeds in the following way. At the beginning of the ceremony, a large screen shows the results for the time moment "one hour before the end", which means that the i-th team has ai points. Then the Jury unfreezes results of the teams one by one in some order. When result of the j-th team is unfrozen, its score changes from aj to aj + dj. At this time the table of results is modified and the place of the team can change. The unfreezing of the j-th team is followed by the applause from the audience with duration of |xj - yj| seconds, where xj is the place of the j-th team before unfreezing and yj is the place right after the unfreezing. For example, if the team does not change the place, there is no applause from the audience. As you can see, during the Award Ceremony, each team will be unfrozen exactly once.

Your task is to find such an order to unfreeze all the teams that the total duration of applause is maximum possible.

Input

The first line of the input file contains a single integer n (1 ≤ n ≤ 100) — the number of teams.

Each of the next n lines contains two integers ai and di (1 ≤ ai ≤ 100,  - 100 ≤ di ≤ 100) — the number of points the i-th team has earned before the last hour of the contest and the number of points earned by this team during the last hour. It is possible that after unfreezing a team will have a negative score.

Output

Print the only integer — maximal total applause duration in seconds if the Jury can choose any order of the teams to unfreeze.

Examples

Input

4
17 -14
52 -5
1 52
6 0

Output

4

Input

5
4 5
3 2
5 -3
6 -2
4 3

Output

14

Note

In the first example the initial standings are:

  1. Team 2, 52 points
  2. Team 1, 17 points
  3. Team 4, 6 points
  4. Team 3, 1 point

Here any order of unfreezing the teams leads to 4 seconds of applause in total. For example, let's unfreeze teams in their order from the Team 1 to the Team 4.

After the Team 1 became unfrozen the standings are:

  1. Team 2, 52 points
  2. Team 4, 6 points
  3. Team 1, 3 points
  4. Team 3, 1 point

So there is 1 second of applause, because the difference between old and new places |2 - 3| = 1.

After the Team 2 became unfrozen the standings are:

  1. Team 2, 47 points
  2. Team 4, 6 points
  3. Team 1, 3 points
  4. Team 3, 1 point

The place of the Team 2 has not changed, so no applause during unfreezing.

After the Team 3 became unfrozen the standings are:

  1. Team 3, 53 point
  2. Team 2, 47 points
  3. Team 4, 6 points
  4. Team 1, 3 points

The place of the Team 3 has changed from 4 to 1, so the duration of applause is |4 - 1| = 3.

The unfreezing of the Team 4 has not changed any place because d4 = 0.

Therefore, the total duration of applause is 1 + 0 + 3 + 0 = 4 seconds.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
int add(int a, int b) {
  if ((a += b) >= P) a -= P;
  return a;
}
int sub(int a, int b) {
  if ((a -= b) < 0) a += P;
  return a;
}
int mul(int a, int b) { return 1ll * a * b % P; }
int kpow(int a, int b) {
  int r = 1;
  for (; b; b >>= 1, a = mul(a, a)) {
    if (b & 1) r = mul(r, a);
  }
  return r;
}
const int N = 105;
pair<int, int> x, y, xx, yy, a[N], b[N];
int n, A, D, ans;
int cal(int i, int j) {
  x = a[i];
  y = a[j];
  xx = b[i];
  yy = b[j];
  if (x < y && xx > yy) return 1;
  if (x > y && xx < yy) return 1;
  if (x < y) {
    if (xx > y && yy > xx) return 2;
    if (yy < x && xx < yy) return 2;
    return 0;
  }
  swap(x, y);
  swap(xx, yy);
  if (x < y) {
    if (xx > y && yy > xx) return 2;
    if (yy < x && xx < yy) return 2;
    return 0;
  }
  return 0;
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> n;
  for (int i = (1); i < (n + 1); i++) {
    cin >> A >> D;
    a[i].first = b[i].first = -A;
    a[i].second = b[i].second = i;
    b[i].first -= D;
  }
  for (int i = (1); i < (n + 1); i++)
    for (int j = (i + 1); j < (n + 1); j++) ans += cal(i, j);
  cout << ans;
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Soon there will be held the world's largest programming contest, but the testing system still has m bugs. The contest organizer, a well-known university, has no choice but to attract university students to fix all the bugs. The university has n students able to perform such work. The students realize that they are the only hope of the organizers, so they don't want to work for free: the i-th student wants to get ci 'passes' in his subjects (regardless of the volume of his work).

Bugs, like students, are not the same: every bug is characterized by complexity aj, and every student has the level of his abilities bi. Student i can fix a bug j only if the level of his abilities is not less than the complexity of the bug: bi ≥ aj, and he does it in one day. Otherwise, the bug will have to be fixed by another student. Of course, no student can work on a few bugs in one day. All bugs are not dependent on each other, so they can be corrected in any order, and different students can work simultaneously.

The university wants to fix all the bugs as quickly as possible, but giving the students the total of not more than s passes. Determine which students to use for that and come up with the schedule of work saying which student should fix which bug.

Input

The first line contains three space-separated integers: n, m and s (1 ≤ n, m ≤ 105, 0 ≤ s ≤ 109) — the number of students, the number of bugs in the system and the maximum number of passes the university is ready to give the students.

The next line contains m space-separated integers a1, a2, ..., am (1 ≤ ai ≤ 109) — the bugs' complexities.

The next line contains n space-separated integers b1, b2, ..., bn (1 ≤ bi ≤ 109) — the levels of the students' abilities.

The next line contains n space-separated integers c1, c2, ..., cn (0 ≤ ci ≤ 109) — the numbers of the passes the students want to get for their help.

Output

If the university can't correct all bugs print "NO".

Otherwise, on the first line print "YES", and on the next line print m space-separated integers: the i-th of these numbers should equal the number of the student who corrects the i-th bug in the optimal answer. The bugs should be corrected as quickly as possible (you must spend the minimum number of days), and the total given passes mustn't exceed s. If there are multiple optimal answers, you can output any of them.

Examples

Input

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

Output

YES
2 3 2 3

Input

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

Output

YES
1 3 1 3

Input

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

Output

YES
3 3 2 3

Input

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

Output

NO

Note

Consider the first sample.

The third student (with level 3) must fix the 2nd and 4th bugs (complexities 3 and 2 correspondingly) and the second student (with level 1) must fix the 1st and 3rd bugs (their complexity also equals 1). Fixing each bug takes one day for each student, so it takes 2 days to fix all bugs (the students can work in parallel).

The second student wants 3 passes for his assistance, the third student wants 6 passes. It meets the university's capabilities as it is ready to give at most 9 passes.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int M = 2e6 + 10;
const int inf = 0x3f3f3f3f;
const long long mod = 998244353;
int n, m, S;
pair<long long, long long> a[N];
int ans[N];
struct node {
  long long a, b, id;
  bool operator<(const node &t) const { return b > t.b; }
} g[N];
bool cmp(node a, node b) { return a.a < b.a; }
bool check(int x) {
  long long sum = 0;
  priority_queue<node> q;
  int i;
  int cnt = n;
  for (i = m; i >= 1; i--) {
    while (cnt && g[cnt].a >= a[i].first) {
      q.push(g[cnt--]);
    }
    if (q.empty()) return false;
    int j;
    for (j = i; j > max(i - x, 0); j--) {
      ans[a[j].second] = q.top().id;
    }
    i -= x;
    i++;
    sum += q.top().b;
    q.pop();
  }
  return sum <= S;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> S;
  int i;
  for (i = 1; i <= m; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  for (i = 1; i <= n; i++) {
    cin >> g[i].a;
    g[i].id = i;
  }
  for (i = 1; i <= n; i++) cin >> g[i].b;
  sort(a + 1, a + 1 + m);
  sort(g + 1, g + 1 + n, cmp);
  int l = 0, r = m + 1;
  while (l < r) {
    int mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  if (l == m + 1) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    check(l);
    for (i = 1; i <= m; i++) cout << ans[i] << " ";
    cout << endl;
  }
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out).

For $n$ queues $Q_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations.

* enqueue($t$, $x$): Insert an integer $x$ to $Q_t$.
* front($t$): Report the value which should be deleted next from $Q_t$. If $Q_t$ is empty, do nothing.
* dequeue($t$): Delete an element from $Q_t$. If $Q_t$ is empty, do nothing.

In the initial state, all queues are empty.

Constraints

* $1 \leq n \leq 1,000$
* $1 \leq q \leq 200,000$
* $-1,000,000,000 \leq x \leq 1,000,000,000$

Input

The input is given in the following format.

$n \; q$
$query_1$
$query_2$
:
$query_q$

Each query $query_i$ is given by

0 $t$ $x$

or

1 $t$

or

2 $t$

where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively.

Output

For each front operation, print an integer in a line.

Example

Input

3 9
0 0 1
0 0 2
0 0 3
0 2 4
0 2 5
1 0
1 2
2 0
1 0

Output

1
4
2

### Response

```cpp
#include <iostream>
#include <queue>

int main()
{
	int n, q; std::cin >> n >> q;

	std::queue<int>* que = new std::queue<int>[n];

	;
	for (int i=0; i<q; i++) {
		int op, x, t;
		std::cin >> op;
		switch (op) {
		case 0:
			std::cin >> t >> x;
			que[t].push(x);
			break;
		case 1:
			std::cin >> t;
			if (!que[t].empty()) std::cout << que[t].front() << std::endl;
			break;
		case 2:
			std::cin >> t;
			if (!que[t].empty()) que[t].pop();
			break;
		}
	}

	delete[] que;

	return 0;
}

```


### Prompt

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

The Squareland national forest is divided into equal 1 × 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner.

Three friends, Alice, Bob, and Charlie are going to buy three distinct plots of land A, B, C in the forest. Initially, all plots in the forest (including the plots A, B, C) are covered by trees. The friends want to visit each other, so they want to clean some of the plots from trees. After cleaning, one should be able to reach any of the plots A, B, C from any other one of those by moving through adjacent cleared plots. Two plots are adjacent if they share a side.

<image> For example, A=(0,0), B=(1,1), C=(2,2). The minimal number of plots to be cleared is 5. One of the ways to do it is shown with the gray color.

Of course, the friends don't want to strain too much. Help them find out the smallest number of plots they need to clean from trees.

Input

The first line contains two integers x_A and y_A — coordinates of the plot A (0 ≤ x_A, y_A ≤ 1000). The following two lines describe coordinates (x_B, y_B) and (x_C, y_C) of plots B and C respectively in the same format (0 ≤ x_B, y_B, x_C, y_C ≤ 1000). It is guaranteed that all three plots are distinct.

Output

On the first line print a single integer k — the smallest number of plots needed to be cleaned from trees. The following k lines should contain coordinates of all plots needed to be cleaned. All k plots should be distinct. You can output the plots in any order.

If there are multiple solutions, print any of them.

Examples

Input

0 0
1 1
2 2

Output

5
0 0
1 0
1 1
1 2
2 2

Input

0 0
2 0
1 1

Output

4
0 0
1 0
1 1
2 0

Note

The first example is shown on the picture in the legend.

The second example is illustrated with the following image:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int x[3], y[3];
  for (int i = 0; i < 3; i++) cin >> x[i] >> y[i];
  int s = 1e9;
  int xx, yy;
  for (int i = 0; i <= 1000; i++)
    for (int j = 0; j <= 1000; j++) {
      int t = 0;
      for (int k = 0; k < 3; k++) t += (abs(i - x[k]) + abs(j - y[k]));
      if (t < s) {
        s = t;
        xx = i;
        yy = j;
      }
    }
  set<pair<int, int>> ans;
  for (int i = 0; i < 3; i++) {
    while (x[i] > xx) ans.insert({x[i]--, y[i]});
    while (x[i] < xx) ans.insert({x[i]++, y[i]});
    while (y[i] > yy) ans.insert({x[i], y[i]--});
    while (y[i] < yy) ans.insert({x[i], y[i]++});
  }
  ans.insert({xx, yy});
  cout << ans.size() << '\n';
  for (auto a : ans) cout << a.first << ' ' << a.second << '\n';
}

```


### Prompt

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

problem

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

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

<image>

input

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

The number of datasets does not exceed 5.

output

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

Examples

Input

380
1
0

Output

4
15

Input

None

Output

None

### Response

```cpp
#include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		n = 1000 - n;
		int count = 0;
		count += n / 500;
		n %= 500;
		count += n / 100;
		n %= 100;
		count += n / 50;
		n %= 50;
		count += n / 10;
		n %= 10;
		count += n / 5;
		n %= 5;
		count += n;
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}
```


### Prompt

Please formulate a Cpp solution to the following problem:

Vasya has got a magic matrix a of size n × m. The rows of the matrix are numbered from 1 to n from top to bottom, the columns are numbered from 1 to m from left to right. Let a_{ij} be the element in the intersection of the i-th row and the j-th column.

Vasya has also got a chip. Initially, the chip is in the intersection of the r-th row and the c-th column (that is, in the element a_{rc}). Vasya performs the following process as long as possible: among all elements of the matrix having their value less than the value of the element with the chip in it, Vasya randomly and equiprobably chooses one element and moves his chip to this element.

After moving the chip, he adds to his score the square of the Euclidean distance between these elements (that is, between the element in which the chip is now and the element the chip was moved from). The process ends when there are no elements having their values less than the value of the element with the chip in it.

Euclidean distance between matrix elements with coordinates (i_1, j_1) and (i_2, j_2) is equal to √{(i_1-i_2)^2 + (j_1-j_2)^2}.

Calculate the expected value of the Vasya's final score.

It can be shown that the answer can be represented as P/Q, where P and Q are coprime integer numbers, and Q not≡ 0~(mod ~ 998244353). Print the value P ⋅ Q^{-1} modulo 998244353.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 1 000) — the number of rows and the number of columns in the matrix a.

The following n lines contain description of the matrix a. The i-th line contains m integers a_{i1}, a_{i2}, ..., a_{im} ~ (0 ≤ a_{ij} ≤ 10^9).

The following line contains two integers r and c (1 ≤ r ≤ n, 1 ≤ c ≤ m) — the index of row and the index of column where the chip is now.

Output

Print the expected value of Vasya's final score in the format described in the problem statement.

Examples

Input

1 4
1 1 2 1
1 3

Output

2

Input

2 3
1 5 7
2 3 1
1 2

Output

665496238

Note

In the first example, Vasya will move his chip exactly once. The expected value of the final score is equal to (1^2 + 2^2+ 1^2)/(3) = 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * power(a * a % md, b / 2, md) % md
                      : power(a * a % md, b / 2, md) % md));
}
const int xn = 1e6 + 10;
const int xm = 1e2 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const long long INF = 1e18 + 10;
const int mod = 998244353;
const int base = 257;
long long n, m, R2, L2, R, L, dp, part, cnt, ans[xn], ansL, ansR, ANS;
pair<int, pair<int, int> > num[xn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      int x;
      cin >> x;
      num[cnt].first = x, num[cnt].second.first = i, num[cnt].second.second = j;
      ++cnt;
    }
  }
  cin >> ansL >> ansR;
  sort(num, num + cnt);
  num[cnt].first = -1;
  int k = 0;
  for (int i = 0; i < cnt;) {
    long long adad = num[i].first, ind = i;
    long long tmpL = 0, tmpR = 0, tmpL2 = 0, tmpR2 = 0, tmpdp = 0, tmpcnt = 0;
    while (i < cnt && num[i].first == adad) {
      int x = num[i].second.first, y = num[i].second.second;
      if (!k)
        ans[i] = 0;
      else
        ans[i] = (x * x % mod) + (y * y % mod) +
                 (part * power(k, mod - 2, mod) % mod) +
                 (L2 * power(k, mod - 2, mod) % mod) +
                 (R2 * power(k, mod - 2, mod)) -
                 ((2 * x * L % mod) * power(k, mod - 2, mod) % mod) -
                 ((2 * y * R % mod) * power(k, mod - 2, mod) % mod),
        ans[i] %= mod;
      tmpdp += ans[i];
      if (num[i].second.first == ansL && num[i].second.second == ansR)
        ANS = ans[i];
      ++i;
      tmpL += x, tmpR += y, tmpL2 += x * x, tmpR2 += y * y, tmpcnt++;
      tmpL %= mod, tmpR %= mod, tmpL2 %= mod, tmpR2 %= mod;
    }
    L += tmpL, L %= mod;
    L2 += tmpL2, L2 %= mod;
    R += tmpR, R %= mod;
    R2 += tmpR2, R2 %= mod;
    part += tmpdp, part %= mod;
    k += tmpcnt;
  }
  cout << ANS;
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Write a program which reads a $ n \times m$ matrix $A$ and a $m \times 1$ vector $b$, and prints their product $Ab$.

A column vector with m elements is represented by the following equation.

\\[ b = \left( \begin{array}{c} b_1 \\\ b_2 \\\ : \\\ b_m \\\ \end{array} \right) \\]

A $n \times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation.

\\[ A = \left( \begin{array}{cccc} a_{11} & a_{12} & ... & a_{1m} \\\ a_{21} & a_{22} & ... & a_{2m} \\\ : & : & : & : \\\ a_{n1} & a_{n2} & ... & a_{nm} \\\ \end{array} \right) \\]

$i$-th element of a $m \times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$).

The product of a $n \times m$ matrix $A$ and a $m \times 1$ column vector $b$ is a $n \times 1$ column vector $c$, and $c_i$ is obtained by the following formula:

\\[ c_i = \sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m \\]

Constraints

* $1 \leq n, m \leq 100$
* $0 \leq b_i, a_{ij} \leq 1000$

Input

In the first line, two integers $n$ and $m$ are given. In the following $n$ lines, $a_{ij}$ are given separated by a single space character. In the next $m$ lines, $b_i$ is given in a line.

Output

The output consists of $n$ lines. Print $c_i$ in a line.

Example

Input

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

Output

5
6
9

### Response

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

int x[101][101]={};
int y[101]={};

int main(){
	int a,b;
	cin>>a>>b;
	for (int i=0;i<a;i++)for (int j=0;j<b;j++)cin>>x[i][j];
	for (int i=0;i<b;i++)cin>>y[i];
	for (int i=0;i<a;i++){
		int ans=0;
		for (int j=0;j<b;j++){
			ans+=x[i][j]*y[j];
		}
		cout<<ans<<endl;
	}
}

```


### Prompt

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

You've come to your favorite store Infinitesco to buy some ice tea.

The store sells ice tea in bottles of different volumes at different costs. Specifically, a 0.25-liter bottle costs Q yen, a 0.5-liter bottle costs H yen, a 1-liter bottle costs S yen, and a 2-liter bottle costs D yen. The store has an infinite supply of bottles of each type.

You want to buy exactly N liters of ice tea. How many yen do you have to spend?

Constraints

* 1 \leq Q, H, S, D \leq 10^8
* 1 \leq N \leq 10^9
* All input values are integers.

Input

Input is given from Standard Input in the following format:

Q H S D
N

Output

Print the smallest number of yen you have to spend to buy exactly N liters of ice tea.

Examples

Input

20 30 70 90
3

Output

150

Input

10000 1000 100 10
1

Output

100

Input

10 100 1000 10000
1

Output

40

Input

12345678 87654321 12345678 87654321
123456789

Output

1524157763907942

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
long long n,x,y,z,d,ma;
int main()
{

    scanf("%d%d%d%d%d",&x,&y,&z,&d,&n);

    cout<<min(min(min(4*x,2*y),z)*n,(n/2*d+n%2* min(min(4*x,2*y),z)))<<endl;

    return 0;
}
```


### Prompt

Construct a cpp code solution to the problem outlined:

Guy-Manuel and Thomas are planning 144 trips around the world.

You are given a simple weighted undirected connected graph with n vertexes and m edges with the following restriction: there isn't any simple cycle (i. e. a cycle which doesn't pass through any vertex more than once) of length greater than 3 which passes through the vertex 1. The cost of a path (not necessarily simple) in this graph is defined as the [XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges in that path with each edge being counted as many times as the path passes through it.

But the trips with cost 0 aren't exciting.

You may choose any subset of edges incident to the vertex 1 and remove them. How many are there such subsets, that, when removed, there is not any nontrivial cycle with the cost equal to 0 which passes through the vertex 1 in the resulting graph? A cycle is called nontrivial if it passes through some edge odd number of times. As the answer can be very big, output it modulo 10^9+7.

Input

The first line contains two integers n and m (1 ≤ n,m ≤ 10^5) — the number of vertexes and edges in the graph. The i-th of the next m lines contains three integers a_i, b_i and w_i (1 ≤ a_i, b_i ≤ n, a_i ≠ b_i, 0 ≤ w_i < 32) — the endpoints of the i-th edge and its weight. It's guaranteed there aren't any multiple edges, the graph is connected and there isn't any simple cycle of length greater than 3 which passes through the vertex 1.

Output

Output the answer modulo 10^9+7.

Examples

Input

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

Output

2

Input

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

Output

1

Input

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

Output

6

Note

The pictures below represent the graphs from examples. <image> In the first example, there aren't any nontrivial cycles with cost 0, so we can either remove or keep the only edge incident to the vertex 1. <image> In the second example, if we don't remove the edge 1-2, then there is a cycle 1-2-4-5-2-1 with cost 0; also if we don't remove the edge 1-3, then there is a cycle 1-3-2-4-5-2-3-1 of cost 0. The only valid subset consists of both edges. <image> In the third example, all subsets are valid except for those two in which both edges 1-3 and 1-4 are kept.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int Maxk = 405, Maxn = 100005, p = 1e9 + 7;
struct Basis {
  int val[5];
  bool insert(int x) {
    for (int i = 4; i >= 0; i--)
      if (x & (1 << i)) {
        if (val[i])
          x ^= val[i];
        else {
          val[i] = x;
          for (int j = 0; j < i; j++)
            if (val[j] && val[i] & (1 << j)) val[i] ^= val[j];
          for (int j = i + 1; j <= 4; j++)
            if (val[j] & (1 << i)) val[j] ^= val[i];
          return true;
        }
      }
    return false;
  }
  int Hash(void) {
    return val[0] | val[1] << 1 | val[2] << 3 | val[3] << 6 | val[4] << 10;
  }
  void init(int x) {
    val[0] = x & 1;
    val[1] = x >> 1 & 3;
    val[2] = x >> 3 & 7;
    val[3] = x >> 6 & 15;
    val[4] = x >> 10 & 31;
  }
} B[Maxn];
int n, m, cnt, block_ct, edge_cnt, dfn_cnt, dfn[Maxn], root[Maxn], dis[Maxn],
    cyc[Maxn], bel[Maxn], head[Maxn], trans[Maxk][Maxk], id[Maxn], rk[Maxk];
bool vis_cyc[Maxn], done[Maxn];
struct edg {
  int nxt, to, w;
} edge[2 * Maxn];
void add(int x, int y, int w) {
  edge[++edge_cnt] = (edg){head[x], y, w};
  head[x] = edge_cnt;
}
void init(void) {
  cnt = 374;
  id[1] = 1, rk[1] = 1;
  id[5] = 2, rk[2] = 5;
  id[37] = 3, rk[3] = 37;
  id[549] = 4, rk[4] = 549;
  id[16933] = 5, rk[5] = 16933;
  id[16421] = 6, rk[6] = 16421;
  id[24613] = 7, rk[7] = 24613;
  id[517] = 8, rk[8] = 517;
  id[16901] = 9, rk[9] = 16901;
  id[20997] = 10, rk[10] = 20997;
  id[773] = 11, rk[11] = 773;
  id[17157] = 12, rk[12] = 17157;
  id[21253] = 13, rk[13] = 21253;
  id[16389] = 14, rk[14] = 16389;
  id[20485] = 15, rk[15] = 20485;
  id[24581] = 16, rk[16] = 24581;
  id[28677] = 17, rk[17] = 28677;
  id[33] = 18, rk[18] = 33;
  id[545] = 19, rk[19] = 545;
  id[16929] = 20, rk[20] = 16929;
  id[18977] = 21, rk[21] = 18977;
  id[673] = 22, rk[22] = 673;
  id[17057] = 23, rk[23] = 17057;
  id[19105] = 24, rk[24] = 19105;
  id[16417] = 25, rk[25] = 16417;
  id[18465] = 26, rk[26] = 18465;
  id[24609] = 27, rk[27] = 24609;
  id[26657] = 28, rk[28] = 26657;
  id[49] = 29, rk[29] = 49;
  id[561] = 30, rk[30] = 561;
  id[16945] = 31, rk[31] = 16945;
  id[18993] = 32, rk[32] = 18993;
  id[689] = 33, rk[33] = 689;
  id[17073] = 34, rk[34] = 17073;
  id[19121] = 35, rk[35] = 19121;
  id[16433] = 36, rk[36] = 16433;
  id[18481] = 37, rk[37] = 18481;
  id[24625] = 38, rk[38] = 24625;
  id[26673] = 39, rk[39] = 26673;
  id[513] = 40, rk[40] = 513;
  id[16897] = 41, rk[41] = 16897;
  id[18945] = 42, rk[42] = 18945;
  id[20993] = 43, rk[43] = 20993;
  id[23041] = 44, rk[44] = 23041;
  id[641] = 45, rk[45] = 641;
  id[17025] = 46, rk[46] = 17025;
  id[19073] = 47, rk[47] = 19073;
  id[21121] = 48, rk[48] = 21121;
  id[23169] = 49, rk[49] = 23169;
  id[769] = 50, rk[50] = 769;
  id[17153] = 51, rk[51] = 17153;
  id[19201] = 52, rk[52] = 19201;
  id[21249] = 53, rk[53] = 21249;
  id[23297] = 54, rk[54] = 23297;
  id[897] = 55, rk[55] = 897;
  id[17281] = 56, rk[56] = 17281;
  id[19329] = 57, rk[57] = 19329;
  id[21377] = 58, rk[58] = 21377;
  id[23425] = 59, rk[59] = 23425;
  id[16385] = 60, rk[60] = 16385;
  id[18433] = 61, rk[61] = 18433;
  id[20481] = 62, rk[62] = 20481;
  id[22529] = 63, rk[63] = 22529;
  id[24577] = 64, rk[64] = 24577;
  id[26625] = 65, rk[65] = 26625;
  id[28673] = 66, rk[66] = 28673;
  id[30721] = 67, rk[67] = 30721;
  id[4] = 68, rk[68] = 4;
  id[36] = 69, rk[69] = 36;
  id[548] = 70, rk[70] = 548;
  id[16932] = 71, rk[71] = 16932;
  id[17956] = 72, rk[72] = 17956;
  id[612] = 73, rk[73] = 612;
  id[16996] = 74, rk[74] = 16996;
  id[18020] = 75, rk[75] = 18020;
  id[16420] = 76, rk[76] = 16420;
  id[17444] = 77, rk[77] = 17444;
  id[24612] = 78, rk[78] = 24612;
  id[25636] = 79, rk[79] = 25636;
  id[44] = 80, rk[80] = 44;
  id[556] = 81, rk[81] = 556;
  id[16940] = 82, rk[82] = 16940;
  id[17964] = 83, rk[83] = 17964;
  id[620] = 84, rk[84] = 620;
  id[17004] = 85, rk[85] = 17004;
  id[18028] = 86, rk[86] = 18028;
  id[16428] = 87, rk[87] = 16428;
  id[17452] = 88, rk[88] = 17452;
  id[24620] = 89, rk[89] = 24620;
  id[25644] = 90, rk[90] = 25644;
  id[516] = 91, rk[91] = 516;
  id[16900] = 92, rk[92] = 16900;
  id[17924] = 93, rk[93] = 17924;
  id[20996] = 94, rk[94] = 20996;
  id[22020] = 95, rk[95] = 22020;
  id[580] = 96, rk[96] = 580;
  id[16964] = 97, rk[97] = 16964;
  id[17988] = 98, rk[98] = 17988;
  id[21060] = 99, rk[99] = 21060;
  id[22084] = 100, rk[100] = 22084;
  id[772] = 101, rk[101] = 772;
  id[17156] = 102, rk[102] = 17156;
  id[18180] = 103, rk[103] = 18180;
  id[21252] = 104, rk[104] = 21252;
  id[22276] = 105, rk[105] = 22276;
  id[836] = 106, rk[106] = 836;
  id[17220] = 107, rk[107] = 17220;
  id[18244] = 108, rk[108] = 18244;
  id[21316] = 109, rk[109] = 21316;
  id[22340] = 110, rk[110] = 22340;
  id[16388] = 111, rk[111] = 16388;
  id[17412] = 112, rk[112] = 17412;
  id[20484] = 113, rk[113] = 20484;
  id[21508] = 114, rk[114] = 21508;
  id[24580] = 115, rk[115] = 24580;
  id[25604] = 116, rk[116] = 25604;
  id[28676] = 117, rk[117] = 28676;
  id[29700] = 118, rk[118] = 29700;
  id[6] = 119, rk[119] = 6;
  id[38] = 120, rk[120] = 38;
  id[550] = 121, rk[121] = 550;
  id[16934] = 122, rk[122] = 16934;
  id[17958] = 123, rk[123] = 17958;
  id[614] = 124, rk[124] = 614;
  id[16998] = 125, rk[125] = 16998;
  id[18022] = 126, rk[126] = 18022;
  id[16422] = 127, rk[127] = 16422;
  id[17446] = 128, rk[128] = 17446;
  id[24614] = 129, rk[129] = 24614;
  id[25638] = 130, rk[130] = 25638;
  id[46] = 131, rk[131] = 46;
  id[558] = 132, rk[132] = 558;
  id[16942] = 133, rk[133] = 16942;
  id[17966] = 134, rk[134] = 17966;
  id[622] = 135, rk[135] = 622;
  id[17006] = 136, rk[136] = 17006;
  id[18030] = 137, rk[137] = 18030;
  id[16430] = 138, rk[138] = 16430;
  id[17454] = 139, rk[139] = 17454;
  id[24622] = 140, rk[140] = 24622;
  id[25646] = 141, rk[141] = 25646;
  id[518] = 142, rk[142] = 518;
  id[16902] = 143, rk[143] = 16902;
  id[17926] = 144, rk[144] = 17926;
  id[20998] = 145, rk[145] = 20998;
  id[22022] = 146, rk[146] = 22022;
  id[582] = 147, rk[147] = 582;
  id[16966] = 148, rk[148] = 16966;
  id[17990] = 149, rk[149] = 17990;
  id[21062] = 150, rk[150] = 21062;
  id[22086] = 151, rk[151] = 22086;
  id[774] = 152, rk[152] = 774;
  id[17158] = 153, rk[153] = 17158;
  id[18182] = 154, rk[154] = 18182;
  id[21254] = 155, rk[155] = 21254;
  id[22278] = 156, rk[156] = 22278;
  id[838] = 157, rk[157] = 838;
  id[17222] = 158, rk[158] = 17222;
  id[18246] = 159, rk[159] = 18246;
  id[21318] = 160, rk[160] = 21318;
  id[22342] = 161, rk[161] = 22342;
  id[16390] = 162, rk[162] = 16390;
  id[17414] = 163, rk[163] = 17414;
  id[20486] = 164, rk[164] = 20486;
  id[21510] = 165, rk[165] = 21510;
  id[24582] = 166, rk[166] = 24582;
  id[25606] = 167, rk[167] = 25606;
  id[28678] = 168, rk[168] = 28678;
  id[29702] = 169, rk[169] = 29702;
  id[32] = 170, rk[170] = 32;
  id[544] = 171, rk[171] = 544;
  id[16928] = 172, rk[172] = 16928;
  id[17952] = 173, rk[173] = 17952;
  id[18976] = 174, rk[174] = 18976;
  id[20000] = 175, rk[175] = 20000;
  id[608] = 176, rk[176] = 608;
  id[16992] = 177, rk[177] = 16992;
  id[18016] = 178, rk[178] = 18016;
  id[19040] = 179, rk[179] = 19040;
  id[20064] = 180, rk[180] = 20064;
  id[672] = 181, rk[181] = 672;
  id[17056] = 182, rk[182] = 17056;
  id[18080] = 183, rk[183] = 18080;
  id[19104] = 184, rk[184] = 19104;
  id[20128] = 185, rk[185] = 20128;
  id[736] = 186, rk[186] = 736;
  id[17120] = 187, rk[187] = 17120;
  id[18144] = 188, rk[188] = 18144;
  id[19168] = 189, rk[189] = 19168;
  id[20192] = 190, rk[190] = 20192;
  id[16416] = 191, rk[191] = 16416;
  id[17440] = 192, rk[192] = 17440;
  id[18464] = 193, rk[193] = 18464;
  id[19488] = 194, rk[194] = 19488;
  id[24608] = 195, rk[195] = 24608;
  id[25632] = 196, rk[196] = 25632;
  id[26656] = 197, rk[197] = 26656;
  id[27680] = 198, rk[198] = 27680;
  id[40] = 199, rk[199] = 40;
  id[552] = 200, rk[200] = 552;
  id[16936] = 201, rk[201] = 16936;
  id[17960] = 202, rk[202] = 17960;
  id[18984] = 203, rk[203] = 18984;
  id[20008] = 204, rk[204] = 20008;
  id[616] = 205, rk[205] = 616;
  id[17000] = 206, rk[206] = 17000;
  id[18024] = 207, rk[207] = 18024;
  id[19048] = 208, rk[208] = 19048;
  id[20072] = 209, rk[209] = 20072;
  id[680] = 210, rk[210] = 680;
  id[17064] = 211, rk[211] = 17064;
  id[18088] = 212, rk[212] = 18088;
  id[19112] = 213, rk[213] = 19112;
  id[20136] = 214, rk[214] = 20136;
  id[744] = 215, rk[215] = 744;
  id[17128] = 216, rk[216] = 17128;
  id[18152] = 217, rk[217] = 18152;
  id[19176] = 218, rk[218] = 19176;
  id[20200] = 219, rk[219] = 20200;
  id[16424] = 220, rk[220] = 16424;
  id[17448] = 221, rk[221] = 17448;
  id[18472] = 222, rk[222] = 18472;
  id[19496] = 223, rk[223] = 19496;
  id[24616] = 224, rk[224] = 24616;
  id[25640] = 225, rk[225] = 25640;
  id[26664] = 226, rk[226] = 26664;
  id[27688] = 227, rk[227] = 27688;
  id[48] = 228, rk[228] = 48;
  id[560] = 229, rk[229] = 560;
  id[16944] = 230, rk[230] = 16944;
  id[17968] = 231, rk[231] = 17968;
  id[18992] = 232, rk[232] = 18992;
  id[20016] = 233, rk[233] = 20016;
  id[624] = 234, rk[234] = 624;
  id[17008] = 235, rk[235] = 17008;
  id[18032] = 236, rk[236] = 18032;
  id[19056] = 237, rk[237] = 19056;
  id[20080] = 238, rk[238] = 20080;
  id[688] = 239, rk[239] = 688;
  id[17072] = 240, rk[240] = 17072;
  id[18096] = 241, rk[241] = 18096;
  id[19120] = 242, rk[242] = 19120;
  id[20144] = 243, rk[243] = 20144;
  id[752] = 244, rk[244] = 752;
  id[17136] = 245, rk[245] = 17136;
  id[18160] = 246, rk[246] = 18160;
  id[19184] = 247, rk[247] = 19184;
  id[20208] = 248, rk[248] = 20208;
  id[16432] = 249, rk[249] = 16432;
  id[17456] = 250, rk[250] = 17456;
  id[18480] = 251, rk[251] = 18480;
  id[19504] = 252, rk[252] = 19504;
  id[24624] = 253, rk[253] = 24624;
  id[25648] = 254, rk[254] = 25648;
  id[26672] = 255, rk[255] = 26672;
  id[27696] = 256, rk[256] = 27696;
  id[56] = 257, rk[257] = 56;
  id[568] = 258, rk[258] = 568;
  id[16952] = 259, rk[259] = 16952;
  id[17976] = 260, rk[260] = 17976;
  id[19000] = 261, rk[261] = 19000;
  id[20024] = 262, rk[262] = 20024;
  id[632] = 263, rk[263] = 632;
  id[17016] = 264, rk[264] = 17016;
  id[18040] = 265, rk[265] = 18040;
  id[19064] = 266, rk[266] = 19064;
  id[20088] = 267, rk[267] = 20088;
  id[696] = 268, rk[268] = 696;
  id[17080] = 269, rk[269] = 17080;
  id[18104] = 270, rk[270] = 18104;
  id[19128] = 271, rk[271] = 19128;
  id[20152] = 272, rk[272] = 20152;
  id[760] = 273, rk[273] = 760;
  id[17144] = 274, rk[274] = 17144;
  id[18168] = 275, rk[275] = 18168;
  id[19192] = 276, rk[276] = 19192;
  id[20216] = 277, rk[277] = 20216;
  id[16440] = 278, rk[278] = 16440;
  id[17464] = 279, rk[279] = 17464;
  id[18488] = 280, rk[280] = 18488;
  id[19512] = 281, rk[281] = 19512;
  id[24632] = 282, rk[282] = 24632;
  id[25656] = 283, rk[283] = 25656;
  id[26680] = 284, rk[284] = 26680;
  id[27704] = 285, rk[285] = 27704;
  id[512] = 286, rk[286] = 512;
  id[16896] = 287, rk[287] = 16896;
  id[17920] = 288, rk[288] = 17920;
  id[18944] = 289, rk[289] = 18944;
  id[19968] = 290, rk[290] = 19968;
  id[20992] = 291, rk[291] = 20992;
  id[22016] = 292, rk[292] = 22016;
  id[23040] = 293, rk[293] = 23040;
  id[24064] = 294, rk[294] = 24064;
  id[576] = 295, rk[295] = 576;
  id[16960] = 296, rk[296] = 16960;
  id[17984] = 297, rk[297] = 17984;
  id[19008] = 298, rk[298] = 19008;
  id[20032] = 299, rk[299] = 20032;
  id[21056] = 300, rk[300] = 21056;
  id[22080] = 301, rk[301] = 22080;
  id[23104] = 302, rk[302] = 23104;
  id[24128] = 303, rk[303] = 24128;
  id[640] = 304, rk[304] = 640;
  id[17024] = 305, rk[305] = 17024;
  id[18048] = 306, rk[306] = 18048;
  id[19072] = 307, rk[307] = 19072;
  id[20096] = 308, rk[308] = 20096;
  id[21120] = 309, rk[309] = 21120;
  id[22144] = 310, rk[310] = 22144;
  id[23168] = 311, rk[311] = 23168;
  id[24192] = 312, rk[312] = 24192;
  id[704] = 313, rk[313] = 704;
  id[17088] = 314, rk[314] = 17088;
  id[18112] = 315, rk[315] = 18112;
  id[19136] = 316, rk[316] = 19136;
  id[20160] = 317, rk[317] = 20160;
  id[21184] = 318, rk[318] = 21184;
  id[22208] = 319, rk[319] = 22208;
  id[23232] = 320, rk[320] = 23232;
  id[24256] = 321, rk[321] = 24256;
  id[768] = 322, rk[322] = 768;
  id[17152] = 323, rk[323] = 17152;
  id[18176] = 324, rk[324] = 18176;
  id[19200] = 325, rk[325] = 19200;
  id[20224] = 326, rk[326] = 20224;
  id[21248] = 327, rk[327] = 21248;
  id[22272] = 328, rk[328] = 22272;
  id[23296] = 329, rk[329] = 23296;
  id[24320] = 330, rk[330] = 24320;
  id[832] = 331, rk[331] = 832;
  id[17216] = 332, rk[332] = 17216;
  id[18240] = 333, rk[333] = 18240;
  id[19264] = 334, rk[334] = 19264;
  id[20288] = 335, rk[335] = 20288;
  id[21312] = 336, rk[336] = 21312;
  id[22336] = 337, rk[337] = 22336;
  id[23360] = 338, rk[338] = 23360;
  id[24384] = 339, rk[339] = 24384;
  id[896] = 340, rk[340] = 896;
  id[17280] = 341, rk[341] = 17280;
  id[18304] = 342, rk[342] = 18304;
  id[19328] = 343, rk[343] = 19328;
  id[20352] = 344, rk[344] = 20352;
  id[21376] = 345, rk[345] = 21376;
  id[22400] = 346, rk[346] = 22400;
  id[23424] = 347, rk[347] = 23424;
  id[24448] = 348, rk[348] = 24448;
  id[960] = 349, rk[349] = 960;
  id[17344] = 350, rk[350] = 17344;
  id[18368] = 351, rk[351] = 18368;
  id[19392] = 352, rk[352] = 19392;
  id[20416] = 353, rk[353] = 20416;
  id[21440] = 354, rk[354] = 21440;
  id[22464] = 355, rk[355] = 22464;
  id[23488] = 356, rk[356] = 23488;
  id[24512] = 357, rk[357] = 24512;
  id[16384] = 358, rk[358] = 16384;
  id[17408] = 359, rk[359] = 17408;
  id[18432] = 360, rk[360] = 18432;
  id[19456] = 361, rk[361] = 19456;
  id[20480] = 362, rk[362] = 20480;
  id[21504] = 363, rk[363] = 21504;
  id[22528] = 364, rk[364] = 22528;
  id[23552] = 365, rk[365] = 23552;
  id[24576] = 366, rk[366] = 24576;
  id[25600] = 367, rk[367] = 25600;
  id[26624] = 368, rk[368] = 26624;
  id[27648] = 369, rk[369] = 27648;
  id[28672] = 370, rk[370] = 28672;
  id[29696] = 371, rk[371] = 29696;
  id[30720] = 372, rk[372] = 30720;
  id[31744] = 373, rk[373] = 31744;
  id[0] = 374, rk[374] = 0;
}
void get_trans(void) {
  init();
  for (int i = 1; i <= 374; i++) {
    Basis tmp_i;
    tmp_i.init(rk[i]);
    for (int j = 1; j <= 374; j++) {
      Basis tmp_j;
      tmp_j.init(rk[j]);
      bool Done = false;
      for (int k = 0; k <= 4; k++)
        if (tmp_i.val[k]) Done |= !tmp_j.insert(tmp_i.val[k]);
      if (!Done) trans[i][j] = id[tmp_j.Hash()];
    }
  }
}
void dfs(int u, int fa, int now) {
  bel[u] = now;
  dfn[u] = ++dfn_cnt;
  for (int i = head[u]; i; i = edge[i].nxt) {
    int to = edge[i].to;
    if (!bel[to])
      dis[to] = dis[u] ^ edge[i].w, dfs(to, u, now);
    else if (to != 1 && to != fa && dfn[to] < dfn[u])
      done[now] |= !B[now].insert(dis[to] ^ dis[u] ^ edge[i].w);
  }
}
long long f[Maxk], g[Maxk], ans;
int main() {
  scanf("%d%d", &n, &m);
  init();
  get_trans();
  for (int i = 1; i <= m; i++) {
    int x, y, w;
    scanf("%d%d%d", &x, &y, &w);
    add(x, y, w);
    add(y, x, w);
  }
  bel[1] = -1;
  for (int i = head[1]; i; i = edge[i].nxt) {
    int to = edge[i].to;
    if (!bel[to])
      root[++block_ct] = to, cyc[block_ct] = edge[i].w, dfs(to, 1, block_ct);
    else {
      int rt = root[bel[to]];
      for (int j = head[to]; j; j = edge[j].nxt)
        if (edge[j].to == rt) {
          cyc[bel[to]] = cyc[bel[to]] ^ edge[i].w ^ edge[j].w;
          vis_cyc[bel[to]] = true;
        }
    }
  }
  f[374] = 1;
  for (int i = 1; i <= block_ct; i++) {
    if (done[i]) continue;
    memcpy(g, f, sizeof(long long[cnt + 1]));
    if (!vis_cyc[i]) {
      int now = id[B[i].Hash()];
      for (int j = 1; j <= cnt; j++)
        if (trans[j][now]) (f[trans[j][now]] += g[j]) %= p;
    } else {
      int now1 = id[B[i].Hash()];
      Basis tmp = B[i];
      bool Done = tmp.insert(cyc[i]);
      int now2 = id[tmp.Hash()];
      for (int j = 1; j <= cnt; j++) {
        if (trans[j][now1]) (f[trans[j][now1]] += 2 * g[j]) %= p;
        if (Done && trans[j][now2]) (f[trans[j][now2]] += g[j]) %= p;
      }
    }
  }
  for (int i = 1; i <= cnt; i++) (ans += f[i]) %= p;
  printf("%lld", ans);
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

problem

Taro bought 10 books. Later, I tried to find out the price based on the receipt, but the receipt was dirty and I could not read the price of a book. We decided to calculate the price of the book from the total price of 10 books and the prices of the other 9 books.

Write a program that outputs the price of the book whose price could not be read. The prices of books are all positive integers. Also, there is no need to consider the consumption tax.

Example

Input

9850
1050
800
420
380
600
820
2400
1800
980
0

Output

600

### Response

```cpp
#include<stdio.h>
int main(void)
{
	int n,m,i,z=0;
		while(1){
		z=0;
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<9;i++){
		m=0;
			scanf("%d",&m);
			z+=m;
		}
		n=n-z;
		printf("%d\n",n);
		}
	return 0;
}
```


### Prompt

Please formulate a CPP solution to the following problem:

In ABBYY a wonderful Smart Beaver lives. This time, he began to study history. When he read about the Roman Empire, he became interested in the life of merchants.

The Roman Empire consisted of n cities numbered from 1 to n. It also had m bidirectional roads numbered from 1 to m. Each road connected two different cities. Any two cities were connected by no more than one road.

We say that there is a path between cities c1 and c2 if there exists a finite sequence of cities t1, t2, ..., tp (p ≥ 1) such that:

  * t1 = c1
  * tp = c2
  * for any i (1 ≤ i < p), cities ti and ti + 1 are connected by a road

We know that there existed a path between any two cities in the Roman Empire.

In the Empire k merchants lived numbered from 1 to k. For each merchant we know a pair of numbers si and li, where si is the number of the city where this merchant's warehouse is, and li is the number of the city where his shop is. The shop and the warehouse could be located in different cities, so the merchants had to deliver goods from the warehouse to the shop.

Let's call a road important for the merchant if its destruction threatens to ruin the merchant, that is, without this road there is no path from the merchant's warehouse to his shop. Merchants in the Roman Empire are very greedy, so each merchant pays a tax (1 dinar) only for those roads which are important for him. In other words, each merchant pays di dinars of tax, where di (di ≥ 0) is the number of roads important for the i-th merchant.

The tax collection day came in the Empire. The Smart Beaver from ABBYY is very curious by nature, so he decided to count how many dinars each merchant had paid that day. And now he needs your help.

Input

The first input line contains two integers n and m, separated by a space, n is the number of cities, and m is the number of roads in the empire.

The following m lines contain pairs of integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi), separated by a space — the numbers of cities connected by the i-th road. It is guaranteed that any two cities are connected by no more than one road and that there exists a path between any two cities in the Roman Empire.

The next line contains a single integer k — the number of merchants in the empire.

The following k lines contain pairs of integers si, li (1 ≤ si, li ≤ n), separated by a space, — si is the number of the city in which the warehouse of the i-th merchant is located, and li is the number of the city in which the shop of the i-th merchant is located.

The input limitations for getting 20 points are:

  * 1 ≤ n ≤ 200
  * 1 ≤ m ≤ 200
  * 1 ≤ k ≤ 200

The input limitations for getting 50 points are:

  * 1 ≤ n ≤ 2000
  * 1 ≤ m ≤ 2000
  * 1 ≤ k ≤ 2000

The input limitations for getting 100 points are:

  * 1 ≤ n ≤ 105
  * 1 ≤ m ≤ 105
  * 1 ≤ k ≤ 105

Output

Print exactly k lines, the i-th line should contain a single integer di — the number of dinars that the i-th merchant paid.

Examples

Input

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

Output

2
1
2
0

Note

The given sample is illustrated in the figure below.

<image>

Let's describe the result for the first merchant. The merchant's warehouse is located in city 1 and his shop is in city 5. Let us note that if either road, (1, 2) or (2, 3) is destroyed, there won't be any path between cities 1 and 5 anymore. If any other road is destroyed, the path will be preserved. That's why for the given merchant the answer is 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, LG = 17 + 3;
int n, m, q, a[N], h[N], mn[N], par[N][LG];
vector<int> adj[N];
void dfs1(int u) {
  mn[u] = h[u] = h[par[u][0]] + 1;
  for (auto v : adj[u])
    if (!h[v]) {
      par[v][0] = u;
      dfs1(v);
      a[v] = (mn[v] > h[u]);
      mn[u] = min(mn[u], mn[v]);
    } else if (v ^ par[u][0])
      mn[u] = min(mn[u], h[v]);
}
void dfs2(int u) {
  for (int i = 0; i < LG - 1; i++) par[u][i + 1] = par[par[u][i]][i];
  for (auto v : adj[u])
    if (h[v] == h[u] + 1) {
      a[v] += a[u];
      dfs2(v);
    }
}
inline int get_par(int u, int k) {
  for (int i = 0; i < LG; i++)
    if (k >> i & 1) u = par[u][i];
  return u;
}
inline int lca(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  v = get_par(v, h[v] - h[u]);
  for (int i = LG - 1; ~i; i--)
    if (par[u][i] ^ par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  return u ^ v ? par[u][0] : u;
}
inline int dist(int u, int v) { return a[u] + a[v] - 2 * a[lca(u, v)]; }
inline void readInput() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
}
inline void solve() {
  dfs1(0);
  dfs2(0);
}
inline void writeOutput() {
  cin >> q;
  for (int i = 0; i < q; i++) {
    int u, v;
    cin >> u >> v;
    cout << dist(u - 1, v - 1) << endl;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  readInput(), solve(), writeOutput();
  return 0;
}

```


### Prompt

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

You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the table

    abcd
    edfg
    hijk

we obtain the table:

    acd
    efg
    hjk

A table is called good if its rows are ordered from top to bottom lexicographically, i.e. each row is lexicographically no larger than the following one. Determine the minimum number of operations of removing a column needed to make a given table good.

Input

The first line contains two integers — n and m (1 ≤ n, m ≤ 100).

Next n lines contain m small English letters each — the characters of the table.

Output

Print a single number — the minimum number of columns that you need to remove in order to make the table good.

Examples

Input

1 10
codeforces

Output

0

Input

4 4
case
care
test
code

Output

2

Input

5 4
code
forc
esco
defo
rces

Output

4

Note

In the first sample the table is already good.

In the second sample you may remove the first and third column.

In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).

Let strings s and t have equal length. Then, s is lexicographically larger than t if they are not equal and the character following the largest common prefix of s and t (the prefix may be empty) in s is alphabetically larger than the corresponding character of t.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int done[1005];
char str[105][105];
int main() {
  int r, c, cnt, sol, i, j;
  ios::sync_with_stdio(false);
  cin >> r >> c;
  for (i = 0; i < r; i++) {
    cin >> str[i];
  }
  cnt = 0;
  for (i = 0; i < c; i++) {
    sol = 0;
    for (j = 1; j < r; j++) {
      if (!done[j] && (str[j][i] < str[j - 1][i])) {
        sol = 1;
      }
    }
    if (!sol) {
      for (j = 1; j < r; j++) {
        if (!done[j] && (str[j][i] > str[j - 1][i])) done[j] = 1;
      }
    } else {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

```


### Prompt

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

In this problem, we will deal with binary strings. Each character of a binary string is either a 0 or a 1. We will also deal with substrings; recall that a substring is a contiguous subsequence of a string. We denote the substring of string s starting from the l-th character and ending with the r-th character as s[l ... r]. The characters of each string are numbered from 1.

We can perform several operations on the strings we consider. Each operation is to choose a substring of our string and replace it with another string. There are two possible types of operations: replace 011 with 110, or replace 110 with 011. For example, if we apply exactly one operation to the string 110011110, it can be transformed into 011011110, 110110110, or 110011011.

Binary string a is considered reachable from binary string b if there exists a sequence s_1, s_2, ..., s_k such that s_1 = a, s_k = b, and for every i ∈ [1, k - 1], s_i can be transformed into s_{i + 1} using exactly one operation. Note that k can be equal to 1, i. e., every string is reachable from itself.

You are given a string t and q queries to it. Each query consists of three integers l_1, l_2 and len. To answer each query, you have to determine whether t[l_1 ... l_1 + len - 1] is reachable from t[l_2 ... l_2 + len - 1].

Input

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

The second line contains one string t (|t| = n). Each character of t is either 0 or 1.

The third line contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries.

Then q lines follow, each line represents a query. The i-th line contains three integers l_1, l_2 and len (1 ≤ l_1, l_2 ≤ |t|, 1 ≤ len ≤ |t| - max(l_1, l_2) + 1) for the i-th query.

Output

For each query, print either YES if t[l_1 ... l_1 + len - 1] is reachable from t[l_2 ... l_2 + len - 1], or NO otherwise. You may print each letter in any register.

Example

Input

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

Output

Yes
Yes
No

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class t, class u>
void chmax(t& first, u second) {
  if (first < second) first = second;
}
template <class t, class u>
void chmin(t& first, u second) {
  if (second < first) first = second;
}
template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;
using pi = pair<ll, ll>;
using vi = vc<ll>;
template <class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
  return os << "{" << p.first << "," << p.second << "}";
}
template <class t>
ostream& operator<<(ostream& os, const vc<t>& v) {
  os << "{";
  for (auto e : v) os << e << ",";
  return os << "}";
}
using uint = unsigned;
using ull = unsigned long long;
template <class t, size_t n>
ostream& operator<<(ostream& os, const array<t, n>& first) {
  return os << vc<t>(first.begin(), first.end());
}
template <ll i, class T>
void print_tuple(ostream&, const T&) {}
template <ll i, class T, class H, class... Args>
void print_tuple(ostream& os, const T& t) {
  if (i) os << ",";
  os << get<i>(t);
  print_tuple<i + 1, T, Args...>(os, t);
}
template <class... Args>
ostream& operator<<(ostream& os, const tuple<Args...>& t) {
  os << "{";
  print_tuple<0, tuple<Args...>, Args...>(os, t);
  return os << "}";
}
template <class t>
void print(t x, ll suc = 1) {
  cout << x;
  if (suc == 1) cout << "\n";
  if (suc == 2) cout << " ";
}
ll read() {
  ll i;
  cin >> i;
  return i;
}
vi readvi(ll n, ll off = 0) {
  vi v(n);
  for (ll i = ll(0); i < ll(n); i++) v[i] = read() + off;
  return v;
}
template <class T>
void print(const vector<T>& v, ll suc = 1) {
  for (ll i = ll(0); i < ll(v.size()); i++)
    print(v[i], i == ll(v.size()) - 1 ? suc : 2);
}
string readString() {
  string s;
  cin >> s;
  return s;
}
template <class T>
T sq(const T& t) {
  return t * t;
}
void yes(bool ex = true) {
  cout << "Yes"
       << "\n";
  if (ex) exit(0);
}
void no(bool ex = true) {
  cout << "No"
       << "\n";
  if (ex) exit(0);
}
void possible(bool ex = true) {
  cout << "Possible"
       << "\n";
  if (ex) exit(0);
}
void impossible(bool ex = true) {
  cout << "Impossible"
       << "\n";
  if (ex) exit(0);
}
constexpr ll ten(ll n) { return n == 0 ? 1 : ten(n - 1) * 10; }
const ll infLL = LLONG_MAX / 3;
const ll inf = infLL;
ll topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); }
ll topbit(ll t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); }
ll botbit(signed first) { return first == 0 ? 32 : __builtin_ctz(first); }
ll botbit(ll first) { return first == 0 ? 64 : __builtin_ctzll(first); }
ll popcount(signed t) { return __builtin_popcount(t); }
ll popcount(ll t) { return __builtin_popcountll(t); }
bool ispow2(ll i) { return i && (i & -i) == i; }
ll mask(ll i) { return (ll(1) << i) - 1; }
template <class t>
bool inc(t first, t second, t c) {
  return first <= second && second <= c;
}
template <class t>
void mkuni(vc<t>& v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
ll rand_int(ll l, ll r) {
  static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
  return uniform_int_distribution<ll>(l, r)(gen);
}
template <class t>
ll lwb(const vc<t>& v, const t& first) {
  return lower_bound(v.begin(), v.end(), first) - v.begin();
}
using uint = unsigned;
using ull = unsigned long long;
struct modinfo {
  uint mod, root;
};
template <modinfo const& ref>
struct modular {
  static constexpr uint const& mod = ref.mod;
  static modular root() { return modular(ref.root); }
  uint v;
  modular(ll vv = 0) { s(vv % mod + mod); }
  modular& s(uint vv) {
    v = vv < mod ? vv : vv - mod;
    return *this;
  }
  modular operator-() const { return modular() - *this; }
  modular& operator+=(const modular& rhs) { return s(v + rhs.v); }
  modular& operator-=(const modular& rhs) { return s(v + mod - rhs.v); }
  modular& operator*=(const modular& rhs) {
    v = ull(v) * rhs.v % mod;
    return *this;
  }
  modular& operator/=(const modular& rhs) { return *this *= rhs.inv(); }
  modular operator+(const modular& rhs) const { return modular(*this) += rhs; }
  modular operator-(const modular& rhs) const { return modular(*this) -= rhs; }
  modular operator*(const modular& rhs) const { return modular(*this) *= rhs; }
  modular operator/(const modular& rhs) const { return modular(*this) /= rhs; }
  modular pow(ll n) const {
    modular res(1), x(*this);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  modular inv() const { return pow(mod - 2); }
  friend modular operator+(ll x, const modular& y) { return modular(x) + y; }
  friend modular operator-(ll x, const modular& y) { return modular(x) - y; }
  friend modular operator*(ll x, const modular& y) { return modular(x) * y; }
  friend modular operator/(ll x, const modular& y) { return modular(x) / y; }
  friend ostream& operator<<(ostream& os, const modular& m) {
    return os << m.v;
  }
  friend istream& operator>>(istream& is, modular& m) {
    ll x;
    is >> x;
    m = modular(x);
    return is;
  }
  bool operator<(const modular& r) const { return v < r.v; }
  bool operator==(const modular& r) const { return v == r.v; }
  bool operator!=(const modular& r) const { return v != r.v; }
  explicit operator bool() const { return v; }
};
extern constexpr modinfo base{1000000007, 0};
using mint = modular<base>;
const ll vmax = (1 << 21) + 10;
mint fact[vmax], finv[vmax], invs[vmax];
void initfact() {
  fact[0] = 1;
  for (ll i = ll(1); i < ll(vmax); i++) {
    fact[i] = fact[i - 1] * i;
  }
  finv[vmax - 1] = fact[vmax - 1].inv();
  for (ll i = vmax - 2; i >= 0; i--) {
    finv[i] = finv[i + 1] * (i + 1);
  }
  for (ll i = vmax - 1; i >= 1; i--) {
    invs[i] = finv[i] * fact[i - 1];
  }
}
mint choose(ll n, ll k) { return fact[n] * finv[n - k] * finv[k]; }
mint binom(ll first, ll second) {
  return fact[first + second] * finv[first] * finv[second];
}
mint catalan(ll n) {
  return binom(n, n) - (n - 1 >= 0 ? binom(n - 1, n + 1) : 0);
}
namespace rhash {
const ll k = 4;
vc<array<mint, k>> first, second;
void init(ll n) {
  first.resize(n + 1);
  second.resize(n + 1);
  for (ll i = ll(0); i < ll(k); i++) {
    first[0][i] = 1;
    first[1][i] = rand_int(1, mint::mod - 1);
    second[0][i] = 1;
    second[1][i] = first[1][i].inv();
  }
  for (ll i = ll(1); i < ll(n); i++)
    for (ll j = ll(0); j < ll(k); j++) {
      first[i + 1][j] = first[i][j] * first[1][j];
      second[i + 1][j] = second[i][j] * second[1][j];
    }
}
using P = pair<array<mint, k>, ll>;
P mrg(P x, P y) {
  for (ll i = ll(0); i < ll(k); i++)
    x.first[i] += y.first[i] * first[x.second][i];
  x.second += y.second;
  return x;
}
struct gen {
  gen() {}
  vc<array<mint, k>> c;
  template <class S>
  gen(S s) : c(s.size() + 1) {
    for (ll i = ll(0); i < ll(s.size()); i++)
      for (ll j = ll(0); j < ll(k); j++)
        c[i + 1][j] = c[i][j] + first[i][j] * s[i];
  }
  P get(ll l, ll r) {
    P res;
    for (ll i = ll(0); i < ll(k); i++)
      res.first[i] = (c[r][i] - c[l][i]) * second[l][i];
    res.second = r - l;
    return res;
  }
};
}  // namespace rhash
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vi ps{-1};
  {
    string s;
    cin >> s;
    for (ll i = ll(0); i < ll(n); i++)
      if (s[i] == '0') ps.push_back(i);
  }
  ps.push_back(n);
  rhash::init(ll(ps.size()));
  vi x[2];
  for (ll k = ll(0); k < ll(2); k++) {
    for (auto v : ps) x[k].push_back((v ^ k) & 1);
  }
  rhash::gen y[2];
  for (ll k = ll(0); k < ll(2); k++) y[k] = rhash::gen(x[k]);
  auto get = [&](ll l, ll r) -> rhash::P {
    ll i = lwb(ps, l);
    if (ps[i] < r) {
      return y[l & 1].get(i, lwb(ps, r));
    } else {
      return {};
    }
  };
  ll q;
  cin >> q;
  for (ll _ = ll(0); _ < ll(q); _++) {
    ll first, second, c;
    cin >> first >> second >> c;
    first--;
    second--;
    if (get(first, first + c) == get(second, second + c))
      yes(0);
    else
      no(0);
  }
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Mikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool programmer, he needs at least p experience points, and a desired flat in Moscow costs q dollars. Mikhail is determined to follow his dreams and registered at a freelance site.

He has suggestions to work on n distinct projects. Mikhail has already evaluated that the participation in the i-th project will increase his experience by ai per day and bring bi dollars per day. As freelance work implies flexible working hours, Mikhail is free to stop working on one project at any time and start working on another project. Doing so, he receives the respective share of experience and money. Mikhail is only trying to become a cool programmer, so he is able to work only on one project at any moment of time.

Find the real value, equal to the minimum number of days Mikhail needs to make his dream come true.

For example, suppose Mikhail is suggested to work on three projects and a1 = 6, b1 = 2, a2 = 1, b2 = 3, a3 = 2, b3 = 6. Also, p = 20 and q = 20. In order to achieve his aims Mikhail has to work for 2.5 days on both first and third projects. Indeed, a1·2.5 + a2·0 + a3·2.5 = 6·2.5 + 1·0 + 2·2.5 = 20 and b1·2.5 + b2·0 + b3·2.5 = 2·2.5 + 3·0 + 6·2.5 = 20.

Input

The first line of the input contains three integers n, p and q (1 ≤ n ≤ 100 000, 1 ≤ p, q ≤ 1 000 000) — the number of projects and the required number of experience and money.

Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 1 000 000) — the daily increase in experience and daily income for working on the i-th project.

Output

Print a real value — the minimum number of days Mikhail needs to get the required amount of experience and money. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

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

Examples

Input

3 20 20
6 2
1 3
2 6

Output

5.000000000000000

Input

4 1 1
2 3
3 2
2 3
3 2

Output

0.400000000000000

Note

First sample corresponds to the example in the problem statement.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
double p, q;
complex<double> ps[100010];
inline double cross(complex<double> a, complex<double> b) {
  return a.real() * b.imag() - a.imag() * b.real();
}
bool cmp(complex<double> a, complex<double> b) {
  double c = cross(a, b);
  if (c == 0) return a.real() + a.imag() < b.real() + b.imag();
  return c > 0;
}
inline bool isl(complex<double> a, complex<double> b, complex<double> c) {
  return cross(b - a, c - a) > 0;
}
vector<complex<double> > convex;
bool calc(double time) {
  for (int i = 0; i < convex.size() - 1; i++) {
    complex<double> a = convex[i] * time, b = complex<double>(p, q),
                    c = convex[i + 1] * time;
    if (cmp(a, b) && cmp(b, c) && !isl(a, b, c)) return true;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> p >> q;
  int mxa = 0, mxb = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    ps[i] = complex<double>(a, b);
    mxa = max(mxa, a);
    mxb = max(mxb, b);
  }
  ps[n] = complex<double>(mxa, 0);
  ps[n + 1] = complex<double>(0, mxb);
  n += 2;
  sort(ps, ps + n, cmp);
  for (int i = 0; i < n; i++) {
    while (convex.size() >= 2 &&
           !isl(convex[convex.size() - 2], convex.back(), ps[i]))
      convex.pop_back();
    convex.push_back(ps[i]);
  }
  double l = 0, r = max(p, q);
  while (r - l > 1e-7) {
    double mid = (l + r) / 2;
    if (calc(mid))
      r = mid;
    else
      l = mid;
  }
  cout << fixed << setprecision(10) << (l + r) / 2 << endl;
}

```


### Prompt

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

I have an undirected graph consisting of n nodes, numbered 1 through n. Each node has at most two incident edges. For each pair of nodes, there is at most an edge connecting them. No edge connects a node to itself.

I would like to create a new graph in such a way that:

  * The new graph consists of the same number of nodes and edges as the old graph.
  * The properties in the first paragraph still hold.
  * For each two nodes u and v, if there is an edge connecting them in the old graph, there is no edge connecting them in the new graph.

Help me construct the new graph, or tell me if it is impossible.

Input

The first line consists of two space-separated integers: n and m (1 ≤ m ≤ n ≤ 105), denoting the number of nodes and edges, respectively. Then m lines follow. Each of the m lines consists of two space-separated integers u and v (1 ≤ u, v ≤ n; u ≠ v), denoting an edge between nodes u and v.

Output

If it is not possible to construct a new graph with the mentioned properties, output a single line consisting of -1. Otherwise, output exactly m lines. Each line should contain a description of edge in the same way as used in the input format.

Examples

Input

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

Output

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

Input

3 2
1 2
2 3

Output

-1

Input

5 4
1 2
2 3
3 4
4 1

Output

1 3
3 5
5 2
2 4

Note

The old graph of the first example:

<image>

A possible new graph for the first example:

<image>

In the second example, we cannot create any new graph.

The old graph of the third example:

<image>

A possible new graph for the third example:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int N, M, cnt;
map<pair<int, int>, bool> mp;
int nd[200005];
void solve() {
  cnt++;
  vector<pair<int, int> > ari;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  for (int i = 1; i <= N; i++) nd[i] = i;
  shuffle(nd + 1, nd + N + 1, rng);
  int l = 1;
  while (l <= N) {
    int r = l;
    while (ari.size() < M && r + 1 <= N && !mp[{nd[r], nd[r + 1]}]) {
      ari.push_back({nd[r], nd[r + 1]});
      r++;
    }
    if (l + 2 <= r && ari.size() < M && !mp[{nd[l], nd[r]}])
      ari.push_back({nd[l], nd[r]});
    l = r + 1;
  }
  if (ari.size() == M) {
    for (auto v : ari) cout << v.first << " " << v.second << "\n";
    exit(0);
  }
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    int u, v;
    cin >> u >> v;
    mp[{u, v}] = 1;
    mp[{v, u}] = 1;
  }
  int T = 150;
  while (T--) solve();
  cout << "-1\n";
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

Nathan O. Davis has been running an electronic bulletin board system named JAG-channel. He is now having hard time to add a new feature there --- threaded view.

Like many other bulletin board systems, JAG-channel is thread-based. Here a thread (also called a topic) refers to a single conversation with a collection of posts. Each post can be an opening post, which initiates a new thread, or a reply to a previous post in an existing thread.

Threaded view is a tree-like view that reflects the logical reply structure among the posts: each post forms a node of the tree and contains its replies as its subnodes in the chronological order (i.e. older replies precede newer ones). Note that a post along with its direct and indirect replies forms a subtree as a whole.

Let us take an example. Suppose: a user made an opening post with a message `hoge`; another user replied to it with `fuga`; yet another user also replied to the opening post with `piyo`; someone else replied to the second post (i.e. `fuga`”) with `foobar`; and the fifth user replied to the same post with `jagjag`. The tree of this thread would look like:

hoge
├─fuga
│　├─foobar
│　└─jagjag
└─piyo

For easier implementation, Nathan is thinking of a simpler format: the depth of each post from the opening post is represented by dots. Each reply gets one more dot than its parent post. The tree of the above thread would then look like:

hoge
.fuga
..foobar
..jagjag
.piyo

Your task in this problem is to help Nathan by writing a program that prints a tree in the Nathan's format for the given posts in a single thread.

Input

Input contains a single dataset in the following format:

n
k_1
M_1
k_2
M_2
:
:
k_n
M_n

The first line contains an integer n (1 ≤ n ≤ 1,000), which is the number of posts in the thread. Then 2n lines follow. Each post is represented by two lines: the first line contains an integer k_i (k_1 = 0, 1 ≤ k_i < i for 2 ≤ i ≤ n) and indicates the i-th post is a reply to the k_i-th post; the second line contains a string M_i and represents the message of the i-th post. k_1 is always 0, which means the first post is not replying to any other post, i.e. it is an opening post.

Each message contains 1 to 50 characters, consisting of uppercase, lowercase, and numeric letters.

Output

Print the given n messages as specified in the problem statement.

Sample Input 1

1
0
icpc

Output for the Sample Input 1

icpc

Sample Input 2

5
0
hoge
1
fuga
1
piyo
2
foobar
2
jagjag

Output for the Sample Input 2

hoge
.fuga
..foobar
..jagjag
.piyo

Sample Input 3

8
0
jagjag
1
hogehoge
1
buhihi
2
fugafuga
4
ponyoponyo
5
evaeva
4
nowawa
5
pokemon

Output for the Sample Input 3

jagjag
.hogehoge
..fugafuga
...ponyoponyo
....evaeva
....pokemon
...nowawa
.buhihi

Sample Input 4

6
0
nakachan
1
fan
2
yamemasu
3
nennryou2
4
dannyaku4
5
kouzai11

Output for the Sample Input 4

nakachan
.fan
..yamemasu
...nennryou2
....dannyaku4
.....kouzai11

Sample Input 5

34
0
LoveLive
1
honoka
2
borarara
2
sunohare
2
mogyu
1
eri
6
kasikoi
7
kawaii
8
eriichika
1
kotori
10
WR
10
haetekurukotori
10
ichigo
1
umi
14
love
15
arrow
16
shoot
1
rin
18
nyanyanya
1
maki
20
6th
20
star
22
nishikino
1
nozomi
24
spiritual
25
power
1
hanayo
27
darekatasukete
28
chottomattete
1
niko
30
natsuiro
30
nikkonikkoni
30
sekaino
33
YAZAWA

Output for the Sample Input 5

LoveLive
.honoka
..borarara
..sunohare
..mogyu
.eri
..kasikoi
...kawaii
....eriichika
.kotori
..WR
..haetekurukotori
..ichigo
.umi
..love
...arrow
....shoot
.rin
..nyanyanya
.maki
..6th
..star
...nishikino
.nozomi
..spiritual
...power
.hanayo
..darekatasukete
...chottomattete
.niko
..natsuiro
..nikkonikkoni
..sekaino
...YAZAWA

Sample Input 6

6
0
2ch
1
1ostu
1
2get
1
1otsu
1
1ostu
3
pgr

Output for the Sample Input 6

2ch
.1ostu
.2get
..pgr
.1otsu
.1ostu

Example

Input

1
0
icpc

Output

icpc

### Response

```cpp
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

class State {
public:
	int id;
	string str;
	int deep;
	vector<State> rep;

	void draw()
	{
		rep(i, deep) {
			cout << '.';
		}

		cout << str << endl;

		for (auto& r : rep) {
			r.draw();
		}
	}

	void add(State s, int i)
	{
		if (i == id) {
			s.deep = deep + 1;
			rep.push_back(s);
		}
		else {
			for (auto& r : rep) {
				r.add(s, i);
			}
		}
	}
};

int main()
{
	int n;

	cin >> n;

	State s;
	s.id = 1;
	s.deep = 0;

	cin >> s.str >> s.str;

	rep(i, n - 1) {
		int r;
		State temp;
		temp.id = i + 2;

		cin >> r >> temp.str;

		s.add(temp, r);
	}

	s.draw();

	return 0;
}
```


### Prompt

Create a solution in Cpp for the following problem:

Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.

The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough for Xenia. She is only beginning to count, so she can calculate a sum only if the summands follow in non-decreasing order. For example, she can't calculate sum 1+3+2+1 but she can calculate sums 1+1+2 and 3+3.

You've got the sum that was written on the board. Rearrange the summans and print the sum in such a way that Xenia can calculate the sum.

Input

The first line contains a non-empty string s — the sum Xenia needs to count. String s contains no spaces. It only contains digits and characters "+". Besides, string s is a correct sum of numbers 1, 2 and 3. String s is at most 100 characters long.

Output

Print the new sum that Xenia can count.

Examples

Input

3+2+1

Output

1+2+3

Input

1+1+3+1+3

Output

1+1+1+3+3

Input

2

Output

2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.length();
  int n1 = 0, n2 = 0, n3 = 0, n4;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') n1 += 1;
    if (s[i] == '2') n2 += 1;
    if (s[i] == '3') n3 += 1;
    if (s[i] == '+') n4 += 1;
  }
  for (int j = 1; j <= n1; j++) {
    cout << 1;
    if (n4 > 0) {
      cout << '+';
      --n4;
    }
  }
  for (int j = 1; j <= n2; j++) {
    cout << 2;
    if (n4 > 0) {
      cout << '+';
      --n4;
    }
  }
  for (int j = 1; j <= n3; j++) {
    cout << 3;
    if (n4 > 0) {
      cout << '+';
      --n4;
    }
  }
}

```


### Prompt

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

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

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

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

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

Input

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

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

Output

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

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

Examples

Input

4
0 1 2 1

Output

-1

Input

3
1 0 1

Output

1

Input

4
0 1 2 239

Output

4

Note

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

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

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

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

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int maxi = 0;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if (a > maxi) {
      cout << i << endl;
      return 0;
    }
    if (a == maxi) {
      maxi++;
    }
  }
  cout << -1 << endl;
}

```


### Prompt

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

Fox Ciel just designed a puzzle game called "Polygon"! It is played using triangulations of a regular n-edge polygon. The goal is to transform one triangulation to another by some tricky rules.

<image>

Triangulation of an n-edge poylgon is a set of n - 3 diagonals satisfying the condition that no two diagonals share a common internal point.

For example, the initial state of the game may look like (a) in above figure. And your goal may look like (c). In each step you can choose a diagonal inside the polygon (but not the one of edges of the polygon) and flip this diagonal.

Suppose you are going to flip a diagonal a – b. There always exist two triangles sharing a – b as a side, let's denote them as a – b – c and a – b – d. As a result of this operation, the diagonal a – b is replaced by a diagonal c – d. It can be easily proven that after flip operation resulting set of diagonals is still a triangulation of the polygon.

So in order to solve above case, you may first flip diagonal 6 – 3, it will be replaced by diagonal 2 – 4. Then you flip diagonal 6 – 4 and get figure (c) as result.

Ciel just proved that for any starting and destination triangulations this game has a solution. She wants you to solve it in no more than 20 000 steps for any puzzle satisfying n ≤ 1000.

Input

The first line contain an integer n (4 ≤ n ≤ 1000), number of edges of the regular polygon.

Then follows two groups of (n - 3) lines describing the original triangulation and goal triangulation.

Description of each triangulation consists of (n - 3) lines. Each line contains 2 integers ai and bi (1 ≤ ai, bi ≤ n), describing a diagonal ai – bi.

It is guaranteed that both original and goal triangulations are correct (i. e. no two diagonals share a common internal point in both of these triangulations).

Output

First, output an integer k (0 ≤ k ≤ 20, 000): number of steps.

Then output k lines, each containing 2 integers ai and bi: the endpoints of a diagonal you are going to flip at step i. You may output ai and bi in any order.

If there are several possible solutions, output any of them.

Examples

Input

4
1 3
2 4

Output

1
1 3

Input

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

Output

2
6 3
6 4

Input

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

Output

3
7 3
7 2
7 1

Note

Sample test 2 is discussed above and shown on the picture.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
set<int> v[1010];
int t[1010], ts;
bool bs[1010][1010];
void go(vector<pair<int, int> > &ans, bool esp = 0) {
  for (int k = 0; k < n - 3; k++) {
    ts = 0;
    for (auto i : v[0]) {
      t[ts++] = i;
    }
    for (int i = 0; i < ts - 1; i++)
      if (t[i] + 1 != t[i + 1]) {
        int aff = 0;
        for (int j = 1; j < n; j++)
          if (bs[t[i]][j] && bs[t[i + 1]][j]) {
            if ((j + 1) % n != t[i] && (t[i] + 1) % n != j) {
              bs[t[i]][j] = bs[j][t[i]] = 0;
            }
            if ((j + 1) % n != t[i + 1] && (t[i + 1] + 1) % n != j) {
              bs[t[i + 1]][j] = bs[j][t[i + 1]] = 0;
            }
            bs[t[i]][t[i + 1]] = bs[t[i + 1]][t[i]] = 0;
            bs[0][j] = bs[j][0] = 1;
            v[0].insert(j);
            aff = j;
            break;
          }
        if (esp)
          ans.push_back(make_pair(0, aff));
        else
          ans.push_back(make_pair(t[i], t[i + 1]));
        break;
      }
  }
}
int main() {
  scanf("%d", &n);
  memset(bs, 0, sizeof bs);
  for (int i = 0; i < n; i++) v[i].clear();
  for (int i = 0; i < n; i++) {
    v[i].insert((i + 1) % n);
    v[(i + 1) % n].insert(i);
    bs[i][(i + 1) % n] = 1;
    bs[(i + 1) % n][i] = 1;
  }
  for (int i = 0; i < n - 3; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    v[a].insert(b);
    v[b].insert(a);
    bs[a][b] = bs[b][a] = 1;
  }
  vector<pair<int, int> > ans1 = vector<pair<int, int> >();
  go(ans1);
  memset(bs, 0, sizeof bs);
  for (int i = 0; i < n; i++) v[i].clear();
  for (int i = 0; i < n; i++) {
    v[i].insert((i + 1) % n);
    v[(i + 1) % n].insert(i);
    bs[i][(i + 1) % n] = 1;
    bs[(i + 1) % n][i] = 1;
  }
  for (int i = 0; i < n - 3; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    v[a].insert(b);
    v[b].insert(a);
    bs[a][b] = bs[b][a] = 1;
  }
  vector<pair<int, int> > ans2 = vector<pair<int, int> >();
  go(ans2, 1);
  reverse(ans2.begin(), ans2.end());
  printf("%d\n", ans1.size() + ans2.size());
  for (int i = 0; i < ans1.size(); i++)
    printf("%d %d\n", ans1[i].first + 1, ans1[i].second + 1);
  for (int i = 0; i < ans2.size(); i++)
    printf("%d %d\n", ans2[i].first + 1, ans2[i].second + 1);
}

```


### Prompt

Develop a solution in cpp to the problem described below:

You are given a set of n elements indexed from 1 to n. The weight of i-th element is wi. The weight of some subset of a given set is denoted as <image>. The weight of some partition R of a given set into k subsets is <image> (recall that a partition of a given set is a set of its subsets such that every element of the given set belongs to exactly one subset in partition).

Calculate the sum of weights of all partitions of a given set into exactly k non-empty subsets, and print it modulo 109 + 7. Two partitions are considered different iff there exist two elements x and y such that they belong to the same set in one of the partitions, and to different sets in another partition.

Input

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 2·105) — the number of elements and the number of subsets in each partition, respectively.

The second line contains n integers wi (1 ≤ wi ≤ 109)— weights of elements of the set.

Output

Print one integer — the sum of weights of all partitions of a given set into k non-empty subsets, taken modulo 109 + 7.

Examples

Input

4 2
2 3 2 3

Output

160

Input

5 2
1 2 3 4 5

Output

645

Note

Possible partitions in the first sample:

  1. {{1, 2, 3}, {4}}, W(R) = 3·(w1 + w2 + w3) + 1·w4 = 24;
  2. {{1, 2, 4}, {3}}, W(R) = 26;
  3. {{1, 3, 4}, {2}}, W(R) = 24;
  4. {{1, 2}, {3, 4}}, W(R) = 2·(w1 + w2) + 2·(w3 + w4) = 20;
  5. {{1, 3}, {2, 4}}, W(R) = 20;
  6. {{1, 4}, {2, 3}}, W(R) = 20;
  7. {{1}, {2, 3, 4}}, W(R) = 26;

Possible partitions in the second sample:

  1. {{1, 2, 3, 4}, {5}}, W(R) = 45;
  2. {{1, 2, 3, 5}, {4}}, W(R) = 48;
  3. {{1, 2, 4, 5}, {3}}, W(R) = 51;
  4. {{1, 3, 4, 5}, {2}}, W(R) = 54;
  5. {{2, 3, 4, 5}, {1}}, W(R) = 57;
  6. {{1, 2, 3}, {4, 5}}, W(R) = 36;
  7. {{1, 2, 4}, {3, 5}}, W(R) = 37;
  8. {{1, 2, 5}, {3, 4}}, W(R) = 38;
  9. {{1, 3, 4}, {2, 5}}, W(R) = 38;
  10. {{1, 3, 5}, {2, 4}}, W(R) = 39;
  11. {{1, 4, 5}, {2, 3}}, W(R) = 40;
  12. {{2, 3, 4}, {1, 5}}, W(R) = 39;
  13. {{2, 3, 5}, {1, 4}}, W(R) = 40;
  14. {{2, 4, 5}, {1, 3}}, W(R) = 41;
  15. {{3, 4, 5}, {1, 2}}, W(R) = 42.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5, yzh = 1e9 + 7;
int x, n, k, inv[N + 5];
int quick_pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1ll * ans * a % yzh;
    a = 1ll * a * a % yzh, b >>= 1;
  }
  return ans;
}
int S(int n, int m) {
  int ans = 0;
  for (int i = 0; i <= m; i++) {
    int t = 1ll * inv[i] * inv[m - i] % yzh * quick_pow(m - i, n) % yzh;
    if (i & 1)
      (ans -= t) %= yzh;
    else
      (ans += t) %= yzh;
  }
  return ans;
}
void work() {
  scanf("%d%d", &n, &k);
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= k; i++) inv[i] = -1ll * yzh / i * inv[yzh % i] % yzh;
  for (int i = 1; i <= k; i++) inv[i] = 1ll * inv[i - 1] * inv[i] % yzh;
  int sum = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &x), (sum += x) %= yzh;
  int ans = (S(n - 1, k - 1) + 1ll * (n + k - 1) * S(n - 1, k) % yzh) % yzh;
  ans = 1ll * ans * sum % yzh;
  printf("%d\n", (ans + yzh) % yzh);
}
int main() {
  work();
  return 0;
}

```


### Prompt

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

You are given n switches and m lamps. The i-th switch turns on some subset of the lamps. This information is given as the matrix a consisting of n rows and m columns where ai, j = 1 if the i-th switch turns on the j-th lamp and ai, j = 0 if the i-th switch is not connected to the j-th lamp.

Initially all m lamps are turned off.

Switches change state only from "off" to "on". It means that if you press two or more switches connected to the same lamp then the lamp will be turned on after any of this switches is pressed and will remain its state even if any switch connected to this lamp is pressed afterwards.

It is guaranteed that if you push all n switches then all m lamps will be turned on.

Your think that you have too many switches and you would like to ignore one of them.

Your task is to say if there exists such a switch that if you will ignore (not use) it but press all the other n - 1 switches then all the m lamps will be turned on.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 2000) — the number of the switches and the number of the lamps.

The following n lines contain m characters each. The character ai, j is equal to '1' if the i-th switch turns on the j-th lamp and '0' otherwise.

It is guaranteed that if you press all n switches all m lamps will be turned on.

Output

Print "YES" if there is a switch that if you will ignore it and press all the other n - 1 switches then all m lamps will be turned on. Print "NO" if there is no such switch.

Examples

Input

4 5
10101
01000
00111
10000

Output

YES

Input

4 5
10100
01000
00110
00101

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 500 * 1000 + 100;
const long long mod = 1e9 + 7;
const long long inf = 2 * 1e18;
const int delta = 10691;
long long pw(long long a, long long b, long long c = mod) {
  if (b == 0) return 1;
  long long ans = pw(a, b / 2, c);
  ans = (ans * ans) % c;
  if (b & 1) ans = (ans * a) % c;
  return ans;
}
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  return (b == 0 ? a : gcd(a % b, b));
}
long long n, m;
char a[2001][2001];
int c[2001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i <= n; i++) c[j] += a[i][j] - '0';
  }
  for (int i = 1; i <= n; i++) {
    bool t = true;
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '1') {
        t &= (c[j] > 1);
      }
    }
    if (t) cout << "YES", exit(0);
  }
  cout << "NO";
  return 0;
}

```


### Prompt

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

You have array a1, a2, ..., an. Segment [l, r] (1 ≤ l ≤ r ≤ n) is good if ai = ai - 1 + ai - 2, for all i (l + 2 ≤ i ≤ r).

Let's define len([l, r]) = r - l + 1, len([l, r]) is the length of the segment [l, r]. Segment [l1, r1], is longer than segment [l2, r2], if len([l1, r1]) > len([l2, r2]).

Your task is to find a good segment of the maximum length in array a. Note that a segment of length 1 or 2 is always good.

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of elements in the array. The second line contains integers: a1, a2, ..., an (0 ≤ ai ≤ 109).

Output

Print the length of the longest good segment in array a.

Examples

Input

10
1 2 3 5 8 13 21 34 55 89

Output

10

Input

5
1 1 1 1 1

Output

2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[100005], i, j, m, n, ans = 0, pos = 1;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 3; i <= n;) {
    if (a[i] == a[i - 1] + a[i - 2]) {
      while (a[i] == a[i - 1] + a[i - 2] && i <= n) {
        i++;
      }
      ans = max(i - pos, ans);
      pos = i - 2;
    } else
      i++, pos = i - 2;
  }
  cout << max(ans, min(n, 2));
  return 0;
}

```


### Prompt

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

You are given an array a_1, a_2, ..., a_n of integer numbers.

Your task is to divide the array into the maximum number of segments in such a way that:

  * each element is contained in exactly one segment;
  * each segment contains at least one element;
  * there doesn't exist a non-empty subset of segments such that bitwise XOR of the numbers from them is equal to 0.

Print the maximum number of segments the array can be divided into. Print -1 if no suitable division exists.

Input

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

The second line contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^9).

Output

Print the maximum number of segments the array can be divided into while following the given constraints. Print -1 if no suitable division exists.

Examples

Input

4
5 5 7 2

Output

2

Input

3
1 2 3

Output

-1

Input

3
3 1 10

Output

3

Note

In the first example 2 is the maximum number. If you divide the array into \{[5], [5, 7, 2]\}, the XOR value of the subset of only the second segment is 5 ⊕ 7 ⊕ 2 = 0. \{[5, 5], [7, 2]\} has the value of the subset of only the first segment being 5 ⊕ 5 = 0. However, \{[5, 5, 7], [2]\} will lead to subsets \{[5, 5, 7]\} of XOR 7, \{[2]\} of XOR 2 and \{[5, 5, 7], [2]\} of XOR 5 ⊕ 5 ⊕ 7 ⊕ 2 = 5.

Let's take a look at some division on 3 segments — \{[5], [5, 7], [2]\}. It will produce subsets:

  * \{[5]\}, XOR 5;
  * \{[5, 7]\}, XOR 2;
  * \{[5], [5, 7]\}, XOR 7;
  * \{[2]\}, XOR 2;
  * \{[5], [2]\}, XOR 7;
  * \{[5, 7], [2]\}, XOR 0;
  * \{[5], [5, 7], [2]\}, XOR 5;

As you can see, subset \{[5, 7], [2]\} has its XOR equal to 0, which is unacceptable. You can check that for other divisions of size 3 or 4, non-empty subset with 0 XOR always exists.

The second example has no suitable divisions.

The third example array can be divided into \{[3], [1], [10]\}. No subset of these segments has its XOR equal to 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<int> basis;
void add(int x) {
  for (int& a : basis)
    if (a & -a & x) x ^= a;
  if (x == 0) return;
  for (int& a : basis)
    if (x & -x & a) a ^= x;
  basis.emplace_back(x);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int x = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    add(x ^= a);
  }
  if (x)
    cout << basis.size();
  else
    cout << "-1";
}

```


### Prompt

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

There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left.

The prophecy says that if the total number of surviving residents is even, then Daenerys wins: Stannis gets beheaded, and Daenerys rises on the Iron Throne. If the total number of surviving residents is odd, Stannis wins and everything goes in the completely opposite way.

Lord Petyr Baelish wants to know which candidates to the throne he should support, and therefore he wonders, which one of them has a winning strategy. Answer to this question of Lord Baelish and maybe you will become the next Lord of Harrenholl.

Input

The first line contains two positive space-separated integers, n and k (1 ≤ k ≤ n ≤ 2·105) — the initial number of cities in Westeros and the number of cities at which the game ends.

The second line contains n space-separated positive integers ai (1 ≤ ai ≤ 106), which represent the population of each city in Westeros.

Output

Print string "Daenerys" (without the quotes), if Daenerys wins and "Stannis" (without the quotes), if Stannis wins.

Examples

Input

3 1
1 2 1

Output

Stannis

Input

3 1
2 2 1

Output

Daenerys

Input

6 3
5 20 12 7 14 101

Output

Stannis

Note

In the first sample Stannis will use his move to burn a city with two people and Daenerys will be forced to burn a city with one resident. The only survivor city will have one resident left, that is, the total sum is odd, and thus Stannis wins.

In the second sample, if Stannis burns a city with two people, Daenerys burns the city with one resident, or vice versa. In any case, the last remaining city will be inhabited by two people, that is, the total sum is even, and hence Daenerys wins.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-8;
const int N = 2e5 + 7;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
int main() {
  int n, k, odd = 0, even = 0, x, m;
  scanf("%d%d", &n, &k);
  m = k;
  k = n - k;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    odd += (x % 2 != 0);
    even += (x % 2 == 0);
  }
  int first = k - k / 2, second = k / 2;
  if (k & 1) {
    if (second >= odd)
      cout << "Daenerys" << endl;
    else if (second >= even && m % 2 == 0)
      cout << "Daenerys" << endl;
    else
      cout << "Stannis" << endl;
  } else {
    if (k == 0 && odd % 2 == 1)
      cout << "Stannis" << endl;
    else if (first >= even && m % 2 != 0)
      cout << "Stannis" << endl;
    else
      cout << "Daenerys" << endl;
  }
}

```