### Prompt

Construct a cpp code solution to the problem outlined:

Niwango bought a piece of land that can be represented as a half-open interval [0, X).

Niwango will lay out N vinyl sheets on this land. The sheets are numbered 1,2, \ldots, N, and they are distinguishable. For Sheet i, he can choose an integer j such that 0 \leq j \leq X - L_i and cover [j, j + L_i) with this sheet.

Find the number of ways to cover the land with the sheets such that no point in [0, X) remains uncovered, modulo (10^9+7). We consider two ways to cover the land different if and only if there is an integer i (1 \leq i \leq N) such that the region covered by Sheet i is different.

Constraints

* 1 \leq N \leq 100
* 1 \leq L_i \leq X \leq 500
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N X
L_1 L_2 \ldots L_N

Output

Print the answer.

Examples

Input

3 3
1 1 2

Output

10

Input

18 477
324 31 27 227 9 21 41 29 50 34 2 362 92 11 13 17 183 119

Output

134796357

### Response

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    for(int i=0; i<N; i++) cin >> L[i];
    sort(L.begin(), L.end());
    create_mod_tables(2*X);

    const int M = 510;

    int64_t small_invs[M];
    for(int i=1; i<=X; i++) small_invs[i] = inv_mod(i);

    static int64_t pre[M][M][M], pre_inv[M][M][M];
    for(int n=0; n<=X; n++) for(int s=0; s<=X; s++) pre[0][n][s] = pre_inv[0][n][s] = 1;
    for(int i=0; i<N; i++) for(int n=0; n<=X; n++) for(int s=0; s<=X; s++){
        int v = max(1, s-(L[i]-1)*n);
        pre[i+1][n][s] = v * pre[i][n][s] % MOD;
        pre_inv[i+1][n][s] = small_invs[v] * pre_inv[i][n][s] % MOD;
    }

    static int64_t dp[2][M][M][2];
    dp[X%2][0][0][0] = 1;
    int pt = N-1;
    for(int x=X; x>0; x--){
        while(pt >= 0 && L[pt] > x) pt--;
        for(int n=0; n<=X; n++) for(int s=0; s<=X; s++) for(int f=0; f<2; f++){
            if(f == 0 && pt < N-1) continue;
            int64_t bef = dp[x%2][n][s][f] * pre_inv[pt+1][n][s] % MOD;
            if(bef == 0) continue;

            for(int k=0; s+x*k+n+k-1<=X; k++){
                int n2 = n+k, s2 = s+x*k, f2 = f|(k>0);
                int64_t res = bef * pre[pt+1][n2][s2] % MOD * comb_mod(n2, k) % MOD;
                add(dp[(x-1)%2][n2][s2][f2], res);
            }
        }
        for(int n=0; n<=X; n++) for(int s=0; s<=X; s++) for(int f=0; f<2; f++) dp[x%2][n][s][f] = 0;
    }

    int64_t ans = 0;
    for(int n=1; n<=X; n++) for(int s=0; s+n-1<=X; s++){
        int rest = X - (s+n-1);
        int64_t res = comb_mod(rest+n, n) * dp[0][n][s][1] % MOD;
        int blank = X-s;
        if(blank%2) res = MOD-res;
        add(ans, res);
    }
    cout << ans << endl;
    return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

This is the easy version of the problem. The only difference between the easy version and the hard version is the constraints on n. You can only make hacks if both versions are solved.

A permutation of 1, 2, …, n is a sequence of n integers, where each integer from 1 to n appears exactly once. For example, [2,3,1,4] is a permutation of 1, 2, 3, 4, but [1,4,2,2] isn't because 2 appears twice in it.

Recall that the number of inversions in a permutation a_1, a_2, …, a_n is the number of pairs of indices (i, j) such that i < j and a_i > a_j.

Let p and q be two permutations of 1, 2, …, n. Find the number of permutation pairs (p,q) that satisfy the following conditions:

  * p is lexicographically smaller than q.
  * the number of inversions in p is greater than the number of inversions in q.

Print the number of such pairs modulo mod. Note that mod may not be a prime.

Input

The only line contains two integers n and mod (1≤ n≤ 50, 1≤ mod≤ 10^9).

Output

Print one integer, which is the answer modulo mod.

Example

Input

4 403458273

Output

17

Note

The following are all valid pairs (p,q) when n=4.

  * p=[1,3,4,2], q=[2,1,3,4],
  * p=[1,4,2,3], q=[2,1,3,4],
  * p=[1,4,3,2], q=[2,1,3,4],
  * p=[1,4,3,2], q=[2,1,4,3],
  * p=[1,4,3,2], q=[2,3,1,4],
  * p=[1,4,3,2], q=[3,1,2,4],
  * p=[2,3,4,1], q=[3,1,2,4],
  * p=[2,4,1,3], q=[3,1,2,4],
  * p=[2,4,3,1], q=[3,1,2,4],
  * p=[2,4,3,1], q=[3,1,4,2],
  * p=[2,4,3,1], q=[3,2,1,4],
  * p=[2,4,3,1], q=[4,1,2,3],
  * p=[3,2,4,1], q=[4,1,2,3],
  * p=[3,4,1,2], q=[4,1,2,3],
  * p=[3,4,2,1], q=[4,1,2,3],
  * p=[3,4,2,1], q=[4,1,3,2],
  * p=[3,4,2,1], q=[4,2,1,3].

### Response

```cpp
#include <iostream>
#include <cmath>
#include <utility>

using namespace std;

#define mp make_pair
#define x first
#define y second
typedef pair<int,int> pii;
typedef long long ll;

ll dp[55][55][2505],sum[55][2505],suff[55][2505],C[55][55];
int mod;

ll add(ll x,ll y){
	return (x+y)%mod;
}
ll mult(ll x,ll y){
	return x*y%mod;
}

void invprep(){
	dp[1][1][0]=1ll;
	sum[1][0]=1ll;
	for(int i=2;i<=50;i++){
		for(int j=1;j<=i;j++){
			for(int k=0;k<=i*i/2;k++){
				if(k>=j-1) dp[i][j][k]=sum[i-1][k-j+1];
			}
		}
		for(int k=0;k<=i*i/2;k++){
			for(int j=1;j<=i;j++){
				sum[i][k]=add(sum[i][k],dp[i][j][k]);
			}
		}
	}
}
void coefprep(){
	C[1][0]=1ll;
	C[1][1]=1ll;
	for(ll i=2;i<=50;i++){
		C[i][i]=1ll;
		for(int j=0;j<i;j++){
			C[i][j]=mult(C[i-1][j],i);
		}
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin>>n;
	cin>>mod;
	invprep();
	for(int i=1;i<=n;i++){
		for(int j=i*i/2;j>=0;j--){
			suff[i][j]=add(suff[i][j+1],sum[i][j]);
		}
	}
//	for(int i=0;i<=(n-1)*n/2;i++){
//		cout<<sum[n][i]<<" ";
//	}
//	cout<<endl;
	coefprep();
	ll sol=0ll;
	ll temp;
	ll mn;
	ll fakt,suma;
	for(ll i=0;i<n-2;i++){
		mn=C[n][n-i];
		suma=0ll;
		for(ll j=1;j<n-i;j++){
			temp=n-i-j;
			fakt=0ll;
			for(ll k=0;k<n*n/2;k++){
				fakt=add(fakt,mult(sum[n-i-1][k],suff[n-i-1][k+j+1]));
			}
			suma=add(suma,mult(fakt,temp));
		}
		sol=add(sol,mult(mn,suma));
	}
	cout<<sol;

return 0;
}

```


### Prompt

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

AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.

The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.

How many different PIN codes can he set this way?

Both the lucky number and the PIN code may begin with a 0.

Constraints

* 4 \leq N \leq 30000
* S is a string of length N consisting of digits.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the number of different PIN codes Takahashi can set.

Examples

Input

4
0224

Output

3

Input

6
123123

Output

17

Input

19
3141592653589793238

Output

329

