### Prompt

Generate a cpp solution to the following problem:

You are given an integer N. Consider an infinite N-ary tree as shown below:

<image>

Figure: an infinite N-ary tree for the case N = 3

As shown in the figure, each vertex is indexed with a unique positive integer, and for every positive integer there is a vertex indexed with it. The root of the tree has the index 1. For the remaining vertices, vertices in the upper row have smaller indices than those in the lower row. Among the vertices in the same row, a vertex that is more to the left has a smaller index.

Regarding this tree, process Q queries. The i-th query is as follows:

* Find the index of the lowest common ancestor (see Notes) of Vertex v_i and w_i.

Constraints

* 1 ≤ N ≤ 10^9
* 1 ≤ Q ≤ 10^5
* 1 ≤ v_i < w_i ≤ 10^9

Input

Input is given from Standard Input in the following format:

N Q
v_1 w_1
:
v_Q w_Q

Output

Print Q lines. The i-th line (1 ≤ i ≤ Q) must contain the index of the lowest common ancestor of Vertex v_i and w_i.

Examples

Input

3 3
5 7
8 11
3 9

Output

2
1
3

Input

100000 2
1 2
3 4

Output

1
1

### Response

```cpp
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;

int main(void){
  int n,q,i,v,w;

  cin >> n >> q;

  if (n==1){
    for (i=0;i<q;i++){
      cin >> v >> w;
      cout << v << endl;
    }
    return 0;
  }

  for (i=0;i<q;i++){
    cin >> v >> w;
    set<int> s;
    while (v>0){
      s.insert(v);
      v=(v+n-2)/n;
    }
    while (1){
      if (s.find(w)!=s.end()) break;
      w=(w+n-2)/n;
    }
    cout << w << endl;
  }

  return 0;
}
```


### Prompt

Please formulate a Cpp solution to the following problem:

You are given a tree with N vertices.
Here, a tree is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices.
The i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i.

You are also given Q queries and an integer K. In the j-th query (1≤j≤Q):

* find the length of the shortest path from Vertex x_j and Vertex y_j via Vertex K.

Constraints

* 3≤N≤10^5
* 1≤a_i,b_i≤N (1≤i≤N-1)
* 1≤c_i≤10^9 (1≤i≤N-1)
* The given graph is a tree.
* 1≤Q≤10^5
* 1≤K≤N
* 1≤x_j,y_j≤N (1≤j≤Q)
* x_j≠y_j (1≤j≤Q)
* x_j≠K,y_j≠K (1≤j≤Q)

Input

Input is given from Standard Input in the following format:

N
a_1 b_1 c_1
:
a_{N-1} b_{N-1} c_{N-1}
Q K
x_1 y_1
:
x_{Q} y_{Q}

Output

Print the responses to the queries in Q lines.
In the j-th line j(1≤j≤Q), print the response to the j-th query.

Examples

Input

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

Output

3
2
4

Input

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

Output

5
14
22

Input

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

Output

17000000000

### Response

```cpp
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 100001
using namespace std;
int a[N*2][3],g[N];
long long dis[N];
int n,m,k;
void ins(int x,int y,int z){
	static int sum=1;
	a[++sum][0]=y,a[sum][1]=z,a[sum][2]=g[x],g[x]=sum;
}
void dfs(int x,int fa){
	for (int i=g[x];i;i=a[i][2])
		if (fa!=a[i][0]){
			dis[a[i][0]]=dis[x]+a[i][1];
			dfs(a[i][0],x);
		}
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
		ins(x,y,z),ins(y,x,z);
	}
	scanf("%d %d",&m,&k);
	dfs(k,0);
	while (m--){
		int x,y;
		scanf("%d %d",&x,&y);
		cout<<dis[x]+dis[y]<<endl;
	}
	return 0;
}
```


### Prompt

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

Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written.

He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.

Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.

Constraints

* 3 ≦ N ≦ 10^{5}
* N is odd.
* 1 ≦ A_i ≦ 10^{5}
* A_i is an integer.

Input

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

N
A_1 A_2 A_3 ... A_{N}

Output

Print the answer.

Examples

Input

5
1 2 1 3 7

Output

3

Input

15
1 3 5 2 1 3 2 8 8 6 2 6 11 1 1

Output

7

### Response

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

#define rep(i, n) for(int i = 0; i < (n); i++)

int main()
{
    int N; cin >>N;
    unordered_set<int> s;
    rep(i, N) {
        int A; cin >> A;
        s.insert(A);
    }
    int uniq = s.size();
    int dup = N-uniq;

    cout << uniq-(dup%2) << endl;
}

```


### Prompt

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

Valera is a coder. Recently he wrote a funny program. The pseudo code for this program is given below:

    //input: integers x, k, p
    a = x;
    for(step = 1; step <= k; step = step + 1){
        rnd = [random integer from 1 to 100];
        if(rnd <= p)
            a = a * 2;
        else
            a = a + 1;
    }

    s = 0;

    while(remainder after dividing a by 2 equals 0){
        a = a / 2;
        s = s + 1;
    }

Now Valera wonders: given the values x, k and p, what is the expected value of the resulting number s?

Input

The first line of the input contains three integers x, k, p (1 ≤ x ≤ 109; 1 ≤ k ≤ 200; 0 ≤ p ≤ 100).

Output

Print the required expected value. Your answer will be considered correct if the absolute or relative error doesn't exceed 10 - 6.

Examples

Input

1 1 50

Output

1.0000000000000

Input

5 3 0

Output

3.0000000000000

Input

5 3 25

Output

1.9218750000000

Note

If the concept of expected value is new to you, you can read about it by the link:

http://en.wikipedia.org/wiki/Expected_value

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int X, K, P;
double dp[203][260][2][260];
int main() {
  scanf("%d%d%d", &X, &K, &P);
  double prob = 0.01 * P;
  int bm = X & 255;
  int last = (X >> 8) & 1;
  int tmp = X >> 8;
  int cnt = 0;
  while (tmp && (tmp & 1) == last) {
    ++cnt;
    tmp >>= 1;
  }
  dp[0][bm][last][cnt] = 1.0;
  for (int k = 0; k < K; ++k) {
    for (int i = 0; i < 256; ++i) {
      for (int j = 0; j < 2; ++j) {
        for (int cnt = 0; cnt < 240; ++cnt) {
          int new_bm = i << 1;
          int new_cnt, new_last;
          if (new_bm & 256) {
            new_last = 1;
            if (j == 1) {
              new_cnt = cnt + 1;
            } else {
              new_cnt = 1;
            }
          } else {
            new_last = 0;
            if (j == 1) {
              new_cnt = 1;
            } else {
              new_cnt = (cnt == 0 ? 0 : cnt + 1);
            }
          }
          new_bm &= 255;
          dp[k + 1][new_bm][new_last][new_cnt] += prob * dp[k][i][j][cnt];
          new_bm = i + 1;
          if (new_bm & 256) {
            if (j == 1) {
              new_last = 0;
              new_cnt = cnt;
            } else {
              new_last = 1;
              new_cnt = 1;
            }
          } else {
            new_last = j;
            new_cnt = cnt;
          }
          new_bm &= 255;
          dp[k + 1][new_bm][new_last][new_cnt] +=
              (1.0 - prob) * dp[k][i][j][cnt];
        }
      }
    }
  }
  double ans = 0;
  for (int i = 0; i < 256; ++i) {
    for (int j = 0; j < 2; ++j) {
      for (int cnt = 0; cnt < 240; ++cnt) {
        int val = 0;
        if (j == 1 || i & 255) {
          if (i & 255) {
            int lsb = i & ((~i) + 1);
            while (lsb > 1) {
              ++val;
              lsb >>= 1;
            }
          } else
            val = 8;
        } else {
          val = (cnt > 0 ? cnt + 8 : 0);
        }
        ans += dp[K][i][j][cnt] * val;
      }
    }
  }
  printf("%.12lf\n", ans);
  return 0;
}

```


### Prompt

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

Lunar New Year is approaching, and Bob is going to receive some red envelopes with countless money! But collecting money from red envelopes is a time-consuming process itself.

Let's describe this problem in a mathematical way. Consider a timeline from time 1 to n. The i-th red envelope will be available from time s_i to t_i, inclusive, and contain w_i coins. If Bob chooses to collect the coins in the i-th red envelope, he can do it only in an integer point of time between s_i and t_i, inclusive, and he can't collect any more envelopes until time d_i (inclusive) after that. Here s_i ≤ t_i ≤ d_i holds.

Bob is a greedy man, he collects coins greedily — whenever he can collect coins at some integer time x, he collects the available red envelope with the maximum number of coins. If there are multiple envelopes with the same maximum number of coins, Bob would choose the one whose parameter d is the largest. If there are still multiple choices, Bob will choose one from them randomly.

However, Alice — his daughter — doesn't want her father to get too many coins. She could disturb Bob at no more than m integer time moments. If Alice decides to disturb Bob at time x, he could not do anything at time x and resumes his usual strategy at the time x + 1 (inclusive), which may lead to missing some red envelopes.

Calculate the minimum number of coins Bob would get if Alice disturbs him optimally.

Input

The first line contains three non-negative integers n, m and k (1 ≤ n ≤ 10^5, 0 ≤ m ≤ 200, 1 ≤ k ≤ 10^5), denoting the length of the timeline, the number of times Alice can disturb Bob and the total number of red envelopes, respectively.

The following k lines describe those k red envelopes. The i-th line contains four positive integers s_i, t_i, d_i and w_i (1 ≤ s_i ≤ t_i ≤ d_i ≤ n, 1 ≤ w_i ≤ 10^9) — the time segment when the i-th envelope is available, the time moment Bob can continue collecting after collecting the i-th envelope, and the number of coins in this envelope, respectively.

Output

Output one integer — the minimum number of coins Bob would get if Alice disturbs him optimally.

Examples

Input

5 0 2
1 3 4 5
2 5 5 8

Output

13

Input

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

Output

2

Input

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

Output

11

Note

In the first sample, Alice has no chance to disturb Bob. Therefore Bob will collect the coins in the red envelopes at time 1 and 5, collecting 13 coins in total.

