### Prompt

Construct a cpp code solution to the problem outlined:

Vus the Cossack has a simple graph with n vertices and m edges. Let d_i be a degree of the i-th vertex. Recall that a degree of the i-th vertex is the number of conected edges to the i-th vertex.

He needs to remain not more than ⌈ (n+m)/(2) ⌉ edges. Let f_i be the degree of the i-th vertex after removing. He needs to delete them in such way so that ⌈ (d_i)/(2) ⌉ ≤ f_i for each i. In other words, the degree of each vertex should not be reduced more than twice.

Help Vus to remain the needed edges!

Input

The first line contains two integers n and m (1 ≤ n ≤ 10^6, 0 ≤ m ≤ 10^6) — the number of vertices and edges respectively.

Each of the next m lines contains two integers u_i and v_i (1 ≤ u_i, v_i ≤ n) — vertices between which there is an edge.

It is guaranteed that the graph does not have loops and multiple edges.

It is possible to show that the answer always exists.

Output

In the first line, print one integer k (0 ≤ k ≤ ⌈ (n+m)/(2) ⌉) — the number of edges which you need to remain.

In each of the next k lines, print two integers u_i and v_i (1 ≤ u_i, v_i ≤ n) — the vertices, the edge between which, you need to remain. You can not print the same edge more than once.

Examples

Input

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

Output

5
2 1
3 2
5 3
5 4
6 5

Input

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

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int M = 4200000;
namespace io {
const int L = (1 << 21) + 1;
char ibuf[L], *iS, *iT, obuf[L], *oS = obuf, *oT = obuf + L - 1, c, st[65];
int f, tp;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char x) {
  *oS++ = x;
  if (oS == oT) flush();
}
inline void read(int &x) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = x * 10 + (c & 15);
  x *= f;
}
inline void print(int x) {
  if (!x) putc('0');
  if (x < 0) putc('-'), x = -x;
  while (x) st[++tp] = x % 10 + '0', x /= 10;
  while (tp) putc(st[tp--]);
}
inline void read(long long &x) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = x * 10 + (c & 15);
  x *= f;
}
inline void print(long long x) {
  if (!x) putc('0');
  if (x < 0) putc('-'), x = -x;
  while (x) st[++tp] = x % 10 + '0', x /= 10;
  while (tp) putc(st[tp--]);
}
inline void read(char *s, int &l) {
  for (c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       c < 33; c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                               (iS == iT ? EOF : *iS++))
                             : *iS++))
    ;
  for (l = 0; c > 32;
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    s[l++] = c;
  s[l] = '\0';
}
inline void read(char *s) {
  int l;
  for (c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       c < 33; c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                               (iS == iT ? EOF : *iS++))
                             : *iS++))
    ;
  for (l = 0; c > 32;
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, L, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    s[l++] = c;
  s[l] = '\0';
}
inline void print(char *s) {
  for (int l = 0; s[l] != '\0'; ++l) putc(s[l]);
}
};  // namespace io
using io::print;
using io::putc;
using io::read;
struct edge {
  int fr, to, nx;
} e[M];
int n, m;
int cnt = 2;
int h[M] = {0};
void add(int u, int v) {
  e[cnt].fr = u;
  e[cnt].nx = h[u];
  e[cnt].to = v;
  h[u] = cnt++;
}
int dgree[M] = {0};
int im;
bool vir(int x) { return x > im; }
int eula[M];
int tp = 0;
vector<int> ans;
bool vsp[M];
bool vse[M];
void dfs(int u, int p) {
  vsp[u] = 1;
  for (int &i = h[u]; i; i = e[i].nx) {
    if (vse[i] || vse[i ^ 1]) continue;
    vse[i] = 1;
    dfs(e[i].to, i);
  }
  eula[tp++] = p;
}
bool del[M];
void solve(int x) {
  tp = 0;
  dfs(x, 0);
  --tp;
  for (int i = (0); i <= (tp); ++i) del[i] = 0;
  for (int i = 1; i < tp; i += 2) {
    int a = eula[i - 1], b = eula[i], c = eula[(i + 1) % tp];
    if (b > im)
      del[i] = 1;
    else {
      if (a > im)
        del[i - 1] = 1;
      else if (c > im)
        del[(i + 1) % tp] = 1;
      else
        del[i] = 1;
    }
  }
  for (int i = (0); i <= (tp - 1); ++i)
    if (!del[i] && eula[i] <= im) {
      ans.push_back(eula[i]);
    }
}
int main() {
  read(n);
  read(m);
  int u, v;
  for (int i = (1); i <= (m); ++i) {
    read(u);
    read(v);
    add(u, v);
    add(v, u);
    ++dgree[u];
    ++dgree[v];
  }
  im = cnt - 1;
  for (int i = (1); i <= (n); ++i)
    if (dgree[i] & 1) {
      add(i, 0);
      add(0, i);
    }
  for (int i = (1); i <= (n); ++i)
    if (!vsp[i]) solve(i);
  print((int)ans.size());
  putc('\n');
  for (int i : ans) {
    print(e[i].fr);
    putc(' ');
    print(e[i].to);
    putc('\n');
  }
  io::flush();
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

You are given an array a consisting of n integers. You can perform the following operations with it:

  1. Choose some positions i and j (1 ≤ i, j ≤ n, i ≠ j), write the value of a_i ⋅ a_j into the j-th cell and remove the number from the i-th cell;
  2. Choose some position i and remove the number from the i-th cell (this operation can be performed no more than once and at any point of time, not necessarily in the beginning).

The number of elements decreases by one after each operation. However, the indexing of positions stays the same. Deleted numbers can't be used in the later operations.

Your task is to perform exactly n - 1 operations with the array in such a way that the only number that remains in the array is maximum possible. This number can be rather large, so instead of printing it you need to print any sequence of operations which leads to this maximum number. Read the output format to understand what exactly you need to print.

Input

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

The second line contains n integers a_1, a_2, ..., a_n (-10^9 ≤ a_i ≤ 10^9) — the elements of the array.

Output

Print n - 1 lines. The k-th line should contain one of the two possible operations.

The operation of the first type should look like this: 1~ i_k~ j_k, where 1 is the type of operation, i_k and j_k are the positions of the chosen elements.

The operation of the second type should look like this: 2~ i_k, where 2 is the type of operation, i_k is the position of the chosen element. Note that there should be no more than one such operation.

If there are multiple possible sequences of operations leading to the maximum number — print any of them.

Examples

Input

5
5 -2 0 1 -3

Output

2 3
1 1 2
1 2 4
1 4 5

Input

5
5 2 0 4 0

Output

1 3 5
2 5
1 1 2
1 2 4

Input

2
2 -1

Output

2 2

Input

4
0 -10 0 0

Output

1 1 2
1 2 3
1 3 4

Input

4
0 0 0 0

Output

1 1 2
1 2 3
1 3 4

Note

Let X be the removed number in the array. Let's take a look at all the examples:

The first example has, for example, the following sequence of transformations of the array: [5, -2, 0, 1, -3] → [5, -2, X, 1, -3] → [X, -10, X, 1, -3] → [X, X, X, -10, -3] → [X, X, X, X, 30]. Thus, the maximum answer is 30. Note, that other sequences that lead to the answer 30 are also correct.

The second example has, for example, the following sequence of transformations of the array: [5, 2, 0, 4, 0] → [5, 2, X, 4, 0] → [5, 2, X, 4, X] → [X, 10, X, 4, X] → [X, X, X, 40, X]. The following answer is also allowed:

    1 5 3
    1 4 2
    1 2 1
    2 3

Then the sequence of transformations of the array will look like this: [5, 2, 0, 4, 0] → [5, 2, 0, 4, X] → [5, 8, 0, X, X] → [40, X, 0, X, X] → [40, X, X, X, X].

The third example can have the following sequence of transformations of the array: [2, -1] → [2, X].

The fourth example can have the following sequence of transformations of the array: [0, -10, 0, 0] → [X, 0, 0, 0] → [X, X, 0, 0] → [X, X, X, 0].

The fifth example can have the following sequence of transformations of the array: [0, 0, 0, 0] → [X, 0, 0, 0] → [X, X, 0, 0] → [X, X, X, 0].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, inf = 1e9 + 7;
int n, s1, s2, sum, last;
int a[N];
pair<int, int> pa;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int main() {
  n = read();
  pa = make_pair(inf, 0);
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    if (a[i] == 0) s1++;
    if (a[i] < 0) {
      s2++;
      pa = min(pa, make_pair(-a[i], i));
    }
  }
  if (s2 & 1) a[pa.second] = 0;
  last = -1;
  for (int i = 1; i <= n; i++) {
    if (a[i] != 0) continue;
    if (last == -1)
      last = i;
    else {
      printf("1 %d %d\n", last, i);
      last = i;
      sum++;
    }
  }
  if (last != -1 && sum < n - 1) printf("2 %d\n", last);
  last = -1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) continue;
    if (last == -1)
      last = i;
    else {
      printf("1 %d %d\n", last, i);
      last = i;
    }
  }
  return 0;
}

```


### Prompt

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

You are going to work in Codeforces as an intern in a team of n engineers, numbered 1 through n. You want to give each engineer a souvenir: a T-shirt from your country (T-shirts are highly desirable in Codeforces). Unfortunately you don't know the size of the T-shirt each engineer fits in. There are m different sizes, numbered 1 through m, and each engineer will fit in a T-shirt of exactly one size.

You don't know the engineers' exact sizes, so you asked your friend, Gerald. Unfortunately, he wasn't able to obtain the exact sizes either, but he managed to obtain for each engineer i and for all sizes j, the probability that the size of the T-shirt that fits engineer i is j.

Since you're planning to give each engineer one T-shirt, you are going to bring with you exactly n T-shirts. For those n T-shirts, you can bring any combination of sizes (you can bring multiple T-shirts with the same size too!). You don't know the sizes of T-shirts for each engineer when deciding what sizes to bring, so you have to pick this combination based only on the probabilities given by your friend, Gerald.

Your task is to maximize the expected number of engineers that receive a T-shirt of his size.

This is defined more formally as follows. When you finally arrive at the office, you will ask each engineer his T-shirt size. Then, if you still have a T-shirt of that size, you will give him one of them. Otherwise, you don't give him a T-shirt. You will ask the engineers in order starting from engineer 1, then engineer 2, and so on until engineer n.

Input

The first line contains two space-separated integers n and m (1 ≤ n ≤ 3000, 1 ≤ m ≤ 300), denoting the number of engineers and the number of T-shirt sizes, respectively.

Then n lines follow, each line contains m space-separated integers. The j-th integer in the i-th line represents the probability that the i-th engineer fits in a T-shirt of size j. Each probability will be given as an integer between 0 and 1000, inclusive. The actual probability should be calculated as the given number divided by 1000.

It is guaranteed that for any engineer, the sum of the probabilities for all m T-shirts is equal to one.

Output

Print a single real number denoting the maximum possible expected number of engineers that will receive a T-shirt.

For the answer the absolute or relative error of 10 - 9 is acceptable.

Examples

Input

2 2
500 500
500 500

Output

1.500000000000

Input

3 3
1000 0 0
1000 0 0
0 1000 0

Output

3.000000000000

Input

1 4
100 200 300 400

Output

0.400000000000

Note

For the first example, bring one T-shirt of each size. With 0.5 chance, either both engineers fit inside T-shirts of size 1 or both fit inside T-shirts of size 2. With the other 0.5 chance, one engineer fits inside a T-shirt of size 1 and the other inside a T-shirt of size 2. If the first is true, the number of engineers that receive a T-shirt is one. If the second is true, the number of such engineers is two. Hence, the expected number of engineers who receive a T-shirt is 1.5. This is maximum possible expected number of engineers for all sets of T-shirts.

For the second example, bring two T-shirts of size 1 and one T-shirt of size 2. This way, each engineer will definitely receive a T-shirt of his size.

For the third example, bring one T-shirt of size 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m, t;
int id[3310], ge[3310];
double a[3310][310], f[3310][3310], b[3310], an;
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf("%d", &k), a[i][j] = 1. * k / 1000;
  for (j = 1; j <= m; j++) {
    id[j] = ++t;
    f[t][0] = 1;
    for (i = 1; i <= n; i++) f[t][i] = f[t][i - 1] * (1 - a[i][j]);
    b[j] = 1 - f[t][n];
  }
  for (k = 1; k <= n; k++) {
    int re = 0;
    double ma = 0;
    for (j = 1; j <= m; j++)
      if (b[j] > ma) ma = b[j], re = j;
    an += ma;
    int last = id[re], now = ++t;
    id[re] = now;
    for (i = 1; i <= n; i++)
      f[now][i] = f[last][i - 1] * a[i][re] + f[now][i - 1] * (1 - a[i][re]);
    b[re] -= f[now][n];
  }
  printf("%.11lf\n", an);
  return 0;
}

```