### Response

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for(int i = 0;i < 1000;i++){
    int a[3] = {i / 100, (i / 10) % 10, i % 10};
    int cnt = 0;
    for(int j = 0;j < N;j++){
      if(S[j] == ('0' + a[cnt])){
        cnt++;
      }
      if(cnt == 3){
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
```


### Prompt

Please create a solution in cpp to the following problem:

Takahashi is at an all-you-can-eat restaurant.

The restaurant offers N kinds of dishes. It takes A_i minutes to eat the i-th dish, whose deliciousness is B_i.

The restaurant has the following rules:

* You can only order one dish at a time. The dish ordered will be immediately served and ready to eat.
* You cannot order the same kind of dish more than once.
* Until you finish eating the dish already served, you cannot order a new dish.
* After T-0.5 minutes from the first order, you can no longer place a new order, but you can continue eating the dish already served.

Let Takahashi's happiness be the sum of the deliciousness of the dishes he eats in this restaurant.

What is the maximum possible happiness achieved by making optimal choices?

Constraints

* 2 \leq N \leq 3000
* 1 \leq T \leq 3000
* 1 \leq A_i \leq 3000
* 1 \leq B_i \leq 3000
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N T
A_1 B_1
:
A_N B_N

Output

Print the maximum possible happiness Takahashi can achieve.

Examples

Input

2 60
10 10
100 100

Output

110

Input

3 60
10 10
10 20
10 30

Output

60

Input

3 60
30 10
30 20
30 30

Output

50

Input

10 100
15 23
20 18
13 17
24 12
18 29
19 27
23 21
18 20
27 15
22 25

Output

145

### Response

```cpp
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

int n, t;
int a[3000];
int b[3000];
int dp[3000][3000][2];

int f(int i, int j, int k)
{
	if (i == n) return 0;
	int &ret = dp[i][j][k];
	if (ret != -1) return ret;

	ret = f(i + 1, j, k);
	if (j + a[i] < t)
		ret = max(f(i + 1, j + a[i], k) + b[i], ret);

	if (k == 1) ret = max(ret, f(i + 1, j, 0) + b[i]);
	return ret;
}

int main()
{
	fastio;
	cin >> n >> t;
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	memset(dp, -1, sizeof(dp));
	cout << f(0, 0, 1);
}
```


### Prompt

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

Koa the Koala has a directed graph G with n nodes and m edges. Each edge has a capacity associated with it. Exactly k edges of the graph, numbered from 1 to k, are special, such edges initially have a capacity equal to 0.

Koa asks you q queries. In each query she gives you k integers w_1, w_2, …, w_k. This means that capacity of the i-th special edge becomes w_i (and other capacities remain the same).

Koa wonders: what is the [maximum flow](https://en.wikipedia.org/wiki/Maximum_flow_problem#Definition) that goes from node 1 to node n after each such query?

Help her!

Input

The first line of the input contains four integers n, m, k, q (2 ≤ n ≤ 10^4, 1 ≤ m ≤ 10^4, 1 ≤ k ≤ min(10, m), 1 ≤ q ≤ 2 ⋅ 10^5) — the number of nodes, the number of edges, the number of special edges and the number of queries.

Each of the next m lines contains three integers u, v, w (1 ≤ u, v ≤ n; 0 ≤ w ≤ 25) — the description of a directed edge from node u to node v with capacity w.

Edges are numbered starting from 1 in the same order they are listed in the input. The first k edges are the special edges. It is guaranteed that w_i = 0 for all i with 1 ≤ i ≤ k.

Each of the next q lines contains k integers w_1, w_2, …, w_k (0 ≤ w_i ≤ 25) — the description of the query. w_i denotes the capacity of i-th edge.

Output

For the i-th query, print one integer res_i — the maximum flow that can be obtained from node 1 to node n given the i-th query's special edge weights.

Examples

Input

2 1 1 3
1 2 0
0
1
2

Output

0
1
2

Input

4 4 2 5
1 2 0
2 3 0
2 4 5
3 4 2
0 0
1 10
10 0
7 1
7 2

Output

0
1
5
6
7

Note

For the second sample, the following images correspond to the first two queries (from left to right respectively). For each edge there is a pair flow/capacity denoting flow pushed through the edge and edge's capacity. The special edges are colored in red.

<image>

As you can see in first query maximum flow from node 1 to node 4 equals 0 and in second query equals 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vi = vector<int>;
using Pii = pair<int, int>;
int uplg(int n) { return 32 - __builtin_clz(n); }
int uplg(ll n) { return 64 - __builtin_clzll(n); }
void run();
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(18);
  run();
  return 0;
}
using flow_t = int;
constexpr flow_t INF = 1e9 + 10;
struct MaxFlow {
  struct Edge {
    int to, inv;
    flow_t rem, cap;
  };
  vector<basic_string<Edge>> G;
  vector<flow_t> extra;
  Vi hei, arc, prv, nxt, act, bot;
  queue<int> Q;
  int n, high, cut, work;
  MaxFlow(int k = 0) : G(k) {}
  int addEdge(int u, int v, flow_t cap, flow_t rcap = 0) {
    G[u].push_back({v, int((G[v]).size()), 0, cap});
    G[v].push_back({u, int((G[u]).size()) - 1, 0, rcap});
    return int((G[u]).size()) - 1;
  }
  void raise(int v, int h) {
    if (hei[v] < n) prv[nxt[prv[v]] = nxt[v]] = prv[v];
    if ((hei[v] = h) < n) {
      if (extra[v] > 0) {
        bot[v] = act[h], act[h] = v;
        high = max(high, h);
      }
      cut = max(cut, h);
      nxt[v] = nxt[prv[v] = h += n];
      prv[nxt[nxt[h] = v]] = v;
    }
  }
  void global(int t) {
    hei.assign(n, n);
    act.assign(n, -1);
    iota((prv).begin(), (prv).end(), 0);
    iota((nxt).begin(), (nxt).end(), 0);
    hei[t] = high = cut = work = 0;
    for (Q.push(t); !Q.empty(); Q.pop()) {
      int v = Q.front();
      for (auto& e : (G[v]))
        if (hei[e.to] == n && G[e.to][e.inv].rem)
          Q.push(e.to), raise(e.to, hei[v] + 1);
    }
  }
  void push(int v, Edge& e) {
    auto f = min(extra[v], e.rem);
    if (f > 0) {
      if (!extra[e.to]) {
        bot[e.to] = act[hei[e.to]];
        act[hei[e.to]] = e.to;
      }
      e.rem -= f;
      G[e.to][e.inv].rem += f;
      extra[v] -= f;
      extra[e.to] += f;
    }
  }
  void discharge(int v) {
    int h = n;
    auto go = [&](int a, int b) {
      for (int i = (a); i < (b); i++) {
        auto& e = G[v][i];
        if (e.rem) {
          if (hei[v] == hei[e.to] + 1) {
            push(v, e);
            if (extra[v] <= 0) return arc[v] = i, 0;
          } else
            h = min(h, hei[e.to] + 1);
        }
      }
      return 1;
    };
    if (go(arc[v], int((G[v]).size())) && go(0, arc[v])) {
      int k = hei[v] + n;
      if (nxt[k] == prv[k]) {
        for (int j = (k); j < (cut + n + 1); j++)
          while (nxt[j] < n) raise(nxt[j], n);
        cut = k - n - 1;
      } else
        raise(v, h), work++;
    }
  }
  flow_t maxFlow(int src, int dst) {
    extra.assign(n = int((G).size()), 0);
    hei.assign(n, 0);
    arc.assign(n, 0);
    prv.resize(n * 2);
    nxt.resize(n * 2);
    act.resize(n);
    bot.resize(n);
    for (auto& v : (G))
      for (auto& e : (v)) e.rem = e.cap;
    extra[dst] = -(extra[src] = INF);
    for (auto& e : (G[src])) push(src, e);
    global(dst);
    for (; high; high--)
      while (act[high] != -1) {
        int v = act[high];
        act[high] = bot[v];
        if (hei[v] == high) {
          discharge(v);
          if (work > 4 * n) global(dst);
        }
      }
    return extra[dst] + INF;
  }
};
void run() {
  int n, m, k, q;
  cin >> n >> m >> k >> q;
  MaxFlow flow(n);
  vector<Pii> edges;
  for (int i = (0); i < (m); i++) {
    int u, v, w;
    cin >> u >> v >> w;
    edges.push_back({u - 1, flow.addEdge(u - 1, v - 1, w)});
  }
  Vi cuts(1 << k);
  for (int mask = (0); mask < (1 << k); mask++) {
    for (int i = (0); i < (k); i++) {
      Pii e = edges[i];
      flow.G[e.first][e.second].cap = ((mask >> i) & 1 ? 0 : INF);
    }
    cuts[mask] = flow.maxFlow(0, n - 1);
  }
  Vi weights(k), sums(1 << k);
  while (q--) {
    int ans = INF;
    for (auto& w : (weights)) cin >> w;
    for (int mask = (1); mask < (1 << k); mask++)
      sums[mask] = sums[mask & (mask - 1)] + weights[__builtin_ctz(mask)];
    for (int mask = (0); mask < (1 << k); mask++)
      ans = min(ans, cuts[mask] + sums[mask]);
    cout << ans << '\n';
  }
}

```


### Prompt

Develop a solution in cpp to the problem described below:

AtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i. Because he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.

Then, for each card i, he judges whether it is unnecessary or not, as follows:

* If, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.
* Otherwise, card i is NOT unnecessary.

Find the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.

Constraints

* All input values are integers.
* 1≤N≤5000
* 1≤K≤5000
* 1≤a_i≤10^9 (1≤i≤N)

Input

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

N K
a_1 a_2 ... a_N

Output

Print the number of the unnecessary cards.

Examples

Input

3 6
1 4 3

Output

1

Input

5 400
3 1 4 1 5

Output

5

Input

6 20
10 4 3 10 25 2

Output

3

### Response

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

void solve(long long N, long long K, std::vector<long long> a) {
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    ll sum = 0;
    ll res = N;

    for (int i = 0; i < N; i++) {
      if (sum + a[i] < K) {
	  sum += a[i];
      } else {
	  res = min(res, N - i - 1);
      }
    }
    cout << res << endl;
}

int main() {

  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, K, std::move(a));
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

KM country has N kinds of coins and each coin has its value a_i.

The king of the country, Kita_masa, thought that the current currency system is poor, and he decided to make it beautiful by changing the values of some (possibly no) coins.

A currency system is called beautiful if each coin has an integer value and the (i+1)-th smallest value is divisible by the i-th smallest value for all i (1 \leq i \leq N-1).

For example, the set {1, 5, 10, 50, 100, 500} is considered as a beautiful system, while the set {1, 5, 10, 25, 50, 100} is NOT, because 25 is not divisible by 10.

Since changing the currency system may confuse citizens, the king, Kita_masa, wants to minimize the maximum value of the confusion ratios. Here, the confusion ratio for the change in the i-th coin is defined as |a_i - b_i| / a_i, where a_i and b_i is the value of i-th coin before and after the structure changes, respectively.

Note that Kita_masa can change the value of each existing coin, but he cannot introduce new coins nor eliminate existing coins. After the modification, the values of two or more coins may coincide.

Input

Each dataset contains two lines. The first line contains a single integer, N, and the second line contains N integers, {a_i}.

You may assume the following constraints:

1 \leq N \leq 20

1 \leq a_1 \lt a_2 \lt... \lt a_N \lt 10^5

Output

Output one number that represents the minimum of the maximum value of the confusion ratios. The value may be printed with an arbitrary number of decimal digits, but may not contain an absolute error greater than or equal to 10^{-8}.

Examples

Input

3
6 11 12

Output

0.090909090909

Input

3
6 11 24

Output

0.090909090909

Input

3
6 11 30

Output

0.166666666667

### Response

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

using namespace std;

#define MAX_N 21
#define MAX_M 150001
#define INF (1<<29)
typedef long long ll;

double dp[MAX_N][MAX_M];

int main()
{
    int N;
    cin >> N;
    vector<double> v(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }

    fill(dp[0], dp[MAX_N], INF);
    dp[0][1] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = MAX_M-1; j >= 0; j--) {
            if (dp[i][j] == INF) continue;
            for (int k = 1; k <= MAX_M; k++) {
                ll nv = (ll)j * k;
                if (nv >= MAX_M) break;
                dp[i+1][nv] = min(dp[i+1][nv],
                                  max(dp[i][j], abs(v[i]-nv) / v[i]));
            }

        }
    }
    double res = INF;
    for (int i = 0; i < MAX_M; i++) {
        res = min(res, dp[N][i]);
    }
    printf("%.15f\n", res);
    return 0;
}
```


### Prompt

Please create a solution in cpp to the following problem:

A penguin Rocher has n sticks. He has exactly one stick with length i for all 1 ≤ i ≤ n.

He can connect some sticks. If he connects two sticks that have lengths a and b, he gets one stick with length a + b. Two sticks, that were used in the operation disappear from his set and the new connected stick appears in his set and can be used for the next connections.

He wants to create the maximum number of sticks that have the same length. It is not necessary to make all sticks have the same length, some sticks can have the other length. How many sticks with the equal length he can create?

Input

The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases. Next t lines contain descriptions of test cases.

For each test case, the only line contains a single integer n (1 ≤ n ≤ 10^{9}).

Output

For each test case, print a single integer — the answer to the problem.

Example

Input

4
1
2
3
4

Output

1
1
2
2

Note

In the third case, he can connect two sticks with lengths 1 and 2 and he will get one stick with length 3. So, he will have two sticks with lengths 3.

In the fourth case, he can connect two sticks with lengths 1 and 3 and he will get one stick with length 4. After that, he will have three sticks with lengths \{2, 4, 4\}, so two sticks have the same length, and one stick has the other length.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    cout << (long long int)ceil((double)n / (double)2) << endl;
  }
}

```


### Prompt

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

Makoto has a big blackboard with a positive integer n written on it. He will perform the following action exactly k times:

Suppose the number currently written on the blackboard is v. He will randomly pick one of the divisors of v (possibly 1 and v) and replace v with this divisor. As Makoto uses his famous random number generator (RNG) and as he always uses 58 as his generator seed, each divisor is guaranteed to be chosen with equal probability.

He now wonders what is the expected value of the number written on the blackboard after k steps.

It can be shown that this value can be represented as P/Q where P and Q are coprime integers and Q not≡ 0 \pmod{10^9+7}. Print the value of P ⋅ Q^{-1} modulo 10^9+7.

Input

The only line of the input contains two integers n and k (1 ≤ n ≤ 10^{15}, 1 ≤ k ≤ 10^4).

Output

Print a single integer — the expected value of the number on the blackboard after k steps as P ⋅ Q^{-1} \pmod{10^9+7} for P, Q defined above.

Examples

Input

6 1

Output

3

Input

6 2

Output

875000008

Input

60 5

Output

237178099

Note

In the first example, after one step, the number written on the blackboard is 1, 2, 3 or 6 — each occurring with equal probability. Hence, the answer is (1+2+3+6)/(4)=3.

In the second example, the answer is equal to 1 ⋅ 9/16+2 ⋅ 3/16+3 ⋅ 3/16+6 ⋅ 1/16=15/8.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 4;
const int MOD = 1e9 + 7;
const int K = 100;
int dp[N][K];
int vis[N][K], visid;
long long inv[K], pw[K];
long long p;
int k;
long long power(long long a, long long b) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b & 1) {
      x = (x * y);
      if (x > MOD) x %= MOD;
    }
    y = y * y;
    if (y > MOD) y %= MOD;
    b >>= 1;
  }
  return x;
}
int solve(int idx, int j) {
  int &ret = dp[idx][j];
  if (vis[idx][j] == visid) return ret;
  vis[idx][j] = visid;
  if (idx == k) return ret = pw[j];
  ret = 0;
  for (int i = 0; i <= j; i++) {
    ret += solve(idx + 1, j - i) * inv[j + 1] % MOD;
    if (ret >= MOD) ret -= MOD;
  }
  return ret;
}
int main() {
  pw[0] = 1;
  for (int i = 1; i < K; i++) inv[i] = power(i, MOD - 2) % MOD;
  long long ans = 1;
  long long n;
  cin >> n >> k;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      visid++;
      p = i;
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      for (int j = 1; j <= cnt; j++) pw[j] = 1LL * pw[j - 1] * i % MOD;
      ans = ans * solve(0, cnt) % MOD;
    }
  }
  if (n != 1) {
    p = n;
    pw[1] = n % MOD;
    visid++;
    ans = ans * solve(0, 1) % MOD;
  }
  cout << ans << "\n";
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.