In the second sample, Alice should disturb Bob at time 1. Therefore Bob skips the first envelope, collects the second one and can not do anything after that. So the answer is 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
multiset<pair<long long, long long> > s;
vector<vector<pair<long long, long long> > > st, en;
vector<pair<long long, long long> > gud;
long long n, m, k;
long long dp[100009][210];
long long f(long long pos, long long baki) {
  if (pos > n) return 0;
  long long &res = dp[pos][baki];
  if (res != -1) return dp[pos][baki];
  long long nxt = gud[pos].second;
  if (nxt == 0) nxt = pos;
  res = gud[pos].first + f(nxt + 1, baki);
  if (baki > 0) res = min(res, f(pos + 1, baki - 1));
  return res;
}
int main() {
  cin >> n >> m >> k;
  gud.assign(n + 4, pair<long long, long long>(0, 0));
  st.assign(n + 4, vector<pair<long long, long long> >());
  en.assign(n + 4, vector<pair<long long, long long> >());
  memset(dp, -1, sizeof dp);
  for (long long i = 0; i < k; i++) {
    long long si, ti, di, wi;
    cin >> si >> ti >> di >> wi;
    st[si].push_back(pair<long long, long long>(wi, di));
    en[ti].push_back(pair<long long, long long>(wi, di));
  }
  for (long long i = 1; i <= n; i++) {
    for (auto pr : st[i]) s.insert(pr);
    if (s.size() > 0) gud[i] = *(s.rbegin());
    for (auto pr : en[i]) s.erase(s.find(pr));
  }
  cout << f(1, m);
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

You are given a rooted tree on n vertices, its root is the vertex number 1. The i-th vertex contains a number w_i. Split it into the minimum possible number of vertical paths in such a way that each path contains no more than L vertices and the sum of integers w_i on each path does not exceed S. Each vertex should belong to exactly one path.

A vertical path is a sequence of vertices v_1, v_2, …, v_k where v_i (i ≥ 2) is the parent of v_{i - 1}.

Input

The first line contains three integers n, L, S (1 ≤ n ≤ 10^5, 1 ≤ L ≤ 10^5, 1 ≤ S ≤ 10^{18}) — the number of vertices, the maximum number of vertices in one path and the maximum sum in one path.

The second line contains n integers w_1, w_2, …, w_n (1 ≤ w_i ≤ 10^9) — the numbers in the vertices of the tree.

The third line contains n - 1 integers p_2, …, p_n (1 ≤ p_i < i), where p_i is the parent of the i-th vertex in the tree.

Output

Output one number — the minimum number of vertical paths. If it is impossible to split the tree, output -1.

Examples

Input

3 1 3
1 2 3
1 1

Output

3

Input

3 3 6
1 2 3
1 1

Output

2

Input

1 1 10000
10001

Output

-1

Note

In the first sample the tree is split into \{1\},\ \{2\},\ \{3\}.

In the second sample the tree is split into \{1,\ 2\},\ \{3\} or \{1,\ 3\},\ \{2\}.

In the third sample it is impossible to split the tree.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, L, S;
int w[100001];
int p[100001];
int d[100001];
bool vis[100001];
vector<int> at[100001];
int ret = 0;
void solve(int cur) {
  if (vis[cur]) return;
  ret++;
  long long weight = S;
  int cnt = L;
  while (weight - w[cur] >= 0 && cnt - 1 >= 0 && cur) {
    weight -= w[cur];
    cnt--;
    vis[cur] = 1;
    cur = p[cur];
  }
}
int main() {
  cout << setprecision(10);
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> L >> S;
  for (int i = 1; i <= n; i++) {
    cin >> w[i];
    if (w[i] > S) {
      cout << -1 << '\n';
      return 0;
    }
  }
  for (int i = 2; i <= n; i++) {
    cin >> p[i];
    d[i] = d[p[i]] + 1;
    at[d[i]].push_back(i);
  }
  at[0].push_back(1);
  for (int dep = n; dep >= 0; dep--)
    for (auto e : at[dep]) solve(e);
  cout << ret << '\n';
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

The Third Doctor Who once correctly said that travel between parallel universes is "like travelling sideways". However, he incorrectly thought that there were infinite parallel universes, whereas in fact, as we now all know, there will never be more than 250.

Heidi recently got her hands on a multiverse observation tool. She was able to see all n universes lined up in a row, with non-existent links between them. She also noticed that the Doctor was in the k-th universe.

The tool also points out that due to restrictions originating from the space-time discontinuum, the number of universes will never exceed m.

Obviously, the multiverse is unstable because of free will. Each time a decision is made, one of two events will randomly happen: a new parallel universe is created, or a non-existent link is broken.

More specifically,

  * When a universe is created, it will manifest itself between any two adjacent universes or at one of the ends.
  * When a link is broken, it could be cut between any two adjacent universes. After separating the multiverse into two segments, the segment NOT containing the Doctor will cease to exist.

Heidi wants to perform a simulation of t decisions. Each time a decision is made, Heidi wants to know the length of the multiverse (i.e. the number of universes), and the position of the Doctor.

Input

The first line contains four integers n, k, m and t (2 ≤ k ≤ n ≤ m ≤ 250, 1 ≤ t ≤ 1000).

Each of the following t lines is in one of the following formats:

  * "1 i" — meaning that a universe is inserted at the position i (1 ≤ i ≤ l + 1), where l denotes the current length of the multiverse.
  * "0 i" — meaning that the i-th link is broken (1 ≤ i ≤ l - 1), where l denotes the current length of the multiverse.

Output

Output t lines. Each line should contain l, the current length of the multiverse and k, the current position of the Doctor.

It is guaranteed that the sequence of the steps will be valid, i.e. the multiverse will have length at most m and when the link breaking is performed, there will be at least one universe in the multiverse.

Example

Input

5 2 10 4
0 1
1 1
0 4
1 2

Output

4 1
5 2
4 2
5 3

Note

The multiverse initially consisted of 5 universes, with the Doctor being in the second.

First, link 1 was broken, leaving the multiverse with 4 universes, and the Doctor in the first.

Then, a universe was added to the leftmost end of the multiverse, increasing the multiverse length to 5, and the Doctor was then in the second universe.

Then, the rightmost link was broken.

Finally, a universe was added between the first and the second universe.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) { cout << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ' ';
  err(++it, args...);
}
int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
int ini() {
  int x;
  scanf("%d", &x);
  return x;
}
long long inl() {
  long long x;
  scanf("%lld", &x);
  return x;
}
int set_1(int n, int pos) { return n = (n | (1 << pos)); }
int reset_0(int n, int pos) { return n = n & ~(1 << pos); }
bool check_bit(int n, int pos) { return n = n & (1 << pos); }
const int N = (int)1e6 + 5;
const int M = (int)1e9 + 7;
const double pi = 2 * acos(0.0);
int main() {
  int n, k, m, t;
  cin >> n >> k >> m >> t;
  int pos = k, sz = n;
  while (t--) {
    int op, x;
    cin >> op >> x;
    if (op == 0) {
      if (x < pos) {
        pos = pos - x;
        sz = sz - x;
      } else if (x > pos) {
        sz = x;
      } else {
        sz = pos;
      }
    } else {
      sz++;
      if (x <= pos) {
        pos += 1;
      }
    }
    cout << sz << " " << pos << endl;
  }
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Consider a tree T (that is, a connected graph without cycles) with n vertices labelled 1 through n. We start the following process with T: while T has more than one vertex, do the following:

  * choose a random edge of T equiprobably;
  * shrink the chosen edge: if the edge was connecting vertices v and u, erase both v and u and create a new vertex adjacent to all vertices previously adjacent to either v or u. The new vertex is labelled either v or u equiprobably.

At the end of the process, T consists of a single vertex labelled with one of the numbers 1, …, n. For each of the numbers, what is the probability of this number becoming the label of the final vertex?

Input

The first line contains a single integer n (1 ≤ n ≤ 50).

The following n - 1 lines describe the tree edges. Each of these lines contains two integers u_i, v_i — labels of vertices connected by the respective edge (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i). It is guaranteed that the given graph is a tree.

Output

Print n floating numbers — the desired probabilities for labels 1, …, n respectively. All numbers should be correct up to 10^{-6} relative or absolute precision.

Examples

Input

4
1 2
1 3
1 4

Output

0.1250000000
0.2916666667
0.2916666667
0.2916666667

Input

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

Output

0.0850694444
0.0664062500
0.0664062500
0.1955295139
0.1955295139
0.1955295139
0.1955295139

Note

In the first sample, the resulting vertex has label 1 if and only if for all three edges the label 1 survives, hence the probability is 1/2^3 = 1/8. All other labels have equal probability due to symmetry, hence each of them has probability (1 - 1/8) / 3 = 7/24.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 55;
vector<int> g[N];
double f[N][N], F[N], tmp[N], C[N][N];
int n, siz[N];
void Solve(int x, int fa) {
  f[x][0] = 1;
  siz[x] = 1;
  for (int v : g[x]) {
    if (v == fa) continue;
    Solve(v, x);
    double pob = 1. / siz[v];
    for (int i = 0; i <= siz[v]; i++) F[i] = 0;
    for (int i = 0; i <= siz[v]; i++)
      for (int j = 0; j < siz[v]; j++)
        if (j < i)
          F[i] += pob * f[v][i - 1];
        else
          F[i] += 0.5 * pob * f[v][j];
    for (int i = 0; i < siz[x]; i++) tmp[i] = f[x][i], f[x][i] = 0;
    for (int i = 0; i < siz[x]; i++)
      for (int j = 0; j <= siz[v]; j++) {
        f[x][i + j] += F[j] * tmp[i] * C[siz[x] - 1][i] * C[siz[v]][j] /
                       C[siz[x] - 1 + siz[v]][i + j];
      }
    siz[x] += siz[v];
  }
}
int main(void) {
  scanf("%d", &n);
  C[0][0] = 1;
  for (int i = 1; i < n; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    memset(f, 0, sizeof f);
    Solve(i, 0);
    printf("%.10f\n", f[i][0]);
  }
  return 0;
}

```


### Prompt

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

Dr. Fukuoka has placed a simple robot in a two-dimensional maze. It moves within the maze and never goes out of the maze as there is no exit.

The maze is made up of H × W grid cells as depicted below. The upper side of the maze faces north. Consequently, the right, lower and left sides face east, south and west respectively. Each cell is either empty or wall and has the coordinates of (i, j) where the north-west corner has (1, 1). The row i goes up toward the south and the column j toward the east.

<image>

The robot moves on empty cells and faces north, east, south or west. It goes forward when there is an empty cell in front, and rotates 90 degrees to the right when it comes in front of a wall cell or on the edge of the maze. It cannot enter the wall cells. It stops right after moving forward by L cells.

Your mission is, given the initial position and direction of the robot and the number of steps, to write a program to calculate the final position and direction of the robot.

Input

The input is a sequence of datasets. Each dataset is formatted as follows.

H W L
c1,1c1,2...c1,W
.
.
.
cH,1cH,2...cH,W

The first line of a dataset contains three integers H, W and L (1 ≤ H, W ≤ 100, 1 ≤ L ≤ 1018).

Each of the following H lines contains exactly W characters. In the i-th line, the j-th character ci,j represents a cell at (i, j) of the maze. "." denotes an empty cell. "#" denotes a wall cell. "N", "E", "S", "W" denote a robot on an empty cell facing north, east, south and west respectively; it indicates the initial position and direction of the robot.

You can assume that there is at least one empty cell adjacent to the initial position of the robot.

The end of input is indicated by a line with three zeros. This line is not part of any dataset.

Output

For each dataset, output in a line the final row, column and direction of the robot, separated by a single space. The direction should be one of the following: "N" (north), "E" (east), "S" (south) and "W" (west).

No extra spaces or characters are allowed.

Examples

Input

3 3 10
E..
.#.
...
5 5 19
####.
.....
.#S#.
...#.
#.##.
5 5 6
#.#..
#....
##.#.
#..S.
#....
5 4 35
..##
....
.##.
.#S.
...#
0 0 0

Output

1 3 E
4 5 S
4 4 E
1 1 N

Input

3 3 10
E..
.#.
...
5 5 19
.
.....
.#S#.
...#.
.##.
5 5 6
.#..
....
.#.
..S.
....
5 4 35
..##
....
.##.
.#S.
...#
0 0 0

Output

1 3 E
4 5 S
4 4 E
1 1 N

### Response

```cpp
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int mod = 1000000007;
const int INF = 1e12;

char c[110][110];
int d[110][110][4];
int h, w, l;
string str = "NESW";
int dy[4] = {-1, 0, 1, 0};
int dx[4] = { 0, 1, 0,-1};
bool contain(int y, int x){
   return (0 <= y && y < h && 0 <= x && x < w);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1){
        cin >> h >> w >> l;
        if(h + w + l == 0) break;
        int dr = 0, y = 0, x = 0;
        rep(i, 0, 110) rep(j, 0, 110) rep(k, 0, 4) d[i][j][k] = -1;
        rep(i, 0, h){
            rep(j, 0, w){
                cin >> c[i][j];
                if(str.find(c[i][j]) != string::npos){
                    dr = str.find(c[i][j]);
                    y = i; x = j;
                }
            }
        }
        d[y][x][dr] = 0;
        vector<PP> sv;
        sv.push_back(PP(P(y, x), dr));
        for(int i = 1;; i++){
            int ny = 0, nx = 0;
            while(1){
                ny = y + dy[dr];
                nx = x + dx[dr];
                if(contain(ny, nx) && c[ny][nx] != '#'){
                    break;
                }
                dr = (dr + 1) % 4;
            }
            y = ny; x = nx;
            if(i == l){
                cout << y + 1 << ' ' << x + 1 << ' ' << str[dr] << endl;
                break;
            }
            if(d[y][x][dr] != -1){
                int loop = i - d[y][x][dr];
                int step = d[y][x][dr] + (l - d[y][x][dr]) % loop;
                //cerr << loop << ' ' << step << endl;
                cout << sv[step].first.first + 1 << ' ' << sv[step].first.second + 1 << ' ' << str[sv[step].second] << endl;
                break;
            }
            d[y][x][dr] = i;
            sv.push_back(PP(P(y, x), dr));
        }
    }
}

```


### Prompt

Create a solution in cpp for the following problem:

a is an array of n positive integers, all of which are not greater than n.

You have to process q queries to this array. Each query is represented by two numbers p and k. Several operations are performed in each query; each operation changes p to p + ap + k. There operations are applied until p becomes greater than n. The answer to the query is the number of performed operations.

Input

The first line contains one integer n (1 ≤ n ≤ 100000).

The second line contains n integers — elements of a (1 ≤ ai ≤ n for each i from 1 to n).

The third line containts one integer q (1 ≤ q ≤ 100000).

Then q lines follow. Each line contains the values of p and k for corresponding query (1 ≤ p, k ≤ n).

Output

Print q integers, ith integer must be equal to the answer to ith query.

Example

Input

3
1 1 1
3
1 1
2 1
3 1

Output

2
1
1

Note

Consider first example:

In first query after first operation p = 3, after second operation p = 5.

In next two queries p is greater than n after the first operation.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, e, dp[100009][320], f[100009], q, sq;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> a;
  for (b = 1; b <= a; b++) cin >> f[b];
  sq = sqrt(a);
  for (c = 1; c <= sq; c++) {
    for (d = a; d >= 1; d--) dp[d][c] = 1;
    for (d = a; d >= 1; d--) {
      if (d + f[d] + c > a) continue;
      dp[d][c] = dp[d + f[d] + c][c] + 1;
    }
  }
  cin >> q;
  for (b = 1; b <= q; b++) {
    cin >> c >> d;
    if (d <= sq) {
      cout << dp[c][d] << endl;
    } else {
      e = c;
      int h = 1;
      while (e <= a) {
        if (f[e] + e + d > a) break;
        h++;
        e = f[e] + e + d;
      }
      cout << h << endl;
    }
  }
  return 0;
}

```


### Prompt

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

Vasya goes to visit his classmate Petya. Vasya knows that Petya's apartment number is n.

There is only one entrance in Petya's house and the distribution of apartments is the following: the first floor contains 2 apartments, every other floor contains x apartments each. Apartments are numbered starting from one, from the first floor. I.e. apartments on the first floor have numbers 1 and 2, apartments on the second floor have numbers from 3 to (x + 2), apartments on the third floor have numbers from (x + 3) to (2 ⋅ x + 2), and so on.

Your task is to find the number of floor on which Petya lives. Assume that the house is always high enough to fit at least n apartments.

You have to answer t independent test cases.

Input

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

The only line of the test case contains two integers n and x (1 ≤ n, x ≤ 1000) — the number of Petya's apartment and the number of apartments on each floor of the house except the first one (there are two apartments on the first floor).

Output

For each test case, print the answer: the number of floor on which Petya lives.

Example

Input

4
7 3
1 5
22 5
987 13

Output

3
1
5
77

Note

Consider the first test case of the example: the first floor contains apartments with numbers 1 and 2, the second one contains apartments with numbers 3, 4 and 5, the third one contains apartments with numbers 6, 7 and 8. Therefore, Petya lives on the third floor.

In the second test case of the example, Petya lives in the apartment 1 which is on the first floor.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x;
    float ans;
    cin >> n;
    cin >> x;
    n = n - 2;
    if (n < 1)
      ans = 1;
    else {
      ans = ceil((float)n / x);
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

This night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either — although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the losestreak only grew longer and longer... It's no wonder he didn't get any sleep this night at all.

In the morning, Vasya was waiting the bus to the university on the bus stop. Vasya's thoughts were hazy and so he couldn't remember the right bus' number quite right and got onto the bus with the number n.

In the bus, Vasya thought that he could get the order of the digits in the number of the bus wrong. Futhermore, he could "see" some digits several times, but the digits he saw were definitely in the real number of the bus. For example, if Vasya saw the number 2028, it could mean that the real bus number could be 2028, 8022, 2820 or just 820. However, numbers 80, 22208, 52 definitely couldn't be the number of the bus. Also, real bus number couldn't start with the digit 0, this meaning that, for example, number 082 couldn't be the real bus number too.

Given n, determine the total number of possible bus number variants.

Input

The first line contains one integer n (1 ≤ n ≤ 10^{18}) — the number of the bus that was seen by Vasya. It is guaranteed that this number does not start with 0.

Output

Output a single integer — the amount of possible variants of the real bus number.

Examples

Input

97

Output

2

Input

2028

Output

13

Note

In the first sample, only variants 97 and 79 are possible.

In the second sample, the variants (in the increasing order) are the following: 208, 280, 802, 820, 2028, 2082, 2208, 2280, 2802, 2820, 8022, 8202, 8220.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
long long fact[20];
string str;
int n;
long long getAns() {
  map<vector<int>, bool> taken;
  long long ans = 0LL;
  int minCnt = 0;
  bool exists[10] = {};
  for (long long i = 0; i < (n); ++i)
    if (!exists[str[i] - 48]) {
      exists[str[i] - 48] = true;
      ++minCnt;
    }
  for (long long i = 0; i < ((1 << n)); ++i) {
    vector<int> cnt(10);
    int curCnt = 0;
    int tempN = 0;
    for (long long j = 0; j < (n); ++j)
      if (i & (1 << j)) ++cnt[str[j] - 48];
    for (long long i = 0; i < (10); ++i)
      if (cnt[i]) {
        tempN += cnt[i];
        ++curCnt;
      }
    if (curCnt != minCnt) continue;
    if (!taken[cnt]) {
      taken[cnt] = true;
      long long temp = fact[tempN];
      for (long long i = 0; i < (10); ++i) temp /= fact[cnt[i]];
      if (cnt[0]) {
        long long diff = fact[tempN - 1];
        --cnt[0];
        for (long long i = 0; i < (10); ++i) diff /= fact[cnt[i]];
        temp -= diff;
      }
      ans += temp;
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> str;
  n = str.length();
  fact[0] = 1LL;
  for (long long i = (1); i < (20); ++i) fact[i] = fact[i - 1] * i;
  cout << getAns() << '\n';
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Game field is represented by a line of n square cells. In some cells there are packmen, in some cells there are asterisks and the rest of the cells are empty. Packmen eat asterisks.

Before the game starts you can choose a movement direction, left or right, for each packman. Once the game begins all the packmen simultaneously start moving according their directions. A packman can't change the given direction.

Once a packman enters a cell containing an asterisk, packman immediately eats the asterisk. Once the packman leaves the cell it becomes empty. Each packman moves at speed 1 cell per second. If a packman enters a border cell, the packman stops. Packmen do not interfere with the movement of other packmen; in one cell there can be any number of packmen moving in any directions.

Your task is to assign a direction to each packman so that they eat the maximal number of asterisks. If there are multiple ways to assign directions to eat the maximal number of asterisks, you should choose the way which minimizes the time to do that.

Input

The first line contains integer number n (2 ≤ n ≤ 1 000 000) — the number of cells in the game field.

The second line contains n characters. If the i-th character is '.', the i-th cell is empty. If the i-th character is '*', the i-th cell contains an asterisk. If the i-th character is 'P', the i-th cell contains a packman.

The field contains at least one asterisk and at least one packman.

Output

Print two integer numbers — the maximal number of asterisks packmen can eat and the minimal time to do it.

Examples

Input

6
*.P*P*

Output

3 4

Input

8
*...P..*

Output

1 3

Note

In the first example the leftmost packman should move to the right, the rightmost packman should move to the left. All the asterisks will be eaten, the last asterisk will be eaten after 4 seconds.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x, y;
  y = scanf("%d", &x);
  return x;
}
const int MAXN = 2e6 + 10;
int n, p[MAXN], sec[MAXN], pt[MAXN];
string s;
int nxt[MAXN], prv[MAXN];
int d[MAXN][2];
bool ok(int mid, int sz) {
  memset(d, 0, sizeof(d));
  d[0][0] = d[0][1] = 1;
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] == '.')
      d[i][0] = d[i - 1][0];
    else if (s[i - 1] == 'P')
      d[i][0] = d[i - 1][1];
    else {
      int xx = prv[i - 1];
      if (~xx && xx + mid >= i - 1) {
        d[i][0] |= d[xx][0];
        int temp = prv[xx];
        if (~temp && temp + mid >= i - 1) {
          int t = max(0, xx - mid);
          int temp2 = 0;
          if (t && nxt[t - 1] < temp) temp2 = 1;
          d[i][0] |= d[t][temp2];
        }
      }
    }
    int xx = nxt[i - 1];
    if (xx < n) {
      int temp = max(0, xx - mid);
      temp = min(temp, i);
      int temp2 = 0;
      if (temp && nxt[temp - 1] < xx) temp2 = 1;
      d[i][1] |= d[temp][temp2];
    }
  }
  return d[n][0];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> s;
  int sz = 0, c = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'P')
      sec[sz++] = i;
    else if (s[i] == '*')
      c++;
  int mn = 1e9, mx = -1;
  for (int i = 0; i < n; i++) {
    p[i + 1] = p[i];
    if (s[i] == '*') {
      p[i + 1]++;
      mn = min(mn, i);
      mx = max(mx, i);
    }
  }
  int last = n;
  for (int i = n - 1; ~i; i--) {
    nxt[i] = last;
    if (s[i] == 'P') last = i;
  }
  last = -1;
  for (int i = 0; i < n; i++) {
    prv[i] = last;
    if (s[i] == 'P') last = i;
  }
  memcpy(pt, p, sizeof(p));
  if (sz == 1) {
    if (mn > sec[0])
      cout << c << " " << mx - sec[0] << "\n";
    else if (mx < sec[0])
      cout << c << " " << sec[0] - mn << "\n";
    else {
      if (p[sec[0]] > c - p[sec[0]])
        cout << p[sec[0]] << "  " << sec[0] - mn << "\n";
      else if (p[sec[0]] < c - p[sec[0]])
        cout << c - p[sec[0]] << " " << mx - sec[0] << "\n";
      else
        cout << p[sec[0]] << " " << min(sec[0] - mn, mx - sec[0]) << "\n";
    }
  } else {
    int lo = 0, hi = n - 1;
    while (hi - lo > 1) {
      int mid = hi + lo >> 1;
      if (ok(mid, sz))
        hi = mid;
      else
        lo = mid;
    }
    cout << c << " " << hi << "\n";
  }
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.

To solve the crossword you should cross out all repeated letters in rows and columns. In other words, a letter should only be crossed out if and only if the corresponding column or row contains at least one more letter that is exactly the same. Besides, all such letters are crossed out simultaneously.

When all repeated letters have been crossed out, we should write the remaining letters in a string. The letters that occupy a higher position follow before the letters that occupy a lower position. If the letters are located in one row, then the letter to the left goes first. The resulting word is the answer to the problem.

You are suggested to solve an African crossword and print the word encrypted there.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 100). Next n lines contain m lowercase Latin letters each. That is the crossword grid.

