### Prompt

Please create a solution in Cpp to the following problem:

The Smart Beaver from ABBYY started cooperating with the Ministry of Defence. Now they train soldiers to move armoured columns. The training involves testing a new type of tanks that can transmit information. To test the new type of tanks, the training has a special exercise, its essence is as follows.

Initially, the column consists of n tanks sequentially numbered from 1 to n in the order of position in the column from its beginning to its end. During the whole exercise, exactly n messages must be transferred from the beginning of the column to its end.

Transferring one message is as follows. The tank that goes first in the column transmits the message to some tank in the column. The tank which received the message sends it further down the column. The process is continued until the last tank receives the message. It is possible that not all tanks in the column will receive the message — it is important that the last tank in the column should receive the message.

After the last tank (tank number n) receives the message, it moves to the beginning of the column and sends another message to the end of the column in the same manner. When the message reaches the last tank (tank number n - 1), that tank moves to the beginning of the column and sends the next message to the end of the column, and so on. Thus, the exercise is completed when the tanks in the column return to their original order, that is, immediately after tank number 1 moves to the beginning of the column.

If the tanks were initially placed in the column in the order 1, 2, ..., n, then after the first message their order changes to n, 1, ..., n - 1, after the second message it changes to n - 1, n, 1, ..., n - 2, and so on.

The tanks are constructed in a very peculiar way. The tank with number i is characterized by one integer ai, which is called the message receiving radius of this tank.

Transferring a message between two tanks takes one second, however, not always one tank can transmit a message to another one. Let's consider two tanks in the column such that the first of them is the i-th in the column counting from the beginning, and the second one is the j-th in the column, and suppose the second tank has number x. Then the first tank can transmit a message to the second tank if i < j and i ≥ j - ax.

The Ministry of Defense (and soon the Smart Beaver) faced the question of how to organize the training efficiently. The exercise should be finished as quickly as possible. We'll neglect the time that the tanks spend on moving along the column, since improving the tanks' speed is not a priority for this training.

You are given the number of tanks, as well as the message receiving radii of all tanks. You must help the Smart Beaver and organize the transferring of messages in a way that makes the total transmission time of all messages as small as possible.

Input

The first line contains integer n — the number of tanks in the column. Each of the next n lines contains one integer ai (1 ≤ ai ≤ 250000, 1 ≤ i ≤ n) — the message receiving radii of the tanks in the order from tank 1 to tank n (let us remind you that initially the tanks are located in the column in ascending order of their numbers).

To get the full points for the first group of tests it is sufficient to solve the problem with 2 ≤ n ≤ 300.

To get the full points for the second group of tests it is sufficient to solve the problem with 2 ≤ n ≤ 10000.

To get the full points for the third group of tests it is sufficient to solve the problem with 2 ≤ n ≤ 250000.

Output

Print a single integer — the minimum possible total time of transmitting the messages.

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

Examples

Input

3
2
1
1

Output

5

Input

5
2
2
2
2
2

Output

10

Note

In the first sample the original order of tanks is 1, 2, 3. The first tank sends a message to the second one, then the second tank sends it to the third one — it takes two seconds. The third tank moves to the beginning of the column and the order of tanks now is 3, 1, 2. The third tank sends a message to the first one, then the first one sends it to the second one — it takes two more seconds. The second tank moves to the beginning and the order of the tanks is now 2, 3, 1. With this arrangement, the second tank can immediately send a message to the first one, since the message receiving radius of the first tank is large enough — it takes one second. Finally, the tanks return to their original order 1, 2, 3. In total, the exercise takes 5 seconds.

In the second sample, all five tanks are the same and sending a single message takes two seconds, so in total the exercise takes 10 seconds.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
pair<int, int> ST[500500][20];
long long Ans;
int Log2[500500], n, a[500500], F[500500][20], head[500500], cnt;
struct Edge {
  int to, next;
} edge[500500 << 1];
void AddEdge(int u, int v) { edge[++cnt] = (Edge){v, head[u]}, head[u] = cnt; }
void Dfs(int u, int fa, int dep) {
  F[u][0] = fa;
  for (int i = 1; 1 << i < dep; i++) F[u][i] = F[F[u][i - 1]][i - 1];
  for (int i = head[u]; i; i = edge[i].next) Dfs(edge[i].to, u, dep + 1);
}
pair<int, int> Min(int l, int r) {
  int len = r - l + 1, Log = Log2[len];
  return min(ST[l][Log], ST[r - (1 << Log) + 1][Log]);
}
int Calc(int u, int tar) {
  int ret = 0;
  if (a[u] <= tar) return 1;
  for (int i = 19; i >= 0; i--)
    if (a[F[u][i]] > tar) u = F[u][i], ret += 1 << i;
  return ret + 2;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i), a[i + n] = a[i];
  for (int i = 1; i <= 2 * n; i++) a[i] = max(i - a[i], 1);
  for (int i = 1; i <= 2 * n; i++) ST[i][0] = make_pair(a[i], i);
  for (int i = 1; i <= 19; i++)
    for (int j = 1; j <= 2 * n; j++)
      ST[j][i] = min(ST[j][i - 1], ST[j + (1 << (i - 1))][i - 1]);
  for (int i = 2; i <= n; i++) Log2[i] = Log2[i >> 1] + 1;
  for (int i = 2; i <= 2 * n; i++) AddEdge(Min(a[i], i - 1).second, i);
  Dfs(1, 0, 1);
  for (int i = 1; i <= n; i++) Ans += Calc(i + n - 1, i);
  printf("%I64d\n", Ans);
}

```


### Prompt

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

There are N strings arranged in a row. It is known that, for any two adjacent strings, the string to the left is lexicographically smaller than the string to the right. That is, S_1<S_2<...<S_N holds lexicographically, where S_i is the i-th string from the left.

At least how many different characters are contained in S_1,S_2,...,S_N, if the length of S_i is known to be A_i?

Constraints

* 1 \leq N \leq 2\times 10^5
* 1 \leq A_i \leq 10^9
* A_i is an integer.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the minimum possible number of different characters contained in the strings.

Examples

Input

3
3 2 1

Output

2

Input

5
2 3 2 1 2

Output

2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n,a[200005];
inline bool check(int x){
	if(x==1){
		bool flag=1;
		for(int i=1;i<n;i++)	if(a[i+1]<=a[i])	flag=0;
		return flag;
	}
	map<int,int> mp;
	int cur=0;
	for(register int i=1;i<=n;i++){
		if(a[i]<=cur){
			cur=a[i];
			while(1){
				if(mp[cur]<x-1)	break;
				mp[cur]=0;
				cur--;
			}
			mp[cur]++;
			if(cur<=0)	return 0;
		}
		else	cur=a[i];
		mp.erase(mp.upper_bound(cur),mp.end());
	}
	return 1;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i];
	int l=1,r=300000,ans;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid))	ans=mid,r=mid-1;
		else			l=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}
```


### Prompt

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

Little girl Susie went shopping with her mom and she wondered how to improve service quality.

There are n people in the queue. For each person we know time ti needed to serve him. A person will be disappointed if the time he waits is more than the time needed to serve him. The time a person waits is the total time when all the people who stand in the queue in front of him are served. Susie thought that if we swap some people in the queue, then we can decrease the number of people who are disappointed.

Help Susie find out what is the maximum number of not disappointed people can be achieved by swapping people in the queue.

Input

The first line contains integer n (1 ≤ n ≤ 105).

The next line contains n integers ti (1 ≤ ti ≤ 109), separated by spaces.

Output

Print a single number — the maximum number of not disappointed people in the queue.

Examples

Input

5
15 2 1 5 3

Output

4

Note

Value 4 is achieved at such an arrangement, for example: 1, 2, 3, 5, 15. Thus, you can make everything feel not disappointed except for the person with time 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, y = 0, z = 0, arr[(long long)1e5];
  cin >> x;
  for (int i = 0; i < x; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + x);
  for (int i = 0; i < x; i++) {
    if (arr[i] >= y) {
      y += arr[i];
      z++;
    }
  }
  cout << z << endl;
  return 0;
}

```


### Prompt

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

Given a simple graph, output the number of simple cycles in it. A simple cycle is a cycle with no repeated vertices or edges.

Input

The first line of input contains two integers n and m (1 ≤ n ≤ 19, 0 ≤ m) – respectively the number of vertices and edges of the graph. Each of the subsequent m lines contains two integers a and b, (1 ≤ a, b ≤ n, a ≠ b) indicating that vertices a and b are connected by an undirected edge. There is no more than one edge connecting any pair of vertices.

Output

Output the number of cycles in the given graph.

Examples

Input

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

Output

7

Note

The example graph is a clique and contains four cycles of length 3 and three cycles of length 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<long long> G[20];
long long ans;
bool f[20];
long long dp[(1 << 19) + 5][20];
signed main() {
  long long a, b;
  scanf("%lld", &(n));
  scanf("%lld", &(m));
  for (long long i = 1; i <= m; i++) {
    scanf("%lld", &(a));
    scanf("%lld", &(b));
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (long long i = 0; i < n; i++) {
    memset(dp, 0, sizeof dp);
    for (long long j = i; j < n; j++) {
      dp[1 << j][j] = 1;
    }
    for (long long k = 1; k <= (1 << n) - 1; k++) {
      for (long long w = i; w < n; w++) {
        if (dp[k][w])
          for (long long x = 0; x < G[w].size(); x++) {
            long long y = G[w][x];
            if (((k & -k) == 1 << i) && y == i && ((k >> i) & 1)) {
              ans += dp[k][w];
            } else if (((k >> y) & 1) == 0 && y > i)
              dp[k | (1 << y)][y] += dp[k][w];
          }
      }
    }
  }
  cout << (ans - m) / 2 << '\n';
}

```


### Prompt

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

Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1 + 2 = 3 cubes, the third level must have 1 + 2 + 3 = 6 cubes, and so on. Thus, the i-th level of the pyramid must have 1 + 2 + ... + (i - 1) + i cubes.

Vanya wants to know what is the maximum height of the pyramid that he can make using the given cubes.

Input

The first line contains integer n (1 ≤ n ≤ 104) — the number of cubes given to Vanya.

Output

Print the maximum possible height of the pyramid in the single line.

Examples

Input

1

Output

1

Input

25

Output

4

Note

Illustration to the second sample:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n2[100];
  n2[0] = 1;
  for (int i = 1; i < 100; i++) {
    n2[i] = n2[i - 1] + i + 1;
  }
  int n;
  while (cin >> n) {
    double count = 0.0;
    for (int i = 0; i < 100; i++) {
      count += n2[i];
      if (n < count) {
        cout << i << endl;
        break;
      }
    }
  }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya.

On the way from Denis's house to the girl's house is a road of n lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to place safety islands in some parts of the road. Each safety island is located after a line, as well as at the beginning and at the end of the road. Pedestrians can relax on them, gain strength and wait for a green light.

Denis came to the edge of the road exactly at the moment when the green light turned on. The boy knows that the traffic light first lights up g seconds green, and then r seconds red, then again g seconds green and so on.

Formally, the road can be represented as a segment [0, n]. Initially, Denis is at point 0. His task is to get to point n in the shortest possible time.

He knows many different integers d_1, d_2, …, d_m, where 0 ≤ d_i ≤ n — are the coordinates of points, in which the safety islands are located. Only at one of these points, the boy can be at a time when the red light is on.