In this problem, we call the greater number of a twin prime "size of the twin prime."

Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n

You may assume that 5 ≤ n ≤ 10000.

Input

The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:

n (integer)

Output

For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.

Example

Input

12
100
200
300
0

Output

5 7
71 73
197 199
281 283

### Response

```cpp
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int N = 100000;

	bool a[100000];

	for(int i = 0; i < N; i++){
		a[i] = true;
	}

	a[0] = false;
	a[1] = false;

	for(int i = 2; i < N; i++){
		if(a[i]){
			for(int j = i * 2; j < N; j += i){
				a[j] = false;
			}
		}
	}

	int n;

	while(true){
		cin >> n;
		if(n == 0){
			break;
		}else if(n < 5 || n > 10000){
			printf("NA\n");
			continue;
		}else{
			for(int i = n; i > 2; i--){
				if(a[i] && a[i - 2]){
					printf("%d %d\n", i - 2, i);
					break;
				}
			}
		}
	}

	return 0;
}
```


### Prompt

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

Filya just learned new geometry object — rectangle. He is given a field consisting of n × n unit cells. Rows are numbered from bottom to top with integer from 1 to n. Columns are numbered from left to right with integers from 1 to n. Cell, located at the intersection of the row r and column c is denoted as (r, c). Filya has painted two rectangles, such that their sides are parallel to coordinate axes and each cell lies fully inside or fully outside each of them. Moreover, no cell lies in both rectangles.

Later, hedgehog Filya became interested in the location of his rectangles but was unable to find the sheet of paper they were painted on. They were taken by Sonya and now she wants to play a little game with Filya. He tells her a query rectangle and she replies with the number of initial rectangles that lie fully inside the given query rectangle. The query rectangle should match the same conditions as initial rectangles. Rectangle lies fully inside the query if each o its cells lies inside the query.

Filya knows Sonya really well, so is sure that if he asks more than 200 questions she will stop to reply.

Input

The first line of the input contains an integer n (2 ≤ n ≤ 216) — size of the field.

For each query an integer between 0 and 2 is returned — the number of initial rectangles that lie fully inside the query rectangle.

Output

To make a query you have to print "? x1 y1 x2 y2" (without quotes) (1 ≤ x1 ≤ x2 ≤ n, 1 ≤ y1 ≤ y2 ≤ n), where (x1, y1) stands for the position of the bottom left cell of the query and (x2, y2) stands for the up right cell of the query. You are allowed to ask no more than 200 queries. After each query you should perform "flush" operation and read the answer.

In case you suppose you've already determined the location of two rectangles (or run out of queries) you should print "! x11 y11 x12 y12 x21 y21 x22 y22" (without quotes), where first four integers describe the bottom left and up right cells of the first rectangle, and following four describe the corresponding cells of the second rectangle. You can print the rectangles in an arbitrary order. After you have printed the answer, print the end of the line and perform "flush". Your program should terminate immediately after it print the answer.

Interaction

To flush you can use (just after printing an integer and end-of-line):

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

You will get the Wrong Answer verdict if you ask more than 200 queries, or if you print an incorrect coordinates.

You will get the Idleness Limit Exceeded verdict if you don't print anything (but you should) or if you forget about flushing the output (more info below).

Hacking.

The first line should contain an integer n (2 ≤ n ≤ 216).

The second line should contain four integers x1, y1, x2, y2 (1 ≤ x1 ≤ x2 ≤ n, 1 ≤ y1 ≤ y2 ≤ n) — the description of the first rectangle.

The third line contains the description of the second rectangle in the similar way.

Example

Input

5
2
1
0
1
1
1
0
1

Output

? 1 1 5 5
? 1 1 3 3
? 1 1 3 1
? 2 2 2 2
? 3 3 5 5
? 3 3 3 5
? 3 3 3 4
? 3 4 3 5
! 2 2 2 2 3 4 3 5

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct abc {
  int x1, y1, x2, y2;
  void print() { cout << x1 << " " << y1 << " " << x2 << " " << y2 << " "; }
};
int query(int x1, int y1, int x2, int y2) {
  if (x1 > x2) swap(x1, x2);
  if (y1 > y2) swap(y1, y2);
  cout << "? " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
  int ans;
  cin >> ans;
  return ans;
}
abc fi(int xx1, int yy1, int xx2, int yy2) {
  abc Ans;
  int l = yy1, r = yy2, ans = yy1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (query(xx1, yy1, xx2, mid) < 1)
      l = mid + 1;
    else
      r = mid - 1, ans = mid;
  }
  Ans.y2 = ans;
  l = yy1, r = yy2, ans = yy1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (query(xx1, mid, xx2, yy2) < 1)
      r = mid - 1;
    else
      l = mid + 1, ans = mid;
  }
  Ans.y1 = ans;
  l = xx1, r = xx2, ans = xx1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (query(xx1, yy1, mid, yy2) < 1)
      l = mid + 1;
    else
      r = mid - 1, ans = mid;
  }
  Ans.x2 = ans;
  l = xx1, r = xx2, ans = xx1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (query(mid, yy1, xx2, yy2) < 1)
      r = mid - 1;
    else
      l = mid + 1, ans = mid;
  }
  Ans.x1 = ans;
  return Ans;
}
int main() {
  int n;
  scanf("%d", &n);
  int l = 1, r = n, ans = 1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (query(1, 1, mid, n) < 1)
      l = mid + 1;
    else
      r = mid - 1, ans = mid;
  }
  if (query(1, 1, ans, n) == 1 && query(ans + 1, 1, n, n) == 1) {
    abc r1 = fi(1, 1, ans, n);
    abc r2 = fi(ans + 1, 1, n, n);
    cout << "! ";
    r1.print();
    r2.print();
    return 0;
  }
  l = 1, r = n, ans = 1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (query(1, 1, n, mid) < 1)
      l = mid + 1;
    else
      r = mid - 1, ans = mid;
  }
  abc r1 = fi(1, 1, n, ans);
  abc r2 = fi(1, ans + 1, n, n);
  cout << "! ";
  r1.print();
  r2.print();
}

```


### Prompt

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

Example

Input

1

Output

)(

### Response

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

int A;
int c[200010];
int n,now;

int main()
{
	scanf("%d",&A);
	n=1;
	while ((ll)n*(n+1)/2<(ll)A) n++;
	int p=A-(ll)n*(n-1)/2;
	c[1]=1;	c[1+p]=2;now=1;
	for(int i=1;i<=2*n;i++) if(c[i]==0) if(now<n) c[i]=1,now++;else c[i]=2;
	for(int i=1;i<=2*n;i++) if(c[i]==1) printf(")");else printf("(");
	printf("\n");
	return 0;
}
```


### Prompt

Develop a solution in CPP to the problem described below:

After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3».

The game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are numbered form 1 to (m + 1). Types of soldiers are numbered from 0 to n - 1. Each player has an army. Army of the i-th player can be described by non-negative integer xi. Consider binary representation of xi: if the j-th bit of number xi equal to one, then the army of the i-th player has soldiers of the j-th type.

Fedor is the (m + 1)-th player of the game. He assume that two players can become friends if their armies differ in at most k types of soldiers (in other words, binary representations of the corresponding numbers differ in at most k bits). Help Fedor and count how many players can become his friends.

Input

The first line contains three integers n, m, k (1 ≤ k ≤ n ≤ 20; 1 ≤ m ≤ 1000).

The i-th of the next (m + 1) lines contains a single integer xi (1 ≤ xi ≤ 2n - 1), that describes the i-th player's army. We remind you that Fedor is the (m + 1)-th player.

Output

Print a single integer — the number of Fedor's potential friends.

Examples

Input

7 3 1
8
5
111
17

Output

0

Input

3 3 3
1
2
3
4

Output

3

### Response

```cpp
#include <bits/stdc++.h>
#pragma gcc optimize("Ofast")
using namespace std;
const int INF = signed(1e9) + 7;
const long double EPS = 1e-7, Pi = acos(-1);
bitset<21> bts[1001];
void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m + 1; ++i) {
    int q;
    cin >> q;
    bts[i] |= q;
  }
  int ans = 0;
  for (int i = 0; i < m; ++i) {
    ans += int((bts[i] ^ bts[m]).count() <= k);
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(10);
  int tests = 1;
  while (tests--) {
    solve();
  }
}

```


### Prompt

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

The Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the number of times he/she has participated in the ACM ICPC world programming championship. According to the ACM ICPC rules, each person can participate in the world championship at most 5 times.

The head of the SSU OPTC is recently gathering teams to participate in the world championship. Each team must consist of exactly three people, at that, any person cannot be a member of two or more teams. What maximum number of teams can the head make if he wants each team to participate in the world championship with the same members at least k times?

Input

The first line contains two integers, n and k (1 ≤ n ≤ 2000; 1 ≤ k ≤ 5). The next line contains n integers: y1, y2, ..., yn (0 ≤ yi ≤ 5), where yi shows the number of times the i-th person participated in the ACM ICPC world championship.

Output

Print a single number — the answer to the problem.

Examples

Input

5 2
0 4 5 1 0

Output

1

Input

6 4
0 1 2 3 4 5

Output

0

Input

6 5
0 0 0 0 0 0

Output

2

Note

In the first sample only one team could be made: the first, the fourth and the fifth participants.

In the second sample no teams could be created.

In the third sample two teams could be created. Any partition into two teams fits.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, temp, res = 0;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> temp;
    if (temp <= 5 - k) res++;
  }
  cout << (res / 3) << endl;
  return 0;
}