Output

Print the encrypted word on a single line. It is guaranteed that the answer consists of at least one letter.

Examples

Input

3 3
cba
bcd
cbc

Output

abcd

Input

5 5
fcofd
ooedo
afaoa
rdcdf
eofsf

Output

codeforces

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 1;
map<pair<long long, long long>, long long> mp, pm;
deque<long long> v, vc, ve;
deque<char> p, pe;
deque<string> ts, ss;
deque<double> sd;
long long a, b, c, d, e, f, cnt, ans, r, n, l;
long double q, t, cnt1;
string g, h, w, o, z, m, s;
char y, u;
bool re, rt;
set<long long> st;
vector<pair<long long, long long> > pr, rp;
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(0);
  cin >> a >> b;
  char arr[a][b];
  for (long long i = 0; i < a; i++) {
    cin >> g;
    for (long long j = 0; j < g.size(); j++) arr[i][j] = g[j];
  }
  for (long long i = 0; i < a; i++) {
    for (long long j = 0; j < b; j++) {
      for (long long k = 0; k < b; k++) {
        if (j != k and (arr[i][j] == arr[i][k])) {
          mp[{i, j}]++;
          mp[{i, k}]++;
          if (mp[{i, j}] == 1) pr.push_back({i, j});
          if (mp[{i, k}] == 1) pr.push_back({i, k});
        }
      }
    }
  }
  for (long long i = 0; i < b; i++) {
    for (long long j = 0; j < a; j++) {
      for (long long k = 0; k < a; k++) {
        if (j != k and (arr[j][i] == arr[k][i])) {
          mp[{j, i}]++;
          mp[{k, i}]++;
          if (mp[{j, i}] == 1) pr.push_back({j, i});
          if (mp[{k, i}] == 1) pr.push_back({k, i});
        }
      }
    }
  }
  for (long long i = 0; i < a; i++) {
    for (long long j = 0; j < b; j++) {
      cnt = 0;
      for (long long k = 0; k < pr.size(); k++) {
        if (i == pr[k].first and j == pr[k].second) {
          cnt++;
          break;
        }
      }
      if (cnt == 0) cout << arr[i][j];
    }
  }
}