Unfortunately, Denis isn't always able to control himself because of the excitement, so some restrictions are imposed:

  * He must always move while the green light is on because it's difficult to stand when so beautiful girl is waiting for you. Denis can change his position by ± 1 in 1 second. While doing so, he must always stay inside the segment [0, n].
  * He can change his direction only on the safety islands (because it is safe). This means that if in the previous second the boy changed his position by +1 and he walked on a safety island, then he can change his position by ± 1. Otherwise, he can change his position only by +1. Similarly, if in the previous second he changed his position by -1, on a safety island he can change position by ± 1, and at any other point by -1.
  * At the moment when the red light is on, the boy must be on one of the safety islands. He can continue moving in any direction when the green light is on.

Denis has crossed the road as soon as his coordinate becomes equal to n.

This task was not so simple, because it's possible that it is impossible to cross the road. Since Denis has all thoughts about his love, he couldn't solve this problem and asked us to help him. Find the minimal possible time for which he can cross the road according to these rules, or find that it is impossible to do.

Input

The first line contains two integers n and m (1 ≤ n ≤ 10^6, 2 ≤ m ≤ min(n + 1, 10^4)) — road width and the number of safety islands.

The second line contains m distinct integers d_1, d_2, …, d_m (0 ≤ d_i ≤ n) — the points where the safety islands are located. It is guaranteed that there are 0 and n among them.

The third line contains two integers g, r (1 ≤ g, r ≤ 1000) — the time that the green light stays on and the time that the red light stays on.

Output

Output a single integer — the minimum time for which Denis can cross the road with obeying all the rules.

If it is impossible to cross the road output -1.

Examples

Input

15 5
0 3 7 14 15
11 11

Output

45

Input

13 4
0 3 7 13
9 9

Output

-1

Note

In the first test, the optimal route is:

  * for the first green light, go to 7 and return to 3. In this case, we will change the direction of movement at the point 7, which is allowed, since there is a safety island at this point. In the end, we will be at the point of 3, where there is also a safety island. The next 11 seconds we have to wait for the red light.
  * for the second green light reaches 14. Wait for the red light again.
  * for 1 second go to 15. As a result, Denis is at the end of the road.

In total, 45 seconds are obtained.

In the second test, it is impossible to cross the road according to all the rules.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int n, m, d[10010], g, r, dist[10010], ans;
bool vis[10010][1010];
vector<int> v;
queue<int> q;
void dfs(int pos, int lft) {
  if (vis[pos][lft]) return;
  vis[pos][lft] = true;
  if (lft == 0) {
    v.push_back(pos);
    return;
  }
  if (pos - 1 >= 0 && lft - (d[pos] - d[pos - 1]) >= 0)
    dfs(pos - 1, lft - (d[pos] - d[pos - 1]));
  if (pos + 1 < m && lft - (d[pos + 1] - d[pos]) >= 0)
    dfs(pos + 1, lft - (d[pos + 1] - d[pos]));
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) scanf("%d", &d[i]);
  sort(d, d + m);
  cin >> g >> r;
  vis[0][0] = true;
  q.push(0);
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    v.clear();
    dfs(i, g);
    for (int j = 0; j < v.size(); j++) {
      dist[v[j]] = dist[i] + g + r;
      q.push(v[j]);
    }
  }
  ans = dist[m - 1] - r;
  for (int i = 0; i < m - 1; i++)
    if (d[m - 1] - d[i] <= g && (dist[i] > 0 || i == 0)) {
      if (ans < 0)
        ans = dist[i] + d[m - 1] - d[i];
      else
        ans = min(ans, dist[i] + d[m - 1] - d[i]);
    }
  if (ans < 0)
    puts("-1");
  else
    cout << ans << endl;
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

You are given n segments [l_1, r_1], [l_2, r_2], ..., [l_n, r_n]. Each segment has one of two colors: the i-th segment's color is t_i.

Let's call a pair of segments i and j bad if the following two conditions are met:

  * t_i ≠ t_j;
  * the segments [l_i, r_i] and [l_j, r_j] intersect, embed or touch, i. e. there exists an integer x such that x ∈ [l_i, r_i] and x ∈ [l_j, r_j].

Calculate the maximum number of segments that can be selected from the given ones, so that there is no bad pair among the selected ones.

Input

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

The next n lines contains three integers l_i, r_i, t_i (1 ≤ l_i ≤ r_i ≤ 10^9; t_i ∈ \{1, 2\}) — description of the i-th segment.

Output

Print the maximum number of segments that can be selected, so that there is no bad pair among the selected segments.

Examples

Input

3
1 3 1
4 6 2
2 5 1

Output

2

Input

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

Output

4

Input

7
19 20 1
13 15 2
6 11 2
4 10 1
14 17 1
13 13 2
5 9 1

Output

5

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using pi3 = pair<int, pii>;
const int NN = 502020;
int st[NN], ed[NN], t[NN];
set<pii> ss[4];
int main() {
  int n;
  cin >> n;
  vector<pi3> vec;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", st + i, ed + i, t + i);
    vec.push_back(pi3(st[i], pii(1, i)));
    vec.push_back(pi3(ed[i], pii(2, i)));
  }
  sort(vec.begin(), vec.end());
  int ans = 0;
  for (auto p : vec) {
    if (p.second.first == 2) {
      int i = p.second.second;
      int j = t[i];
      int k = 3 - j;
      if (ss[j].count(pii(ed[i], i)) && ss[k].size()) {
        ans++;
        ss[k].erase(ss[k].begin());
      }
      if (ss[j].count(pii(ed[i], i))) {
        ss[j].erase(ss[j].find(pii(ed[i], i)));
      }
    } else {
      ss[t[p.second.second]].insert(pii(ed[p.second.second], p.second.second));
    }
  }
  cout << n - ans << endl;
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.

Constraints

* The length of S is 2 or 3.
* S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If the length of S is 2, print S as is; if the length is 3, print S after reversing it.

Examples

Input

abc

Output

cba

Input

ac

Output

ac

### Response

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

using namespace std;

int main(){
	string S;
	cin >> S;

	if (S.length() == 3){
		reverse(S.begin(), S.end());
		cout << S << endl;
	}
	else{
		cout << S;
	}

}
```


### Prompt

Generate a CPP solution to the following problem:

There is data that records the customer number of the business partner and the trading date on a monthly basis. Please create a program that reads this month's data and last month's data and outputs the customer number of the company with which you have transactions and the number of transactions for two consecutive months from last month. However, the number of monthly business partners is 1,000 or less.

Input

This month's data and last month's data are given separated by one blank line. Each data is given in the following format.

c1, d1
c2, d2
...
...

ci (1 ≤ ci ≤ 1,000) is an integer representing the customer number, and di (1 ≤ di ≤ 31) is an integer representing the trading day.

Output

For companies that have transactions for two consecutive months, the customer number and the total number of transactions are output separated by a blank in ascending order of customer number.

Example

Input

123,10
56,12
34,14

123,3
56,4
123,5

Output

56 2
123 3

### Response

```cpp
#include <iostream>
#include <cstdio>
#include <map>
#include <string>

using namespace std;

int ID(string str){
	int num = 0;
	for(int i = 0; i < 500; i++){
		if(str[i] == ','){
			break;
		}
		num *= 10;
		num += (str[i] - '0');
	}
	return num;
}

// ??????????????§??????????????¢?´¢?????????????????????

int main(){

	map<int, int> m;
	map<int, int>::iterator ite;

	string str;
	int id;

	while(true){
		getline(cin, str);
		if(str.size() == 0){
			break;
		}
		id = ID(str);
		ite = m.find(id);
		if(ite != m.end()){
			ite -> second++;
		}else{
			m.insert(make_pair(id, 1));
		}
	}

	while(true){
		cin >> str;
		if(cin.eof()){
			break;
		}
		id = ID(str);
		ite = m.find(id);
		if(ite != m.end()){
			if(ite -> second < 10000){
				ite -> second += 10000;
			}
			ite -> second++;
		}
	}

	for(ite = m.begin(); ite != m.end(); ite++){
		if(ite -> second > 10000){
			cout << ite -> first << " " << ite -> second - 10000 << endl;
		}
	}

	return 0;
}
```


### Prompt

Please create a solution in cpp to the following problem:

Note that the only difference between the easy and hard version is the constraint on the number of queries. You can make hacks only if all versions of the problem are solved.

This is an interactive problem.

You are given a tree consisting of n nodes numbered with integers from 1 to n. Ayush and Ashish chose two secret distinct nodes in the tree. You need to find out both the nodes. You can make the following query:

  * Provide a list of nodes and you will receive a node from that list whose sum of distances to both the hidden nodes is minimal (if there are multiple such nodes in the list, you will receive any one of them). You will also get the sum of distances of that node to the hidden nodes.

Recall that a tree is a connected graph without cycles. The distance between two nodes is defined as the number of edges in the simple path between them.

More formally, let's define two hidden nodes as s and f. In one query you can provide the set of nodes \\{a_1, a_2, …, a_c\} of the tree. As a result, you will get two numbers a_i and dist(a_i, s) + dist(a_i, f). The node a_i is any node from the provided set, for which the number dist(a_i, s) + dist(a_i, f) is minimal.

You can ask no more than 14 queries.

Input

The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Please note, how the interaction process is organized.

The first line of each test case consists of a single integer n (2 ≤ n ≤ 1000) — the number of nodes in the tree.

The next n - 1 lines consist of two integers u, v (1 ≤ u, v ≤ n, u ≠ v) — the edges of the tree.

Interaction

To ask a query print a single line:

  * In the beginning print "? c " (without quotes) where c (1 ≤ c ≤ n) denotes the number of nodes being queried, followed by c distinct integers in the range [1, n] — the indices of nodes from the list.

For each query, you will receive two integers x, d — the node (among the queried nodes) with the minimum sum of distances to the hidden nodes and the sum of distances from that node to the hidden nodes. If the subset of nodes queried is invalid or you exceeded the number of queries then you will get x = d = -1. In this case, you should terminate the program immediately.

When you have guessed the hidden nodes, print a single line "! " (without quotes), followed by two integers in the range [1, n] — the hidden nodes. You can output the hidden nodes in any order.

After this, you should read a string. If you guess the nodes correctly, you will receive the string "Correct". In this case, you should continue solving the remaining test cases or terminate the program, if all test cases were solved. Otherwise, you will receive the string "Incorrect". In this case, you should terminate the program immediately.

Guessing the hidden nodes does not count towards the number of queries asked.

The interactor is not adaptive. The hidden nodes do not change with queries.

Do not forget to read the string "Correct" / "Incorrect" after guessing the hidden nodes.

You need to solve each test case before receiving the input for the next test case.

The limit of 14 queries applies to each test case and not to the entire input.

After printing a query do not forget to output the end of the line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

  * fflush(stdout) or cout.flush() in C++;
  * System.out.flush() in Java;
  * flush(output) in Pascal;
  * stdout.flush() in Python;
  * see the documentation for other languages.

Hacks

To hack the solution, use the following test format:

The first line should contain a single integer t (1 ≤ t ≤ 10) — the number of test cases. The description of the test cases follows.

The first line of each test case should contain a single integer n (2 ≤ n ≤ 1000) — the number of nodes in the tree. The second line should contain two distinct integers in the range [1, n] — the hidden nodes. The next n - 1 lines should contain two integers u, v (1 ≤ u, v ≤ n, u ≠ v) — the edges of the tree.

Example

Input

1
3
1 2
1 3

1 1

2 3

3 1

3 1

Correct

Output

? 1 1

? 1 2

? 1 3

? 2 2 3

! 1 3

Note

The tree from the first test is shown below, and the hidden nodes are 1 and 3.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int b[1005];
int ans[1005];
int n, k;
void valid(int x) {
  if (x == -1) exit(0);
}
int query2(vector<int> v) {
  cout << "? " << v.size() << " ";
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << endl;
  int maks;
  cin >> maks;
  valid(maks);
  return maks;
}
int query1(int l, int r) {
  int sz = r - l + 1;
  cout << "? " << sz << " ";
  for (int i = l; i <= r; i++) cout << i << " ";
  cout << endl;
  int maks;
  cin >> maks;
  valid(maks);
  return maks;
}
void odgovor() {
  cout << "! ";
  for (int i = 1; i <= k; i++) cout << ans[i] << " ";
  cout << endl;
  string odg;
  cin >> odg;
  if (odg == "Incorrect") exit(0);
}
int nadjibinarno(int l, int r, int x) {
  if (l == r) return l;
  int mid = (l + r) / 2;
  int y = query1(l, mid);
  if (y == x) return nadjibinarno(l, mid, x);
  return nadjibinarno(mid + 1, r, x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) b[i] = 0;
    for (int i = 1; i <= k; i++) {
      int c;
      cin >> c;
      for (int j = 1; j <= c; j++) {
        int x;
        cin >> x;
        b[x] = i;
      }
    }
    int l1 = 1;
    int r1 = n / 2;
    int l2 = r1 + 1;
    int r2 = n;
    int x = query1(l1, r1);
    int y = query1(l2, r2);
    int pos;
    if (x > y)
      pos = nadjibinarno(l1, r1, x);
    else
      pos = nadjibinarno(l2, r2, y);
    int bc = b[pos];
    if (bc == 0)
      for (int i = 1; i <= k; i++) ans[i] = max(x, y);
    else {
      for (int i = 1; i <= k; i++)
        if (i != bc) ans[i] = max(x, y);
      vector<int> v;
      for (int i = 1; i <= n; i++)
        if (b[i] != bc) v.push_back(i);
      ans[bc] = query2(v);
    }
    odgovor();
  }
  return 0;
}

```