```


### Prompt

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

Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler!

However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has n marks, with which he can make measurements. We assume that the marks are numbered from 1 to n in the order they appear from the beginning of the ruler to its end. The first point coincides with the beginning of the ruler and represents the origin. The last mark coincides with the end of the ruler, at distance l from the origin. This ruler can be repesented by an increasing sequence a1, a2, ..., an, where ai denotes the distance of the i-th mark from the origin (a1 = 0, an = l).

Valery believes that with a ruler he can measure the distance of d centimeters, if there is a pair of integers i and j (1 ≤ i ≤ j ≤ n), such that the distance between the i-th and the j-th mark is exactly equal to d (in other words, aj - ai = d).

Under the rules, the girls should be able to jump at least x centimeters, and the boys should be able to jump at least y (x < y) centimeters. To test the children's abilities, Valery needs a ruler to measure each of the distances x and y.

Your task is to determine what is the minimum number of additional marks you need to add on the ruler so that they can be used to measure the distances x and y. Valery can add the marks at any integer non-negative distance from the origin not exceeding the length of the ruler.

Input

The first line contains four positive space-separated integers n, l, x, y (2 ≤ n ≤ 105, 2 ≤ l ≤ 109, 1 ≤ x < y ≤ l) — the number of marks, the length of the ruler and the jump norms for girls and boys, correspondingly.

The second line contains a sequence of n integers a1, a2, ..., an (0 = a1 < a2 < ... < an = l), where ai shows the distance from the i-th mark to the origin.

Output

In the first line print a single non-negative integer v — the minimum number of marks that you need to add on the ruler.

In the second line print v space-separated integers p1, p2, ..., pv (0 ≤ pi ≤ l). Number pi means that the i-th mark should be at the distance of pi centimeters from the origin. Print the marks in any order. If there are multiple solutions, print any of them.

Examples

Input

3 250 185 230
0 185 250

Output

1
230

Input

4 250 185 230
0 20 185 250

Output

0

Input

2 300 185 230
0 300

Output

2
185 230

Note

In the first sample it is impossible to initially measure the distance of 230 centimeters. For that it is enough to add a 20 centimeter mark or a 230 centimeter mark.

In the second sample you already can use the ruler to measure the distances of 185 and 230 centimeters, so you don't have to add new marks.

In the third sample the ruler only contains the initial and the final marks. We will need to add two marks to be able to test the children's skills.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[100005];
bool solve();
int finds(int);
int n, length, x, y;
int main() {
  scanf("%d%d%d%d", &n, &length, &x, &y);
  memset(a, 0, sizeof(a));
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  solve();
  return 0;
}
bool solve() {
  int r1, r2, r3, r4;
  r1 = finds(x);
  r2 = finds(y);
  r3 = finds(x + y);
  r4 = finds(y - x);
  if (r1 != -1 && r2 != -1) {
    printf("0\n");
  } else {
    if (r1 != -1)
      printf("%d\n%d\n", 1, y);
    else if (r2 != -1)
      printf("%d\n%d\n", 1, x);
    else if (r3 != -1)
      printf("%d\n%d\n", 1, r3 - y);
    else if (r4 != -1) {
      if (r4 - y > 0)
        printf("%d\n%d\n", 1, r4 - y);
      else if (r4 + x < length)
        printf("%d\n%d\n", 1, r4 + x);
    } else
      printf("%d\n%d %d\n", 2, x, y);
  }
  return true;
}
int finds(int pos) {
  int tmp;
  for (int i = 0; i < n; i++) {
    tmp = lower_bound(a, a + n, a[i] + pos) - a;
    if (tmp == n)
      break;
    else {
      if (a[tmp] == a[i] + pos) {
        if (pos == y - x) {
          if (a[tmp] - y < 0 && a[tmp] + x > length)
            continue;
          else
            return a[tmp];
        } else
          return a[tmp];
      }
    }
  }
  return -1;
}

```


### Prompt

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

A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).

Your task is to find out if a given integer is a triangular number.

Input

The first line contains the single number n (1 ≤ n ≤ 500) — the given integer.

Output

If the given integer is a triangular number output YES, otherwise output NO.

Examples

Input

1

Output

YES

Input

2

Output

NO

Input

3

Output