```


### Prompt

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

Again, there are hard times in Berland! Many towns have such tensions that even civil war is possible.

There are n towns in Reberland, some pairs of which connected by two-way roads. It is not guaranteed that it is possible to reach one town from any other town using these roads.

Towns s and t announce the final break of any relationship and intend to rule out the possibility of moving between them by the roads. Now possibly it is needed to close several roads so that moving from s to t using roads becomes impossible. Each town agrees to spend money on closing no more than one road, therefore, the total number of closed roads will be no more than two.

Help them find set of no more than two roads such that there will be no way between s and t after closing these roads. For each road the budget required for its closure was estimated. Among all sets find such that the total budget for the closure of a set of roads is minimum.

Input

The first line of the input contains two integers n and m (2 ≤ n ≤ 1000, 0 ≤ m ≤ 30 000) — the number of towns in Berland and the number of roads.

The second line contains integers s and t (1 ≤ s, t ≤ n, s ≠ t) — indices of towns which break up the relationships.

Then follow m lines, each of them contains three integers xi, yi and wi (1 ≤ xi, yi ≤ n, 1 ≤ wi ≤ 109) — indices of towns connected by the i-th road, and the budget on its closure.

All roads are bidirectional. It is allowed that the pair of towns is connected by more than one road. Roads that connect the city to itself are allowed.

Output

In the first line print the minimum budget required to break up the relations between s and t, if it is allowed to close no more than two roads.

In the second line print the value c (0 ≤ c ≤ 2) — the number of roads to be closed in the found solution.

In the third line print in any order c diverse integers from 1 to m — indices of closed roads. Consider that the roads are numbered from 1 to m in the order they appear in the input.

If it is impossible to make towns s and t disconnected by removing no more than 2 roads, the output should contain a single line -1.

If there are several possible answers, you may print any of them.

Examples

Input

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

Output

8
2
2 7

Input

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

Output

9
2
4 5

Input

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

Output

1
1
2

Input

2 3
1 2
1 2 734458840
1 2 817380027
1 2 304764803

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 2, M = 3e4 + 5;
int a[M], b[M], w[M], dontgo, d[N], pos = 0, can[N], par[N];
vector<int> path, adj[N];
void dfs(int x, int prev) {
  int i, u, v;
  d[x] = can[x] = ++pos;
  for (i = 0; i < adj[x].size(); ++i) {
    u = adj[x][i];
    if (prev != u && u != dontgo) {
      v = a[u] ^ b[u] ^ x;
      if (d[v])
        can[x] = min(can[x], d[v]);
      else {
        dfs(v, u);
        par[v] = u;
        can[x] = min(can[x], can[v]);
      }
    }
  }
}
long long W = 2e9 + 5, R1 = -1, R2 = -1;
void sol(long long w, int x, int y) {
  if (W > w) W = w, R1 = x, R2 = y;
}
int main() {
  int s, t, n, m, i, j;
  cin >> n >> m >> s >> t;
  for (i = 1; i <= m; ++i)
    scanf("%d%d%d", &a[i], &b[i], &w[i]), adj[a[i]].push_back(i),
        adj[b[i]].push_back(i);
  dfs(s, -1);
  if (d[t] == 0) {
    printf("0\n0\n");
    return 0;
  }
  int u, v, node = t, pp;
  while (node != s) {
    pp = node ^ a[par[node]] ^ b[par[node]];
    if (d[pp] < can[node])
      sol(w[par[node]], par[node], -1);
    else
      path.push_back(par[node]);
    node = pp;
  }
  for (i = 0; i < path.size(); ++i) {
    u = path[i];
    memset(can, 0, sizeof(can));
    memset(d, 0, sizeof(d));
    dontgo = u;
    dfs(s, -1);
    node = t;
    while (node != s) {
      pp = node ^ a[par[node]] ^ b[par[node]];
      if (d[pp] < can[node]) sol(w[par[node]] + w[u], par[node], u);
      node = pp;
    }
  }
  if (W == 2e9 + 5) {
    printf("-1\n");
  } else {
    cout << W << endl;
    cout << (R1 != -1) + (R2 != -1) << endl;
    if (R1 != -1) cout << R1 << " ";
    if (R2 != -1) cout << R2;
    cout << endl;
  }
}

```


### Prompt

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

You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white.

You think that this picture is not interesting enough. You consider a picture to be interesting if there is at least one cross in it. A cross is represented by a pair of numbers x and y, where 1 ≤ x ≤ n and 1 ≤ y ≤ m, such that all cells in row x and all cells in column y are painted black.

For examples, each of these pictures contain crosses:

<image>

The fourth picture contains 4 crosses: at (1, 3), (1, 5), (3, 3) and (3, 5).

Following images don't contain crosses:

<image>

You have a brush and a can of black paint, so you can make this picture interesting. Each minute you may choose a white cell and paint it black.

What is the minimum number of minutes you have to spend so the resulting picture contains at least one cross?

You are also asked to answer multiple independent queries.

Input

The first line contains an integer q (1 ≤ q ≤ 5 ⋅ 10^4) — the number of queries.

The first line of each query contains two integers n and m (1 ≤ n, m ≤ 5 ⋅ 10^4, n ⋅ m ≤ 4 ⋅ 10^5) — the number of rows and the number of columns in the picture.

Each of the next n lines contains m characters — '.' if the cell is painted white and '*' if the cell is painted black.

It is guaranteed that ∑ n ≤ 5 ⋅ 10^4 and ∑ n ⋅ m ≤ 4 ⋅ 10^5.

Output

Print q lines, the i-th line should contain a single integer — the answer to the i-th query, which is the minimum number of minutes you have to spend so the resulting picture contains at least one cross.

Example

Input

9
5 5
..*..
..*..
*****
..*..
..*..
3 4
****
.*..
.*..
4 3
***
*..
*..
*..
5 5
*****
*.*.*
*****
..*.*
..***
1 4
****
5 5
.....
..*..
.***.
..*..
.....
5 3
...
.*.
.*.
***
.*.
3 3
.*.
*.*
.*.
4 4
*.**
....
*.**
*.**

Output

0
0
0
0
0
4
1
1
2

Note

The example contains all the pictures from above in the same order.

The first 5 pictures already contain a cross, thus you don't have to paint anything.

You can paint (1, 3), (3, 1), (5, 3) and (3, 5) on the 6-th picture to get a cross in (3, 3). That'll take you 4 minutes.

You can paint (1, 2) on the 7-th picture to get a cross in (4, 2).

You can paint (2, 2) on the 8-th picture to get a cross in (2, 2). You can, for example, paint (1, 3), (3, 1) and (3, 3) to get a cross in (3, 3) but that will take you 3 minutes instead of 1.

There are 9 possible crosses you can get in minimum time on the 9-th picture. One of them is in (1, 1): paint (1, 2) and (2, 1).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
template <class T>
inline T read() {
  T 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();
  }
  if (ch == '.') {
    ch = getchar();
    while (ch >= '0' && ch <= '9') {
      x = x * 10 + ch - '0';
      f *= 0.1;
      ch = getchar();
    }
  }
  return x * f;
}
inline void readstr(char* s) {
  char ch = getchar();
  int cnt = 0;
  while (ch == '\n' || ch == ' ') ch = getchar();
  while (!(ch == '\n' || ch == ' ')) s[cnt++] = ch, ch = getchar();
  s[cnt] = 0;
}
void debug(int f) {
  if (f) freopen("input.txt", "r", stdin);
  if (f == 2) freopen("output.txt", "w", stdout);
}
const int MOD = 1e9 + 7, INF = 0XFFFFFFF;
const double eps = 1e-8;
const int maxn = 5e4 + 5, maxm = 200005;
int n, m;
vector<char> c[maxn];
int x[maxn], y[maxn];
int main() {
  debug(0);
  int T = read<int>();
  while (T--) {
    n = read<int>(), m = read<int>();
    char str[maxn];
    memset(x, 0, sizeof(x));
    memset(y, 0, sizeof(y));
    for (int i = 0; i < n; i++) {
      readstr(str);
      for (int j = 0; j < m; j++) c[i].push_back(str[j]);
    }
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        if (c[i][j] == '.') x[i]++, y[j]++;
      }
    int ans = n + m + 1;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        if (c[i][j] == '.')
          ans = min(ans, x[i] + y[j] - 1);
        else
          ans = min(ans, x[i] + y[j]);
      }
    printf("%d\n", ans);
    for (int i = 0; i < n; i++) c[i].clear();
  }
  return 0;
}