### Prompt

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

You have a statistic of price changes for one product represented as an array of n positive integers p_0, p_1, ..., p_{n - 1}, where p_0 is the initial price of the product and p_i is how the price was increased during the i-th month.

Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase p_i to the price at the start of this month (p_0 + p_1 + ... + p_{i - 1}).

Your boss said you clearly that the inflation coefficients must not exceed k %, so you decided to increase some values p_i in such a way, that all p_i remain integers and the inflation coefficients for each month don't exceed k %.

You know, that the bigger changes — the more obvious cheating. That's why you need to minimize the total sum of changes.

What's the minimum total sum of changes you need to make all inflation coefficients not more than k %?

Input

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

The first line of each test case contains two integers n and k (2 ≤ n ≤ 100; 1 ≤ k ≤ 100) — the length of array p and coefficient k.

The second line of each test case contains n integers p_0, p_1, ..., p_{n - 1} (1 ≤ p_i ≤ 10^9) — the array p.

Output

For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than k %.

Example

Input

2
4 1
20100 1 202 202
3 100
1 1 1

Output

99
0

Note

In the first test case, you can, for example, increase p_0 by 50 and p_1 by 49 and get array [20150, 50, 202, 202]. Then you get the next inflation coefficients:

  1. 50/20150 ≤ 1/100;
  2. (202)/(20150 + 50) ≤ 1/100;
  3. (202)/(20200 + 202) ≤ 1/100;

In the second test case, you don't need to modify array p, since the inflation coefficients are already good:

  1. 1/1 ≤ 100/100;
  2. (1)/(1 + 1) ≤ 100/100;

### Response

```cpp
// 02/02/2021
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define CLR(a) memset(a, 0, sizeof(a))
#define REP(i, n) for(int i=0;i<n;i++)
#define FOR(i, n) for(int i=1;i<=n;i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
const int mxn = 1e2+2, MM = 1e9;

ll t(1), n, k, a[mxn], x, sum;
void solve() {
    cin >> n >> k;
    FOR(i, n) cin >> a[i];
    x = 0; sum = a[1];
    for(int i=2;i<=n;i++) {
        x = max(x, (100ll*a[i]-k*sum+k-1)/k);
        sum+=a[i];
    }
    cout << x << endl;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> t;
    for (int i=1;i<=t;i++) {
        solve();
    }
}
```


### Prompt

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

Sigma and Sugim are playing a game.

The game is played on a graph with N vertices numbered 1 through N. The graph has N-1 red edges and N-1 blue edges, and the N-1 edges in each color forms a tree. The red edges are represented by pairs of integers (a_i, b_i), and the blue edges are represented by pairs of integers (c_i, d_i).

Each player has his own piece. Initially, Sigma's piece is at vertex X, and Sugim's piece is at vertex Y.

The game is played in turns, where turns are numbered starting from turn 1. Sigma takes turns 1, 3, 5, ..., and Sugim takes turns 2, 4, 6, ....

In each turn, the current player either moves his piece, or does nothing. Here, Sigma can only move his piece to a vertex that is directly connected to the current vertex by a red edge. Similarly, Sugim can only move his piece to a vertex that is directly connected to the current vertex by a blue edge.

When the two pieces come to the same vertex, the game ends immediately. If the game ends just after the operation in turn i, let i be the total number of turns in the game.

Sigma's objective is to make the total number of turns as large as possible, while Sugim's objective is to make it as small as possible.

Determine whether the game will end in a finite number of turns, assuming both players plays optimally to achieve their respective objectives. If the answer is positive, find the number of turns in the game.

Constraints

* 2 ≦ N ≦ 200,000
* 1 ≦ X, Y ≦ N
* X \neq Y
* 1 ≦ a_i, b_i, c_i, d_i ≦ N
* The N-1 edges in each color (red and blue) forms a tree.

Input

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

N X Y
a_1 b_1
a_2 b_2
:
a_{N-1} b_{N-1}
c_1 d_1
c_2 d_2
:
c_{N-1} d_{N-1}

Output

If the game will end in a finite number of turns, print the number of turns. Otherwise, print `-1`.

Examples

Input

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

Output

4

Input

3 3 1
1 2
2 3
1 2
2 3

Output

4

Input

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

Output

2

Input

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

Output

-1

Input

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

Output

6

### Response

```cpp
#include<bits/stdc++.h>
#define N 200009
#define M 800009
using namespace std;

int n,rt,sta,tot,pnt[M],nxt[M]; bool bo[N];
int h[N],fa[N],dep[N],sz[N],son[N],anc[N],d[N];
struct graph{
	int fst[N];
	void add(int x,int y){
		pnt[++tot]=y; nxt[tot]=fst[x]; fst[x]=tot;
	}
}gr,gb;
void dfs(int x){
	int i,y; sz[x]=1;
	for (i=gb.fst[x]; i; i=nxt[i]){
		y=pnt[i];
		if (y!=fa[x]){
			fa[y]=x; dep[y]=dep[x]+1;
			dfs(y); sz[x]+=sz[y];
			if (sz[y]>sz[son[x]]) son[x]=y;
		}
	}
}
void dvd(int x,int tp){
	int i,y; anc[x]=tp;
	if (son[x]) dvd(son[x],tp);
	for (i=gb.fst[x]; i; i=nxt[i]){
		y=pnt[i];
		if (y!=fa[x] && y!=son[x]) dvd(y,y);
	}
}
int lca(int x,int y){
	for (; anc[x]!=anc[y]; x=fa[anc[x]])
		if (dep[anc[x]]<dep[anc[y]]) swap(x,y);
	return dep[x]<dep[y]?x:y;
}
int dist(int x,int y){
	return dep[x]+dep[y]-(dep[lca(x,y)]<<1);
}
int main(){
	scanf("%d%d%d",&n,&sta,&rt);
	int i,j,x,y;
	for (i=1; i<n; i++){
		scanf("%d%d",&x,&y);
		gr.add(x,y); gr.add(y,x);
	}
	for (i=1; i<n; i++){
		scanf("%d%d",&x,&y);
		gb.add(x,y); gb.add(y,x);
	}
	dfs(rt); dvd(rt,rt);
	for (i=1; i<=n; i++)
		for (j=gr.fst[i]; j; j=nxt[j])
			if (dist(i,pnt[j])>2) bo[i]=1;
	int head=0,tail=1,ans=0; h[1]=sta;
	memset(d,-1,sizeof(d)); d[sta]=0;
	while (head<tail){
		x=h[++head];
		if (bo[x]){ puts("-1"); return 0; }
		ans=max(ans,dep[x]<<1);
		for (i=gr.fst[x]; i; i=nxt[i]){
			y=pnt[i];
			if (d[y]==-1 && d[x]+1<dep[y]){
				d[y]=d[x]+1; h[++tail]=y;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

```


### Prompt

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

Ichihime is the current priestess of the Mahjong Soul Temple. She claims to be human, despite her cat ears.

These days the temple is holding a math contest. Usually, Ichihime lacks interest in these things, but this time the prize for the winner is her favorite — cookies. Ichihime decides to attend the contest. Now she is solving the following problem.

<image>

You are given four positive integers a, b, c, d, such that a ≤ b ≤ c ≤ d.

Your task is to find three integers x, y, z, satisfying the following conditions:

  * a ≤ x ≤ b.
  * b ≤ y ≤ c.
  * c ≤ z ≤ d.
  * There exists a triangle with a positive non-zero area and the lengths of its three sides are x, y, and z.

Ichihime desires to get the cookie, but the problem seems too hard for her. Can you help her?

Input

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

The next t lines describe test cases. Each test case is given as four space-separated integers a, b, c, d (1 ≤ a ≤ b ≤ c ≤ d ≤ 10^9).

Output

For each test case, print three integers x, y, z — the integers you found satisfying the conditions given in the statement.

It is guaranteed that the answer always exists. If there are multiple answers, print any.

Example

Input

4
1 3 5 7
1 5 5 7
100000 200000 300000 400000
1 1 977539810 977539810

Output

3 4 5
5 5 5
182690 214748 300999
1 977539810 977539810

Note

One of the possible solutions to the first test case:

<image>

One of the possible solutions to the second test case:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << b << " " << c << " " << c << endl;
  }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

This morning Tolik has understood that while he was sleeping he had invented an incredible problem which will be a perfect fit for Codeforces! But, as a "Discuss tasks" project hasn't been born yet (in English, well), he decides to test a problem and asks his uncle.

After a long time thinking, Tolik's uncle hasn't any ideas on how to solve it. But, he doesn't want to tell Tolik about his inability to solve it, so he hasn't found anything better than asking you how to solve this task.

In this task you are given a cell field n ⋅ m, consisting of n rows and m columns, where point's coordinates (x, y) mean it is situated in the x-th row and y-th column, considering numeration from one (1 ≤ x ≤ n, 1 ≤ y ≤ m). Initially, you stand in the cell (1, 1). Every move you can jump from cell (x, y), which you stand in, by any non-zero vector (dx, dy), thus you will stand in the (x+dx, y+dy) cell. Obviously, you can't leave the field, but also there is one more important condition — you're not allowed to use one vector twice. Your task is to visit each cell of the field exactly once (the initial cell is considered as already visited).

Tolik's uncle is a very respectful person. Help him to solve this task!

Input

The first and only line contains two positive integers n, m (1 ≤ n ⋅ m ≤ 10^{6}) — the number of rows and columns of the field respectively.

Output

Print "-1" (without quotes) if it is impossible to visit every cell exactly once.

Else print n ⋅ m pairs of integers, i-th from them should contain two integers x_i, y_i (1 ≤ x_i ≤ n, 1 ≤ y_i ≤ m) — cells of the field in order of visiting, so that all of them are distinct and vectors of jumps between them are distinct too.

Notice that the first cell should have (1, 1) coordinates, according to the statement.

Examples

Input

2 3

Output

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

Input

1 1

Output

1 1

Note

The vectors from the first example in the order of making jumps are (0, 2), (0, -1), (1, 0), (0, 1), (0, -2).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 50;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int l = 1;
  int r = n;
  while (l < r) {
    for (int i = 1; i <= m; i++) {
      printf("%d %d\n%d %d\n", l, i, r, m - i + 1);
    }
    l++;
    r--;
  }
  if (l == r) {
    for (int i = 1; i <= m / 2; i++) {
      printf("%d %d\n%d %d\n", l, i, l, m - i + 1);
    }
    if (m % 2) {
      printf("%d %d\n", l, m / 2 + 1);
    }
  }
}