YES

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  cin >> n;
  n *= 2;
  for (int i = 1; i < n; i++) {
    if (i * (i + 1) > n)
      break;
    else if (i * (i + 1) != n)
      continue;
    else {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

```


### Prompt

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

Ostap is preparing to play chess again and this time he is about to prepare. Thus, he was closely monitoring one recent chess tournament. There were m players participating and each pair of players played exactly one game. The victory gives 2 points, draw — 1 points, lose — 0 points.

Ostap is lazy, so he never tries to remember the outcome of each game. Instead, he computes the total number of points earned by each of the players (the sum of his points in all games which he took part in), sort these value in non-ascending order and then remembers first n integers in this list.

Now the Great Strategist Ostap wonders whether he remembers everything correct. He considers that he is correct if there exists at least one tournament results table such that it will produce the given integers. That means, if we count the sum of points for each player, sort them and take first n elements, the result will coincide with what Ostap remembers. Can you check if such table exists?

Input

The first line of the input contains two integers m and n (1 ≤ n ≤ m ≤ 3000) — the number of participants of the tournament and the number of top results Ostap remembers.

The second line contains n integers, provided in non-ascending order — the number of points earned by top participants as Ostap remembers them. It's guaranteed that this integers are non-negative and do not exceed 2·m.

Output

If there is no tournament such that Ostap can obtain the given set of integers using the procedure described in the statement, then print "no" in the only line of the output. Otherwise, the first line of the output should contain the word "yes". Next m lines should provide the description of any valid tournament. Each of these lines must contain m characters 'X', 'W', 'D' and 'L'. Character 'X' should always be located on the main diagonal (and only there), that is on the i-th position of the i-th string. Character 'W' on the j-th position of the i-th string means that the i-th player won the game against the j-th. In the same way character 'L' means loose and 'D' means draw.

The table you print must be consistent and the points earned by best n participants should match the memory of Ostap. If there are many possible answers, print any of them.

Examples

Input

5 5
8 6 4 2 0

Output

yes
XWWWW
LXWWW
LLXWW
LLLXW
LLLLX

Input

5 1
9

Output

no

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') ch == '-' && (f = 0) || (ch = getchar());
  while (ch <= '9' && ch >= '0')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return f ? x : -x;
}
int n, m, f[3010][3010];
struct misaka {
  int x, y;
  friend bool operator<(const misaka &p, const misaka &q) { return p.x > q.x; }
} a[3010];
void get(int k) {
  sort(a + k, a + n + 1);
  int w = a[k].x;
  for (int i = n; i > k; i--) {
    if (w > 1)
      w -= 2, f[a[k].y][a[i].y] = 1;
    else if (!w)
      a[i].x -= 2, f[a[i].y][a[k].y] = 1;
    else
      w--, a[i].x--, f[a[k].y][a[i].y] = f[a[i].y][a[k].y] = 2;
  }
  a[k].x = 0;
}
int main(int argc, char const *argv[]) {
  cin >> n >> m;
  int x = 0, sum = 0;
  for (int i = 1; i <= m; i++) {
    cin >> a[i].x;
    a[i].y = i;
    x += n - i << 1;
    sum += a[i].x;
    if (sum > x) return puts("no") & 0;
  }
  for (int i = m + 1; i <= n; i++) {
    a[i].y = i;
    x += n - i << 1;
    a[i].x = min(a[i - 1].x, x - sum);
    sum += a[i].x;
  }
  if (sum != x) return puts("no") & 0;
  for (int i = 1; i < n; i++) get(i);
  puts("yes");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j)
        putchar('X');
      else if (!f[i][j])
        putchar('L');
      else if (f[i][j] == 1)
        putchar('W');
      else
        putchar('D');
    }
    puts("");
  }
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Sonya decided that having her own hotel business is the best way of earning money because she can profit and rest wherever she wants.

The country where Sonya lives is an endless line. There is a city in each integer coordinate on this line. She has n hotels, where the i-th hotel is located in the city with coordinate x_i. Sonya is a smart girl, so she does not open two or more hotels in the same city.

Sonya understands that her business needs to be expanded by opening new hotels, so she decides to build one more. She wants to make the minimum distance from this hotel to all others to be equal to d. The girl understands that there are many possible locations to construct such a hotel. Thus she wants to know the number of possible coordinates of the cities where she can build a new hotel.

Because Sonya is lounging in a jacuzzi in one of her hotels, she is asking you to find the number of cities where she can build a new hotel so that the minimum distance from the original n hotels to the new one is equal to d.

Input

The first line contains two integers n and d (1≤ n≤ 100, 1≤ d≤ 10^9) — the number of Sonya's hotels and the needed minimum distance from a new hotel to all others.

The second line contains n different integers in strictly increasing order x_1, x_2, …, x_n (-10^9≤ x_i≤ 10^9) — coordinates of Sonya's hotels.

Output

Print the number of cities where Sonya can build a new hotel so that the minimum distance from this hotel to all others is equal to d.

Examples

Input

4 3
-3 2 9 16

Output

6

Input

5 2
4 8 11 18 19

Output

5

Note

In the first example, there are 6 possible cities where Sonya can build a hotel. These cities have coordinates -6, 5, 6, 12, 13, and 19.

In the second example, there are 5 possible cities where Sonya can build a hotel. These cities have coordinates 2, 6, 13, 16, and 21.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[101], i, d, s = 2;
  cin >> n >> d;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 2; i <= n; i++) {
    if (a[i] - a[i - 1] > 2 * d)
      s += 2;
    else if (a[i] - a[i - 1] == 2 * d)
      s++;
  }
  cout << s;
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Mike has always been thinking about the harshness of social inequality. He's so obsessed with it that sometimes it even affects him while solving problems. At the moment, Mike has two sequences of positive integers A = [a1, a2, ..., an] and B = [b1, b2, ..., bn] of length n each which he uses to ask people some quite peculiar questions.

To test you on how good are you at spotting inequality in life, he wants you to find an "unfair" subset of the original sequence. To be more precise, he wants you to select k numbers P = [p1, p2, ..., pk] such that 1 ≤ pi ≤ n for 1 ≤ i ≤ k and elements in P are distinct. Sequence P will represent indices of elements that you'll select from both sequences. He calls such a subset P "unfair" if and only if the following conditions are satisfied: 2·(ap1 + ... + apk) is greater than the sum of all elements from sequence A, and 2·(bp1 + ... + bpk) is greater than the sum of all elements from the sequence B. Also, k should be smaller or equal to <image> because it will be to easy to find sequence P if he allowed you to select too many elements!

Mike guarantees you that a solution will always exist given the conditions described above, so please help him satisfy his curiosity!

Input

The first line contains integer n (1 ≤ n ≤ 105) — the number of elements in the sequences.

On the second line there are n space-separated integers a1, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.

On the third line there are also n space-separated integers b1, ..., bn (1 ≤ bi ≤ 109) — elements of sequence B.

Output

On the first line output an integer k which represents the size of the found subset. k should be less or equal to <image>.

On the next line print k integers p1, p2, ..., pk (1 ≤ pi ≤ n) — the elements of sequence P. You can print the numbers in any order you want. Elements in sequence P should be distinct.

Example

Input

5
8 7 4 8 3
4 2 5 3 7

Output

3
1 4 5

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 50;
struct A {
  int x, y, i;
} a[MAXN];
vector<int> v;
bool cmp(A a, A b) {
  if (a.x == b.x) return a.y > b.y;
  return a.x > b.x;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].x;
    a[i].i = i;
  }
  for (int i = 1; i <= n; i++) {
    cin >> a[i].y;
  }
  sort(a + 1, a + n + 1, cmp);
  v.push_back(a[1].i);
  if (n % 2 == 0) {
    v.push_back(a[n].i);
  }
  for (int i = 2; i <= n - 1; i += 2) {
    if (a[i].y >= a[i + 1].y) {
      v.push_back(a[i].i);
    } else
      v.push_back(a[i + 1].i);
  }
  int l = v.size();
  cout << l << endl;
  for (int i = 0; i < l; i++) {
    cout << v[i] << ' ';
  }
  cout << endl;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

The cows have just learned what a primitive root is! Given a prime p, a primitive root <image> is an integer x (1 ≤ x < p) such that none of integers x - 1, x2 - 1, ..., xp - 2 - 1 are divisible by p, but xp - 1 - 1 is.

Unfortunately, computing primitive roots can be time consuming, so the cows need your help. Given a prime p, help the cows find the number of primitive roots <image>.

Input

The input contains a single line containing an integer p (2 ≤ p < 2000). It is guaranteed that p is a prime.

Output

Output on a single line the number of primitive roots <image>.

Examples

Input

3

Output

1

Input

5

Output

2

Note

The only primitive root <image> is 2.

The primitive roots <image> are 2 and 3.

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
using namespace std;
int main() {
  int p, ans = 0;
  scanf("%d", &p);
  for (int x = 1; x < p; x++) {
    int i, y = 1;
    for (i = 1; i <= p - 2; i++) {
      y = y * x % p;
      if (y == 1) break;
    }
    if (i == p - 1 && y * x % p == 1) ans++;
  }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

I have n tickets for a train with a rabbit. Each ticket is numbered from 0 to n − 1, and you can use the k ticket to go to p⋅ak + q⋅bk station.

Rabbit wants to go to the all-you-can-eat carrot shop at the station m station ahead of the current station, but wants to walk as short as possible. The stations are lined up at regular intervals. When using, how many stations can a rabbit walk to reach the store?

Input

1 ≤ n, m, a, b, p, q ≤ 1 000 000 000 000 (integer)

Output

Output the number of rabbits that can reach the store on foot at the minimum number of stations in one line.

Examples

Input

6 200 2 3 4 5

Output

1

Input

6 1 2 3 4 5

Output

1

### Response

```cpp
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod*mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

//t個が1,x以下とx以上を求める
LP calc(ll x, int t,int sup=40) {
	vector<int> v;
	rep(i, sup) {
		ll k = (ll)1 << i;
		if (x&k)v.push_back(i);
	}
	int len = v.size();
	ll le = 0;
	if (t <= len) {
		for (int i = len - 1; i >= len - t; i--) {
			le += (ll)1 << v[i];
		}
	}
	else {
		bool f = false;
		rep(i, len) {
			int cnt = v[i];
			cnt += len - 1 - i;
			if (cnt >= t) {
				for (int j = len - 1; j > i; j--) {
					le += (ll)1<<v[j];
				}
				int r = t - (len - 1 - i);
				rep(j, r) {
					le += (ll)1 << j;
				}
				f = true;
				break;
			}
		}
		if (!f)le = -INF;
	}
	ll ri = 0;
	if (t <= len) {
		int tmp = len;
		rep(i, sup) {
			ll k = (ll)1 << i;
			if (k&x) {
				tmp--; continue;
			}
			int cnt = i;
			cnt += tmp;
			cnt++;
			if (tmp + 1 <= t && cnt >= t) {
				ri += k;
				Rep(j, len-tmp, len) {
					ri += (ll)1 << v[j];
				}
				int r = t - (tmp + 1);
				rep(j, r) {
					ri += (ll)1 << j;
				}
				break;
			}
		}
	}
	else {
		rep(i, len) {
			ri += (ll)1 << v[i];
		}
		int r = t - len;
		rep(j, sup) {
			if (r == 0)break;
			ll k = (ll)1 << j;
			if ((x&k) == 0) {
				ri += k; r--;
			}
		}
	}
	return { le,ri };
}
string add(string a, string b) {
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	int len = max(a.length(), b.length());
	int rest = 0; string res;
	rep(i, len + 1) {
		if (i < (int)a.length()) {
			rest += a[i] - '0';
		}
		if (i < (int)b.length()) {
			rest += b[i] - '0';
		}
		res.push_back('0' + (rest % 10));
		rest /= 10;
	}
	while (res.length() && res[res.length() - 1] == '0')res.erase(res.end() - 1);
	reverse(res.begin(), res.end());
	return res;
}
string multi0(int m, string a) {
	string res;
	reverse(a.begin(), a.end());
	int len = a.length();
	int rest = 0;
	rep(i, len) {
		rest += m * (a[i] - '0');
		res.push_back('0' + (rest % 10));
		rest /= 10;
	}
	if (rest)res.push_back('0' + rest);
	reverse(res.begin(), res.end());
	return res;
}
string multi(string a, string b) {
	int len = a.length(); string res = "0";
	per(i, len) {
		int t = a[i] - '0'; int rest = len - i - 1;
		string nex = multi0(t, b);
		rep(j, rest) {
			nex.push_back('0');
		}
		res = add(res, nex);
	}
	return res;
}
bool invalid(ll a,ll p) {
	string s = to_string(a); string t = to_string(p);
	string st = multi(s, t);
	if (st.size() >= 15)return true;
	else return false;
}
void solve() {
	ll n, m, a, b, p, q; cin >> n >> m >> a >> b >> p >> q;
	if (a > b) {
		swap(a, b); swap(p, q);
	}
	ll ans = INF;
	if (invalid(a, p) || invalid(b, q)) {
		ans = m;
		ans = min(ans, abs(m - p - q));
	}
	else if (invalid(a,a)||invalid(b,b)) {
		//cout << "hello" << endl;
		ans = min(ans, m);
		ans = min(ans, abs(m - p - q));
		if (n > 1) {
			ans = min(ans, abs(m - p * a - q * b));
			ans = min(ans, abs(m - p * a - q * b - p - q));
		}
	}
	else if (a == 1 && b == 1) {
		ll le = m / (p + q);
		if (n < le) {
			ll sum = (p + q)*n;
			ans = min(ans, m - sum);
		}
		else {
			ans = min(ans, m - (p + q)*le);
		}
		if (n >= le + 1) {
			ans = min(ans, (p + q)*(le + 1) - m);
		}
	}
	else if (a == 1 && b == 2) {
		ll x = a, y = b;
		rep(i, n) {
			ll sum = p * x + q * y;
			if (sum >= m) {
				ans = min(ans, sum - m); break;
			}
			x = x * a; y = y * b;
		}
		ll s = min(n, (ll)40);
		//i個使う
		rep1(i, s) {
			ll mm = m - i * p;
			ll d = mm / q;
			LP z = calc(d, i, s);
			if (z.first != -INF) {
				ans = min(ans, abs(mm - q * z.first));
			}
			ans = min(ans, abs(mm - q * z.second));
			//ll lesum = q * z.first, risum = q * z.second;
			//cout << lesum + i * p << " i " << risum + i * p << endl;
			//ans = min(ans, abs(mm - lesum));
			//ans = min(ans, abs(risum - mm));
		}
	}
	else if (a == 2 && b == 2) {
		ll d = m / (p + q);
		ll s = min(n, (ll)40);
		ll z = 0;
		rep(i, s) {
			z += (ll)1 << i;
		}
		if (z < m)ans = min(ans, m - z * (p + q));
		else {
			ll le = d;
			ans = min(ans, m - le * (p + q));
			le++;
			ll las = 0;
			rep(i, 40) {
				ll k = (ll)1 << i;
				if (k&le) {
					las = i;
				}
			}
			if (las < n) {
				ans = min(ans, m - le * (p + q));
			}
		}
	}
	else {
		ll x = 1, y = 1;
		vector<ll> v;
		rep(i, n) {
			ll sum = p * x + q * y;
			if (sum >= m) {
				ans = min(ans, sum - m);
				break;
			}
			v.push_back(sum);
			x = x * a; y = y * b;
		}
		int len = v.size();
		ll sum = 0;
		per(i, v.size()) {
			if (sum + v[i] <= m) {
				sum += v[i];
			}
			else {
				ans = min(ans, abs(m - sum-v[i]));
			}
		}
		ans = min(ans, abs(m - sum));
		/*cout << len << endl;
		rep(i, (1 << len)) {
			ll u = 0;
			rep(j, len) {
				if (i&(1 << j))u += v[j];
			}
			ans = min(ans, abs(m - u));
		}*/
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn.

Your task is to find such permutation p of length n, that the group of numbers |p1 - p2|, |p2 - p3|, ..., |pn - 1 - pn| has exactly k distinct elements.

Input

The single line of the input contains two space-separated positive integers n, k (1 ≤ k < n ≤ 105).

Output

Print n integers forming the permutation. If there are multiple answers, print any of them.

Examples

Input

3 2

Output

1 3 2

Input

3 1

Output

1 2 3

Input

5 2

Output

1 3 2 4 5

Note

By |x| we denote the absolute value of number x.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (cin >> n >> m) {
    int i = 1;
    for (i; i <= m; i++) {
      if (i != 1) printf(" ");
      if (i % 2 == 1)
        printf("%d", i / 2 + 1);
      else
        printf("%d", n - i / 2 + 1);
    }
    if (i % 2 == 1) {
      int end = (i + 1) / 2;
      for (int j = n - (i + 1) / 2 + 1; j >= end; j--) {
        printf(" %d", j);
      }
      printf("\n");
    } else {
      int end = n - (i + 1) / 2 + 1;
      for (int j = (i - 1) / 2 + 2; j <= end; j++) {
        printf(" %d", j);
      }
      printf("\n");
    }
  }
}

```


### Prompt

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

Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next to each other, forming a row.

Sometimes Alyona chooses some segment towers, and put on the top of each tower several cubes. Formally, Alyouna chooses some segment of towers from li to ri and adds di cubes on the top of them.

Let the sequence a1, a2, ..., an be the heights of the towers from left to right. Let's call as a segment of towers al, al + 1, ..., ar a hill if the following condition holds: there is integer k (l ≤ k ≤ r) such that al < al + 1 < al + 2 < ... < ak > ak + 1 > ak + 2 > ... > ar.

After each addition of di cubes on the top of the towers from li to ri, Alyona wants to know the maximum width among all hills. The width of a hill is the number of towers in it.

Input

The first line contain single integer n (1 ≤ n ≤ 3·105) — the number of towers.

The second line contain n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the number of cubes in each tower.

The third line contain single integer m (1 ≤ m ≤ 3·105) — the number of additions.

The next m lines contain 3 integers each. The i-th of these lines contains integers li, ri and di (1 ≤ l ≤ r ≤ n, 1 ≤ di ≤ 109), that mean that Alyona puts di cubes on the tio of each of the towers from li to ri.

Output

Print m lines. In i-th line print the maximum width of the hills after the i-th addition.

Example

Input

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

Output

2
4
5

Note

The first sample is as follows:

After addition of 2 cubes on the top of each towers from the first to the third, the number of cubes in the towers become equal to [7, 7, 7, 5, 5]. The hill with maximum width is [7, 5], thus the maximum width is 2.

After addition of 1 cube on the second tower, the number of cubes in the towers become equal to [7, 8, 7, 5, 5]. The hill with maximum width is now [7, 8, 7, 5], thus the maximum width is 4.

After addition of 1 cube on the fourth tower, the number of cubes in the towers become equal to [7, 8, 7, 6, 5]. The hill with maximum width is now [7, 8, 7, 6, 5], thus the maximum width is 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1500001;
struct JS {
  int l, r, sum, ld, rd, ud, lud, udr;
  long long d, lone, rone;
} f[N];
int i, j, n, m;
long long a[N], b[N];
void update(int k) {
  if (f[k].l == f[k].r) {
    return;
  }
  long long x = f[2 * k].rone + f[2 * k].d,
            y = f[2 * k + 1].lone + f[2 * k + 1].d;
  f[k].lone = f[2 * k].lone + f[2 * k].d;
  f[k].rone = f[2 * k + 1].rone + f[2 * k + 1].d;
  if (f[2 * k + 1].rd < f[2 * k + 1].sum || x >= y)
    f[k].rd = f[2 * k + 1].rd;
  else
    f[k].rd = f[2 * k + 1].sum + f[2 * k].rd;
  if (f[2 * k].ld < f[2 * k].sum || x <= y)
    f[k].ld = f[2 * k].ld;
  else
    f[k].ld = f[2 * k].sum + f[2 * k + 1].ld;
  f[k].lud = f[2 * k].lud;
  if (f[2 * k].lud == f[2 * k].sum && x > y)
    f[k].lud = max(f[k].lud, f[2 * k].sum + f[2 * k + 1].ld);
  if (f[2 * k].rd == f[2 * k].sum && x < y)
    f[k].lud = max(f[k].lud, f[2 * k].sum + f[2 * k + 1].lud);
  f[k].udr = f[2 * k + 1].udr;
  if (f[2 * k + 1].udr == f[2 * k + 1].sum && x < y)
    f[k].udr = max(f[k].udr, f[2 * k].rd + f[2 * k + 1].sum);
  if (f[2 * k + 1].ld == f[2 * k + 1].sum && x > y)
    f[k].udr = max(f[k].udr, f[2 * k].udr + f[2 * k + 1].sum);
  f[k].ud = max(f[2 * k].ud, f[2 * k + 1].ud);
  if (x > y) f[k].ud = max(f[k].ud, f[2 * k].udr + f[2 * k + 1].ld);
  if (x < y) f[k].ud = max(f[k].ud, f[2 * k].rd + f[2 * k + 1].lud);
}
void push(int k) {
  f[2 * k].d += f[k].d;
  f[2 * k + 1].d += f[k].d;
  f[k].d = 0;
}
void build(int k, int l, int r) {
  f[k].l = l;
  f[k].r = r;
  f[k].sum = r - l + 1;
  if (l == r) {
    f[k].d = a[l];
    f[k].ld = f[k].rd = f[k].ud = f[k].lud = f[k].udr = 1;
  } else {
    int mid = (l + r) / 2;
    build(2 * k, l, mid);
    build(2 * k + 1, mid + 1, r);
    update(k);
  }
}
void change(int k, int L, int R, long long x) {
  if (L <= f[k].l && f[k].r <= R)
    f[k].d += x;
  else {
    push(k);
    int mid = (f[k].l + f[k].r) / 2;
    if (L <= mid) change(2 * k, L, R, x);
    if (R > mid) change(2 * k + 1, L, R, x);
    update(k);
  }
}
long long get(int k, int wh) {
  if (f[k].l == f[k].r) return f[k].d;
  f[2 * k].d += f[k].d;
  f[2 * k + 1].d += f[k].d;
  f[k].d = 0;
  int mid = (f[k].l + f[k].r) / 2;
  if (wh <= mid)
    return get(2 * k, wh);
  else
    return get(2 * k + 1, wh);
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  build(1, 1, n);
  scanf("%d", &m);
  for (i = 1; i <= m; i++) {
    int x, y;
    long long z;
    scanf("%d%d%lld", &x, &y, &z);
    change(1, x, y, z);
    printf("%d\n", f[1].ud);
  }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Alexey, a merry Berland entrant, got sick of the gray reality and he zealously wants to go to university. There are a lot of universities nowadays, so Alexey is getting lost in the diversity — he has not yet decided what profession he wants to get. At school, he had bad grades in all subjects, and it's only thanks to wealthy parents that he was able to obtain the graduation certificate.

The situation is complicated by the fact that each high education institution has the determined amount of voluntary donations, paid by the new students for admission — ni berubleys. He cannot pay more than ni, because then the difference between the paid amount and ni can be regarded as a bribe!

Each rector is wearing the distinctive uniform of his university. Therefore, the uniform's pockets cannot contain coins of denomination more than ri. The rector also does not carry coins of denomination less than li in his pocket — because if everyone pays him with so small coins, they gather a lot of weight and the pocket tears. Therefore, a donation can be paid only by coins of denomination x berubleys, where li ≤ x ≤ ri (Berland uses coins of any positive integer denomination). Alexey can use the coins of different denominations and he can use the coins of the same denomination any number of times. When Alexey was first confronted with such orders, he was puzzled because it turned out that not all universities can accept him! Alexey is very afraid of going into the army (even though he had long wanted to get the green uniform, but his dad says that the army bullies will beat his son and he cannot pay to ensure the boy's safety). So, Alexey wants to know for sure which universities he can enter so that he could quickly choose his alma mater.

Thanks to the parents, Alexey is not limited in money and we can assume that he has an unlimited number of coins of each type.

In other words, you are given t requests, each of them contains numbers ni, li, ri. For each query you need to answer, whether it is possible to gather the sum of exactly ni berubleys using only coins with an integer denomination from li to ri berubleys. You can use coins of different denominations. Coins of each denomination can be used any number of times.

Input

The first line contains the number of universities t, (1 ≤ t ≤ 1000) Each of the next t lines contain three space-separated integers: ni, li, ri (1 ≤ ni, li, ri ≤ 109; li ≤ ri).

Output

For each query print on a single line: either "Yes", if Alexey can enter the university, or "No" otherwise.

Examples

Input

2
5 2 3
6 4 5

Output

Yes
No

Note

You can pay the donation to the first university with two coins: one of denomination 2 and one of denomination 3 berubleys. The donation to the second university cannot be paid.

### Response

```cpp
#include <bits/stdc++.h>
long long int n, k, a, b;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> k >> a >> b;
    if (k / a != k / b || k % a == 0 || k % b == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

```


### Prompt

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

You are given two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n. Each element of both sequences is either 0, 1 or 2. The number of elements 0, 1, 2 in the sequence a is x_1, y_1, z_1 respectively, and the number of elements 0, 1, 2 in the sequence b is x_2, y_2, z_2 respectively.

You can rearrange the elements in both sequences a and b however you like. After that, let's define a sequence c as follows:

c_i = \begin{cases} a_i b_i & \mbox{if }a_i > b_i \\\ 0 & \mbox{if }a_i = b_i \\\ -a_i b_i & \mbox{if }a_i < b_i \end{cases}

You'd like to make ∑_{i=1}^n c_i (the sum of all elements of the sequence c) as large as possible. What is the maximum possible sum?

Input

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

Each test case consists of two lines. The first line of each test case contains three integers x_1, y_1, z_1 (0 ≤ x_1, y_1, z_1 ≤ 10^8) — the number of 0-s, 1-s and 2-s in the sequence a.

The second line of each test case also contains three integers x_2, y_2, z_2 (0 ≤ x_2, y_2, z_2 ≤ 10^8; x_1 + y_1 + z_1 = x_2 + y_2 + z_2 > 0) — the number of 0-s, 1-s and 2-s in the sequence b.

Output

For each test case, print the maximum possible sum of the sequence c.

Example

Input

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

Output

4
2
0

Note

In the first sample, one of the optimal solutions is:

a = \{2, 0, 1, 1, 0, 2, 1\}

b = \{1, 0, 1, 0, 2, 1, 0\}

c = \{2, 0, 0, 0, 0, 2, 0\}

In the second sample, one of the optimal solutions is:

a = \{0, 2, 0, 0, 0\}

b = \{1, 1, 0, 1, 0\}

c = \{0, 2, 0, 0, 0\}

In the third sample, the only possible solution is:

a = \{2\}

b = \{2\}

c = \{0\}

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int t;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> t;
  while (t--) {
    int a[3];
    int b[3];
    cin >> a[0] >> a[1] >> a[2];
    cin >> b[0] >> b[1] >> b[2];
    long long sum = 0;
    int aux = 0;
    for (int i = 2; i >= 0; i--) {
      if (i == 2) {
        for (int j : {1, 2, 0}) {
          aux = min(a[i], b[j]);
          if (i > j)
            sum += aux * i * j;
          else if (i < j)
            sum -= aux * i * j;
          a[i] -= aux;
          b[j] -= aux;
        }
      } else if (i == 1) {
        for (int j : {1, 0, 2}) {
          aux = min(a[i], b[j]);
          if (i > j)
            sum += aux * i * j;
          else if (i < j)
            sum -= aux * i * j;
          a[i] -= aux;
          b[j] -= aux;
        }
      } else {
        for (int j : {0, 1, 2}) {
          aux = min(a[i], b[j]);
          if (i > j)
            sum += aux * i * j;
          else if (i < j)
            sum -= aux * i * j;
          a[i] -= aux;
          b[j] -= aux;
        }
      }
    }
    cout << sum << "\n";
  }
  return 0;
}

```


### Prompt

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

Demiurges Shambambukli and Mazukta love to watch the games of ordinary people. Today, they noticed two men who play the following game.

There is a rooted tree on n nodes, m of which are leaves (a leaf is a nodes that does not have any children), edges of the tree are directed from parent to children. In the leaves of the tree integers from 1 to m are placed in such a way that each number appears exactly in one leaf.

Initially, the root of the tree contains a piece. Two players move this piece in turns, during a move a player moves the piece from its current nodes to one of its children; if the player can not make a move, the game ends immediately. The result of the game is the number placed in the leaf where a piece has completed its movement. The player who makes the first move tries to maximize the result of the game and the second player, on the contrary, tries to minimize the result. We can assume that both players move optimally well.

Demiurges are omnipotent, so before the game they can arbitrarily rearrange the numbers placed in the leaves. Shambambukli wants to rearrange numbers so that the result of the game when both players play optimally well is as large as possible, and Mazukta wants the result to be as small as possible. What will be the outcome of the game, if the numbers are rearranged by Shambambukli, and what will it be if the numbers are rearranged by Mazukta? Of course, the Demiurges choose the best possible option of arranging numbers.

Input

The first line contains a single integer n — the number of nodes in the tree (1 ≤ n ≤ 2·105).

Each of the next n - 1 lines contains two integers ui and vi (1 ≤ ui, vi ≤ n) — the ends of the edge of the tree; the edge leads from node ui to node vi. It is guaranteed that the described graph is a rooted tree, and the root is the node 1.

Output

Print two space-separated integers — the maximum possible and the minimum possible result of the game.

Examples

Input

5
1 2
1 3
2 4
2 5

Output

3 2

Input

6
1 2
1 3
3 4
1 5
5 6

Output

3 3

Note

Consider the first sample. The tree contains three leaves: 3, 4 and 5. If we put the maximum number 3 at node 3, then the first player moves there and the result will be 3. On the other hand, it is easy to see that for any rearrangement the first player can guarantee the result of at least 2.

In the second sample no matter what the arragment is the first player can go along the path that ends with a leaf with number 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 2e5 + 50;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return f * x;
}
int n, num_edge, leaves;
int head[SIZE];
int dp_min[SIZE][2], dp_max[SIZE][2];
struct node {
  int to, nxt;
};
node edge[SIZE << 1];
inline void add(int u, int v) {
  edge[++num_edge].to = v;
  edge[num_edge].nxt = head[u];
  head[u] = num_edge;
}
void pre(int u, int fa) {
  int son = 0;
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].to;
    if (v == fa) continue;
    son++;
    pre(v, u);
  }
  if (!son) {
    leaves++;
    dp_min[u][1] = dp_min[u][0] = dp_max[u][1] = dp_max[u][0] = 1;
  }
}
void dfs(int u, int fa) {
  if (dp_min[u][1]) return;
  dp_min[u][1] = 0;
  dp_min[u][0] = 1e9;
  dp_max[u][1] = 1e9;
  dp_max[u][0] = 0;
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].to;
    if (v == fa) continue;
    dfs(v, u);
    dp_min[u][1] += dp_min[v][0];
    dp_min[u][0] = min(dp_min[u][0], dp_min[v][1]);
    dp_max[u][1] = min(dp_max[u][1], dp_max[v][0]);
    dp_max[u][0] += dp_max[v][1];
  }
}
int main() {
  n = read();
  for (int i = 1; i < n; ++i) {
    int u = read(), v = read();
    add(u, v), add(v, u);
  }
  pre(1, 1);
  dfs(1, 1);
  printf("%d %d\n", leaves - dp_max[1][1] + 1, dp_min[1][1]);
  return 0;
}