```


### Prompt

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

We are committed to the well being of all participants. Therefore, instead of the problem, we suggest you enjoy a piece of cake.

Uh oh. Somebody cut the cake. We told them to wait for you, but they did it anyway. There is still some left, though, if you hurry back. Of course, before you taste the cake, you thought about how the cake was cut.

It is known that the cake was originally a regular n-sided polygon, each vertex of which had a unique number from 1 to n. The vertices were numbered in random order.

Each piece of the cake is a triangle. The cake was cut into n - 2 pieces as follows: each time one cut was made with a knife (from one vertex to another) such that exactly one triangular piece was separated from the current cake, and the rest continued to be a convex polygon. In other words, each time three consecutive vertices of the polygon were selected and the corresponding triangle was cut off.

A possible process of cutting the cake is presented in the picture below.

<image> Example of 6-sided cake slicing.

You are given a set of n-2 triangular pieces in random order. The vertices of each piece are given in random order — clockwise or counterclockwise. Each piece is defined by three numbers — the numbers of the corresponding n-sided cake vertices.

For example, for the situation in the picture above, you could be given a set of pieces: [3, 6, 5], [5, 2, 4], [5, 4, 6], [6, 3, 1].

You are interested in two questions.

  * What was the enumeration of the n-sided cake vertices?
  * In what order were the pieces cut?

Formally, you have to find two permutations p_1, p_2, ..., p_n (1 ≤ p_i ≤ n) and q_1, q_2, ..., q_{n - 2} (1 ≤ q_i ≤ n - 2) such that if the cake vertices are numbered with the numbers p_1, p_2, ..., p_n in order clockwise or counterclockwise, then when cutting pieces of the cake in the order q_1, q_2, ..., q_{n - 2} always cuts off a triangular piece so that the remaining part forms one convex polygon.

For example, in the picture above the answer permutations could be: p=[2, 4, 6, 1, 3, 5] (or any of its cyclic shifts, or its reversal and after that any cyclic shift) and q=[2, 4, 1, 3].

Write a program that, based on the given triangular pieces, finds any suitable permutations p and q.

Input

The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Then there are t independent sets of input data.

The first line of each set consists of a single integer n (3 ≤ n ≤ 10^5) — the number of vertices in the cake.

The following n - 2 lines describe the numbers of the pieces vertices: each line consists of three different integers a, b, c (1 ≤ a, b, c ≤ n) — the numbers of the pieces vertices of cake given in random order. The pieces are given in random order.

It is guaranteed that the answer to each of the tests exists. It is also guaranteed that the sum of n for all test cases does not exceed 10^5.

Output

Print 2t lines — answers to given t test cases in the order in which they are written in the input. Each answer should consist of 2 lines.

In the first line of an answer on a test case print n distinct numbers p_1, p_2, ..., p_n(1 ≤ p_i ≤ n) — the numbers of the cake vertices in clockwise or counterclockwise order.

In the second line of an answer on a test case print n - 2 distinct numbers q_1, q_2, ..., q_{n - 2}(1 ≤ q_i ≤ n - 2) — the order of cutting pieces of the cake. The number of a piece of the cake corresponds to its number in the input.

If there are several answers, print any. It is guaranteed that the answer to each of the tests exists.

Example

Input

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

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long INF = 1e18;
const long double PI = acos((long double)-1);
const int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
const int MN = 1e5 + 5;
int T, N, cnt[MN], lft[MN], rht[MN], deg[MN];
bool vis[MN], done[MN];
map<vector<int>, int> rev;
vector<vector<int>> v;
map<pair<int, int>, vector<int>> m;
vector<int> g[MN];
inline void reset() {
  rev.clear();
  v.clear();
  m.clear();
}
inline int not_common(vector<int> &a, vector<int> &b) {
  for (int i = 0; i < 3; i++) {
    if (find(begin(a), end(a), b[i]) != a.end()) continue;
    return b[i];
  }
  assert(false);
}
inline void add(int a, int b, int n) {
  if (rht[a] != b) swap(a, b);
  lft[n] = a, rht[n] = b;
  rht[a] = n, lft[b] = n;
}
void dfs(int u, int p) {
  for (int ch : g[u]) {
    if (ch == p) continue;
    int n = not_common(v[u], v[ch]);
    vector<int> other;
    for (int ck : v[ch])
      if (ck != n) other.push_back(ck);
    add(other[0], other[1], n);
    dfs(ch, u);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> T;
  while (T--) {
    cin >> N;
    reset();
    for (int i = 0; i <= N; i++) {
      g[i].clear(), cnt[i] = 0;
      lft[i] = rht[i] = deg[i] = 0;
      vis[i] = done[i] = false;
    }
    for (int i = 3; i <= N; i++) {
      vector<int> t;
      for (int k = 0; k < 3; k++) {
        int a;
        cin >> a;
        t.push_back(a);
        cnt[a]++;
      }
      sort(begin(t), end(t));
      v.push_back(t);
      m[{t[0], t[1]}].push_back(i - 3);
      m[{t[1], t[2]}].push_back(i - 3);
      m[{t[0], t[2]}].push_back(i - 3);
    }
    for (int i = 0; i < v.size(); i++) rev[v[i]] = i;
    int rt = -1, al = -1;
    vector<int> tmp;
    for (int i = 0; i < v.size(); i++) {
      for (int a = 0; a < 3; a++) {
        for (int b = a + 1; b < 3; b++) {
          vector<int> &v2 = m[{v[i][a], v[i][b]}];
          for (int ck : v2) {
            if (ck == i) continue;
            g[i].push_back(ck);
            deg[i]++;
          }
        }
        if (cnt[v[i][a]] == 1) {
          rt = i, al = v[i][a];
          if (a == 0)
            tmp = {v[i][1], v[i][2]};
          else if (a == 1)
            tmp = {v[i][0], v[i][2]};
          else
            tmp = {v[i][0], v[i][1]};
        }
      }
    }
    rht[tmp[0]] = al, lft[tmp[0]] = tmp[1];
    lft[tmp[1]] = al, rht[tmp[1]] = tmp[0];
    lft[al] = tmp[0], rht[al] = tmp[1];
    dfs(rt, -1);
    int curr = al;
    while (!vis[curr]) {
      vis[curr] = true;
      cout << curr << " ";
      curr = rht[curr];
    }
    cout << "\n";
    vector<int> t;
    for (int i = 0; i < v.size(); i++)
      if (deg[i] <= 1) done[i] = true, t.push_back(i);
    while (t.size()) {
      int n = t.back();
      t.pop_back();
      cout << n + 1 << " ";
      for (int ck : g[n]) {
        if (done[ck]) continue;
        deg[ck]--;
        if (deg[ck] <= 1) {
          done[ck] = true;
          t.push_back(ck);
        }
      }
    }
    cout << "\n";
  }
}

```


### Prompt

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

You are given two segments [l_1; r_1] and [l_2; r_2] on the x-axis. It is guaranteed that l_1 < r_1 and l_2 < r_2. Segments may intersect, overlap or even coincide with each other.

<image> The example of two segments on the x-axis.

Your problem is to find two integers a and b such that l_1 ≤ a ≤ r_1, l_2 ≤ b ≤ r_2 and a ≠ b. In other words, you have to choose two distinct integer points in such a way that the first point belongs to the segment [l_1; r_1] and the second one belongs to the segment [l_2; r_2].

It is guaranteed that the answer exists. If there are multiple answers, you can print any of them.

You have to answer q independent queries.

Input

The first line of the input contains one integer q (1 ≤ q ≤ 500) — the number of queries.

Each of the next q lines contains four integers l_{1_i}, r_{1_i}, l_{2_i} and r_{2_i} (1 ≤ l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} ≤ 10^9, l_{1_i} < r_{1_i}, l_{2_i} < r_{2_i}) — the ends of the segments in the i-th query.

Output

Print 2q integers. For the i-th query print two integers a_i and b_i — such numbers that l_{1_i} ≤ a_i ≤ r_{1_i}, l_{2_i} ≤ b_i ≤ r_{2_i} and a_i ≠ b_i. Queries are numbered in order of the input.

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

Example

Input

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

Output

2 1
3 4
3 2
1 2
3 7

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long q;
  cin >> q;
  while (q--) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << a << " ";
    if (a == c) {
      cout << d << '\n';
    } else {
      cout << c << '\n';
    }
  }
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Polycarp has a lot of work to do. Recently he has learned a new time management rule: "if a task takes five minutes or less, do it immediately". Polycarp likes the new rule, however he is not sure that five minutes is the optimal value. He supposes that this value d should be chosen based on existing task list.

Polycarp has a list of n tasks to complete. The i-th task has difficulty p_i, i.e. it requires exactly p_i minutes to be done. Polycarp reads the tasks one by one from the first to the n-th. If a task difficulty is d or less, Polycarp starts the work on the task immediately. If a task difficulty is strictly greater than d, he will not do the task at all. It is not allowed to rearrange tasks in the list. Polycarp doesn't spend any time for reading a task or skipping it.

Polycarp has t minutes in total to complete maximum number of tasks. But he does not want to work all the time. He decides to make a break after each group of m consecutive tasks he was working on. The break should take the same amount of time as it was spent in total on completion of these m tasks.

For example, if n=7, p=[3, 1, 4, 1, 5, 9, 2], d=3 and m=2 Polycarp works by the following schedule:

  * Polycarp reads the first task, its difficulty is not greater than d (p_1=3 ≤ d=3) and works for 3 minutes (i.e. the minutes 1, 2, 3);
  * Polycarp reads the second task, its difficulty is not greater than d (p_2=1 ≤ d=3) and works for 1 minute (i.e. the minute 4);
  * Polycarp notices that he has finished m=2 tasks and takes a break for 3+1=4 minutes (i.e. on the minutes 5, 6, 7, 8);
  * Polycarp reads the third task, its difficulty is greater than d (p_3=4 > d=3) and skips it without spending any time;
  * Polycarp reads the fourth task, its difficulty is not greater than d (p_4=1 ≤ d=3) and works for 1 minute (i.e. the minute 9);
  * Polycarp reads the tasks 5 and 6, skips both of them (p_5>d and p_6>d);
  * Polycarp reads the 7-th task, its difficulty is not greater than d (p_7=2 ≤ d=3) and works for 2 minutes (i.e. the minutes 10, 11);
  * Polycarp notices that he has finished m=2 tasks and takes a break for 1+2=3 minutes (i.e. on the minutes 12, 13, 14).

Polycarp stops exactly after t minutes. If Polycarp started a task but has not finished it by that time, the task is not considered as completed. It is allowed to complete less than m tasks in the last group. Also Polycarp considers acceptable to have shorter break than needed after the last group of tasks or even not to have this break at all — his working day is over and he will have enough time to rest anyway.

Please help Polycarp to find such value d, which would allow him to complete maximum possible number of tasks in t minutes.

Input

The first line of the input contains single integer c (1 ≤ c ≤ 5 ⋅ 10^4) — number of test cases. Then description of c test cases follows. Solve test cases separately, test cases are completely independent and do not affect each other.