```


### Prompt

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

Example

Input

2 3 1 3 1 0

Output

2

### Response

```cpp
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 2500005;

ll sa[MAX_N],sb[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m,n,u1,v1,u2,v2;
    cin >> m >> n >> u1 >> v1 >> u2 >> v2;
    vl a(m),b(n);
    rep(i,m){
        a[i] = u1;
        u1 = (u1*58+v1) % (n+1);
    }
    rep(i,n){
        b[i] = u2;
        u2 = (u2*58+v2) % (m+1);
    }
    sort(all(a)),sort(all(b));
    rep(i,m){
        sa[i+1] = sa[i] + a[i];
    }
    rep(i,n){
        sb[i+1] = sb[i] + b[i];
    }
    ll ans = (1LL << 60);
    rep(i,m+1){
        int cnt = upper_bound(all(b),i) - b.begin();
        cmn(ans,sa[m-i]+i*(n-cnt)+sb[cnt]);
    }
    cout << ans << "\n";
    return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

The Olympic Games in Bercouver are in full swing now. Here everyone has their own objectives: sportsmen compete for medals, and sport commentators compete for more convenient positions to give a running commentary. Today the main sport events take place at three round stadiums, and the commentator's objective is to choose the best point of observation, that is to say the point from where all the three stadiums can be observed. As all the sport competitions are of the same importance, the stadiums should be observed at the same angle. If the number of points meeting the conditions is more than one, the point with the maximum angle of observation is prefered.

Would you, please, help the famous Berland commentator G. Berniev to find the best point of observation. It should be noted, that the stadiums do not hide each other, the commentator can easily see one stadium through the other.

Input

The input data consists of three lines, each of them describes the position of one stadium. The lines have the format x, y, r, where (x, y) are the coordinates of the stadium's center ( - 103 ≤ x, y ≤ 103), and r (1 ≤ r ≤ 103) is its radius. All the numbers in the input data are integer, stadiums do not have common points, and their centers are not on the same line.

Output

Print the coordinates of the required point with five digits after the decimal point. If there is no answer meeting the conditions, the program shouldn't print anything. The output data should be left blank.

Examples

Input

0 0 10
60 0 10
30 30 10

Output

30.00000 0.00000

### Response

```cpp
#include <bits/stdc++.h>
double t[5], temp;
double x_1, y_1, r1, x2, y2, r2, x3, y3, r3, X = 0.0, Y = 0.0;
int f = 0;
double check(double dx, double dy) {
  double ret = 0.0;
  t[0] = sqrt(((dx - x_1) * (dx - x_1)) + ((dy - y_1) * (dy - y_1))) / r1;
  t[1] = sqrt(((dx - x2) * (dx - x2)) + ((dy - y2) * (dy - y2))) / r2;
  t[2] = sqrt(((dx - x3) * (dx - x3)) + ((dy - y3) * (dy - y3))) / r3;
  ret += ((t[0] - t[1]) * (t[0] - t[1]));
  ret += ((t[1] - t[2]) * (t[1] - t[2]));
  ret += ((t[2] - t[0]) * (t[2] - t[0]));
  return ret;
}
int main() {
  double s;
  scanf("%lf%lf%lf", &x_1, &y_1, &r1);
  scanf("%lf%lf%lf", &x2, &y2, &r2);
  scanf("%lf%lf%lf", &x3, &y3, &r3);
  X = (x2 + x3 + x_1) / 3 + 0.1;
  Y = (y2 + y3 + y_1) / 3 + 0.1;
  for (s = 1; s > (1e-6); f = 0) {
    temp = check(X, Y);
    if (temp > check(X + s, Y))
      X += s, f = 1;
    else if (temp > check(X - s, Y))
      X -= s, f = 1;
    else if (temp > check(X, Y + s))
      Y += s, f = 1;
    else if (temp > check(X, Y - s))
      Y -= s, f = 1;
    if (!f) s *= 0.7;
  }
  if (check(X, Y) < (1e-5)) printf("%.5lf %.5lf\n", X, Y);
  return 0;
}

```


### Prompt

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

Little Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a well-known data structure: multiset.

Artem wants to create a basic multiset of integers. He wants these structure to support operations of three types:

  1. Add integer to the multiset. Note that the difference between set and multiset is that multiset may store several instances of one integer.
  2. Remove integer from the multiset. Only one instance of this integer is removed. Artem doesn't want to handle any exceptions, so he assumes that every time remove operation is called, that integer is presented in the multiset.
  3. Count the number of instances of the given integer that are stored in the multiset.

But what about time machine? Artem doesn't simply apply operations to the multiset one by one, he now travels to different moments of time and apply his operation there. Consider the following example.

  * First Artem adds integer 5 to the multiset at the 1-st moment of time.
  * Then Artem adds integer 3 to the multiset at the moment 5.
  * Then Artem asks how many 5 are there in the multiset at moment 6. The answer is 1.
  * Then Artem returns back in time and asks how many integers 3 are there in the set at moment 4. Since 3 was added only at moment 5, the number of integers 3 at moment 4 equals to 0.
  * Then Artem goes back in time again and removes 5 from the multiset at moment 3.
  * Finally Artyom asks at moment 7 how many integers 5 are there in the set. The result is 0, since we have removed 5 at the moment 3.

Note that Artem dislikes exceptions so much that he assures that after each change he makes all delete operations are applied only to element that is present in the multiset. The answer to the query of the third type is computed at the moment Artem makes the corresponding query and are not affected in any way by future changes he makes.

Help Artem implement time travellers multiset.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of Artem's queries.

Then follow n lines with queries descriptions. Each of them contains three integers ai, ti and xi (1 ≤ ai ≤ 3, 1 ≤ ti, xi ≤ 109) — type of the query, moment of time Artem travels to in order to execute this query and the value of the query itself, respectively. It's guaranteed that all moments of time are distinct and that after each operation is applied all operations of the first and second types are consistent.

Output

For each ask operation output the number of instances of integer being queried at the given moment of time.

Examples

Input

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

Output

1
2
1

Input

3
1 1 1
2 2 1
3 3 1

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 15;
struct Persistent {
  int l, r, s;
  Persistent() { l = r = s = 0; }
} t[N << 5];
int n, no, avail, root[N];
map<int, int> vis;
int squeeze(int x) {
  if (vis.find(x) == vis.end()) vis[x] = ++no;
  return vis[x];
}
int update(int pre, int b, int e, int pos, int v) {
  int node = ++avail;
  t[node] = t[pre];
  if (b == e) {
    t[node].s += v;
    return node;
  }
  int m = (b + e) >> 1;
  if (pos <= m)
    t[node].l = update(t[node].l, b, m, pos, v);
  else
    t[node].r = update(t[node].r, m + 1, e, pos, v);
  t[node].s = t[t[node].l].s + t[t[node].r].s;
  return node;
}
int query(int node, int b, int e, int l, int r) {
  if (e < l || b > r || b > e) return 0;
  if (l <= b && e <= r) return t[node].s;
  int m = (b + e) >> 1;
  return query(t[node].l, b, m, l, r) + query(t[node].r, m + 1, e, l, r);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i += 1) {
    int operation, t, x;
    cin >> operation >> t >> x;
    x = squeeze(x);
    if (operation == 1) {
      root[x] = update(root[x], 1, 1e9, t, +1);
    } else if (operation == 2) {
      root[x] = update(root[x], 1, 1e9, t, -1);
    } else {
      cout << query(root[x], 1, 1e9, 1, t) << '\n';
    }
  }
  return 0;
}

```


### Prompt

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

Goldbach's Conjecture: For any even number n greater than or equal to 4, there exists at least one pair of prime numbers p1 and p2 such that n = p1 + p2.

This conjecture has not been proved nor refused yet. No one is sure whether this conjecture actually holds. However, one can find such a pair of prime numbers, if any, for a given even number. The problem here is to write a program that reports the number of all the pairs of prime numbers satisfying the condition in the conjecture for a given even number.

A sequence of even numbers is given as input. Corresponding to each number, the program should output the number of pairs mentioned above. Notice that we are intereseted in the number of essentially different pairs and therefore you should not count (p1, p2) and (p2, p1) separately as two different pairs.

Input

An integer is given in each input line. You may assume that each integer is even, and is greater than or equal to 4 and less than 215. The end of the input is indicated by a number 0.

Output

Each output line should contain an integer number. No other characters should appear in the output.

Example

Input

6
10
12
0

Output

1
2
1

### Response

```cpp
#include<stdio.h>
#include<bitset>
int main()
{
	const int N=65536;
	std::bitset<N>p;
	int i,j,n,r;
	p.set();
	for(i=2;i<N/2;++i)if(p[i])for(j=i*2;j<N;j+=i)p[j]=0;
	while(scanf("%d",&n),n)
	{
		for(r=0,i=j=n/2;i>1;++j)if(p[i--]&&p[j])++r;
		printf("%d\n",r);
	}
	return 0;
}
```


### Prompt

Create a solution in CPP for the following problem:

Find the edit distance between given two words s1 and s2.

The disntace is the minimum number of single-character edits required to change one word into the other. The edits including the following operations:

* insertion: Insert a character at a particular position.
* deletion: Delete a character at a particular position.
* substitution: Change the character at a particular position to a different character

Constraints

* 1 ≤ length of s1 ≤ 1000
* 1 ≤ length of s2 ≤ 1000

Input

s1
s2

Two words s1 and s2 are given in the first line and the second line respectively. The words will consist of lower case characters.

Output

Print the edit distance in a line.

Examples

Input

acac
acm

Output

2

Input

icpc
icpc

Output

0

### Response

```cpp
#include <iostream>
#include <cstring>
#include <algorithm>

char s1[1000], s2[1000];
int dp[1001][1001];

int main()
{
	std::cin >> s1 >> s2;

	int s1_len = std::strlen(s1);
	int s2_len = std::strlen(s2);

	for (int i = 0; i < 1001; ++i)
	{
		dp[0][i] = i;
		dp[i][0] = i;
	}

	for (int i = 1; i <= s1_len; ++i)
	{
		for (int j = 1; j <= s2_len; ++j)
		{
			if (s1[i - 1] == s2[j - 1])
			{
				dp[i][j] = dp[i - 1][j - 1];
			}
			else
			{
				dp[i][j] = std::min({dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + 1});
			}
		}
	}

	std::cout << dp[s1_len][s2_len] << std::endl;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

You are given an array a of n integers.

You want to make all elements of a equal to zero by doing the following operation exactly three times:

  * Select a segment, for each number in this segment we can add a multiple of len to it, where len is the length of this segment (added integers can be different).

It can be proven that it is always possible to make all elements of a equal to zero.

Input

The first line contains one integer n (1 ≤ n ≤ 100 000): the number of elements of the array.

The second line contains n elements of an array a separated by spaces: a_1, a_2, ..., a_n (-10^9 ≤ a_i ≤ 10^9).

Output

The output should contain six lines representing three operations.

For each operation, print two lines:

  * The first line contains two integers l, r (1 ≤ l ≤ r ≤ n): the bounds of the selected segment.

  * The second line contains r-l+1 integers b_l, b_{l+1}, ..., b_r (-10^{18} ≤ b_i ≤ 10^{18}): the numbers to add to a_l, a_{l+1}, …, a_r, respectively; b_i should be divisible by r - l + 1.

Example

Input

4
1 3 2 4

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
struct _ {
  ios_base::Init i;
  _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); }
} _;
int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i <= n - 1; i++) cin >> a[i];
  if (n == 1) {
    cout << "1 1\n0\n1 1\n0\n1 1\n";
    cout << -a[0];
    return 0;
  }
  for (auto rep : {0, 1, 2}) {
    if (rep == 0) {
      cout << "1 " << n - 1 << "\n";
      for (long long i = 0; i <= n - 2; i++) {
        cout << (n - 1) * a[i] << " ";
        a[i] += (n - 1) * a[i];
      }
      cout << "\n";
    } else if (rep == 1) {
      cout << n << " " << n << "\n";
      cout << -a[n - 1] << "\n";
      a[n - 1] = 0;
    } else {
      cout << "1 " << n << "\n";
      for (long long i = 0; i <= n - 1; i++) cout << -a[i] << " ";
    }
  }
  return 0;
}