```


### Prompt

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

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

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

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

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

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

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

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

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

Input

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

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

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

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

The input limitations for getting 20 points are:

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

The input limitations for getting 50 points are:

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

The input limitations for getting 100 points are:

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

Output

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

Examples

Input

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

Output

2
1
2
0

Note

The given sample is illustrated in the figure below.

<image>

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> a[100005], e[100005];
int dep[100005], low[100005];
int u[100005], g[100005];
int FIND(int x) { return g[x] == x ? x : g[x] = FIND(g[x]); }
void UNION(int x, int y) { g[FIND(x)] = FIND(y); }
void go(int lev, int x, int from = -1) {
  u[x] = 1;
  dep[x] = lev;
  low[x] = lev;
  for (int i = 0; i < (int)a[x].size(); i++) {
    if (!u[a[x][i]]) {
      go(lev + 1, a[x][i], x);
      if (low[a[x][i]] <= lev) {
        UNION(a[x][i], x);
        low[x] = min(low[x], low[a[x][i]]);
      }
    } else if (a[x][i] != from) {
      if (low[a[x][i]] <= lev) {
        UNION(a[x][i], x);
        low[x] = min(low[x], low[a[x][i]]);
      }
    }
  }
}
int ldep[100005];
int lca[100005];
vector<pair<int, int> > q[100005];
int gg[100005];
int v[100005];
int FIND2(int x) { return x == gg[x] ? x : gg[x] = FIND2(gg[x]); }
void UNION2(int x, int y) { gg[FIND2(x)] = FIND2(y); }
void dfs(int x, int from = -1, int lev = 0) {
  v[x] = 1;
  ldep[x] = lev;
  for (int i = 0; i < (int)e[x].size(); i++) {
    int y = e[x][i];
    if (!v[y]) dfs(y, x, lev + 1);
  }
  for (int i = 0; i < (int)q[x].size(); i++) {
    int to = q[x][i].first;
    if (v[to]) lca[q[x][i].second] = ldep[x] + ldep[to] - 2 * ldep[FIND2(to)];
  }
  UNION2(x, from);
  v[x] = 2;
}
int main(void) {
  int n, m, k;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) g[i] = i;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x].push_back(y);
    a[y].push_back(x);
  }
  scanf("%d", &k);
  for (int i = 1; i <= n; i++) gg[i] = i;
  for (int i = 1; i <= n; i++) {
    if (!u[i]) {
      go(0, i);
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < (int)a[i].size(); j++)
      if (FIND(i) != FIND(a[i][j])) e[FIND(i)].push_back(FIND(a[i][j]));
  for (int i = 0; i < k; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x = FIND(x);
    y = FIND(y);
    q[x].push_back(make_pair(y, i));
    q[y].push_back(make_pair(x, i));
  }
  dfs(FIND(1));
  for (int i = 0; i < k; i++) printf("%d\n", lca[i]);
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

There are N rabbits, numbered 1 through N.

The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i.

For a pair of rabbits i and j (i＜j), we call the pair (i，j) a friendly pair if the following condition is met.

* Rabbit i likes rabbit j and rabbit j likes rabbit i.

Calculate the number of the friendly pairs.

Constraints

* 2≤N≤10^5
* 1≤a_i≤N
* a_i≠i

Input

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

N
a_1 a_2 ... a_N

Output

Print the number of the friendly pairs.

Examples

Input

4
2 1 4 3

Output

2

Input

3
2 3 1

Output

0

Input

5
5 5 5 5 1

Output

1

### Response

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

int main(){
 int n,a[100010];
 cin>>n;
 for(int i=0;i<n;i++){
   cin>>a[i];
   a[i]--;
 }
 int ans=0;
 for(int i=0;i<n;i++) if(a[a[i]]==i){ ans++; a[i]=-1;}
 cout<<ans<<endl;
 return 0;
}
```