Each test case is described by two lines. The first of these lines contains three space-separated integers n, m and t (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ m ≤ 2 ⋅ 10^5, 1 ≤ t ≤ 4 ⋅ 10^{10}) — the number of tasks in Polycarp's list, the number of tasks he can do without a break and the total amount of time Polycarp can work on tasks. The second line of the test case contains n space separated integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ 2 ⋅ 10^5) — difficulties of the tasks.

The sum of values n for all test cases in the input does not exceed 2 ⋅ 10^5.

Output

Print c lines, each line should contain answer for the corresponding test case — the maximum possible number of tasks Polycarp can complete and the integer value d (1 ≤ d ≤ t) Polycarp should use in time management rule, separated by space. If there are several possible values d for a test case, output any of them.

Examples

Input

4
5 2 16
5 6 1 4 7
5 3 30
5 6 1 4 7
6 4 15
12 5 15 7 20 17
1 1 50
100

Output

3 5
4 7
2 10
0 25

Input

3
11 1 29
6 4 3 7 5 3 4 7 3 5 3
7 1 5
1 1 1 1 1 1 1
5 2 18
2 3 3 7 5

Output

4 3
3 1
4 5

Note

In the first test case of the first example n=5, m=2 and t=16. The sequence of difficulties is [5, 6, 1, 4, 7]. If Polycarp chooses d=5 then he will complete 3 tasks. Polycarp will work by the following schedule:

  * Polycarp reads the first task, its difficulty is not greater than d (p_1=5 ≤ d=5) and works for 5 minutes (i.e. the minutes 1, 2, ..., 5);
  * Polycarp reads the second task, its difficulty is greater than d (p_2=6 > d=5) and skips it without spending any time;
  * Polycarp reads the third task, its difficulty is not greater than d (p_3=1 ≤ d=5) and works for 1 minute (i.e. the minute 6);
  * Polycarp notices that he has finished m=2 tasks and takes a break for 5+1=6 minutes (i.e. on the minutes 7, 8, ..., 12);
  * Polycarp reads the fourth task, its difficulty is not greater than d (p_4=4 ≤ d=5) and works for 4 minutes (i.e. the minutes 13, 14, 15, 16);
  * Polycarp stops work because of t=16.

In total in the first test case Polycarp will complete 3 tasks for d=5. He can't choose other value for d to increase the number of completed tasks.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 200200;
int n, m;
long long t;
long long a[N];
long long b[N];
bool solve(int k) {
  int kk = k - k % m;
  if (kk == k) kk -= m;
  int pos = 0;
  long long T = t;
  for (int i = 0; pos < k; i++) {
    if (a[i] > b[k - 1]) continue;
    T -= a[i];
    if (pos < kk) T -= a[i];
    if (T < 0) return false;
    pos++;
  }
  return true;
}
void solve() {
  scanf("%d%d%lld", &n, &m, &t);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    b[i] = a[i];
  }
  sort(b, b + n);
  int l = 0, r = n + 1;
  while (r - l > 1) {
    int x = (l + r) / 2;
    if (solve(x))
      l = x;
    else
      r = x;
  }
  printf("%d %lld\n", l, (l == 0 ? 1 : b[l - 1]));
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) solve();
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i.

He wrote an integer X on the blackboard, then performed the following operation N times:

* Choose one element from S and remove it.
* Let x be the number written on the blackboard now, and y be the integer removed from S. Replace the number on the blackboard with x \bmod {y}.

There are N! possible orders in which the elements are removed from S. For each of them, find the number that would be written on the blackboard after the N operations, and compute the sum of all those N! numbers modulo 10^{9}+7.

Constraints

* All values in input are integers.
* 1 \leq N \leq 200
* 1 \leq S_i, X \leq 10^{5}
* S_i are pairwise distinct.

Input

Input is given from Standard Input in the following format:

N X
S_1 S_2 \ldots S_{N}

Output

Print the answer.

Examples

Input

2 19
3 7

Output

3

Input

5 82
22 11 6 5 13

Output

288

Input

10 100000
50000 50001 50002 50003 50004 50005 50006 50007 50008 50009

Output

279669259

### Response

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
ll N,X;
ll dp[202][101010];
ll S[222];
ll i,j,k;
int main(){
    scanf("%lld%lld", &N ,& X);
    fornum(i,0,N){
        scanf("%lld", &S[i]);
    }
    sort(S, S + N, greater<ll>());
    dp[0][X] = 1;
    fornum(i,0,N){
        fornum(j,0,X+1){
            dp[i+1][j % S[i]] =(dp[i+1][j % S[i]] + dp[i][j])%MOD;
        }
        fornum(j,0,X+1){
            dp[i + 1][j] = (dp[i+1][j]+dp[i][j] * (N-1-i)) % MOD;
        }
    }
    ll ans = 0;
    fornum(i,0,S[N-1]){
        ans = (ans+dp[N][i] * i)%MOD;
    }
    printf("%lld", ans);
    return 0;
}
```


### Prompt

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

Polycarp is very careful. He even types numeric sequences carefully, unlike his classmates. If he sees a sequence without a space after the comma, with two spaces in a row, or when something else does not look neat, he rushes to correct it. For example, number sequence written like "1,2 ,3,..., 10" will be corrected to "1, 2, 3, ..., 10".

In this task you are given a string s, which is composed by a concatination of terms, each of which may be:

  * a positive integer of an arbitrary length (leading zeroes are not allowed),
  * a "comma" symbol (","),
  * a "space" symbol (" "),
  * "three dots" ("...", that is, exactly three points written one after another, also known as suspension points).

Polycarp wants to add and remove spaces in the string s to ensure the following:

  * each comma is followed by exactly one space (if the comma is the last character in the string, this rule does not apply to it),
  * each "three dots" term is preceded by exactly one space (if the dots are at the beginning of the string, this rule does not apply to the term),
  * if two consecutive numbers were separated by spaces only (one or more), then exactly one of them should be left,
  * there should not be other spaces.

Automate Polycarp's work and write a program that will process the given string s.

Input

The input data contains a single string s. Its length is from 1 to 255 characters. The string s does not begin and end with a space. Its content matches the description given above.

Output

Print the string s after it is processed. Your program's output should be exactly the same as the expected answer. It is permissible to end output line with a line-break character, and without it.

Examples

Input

1,2 ,3,...,     10

Output

1, 2, 3, ..., 10

Input

1,,,4...5......6

Output

1, , , 4 ...5 ... ...6

Input

...,1,2,3,...

Output

..., 1, 2, 3, ...

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  getline(cin, str);
  string ans;
  int cnt = 0;
  bool check = false;
  for (int i = 0; i < str.size(); i++) {
    char ch = str[i];
    if (!isdigit(ch)) {
      if (ch == ',') {
        ans.push_back(',');
        ans.push_back(' ');
      }
      if (ch == '.') cnt++;
      if (cnt == 3) {
        ans.push_back(' ');
        ans.push_back('.');
        ans.push_back('.');
        ans.push_back('.');
        cnt = 0;
      }
      if (ch == ' ') {
        if (isdigit(str[i - 1])) {
          check = true;
        }
        if (check) {
          if (isdigit(str[i + 1])) {
            ans.push_back(' ');
            check = false;
          }
        }
        if (str[i + 1] != ch) check = false;
      }
    } else
      ans.push_back(ch);
  }
  int low = 0, high = ans.size() - 1;
  while (ans[low] == ' ') {
    ans[low] = '-';
    low++;
  }
  while (ans[high] == ' ') {
    ans[high] = '-';
    high--;
  }
  for (int i = 0; i < ans.size() - 1; i++) {
    if ((ans[i] == ' ') && (ans[i + 1] == ' ')) ans[i] = '-';
  }
  for (int i = 0; i < ans.size(); i++) {
    if (ans[i] != '-') cout << ans[i];
  }
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

You are given the following concurrent program. There are N processes and the i-th process has the following pseudocode:

    repeat ni times
        yi := y
        y := yi + 1
    end repeat

Here y is a shared variable. Everything else is local for the process. All actions on a given row are atomic, i.e. when the process starts executing a row it is never interrupted. Beyond that all interleavings are possible, i.e. every process that has yet work to do can be granted the rights to execute its next row. In the beginning y = 0. You will be given an integer W and ni, for i = 1, ... , N. Determine if it is possible that after all processes terminate, y = W, and if it is possible output an arbitrary schedule that will produce this final value.

Input

In the first line of the input you will be given two space separated integers N (1 ≤ N ≤ 100) and W ( - 109 ≤ W ≤ 109). In the second line there are N space separated integers ni (1 ≤ ni ≤ 1000).

Output

On the first line of the output write Yes if it is possible that at the end y = W, or No otherwise. If the answer is No then there is no second line, but if the answer is Yes, then on the second line output a space separated list of integers representing some schedule that leads to the desired result. For more information see note.

Examples

Input

1 10
11

Output

No

Input

2 3
4 4

Output

Yes
1 1 2 1 2 2 2 2 2 1 2 1 1 1 1 2

Input

3 6
1 2 3

Output

Yes
1 1 2 2 2 2 3 3 3 3 3 3

Note

For simplicity, assume that there is no repeat statement in the code of the processes, but the code from the loop is written the correct amount of times. The processes are numbered starting from 1. The list of integers represent which process works on its next instruction at a given step. For example, consider the schedule 1 2 2 1 3. First process 1 executes its first instruction, then process 2 executes its first two instructions, after that process 1 executes its second instruction, and finally process 3 executes its first instruction. The list must consists of exactly 2·Σ i = 1...N ni numbers.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
long long sum, W, w;
struct A {
  int id, val;
} a[102];
bool comp(A x, A y) { return (x.val < y.val); }
int main() {
  int i, j;
  cin >> n >> W;
  sum = 0LL;
  for (i = 1; i <= n; i++) {
    a[i].id = i;
    cin >> a[i].val;
    sum += (long long)a[i].val;
  }
  sort(&a[1], &a[n + 1], comp);
  if (W <= 0LL || W > sum || (n == 1 && sum != W) || (a[1].val > 1 && W == 1LL))
    cout << "No";
  else if (W == sum) {
    cout << "Yes" << endl;
    printf("%d %d", a[1].id, a[1].id);
    a[1].val--;
    for (i = 1; i <= n; i++)
      for (; a[i].val > 0; a[i].val--) printf(" %d %d", a[i].id, a[i].id);
  } else if (W >= a[1].val) {
    cout << "Yes" << endl;
    w = sum - W;
    printf("%d", a[1].id);
    a[1].val--;
    for (i = 2; i <= n && w > 0; i++)
      for (; a[i].val > 0 && w > 0; a[i].val--)
        w--, printf(" %d %d", a[i].id, a[i].id);
    printf(" %d", a[1].id);
    for (i = 1; i <= n; i++)
      for (; a[i].val > 0; a[i].val--) printf(" %d %d", a[i].id, a[i].id);
  } else {
    cout << "Yes" << endl;
    printf("%d", a[1].id);
    a[1].val--;
    for (; a[2].val > 1; a[2].val--) printf(" %d %d", a[2].id, a[2].id);
    printf(" %d", a[1].id);
    printf(" %d", a[2].id);
    w = W - 2;
    for (; a[1].val > w; a[1].val--) printf(" %d %d", a[1].id, a[1].id);
    for (i = 3; i <= n; i++)
      for (; a[i].val > 0; a[i].val--) printf(" %d %d", a[i].id, a[i].id);
    printf(" %d", a[2].id);
    for (; a[1].val > 0; a[1].val--) printf(" %d %d", a[1].id, a[1].id);
  }
  return 0;
}

```