### Prompt

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

You invited n guests to dinner! You plan to arrange one or more circles of chairs. Each chair is going to be either occupied by one guest, or be empty. You can make any number of circles.

Your guests happen to be a little bit shy, so the i-th guest wants to have a least l_i free chairs to the left of his chair, and at least r_i free chairs to the right. The "left" and "right" directions are chosen assuming all guests are going to be seated towards the center of the circle. Note that when a guest is the only one in his circle, the l_i chairs to his left and r_i chairs to his right may overlap.

What is smallest total number of chairs you have to use?

Input

First line contains one integer n — number of guests, (1 ⩽ n ⩽ 10^5).

Next n lines contain n pairs of space-separated integers l_i and r_i (0 ⩽ l_i, r_i ⩽ 10^9).

Output

Output a single integer — the smallest number of chairs you have to use.

Examples

Input

3
1 1
1 1
1 1

Output

6

Input

4
1 2
2 1
3 5
5 3

Output

15

Input

1
5 6

Output

7

Note

In the second sample the only optimal answer is to use two circles: a circle with 5 chairs accomodating guests 1 and 2, and another one with 10 chairs accomodationg guests 3 and 4.

In the third sample, you have only one circle with one person. The guest should have at least five free chairs to his left, and at least six free chairs to his right to the next person, which is in this case the guest herself. So, overall number of chairs should be at least 6+1=7.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v, v1;
  for (int i = 0; i < n; i++) {
    int t, y;
    cin >> t >> y;
    v.push_back(t);
    v1.push_back(y);
  }
  sort(v.begin(), v.end());
  sort(v1.begin(), v1.end());
  long long ans = n;
  for (int i = 0; i < n; i++) {
    ans += max(v[i], v1[i]);
  }
  cout << ans;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Xenia the horse breeder has n (n > 1) horses that stand in a row. Each horse has its own unique number. Initially, the i-th left horse has number i. That is, the sequence of numbers of horses in a row looks as follows (from left to right): 1, 2, 3, ..., n.

Xenia trains horses before the performance. During the practice sessions, she consistently gives them commands. Each command is a pair of numbers l, r (1 ≤ l < r ≤ n). The command l, r means that the horses that are on the l-th, (l + 1)-th, (l + 2)-th, ..., r-th places from the left must be rearranged. The horses that initially stand on the l-th and r-th places will swap. The horses on the (l + 1)-th and (r - 1)-th places will swap. The horses on the (l + 2)-th and (r - 2)-th places will swap and so on. In other words, the horses that were on the segment [l, r] change their order to the reverse one.

For example, if Xenia commanded l = 2, r = 5, and the sequence of numbers of horses before the command looked as (2, 1, 3, 4, 5, 6), then after the command the sequence will be (2, 5, 4, 3, 1, 6).

We know that during the practice Xenia gave at most three commands of the described form. You have got the final sequence of numbers of horses by the end of the practice. Find what commands Xenia gave during the practice. Note that you do not need to minimize the number of commands in the solution, find any valid sequence of at most three commands.

Input

The first line contains an integer n (2 ≤ n ≤ 1000) — the number of horses in the row. The second line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ n), where ai is the number of the i-th left horse in the row after the practice.

Output

The first line should contain integer k (0 ≤ k ≤ 3) — the number of commads Xenia gave during the practice. In each of the next k lines print two integers. In the i-th line print numbers li, ri (1 ≤ li < ri ≤ n) — Xenia's i-th command during the practice.

It is guaranteed that a solution exists. If there are several solutions, you are allowed to print any of them.

Examples

Input

5
1 4 3 2 5

Output

1
2 4

Input

6
2 1 4 3 6 5

Output

3
1 2
3 4
5 6

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
const int INF = 1e9 + 7;
int n, a[N];
pair<int, int> ans[3];
bool check() {
  for (int i = (1); i < (n + 1); ++i)
    if (a[i] != i) return false;
  return true;
}
bool f(int i) {
  return (a[i] != i) && (abs(a[i] - a[i - 1]) > 1 || abs(a[i + 1] - a[i]) > 1);
}
bool dfs(int dep) {
  if (check()) {
    printf("%d\n", dep);
    for (int i = (0); i < (dep); ++i)
      printf("%d %d\n", ans[dep - 1 - i].first, ans[dep - 1 - i].second);
    return true;
  }
  if (dep >= 3) return false;
  for (int l = (1); l < (n + 1); ++l) {
    if (!f(l)) continue;
    for (int r = (l + 1); r < (n + 1); ++r) {
      if (!f(r)) continue;
      reverse(a + l, a + r + 1);
      ans[dep] = make_pair(l, r);
      if (dfs(dep + 1)) return true;
      reverse(a + l, a + r + 1);
    }
  }
  return false;
}
int main() {
  scanf("%d", &n);
  a[0] = a[n + 1] = INF;
  for (int i = (1); i < (n + 1); ++i) scanf("%d", &a[i]);
  dfs(0);
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Dima got into number sequences. Now he's got sequence a1, a2, ..., an, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence:

  * f(0) = 0;
  * f(2·x) = f(x);
  * f(2·x + 1) = f(x) + 1.

Dima wonders, how many pairs of indexes (i, j) (1 ≤ i < j ≤ n) are there, such that f(ai) = f(aj). Help him, count the number of such pairs.

Input

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

The numbers in the lines are separated by single spaces.

Output

In a single line print the answer to the problem.

Please, don't use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

3
1 2 4

Output

3

Input

3
5 3 1

Output

1

Note

In the first sample any pair (i, j) will do, so the answer is 3.

In the second sample only pair (1, 2) will do.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, m[33], x, ans, answer;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    ans = 0;
    cin >> x;
    while (x >= 1) {
      if (x % 2 == 1) {
        ans++;
      }
      x /= 2;
    }
    m[ans]++;
  }
  for (int i = 1; i <= 31; i++) {
    answer += (m[i] - 1) * (m[i]) / 2;
  }
  cout << answer << endl;
  return 0;
}