```


### Prompt

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

In one very old text file there was written Great Wisdom. This Wisdom was so Great that nobody could decipher it, even Phong — the oldest among the inhabitants of Mainframe. But still he managed to get some information from there. For example, he managed to learn that User launches games for pleasure — and then terrible Game Cubes fall down on the city, bringing death to those modules, who cannot win the game...

For sure, as guard Bob appeared in Mainframe many modules stopped fearing Game Cubes. Because Bob (as he is alive yet) has never been defeated by User, and he always meddles with Game Cubes, because he is programmed to this.

However, unpleasant situations can happen, when a Game Cube falls down on Lost Angles. Because there lives a nasty virus — Hexadecimal, who is... mmm... very strange. And she likes to play very much. So, willy-nilly, Bob has to play with her first, and then with User.

This time Hexadecimal invented the following entertainment: Bob has to leap over binary search trees with n nodes. We should remind you that a binary search tree is a binary tree, each node has a distinct key, for each node the following is true: the left sub-tree of a node contains only nodes with keys less than the node's key, the right sub-tree of a node contains only nodes with keys greater than the node's key. All the keys are different positive integer numbers from 1 to n. Each node of such a tree can have up to two children, or have no children at all (in the case when a node is a leaf).

In Hexadecimal's game all the trees are different, but the height of each is not lower than h. In this problem «height» stands for the maximum amount of nodes on the way from the root to the remotest leaf, the root node and the leaf itself included. When Bob leaps over a tree, it disappears. Bob gets the access to a Cube, when there are no trees left. He knows how many trees he will have to leap over in the worst case. And you?

Input

The input data contains two space-separated positive integer numbers n and h (n ≤ 35, h ≤ n).

Output

Output one number — the answer to the problem. It is guaranteed that it does not exceed 9·1018.

Examples

Input

3 2

Output

5

Input

3 3

Output

4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int64_t dp[35 + 1][35 + 1];
int main() {
  memset(dp, 0, sizeof(dp));
  int n, h;
  scanf("%d%d", &n, &h);
  dp[0][0] = 1LL;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= i; ++j) {
      int l = j - 1, r = i - j;
      int ls = (l == 0) ? 0 : (log2(l) + 1);
      int rs = (r == 0) ? 0 : (log2(r) + 1);
      for (int lh = ls; lh <= l; ++lh) {
        for (int rh = rs; rh <= r; ++rh) {
          int mxh = max(lh, rh) + 1;
          dp[i][mxh] += dp[l][lh] * dp[r][rh];
        }
      }
    }
  }
  int64_t ans = 0;
  for (int i = h; i <= n; ++i) {
    ans += dp[n][i];
  }
  printf("%" PRId64 "\n", ans);
  return 0;
}

```


### Prompt

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

Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.

Arkady goes to the riverside each day and makes a mark on the side of the channel at the height of the water level, but if it coincides with a mark made before, no new mark is created. The water does not wash the marks away. Arkady writes down the number of marks strictly above the water level each day, on the i-th day this value is equal to mi.

Define di as the number of marks strictly under the water level on the i-th day. You are to find out the minimum possible sum of di over all days. There are no marks on the channel before the first day.

Input

The first line contains a single positive integer n (1 ≤ n ≤ 105) — the number of days.

The second line contains n space-separated integers m1, m2, ..., mn (0 ≤ mi < i) — the number of marks strictly above the water on each day.

Output

Output one single integer — the minimum possible sum of the number of marks strictly below the water level among all days.

Examples

Input

6
0 1 0 3 0 2

Output

6

Input

5
0 1 2 1 2

Output

1

Input

5
0 1 1 2 2

Output

0

Note

In the first example, the following figure shows an optimal case.

<image>

Note that on day 3, a new mark should be created because if not, there cannot be 3 marks above water on day 4. The total number of marks underwater is 0 + 0 + 2 + 0 + 3 + 1 = 6.

In the second example, the following figure shows an optimal case.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main() {
  long long n;
  cin >> n;
  long long maxi = 0;
  multiset<long long, greater<long long> > mi;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    maxi = max(maxi, arr[i]);
    mi.insert(arr[i]);
  }
  long long tot = 0;
  for (long long i = n - 1; i >= 0; i--) {
    if (maxi > *mi.begin()) maxi--;
    tot += maxi - arr[i];
    mi.erase(mi.find(arr[i]));
  }
  cout << tot;
  return 0;
}

```


### Prompt

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

Dreamoon saw a large integer x written on the ground and wants to print its binary form out. Dreamoon has accomplished the part of turning x into its binary format. Now he is going to print it in the following manner.

He has an integer n = 0 and can only perform the following two operations in any order for unlimited times each:

  1. Print n in binary form without leading zeros, each print will append to the right of previous prints.
  2. Increase n by 1.

Let's define an ideal sequence as a sequence of operations that can successfully print binary representation of x without leading zeros and ends with a print operation (i.e. operation 1). Dreamoon wants to know how many different ideal sequences are there and the length (in operations) of the shortest ideal sequence.

The answers might be large so please print them modulo 1000000007 (109 + 7).

Let's define the string representation of an ideal sequence as a string of '1' and '2' where the i-th character in the string matches the i-th operation performed. Two ideal sequences are called different if their string representations are different.

Input

The single line of the input contains a binary integer representing x (1 ≤ x < 25000) without leading zeros.

Output

The first line of the output should contain an integer representing the number of different ideal sequences modulo 1000000007 (109 + 7).

The second line of the output contains an integer representing the minimal length of an ideal sequence modulo 1000000007 (109 + 7).

Examples

Input

101

Output

1
6

Input

11010

Output

3
5

Note

For the first sample, the shortest and the only ideal sequence is «222221» of length 6.

For the second sample, there are three ideal sequences «21211», «212222222221», «222222222222222222222222221». Among them the shortest one has length 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
const int inf = 1 << 29;
const int mod = 1000000007;
const double eps = 1e-8;
char ss[maxn];
int xi[maxn][13];
int lo(int x) {
  int tp = 1, res = 0;
  while (tp * 2 <= x) {
    tp <<= 1;
    res++;
  }
  return res;
}
struct suf {
  int s[maxn];
  int sa[maxn], t[maxn], t2[maxn], c[maxn], n, m;
  int rank[maxn], h[maxn];
  void init(int le) {
    n = le;
    m = 3;
    for (int i = 0; i < n; i++) s[i] = ss[i] - '0';
    s[n] = 0;
    build();
    rmq();
  }
  inline int lcp(int x, int y) {
    if (x > y) swap(x, y);
    return query(x + 1, y);
  }
  void rmq() {
    for (int i = 0; i < n; i++) xi[i][0] = h[i];
    for (int j = 1; j <= lo(n); j++)
      for (int i = 0; i + (1 << j) - 1 < n; i++)
        xi[i][j] = min(xi[i][j - 1], xi[i + (1 << (j - 1))][j - 1]);
  }
  int query(int x, int y) {
    int k = lo(y - x + 1);
    return min(xi[x][k], xi[y - (1 << k) + 1][k]);
  }
  void geth() {
    int i, j, k = 0;
    for (i = 0; i < n; i++) rank[sa[i]] = i;
    for (i = 0; i < n; i++) {
      if (k) k--;
      if (!rank[i]) continue;
      j = sa[rank[i] - 1];
      while (s[i + k] == s[j + k]) k++;
      h[rank[i]] = k;
    }
  }
  void build() {
    int i, *x = t, *y = t2;
    for (i = 0; i < m; i++) c[i] = 0;
    for (i = 0; i < n; i++) c[x[i] = s[i]]++;
    for (i = 1; i < m; i++) c[i] += c[i - 1];
    for (i = n - 1; i >= 0; i--) sa[--c[x[i]]] = i;
    for (int k = 1; k <= n; k <<= 1) {
      int p = 0;
      for (i = n - k; i < n; i++) y[p++] = i;
      for (i = 0; i < n; i++)
        if (sa[i] >= k) y[p++] = sa[i] - k;
      for (i = 0; i < m; i++) c[i] = 0;
      for (i = 0; i < n; i++) c[x[y[i]]]++;
      for (i = 1; i < m; i++) c[i] += c[i - 1];
      for (i = n - 1; i >= 0; i--) sa[--c[x[y[i]]]] = y[i];
      swap(x, y);
      p = 1, x[sa[0]] = 0;
      for (i = 1; i < n; i++) {
        if (y[sa[i]] != y[sa[i - 1]])
          x[sa[i]] = p++;
        else if (sa[i] < n - k && sa[i - 1] < n - k)
          x[sa[i]] = y[sa[i] + k] == y[sa[i - 1] + k] ? p - 1 : p++;
        else
          x[sa[i]] = p++;
      }
      if (p >= n) break;
      m = p;
    }
    geth();
  }
} st;
int dp[maxn][maxn], n;
int f(int l, int r) {
  int tp = r * 2 - l;
  if (tp > n) return -1;
  if (st.lcp(st.rank[l], st.rank[r]) >= r - l) return tp;
  if (st.rank[l] < st.rank[r]) return tp;
  return tp + 1 > n ? -1 : tp + 1;
}
int g(int x, int y) {
  if (!y) return x;
  return min(x, y);
}
int ff(int l, int r) {
  int res = 0, b = 1;
  for (int i = r - 1; i >= l; i--) {
    res = (res + (ss[i] - '0') * b) % mod;
    b = (b * 2) % mod;
  }
  return res;
}
int main() {
  scanf("%s", ss);
  n = strlen(ss);
  st.init(n);
  dp[0][1] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (!dp[i][j]) continue;
      dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod;
      if (ss[j] == '1') {
        int p = f(i, j);
        if (p != -1) {
          dp[j][p] = (dp[j][p] + dp[i][j]) % mod;
        }
      }
    }
  }
  int r = 0;
  for (int i = 0; i < n; i++) r = (r + dp[i][n]) % mod;
  printf("%d\n", r);
  memset(dp, 0, sizeof(dp));
  dp[0][1] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (!dp[i][j]) continue;
      dp[i][j + 1] = g(dp[i][j], dp[i][j + 1]);
      if (ss[j] == '1') {
        int p = f(i, j);
        if (p != -1) {
          dp[j][p] = g(dp[i][j] + 1, dp[j][p]);
        }
      }
    }
  }
  int la = 1;
  for (int i = 0; i < n; i++) {
    if (dp[i][n]) {
      if (n - i >= 13)
        r = (ff(i, n) + dp[i][n]) % mod;
      else {
        if (la) {
          la = 0;
          r = ff(i, n) + dp[i][n];
        } else
          r = min(r, ff(i, n) + dp[i][n]);
      }
    }
  }
  printf("%d\n", r);
}

```