### Prompt

Generate a cpp solution to the following problem:

You are given a mysterious language (codenamed "Secret") available in "Custom Test" tab. Find out what this language is and write a program which outputs its name. Note that the program must be written in this language.

Input

This program has only one test, and it's empty (it doesn't give your program anything to read).

Output

Output the name of the mysterious language.

Examples

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  puts("INTERCAL");
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Bogdan has a birthday today and mom gave him a tree consisting of n vertecies. For every edge of the tree i, some number xi was written on it. In case you forget, a tree is a connected non-directed graph without cycles. After the present was granted, m guests consecutively come to Bogdan's party. When the i-th guest comes, he performs exactly one of the two possible operations:

  1. Chooses some number yi, and two vertecies ai and bi. After that, he moves along the edges of the tree from vertex ai to vertex bi using the shortest path (of course, such a path is unique in the tree). Every time he moves along some edge j, he replaces his current number yi by <image>, that is, by the result of integer division yi div xj.
  2. Chooses some edge pi and replaces the value written in it xpi by some positive integer ci < xpi.

As Bogdan cares about his guests, he decided to ease the process. Write a program that performs all the operations requested by guests and outputs the resulting value yi for each i of the first type.

Input

The first line of the input contains integers, n and m (2 ≤ n ≤ 200 000, 1 ≤ m ≤ 200 000) — the number of vertecies in the tree granted to Bogdan by his mom and the number of guests that came to the party respectively.

Next n - 1 lines contain the description of the edges. The i-th of these lines contains three integers ui, vi and xi (1 ≤ ui, vi ≤ n, ui ≠ vi, 1 ≤ xi ≤ 1018), denoting an edge that connects vertecies ui and vi, with the number xi initially written on it.

The following m lines describe operations, requested by Bogdan's guests. Each description contains three or four integers and has one of the two possible forms:

  * 1 ai bi yi corresponds to a guest, who chooses the operation of the first type.
  * 2 pi ci corresponds to a guests, who chooses the operation of the second type.

It is guaranteed that all the queries are correct, namely 1 ≤ ai, bi ≤ n, 1 ≤ pi ≤ n - 1, 1 ≤ yi ≤ 1018 and 1 ≤ ci < xpi, where xpi represents a number written on edge pi at this particular moment of time that is not necessarily equal to the initial value xpi, as some decreases may have already been applied to it. The edges are numbered from 1 to n - 1 in the order they appear in the input.

Output

For each guest who chooses the operation of the first type, print the result of processing the value yi through the path from ai to bi.

Examples

Input

6 6
1 2 1
1 3 7
1 4 4
2 5 5
2 6 2
1 4 6 17
2 3 2
1 4 6 17
1 5 5 20
2 4 1
1 5 1 3

Output

2
4
20
3

Input

5 4
1 2 7
1 3 3
3 4 2
3 5 5
1 4 2 100
1 5 4 1
2 2 2
1 1 3 4

Output

2
0
2

Note

Initially the tree looks like this:

<image>

The response to the first query is: <image> = 2

After the third edge is changed, the tree looks like this:

<image>

The response to the second query is: <image> = 4

In the third query the initial and final vertex coincide, that is, the answer will be the initial number 20.

After the change in the fourth edge the tree looks like this:

<image>

In the last query the answer will be: <image> = 3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, unsigned long long int> > e[200110];
int parent[200110];
unsigned long long int parent_weight[200110];
int depth[200110];
int sz[200110];
unsigned long long int seg[200110 * 3];
pair<int, int> num[200110];
int tnum[200110];
int lca[200110][19];
pair<int, int> yol[200110];
int st = 1;
inline unsigned long long int carp(unsigned long long int x,
                                   unsigned long long int y) {
  if (x == 0) return 0;
  if (y == 0) return 0;
  unsigned long long int c = x * y;
  if (c / x == y)
    return c;
  else
    return 2000000000000000000LL;
}
unsigned long long int find(int d, int a, int b, int x, int y) {
  if (b < x || y < a) return 1;
  if (x <= a && b <= y) return seg[d];
  return carp(find(d * 2, a, (a + b) / 2, x, y),
              find(d * 2 + 1, (a + b) / 2 + 1, b, x, y));
}
unsigned long long int update(int d, int a, int b, int x,
                              unsigned long long int y) {
  if (b < x || x < a) return seg[d];
  if (a == b && a == x) return seg[d] = y;
  return seg[d] = carp(update(d * 2, a, (a + b) / 2, x, y),
                       update(d * 2 + 1, (a + b) / 2 + 1, b, x, y));
}
int dfs1(int x, int pr, int dep, unsigned long long int yol) {
  sz[x] = 1;
  depth[x] = dep;
  parent_weight[x] = yol;
  parent[x] = pr;
  for (int i = 0; i < e[x].size(); i++) {
    int y = e[x][i].first;
    unsigned long long int c = e[x][i].second;
    if (y == pr) continue;
    sz[x] += dfs1(y, x, dep + 1, c);
  }
  return sz[x];
}
void dfs2(int x, int par, int dontgo) {
  if (par == -1) {
    par = st;
    num[x] = make_pair(st, st);
    tnum[st] = x;
    st++;
  } else {
    tnum[st] = x;
    num[x] = make_pair(st++, par);
  }
  update(1, 1, n + 10, num[x].first, parent_weight[x]);
  for (int i = 0; i < e[x].size(); i++) {
    int y = e[x][i].first;
    if (y == dontgo) continue;
    if (sz[y] > sz[x] / 2) dfs2(y, par, x);
  }
  for (int i = 0; i < e[x].size(); i++) {
    int y = e[x][i].first;
    if (y == dontgo) continue;
    if (sz[y] <= sz[x] / 2) dfs2(y, -1, x);
  }
}
void dfs3(int x, int y, unsigned long long int& c) {
  if (x == y) return;
  int ay = num[y].first;
  while (true) {
    int ax = num[x].first;
    int stx = num[x].second;
    if (stx <= ay && ay <= ax) {
      c /= find(1, 1, n + 10, ay + 1, ax);
      break;
    } else {
      c /= find(1, 1, n + 10, stx + 1, ax);
      c /= parent_weight[tnum[stx]];
      x = parent[tnum[stx]];
    }
  }
}
void MakeLCA() {
  for (int i = 1; i <= n; i++) lca[i][0] = parent[i];
  for (int k = 1; k <= 18; k++)
    for (int i = 1; i <= n; i++) lca[i][k] = lca[lca[i][k - 1]][k - 1];
}
int GetLCA(int x, int y) {
  if (x == y) return x;
  if (depth[x] < depth[y]) swap(x, y);
  for (int k = 18; k >= 0; k--)
    if (lca[x][k] != 0 && depth[lca[x][k]] >= depth[y]) x = lca[x][k];
  if (x == y) return x;
  for (int k = 18; k >= 0; k--)
    if (lca[x][k] != 0 && lca[x][k] != lca[y][k]) x = lca[x][k], y = lca[y][k];
  x = lca[x][0];
  return x;
}
unsigned long long int getans(int x, int y, unsigned long long int c) {
  int lca = GetLCA(x, y);
  dfs3(x, lca, c);
  dfs3(y, lca, c);
  return c;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; i++) {
    int x, y;
    unsigned long long int c;
    scanf("%d%d%I64d", &x, &y, &c);
    e[x].push_back(make_pair(y, c));
    e[y].push_back(make_pair(x, c));
    yol[i] = make_pair(x, y);
  }
  dfs1(1, 0, 1, 0);
  dfs2(1, -1, -1);
  update(1, 1, n + 10, 1, 1);
  MakeLCA();
  while (m--) {
    int t;
    scanf("%d", &t);
    int x, y;
    unsigned long long int c;
    if (t == 1) {
      scanf("%d%d%I64d", &x, &y, &c);
      unsigned long long int cevap = getans(x, y, c);
      printf("%I64d\n", cevap);
    } else {
      scanf("%d%I64d", &x, &c);
      int a1 = yol[x].first;
      int a2 = yol[x].second;
      if (parent[a1] == a2) swap(a1, a2);
      update(1, 1, n + 10, num[a2].first, c);
      parent_weight[a2] = c;
    }
  }
  return 0;
}