```


### Prompt

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

This problem was deleted from the contest, because it was used previously at another competition.

Input

Output

Examples

Input

1 1
1 2 100

Output

6

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100050, maxp = 1000, maxps = 200;
int pr[maxps], whe[maxn] = {0}, ps = 0;
long long n, m, L, R, p, ans = 0;
int fa[maxps], fs = 0;
int Sqrt(long long x) {
  if (x < 0)
    return 0;
  else if (x > m * m)
    return m;
  return sqrt(x);
}
void init() {
  int i, j;
  for (i = 2; i < maxp; i++) {
    if (!whe[i]) pr[ps++] = i;
    for (j = 0; j < ps && i * pr[j] < maxn; j++) {
      whe[i * pr[j]] = 1;
      if (!(i % pr[j])) break;
    }
  }
}
int dfs(int k, bool u, int cur, int now) {
  int i;
  long long s = 0;
  if (cur == fs) {
    long long t = k / now;
    s = (t * (m + 1) - t * (t + 1) / 2 * now);
    return (-2 * u + 1) * s % p;
  }
  s = dfs(k, u, cur + 1, now);
  s += dfs(k, !u, cur + 1, now * fa[cur]);
  return s % p;
}
int calc(int x, int k) {
  int i, x0 = x;
  if (!k) return 0;
  fs = 0;
  memset(fa, 0, sizeof(fa));
  for (i = 0; i < ps; i++)
    if (!(x0 % pr[i])) {
      while (!(x0 % pr[i])) x0 /= pr[i];
      fa[fs++] = pr[i];
    }
  if (x0 > 1) fa[fs++] = x0;
  return dfs(k, 0, 0, 1);
}
int main() {
  long long x;
  init();
  scanf("%I64d%I64d%I64d%I64d%I64d", &n, &m, &L, &R, &p);
  for (x = 1; x <= min(n, R - 1); x++) {
    int l = Sqrt(L * L - x * x - 1), r = Sqrt(R * R - x * x);
    ans += (n - x + 1) * (calc(x, r) - calc(x, l)) % p;
    ans %= p;
  }
  ans *= 2;
  if (L == 1) ans += n * (m + 1) + m * (n + 1);
  ans %= p;
  if (ans < 0) ans += p;
  printf("%I64d\n", ans);
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

The Smart Beaver from ABBYY has a lot of hobbies. One of them is constructing efficient hash tables. One of the most serious problems in hash tables is resolving collisions. The Beaver is interested in this problem very much and he decided to explore it in detail.

We assume that the hash table consists of h cells numbered from 0 to h - 1. Objects are added to and removed from it. Every object has its own unique identifier. In addition, every object has a corresponding hash value — an integer between 0 and h - 1, inclusive. When an object is added to the table, if the cell corresponding to the hash value of the object is free, then this object goes there. If the cell is already occupied by another object, there is a collision. When an object is deleted from the table, the cell which it occupied becomes empty.

The Smart Beaver has recently learned about the method of linear probing to resolve collisions. It is as follows. Let's say that the hash value for the added object equals t and cell t of the table is already occupied. Then we try to add this object to cell (t + m) mod h. If it is also occupied, then we try cell (t + 2·m) mod h, then cell (t + 3·m) mod h, and so on. Note that in some cases it's possible that the new object can not be added to the table. It is guaranteed that the input for this problem doesn't contain such situations.

The operation a mod b means that we take the remainder of the division of number a by number b.

This technique immediately seemed very inoptimal to the Beaver, and he decided to assess its inefficiency. So, you are given a sequence of operations, each of which is either an addition of an object to the table or a deletion of an object from the table. When adding a new object, a sequence of calls to the table is performed. Calls to occupied cells are called dummy. In other words, if the result of the algorithm described above is the object being added to cell (t + i·m) mod h (i ≥ 0), then exactly i dummy calls have been performed.

Your task is to calculate the total number of dummy calls to the table for the given sequence of additions and deletions. When an object is deleted from the table, assume that no dummy calls are performed. The table is empty before performing the operations, that is, initially it doesn't contain any objects.

Input

The first line of input contains three integers h, m and n (1 ≤ m < h), separated by spaces, where h is the size of the hash table, m is the number that is used to resolve collisions, n is the number of operations.

The following n lines contains the descriptions of the operations. Their execution order corresponds to the order in which they appear in the input file. Each operation is described by a single line. The operations are described as follows:

  * "+ id hash"

This is the format of the operation that adds an object to the table. The first character is "+" (ASCII 43), followed by a single space, then the object identifier id (0 ≤ id ≤ 109), then another space, and the hash value of the given object hash (0 ≤ hash < h). The object identifier and the hash value of this object are integers.

  * "- id"

This is the format of the operation that deletes an object from the table. The first character is "-" (ASCII 45), followed by a single space, then the object identifier id (0 ≤ id ≤ 109). The object identifier is an integer.

It is guaranteed that for all addition operations the value of id is unique. It is also guaranteed that the initial data is correct, that is, it's always possible to add an object to the hash table and there won't be any deletions of nonexisting objects.

The input limitations for getting 20 points are:

  * 1 ≤ h ≤ 5000
  * 1 ≤ n ≤ 5000

The input limitations for getting 50 points are:

  * 1 ≤ h ≤ 5·104
  * 1 ≤ n ≤ 5·104

The input limitations for getting 100 points are:

  * 1 ≤ h ≤ 2·105
  * 1 ≤ n ≤ 2·105

Output

Print a single number — the total number of dummy calls to the hash table.

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

Examples

Input

10 2 7
+ 11 0
+ 22 2
+ 33 6
+ 44 0
+ 55 0
- 22
+ 66 0

Output

7

Input

5 1 6
+ 123 0
+ 234 1
+ 345 2
- 234
+ 456 0
+ 567 0

Output

4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[200000], b[200000][2], f[200000][2];
int bit[1 << 18];
vector<vector<int> > v;
map<int, int> mp;
int sum(int i) {
  int s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}
void add(int i, int x) {
  while (i < (1 << 18)) {
    bit[i] += x;
    i += i & -i;
  }
}
int insert(int x, int y) {
  int p, q, l, r, m;
  p = b[f[y][0]][0] + f[y][1];
  q = b[f[y][0]][1];
  if (sum(q + 1) - sum(p) < q - p + 1) {
    l = p;
    r = q;
    m = (l + r) / 2;
    while (r - l > 1) {
      if (sum(m + 1) - sum(p) < m - p + 1) {
        r = m;
        m = (l + r) / 2;
      } else {
        l = m;
        m = (l + r) / 2;
      }
    }
    if (a[v[f[y][0]][l - b[f[y][0]][0]]] == 0) {
      a[v[f[y][0]][l - b[f[y][0]][0]]] = 1;
      mp[x] = v[f[y][0]][l - b[f[y][0]][0]];
      add(l + 1, 1);
      return l - p;
    } else {
      a[v[f[y][0]][r - b[f[y][0]][0]]] = 1;
      mp[x] = v[f[y][0]][r - b[f[y][0]][0]];
      add(r + 1, 1);
      return r - p;
    }
  } else {
    p = b[f[y][0]][0];
    l = p;
    r = l + f[y][1] - 1;
    m = (l + r) / 2;
    while (r - l > 1) {
      if (sum(m + 1) - sum(p) < m - p + 1) {
        r = m;
        m = (l + r) / 2;
      } else {
        l = m;
        m = (l + r) / 2;
      }
    }
    if (a[v[f[y][0]][l - p]] == 0) {
      a[v[f[y][0]][l - p]] = 1;
      mp[x] = v[f[y][0]][l - p];
      add(l + 1, 1);
      return q - b[f[y][0]][0] - f[y][1] + l - p + 1;
    } else {
      a[v[f[y][0]][r - p]] = 1;
      mp[x] = v[f[y][0]][r - p];
      add(r + 1, 1);
      return q - b[f[y][0]][0] - f[y][1] + r - p + 1;
    }
  }
}
int main() {
  int h, m, n, p = 0, i, j;
  long long ans = 0;
  scanf("%d %d %d", &h, &m, &n);
  for (i = 0; i < h; i++) f[i][0] = -1;
  for (i = 0; i < h; i++) {
    if (f[i][0] == -1) {
      int c = 0;
      vector<int> w;
      b[v.size()][0] = p;
      for (j = i;; j = (j + m) % h, c++, p++) {
        if (f[j][0] >= 0) break;
        f[j][0] = v.size();
        f[j][1] = c;
        w.push_back(j);
      }
      b[v.size()][1] = p - 1;
      v.push_back(w);
    }
  }
  for (i = 0; i < n; i++) {
    int x, y;
    char s[2];
    scanf("%s %d", s, &x);
    if (s[0] == '+') {
      scanf("%d", &y);
      ans += insert(x, y);
    } else {
      y = mp[x];
      a[y] = 0;
      mp.erase(x);
      add(b[f[y][0]][0] + f[y][1] + 1, -1);
    }
  }
  printf("%I64d\n", ans);
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Once upon a time in a kingdom far, far away… Okay, let’s start at the point where Ivan the Fool met Gorynych the Dragon. Ivan took out his magic sword and the battle began. First Gorynych had h heads and t tails. With each strike of the sword Ivan can either cut off several heads (from 1 to n, but not more than Gorynych has at the moment), or several tails (from 1 to m, but not more than Gorynych has at the moment). At the same time, horrible though it seems, Gorynych the Dragon can also grow new heads and tails. And the number of growing heads and tails is determined uniquely by the number of heads or tails cut by the current strike. When the total number of heads and tails exceeds R, Gorynych the Dragon strikes its final blow and destroys Ivan the Fool. That’s why Ivan aims to cut off all the dragon’s heads and tails as quickly as possible and win. The events can also develop in a third way: neither of the opponents can win over the other one and they will continue fighting forever.

The tale goes like this; easy to say, hard to do. Your task is to write a program that will determine the battle’s outcome. Consider that Ivan strikes consecutively. After each blow Gorynych grows a number of new heads and tails depending on the number of cut ones. Gorynych the Dragon is defeated if after the blow he loses all his heads and tails and can’t grow new ones. Ivan fights in the optimal way (fools are lucky), i.e.

  * if Ivan can win, he wins having struck the least number of blows;
  * if it is impossible to defeat Gorynych, but is possible to resist him for an infinitely long period of time, then that’s the strategy Ivan chooses;
  * if Gorynych wins in any case, Ivan aims to resist him for as long as possible.

Input

The first line contains three integers h, t and R (0 ≤ h, t, R ≤ 200, 0 < h + t ≤ R) which represent the initial numbers of Gorynych’s heads and tails and the largest total number of heads and tails with which Gorynych the Dragon does not yet attack. The next line contains integer n (1 ≤ n ≤ 200). The next n contain pairs of non-negative numbers "hi ti" which represent the number of heads and the number of tails correspondingly, that will grow if Gorynych has i heads (1 ≤ i ≤ n) cut. The next line contains an integer m (1 ≤ m ≤ 200) and then — the description of Gorynych’s behavior when his tails are cut off in the format identical to the one described above. All the numbers in the input file do not exceed 200.

Output

Print "Ivan" (without quotes) in the first line if Ivan wins, or "Zmey" (that means a dragon in Russian) if Gorynych the Dragon wins. In the second line print a single integer which represents the number of blows Ivan makes. If the battle will continue forever, print in the first line "Draw".

Examples

Input

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

Output

Ivan
2

Input

2 2 4
1
0 1
1
1 0

Output

Draw

Input

2 2 5
1
1 1
1
3 0

Output

Zmey
2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 200 + 7;
int sh, st, lim;
int n, m;
int addh[N][2], addt[N][2];
vector<pair<pair<int, int>, pair<int, int> > > ad, rad;
int dis[N][N];
bool ok(int x, int y) { return (x >= 0 && y >= 0 && x + y <= lim); }
void bfs() {
  queue<pair<int, int> > q;
  q.push({sh, st});
  dis[sh][st] = 1;
  while (q.size()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    if (x == 0 && y == 0) {
      cout << "Ivan" << endl << dis[0][0] - 1;
      exit(0);
    }
    for (auto p : ad) {
      int nx = x + p.first.first;
      int ny = y + p.first.second;
      int lx = p.second.first;
      int ly = p.second.second;
      if (x >= lx && y >= ly && ok(nx, ny) && !dis[nx][ny]) {
        q.push({nx, ny});
        dis[nx][ny] = dis[x][y] + 1;
      }
    }
  }
}
bool mrk[N][N];
int in[N][N];
vector<pair<int, int> > com;
void dfs(int x, int y) {
  mrk[x][y] = 1;
  com.push_back({x, y});
  for (auto p : ad) {
    int nx = x + p.first.first;
    int ny = y + p.first.second;
    int lx = p.second.first;
    int ly = p.second.second;
    if (x < lx || y < ly || !ok(nx, ny)) continue;
    if (!mrk[nx][ny]) {
      dfs(nx, ny);
    }
  }
}
int go[N][N];
int dp[N][N];
int main() {
  cin >> sh >> st >> lim;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> addh[i][0] >> addh[i][1];
    ad.push_back({{addh[i][0] - i, addh[i][1]}, {i, 0}});
    rad.push_back({{-addh[i][0] + i, -addh[i][1]}, {addh[i][0], 0}});
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> addt[i][0] >> addt[i][1];
    ad.push_back({{addt[i][0], addt[i][1] - i}, {0, i}});
    rad.push_back({{-addt[i][0], i - addt[i][1]}, {0, addt[i][1]}});
  }
  bfs();
  dfs(sh, st);
  for (auto p : com) {
    int x = p.first;
    int y = p.second;
    for (auto pp : ad) {
      int nx = x + pp.first.first;
      int ny = y + pp.first.second;
      int lx = pp.second.first;
      int ly = pp.second.second;
      if (x >= lx && y >= ly && ok(nx, ny)) {
        in[nx][ny]++;
        go[x][y]++;
      }
    }
  }
  queue<pair<int, int> > q;
  for (auto p : com) {
    if (!in[p.first][p.second]) q.push({p.first, p.second});
  }
  int cnt = 0;
  while (q.size()) {
    int x = q.front().first;
    int y = q.front().second;
    cnt++;
    q.pop();
    for (auto p : ad) {
      int nx = x + p.first.first;
      int ny = y + p.first.second;
      int lx = p.second.first;
      int ly = p.second.second;
      if (x >= lx && y >= ly && ok(nx, ny)) {
        in[nx][ny]--;
        if (!in[nx][ny]) q.push({nx, ny});
      }
    }
  }
  if (cnt < com.size()) {
    cout << "Draw";
    return 0;
  }
  for (auto p : com) {
    if (!go[p.first][p.second]) {
      q.push({p.first, p.second});
      dp[p.first][p.second] = 1;
    }
  }
  while (q.size()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    for (auto p : rad) {
      int nx = x + p.first.first;
      int ny = y + p.first.second;
      int lx = p.second.first;
      int ly = p.second.second;
      if (x >= lx && y >= ly && ok(nx, ny)) {
        go[nx][ny]--;
        dp[nx][ny] = max(dp[nx][ny], dp[x][y] + 1);
        if (!go[nx][ny]) q.push({nx, ny});
      }
    }
  }
  cout << "Zmey" << endl;
  cout << dp[sh][st];
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi.

How many ways are there to choose K consecutive integers?

Constraints

* All values in input are integers.
* 1 \leq K \leq N \leq 50

Input

Input is given from Standard Input in the following format:

N K

Output

Print the answer.

Examples

Input

3 2

Output

2

Input

13 3

Output

11

### Response

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

int main(){
  int a,b;
  cin>>a>>b;
  cout<<a-b+1<<endl;
  return 0;

}
```