### Prompt

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

Takahashi has K 500-yen coins. (Yen is the currency of Japan.) If these coins add up to X yen or more, print `Yes`; otherwise, print `No`.

Constraints

* 1 \leq K \leq 100
* 1 \leq X \leq 10^5

Input

Input is given from Standard Input in the following format:

K X

Output

If the coins add up to X yen or more, print `Yes`; otherwise, print `No`.

Examples

Input

2 900

Output

Yes

Input

1 501

Output

No

Input

4 2000

Output

Yes

### Response

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

int main(){

  int N,X;
  cin>>N>>X;
  if(N*500<X)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}
```


### Prompt

Generate a cpp solution to the following problem:

The German University in Cairo (GUC) dorm houses are numbered from 1 to n. Underground water pipes connect these houses together. Each pipe has certain direction (water can flow only in this direction and not vice versa), and diameter (which characterizes the maximal amount of water it can handle).

For each house, there is at most one pipe going into it and at most one pipe going out of it. With the new semester starting, GUC student and dorm resident, Lulu, wants to install tanks and taps at the dorms. For every house with an outgoing water pipe and without an incoming water pipe, Lulu should install a water tank at that house. For every house with an incoming water pipe and without an outgoing water pipe, Lulu should install a water tap at that house. Each tank house will convey water to all houses that have a sequence of pipes from the tank to it. Accordingly, each tap house will receive water originating from some tank house.

In order to avoid pipes from bursting one week later (like what happened last semester), Lulu also has to consider the diameter of the pipes. The amount of water each tank conveys should not exceed the diameter of the pipes connecting a tank to its corresponding tap. Lulu wants to find the maximal amount of water that can be safely conveyed from each tank to its corresponding tap.

Input

The first line contains two space-separated integers n and p (1 ≤ n ≤ 1000, 0 ≤ p ≤ n) — the number of houses and the number of pipes correspondingly.

Then p lines follow — the description of p pipes. The i-th line contains three integers ai bi di, indicating a pipe of diameter di going from house ai to house bi (1 ≤ ai, bi ≤ n, ai ≠ bi, 1 ≤ di ≤ 106).

It is guaranteed that for each house there is at most one pipe going into it and at most one pipe going out of it.

Output

Print integer t in the first line — the number of tank-tap pairs of houses.

For the next t lines, print 3 integers per line, separated by spaces: tanki, tapi, and diameteri, where tanki ≠ tapi (1 ≤ i ≤ t). Here tanki and tapi are indexes of tank and tap houses respectively, and diameteri is the maximum amount of water that can be conveyed. All the t lines should be ordered (increasingly) by tanki.

Examples

Input

3 2
1 2 10
2 3 20

Output

1
1 3 10

Input

3 3
1 2 20
2 3 10
3 1 5

Output

0

Input

4 2
1 2 60
3 4 50

Output

2
1 2 60
3 4 50

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int v, d;
} Edge_t;
const int maxn = 1005;
int ideg[maxn], odeg[maxn];
vector<Edge_t> E[maxn];
typedef struct tuple_t {
  int s, e, d;
  friend bool operator<(const tuple_t& a, const tuple_t& b) {
    return a.s < b.s;
  }
} tuple_t;
vector<tuple_t> ans;
tuple_t t;
void dfs(int u, int d) {
  if (odeg[u] == 0 && u != t.s) {
    t.d = d;
    t.e = u;
    ans.push_back(t);
    return;
  }
  int v, d_;
  for (int i = 0; i < ((int)(E[u]).size()); ++i) {
    v = E[u][i].v;
    d_ = E[u][i].d;
    d_ = min(d_, d);
    dfs(v, d_);
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  int u, v, d;
  Edge_t e;
  memset(ideg, 0, sizeof(ideg));
  memset(odeg, 0, sizeof(odeg));
  scanf("%d %d", &n, &m);
  while (m--) {
    scanf("%d %d %d", &u, &e.v, &e.d);
    E[u].push_back(e);
    ++ideg[e.v];
    ++odeg[u];
  }
  for (int i = 1; i < n + 1; ++i) {
    if (ideg[i] == 0) {
      t.s = i;
      dfs(i, INT_MAX);
    }
  }
  sort((ans).begin(), (ans).end());
  n = ((int)(ans).size());
  printf("%d\n", n);
  for (int i = 0; i < n; ++i)
    printf("%d %d %d\n", ans[i].s, ans[i].e, ans[i].d);
  return 0;
}

```


### Prompt

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

I conducted an exit poll of the shopping amount at a department store. Create a program that takes the shopping amount data as input, calculates the average shopping amount per person, and outputs it. The number of people surveyed shall be 100,000 or less, and the shopping amount per person shall not exceed 1 million yen.

Input

The input is given in the following format:

n
v1
v2
::
vn

The first line gives the number of people surveyed n, and the following n lines give the integer vi representing the purchase amount of the ith person.

Output

Please output the average shopping amount (integer: rounded down to the nearest whole number) on one line.

Example

Input

6
12300
5600
33800
0
26495
52000

Output

21699

### Response

```cpp
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        ans += x;
    }
    cout << ans/n << "\n";
    return 0;
}

```


### Prompt

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

There are some ambiguities when one writes Berland names with the letters of the Latin alphabet.

For example, the Berland sound u can be written in the Latin alphabet as "u", and can be written as "oo". For this reason, two words "ulyana" and "oolyana" denote the same name.

The second ambiguity is about the Berland sound h: one can use both "h" and "kh" to write it. For example, the words "mihail" and "mikhail" denote the same name.

There are n users registered on the Polycarp's website. Each of them indicated a name represented by the Latin letters. How many distinct names are there among them, if two ambiguities described above are taken into account?

Formally, we assume that two words denote the same name, if using the replacements "u" <image> "oo" and "h" <image> "kh", you can make the words equal. One can make replacements in both directions, in any of the two words an arbitrary number of times. A letter that resulted from the previous replacement can participate in the next replacements.

For example, the following pairs of words denote the same name:

  * "koouper" and "kuooper". Making the replacements described above, you can make both words to be equal: "koouper" <image> "kuuper" and "kuooper" <image> "kuuper".
  * "khun" and "kkkhoon". With the replacements described above you can make both words to be equal: "khun" <image> "khoon" and "kkkhoon" <image> "kkhoon" <image> "khoon".

For a given list of words, find the minimal number of groups where the words in each group denote the same name.

Input

The first line contains integer number n (2 ≤ n ≤ 400) — number of the words in the list.

The following n lines contain words, one word per line. Each word consists of only lowercase Latin letters. The length of each word is between 1 and 20 letters inclusive.

Output

Print the minimal number of groups where the words in each group denote the same name.

Examples

Input

10
mihail
oolyana
kooooper
hoon
ulyana
koouper
mikhail
khun
kuooper
kkkhoon

Output

4

Input

9
hariton
hkariton
buoi
kkkhariton
boooi
bui
khariton
boui
boi

Output

5

Input

2
alex
alex

Output

1

Note

There are four groups of words in the first example. Words in each group denote same name:

  1. "mihail", "mikhail"
  2. "oolyana", "ulyana"
  3. "kooooper", "koouper"
  4. "hoon", "khun", "kkkhoon"

There are five groups of words in the second example. Words in each group denote same name:

  1. "hariton", "kkkhariton", "khariton"
  2. "hkariton"
  3. "buoi", "boooi", "boui"
  4. "bui"
  5. "boi"

In the third example the words are equal, so they denote the same name.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string* input;
string* filteru;
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  input = new string[n];
  filteru = new string[n];
  for (int i = 0; i < n; i++) {
    cin >> input[i];
  }
  for (int i = 0; i < n; i++) {
    string s = input[i];
    vector<char> v;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == 'u') {
        v.push_back('o');
        v.push_back('o');
      } else {
        v.push_back(s[j]);
      }
    }
    string s2(v.begin(), v.end());
    filteru[i] = s2;
  }
  set<string> distinct;
  for (int i = 0; i < n; i++) {
    string s = filteru[i];
    vector<char> v;
    char prev = s[s.size() - 1];
    v.push_back(prev);
    for (int j = s.size() - 2; j >= 0; j--) {
      if (prev == 'h' && s[j] == 'k') {
        prev = 'h';
      } else {
        v.push_back(s[j]);
        prev = s[j];
      }
    }
    reverse(v.begin(), v.end());
    string s2(v.begin(), v.end());
    distinct.insert(s2);
  }
  cout << distinct.size() << "\n";
}

```


### Prompt

Generate a Cpp solution to the following problem:

Given are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.

* There exists a non-negative integer j such that the concatenation of i copies of t is a substring of the concatenation of j copies of s.

Constraints

* 1 \leq |s| \leq 5 \times 10^5
* 1 \leq |t| \leq 5 \times 10^5
* s and t consist of lowercase English letters.

Input

Input is given from Standard Input in the following format:

s
t

Output

If the number of non-negative integers i satisfying the following condition is finite, print the maximum value of such i; if the number is infinite, print `-1`.

Examples

Input

abcabab
ab

Output

3

Input

aa
aaaaaaa

Output

-1

Input

aba
baaab

Output

0

### Response

```cpp
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<stdio.h>
#include<cstdio>