### Prompt

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

In this problem, we only consider strings consisting of lowercase English letters.

Strings s and t are said to be isomorphic when the following conditions are satisfied:

* |s| = |t| holds.
* For every pair i, j, one of the following holds:
* s_i = s_j and t_i = t_j.
* s_i \neq s_j and t_i \neq t_j.

For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not.

A string s is said to be in normal form when the following condition is satisfied:

* For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison.

For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`.

You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.

Constraints

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

Input

Input is given from Standard Input in the following format:

N

Output

Assume that there are K strings of length N that are in normal form: w_1, \ldots, w_K in lexicographical order. Output should be in the following format:

w_1
:
w_K

Output

Assume that there are K strings of length N that are in normal form: w_1, \ldots, w_K in lexicographical order. Output should be in the following format:

w_1
:
w_K

Examples

Input

1

Output

a

Input

2

Output

aa
ab

### Response

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

void dfs(string s, char c)
{
  if (s.size() == N)
  {
    cout << s << endl;
  }
  else
  {
    for (char i = 'a'; i <= c; i++)
    {
      if (i != c)
        dfs(s + i, c);
      else
        dfs(s + i, c + 1);
    }
  }
}

int main()
{
  cin >> N;
  dfs("", 'a');
}

```


### Prompt

Create a solution in Cpp for the following problem:

Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way:

<image>

This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denotes the degree of polynomial P(x). <image> is called the remainder of division of polynomial <image> by polynomial <image>, it is also denoted as <image>.

Since there is a way to divide polynomials with remainder, we can define Euclid's algorithm of finding the greatest common divisor of two polynomials. The algorithm takes two polynomials <image>. If the polynomial <image> is zero, the result is <image>, otherwise the result is the value the algorithm returns for pair <image>. On each step the degree of the second argument decreases, so the algorithm works in finite number of steps. But how large that number could be? You are to answer this question.

You are given an integer n. You have to build two polynomials with degrees not greater than n, such that their coefficients are integers not exceeding 1 by their absolute value, the leading coefficients (ones with the greatest power of x) are equal to one, and the described Euclid's algorithm performs exactly n steps finding their greatest common divisor. Moreover, the degree of the first polynomial should be greater than the degree of the second. By a step of the algorithm we mean the transition from pair <image> to pair <image>.

Input

You are given a single integer n (1 ≤ n ≤ 150) — the number of steps of the algorithm you need to reach.

Output

Print two polynomials in the following format.

In the first line print a single integer m (0 ≤ m ≤ n) — the degree of the polynomial.

In the second line print m + 1 integers between  - 1 and 1 — the coefficients of the polynomial, from constant to leading.

The degree of the first polynomial should be greater than the degree of the second polynomial, the leading coefficients should be equal to 1. Euclid's algorithm should perform exactly n steps when called using these polynomials.

If there is no answer for the given n, print -1.

If there are multiple answer, print any of them.

Examples

Input

1

Output

1
0 1
0
1

Input

2

Output

2
-1 0 1
1
0 1

Note

In the second example you can print polynomials x2 - 1 and x. The sequence of transitions is

(x2 - 1, x) → (x, - 1) → ( - 1, 0).

There are two steps in it.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long min(long long a, long long b) {
  if (a < b)
    return a;
  else
    return b;
}
static long long gcd(long long a, long long b) {
  long long r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) {
  long long temp = gcd(a, b);
  return temp ? (a / temp * b) : 0;
}
unsigned long long PowMod(unsigned long long x, unsigned long long e,
                          unsigned long long mod) {
  unsigned long long res;
  if (e == 0) {
    res = 1;
  } else if (e == 1) {
    res = x;
  } else {
    res = PowMod(x, e / 2, mod);
    res = res * res % mod;
    if (e % 2) res = res * x % mod;
  }
  return res;
}
int a[152][152];
int r[152][152];
bool check(int x, int y) {
  a[x + 1][0] = 0;
  for (int i = 0; i <= x; i++) {
    a[x + 1][i + 1] = a[x][i];
    r[x + 1][i] = a[x][i];
  }
  for (int i = 0; i <= x; i++) {
    a[x + 1][i] += (y * r[x][i]);
  }
  for (int i = 0; i <= x + 1; i++) {
    if (a[x + 1][i] > 1 || a[x + 1][i] < (-1)) {
      return false;
    }
  }
  return true;
}
int solve() {
  int n;
  cin >> n;
  memset(a, 0, sizeof(a));
  memset(r, 0, sizeof(r));
  a[1][0] = 0;
  a[1][1] = 1;
  r[1][0] = 1;
  a[2][0] = -1;
  a[2][1] = 0;
  a[2][2] = 1;
  r[2][0] = 0;
  r[2][1] = 1;
  for (int i = 3; i <= n; i++) {
    if (check(i - 1, 1) == true) {
    } else {
      check(i - 1, -1);
    }
  }
  cout << n << endl;
  for (int i = 0; i <= n; i++) {
    cout << a[n][i] << " ";
  }
  cout << endl << n - 1 << endl;
  for (int i = 0; i < n; i++) {
    cout << r[n][i] << " ";
  }
  cout << endl;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

Every year a race takes place on the motorway between cities A and B. This year Vanya decided to take part in the race and drive his own car that has been around and bears its own noble name — The Huff-puffer.

So, Vasya leaves city A on the Huff-puffer, besides, at the very beginning he fills the petrol tank with α liters of petrol (α ≥ 10 is Vanya's favorite number, it is not necessarily integer). Petrol stations are located on the motorway at an interval of 100 kilometers, i.e. the first station is located 100 kilometers away from the city A, the second one is 200 kilometers away from the city A, the third one is 300 kilometers away from the city A and so on. The Huff-puffer spends 10 liters of petrol every 100 kilometers.

Vanya checks the petrol tank every time he passes by a petrol station. If the petrol left in the tank is not enough to get to the next station, Vanya fills the tank with α liters of petrol. Otherwise, he doesn't stop at the station and drives on.

For example, if α = 43.21, then the car will be fuelled up for the first time at the station number 4, when there'll be 3.21 petrol liters left. After the fuelling up the car will have 46.42 liters. Then Vanya stops at the station number 8 and ends up with 6.42 + 43.21 = 49.63 liters. The next stop is at the station number 12, 9.63 + 43.21 = 52.84. The next stop is at the station number 17 and so on.

You won't believe this but the Huff-puffer has been leading in the race! Perhaps it is due to unexpected snow. Perhaps it is due to video cameras that have been installed along the motorway which register speed limit breaking. Perhaps it is due to the fact that Vanya threatened to junk the Huff-puffer unless the car wins. Whatever the reason is, the Huff-puffer is leading, and jealous people together with other contestants wrack their brains trying to think of a way to stop that outrage.

One way to do this is to mine the next petrol station where Vanya will stop. Your task is to calculate at which station this will happen and warn Vanya. You don't know the α number, however, you are given the succession of the numbers of the stations where Vanya has stopped. Find the number of the station where the next stop will be.

Input

The first line contains an integer n (1 ≤ n ≤ 1000) which represents the number of petrol stations where Vanya has stopped. The next line has n space-separated integers which represent the numbers of the stations. The numbers are positive and do not exceed 106, they are given in the increasing order. No two numbers in the succession match. It is guaranteed that there exists at least one number α ≥ 10, to which such a succession of stops corresponds.

Output

Print in the first line "unique" (without quotes) if the answer can be determined uniquely. In the second line print the number of the station where the next stop will take place. If the answer is not unique, print in the first line "not unique".

Examples

Input

3
1 2 4

Output

unique
5

Input

2
1 2

Output

not unique

Note

In the second example the answer is not unique. For example, if α = 10, we'll have such a sequence as 1, 2, 3, and if α = 14, the sequence will be 1, 2, 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int i;
  int s;
  double A = -1;
  double B = -1;
  for (i = 1; i <= n; ++i) {
    cin >> s;
    if (A < 0 || A <= (s * 10 + 0.0) / (i + 0.0))
      A = (s * 10 + 0.0) / (i + 0.0);
    if (B < 0 || B > (10.0 + s * 10) / (i + 0.0))
      B = (10.0 + s * 10) / (i + 0.0);
  }
  double L = A * (n + 1) / 10;
  double R = B * (n + 1) / 10;
  if (int(L) != (int)(R - (1e-8)))
    cout << "not unique" << endl;
  else
    cout << "unique" << endl << int(L) << endl;
  return 0;
}

```


### Prompt

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

You are running through a rectangular field. This field can be represented as a matrix with 3 rows and m columns. (i, j) denotes a cell belonging to i-th row and j-th column.

You start in (2, 1) and have to end your path in (2, m). From the cell (i, j) you may advance to:

  * (i - 1, j + 1) — only if i > 1,
  * (i, j + 1), or
  * (i + 1, j + 1) — only if i < 3.

However, there are n obstacles blocking your path. k-th obstacle is denoted by three integers ak, lk and rk, and it forbids entering any cell (ak, j) such that lk ≤ j ≤ rk.

You have to calculate the number of different paths from (2, 1) to (2, m), and print it modulo 109 + 7.

Input

The first line contains two integers n and m (1 ≤ n ≤ 104, 3 ≤ m ≤ 1018) — the number of obstacles and the number of columns in the matrix, respectively.

Then n lines follow, each containing three integers ak, lk and rk (1 ≤ ak ≤ 3, 2 ≤ lk ≤ rk ≤ m - 1) denoting an obstacle blocking every cell (ak, j) such that lk ≤ j ≤ rk. Some cells may be blocked by multiple obstacles.

Output

Print the number of different paths from (2, 1) to (2, m), taken modulo 109 + 7. If it is impossible to get from (2, 1) to (2, m), then the number of paths is 0.

Example

Input

2 5
1 3 4
2 2 3

Output

2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > operator*(vector<vector<long long> > a,
                                     vector<vector<long long> > b) {
  int n = (int)a.size();
  int m = (int)b.size();
  int p = (int)b[0].size();
  vector<vector<long long> > c;
  c.resize(n);
  for (int i = 0; i < n; i++) {
    c[i].assign(p, 0);
    for (int j = 0; j < p; j++) {
      for (int k = 0; k < m; k++) {
        c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % 1000000007;
      }
    }
  }
  return c;
}
vector<vector<long long> > id(int size) {
  vector<vector<long long> > a(size, vector<long long>(size, 0));
  for (int i = 0; i < size; i++) a[i][i] = 1;
  return a;
}
vector<vector<long long> > matrixExp(vector<vector<long long> > a,
                                     long long n) {
  if (n == 0) return id(a.size());
  vector<vector<long long> > c = matrixExp(a, n / 2);
  c = c * c;
  if (n % 2 != 0) c = c * a;
  return c;
}
vector<vector<long long> > blocked(int *b) {
  vector<vector<long long> > a(3, vector<long long>(3, 0));
  a[0][0] = a[0][1] = 1;
  a[1][0] = a[1][1] = a[1][2] = 1;
  a[2][1] = a[2][2] = 1;
  if (b[1] > 0) a[0][0] = a[0][1] = a[1][0] = 0;
  if (b[2] > 0) a[0][1] = a[1][0] = a[1][1] = a[1][2] = a[2][1] = 0;
  if (b[3] > 0) a[1][2] = a[2][1] = a[2][2] = 0;
  return a;
}
int main() {
  int n;
  long long m;
  cin >> n >> m;
  vector<pair<long long, int> > block;
  for (int i = 0; i < n; i++) {
    int b;
    long long l, r;
    cin >> b >> l >> r;
    block.push_back(pair<long long, int>(l, b));
    block.push_back(pair<long long, int>(r, -b));
  }
  sort(block.begin(), block.end());
  vector<vector<long long> > ans = id(3);
  long long pos = 1;
  int b[4] = {0, 0, 0, 0};
  for (auto it : block) {
    long long nextPos = it.first;
    ans = ans * matrixExp(blocked(b), nextPos - pos);
    b[abs(it.second)] += it.second;
    pos = nextPos;
  }
  ans = ans * matrixExp(blocked(b), m - pos);
  cout << ans[1][1] << endl;
}

```


### Prompt

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

You have a knapsack with the capacity of W. There are also n items, the i-th one has weight w_i.

You want to put some of these items into the knapsack in such a way that their total weight C is at least half of its size, but (obviously) does not exceed it. Formally, C should satisfy: ⌈ W/2⌉ ≤ C ≤ W.

Output the list of items you will put into the knapsack or determine that fulfilling the conditions is impossible.

If there are several possible lists of items satisfying the conditions, you can output any. Note that you don't have to maximize the sum of weights of items in the knapsack.

Input

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

The first line of each test case contains integers n and W (1 ≤ n ≤ 200 000, 1≤ W ≤ 10^{18}).

The second line of each test case contains n integers w_1, w_2, ..., w_n (1 ≤ w_i ≤ 10^9) — weights of the items.

The sum of n over all test cases does not exceed 200 000.

Output

For each test case, if there is no solution, print a single integer -1.

If there exists a solution consisting of m items, print m in the first line of the output and m integers j_1, j_2, ..., j_m (1 ≤ j_i ≤ n, all j_i are distinct) in the second line of the output — indices of the items you would like to pack into the knapsack.

If there are several possible lists of items satisfying the conditions, you can output any. Note that you don't have to maximize the sum of weights items in the knapsack.

Example

Input

3
1 3
3
6 2
19 8 19 69 9 4
7 12
1 1 1 17 1 1 1

Output

1
1
-1
6
1 2 3 5 6 7

Note

In the first test case, you can take the item of weight 3 and fill the knapsack just right.

In the second test case, all the items are larger than the knapsack's capacity. Therefore, the answer is -1.

In the third test case, you fill the knapsack exactly in half.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ld = long double;
const int N = 1e5 + 1;
const lli MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    lli n, w;
    cin >> n >> w;
    vector<pair<lli, lli> > v;
    lli sum = 0;
    for (int i = 0; i < n; i++) {
      lli c;
      cin >> c;
      if (c > w) {
        continue;
      }
      v.emplace_back(c, i + 1);
      sum += c;
    }
    if (2 * sum < w) {
      cout << "-1\n";
      continue;
    }
    sort(v.rbegin(), v.rend());
    lli val = 0, i = 0;
    while (2 * val < w) {
      val += v[i].first;
      i++;
    }
    cout << i << '\n';
    for (int j = 0; j < i; j++) {
      cout << v[j].second << " \n"[j == i - 1];
    }
  }
}