### Prompt

Create a solution in CPP for the following problem:

There are n segments on a Ox axis [l_1, r_1], [l_2, r_2], ..., [l_n, r_n]. Segment [l, r] covers all points from l to r inclusive, so all x such that l ≤ x ≤ r.

Segments can be placed arbitrarily — be inside each other, coincide and so on. Segments can degenerate into points, that is l_i=r_i is possible.

Union of the set of segments is such a set of segments which covers exactly the same set of points as the original set. For example:

  * if n=3 and there are segments [3, 6], [100, 100], [5, 8] then their union is 2 segments: [3, 8] and [100, 100];
  * if n=5 and there are segments [1, 2], [2, 3], [4, 5], [4, 6], [6, 6] then their union is 2 segments: [1, 3] and [4, 6].

Obviously, a union is a set of pairwise non-intersecting segments.

You are asked to erase exactly one segment of the given n so that the number of segments in the union of the rest n-1 segments is maximum possible.

For example, if n=4 and there are segments [1, 4], [2, 3], [3, 6], [5, 7], then:

  * erasing the first segment will lead to [2, 3], [3, 6], [5, 7] remaining, which have 1 segment in their union;
  * erasing the second segment will lead to [1, 4], [3, 6], [5, 7] remaining, which have 1 segment in their union;
  * erasing the third segment will lead to [1, 4], [2, 3], [5, 7] remaining, which have 2 segments in their union;
  * erasing the fourth segment will lead to [1, 4], [2, 3], [3, 6] remaining, which have 1 segment in their union.

Thus, you are required to erase the third segment to get answer 2.

Write a program that will find the maximum number of segments in the union of n-1 segments if you erase any of the given n segments.

Note that if there are multiple equal segments in the given set, then you can erase only one of them anyway. So the set after erasing will have exactly n-1 segments.

Input

The first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases in the test. Then the descriptions of t test cases follow.

The first of each test case contains a single integer n (2 ≤ n ≤ 2⋅10^5) — the number of segments in the given set. Then n lines follow, each contains a description of a segment — a pair of integers l_i, r_i (-10^9 ≤ l_i ≤ r_i ≤ 10^9), where l_i and r_i are the coordinates of the left and right borders of the i-th segment, respectively.

The segments are given in an arbitrary order.

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

Output

Print t integers — the answers to the t given test cases in the order of input. The answer is the maximum number of segments in the union of n-1 segments if you erase any of the given n segments.

Example

Input

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

Output