int v[1500001];
char s[1500001],t[500002];
void Zalgorithm(int N){
  int i=1,j=0,k=0;
  while(i<N){
    while(i+j<N&&s[i+j]==s[j])++j;
    v[i]=j;
    if(!j){
      ++i;
      continue;
    }
    k=1;
    while(v[k]+k<j){
      v[i+k]=v[k];
      ++k;
    }
    i+=k;
    j-=k;
  }
}
int i,j,K,que[500001],bf,ans,size;
int main(){
  int N,ng=500001,mid;
  std::fgets(t,1000000,stdin);
  std::fgets(s,1000000,stdin);
  while(ng-K>1){
    mid=(ng+K)>>1;
    (s[mid]?K:ng)=mid;
  }
  while(t[i]!='\n'){
    s[K+i]=t[i];++i;
  }
  N=i;
  i+=K;
  int M=N+(K<<1);
  while(i<M){
    s[i++]=t[j++];
    j*=j<N;
  }
  Zalgorithm(M);
  for(i=0;i<N;++i){
    if(v[i+K]<K)que[size++]=(i+K)%N;
  }
  for(i=0;i<N;++i){
    if(i==size){
      puts("-1");
      return 0;
    }
    if(v[que[i]+=K]>=K){
      que[size++]=que[i]%N;
      if(bf<=i){
        bf=size-1;
        ++ans;
      }
    }
  }
  printf("%d\n",ans);
}
```


### Prompt

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

The Committee for Research on Binary Viruses discovered a method of replication for a large family of viruses whose genetic codes are sequences of zeros and ones. Each virus originates from a single gene; for simplicity genes are denoted by integers from 0 to G - 1. At each moment in time a virus is a sequence of genes. When mutation occurs, one of the genes from the sequence is replaced by a certain sequence of genes, according to the mutation table. The virus stops mutating when it consists only of genes 0 and 1.

For instance, for the following mutation table: $$$ 2 → ⟨ 0\ 1 ⟩ \\\ 3 → ⟨ 2\ 0\ 0⟩\\\ 3 → ⟨ 1\ 3⟩\\\ 4 → ⟨ 0\ 3\ 1\ 2⟩\\\ 5 → ⟨ 2\ 1⟩\\\ 5 → ⟨ 5⟩  a virus that initially consisted of a single gene 4, could have mutated as follows:  ⟨ 4 ⟩ → ⟨ \underline{0\ 3\ 1\ 2} ⟩ → ⟨ 0\ \underline{2\ 0\ 0}\ 1\ 2 ⟩ → ⟨ 0\ \underline{0\ 1}\ 0\ 0\ 1\ 2 ⟩ → ⟨ 0\ 0\ 1\ 0\ 0\ 1\ \underline{0\ 1} ⟩  or in another way:  ⟨ 4 ⟩ → ⟨ \underline{0\ 3\ 1\ 2} ⟩ → ⟨ 0\ \underline{1\ 3}\ 1\ 2 ⟩ → ⟨ 0\ 1\ 3\ 1\ \underline{0\ 1} ⟩ → ⟨ 0\ 1\ \underline{2\ 0\ 0}\ 1\ 0\ 1 ⟩ → ⟨ 0\ 1\ \underline{0\ 1}\ 0\ 0\ 1\ 0\ 1 ⟩ $$$

Viruses are detected by antibodies that identify the presence of specific continuous fragments of zeros and ones in the viruses' codes. For example, an antibody reacting to a fragment ⟨ 0\ 0\ 1\ 0\ 0 ⟩ will detect a virus ⟨ 0\ 0\ 1\ 0\ 0\ 1\ 0\ 1 ⟩, but it will not detect a virus ⟨ 0\ 1\ 0\ 1\ 0\ 0\ 1\ 0\ 1 ⟩.

For each gene from 2 to G-1, the scientists are wondering whether a given set of antibodies is enough to detect all viruses that can emerge through mutations from this gene. If not, they want to know the length of the shortest virus that cannot be detected.

It may happen that sometimes scientists don't have any antibodies. Then of course no virus can be detected, so the scientists are only interested in the length of the shortest possible virus that can emerge from the gene mutations.

Input

The first line of the input will contain three integers G, N and M (G > 2, N ≥ G - 2, M ≥ 0) specifying the number of genes, the number of rows in the mutation table, and the number of antibodies.

The following N lines contain descriptions of rows of the mutation table; each line begins with two integers a and k (2 ≤ a < G, k ≥ 1), followed by a sequence of k integers b_1, b_2, …, b_k (0 ≤ b_i < G), that encode the row $$$ a → ⟨ b_1\ b_2\ …\ b_k ⟩ $$$

The sum of all values k does not exceed 100. Every integer from 2 to G - 1 appears in the table as a at least once.

The next M lines contain descriptions of the antibodies; each such line begins with an integer ℓ (ℓ ≥ 1), followed by a sequence of ℓ integers c_1, c_2, …, c_ℓ (0 ≤ c_i ≤ 1), describing the antibody. The sum of all values ℓ does not exceed 50.

Output

Your program needs to output exactly G - 2 lines, containing the answers for the subsequent genes from 2 to G - 1.

If all viruses that can mutate from this single gene can be detected by the given set of antibodies, you need to print the word "YES". You also need to print this if there are no viruses that could originate from this gene (it can happen when the sequences never stop mutating).

Otherwise you need to print the word "NO", followed by an integer denoting the minimal length of the undetectable virus. You can assume that for all the prepared input data this value will be smaller than 2^{63}.

Scoring

Subtasks:

  1. (11 points) No antibodies (M = 0)
  2. (14 points) N = G - 2
  3. (25 points) One antibody (M = 1)
  4. (32 points) The sum of all values ℓ does not exceed 10
  5. (18 points) No further constraints

Example

Input

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

Output

NO 2
NO 4
NO 9
YES

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char a = getchar();
  for (; !isdigit(a); a = getchar())
    if (a == '-') f = -1;
  for (; isdigit(a); a = getchar()) x = x * 10 + a - '0';
  return x * f;
}
const unsigned long long INF = 1ULL << 63;
const int N = 200 + 5;
const int M = 50 + 5;
int IG, IN, IM, n, ipt[N];
int issuf[N];
int vis[N][M][M];
unsigned long long f[N][M][M];
vector<pair<int, int> > ed[N];
int ch[M][2], fail[M * 2], ok[M * 2], tot = 1;
void ins(int *A, int len) {
  int x = 1;
  for (int i = 1; i <= len; i++) {
    if (!ch[x][A[i]]) ch[x][A[i]] = ++tot;
    x = ch[x][A[i]];
  }
  ok[x] = 1;
}
void buildfail() {
  queue<int> q;
  for (int i = 0; i <= 1; i++)
    if (ch[1][i])
      fail[ch[1][i]] = 1, q.push(ch[1][i]);
    else
      ch[1][i] = 1;
  while (q.size()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i <= 1; i++)
      if (ch[x][i]) {
        fail[ch[x][i]] = ch[fail[x]][i];
        ok[ch[x][i]] |= ok[fail[ch[x][i]]];
        q.push(ch[x][i]);
      } else
        ch[x][i] = ch[fail[x]][i];
  }
}
int id[M * 2], loc[M * 2];
struct Node {
  int x, fr, to;
  unsigned long long val;
  Node(int X = 0, int F = 0, int T = 0, unsigned long long V = 0)
      : x(X), fr(F), to(T), val(V) {}
  inline friend bool operator<(const Node &a, const Node &b) {
    return a.val > b.val;
  }
};
priority_queue<Node> hp;
int main() {
  IG = read() - 1;
  IN = read();
  IM = read();
  n = IG;
  for (int i = 1; i <= IN; i++) {
    int a = read(), k = read();
    for (int j = 1; j <= k; j++) ipt[j] = read(), issuf[j + n] = 1;
    for (int j = 2; j <= k; j++) {
      ed[n + j].push_back({n + j - 1, ipt[j - 1]});
      ed[ipt[j - 1]].push_back({n + j - 1, n + j});
    }
    ed[ipt[k]].push_back({n + k, -1});
    ed[n + 1].push_back({a, -1});
    n += k;
  }
  for (int i = 1; i <= IM; i++) {
    int len = read();
    for (int j = 1; j <= len; j++) ipt[j] = read();
    ins(ipt, len);
  }
  buildfail();
  int cnt = 0;
  for (int i = 1; i <= tot; i++)
    if (ok[i] == 0) id[i] = ++cnt, loc[cnt] = i;
  for (int i = 0; i <= n; i++)
    for (int j = 1; j <= cnt; j++)
      for (int k = 1; k <= cnt; k++) f[i][j][k] = INF;
  for (int i = 1; i <= cnt; i++) {
    int x = loc[i];
    if (id[ch[x][0]]) {
      f[0][i][id[ch[x][0]]] = 1;
      hp.push(Node(0, i, id[ch[x][0]], 1));
    }
    if (id[ch[x][1]]) {
      f[1][i][id[ch[x][1]]] = 1;
      hp.push(Node(1, i, id[ch[x][1]], 1));
    }
  }
  while (hp.size()) {
    Node tmp = hp.top();
    hp.pop();
    int x = tmp.x, fr = tmp.fr, to = tmp.to;
    unsigned long long val = tmp.val;
    if (vis[x][fr][to]) continue;
    vis[x][fr][to] = 1;
    for (auto e : ed[x]) {
      int y = e.first, w = e.second;
      if (w == -1) {
        if (f[y][fr][to] > val) {
          f[y][fr][to] = val;
          hp.push(Node(y, fr, to, f[y][fr][to]));
        }
      } else {
        if (issuf[x] == 0) {
          for (int j = 1; j <= cnt; j++)
            if (f[y][fr][j] > val + f[w][to][j]) {
              f[y][fr][j] = val + f[w][to][j];
              hp.push(Node(y, fr, j, f[y][fr][j]));
            }
        } else {
          for (int j = 1; j <= cnt; j++)
            if (f[y][j][to] > f[w][j][fr] + val) {
              f[y][j][to] = f[w][j][fr] + val;
              hp.push(Node(y, j, to, f[y][j][to]));
            }
        }
      }
    }
  }
  for (int i = 2; i <= IG; i++) {
    unsigned long long ans = INF;
    for (int j = 1; j <= cnt; j++) ans = min(ans, f[i][1][j]);
    if (ans == INF)
      printf("YES\n");
    else
      printf("NO %lld\n", ans);
  }
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

You are organizing a boxing tournament, where n boxers will participate (n is a power of 2), and your friend is one of them. All boxers have different strength from 1 to n, and boxer i wins in the match against boxer j if and only if i is stronger than j.

The tournament will be organized as follows: n boxers will be divided into pairs; the loser in each pair leaves the tournament, and n/2 winners advance to the next stage, where they are divided into pairs again, and the winners in all pairs advance to the next stage, and so on, until only one boxer remains (who is declared the winner).

Your friend really wants to win the tournament, but he may be not the strongest boxer. To help your friend win the tournament, you may bribe his opponents: if your friend is fighting with a boxer you have bribed, your friend wins even if his strength is lower.

Furthermore, during each stage you distribute the boxers into pairs as you wish.

The boxer with strength i can be bribed if you pay him a_i dollars. What is the minimum number of dollars you have to spend to make your friend win the tournament, provided that you arrange the boxers into pairs during each stage as you wish?

Input

The first line contains one integer n (2 ≤ n ≤ 2^{18}) — the number of boxers. n is a power of 2.

The second line contains n integers a_1, a_2, ..., a_n, where a_i is the number of dollars you have to pay if you want to bribe the boxer with strength i. Exactly one of a_i is equal to -1 — it means that the boxer with strength i is your friend. All other values are in the range [1, 10^9].

Output

Print one integer — the minimum number of dollars you have to pay so your friend wins.

Examples

Input

4
3 9 1 -1

Output

0

Input

8
11 -1 13 19 24 7 17 5

Output

12

Note

In the first test case no matter how you will distribute boxers into pairs, your friend is the strongest boxer and anyway wins the tournament.

In the second test case you can distribute boxers as follows (your friend is number 2):

1 : 2, 8 : 5, 7 : 3, 6 : 4 (boxers 2, 8, 7 and 6 advance to the next stage);

2 : 6, 8 : 7 (boxers 2 and 8 advance to the next stage, you have to bribe the boxer with strength 6);

2 : 8 (you have to bribe the boxer with strength 8);

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 20) + 5;
const int mod = 10007;
int a[N];
priority_queue<int, vector<int>, greater<int> > q;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int p = n >> 1;
  long long ans = 0;
  int now = n;
  q.push(a[n]);
  if (a[n] == -1) {
    puts("0");
    return 0;
  }
  while (1) {
    ans += q.top();
    q.pop();
    int t = p;
    while (t--) {
      now--;
      if (a[now] == -1) {
        printf("%lld", ans);
        return 0;
      }
      q.push(a[now]);
    }
    p >>= 1;
  }
  return 0;
}

```


### Prompt

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

In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads. The following are known about the road network:

* People traveled between cities only through roads. It was possible to reach any city from any other city, via intermediate cities if necessary.
* Different roads may have had different lengths, but all the lengths were positive integers.

Snuke the archeologist found a table with N rows and N columns, A, in the ruin of Takahashi Kingdom. He thought that it represented the shortest distances between the cities along the roads in the kingdom.

Determine whether there exists a road network such that for each u and v, the integer A_{u, v} at the u-th row and v-th column of A is equal to the length of the shortest path from City u to City v. If such a network exist, find the shortest possible total length of the roads.

Constraints

* 1 \leq N \leq 300
* If i ≠ j, 1 \leq A_{i, j} = A_{j, i} \leq 10^9.
* A_{i, i} = 0

Inputs

Input is given from Standard Input in the following format:

N
A_{1, 1} A_{1, 2} ... A_{1, N}
A_{2, 1} A_{2, 2} ... A_{2, N}
...
A_{N, 1} A_{N, 2} ... A_{N, N}

Outputs

If there exists no network that satisfies the condition, print `-1`. If it exists, print the shortest possible total length of the roads.

Examples

Input

3
0 1 3
1 0 2
3 2 0

Output

3

Input

3
0 1 3
1 0 1
3 1 0

Output

-1

Input

5
0 21 18 11 28
21 0 13 10 26
18 13 0 23 13
11 10 23 0 17
28 26 13 17 0

Output

82

Input

3
0 1000000000 1000000000
1000000000 0 1000000000
1000000000 1000000000 0

Output

3000000000

### Response

```cpp
#include<bits//stdc++.h>
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
typedef long long int ll;
int main() {
    int n; cin >> n; ll ans= 0; vector<vector<ll>> dp(n, vector<ll>(n,1)), G(n, vector<ll>(n));
    rep(i, n) rep(j, n) cin >> G[i][j];
    rep(i, n) {
        rep(j, n) {
            rep(k, n) {
                if (G[i][j] > G[i][k] + G[k][j]) {
                    cout << -1 << endl;
                    return 0;
                }
                else if (k != i && k != j && G[i][j] == G[i][k] + G[k][j])dp[i][j] = 0;
            }
        }
    }
    rep(i, n) rep(j, n) if (dp[i][j]) ans += G[i][j];
    cout << ans/2 << endl;
}
```


### Prompt

Create a solution in Cpp for the following problem:

Gerda is travelling to the palace of the Snow Queen.

The road network consists of n intersections and m bidirectional roads. Roads are numbered from 1 to m. Snow Queen put a powerful spell on the roads to change the weather conditions there. Now, if Gerda steps on the road i at the moment of time less or equal to i, she will leave the road exactly at the moment i. In case she steps on the road i at the moment of time greater than i, she stays there forever.

Gerda starts at the moment of time l at the intersection number s and goes to the palace of the Snow Queen, located at the intersection number t. Moreover, she has to be there at the moment r (or earlier), before the arrival of the Queen.

Given the description of the road network, determine for q queries li, ri, si and ti if it's possible for Gerda to get to the palace on time.

Input

The first line of the input contains integers n, m and q (2 ≤ n ≤ 1000, 1 ≤ m, q ≤ 200 000) — the number of intersections in the road network of Snow Queen's Kingdom, the number of roads and the number of queries you have to answer.

The i-th of the following m lines contains the description of the road number i. The description consists of two integers vi and ui (1 ≤ vi, ui ≤ n, vi ≠ ui) — the indices of the intersections connected by the i-th road. It's possible to get both from vi to ui and from ui to vi using only this road. Each pair of intersection may appear several times, meaning there are several roads connecting this pair.

Last q lines contain the queries descriptions. Each of them consists of four integers li, ri, si and ti (1 ≤ li ≤ ri ≤ m, 1 ≤ si, ti ≤ n, si ≠ ti) — the moment of time Gerda starts her journey, the last moment of time she is allowed to arrive to the palace, the index of the starting intersection and the index of the intersection where palace is located.

Output

For each query print "Yes" (without quotes) if Gerda can be at the Snow Queen palace on time (not later than ri) or "No" (without quotes) otherwise.

Example

Input

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

Output

Yes
Yes
Yes
No
No
Yes

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
using v = vector<T>;
struct query {
  int i, l, r, s, t;
  query() {}
  query(int i_, int l_, int r_, int s_, int t_)
      : i(i_), l(l_), r(r_), s(s_), t(t_) {}
};
const int N = 1000;
const int M = 200000;
const int INF = numeric_limits<int>::max();
int A[N + 1][N + 1];
int E[M + 1][2];
v<v<query>> Q(M + 1);
bitset<M + 1> result;
int main(int argc, char const* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int a, b, c, d;
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      A[i][j] = INF;
    }
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &E[i][0], &E[i][1]);
  }
  for (int i = 1; i <= q; i++) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    Q[a].push_back(query(i, a, b, c, d));
  }
  int u, v;
  for (int e = m; e >= 1; e--) {
    u = E[e][0];
    v = E[e][1];
    for (int i = 1; i <= n; i++) {
      if (A[u][i] < A[v][i]) {
        A[v][i] = A[u][i];
      } else {
        A[u][i] = A[v][i];
      }
    }
    A[u][v] = e;
    A[v][u] = e;
    for (const query& curq : Q[e]) {
      result[curq.i] = (A[curq.s][curq.t] <= curq.r);
    }
  }
  for (ll i = 1; i <= q; i++) {
    printf("%s\n", (result[i] ? "Yes" : "No"));
  }
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

You are given an undirected graph where each edge has one of two colors: black or red.

Your task is to assign a real number to each node so that:

  * for each black edge the sum of values at its endpoints is 1;
  * for each red edge the sum of values at its endpoints is 2;
  * the sum of the absolute values of all assigned numbers is the smallest possible.

Otherwise, if it is not possible, report that there is no feasible assignment of the numbers.

Input

The first line contains two integers N (1 ≤ N ≤ 100 000) and M (0 ≤ M ≤ 200 000): the number of nodes and the number of edges, respectively. The nodes are numbered by consecutive integers: 1, 2, …, N.

The next M lines describe the edges. Each line contains three integers a, b and c denoting that there is an edge between nodes a and b (1 ≤ a, b ≤ N) with color c (1 denotes black, 2 denotes red).

Output

If there is a solution, the first line should contain the word "YES" and the second line should contain N space-separated numbers. For each i (1 ≤ i ≤ N), the i-th number should be the number assigned to the node i.

Output should be such that:

  * the sum of the numbers at the endpoints of each edge differs from the precise value by less than 10^{-6};
  * the sum of the absolute values of all assigned numbers differs from the smallest possible by less than 10^{-6}.

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

If there is no solution, the only line should contain the word "NO".

Scoring

Subtasks:

  1. (5 points) N ≤ 5, M ≤ 14
  2. (12 points) N ≤ 100
  3. (17 points) N ≤ 1000
  4. (24 points) N ≤ 10 000
  5. (42 points) No further constraints

Examples

Input

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

Output

YES
0.5 0.5 1.5 -0.5

Input

2 1
1 2 1

Output

YES
0.3 0.7

Input

3 2
1 2 2
2 3 2

Output

YES
0 2 0

Input

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

Output

NO

Note

Note that in the second example the solution is not unique.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void program();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  program();
}
const int MX = 5e5;
const long long EPS = 1e-16;
int n, m;
vector<pair<int, int> > adj[MX];
long long x[MX], a[MX], b[MX];
bitset<MX> visited;
long long mustX = -1e10;
vector<long long> f;
bool possible = 1;
void resetVisited(int u) {
  if (!visited[u]) return;
  visited[u] = 0;
  for (pair<int, int> v : adj[u]) resetVisited(v.first);
}
void dfsXA(int u, long long nx, long long na) {
  if (visited[u]) {
    if (x[u] == nx) {
      if (a[u] != na) possible = 0;
    } else {
      mustX = (na - a[u]) * 2 / (x[u] - nx);
    }
    return;
  }
  visited[u] = 1;
  x[u] = nx;
  a[u] = na;
  for (pair<int, int> p : adj[u]) {
    int v = p.first;
    long long c = p.second;
    dfsXA(v, -nx, c - na);
  }
}
bool dfsPossible(int u) {
  if (visited[u]) return 1;
  visited[u] = 1;
  for (pair<int, int> p : adj[u]) {
    int v = p.first;
    long long c = p.second;
    if (!dfsPossible(v)) return 0;
    if (b[u] + b[v] != 2 * c) return 0;
  }
  return 1;
}
long long dfsSet(int u, long long X) {
  if (visited[u]) return 0;
  visited[u] = 1;
  b[u] = x[u] * X + a[u] * 2;
  long long ans = fabs(b[u]);
  for (pair<int, int> v : adj[u]) ans += dfsSet(v.first, X);
  return ans;
}
long long getTot(int u, long long X) {
  resetVisited(u);
  return dfsSet(u, X);
}
void dfsList(int u) {
  if (visited[u]) return;
  visited[u] = 1;
  f.push_back(-x[u] * a[u]);
  for (pair<int, int> v : adj[u]) dfsList(v.first);
}
int SA[MX];
void program() {
  scanf("%d%d", &n, &m);
  for (int i = int(0); i < int(m); i++) {
    int u, v, c;
    scanf("%d%d%d", &u, &v, &c);
    adj[u].push_back({v, c});
    adj[v].push_back({u, c});
  }
  visited.reset();
  for (int u = int(1); u < int(n + 1); u++) {
    if (visited[u]) continue;
    possible = 1;
    mustX = -1e10;
    dfsXA(u, 1, 0);
    if (!possible) {
      cout << "NO\n";
      return;
    }
    if (mustX != -1e10) {
      resetVisited(u);
      dfsSet(u, mustX);
      resetVisited(u);
      if (!dfsPossible(u)) {
        cout << "NO\n";
        return;
      }
    } else {
      f.clear();
      resetVisited(u);
      dfsList(u);
      sort(f.begin(), f.end());
      int N = f.size();
      long long best = f[(N - 1) / 2];
      getTot(u, best * 2);
    }
  }
  cout << "YES\n";
  for (int i = int(1); i < int(n + 1); i++) {
    if (i != 1) cout << " ";
    cout << (double)(b[i]) / 2.0;
  }
  cout << "\n";
}

```


### Prompt

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

Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you solve the following problem, I'll return it to you."

<image>

The problem is:

You are given a lucky number n. Lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

If we sort all lucky numbers in increasing order, what's the 1-based index of n?

Tavas is not as smart as SaDDas, so he asked you to do him a favor and solve this problem so he can have his headphones back.

Input

The first and only line of input contains a lucky number n (1 ≤ n ≤ 109).

Output

Print the index of n among all lucky numbers.

Examples

Input

4

Output

1

Input

7

Output

2

Input

77

Output

6

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int sol = 0, t;
  string n;
  cin >> n;
  t = n.size();
  for (int k = 0; k < t; k++) {
    if (n[k] == '7') sol = sol + 2 * pow(2, t - 1 - k);
    if (n[k] == '4') sol = sol + pow(2, t - 1 - k);
  }
  cout << sol << endl;
  return 0;
}

```


### Prompt

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

The problem uses a simplified TCP/IP address model, please make sure you've read the statement attentively.

Polycarpus has found a job, he is a system administrator. One day he came across n IP addresses. Each IP address is a 32 bit number, represented as a group of four 8-bit numbers (without leading zeroes), separated by dots. For example, the record 0.255.1.123 shows a correct IP address and records 0.256.1.123 and 0.255.1.01 do not. In this problem an arbitrary group of four 8-bit numbers is a correct IP address.

Having worked as an administrator for some time, Polycarpus learned that if you know the IP address, you can use the subnet mask to get the address of the network that has this IP addess.

The subnet mask is an IP address that has the following property: if we write this IP address as a 32 bit string, that it is representable as "11...11000..000". In other words, the subnet mask first has one or more one bits, and then one or more zero bits (overall there are 32 bits). For example, the IP address 2.0.0.0 is not a correct subnet mask as its 32-bit record looks as 00000010000000000000000000000000.

To get the network address of the IP address, you need to perform the operation of the bitwise "and" of the IP address and the subnet mask. For example, if the subnet mask is 255.192.0.0, and the IP address is 192.168.1.2, then the network address equals 192.128.0.0. In the bitwise "and" the result has a bit that equals 1 if and only if both operands have corresponding bits equal to one.