```


### Prompt

Generate a cpp solution to the following problem:

Vasya has n burles. One bottle of Ber-Cola costs a burles and one Bars bar costs b burles. He can buy any non-negative integer number of bottles of Ber-Cola and any non-negative integer number of Bars bars.

Find out if it's possible to buy some amount of bottles of Ber-Cola and Bars bars and spend exactly n burles.

In other words, you should find two non-negative integers x and y such that Vasya can buy x bottles of Ber-Cola and y Bars bars and x·a + y·b = n or tell that it's impossible.

Input

First line contains single integer n (1 ≤ n ≤ 10 000 000) — amount of money, that Vasya has.

Second line contains single integer a (1 ≤ a ≤ 10 000 000) — cost of one bottle of Ber-Cola.

Third line contains single integer b (1 ≤ b ≤ 10 000 000) — cost of one Bars bar.

Output

If Vasya can't buy Bars and Ber-Cola in such a way to spend exactly n burles print «NO» (without quotes).

Otherwise in first line print «YES» (without quotes). In second line print two non-negative integers x and y — number of bottles of Ber-Cola and number of Bars bars Vasya should buy in order to spend exactly n burles, i.e. x·a + y·b = n. If there are multiple answers print any of them.

Any of numbers x and y can be equal 0.

Examples

Input

7
2
3

Output

YES
2 1

Input

100
25
10

Output

YES
0 10

Input

15
4
8

Output

NO

Input

9960594
2551
2557

Output

YES
1951 1949

Note

In first example Vasya can buy two bottles of Ber-Cola and one Bars bar. He will spend exactly 2·2 + 1·3 = 7 burles.

In second example Vasya can spend exactly n burles multiple ways:

  * buy two bottles of Ber-Cola and five Bars bars;
  * buy four bottles of Ber-Cola and don't buy Bars bars;
  * don't buy Ber-Cola and buy 10 Bars bars.

In third example it's impossible to but Ber-Cola and Bars bars in order to spend exactly n burles.

### Response

```cpp
#include <bits/stdc++.h>
int dx[] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy[] = {-1, 0, 1, 1, 1, 0, -1, -1};
using namespace std;
long long power(long long a, long long p, long long M) {
  long long r = 1;
  a = a % M;
  while (p > 0) {
    if (p % 2) r = (r * a) % M;
    a = (a * a) % M;
    p /= 2;
  }
  return r;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void solve() {
  long long n, a, b;
  cin >> n >> a >> b;
  long long x = 0;
  while (x * a <= n) {
    long long y = (n - x * a) / b;
    if (x * a + y * b == n) {
      cout << "YES\n";
      cout << x << " " << y << endl;
      return;
    }
    x++;
  }
  cout << "NO\n";
}
int main() {
  solve();
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Taro, a junior high school student, is working on his homework. Today's homework is to read Chinese classic texts.

As you know, Japanese language shares the (mostly) same Chinese characters but the order of words is a bit different. Therefore the notation called "returning marks" was invented in order to read Chinese classic texts in the order similar to Japanese language.

There are two major types of returning marks: 'Re' mark and jump marks. Also there are a couple of jump marks such as one-two-three marks, top-middle-bottom marks. The marks are attached to letters to describe the reading order of each letter in the Chinese classic text. Figure 1 is an example of a Chinese classic text annotated with returning marks, which are the small letters at the bottom-left of the big Chinese letters.

<image>

Figure 1: a Chinese classic text

Taro generalized the concept of jump marks, and summarized the rules to read Chinese classic texts with returning marks as below. Your task is to help Taro by writing a program that interprets Chinese classic texts with returning marks following his rules, and outputs the order of reading of each letter.

When two (or more) rules are applicable in each step, the latter in the list below is applied first, then the former.

1. Basically letters are read downwards from top to bottom, i.e. the first letter should be read (or skipped) first, and after the i-th letter is read or skipped, (i + 1)-th letter is read next.
2. Each jump mark has a type (represented with a string consisting of lower-case letters) and a number (represented with a positive integer). A letter with a jump mark whose number is 2 or larger must be skipped.
3. When the i-th letter with a jump mark of type t, number n is read, and when there exists an unread letter L at position less than i that has a jump mark of type t, number n + 1, then L must be read next. If there is no such letter L, the (k + 1)-th letter is read, where k is the index of the most recently read letter with a jump mark of type t, number 1.
4. A letter with a 'Re' mark must be skipped.
5. When the i-th letter is read and (i - 1)-th letter has a 'Re' mark, then (i - 1)-th letter must be read next.
6. No letter may be read twice or more. Once a letter is read, the letter must be skipped in the subsequent steps.
7. If no letter can be read next, finish reading.

Let's see the first case of the sample input. We begin reading with the first letter because of the rule 1. However, since the first letter has a jump mark 'onetwo2', we must follow the rule 2 and skip the letter. Therefore the second letter, which has no returning mark, will be read first.

Then the third letter will be read. The third letter has a jump mark 'onetwo1', so we must follow rule 3 and read a letter with a jump mark `onetwo2' next, if exists. The first letter has the exact jump mark, so it will be read third. Similarly, the fifth letter is read fourth, and then the sixth letter is read.

Although we have two letters which have the same jump mark 'onetwo2', we must not take into account the first letter, which has already been read, and must read the fourth letter. Now we have read all six letters and no letter can be read next, so we finish reading. We have read the second, third, first, fifth, sixth, and fourth letter in this order, so the output is 2 3 1 5 6 4.

Input

The input contains multiple datasets. Each dataset is given in the following format:

N
mark1
...
markN

N, a positive integer (1 ≤ N ≤ 10,000), means the number of letters in a Chinese classic text. marki denotes returning marks attached to the i-th letter.

A 'Re' mark is represented by a single letter, namely, 'v' (quotes for clarity). The description of a jump mark is the simple concatenation of its type, specified by one or more lowercase letter, and a positive integer. Note that each letter has at most one jump mark and at most one 'Re' mark. When the same letter has both types of returning marks, the description of the jump mark comes first, followed by 'v' for the 'Re' mark. You can assume this happens only on the jump marks with the number 1.

If the i-th letter has no returning mark, marki is '-' (quotes for clarity). The length of marki never exceeds 20.

You may assume that input is well-formed, that is, there is exactly one reading order that follows the rules above. And in the ordering, every letter is read exactly once.

You may also assume that the N-th letter does not have 'Re' mark.

The input ends when N = 0. Your program must not output anything for this case.

Output

For each dataset, you should output N lines. The first line should contain the index of the letter which is to be read first, the second line for the letter which is to be read second, and so on. All the indices are 1-based.

Example

Input

6
onetwo2
-
onetwo1
onetwo2
-
onetwo1
7
v
topbottom2
onetwo2
-
onetwo1
topbottom1
-
6
baz2
foo2
baz1v
bar2
foo1
bar1
0

Output

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

### Response

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n;cin>>n && n;){
		vs lines(n);
		rep(i,n) cin>>lines[i];

		vi prev(n,-1);
		rep(i,n) if(lines[i].back()=='v'){
			prev[i]=i+1;
			//lines[i].pop_back();
			lines[i].erase(end(lines[i])-1);
		}
		map<string,int> f;
		per(i,n) if(lines[i].size() && isdigit(lines[i].back()))
			rep(j,lines[i].size())
				if(isdigit(lines[i][j])){
					string tag=lines[i].substr(0,j);
					int x=stoi(lines[i].substr(j));
					if(x>1) prev[i]=f[tag];
					f[tag]=i;
				}

		vvi pathes;
		vi vis(n);
		rep(i,n) if(!vis[i]){
			vi path;
			for(int v=i;v!=-1;v=prev[v]){
				path.push_back(v);
				vis[v]=1;
			}
			reverse(all(path));
			pathes.push_back(path);
		}
		sort(all(pathes));

		rep(i,pathes.size()) rep(j,pathes[i].size())
			cout<<pathes[i][j]+1<<endl;
	}
}
```