2
1
5

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
int main() {
  int t;
  cin >> t;
  vector<int> ans(t);
  vector<int> a;
  for (int i = 0; i < (int)t; i++) {
    int n;
    cin >> n;
    a.clear();
    int l[n], r[n];
    set<int> s;
    for (int j = 0; j < (int)n; j++) {
      cin >> l[j] >> r[j];
      if (s.find(l[j]) == s.end()) a.push_back(l[j]);
      s.insert(l[j]);
      if (s.find(r[j]) == s.end()) a.push_back(r[j]);
      s.insert(r[j]);
    }
    sort(a.begin(), a.end());
    int v = s.size();
    map<int, int> m;
    for (int j = 0; j < (int)v; j++) m[a[j]] = j * 2 + 1;
    vector<int> seg(2 * v + 1, 0);
    vector<int> one(2 * v + 1, 0);
    for (int j = 0; j < (int)n; j++) {
      seg[m[l[j]]]++;
      seg[m[r[j]] + 1]--;
    }
    for (int j = 1; j <= 2 * v; j++) seg[j] += seg[j - 1];
    int p = 1;
    for (int j = 1; j < 2 * v; j++) {
      if (seg[j] == 0) p++;
    }
    for (int j = 1; j <= 2 * v; j++) {
      one[j] += one[j - 1];
      if (j % 2 == 0 && seg[j] == 1) one[j]++;
    }
    int b = -INF;
    for (int j = 0; j < (int)n; j++) {
      int dif = one[m[r[j]]] - one[m[l[j]]];
      if (seg[m[r[j]] + 1] == 0 && seg[m[r[j]]] == 1 && seg[m[r[j]] - 1] == 1)
        dif--;
      if (seg[m[l[j]] - 1] == 0 && seg[m[l[j]]] == 1 && seg[m[l[j]] + 1] == 1)
        dif--;
      if (r[j] == l[j] && seg[m[r[j]]] == 1 && seg[m[r[j]] + 1] == 0 &&
          seg[m[l[j]] - 1] == 0)
        dif--;
      b = max(b, dif);
    }
    ans[i] = p + b;
  }
  for (auto k : ans) cout << k << endl;
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place?

<image>

One day, when he came to his friend Evan, Om Nom didn't find him at home but he found two bags with candies. The first was full of blue candies and the second bag was full of red candies. Om Nom knows that each red candy weighs Wr grams and each blue candy weighs Wb grams. Eating a single red candy gives Om Nom Hr joy units and eating a single blue candy gives Om Nom Hb joy units.

Candies are the most important thing in the world, but on the other hand overeating is not good. Om Nom knows if he eats more than C grams of candies, he will get sick. Om Nom thinks that it isn't proper to leave candy leftovers, so he can only eat a whole candy. Om Nom is a great mathematician and he quickly determined how many candies of what type he should eat in order to get the maximum number of joy units. Can you repeat his achievement? You can assume that each bag contains more candies that Om Nom can eat.

Input

The single line contains five integers C, Hr, Hb, Wr, Wb (1 ≤ C, Hr, Hb, Wr, Wb ≤ 109).

Output

Print a single integer — the maximum number of joy units that Om Nom can get.

Examples

Input

10 3 5 2 3

Output

16

Note

In the sample test Om Nom can eat two candies of each type and thus get 16 joy units.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
map<long long int, long long int> dp;
int k = 0;
long long int func(long long int c, long long int a1, long long int a2,
                   long long int b1, long long int b2) {
  long long int ans = 0, j;
  for (int i = 0; b1 * i <= c && i < 100000; i++) {
    j = (c - (b1 * i)) / b2;
    ans = max(ans, a1 * i + a2 * j);
  }
  for (int i = 0; b2 * i <= c && i < 100000; i++) {
    j = (c - (b2 * i)) / b1;
    ans = max(ans, a2 * i + a1 * j);
  }
  return ans;
}
int main() {
  long long int c, a1, a2, b1, b2;
  cin >> c >> a1 >> a2 >> b1 >> b2;
  cout << func(c, a1, a2, b1, b2);
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though.

Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious.

Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it.

Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.

Constraints

* 1 ≤ X,A,B ≤ 10^9

Input

Input is given from Standard Input in the following format:

X A B

Output

Print `delicious` if Takahashi found the food delicious; print `safe` if he neither found it delicious nor got a stomachache; print `dangerous` if he got a stomachache.

Examples

Input

4 3 6

Output

safe

Input

6 5 1

Output

delicious

Input

3 7 12

Output

dangerous

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,x;cin>>x>>a>>b;
  string s;
  if(a>=b) s="delicious";
  if(b>a && b<=x+a) s="safe";
  if(b>x+a) s="dangerous";
  cout<<s<<endl;
}
```


### Prompt

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

We have a set S of N points in a two-dimensional plane. The coordinates of the i-th point are (x_i, y_i). The N points have distinct x-coordinates and distinct y-coordinates.

For a non-empty subset T of S, let f(T) be the number of points contained in the smallest rectangle, whose sides are parallel to the coordinate axes, that contains all the points in T. More formally, we define f(T) as follows:

* f(T) :=  (the number of integers i (1 \leq i \leq N) such that a \leq x_i \leq b and c \leq y_i \leq d, where a, b, c, and d are the minimum x-coordinate, the maximum x-coordinate, the minimum y-coordinate, and the maximum y-coordinate of the points in T)

Find the sum of f(T) over all non-empty subset T of S. Since it can be enormous, print the sum modulo 998244353.

Constraints

* 1 \leq N \leq 2 \times 10^5
* -10^9 \leq x_i, y_i \leq 10^9
* x_i \neq x_j (i \neq j)
* y_i \neq y_j (i \neq j)
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
:
x_N y_N

Output

Print the sum of f(T) over all non-empty subset T of S, modulo 998244353.

Examples

Input

3
-1 3
2 1
3 -2

Output

13

Input

4
1 4
2 1
3 3
4 2

Output

34

Input

10
19 -11
-3 -12
5 3
3 -15
8 -14
-9 -20
10 -9
0 2
-7 17
6 -6

Output

7222

### Response

```cpp
// F - Enclosed Points
#include <bits/stdc++.h>

using namespace std;

#define	MOD	998244353

long long mpow(long long x, long long n)
{
	long long r = 1;
	for ( ; n > 0; x = x * x % MOD, n >>= 1) if (n & 1) r = r * x % MOD;
	return r;
}

void fen_update(vector<int> &tree, int i, int val)
{
	for ( ; i > 0 && i < tree.size(); i += i & -i) tree[i] += val;
}

int fen_get(vector<int> &tree, int i)
{
	int sum = 0;
	for ( ; i > 0; i &= i - 1) sum += tree[i];
	return sum;
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	long long n;
	cin >> n;
	vector<int> b;
	vector<pair<int, int> > a(n);
	for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second, b.push_back(a[i].second);
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	map<int, int> m;
	for (int i = 0; i < b.size(); i++) m[b[i]] = i;

	vector<long long> tp(n + 1, 1);
	for (int i = 1; i <= n; i++) tp[i] = tp[i - 1] * 2 % MOD;

	long long ans = n * tp[n - 1] % MOD;

	vector<int> l(n + 1), r(n + 1);
	for (int i = 0; i < n; i++)  fen_update(r, i + 1, 1);

	for (int i = 0; i < n; i++) {
		int y = m[a[i].second];
		fen_update(r, y + 1, -1);
		long long l1 = fen_get(l, y), l2 = i - l1;
		long long r1 = fen_get(r, y), r2 = n - 1 - i - r1;
		long long t1 = (tp[l1] - 1 + MOD) % MOD * (tp[r2] - 1 + MOD) % MOD * tp[l2 + r1] % MOD;
		long long t2 = (tp[l2] - 1 + MOD) % MOD * (tp[r1] - 1 + MOD) % MOD * tp[l1 + r2] % MOD;
		long long d = (tp[l1] - 1 + MOD) % MOD * (tp[r2] - 1 + MOD) % MOD * (tp[l2] - 1 + MOD) % MOD * (tp[r1] - 1 + MOD) % MOD;
		ans = (ans + t1 + t2 -d + MOD) % MOD;
		fen_update(l, y + 1, 1);
	}

	cout << ans << endl;

	return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

The start of the new academic year brought about the problem of accommodation students into dormitories. One of such dormitories has a a × b square meter wonder room. The caretaker wants to accommodate exactly n students there. But the law says that there must be at least 6 square meters per student in a room (that is, the room for n students must have the area of at least 6n square meters). The caretaker can enlarge any (possibly both) side of the room by an arbitrary positive integer of meters. Help him change the room so as all n students could live in it and the total area of the room was as small as possible.

Input

The first line contains three space-separated integers n, a and b (1 ≤ n, a, b ≤ 109) — the number of students and the sizes of the room.

Output

Print three integers s, a1 and b1 (a ≤ a1; b ≤ b1) — the final area of the room and its sizes. If there are multiple optimal solutions, print any of them.

Examples

Input

3 3 5

Output

18
3 6

Input

2 4 4

Output

16
4 4

### Response

```cpp
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
long long n, a, b;
long long mi = ((1ll << 62) - 1);
long long mi1, mi2;
int main() {
  long long i, j, k;
  scanf("%I64d%I64d%I64d", &n, &a, &b);
  for (i = a; i <= a + 10000000; i++) {
    long long b1 = max((6 * n + i - 1) / i, b);
    if (b1 * i < mi) {
      mi = b1 * i;
      mi1 = i, mi2 = b1;
    }
  }
  for (i = b; i <= b + 10000000; i++) {
    long long a1 = max((6 * n + i - 1) / i, a);
    if (a1 * i < mi) {
      mi = a1 * i;
      mi1 = a1, mi2 = i;
    }
  }
  printf("%I64d\n%I64d %I64d", mi, mi1, mi2);
  return 0;
}

```


### Prompt

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

Note that the only difference between the easy and hard version is the constraint on the number of queries. You can make hacks only if all versions of the problem are solved.

This is an interactive problem.

You are given a tree consisting of n nodes numbered with integers from 1 to n. Ayush and Ashish chose two secret distinct nodes in the tree. You need to find out both the nodes. You can make the following query:

  * Provide a list of nodes and you will receive a node from that list whose sum of distances to both the hidden nodes is minimal (if there are multiple such nodes in the list, you will receive any one of them). You will also get the sum of distances of that node to the hidden nodes.

Recall that a tree is a connected graph without cycles. The distance between two nodes is defined as the number of edges in the simple path between them.

More formally, let's define two hidden nodes as s and f. In one query you can provide the set of nodes \\{a_1, a_2, …, a_c\} of the tree. As a result, you will get two numbers a_i and dist(a_i, s) + dist(a_i, f). The node a_i is any node from the provided set, for which the number dist(a_i, s) + dist(a_i, f) is minimal.

You can ask no more than 11 queries.

Input

The first line contains a single integer t (1 ≤ t ≤ 10) — the number of test cases. Please note, how the interaction process is organized.

The first line of each test case consists of a single integer n (2 ≤ n ≤ 1000) — the number of nodes in the tree.

The next n - 1 lines consist of two integers u, v (1 ≤ u, v ≤ n, u ≠ v) — the edges of the tree.

Interaction

To ask a query print a single line:

  * In the beginning print "? c " (without quotes) where c (1 ≤ c ≤ n) denotes the number of nodes being queried, followed by c distinct integers in the range [1, n] — the indices of nodes from the list.

For each query, you will receive two integers x, d — the node (among the queried nodes) with the minimum sum of distances to the hidden nodes and the sum of distances from that node to the hidden nodes. If the subset of nodes queried is invalid or you exceeded the number of queries then you will get x = d = -1. In this case, you should terminate the program immediately.

When you have guessed the hidden nodes, print a single line "! " (without quotes), followed by two integers in the range [1, n] — the hidden nodes. You can output the hidden nodes in any order.

After this, you should read a string. If you guess the nodes correctly, you will receive the string "Correct". In this case, you should continue solving the remaining test cases or terminate the program, if all test cases were solved. Otherwise, you will receive the string "Incorrect". In this case, you should terminate the program immediately.

Guessing the hidden nodes does not count towards the number of queries asked.

The interactor is not adaptive. The hidden nodes do not change with queries.

Do not forget to read the string "Correct" / "Incorrect" after guessing the hidden nodes.

You need to solve each test case before receiving the input for the next test case.

The limit of 11 queries applies to each test case and not to the entire input.

After printing a query do not forget to output the end of the line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

  * fflush(stdout) or cout.flush() in C++;
  * System.out.flush() in Java;
  * flush(output) in Pascal;
  * stdout.flush() in Python;
  * see the documentation for other languages.

Hacks

To hack the solution, use the following test format:

The first line should contain a single integer t (1 ≤ t ≤ 10) — the number of test cases. The description of the test cases follows.

The first line of each test case should contain a single integer n (2 ≤ n ≤ 1000) — the number of nodes in the tree. The second line should contain two distinct integers in the range [1, n] — the hidden nodes. The next n - 1 lines should contain two integers u, v (1 ≤ u, v ≤ n, u ≠ v) — the edges of the tree.

Example

Input

1
3
1 2
1 3

1 1

2 3

3 1

3 1

Correct

Output

? 1 1

? 1 2

? 1 3

? 2 2 3

! 1 3

Note

The tree from the first test is shown below, and the hidden nodes are 1 and 3.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
const int maxm = 55;
const int inf = 2147483647;
const long long p = 1000000007;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
int dep[maxn], maxdep;
vector<int> g[maxn];
vector<int> gdep[maxn];
pair<int, int> query(vector<int> &a) {
  if (a.empty()) return make_pair(-1, -1);
  printf("? %d", (int)a.size());
  for (register int i = (0); i < (a.size()); ++i) printf(" %d", a[i]);
  printf("\n");
  fflush(stdout);
  int ans1, ans2;
  scanf("%d%d", &ans1, &ans2);
  return make_pair(ans1, ans2);
}
void answer(int a, int b) {
  printf("! %d %d\n", a, b);
  fflush(stdout);
  char c[15];
  scanf("%s", c);
  if (strcmp(c, "Incorrect") == 0) exit(0);
}
void dfs(int u, int f) {
  dep[u] = dep[f] + 1;
  maxdep = max(maxdep, dep[u]);
  gdep[dep[u]].push_back(u);
  for (register int i = (0); i < (g[u].size()); ++i) {
    if (g[u][i] != f) dfs(g[u][i], u);
  }
}
void dfs2(int u, int f, int deep, int len, vector<int> &a) {
  if (deep == len) a.push_back(u);
  for (register int i = (0); i < (g[u].size()); ++i) {
    if (g[u][i] != f) dfs2(g[u][i], u, deep + 1, len, a);
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    for (register int i = (0); i < (n - 1); ++i) {
      int u, v;
      scanf("%d%d", &u, &v);
      g[u].push_back(v);
      g[v].push_back(u);
    }
    vector<int> node;
    for (register int i = (1); i < (n + 1); ++i) node.push_back(i);
    maxdep = 0;
    int rt, len;
    pair<int, int> xx;
    xx = query(node);
    rt = xx.first, len = xx.second;
    dep[0] = -1;
    dfs(rt, 0);
    int l = (len + 1) / 2, r = min(maxdep, len), s = 0;
    while (l <= r) {
      int mid = l + r >> 1;
      int le, ts;
      xx = query(gdep[mid]);
      ts = xx.first, le = xx.second;
      if (le != len) {
        r = mid - 1;
      } else
        l = mid + 1, s = ts;
    }
    node.clear();
    dfs2(s, 0, 0, len, node);
    int tt;
    if (node.size() == 1)
      tt = node[0];
    else
      tt = query(node).first;
    answer(tt, s);
    for (register int i = (0); i < (n + 1); ++i) {
      g[i].clear();
      gdep[i].clear();
    }
  }
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sticks of different colours. Naturally, one of the sticks is extra. It is not allowed to break the sticks or use their partial length. Anne has perfectly solved this task, now she is asking Johnny to do the same.

The boy answered that he would cope with it without any difficulty. However, after a while he found out that different tricky things can occur. It can happen that it is impossible to construct a triangle of a positive area, but it is possible to construct a degenerate triangle. It can be so, that it is impossible to construct a degenerate triangle even. As Johnny is very lazy, he does not want to consider such a big amount of cases, he asks you to help him.

Input

The first line of the input contains four space-separated positive integer numbers not exceeding 100 — lengthes of the sticks.

Output

Output TRIANGLE if it is possible to construct a non-degenerate triangle. Output SEGMENT if the first case cannot take place and it is possible to construct a degenerate triangle. Output IMPOSSIBLE if it is impossible to construct any triangle. Remember that you are to use three sticks. It is not allowed to break the sticks or use their partial length.

Examples

Input

4 2 1 3

Output

TRIANGLE

Input

7 2 2 4

Output

SEGMENT

Input

3 5 9 1

Output

IMPOSSIBLE

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[4];
  cin >> arr[0] >> arr[1] >> arr[2] >> arr[3];
  sort(arr, arr + 4);
  if (arr[2] + arr[1] > arr[3] || arr[0] + arr[1] > arr[2])
    return cout << "TRIANGLE\n", 0;
  else {
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (j != i)
          for (int z = 0; z < 4; z++)
            if (arr[i] + arr[j] == arr[z]) return cout << "SEGMENT\n", 0;
  }
  cout << "IMPOSSIBLE\n";
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

You are given an array [a_1, a_2, ..., a_n] such that 1 ≤ a_i ≤ 10^9. Let S be the sum of all elements of the array a.

Let's call an array b of n integers beautiful if:

  * 1 ≤ b_i ≤ 10^9 for each i from 1 to n;
  * for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or b_{i + 1} divides b_i (or both);
  * 2 ∑ _{i = 1}^{n} |a_i - b_i| ≤ S.

Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.

Input

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

Each test case consists of two lines. The first line contains one integer n (2 ≤ n ≤ 50).

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

Output

For each test case, print the beautiful array b_1, b_2, ..., b_n (1 ≤ b_i ≤ 10^9) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.

Example

Input

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

Output

3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
void solve()
{
	long long int n,s=0,sum=0,k;
	cin>>n;
	long long int arr[n+1];
	for(int i=1;i<=n;i++)
	{
	cin>>arr[i];
	if(i%2==1)
	sum=sum+arr[i];
	else
	s=s+arr[i];}
	if(sum>=s)
	{
		for(int i=1;i<=n;i++)
	    {
	    	if(i%2==1)
	    	cout<<arr[i]<<" ";
	    	else
	    	cout<<"1"<<" ";
		}
	}
	else
	{
		for(int i=1;i<=n;i++)
	    {
	    	if(i%2==0)
	    	cout<<arr[i]<<" ";
	    	else
	    	cout<<"1"<<" ";
		}
	}
		cout<<endl;
}
int main() {
	int t=1;
	cin >> t;
	while(t--) {
		solve();
	}
}

```


### Prompt

Please create a solution in cpp to the following problem:

The New Year tree is an infinite perfect binary tree rooted in the node 1. Each node v has two children: nodes indexed (2·v) and (2·v + 1).

<image>

Polar bears love decorating the New Year tree and Limak is no exception. As he is only a little bear, he was told to decorate only one simple path between some pair of nodes. Though he was given an opportunity to pick the pair himself! Now he wants to know the number of unordered pairs of indices (u, v) (u ≤ v), such that the sum of indices of all nodes along the simple path between u and v (including endpoints) is equal to s. Can you help him and count this value?

Input

The only line of the input contains a single integer s (1 ≤ s ≤ 1015).

Output

Print one integer, denoting the number of unordered pairs of nodes indices defining simple paths with the sum of indices of vertices equal to s.

Example

Input

10

Output

4

Note

In sample test, there are 4 paths with the sum of indices equal to 10:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
const int maxx = 50;
long long dp[2][maxn * 2][2];
long long s;
inline long long pow2(long long x) { return (1ll << x); }
int main() {
  cin >> s;
  long long res = 0;
  for (int h1 = 0; h1 <= 50; h1++) {
    for (int h2 = 0; h2 <= 50; h2++) {
      long long curt = (pow2(h1 + 1) - 2 + pow2(h2 + 1) - 2 + 1);
      if (curt > s) continue;
      if (curt > s - pow2(h2) + 1) continue;
      if (h1 <= 1 && h2 <= 1) {
        long long lca = (s - pow2(h2) + 1) / curt;
        long long n = s - lca * curt - (pow2(h2) - 1);
        if (n == 0) {
          res++;
        }
        continue;
      }
      if (h2 == 0) {
        long long lca = (s - pow2(h2) + 1) / curt;
        if (lca <= 0) continue;
        if (lca > s) continue;
        for (int cnt = 0; cnt <= h1 - 1; cnt++) {
          long long n = s - lca * curt - (pow2(h2) - 1) + cnt;
          if (n < 0) continue;
          if (n >= pow2(h1)) continue;
          int c = 0;
          if (n % 2 == 1) continue;
          for (int i = 1; i <= h1 - 1; i++) {
            if ((n >> i) & 1) c++;
          }
          if (cnt == c) {
            res++;
          }
        }
        continue;
      }
      if (h1 == 0) {
        long long lca = (s - pow2(h2) + 1) / curt;
        if (lca <= 0) continue;
        if (lca > s) continue;
        for (int cnt = 0; cnt <= h2 - 1; cnt++) {
          long long n = s - lca * curt - (pow2(h2) - 1) + cnt;
          if (n >= pow2(h2)) continue;
          if (n < 0) continue;
          int c = 0;
          for (int i = 1; i <= h2 - 1; i++) {
            if ((n >> i) & 1) c++;
          }
          if (n % 2 == 1) continue;
          if (cnt == c) {
            res++;
          }
        }
        continue;
      }
      long long lca = (s - pow2(h2) + 1) / curt;
      if (lca <= 0) continue;
      if (lca > s) continue;
      for (int cnt = 0; cnt <= h1 + h2 - 2; cnt++) {
        long long n = s - lca * curt - (pow2(h2) - 1) + cnt;
        if (n < 0) continue;
        if (n % 2 == 1) continue;
        if (n > pow2(h1) - 2 + pow2(h2) - 2) continue;
        memset(dp, 0, sizeof(dp));
        int top1 = 0, top2 = 0;
        if (h1 >= 2) top1 = 1;
        if (h2 >= 2) top2 = 1;
        for (int a = 0; a <= top1; a++) {
          for (int b = 0; b <= top2; b++) {
            if ((a + b) % 2 == ((n >> 1) & 1)) {
              dp[1][a + b][(a + b) / 2]++;
            }
          }
        }
        for (int d = 1; d <= max(h1, h2) - 1; d++) {
          int ct = d % 2, ot = (d + 1) % 2;
          memset(dp[ot], 0, sizeof(dp[ot]));
          int sp = ((n >> (d + 1)) & 1);
          top1 = top2 = 0;
          if (h1 >= d + 2) top1 = 1;
          if (h2 >= d + 2) top2 = 1;
          for (int j = 0; j <= cnt && j <= (d + 1) * 2; j++) {
            for (int c = 0; c <= 1; c++) {
              if (dp[ct][j][c] == 0) continue;
              for (int a = 0; a <= top1; a++) {
                for (int b = 0; b <= top2; b++) {
                  if ((a + b + c) % 2 != sp) continue;
                  if (j + a + b > cnt) continue;
                  dp[ot][j + a + b][(c + a + b) / 2] += dp[ct][j][c];
                }
              }
            }
          }
        }
        res += dp[(max(h1, h2)) % 2][cnt][0];
      }
    }
  }
  cout << res << endl;
}

```


### Prompt

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

There are n robbers at coordinates (a_1, b_1), (a_2, b_2), ..., (a_n, b_n) and m searchlight at coordinates (c_1, d_1), (c_2, d_2), ..., (c_m, d_m).

In one move you can move each robber to the right (increase a_i of each robber by one) or move each robber up (increase b_i of each robber by one). Note that you should either increase all a_i or all b_i, you can't increase a_i for some points and b_i for some other points.

Searchlight j can see a robber i if a_i ≤ c_j and b_i ≤ d_j.

A configuration of robbers is safe if no searchlight can see a robber (i.e. if there is no pair i,j such that searchlight j can see a robber i).

What is the minimum number of moves you need to perform to reach a safe configuration?

Input

The first line of input contains two integers n and m (1 ≤ n, m ≤ 2000): the number of robbers and the number of searchlight.

Each of the next n lines contains two integers a_i, b_i (0 ≤ a_i, b_i ≤ 10^6), coordinates of robbers.

Each of the next m lines contains two integers c_i, d_i (0 ≤ c_i, d_i ≤ 10^6), coordinates of searchlights.

Output

Print one integer: the minimum number of moves you need to perform to reach a safe configuration.

Examples

Input

1 1
0 0
2 3

Output

3

Input

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

Output

4

Input

1 2
0 0
0 0
0 0

Output

1

Input

7 3
0 8
3 8
2 7
0 10
5 5
7 0
3 5
6 6
3 11
11 5

Output

6

Note

In the first test, you can move each robber to the right three times. After that there will be one robber in the coordinates (3, 0).

The configuration of the robbers is safe, because the only searchlight can't see the robber, because it is in the coordinates (2, 3) and 3 > 2.

In the second test, you can move each robber to the right two times and two times up. After that robbers will be in the coordinates (3, 8), (8, 3).

It's easy the see that the configuration of the robbers is safe.

It can be proved that you can't reach a safe configuration using no more than 3 moves.

### Response

```cpp
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int maxN = 2010;
const int N = 1e6 + 10;
pair<int, int> a[maxN];
int dp[N];
struct node {
  int x, add;
  node(int x = -1e9, int add = -1e9) : x(x), add(add) {}
};
node t[4 * N];
struct segmentTree {
  int getV(int v) { return max(t[v].add, t[v].x); }
  void push(int v) {
    t[2 * v + 1].add = max(t[2 * v + 1].add, t[v].add);
    t[2 * v + 2].add = max(t[2 * v + 2].add, t[v].add);
    t[v].add = -1e9;
  }
  void recalc(int v) { t[v].x = max(getV(2 * v + 1), getV(2 * v + 2)); }
  void add(int L, int R, int x, int v = 0, int tl = 0, int tr = N) {
    if (R <= tl || L >= tr || tr - tl < 1)
      return;
    else if (L <= tl && tr <= R)
      t[v].add = max(t[v].add, x);
    else {
      push(v);
      int mid = (tl + tr) / 2;
      add(L, R, x, 2 * v + 1, tl, mid);
      add(L, R, x, 2 * v + 2, mid, tr);
      recalc(v);
    }
  }
  int get(int ind, int v = 0, int tl = 0, int tr = N) {
    if (tr - tl == 1)
      return getV(v);
    else {
      push(v);
      int mid = (tl + tr) / 2;
      int ans = 0;
      if (ind >= mid)
        ans = get(ind, 2 * v + 2, mid, tr);
      else
        ans = get(ind, 2 * v + 1, tl, mid);
      recalc(v);
      return ans;
    }
  }
} tree;
int n, m;
int getCnt(int mid) {
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int ny = a[i].second + mid;
    int pans = -1e9;
    if (ny < N) pans = dp[ny];
    ans = max(ans, pans - a[i].first + 1);
  }
  return mid + ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    tree.add(0, b + 1, a);
  }
  for (int i = 0; i < N; ++i) dp[i] = tree.get(i);
  int ans = 1e9;
  for (int i = 0; i < 1e5; ++i) ans = min(ans, getCnt(i));
  for (int i = 1e6; i >= 1e6 - 1e5; --i) ans = min(ans, getCnt(i));
  cout << ans << "\n";
  return 0;
}

```


### Prompt

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

You are given a sorted array a_1, a_2, ..., a_n (for each index i > 1 condition a_i ≥ a_{i-1} holds) and an integer k.

You are asked to divide this array into k non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray.

Let max(i) be equal to the maximum in the i-th subarray, and min(i) be equal to the minimum in the i-th subarray. The cost of division is equal to ∑_{i=1}^{k} (max(i) - min(i)). For example, if a = [2, 4, 5, 5, 8, 11, 19] and we divide it into 3 subarrays in the following way: [2, 4], [5, 5], [8, 11, 19], then the cost of division is equal to (4 - 2) + (5 - 5) + (19 - 8) = 13.

Calculate the minimum cost you can obtain by dividing the array a into k non-empty consecutive subarrays.

Input

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 3 ⋅ 10^5).

The second line contains n integers a_1, a_2, ..., a_n ( 1 ≤ a_i ≤ 10^9, a_i ≥ a_{i-1}).

Output

Print the minimum cost you can obtain by dividing the array a into k nonempty consecutive subarrays.

Examples

Input

6 3
4 8 15 16 23 42

Output

12

Input

4 4
1 3 3 7

Output

0

Input

8 1
1 1 2 3 5 8 13 21

Output

20

Note

In the first test we can divide array a in the following way: [4, 8, 15, 16], [23], [42].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool marked[3 * 100000 + 10] = {0};
vector<long long int> a(3 * 100000 + 10);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k, ans;
  cin >> n >> k;
  vector<long long int> pref(n - 1);
  for (long long int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i > 0) {
      pref[i] = pref[i - 1] + a[i];
    } else if (i < n - 1) {
      pref[i] = a[i];
    }
  }
  ans = k * (pref[n - 2] + a[n - 1]);
  sort((pref).begin(), (pref).end());
  for (long long int i = 0; i < k - 1; ++i) {
    ans -= pref[i];
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

There are n problems prepared for the next Codeforces round. They are arranged in ascending order by their difficulty, and no two problems have the same difficulty. Moreover, there are m pairs of similar problems. Authors want to split problems between two division according to the following rules:

  * Problemset of each division should be non-empty.
  * Each problem should be used in exactly one division (yes, it is unusual requirement).
  * Each problem used in division 1 should be harder than any problem used in division 2.
  * If two problems are similar, they should be used in different divisions.

Your goal is count the number of ways to split problem between two divisions and satisfy all the rules. Two ways to split problems are considered to be different if there is at least one problem that belongs to division 1 in one of them and to division 2 in the other.

Note, that the relation of similarity is not transitive. That is, if problem i is similar to problem j and problem j is similar to problem k, it doesn't follow that i is similar to k.

Input

The first line of the input contains two integers n and m (2 ≤ n ≤ 100 000, 0 ≤ m ≤ 100 000) — the number of problems prepared for the round and the number of pairs of similar problems, respectively.

Each of the following m lines contains a pair of similar problems ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi). It's guaranteed, that no pair of problems meets twice in the input.

Output

Print one integer — the number of ways to split problems in two divisions.

Examples

Input

5 2
1 4
5 2

Output

2

Input

3 3
1 2
2 3
1 3

Output

0

Input

3 2
3 1
3 2

Output

1

Note

In the first sample, problems 1 and 2 should be used in division 2, while problems 4 and 5 in division 1. Problem 3 may be used either in division 1 or in division 2.

In the second sample, all pairs of problems are similar and there is no way to split problem between two divisions without breaking any rules.

Third sample reminds you that the similarity relation is not transitive. Problem 3 is similar to both 1 and 2, but 1 is not similar to 2, so they may be used together.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    int l = 1, r = n;
    for (int i = 0; i < m; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      if (a > b) swap(a, b);
      l = max(l, a);
      r = min(r, b);
    }
    if (r - l < 0)
      printf("0\n");
    else
      printf("%d\n", r - l);
  }
  return 0;
}