Now Polycarpus wants to find all networks to which his IP addresses belong. Unfortunately, Polycarpus lost subnet mask. Fortunately, Polycarpus remembers that his IP addresses belonged to exactly k distinct networks. Help Polycarpus find the subnet mask, such that his IP addresses will belong to exactly k distinct networks. If there are several such subnet masks, find the one whose bit record contains the least number of ones. If such subnet mask do not exist, say so.

Input

The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 105) — the number of IP addresses and networks. The next n lines contain the IP addresses. It is guaranteed that all IP addresses are distinct.

Output

In a single line print the IP address of the subnet mask in the format that is described in the statement, if the required subnet mask exists. Otherwise, print -1.

Examples

Input

5 3
0.0.0.1
0.1.1.2
0.0.2.1
0.1.1.0
0.0.2.3

Output

255.255.254.0

Input

5 2
0.0.0.1
0.1.1.2
0.0.2.1
0.1.1.0
0.0.2.3

Output

255.255.0.0

Input

2 1
255.0.0.1
0.0.0.2

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
unsigned int mas[100100];
int main() {
  int i, j, k, m, n;
  scanf("%d %d", &n, &k);
  for (i = 0; i < n; i++) {
    unsigned int a, b, c, d;
    scanf("%u.%u.%u.%u", &a, &b, &c, &d);
    mas[i] = (a << 24) + (b << 16) + (c << 8) + d;
  }
  unsigned int mask = 1u << 31;
  while (!(mask & 1)) {
    set<unsigned int> nets;
    for (i = 0; i < n; i++) {
      nets.insert(mas[i] & mask);
    }
    if (nets.size() == k) break;
    mask >>= 1u;
    mask |= 1u << 31;
  }
  if (mask & 1)
    printf("-1");
  else
    printf("%u.%u.%u.%u", mask >> 24, (mask >> 16) & 0xff, (mask >> 8) & 0xff,
           mask & 0xff);
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Once upon a time a little frog whose name was Vasya decided to travel around his home swamp. Overall there are n mounds on the swamp, located on one line. The distance between the neighboring mounds is one meter. Vasya wants to visit all the mounds in one day; besides, he wants to visit each one exactly once. For that he makes a route plan, to decide the order in which to jump on the mounds. Vasya can pick any mound as the first one. He thinks it boring to jump two times at the same distance. That's why he wants any two jumps on his route to have different lengths. Help Vasya the Frog and make the plan for him.

Input

The single line contains a number n (1 ≤ n ≤ 104) which is the number of mounds.

Output

Print n integers pi (1 ≤ pi ≤ n) which are the frog's route plan.

  * All the pi's should be mutually different.
  * All the |pi–pi + 1|'s should be mutually different (1 ≤ i ≤ n - 1).

If there are several solutions, output any.

Examples

Input

2

Output

1 2

Input

3

Output

1 3 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using namespace std;
int32_t main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= (n / 2); ++i) {
    cout << i << " " << (n - i + 1) << " ";
  }
  if (n & 1) cout << ((n + 1) / 2);
}

```


### Prompt

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

Unknown pathogen

Dr. Hideyo discovered an unknown pathogen. This pathogen has a chain structure in which two types of bacteria called Akdamakin and Zendamakin are linked in a straight line. We want to detoxify this pathogen for humankind.

It is known that this pathogen weakens when the length is 2 or less and is detoxified by immunity. Dr. Hideyo can cut this pathogen anywhere to make two chains, the first half and the second half. You can also connect two chains into one chain.

However, it should be noted that chains with a large number of Akdamakin are extremely harmful. When the number of Akdamakins in a chain exceeds the number of Zendamakins, the Akdamakins begin to grow indefinitely at that moment. This is no exception for chains with a length of 2 or less, so you must carefully cut the chains.

Is it possible to make one chain harmless by making it 2 or less in length without making a chain that has more Akdamakins at any moment? Dr. Hideyo has instructed you, your assistant, to write a program to determine if detoxification is possible. Create a program that outputs the operation if detoxification is possible, and outputs that it is impossible if it is not possible. However, the number of steps for that operation does not have to be minimal.

Input / output example

Input example

6
oooxxxx
ooooxxx
oxxooxxo
ooxx
oo
ooo

Output example

-1
7
split 0 0
join 2 1
split 3 4
split 4 0
join 7 6
split 8 2
split 9 0
3
split 0 1
split 2 1
split 4 1
-1
0
1
split 0 0

For example, the second pathogen ooooxxx in the input example
split 0 0 creates o (1) and oooxxx (2). Here, the numbers in parentheses represent identification numbers.
join 2 1 creates oooxxxo (3) and 1 and 2 disappear.
split 3 4 gives oooxx (4) and xo (5). At this time, there is a chain of {oooxx (4), xo (5)}.
split 40 produces o (6) and ooxx (7). {xo (5), o (6), ooxx (7)}
ooxxo (8) can be created by join 7 6. {xo (5), ooxxo (8)}
split 8 2 produces oox (9) and xo (10). {xo (5), oox (9), xo (10)}
The split 90 results in {xo (5), xo (10), o (11), ox (12)} and ends.

input

The input is given in the following format.

Q
str1
str2
::
strQ

The number of pathogens Q (1 ≤ Q ≤ 300) is given on the first line. The following Q line is given a single string stri consisting of'o'(Zendamakin) and'x' (Akudamakin) representing the initial state of each pathogen. The length of the string stri is 1 or more and 100 or less.

output

For stri, if there is a column of disconnect / join operations that meets the requirements, the first row of output outputs an integer n representing the length of the operation column, and the following n rows contain the operation content 1 per row. Outputs each operation in order from the first operation.

The disconnect operation should be expressed in the following format.

split a p

a is an integer representing the identification number of the chain to be cut, and p is the position to cut the chain. As a result of this operation, chain a is cleaved immediately after the p-th (serial number starting with 0) fungus from the beginning. Of the two new chains, the first half is given the identification number m + 1 and the second half is given the identification number m + 2 (where m represents the highest identification number ever assigned. ). Also, the chain a disappears.

The join operation should be expressed in the following format.

join a b

a and b are integers representing the identification numbers of the chains to be joined. The result of this operation is a new chain with the beginning of chain b joined to the end of chain a. The newly created strand is given the identification number m + 1 (where m represents the highest identification number ever given). Also, the chains a and b disappear.

The first strand given as input is given the identification number 0.

As a result of the operation, if the chain is disassembled to meet the requirements of the problem, any operation is judged to be the correct answer. The length of the operation sequence does not necessarily have to be the shortest. However, the length of the operation sequence must be 20000 or less. Whenever a chain is decomposable in a dataset, it is guaranteed that there is an operating sequence that meets this condition.

If an invalid operation sequence is output, it is judged as an incorrect answer. The illegal operation sequence includes the following cases.

* If 0 ≤ p <(length of chain a) -1 is not satisfied in the split operation split a p.
* When the identification number of the chain to be the target of the cutting / joining operation has not been generated yet, or when it has disappeared because it has already been the target of another operation.
* In the join operation join a b, if a and b are equal.

If there is no disconnect / join operation column that satisfies the request, "-1" is output.

Example

Input

6
oooxxxx
ooooxxx
oxxooxxo
ooxx
oo
ooo

Output

-1
7
split 0 0
join 2 1
split 3 4
split 4 0
join 7 6
split 8 2
split 9 0
3
split 0 1
split 2 1
split 4 1
-1
0
1
split 0 0

### Response

```cpp
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

string makeCommand(string s, int a, int b)
{
    ostringstream oss;
    oss << s << ' ' << a << ' ' << b;
    return oss.str();
}

bool solve(string s, vector<string>& ans)
{
    int n = s.size();
    ans.clear();

    int oNum = count(s.begin(), s.end(), 'o');
    int xNum = s.size() - oNum;
    if(oNum < xNum){
        return false;
    }
    else if(oNum == xNum){
        bool ng = false;
        for(int i=0; i<n; i+=2){
            if(s[i] == s[i+1])
                ng = true;
        }
        if(ng)
            return false;
    }

    int index = 0;
    while(n > 2){
        if(s.find('x') == string::npos){
            ans.push_back(makeCommand("split", index, 1));
            index += 2;
            s = s.substr(2);
            n -= 2;
        }
        else if(s[0] != s[1]){
            ans.push_back(makeCommand("split", index, 1));
            index += 2;
            s = s.substr(2);
            n -= 2;
        }
        else if(s[n-2] != s[n-1]){
            ans.push_back(makeCommand("split", index, n - 3));
            index += 2;
            s = s.substr(0, n - 2);
            n -= 2;
        }
        else{
            int cnt1 = 0;
            int cnt2 = n - count(s.begin(), s.end(), 'x') * 2;
            for(int i=0; ; ++i){
                if(s[i] == 'o'){
                    ++ cnt1;
                    -- cnt2;
                }
                else{
                    -- cnt1;
                    ++ cnt2;
                }
                if(cnt1 >= 0 && cnt2 >= 0){
                    ans.push_back(makeCommand("split", index, i));
                    ans.push_back(makeCommand("join", index + 2, index + 1));
                    s = s.substr(i+1) + s.substr(0, i+1);
                    break;
                }
            }
            index += 3;
        }
    }

    return true;
}

int main()
{
    int q;
    cin >> q;

    while(--q >= 0){
        string s;
        cin >> s;

        vector<string> ans;
        if(solve(s, ans)){
            cout << ans.size() << endl;
            for(const string& t : ans)
                cout << t << endl;
        }
        else{
            cout << -1 << endl;
        }
    }

    return 0;
}
```


### Prompt

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

From tomorrow, the long-awaited summer vacation will begin. So I decided to invite my friends to go out to the sea.

However, many of my friends are shy. They would hate it if they knew that too many people would come with them.

Besides, many of my friends want to stand out. They will probably hate it if they know that not many people come with them.

Also, some of my friends are always shy, though they always want to stand out. They will surely hate if too many or too few people come with them.

This kind of thing should be more fun to do in large numbers. That's why I want to invite as many friends as possible. However, it is not good to force a friend you dislike.

How many friends can I invite up to?

I'm not very good at this kind of problem that seems to use my head. So I have a request for you. If you don't mind, could you solve this problem for me? No, I'm not overdoing it. But if I'm slacking off, I'm very happy.

Input

N
a1 b1
a2 b2
..
..
..
aN bN

The integer N (1 ≤ N ≤ 100,000) is written on the first line of the input. This represents the number of friends.

On the following N lines, the integer ai and the integer bi (2 ≤ ai ≤ bi ≤ 100,001) are written separated by blanks. The integers ai and bi written on the 1 + i line indicate that the i-th friend does not want to go to the sea unless the number of people going to the sea is ai or more and bi or less. Note that the number of people going to the sea includes "I".

Output

Output the maximum number of friends you can invite to the sea so that no friends dislike it.

Examples

Input

4
2 5
4 7
2 4
3 6

Output

3

Input

5
8 100001
7 100001
12 100001
8 100001
3 100001

Output

0

Input

6
2 9
4 8
6 7
6 6
5 7
2 100001

Output

5

### Response

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

#define MAX 100002

int main() {
  int n;
  int a, b;
  int v[MAX] = {};

  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a >> b;
    v[a] ++;
    v[b+1] --;
  }

  int now = 0;
  int ans = 0;
  for(int i=0; i<MAX; i++) {
    now += v[i];
    if(i <= now+1) ans = i-1;
  }

  cout << ans << endl;

  return 0;
}
```