```


### Prompt

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

Takahashi the Jumbo will practice golf.

His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).

If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Constraints

* All values in input are integers.
* 1 \leq A \leq B \leq 1000
* 1 \leq K \leq 1000

Input

Input is given from Standard Input in the following format:

K
A B

Output

If he can achieve the objective, print `OK`; if he cannot, print `NG`.

Examples

Input

7
500 600

Output

OK

Input

4
5 7

Output

NG

Input

1
11 11

Output

OK

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;
cin>>k>>a>>b;
  if(b-a>=k-a%k||a%k==0)cout<<"OK";
  else cout<<"NG";
  return 0;
}
```


### Prompt

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

Does the card fit in a snack? (Are Cards Snacks?)

square1001 You have $ N $ cards.

Each of these cards has an integer written on it, and the integer on the $ i $ th card is $ A_i $.

square1001 Your random number today is $ K $. square1001 You want to choose some of these $ N $ cards so that they add up to $ K $.

E869120, who was watching this situation, wanted to prevent this.

Specifically, I want to eat a few cards in advance so that square1001 doesn't add up to $ K $ no matter how you choose the rest of the cards.

However, E869120 is full and I don't want to eat cards as much as possible.

Now, how many cards can you eat at least E869120 to prevent this?

input

Input is given from standard input in the following format.

$ N $ $ K $
$ A_1 $ $ A_2 $ $ A_3 $ $ \ cdots $ $ A_N $

output

E869120 Print the minimum number of cards you eat to achieve your goal in one line.

However, insert a line break at the end.

Constraint

* $ 1 \ leq N \ leq 20 $
* $ 1 \ leq K \ leq 1000000000 \ (= 10 ^ 9) $
* $ 0 \ leq A_i \ leq 1000000 \ (= 10 ^ 6) $
* All inputs are integers.

Input example 1

5 9
8 6 9 1 2

Output example 1

2

For example, you can thwart square1001's purpose by eating the third card (which has a 9) and the fourth card (which has a 1).

Input example 2

8 2
1 1 1 1 1 1 1 1

Output example 2

7

Input example 3

20 200
31 12 21 17 19 29 25 40 5 8 32 1 27 20 31 13 35 1 8 5

Output example 3

6

Example

Input

5 9
8 6 9 1 2

Output

2

### Response

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

bool ng[1<<20] = {};
int popcnt[1<<20] = {};

int main(){
    int n, k;
    cin >> n >> k;
    int a[n], ret = n;
    for(int i = 0; i < n; i++)  cin >> a[i];
    for(int s = 1; s < 1<<n; s++){
        int sum = 0;
        for(int i = 0; i < n; i++)  if((s>>i)&1)    sum += a[i], popcnt[s]++;
        ng[s] = sum==k;
        for(int i = 0; i < n; i++)  if((s>>i)&1)    ng[s] |= ng[s^(1<<i)];
        if(!ng[s])  ret = min(ret, n-popcnt[s]);
    }
    cout << ret << endl;
    return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

A breakthrough among computer games, "Civilization XIII", is striking in its scale and elaborate details. Let's take a closer look at one of them.

The playing area in the game is split into congruent cells that are regular hexagons. The side of each cell is equal to 1. Each unit occupies exactly one cell of the playing field. The field can be considered infinite.

Let's take a look at the battle unit called an "Archer". Each archer has a parameter "shot range". It's a positive integer that determines the radius of the circle in which the archer can hit a target. The center of the circle coincides with the center of the cell in which the archer stays. A cell is considered to be under the archer’s fire if and only if all points of this cell, including border points are located inside the circle or on its border.

The picture below shows the borders for shot ranges equal to 3, 4 and 5. The archer is depicted as A.

<image>

Find the number of cells that are under fire for some archer.

Input

The first and only line of input contains a single positive integer k — the archer's shot range (1 ≤ k ≤ 106).

Output

Print the single number, the number of cells that are under fire.

Please do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cout stream (also you may use the %I64d specificator).

Examples

Input

3

Output

7

Input

4

Output

13

Input

5

Output

19

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct pt {
  double x;
  double y;
};
int dcmp(double x) { return x < -1e-8 ? -1 : x > 1e-8; }
double dis(pt p) { return (p.x * p.x) + (p.y * p.y); }
int n, edge;
double d = sqrt(3);
pt p;
pt p0, p1, p2;
int main() {
  int i, j, lf, rt, mid;
  int a, b;
  long long cnt = 0;
  long long res;
  while (scanf("%d", &n) != EOF) {
    lf = 0;
    rt = 50000000;
    while (lf <= rt) {
      mid = (lf + rt) / 2;
      p = (pt){0.5 * (3 * mid + 1), 0.5 * d * (mid + 1)};
      if (dcmp(dis(p) - (double)n * n) <= 0)
        lf = mid + 1;
      else
        rt = mid - 1;
    }
    a = lf;
    lf = 0;
    rt = 50000000;
    while (lf <= rt) {
      mid = (lf + rt) / 2;
      p = (pt){1 + 3.0 / 2 * mid, (mid % 2 == 0 ? 0 : d / 2)};
      if (dcmp(dis(p) - (double)n * n) <= 0)
        lf = mid + 1;
      else
        rt = mid - 1;
    }
    b = lf;
    for (i = 0, res = 1; i < a; i++) res += (long long)i * 6;
    for (i = a, cnt = 0; i < b; i++) {
      lf = 0, rt = i / 2;
      while (lf <= rt) {
        mid = (lf + rt) / 2;
        p0 = (pt){0.5 * (3 * i + 1), 0.5 * d * (i % 2 + 1 + 2 * mid)};
        p1 = (pt){0.5 * (3 * i + 2), 0.5 * d * (i % 2 + 2 * mid)};
        p2 = (pt){0.5 * (3 * i + 1), 0.5 * d * (i % 2 - 1 + 2 * mid)};
        if (dcmp(dis(p0) - double(n) * n) <= 0 &&
            dcmp(dis(p1) - double(n) * n) <= 0 &&
            dcmp(dis(p2) - double(n) * n) <= 0)
          lf = mid + 1;
        else
          rt = mid - 1;
      }
      cnt += 2 * lf;
      if (i % 2 == 0) cnt--;
    }
    res += 6 * cnt;
    cout << res << endl;
  }
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Sasha grew up and went to first grade. To celebrate this event her mother bought her a multiplication table M with n rows and n columns such that M_{ij}=a_i ⋅ a_j where a_1, ..., a_n is some sequence of positive integers.

Of course, the girl decided to take it to school with her. But while she was having lunch, hooligan Grisha erased numbers on the main diagonal and threw away the array a_1, ..., a_n. Help Sasha restore the array!

Input

The first line contains a single integer n (3 ⩽ n ⩽ 10^3), the size of the table.

The next n lines contain n integers each. The j-th number of the i-th line contains the number M_{ij} (1 ≤ M_{ij} ≤ 10^9). The table has zeroes on the main diagonal, that is, M_{ii}=0.

Output

In a single line print n integers, the original array a_1, ..., a_n (1 ≤ a_i ≤ 10^9). It is guaranteed that an answer exists. If there are multiple answers, print any.

Examples

Input

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

Output

2 2 3 1 2

Input

3
0 99990000 99970002
99990000 0 99980000
99970002 99980000 0

Output

9999 10000 9998

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int arr[n][n];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      cin >> arr[i][j];
    }
  }
  long long int a = (arr[0][2] * arr[1][2]) / arr[0][1];
  a = sqrt(a);
  for (long long int i = 0; i < n; i++) {
    if (i == 2)
      cout << a << " ";
    else
      cout << (arr[i][2] / a) << " ";
  }
  return 0;
  ;
}

```


### Prompt

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

Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly n, based on the alphabet of size m. Any its substring with length equal to k is a palindrome. How many such strings exist? Your task is to find their quantity modulo 1000000007 (109 + 7). Be careful and don't miss a string or two!

Let us remind you that a string is a palindrome if it can be read the same way in either direction, from the left to the right and from the right to the left.

Input

The first and only line contains three integers: n, m and k (1 ≤ n, m, k ≤ 2000).

Output

Print a single integer — the number of strings of the described type modulo 1000000007 (109 + 7).

Examples

Input

1 1 1

Output

1

Input

5 2 4

Output

2

Note

In the first sample only one string is valid: "a" (let's denote the only letter of our alphabet as "a").

In the second sample (if we denote the alphabet letters as "a" and "b") the following strings are valid: "aaaaa" and "bbbbb".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int find(int v, vector<int> &p) {
  if (p[v] < 0) return v;
  while (true) {
    if (p[v] == -1) return v;
    v = p[v];
  }
  return 0;
}
long long mod = 1000000007;
long long power(long long m, long long e) {
  long long ans = 1;
  for (long long i = 0; i < e; i++) {
    ans = ans * m;
    ans = ans % mod;
  }
  return ans;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<pair<int, int>> v;
  vector<int> p(n + 1, -1), v1, sz(n + 1, 1);
  for (int i = 0; i < n - k + 1; i++) {
    for (int j = 0; j < k / 2; j++) {
      int x = i + j, y = i + k - 1 - j;
      int x1 = find(x, p), y1 = find(y, p);
      if (x1 != y1) {
        if (sz[x1] < sz[y1]) {
          swap(x, y);
        }
        p[y1] = x1;
        sz[x1] = sz[x1] + sz[y1];
      }
    }
  }
  int e = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] == -1) {
      e++;
    }
  }
  cout << power(m, e) << endl;
}

```