```


### Prompt

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

All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket.

The goods in the supermarket have unique integer ids. Also, for every integer there is a product with id equal to this integer. Fedor has n discount coupons, the i-th of them can be used with products with ids ranging from li to ri, inclusive. Today Fedor wants to take exactly k coupons with him.

Fedor wants to choose the k coupons in such a way that the number of such products x that all coupons can be used with this product x is as large as possible (for better understanding, see examples). Fedor wants to save his time as well, so he asks you to choose coupons for him. Help Fedor!

Input

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 3·105) — the number of coupons Fedor has, and the number of coupons he wants to choose.

Each of the next n lines contains two integers li and ri ( - 109 ≤ li ≤ ri ≤ 109) — the description of the i-th coupon. The coupons can be equal.

Output

In the first line print single integer — the maximum number of products with which all the chosen coupons can be used. The products with which at least one coupon cannot be used shouldn't be counted.

In the second line print k distinct integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the ids of the coupons which Fedor should choose.

If there are multiple answers, print any of them.

Examples

Input

4 2
1 100
40 70
120 130
125 180

Output

31
1 2

Input

3 2
1 12
15 20
25 30

Output

0
1 2

Input

5 2
1 10
5 15
14 50
30 70
99 100

Output

21
3 4

Note

In the first example if we take the first two coupons then all the products with ids in range [40, 70] can be bought with both coupons. There are 31 products in total.

In the second example, no product can be bought with two coupons, that is why the answer is 0. Fedor can choose any two coupons in this example.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline bool scan_d(int &num) {
  char in;
  bool IsN = false;
  in = getchar();
  if (in == EOF) return false;
  while (in != '-' && (in < '0' || in > '9')) in = getchar();
  if (in == '-') {
    IsN = true;
    num = 0;
  } else
    num = in - '0';
  while (in = getchar(), in >= '0' && in <= '9') {
    num *= 10, num += in - '0';
  }
  if (IsN) num = -num;
  return true;
}
void Out(int a) {
  if (a < 0) {
    putchar('-');
    a = -a;
  }
  if (a >= 10) {
    Out(a / 10);
  }
  putchar(a % 10 + '0');
}
struct note {
  int r;
  int l;
  int id;
} x[3000005];
int cmp(note a, note b) { return a.l < b.l; }
int main() {
  int n, k;
  int flag = 0;
  int tail, end;
  scan_d(n);
  scan_d(k);
  for (int i = 1; i <= n; i++) {
    scan_d(x[i].l);
    scan_d(x[i].r);
    x[i].id = i;
  }
  sort(x + 1, x + n + 1, cmp);
  priority_queue<int, vector<int>, greater<int> > que;
  int len = 0;
  int len1, num = 0;
  for (int i = 1; i <= n; i++) {
    que.push(x[i].r);
    if (que.size() > k) {
      que.pop();
    }
    len1 = que.top() - x[i].l + 1;
    if (que.size() == k && len < len1) {
      len = len1;
      num = x[i].l;
    }
  }
  Out(len);
  puts("");
  if (len == 0) {
    Out(1);
    for (int i = 2; i <= k; ++i) printf(" %d", i);
  } else {
    for (int i = 1; i <= n && k; ++i) {
      if (num >= x[i].l && len + num - 1 <= x[i].r) {
        if (k >= 1)
          printf("%d ", x[i].id);
        else
          printf("%d", x[i].id);
        k--;
      }
    }
  }
  puts("");
  return 0;
}

```


### Prompt

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

The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person.

You are given the first and the last name of a user. Return the alphabetically earliest login they can get (regardless of other potential Polygon users).

As a reminder, a prefix of a string s is its substring which occurs at the beginning of s: "a", "ab", "abc" etc. are prefixes of string "{abcdef}" but "b" and 'bc" are not. A string a is alphabetically earlier than a string b, if a is a prefix of b, or a and b coincide up to some position, and then a has a letter that is alphabetically earlier than the corresponding letter in b: "a" and "ab" are alphabetically earlier than "ac" but "b" and "ba" are alphabetically later than "ac".

Input

The input consists of a single line containing two space-separated strings: the first and the last names. Each character of each string is a lowercase English letter. The length of each string is between 1 and 10, inclusive.

Output

Output a single string — alphabetically earliest possible login formed from these names. The output should be given in lowercase as well.

Examples

Input

harry potter

Output

hap

Input

tom riddle

Output

tomr

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string first, second;
  cin >> first >> second;
  cout << first[0];
  for (int i = 1; i < first.size(); i++) {
    if (first[i] < second[0])
      cout << first[i];
    else
      break;
  }
  cout << second[0];
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

The only difference between easy and hard versions is the length of the string.

You are given a string s and a string t, both consisting only of lowercase Latin letters. It is guaranteed that t can be obtained from s by removing some (possibly, zero) number of characters (not necessary contiguous) from s without changing order of remaining characters (in other words, it is guaranteed that t is a subsequence of s).

For example, the strings "test", "tst", "tt", "et" and "" are subsequences of the string "test". But the strings "tset", "se", "contest" are not subsequences of the string "test".

You want to remove some substring (contiguous subsequence) from s of maximum possible length such that after removing this substring t will remain a subsequence of s.

If you want to remove the substring s[l;r] then the string s will be transformed to s_1 s_2 ... s_{l-1} s_{r+1} s_{r+2} ... s_{|s|-1} s_{|s|} (where |s| is the length of s).

Your task is to find the maximum possible length of the substring you can remove so that t is still a subsequence of s.

Input

The first line of the input contains one string s consisting of at least 1 and at most 200 lowercase Latin letters.

The second line of the input contains one string t consisting of at least 1 and at most 200 lowercase Latin letters.

It is guaranteed that t is a subsequence of s.

Output

Print one integer — the maximum possible length of the substring you can remove so that t is still a subsequence of s.

Examples

Input

bbaba
bb

Output

3

Input

baaba
ab

Output

2

Input

abcde
abcde

Output

0

Input

asdfasdf
fasd

Output

3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  long long int j = 0;
  vector<long long int> a, b;
  for (long long int i = 0; i < s.size(), j < t.size(); i++) {
    if (t[j] == s[i]) {
      a.push_back(i);
      j++;
    }
  }
  j = t.size() - 1;
  for (long long int i = s.size() - 1; i >= 0, j >= 0; i--) {
    if (t[j] == s[i]) {
      b.push_back(i);
      j--;
    }
  }
  long long int ans = 0;
  for (long long int i = 0; i < t.size() - 1; i++) {
    ans = max(ans, b[t.size() - i - 2] - a[i] - 1);
  }
  long long int k = b[t.size() - 1];
  ans = max(ans, k);
  k = s.size() - 1 - a[t.size() - 1];
  ans = max(ans, k);
  cout << ans;
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

E869120's and square1001's 16-th birthday is coming soon.
Takahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.

E869120 and square1001 were just about to eat A and B of those pieces, respectively,
when they found a note attached to the cake saying that "the same person should not take two adjacent pieces of cake".

Can both of them obey the instruction in the note and take desired numbers of pieces of cake?

Constraints

* A and B are integers between 1 and 16 (inclusive).
* A+B is at most 16.

Input

Input is given from Standard Input in the following format:

A B

Output

If both E869120 and square1001 can obey the instruction in the note and take desired numbers of pieces of cake, print `Yay!`; otherwise, print `:(`.

Examples

Input

5 4

Output

Yay!

Input

8 8

Output

Yay!

Input

11 4

Output

:(

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  if(A<=8 && B<=8)
    puts("Yay!");
  else
    puts(":(");
}
```


### Prompt

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

Bob got a job as a system administrator in X corporation. His first task was to connect n servers with the help of m two-way direct connection so that it becomes possible to transmit data from one server to any other server via these connections. Each direct connection has to link two different servers, each pair of servers should have at most one direct connection. Y corporation, a business rival of X corporation, made Bob an offer that he couldn't refuse: Bob was asked to connect the servers in such a way, that when server with index v fails, the transmission of data between some other two servers becomes impossible, i.e. the system stops being connected. Help Bob connect the servers.

Input

The first input line contains 3 space-separated integer numbers n, m, v (3 ≤ n ≤ 105, 0 ≤ m ≤ 105, 1 ≤ v ≤ n), n — amount of servers, m — amount of direct connections, v — index of the server that fails and leads to the failure of the whole system.

Output

If it is impossible to connect the servers in the required way, output -1. Otherwise output m lines with 2 numbers each — description of all the direct connections in the system. Each direct connection is described by two numbers — indexes of two servers, linked by this direct connection. The servers are numbered from 1. If the answer is not unique, output any.

Examples

Input

5 6 3

Output

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

Input

6 100 1

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > ans;
vector<int> v1, v2;
int n, m, v;
void addE(int a, int b) {
  ans.push_back({a, b});
  --m;
}
void solve() {
  scanf("%d %d %d", &n, &m, &v);
  if (m < n - 1) {
    printf("-1");
    return;
  }
  int p = n - 2;
  for (int i = 1; i <= n; ++i) {
    if (i == v) {
      continue;
    }
    if (p > 0) {
      v1.push_back(i);
    } else {
      v2.push_back(i);
    }
    --p;
  }
  v1.push_back(v);
  v2.push_back(v);
  for (int i = 0; i + 1 < v1.size(); ++i) {
    addE(v1[i], v1[i + 1]);
  }
  for (int i = 0; i + 1 < v2.size(); ++i) {
    addE(v2[i], v2[i + 1]);
  }
  for (int i = 0; i < v1.size() && m > 0; ++i) {
    for (int j = i + 2; j < v1.size() && m > 0; ++j) {
      addE(v1[i], v1[j]);
    }
  }
  if (m > 0) {
    printf("-1");
    return;
  }
  for (auto it : ans) {
    int a, b;
    tie(a, b) = it;
    printf("%d %d\n", a, b);
  }
}
int main() {
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}

```