### Prompt

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

Vasya plays a computer game with ninjas. At this stage Vasya's ninja should get out of a deep canyon.

The canyon consists of two vertical parallel walls, their height is n meters. Let's imagine that we split these walls into 1 meter-long areas and number them with positive integers from 1 to n from bottom to top. Some areas are safe and the ninja can climb them. Others are spiky and ninja can't be there. Let's call such areas dangerous.

Initially the ninja is on the lower area of the left wall. He can use each second to perform one of the following actions:

  * climb one area up;
  * climb one area down;
  * jump to the opposite wall. That gets the ninja to the area that is exactly k meters higher than the area he jumped from. More formally, if before the jump the ninja is located at area x of one wall, then after the jump he is located at area x + k of the other wall.

If at some point of time the ninja tries to get to an area with a number larger than n, then we can assume that the ninja got out of the canyon.

The canyon gets flooded and each second the water level raises one meter. Initially the water level is at the lower border of the first area. Ninja cannot be on the area covered by water. We can assume that the ninja and the water "move in turns" — first the ninja performs some action, then the water raises for one meter, then the ninja performs one more action and so on.

The level is considered completed if the ninja manages to get out of the canyon.

After several failed attempts Vasya started to doubt whether it is possible to complete the level at all. Help him answer the question.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 105) — the height of the canyon and the height of ninja's jump, correspondingly.

The second line contains the description of the left wall — a string with the length of n characters. The i-th character represents the state of the i-th wall area: character "X" represents a dangerous area and character "-" represents a safe area.

The third line describes the right wall in the same format.

It is guaranteed that the first area of the left wall is not dangerous.

Output

Print "YES" (without the quotes) if the ninja can get out from the canyon, otherwise, print "NO" (without the quotes).

Examples

Input

7 3
---X--X
-X--XX-

Output

YES

Input

6 2
--X-X-
X--XX-

Output

NO

Note

In the first sample the ninja should first jump to the right wall, then go one meter down along the right wall, then jump to the left wall. The next jump can get the ninja from the canyon.

In the second sample there's no way the ninja can get out of the canyon.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
const int inf = 1e9;
struct pnt {
  int x, y;
  pnt() {}
  pnt(int _x, int _y) {
    x = _x;
    y = _y;
  }
};
pnt que[maxn];
int dist[maxn][2];
string s[2];
int main() {
  int i, n, k, uk1, uk2;
  pnt p, p1;
  cin >> n >> k;
  cin >> s[0];
  cin >> s[1];
  for (i = 0; i < n; i++) dist[i][0] = dist[i][1] = inf;
  dist[0][0] = 0;
  que[0] = pnt(0, 0);
  uk1 = 0;
  uk2 = 1;
  for (; uk1 < uk2; uk1++) {
    p = que[uk1];
    if (p.x == n - 1) {
      cout << "YES";
      return 0;
    }
    if (s[p.y][p.x + 1] == '-' && dist[p.x + 1][p.y] > dist[p.x][p.y] + 1) {
      que[uk2++] = pnt(p.x + 1, p.y);
      dist[p.x + 1][p.y] = dist[p.x][p.y] + 1;
    }
    if (p.x - 1 >= 0 && s[p.y][p.x - 1] == '-' &&
        dist[p.x - 1][p.y] > dist[p.x][p.y] + 1 &&
        dist[p.x][p.y] + 1 <= p.x - 1) {
      que[uk2++] = pnt(p.x - 1, p.y);
      dist[p.x - 1][p.y] = dist[p.x][p.y] + 1;
    }
    p1 = pnt(p.x + k, (p.y + 1) % 2);
    if (p1.x >= n) {
      cout << "YES";
      return 0;
    }
    if (s[p1.y][p1.x] == '-' && dist[p1.x][p1.y] > dist[p.x][p.y] + 1) {
      que[uk2++] = pnt(p1.x, p1.y);
      dist[p1.x][p1.y] = dist[p.x][p.y] + 1;
    }
  }
  cout << "NO";
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

When Valera was playing football on a stadium, it suddenly began to rain. Valera hid in the corridor under the grandstand not to get wet. However, the desire to play was so great that he decided to train his hitting the ball right in this corridor. Valera went back far enough, put the ball and hit it. The ball bounced off the walls, the ceiling and the floor corridor and finally hit the exit door. As the ball was wet, it left a spot on the door. Now Valera wants to know the coordinates for this spot.

Let's describe the event more formally. The ball will be considered a point in space. The door of the corridor will be considered a rectangle located on plane xOz, such that the lower left corner of the door is located at point (0, 0, 0), and the upper right corner is located at point (a, 0, b) . The corridor will be considered as a rectangular parallelepiped, infinite in the direction of increasing coordinates of y. In this corridor the floor will be considered as plane xOy, and the ceiling as plane, parallel to xOy and passing through point (a, 0, b). We will also assume that one of the walls is plane yOz, and the other wall is plane, parallel to yOz and passing through point (a, 0, b).

We'll say that the ball hit the door when its coordinate y was equal to 0. Thus the coordinates of the spot are point (x0, 0, z0), where 0 ≤ x0 ≤ a, 0 ≤ z0 ≤ b. To hit the ball, Valera steps away from the door at distance m and puts the ball in the center of the corridor at point <image>. After the hit the ball flies at speed (vx, vy, vz). This means that if the ball has coordinates (x, y, z), then after one second it will have coordinates (x + vx, y + vy, z + vz).

See image in notes for clarification.

When the ball collides with the ceiling, the floor or a wall of the corridor, it bounces off in accordance with the laws of reflection (the angle of incidence equals the angle of reflection). In the problem we consider the ideal physical model, so we can assume that there is no air resistance, friction force, or any loss of energy.

Input

The first line contains three space-separated integers a, b, m (1 ≤ a, b, m ≤ 100). The first two integers specify point (a, 0, b), through which the ceiling and one of the corridor walls pass. The third integer is the distance at which Valera went away from the door.

The second line has three space-separated integers vx, vy, vz (|vx|, |vy|, |vz| ≤ 100, vy < 0, vz ≥ 0) — the speed of the ball after the hit.

It is guaranteed that the ball hits the door.

Output

Print two real numbers x0, z0 — the x and z coordinates of point (x0, 0, z0), at which the ball hits the exit door. The answer will be considered correct, if its absolute or relative error does not exceed 10  - 6.

Examples

Input

7 2 11
3 -11 2

Output

6.5000000000 2.0000000000

Input

7 2 11
4 -3 3

Output

4.1666666667 1.0000000000

Note

<image>

### Response

```cpp
#include <bits/stdc++.h>
const int MAX = 100010;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const long double EPS = 1e-10;
const long double PI = acosl(-1.0);
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long double a, b, m;
  long double vx, vy, vz;
  cin >> a >> b >> m;
  cin >> vx >> vy >> vz;
  long double t = -m / vy;
  long double sz = t * vz, sx = t * vx;
  long double x, z;
  if ((int)(sz / b) & 1)
    z = b - fmod(sz, b);
  else
    z = fmod(sz, b);
  if (vx < 0) {
    sx = -sx;
    if (sx < a / 2)
      x = a / 2 - sx;
    else {
      sx -= a / 2;
      if ((int)(sx / a) & 1)
        x = a - fmod(sx, a);
      else
        x = fmod(sx, a);
    }
  } else {
    sx += a / 2;
    if ((int)(sx / a) & 1)
      x = a - fmod(sx, a);
    else
      x = fmod(sx, a);
  }
  cout << fixed << setprecision(10);
  cout << x << " " << z << '\n';
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Sometimes it is not easy to come to an agreement in a bargain. Right now Sasha and Vova can't come to an agreement: Sasha names a price as high as possible, then Vova wants to remove as many digits from the price as possible. In more details, Sasha names some integer price n, Vova removes a non-empty substring of (consecutive) digits from the price, the remaining digits close the gap, and the resulting integer is the price.

For example, is Sasha names 1213121, Vova can remove the substring 1312, and the result is 121.

It is allowed for result to contain leading zeros. If Vova removes all digits, the price is considered to be 0.

Sasha wants to come up with some constraints so that Vova can't just remove all digits, but he needs some arguments supporting the constraints. To start with, he wants to compute the sum of all possible resulting prices after Vova's move.

Help Sasha to compute this sum. Since the answer can be very large, print it modulo 10^9 + 7.

Input

The first and only line contains a single integer n (1 ≤ n < 10^{10^5}).

Output

In the only line print the required sum modulo 10^9 + 7.

Examples

Input

107

Output

42

Input

100500100500

Output

428101984

Note

Consider the first example.

Vova can choose to remove 1, 0, 7, 10, 07, or 107. The results are 07, 17, 10, 7, 1, 0. Their sum is 42.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
char ini[100005];
const int mod = 1e9 + 7;
long long key[100005];
long long now = 0;
long long quickpow(int b) {
  long long res = 1, a = 10;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> ini;
  int len = strlen(ini);
  for (int i = 1; i < len; i++) {
    now = (quickpow(i - 1) * i) % mod;
    key[i] = (key[i - 1] + now) % mod;
  }
  long long ans = 0;
  for (long long i = 0; i < len; i++) {
    long long temp = (1LL * i * (i + 1) / 2) % mod;
    ans = (ans + (temp * (ini[i] - '0') * quickpow(len - i - 1)) % mod) % mod;
    ans = (ans + key[(len - i - 1)] * (ini[i] - '0')) % mod;
  }
  cout << ans << endl;
}

```


### Prompt

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

Snuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.

Some of the squares have a lotus leaf on it and cannot be entered. The square (i,j) has a lotus leaf on it if c_{ij} is `@`, and it does not if c_{ij} is `.`.

In one stroke, Snuke can move between 1 and K squares (inclusive) toward one of the four directions: north, east, south, and west. The move may not pass through a square with a lotus leaf. Moving to such a square or out of the pond is also forbidden.

Find the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2). If the travel from (x_1,y_1) to (x_2,y_2) is impossible, point out that fact.

Constraints

* 1 \leq H,W,K \leq 10^6
* H \times W \leq 10^6
* 1 \leq x_1,x_2 \leq H
* 1 \leq y_1,y_2 \leq W
* x_1 \neq x_2 or y_1 \neq y_2.
* c_{i,j} is `.` or `@`.
* c_{x_1,y_1} = `.`
* c_{x_2,y_2} = `.`
* All numbers in input are integers.

Input

Input is given from Standard Input in the following format:

H W K
x_1 y_1 x_2 y_2
c_{1,1}c_{1,2} .. c_{1,W}
c_{2,1}c_{2,2} .. c_{2,W}
:
c_{H,1}c_{H,2} .. c_{H,W}

Output

Print the minimum number of strokes Snuke takes to travel from the square (x_1,y_1) to (x_2,y_2), or print `-1` if the travel is impossible.

Examples

Input

3 5 2
3 2 3 4
.....
.@..@
..@..

Output

5

Input

1 6 4
1 1 1 6
......

Output

2

Input

3 3 1
2 1 2 3
.@.
.@.
.@.

Output

-1

### Response

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

i64 h,w,k, a,b,c,d;
string s[1010101];
void solve(){
	cin >> h >> w >> k;
	cin >> a >> b >> c >> d;
	a--; b--; c--; d--;
	for(int i = 0; i < h; i++){
		cin >> s[i];
	}

	vector<vector<int>> v(h,vector<int>(w,INF));
	queue<pair<P,int>> q;
	q.push(make_pair(P(a,b),0));
	v[a][b] = 0;
	int dx[4] = {0,-1,0,1}, dy[4] = {1,0,-1,0};
	while(!q.empty()){
		auto p = q.front(); q.pop();
		int x = p.first.first, y = p.first.second, cnt = p.second;
		if(v[x][y] != cnt) continue;
		if(x == c && y == d){
			cout << cnt << endl;
			return;
		}
		for(int i = 0; i < 4; i++){
			for(int j = 1; j <= k; j++){
				int nx = x+dx[i]*j, ny = y+dy[i]*j;
				if(nx<0||ny<0||nx>=h||ny>=w) break;
				if(v[nx][ny] < cnt+1) break;
				if(s[nx][ny] == '@') break;
				if(chmin(v[nx][ny], cnt+1)){
					q.push(make_pair(P(nx,ny),cnt+1));
				}
			}
		}
	}
	cout << -1 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}

	return 0;
}
```


### Prompt

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

A one-dimensional Japanese crossword can be represented as a binary string of length x. An encoding of this crossword is an array a of size n, where n is the number of segments formed completely of 1's, and ai is the length of i-th segment. No two segments touch or intersect.

For example:

  * If x = 6 and the crossword is 111011, then its encoding is an array {3, 2};
  * If x = 8 and the crossword is 01101010, then its encoding is an array {2, 1, 1};
  * If x = 5 and the crossword is 11111, then its encoding is an array {5};
  * If x = 5 and the crossword is 00000, then its encoding is an empty array.

Mishka wants to create a new one-dimensional Japanese crossword. He has already picked the length and the encoding for this crossword. And now he needs to check if there is exactly one crossword such that its length and encoding are equal to the length and encoding he picked. Help him to check it!

Input

The first line contains two integer numbers n and x (1 ≤ n ≤ 100000, 1 ≤ x ≤ 109) — the number of elements in the encoding and the length of the crossword Mishka picked.

The second line contains n integer numbers a1, a2, ..., an (1 ≤ ai ≤ 10000) — the encoding.

Output

Print YES if there exists exaclty one crossword with chosen length and encoding. Otherwise, print NO.

Examples

Input

2 4
1 3

Output

NO

Input

3 10
3 3 2

Output

YES

Input

2 10
1 3

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100007;
int n, x, m, sum;
int main() {
  cin >> n >> x;
  for (int i = 1; i <= n; i++) {
    cin >> m;
    sum += m;
  }
  sum += n - 1;
  cout << (sum == x ? "YES" : "NO") << endl;
  return 0;
}

```


### Prompt

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

You are given a sequence a_1, a_2, …, a_n of non-negative integers.

You need to find the largest number m of triples (i_1, j_1, k_1), (i_2, j_2, k_2), ..., (i_m, j_m, k_m) such that:

  * 1 ≤ i_p < j_p < k_p ≤ n for each p in 1, 2, …, m;
  * a_{i_p} = a_{k_p} = 0, a_{j_p} ≠ 0;
  * all a_{j_1}, a_{j_2}, …, a_{j_m} are different;
  * all i_1, j_1, k_1, i_2, j_2, k_2, …, i_m, j_m, k_m are different.

Input

The first line of input contains one integer t (1 ≤ t ≤ 500 000): the number of test cases.

The first line of each test case contains one integer n (1 ≤ n ≤ 500 000).

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

The total sum of n is at most 500 000.

Output

For each test case, print one integer m: the largest number of proper triples that you can find.

Example

Input

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

Output

0
0
1
2
1
1
1
2

Note

In the first two test cases, there are not enough elements even for a single triple, so the answer is 0.

In the third test case we can select one triple (1, 2, 3).

In the fourth test case we can select two triples (1, 3, 5) and (2, 4, 6).

In the fifth test case we can select one triple (1, 2, 3). We can't select two triples (1, 2, 3) and (4, 5, 6), because a_2 = a_5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int w = 0, x = 0;
  char c = getchar();
  while (!isdigit(c)) w |= c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
  return w ? -x : x;
}
namespace star {
const int maxn = 5e5 + 10;
int n, ans, sum, a[maxn << 1], l[maxn], tot, r[maxn], s;
pair<int, int> q[maxn];
inline void work() {
  n = read();
  ans = tot = s = 0;
  for (int i = 1; i <= n << 1; i++) a[i] = 0;
  for (int i = 1; i <= n; i++)
    s += (a[i] = read()) == 0, l[i] = n + 1, r[i] = 0;
  s >>= 1, sum = s;
  if (!s) return (void)puts("0");
  int x;
  for (x = 1; x <= n; x++)
    if (!a[x] and (--s == 0)) break;
  for (int i = 1; i <= x; i++) r[a[i]] = i;
  for (int i = n; i > x; i--) l[a[i]] = i;
  for (int i = 1; i <= n; i++) q[++tot] = make_pair(l[i] - x, r[i] + n - x);
  sort(q + 1, q + 1 + tot);
  priority_queue<int, vector<int>, greater<int>> que;
  for (int j = 1, i = 1; i <= n; i++)
    if (!a[(i + x - 1) % n + 1]) {
      while (j <= tot and q[j].first <= i) que.push(q[j++].second);
      while (!que.empty() and que.top() < i) que.pop();
      if (!que.empty()) ++ans, que.pop();
    }
  printf("%d\n", min(ans, sum));
}
}  // namespace star
signed main() {
  int T = read();
  while (T--) star::work();
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Recently, Berland faces federalization requests more and more often. The proponents propose to divide the country into separate states. Moreover, they demand that there is a state which includes exactly k towns.

Currently, Berland has n towns, some pairs of them are connected by bilateral roads. Berland has only n - 1 roads. You can reach any city from the capital, that is, the road network forms a tree.

The Ministry of Roads fears that after the reform those roads that will connect the towns of different states will bring a lot of trouble.

Your task is to come up with a plan to divide the country into states such that:

  * each state is connected, i.e. for each state it is possible to get from any town to any other using its roads (that is, the roads that connect the state towns),
  * there is a state that consisted of exactly k cities,
  * the number of roads that connect different states is minimum.

Input

The first line contains integers n, k (1 ≤ k ≤ n ≤ 400). Then follow n - 1 lines, each of them describes a road in Berland. The roads are given as pairs of integers xi, yi (1 ≤ xi, yi ≤ n; xi ≠ yi) — the numbers of towns connected by the road. Assume that the towns are numbered from 1 to n.

Output

The the first line print the required minimum number of "problem" roads t. Then print a sequence of t integers — their indices in the found division. The roads are numbered starting from 1 in the order they follow in the input. If there are multiple possible solutions, print any of them.

If the solution shows that there are no "problem" roads at all, print a single integer 0 and either leave the second line empty or do not print it at all.

Examples

Input

5 2
1 2
2 3
3 4
4 5

Output

1
2

Input

5 3
1 2
1 3
1 4
1 5

Output

2
3 4

Input

1 1

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 401;
long long n, m, a[maxn], dp[maxn][maxn], Size[maxn], k;
long long par[maxn];
long long PreCal[maxn], trace[maxn][maxn];
vector<long long> vt[maxn];
long long u, v;
long long Edge[maxn][maxn];
bool d2[maxn];
void DFS(long long u, long long p) {
  par[u] = p;
  bool isLeaf = true;
  for (auto v : vt[u]) {
    if (v != p) {
      isLeaf = false;
      DFS(v, u);
      for (long long i = k; i >= 2; i--) {
        for (long long j = 1; j < i; j++) {
          if (dp[u][i] > dp[u][j] + dp[v][i - j] - 2) {
            dp[u][i] = dp[u][j] + dp[v][i - j] - 2;
            trace[v][i] = i - j;
          }
        }
      }
    }
  }
}
void Trace(long long u, long long num) {
  d2[u] = true;
  for (auto i = vt[u].rbegin(); i < vt[u].rend(); i++) {
    long long v = *i;
    if (v == par[u]) continue;
    if (trace[v][num] != 0) {
      Trace(v, trace[v][num]);
      num -= trace[v][num];
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  fill_n(&dp[0][0], maxn * maxn, INT_MAX);
  cin >> n >> k;
  for (long long i = 1; i < n; i++) {
    cin >> u >> v;
    vt[u].push_back(v);
    vt[v].push_back(u);
    Edge[u][v] = i;
    Edge[v][u] = i;
  }
  for (long long i = 1; i <= n; i++) dp[i][1] = vt[i].size();
  DFS(1, 1);
  long long Max = INT_MAX, idMax;
  for (long long i = 1; i <= n; i++) {
    if (Max > dp[i][k]) Max = dp[i][k], idMax = i;
  }
  cout << Max << '\n';
  Trace(idMax, k);
  for (long long i = 1; i <= n; i++) {
    if (d2[i]) {
      for (auto j : vt[i]) {
        if (!d2[j]) cout << Edge[i][j] << ' ';
      }
    }
  }
}

```


### Prompt

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

qd ucyhf yi q fhycu dkcruh mxeiu huluhiu yi q tyvvuhudj fhycu dkcruh. oekh jqia yi je vydt jxu djx ucyhf.

Input

jxu ydfkj sediyiji ev q iydwbu ydjuwuh d (1 ≤ d ≤ 11184) — jxu edu-rqiut ydtun ev jxu ucyhf je vydt.

Output

ekjfkj q iydwbu dkcruh.

Examples

Input

1

Output

13

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int X[1000000];
int F[100000];
int main() {
  int n;
  cin >> n;
  int i, j, k, N = 1000000;
  for (i = 1; i < N; i++) X[i] = 1;
  for (i = 2; i < N; i++)
    if (X[i] == 1) {
      j = i + i;
      while (j < N) {
        X[j] = 0;
        j += i;
      }
    }
  k = 0;
  int x, y;
  for (i = 2; i < N; i++)
    if (X[i] == 1) {
      x = i;
      y = 0;
      while (x > 0) {
        y *= 10;
        y += (x % 10);
        x /= 10;
      }
      if ((X[y] == 1) && (i != y)) {
        k++;
        F[k] = i;
      }
    }
  cout << F[n] << endl;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

You are given an integer x. Can you make x by summing up some number of 11, 111, 1111, 11111, …? (You can use any number among them any number of times).

For instance,

  * 33=11+11+11
  * 144=111+11+11+11

Input

The first line of input contains a single integer t (1 ≤ t ≤ 10000) — the number of testcases.

The first and only line of each testcase contains a single integer x (1 ≤ x ≤ 10^9) — the number you have to make.

Output

For each testcase, you should output a single string. If you can make x, output "YES" (without quotes). Otherwise, output "NO".

You can print each letter of "YES" and "NO" in any case (upper or lower).

Example

Input

3
33
144
69

Output

YES
YES
NO

Note

Ways to make 33 and 144 were presented in the statement. It can be proved that we can't present 69 this way.

### Response

```cpp
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#define ll long long int
using namespace std;

int main() {
	// your code goes here
	ll t;
	cin >> t;
	while(t--){
	    ll x;
	    cin >> x;
	    ll num = x/11;
	    ll b = x%11;
	    if(num - 10*b >= 0) cout << "YES" << endl;
	    else cout << "NO" << endl;
	}
	return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

The squirrel Chokudai has N acorns. One day, he decides to do some trades in multiple precious metal exchanges to make more acorns.

His plan is as follows:

1. Get out of the nest with N acorns in his hands.
2. Go to Exchange A and do some trades.
3. Go to Exchange B and do some trades.
4. Go to Exchange A and do some trades.
5. Go back to the nest.

In Exchange X (X = A, B), he can perform the following operations any integer number of times (possibly zero) in any order:

* Lose g_{X} acorns and gain 1 gram of gold.
* Gain g_{X} acorns and lose 1 gram of gold.
* Lose s_{X} acorns and gain 1 gram of silver.
* Gain s_{X} acorns and lose 1 gram of silver.
* Lose b_{X} acorns and gain 1 gram of bronze.
* Gain b_{X} acorns and lose 1 gram of bronze.

Naturally, he cannot perform an operation that would leave him with a negative amount of acorns, gold, silver, or bronze.

What is the maximum number of acorns that he can bring to the nest? Note that gold, silver, or bronze brought to the nest would be worthless because he is just a squirrel.

Constraints

* 1 \leq N \leq 5000
* 1 \leq g_{X} \leq 5000
* 1 \leq s_{X} \leq 5000
* 1 \leq b_{X} \leq 5000
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
g_A s_A b_A
g_B s_B b_B

Output

Print the maximum number of acorns that Chokudai can bring to the nest.

Example

Input

23
1 1 1
2 1 1

Output

46

### Response

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

using namespace std;

long long n;
long long dp1[20000];
long long dp2[26000000];

int main() {
  int g1, s1, b1, g2, s2, b2;
  cin >> n >> g1 >> s1 >> b1 >> g2 >> s2 >> b2;
  int vg = g2 - g1, vs = s2 - s1, vb = b2 - b1;

  for (int i = 0; i < n; ++i) {
    dp1[i+g1] = max(dp1[i+g1], dp1[i]+vg);
    dp1[i+s1] = max(dp1[i+s1], dp1[i]+vs);
    dp1[i+b1] = max(dp1[i+b1], dp1[i]+vb);
  }

  long long mx = 0;
  for (int i = 0; i <= n; ++i) mx = max(mx, dp1[i]);
  n += mx;

  for (int i = 0; i < n; ++i) {
    dp2[i+g2] = max(dp2[i+g2], dp2[i]-vg);
    dp2[i+s2] = max(dp2[i+s2], dp2[i]-vs);
    dp2[i+b2] = max(dp2[i+b2], dp2[i]-vb);
  }

  mx = 0;
  for (int i = 0; i <= n; ++i) mx = max(mx, dp2[i]);
  n += mx;

  cout << n << endl;
  return 0;
}
```


### Prompt

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

DZY loves planting, and he enjoys solving tree problems.

DZY has a weighted tree (connected undirected graph without cycles) containing n nodes (they are numbered from 1 to n). He defines the function g(x, y) (1 ≤ x, y ≤ n) as the longest edge in the shortest path between nodes x and y. Specially g(z, z) = 0 for every z.

For every integer sequence p1, p2, ..., pn (1 ≤ pi ≤ n), DZY defines f(p) as <image>.

DZY wants to find such a sequence p that f(p) has maximum possible value. But there is one more restriction: the element j can appear in p at most xj times.

Please, find the maximum possible f(p) under the described restrictions.

Input

The first line contains an integer n (1 ≤ n ≤ 3000).

Each of the next n - 1 lines contains three integers ai, bi, ci (1 ≤ ai, bi ≤ n; 1 ≤ ci ≤ 10000), denoting an edge between ai and bi with length ci. It is guaranteed that these edges form a tree.

Each of the next n lines describes an element of sequence x. The j-th line contains an integer xj (1 ≤ xj ≤ n).

Output

Print a single integer representing the answer.

Examples

Input

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

Output

2

Input

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

Output

3

Note

In the first sample, one of the optimal p is [4, 3, 2, 1].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &x, T y) {
  if (y > x) x = y;
}
template <class T>
inline void umin(T &x, T y) {
  if (y < x) x = y;
}
const int N = 2e5 + 5, B = 0x7fffffff;
pair<int, pair<int, int> > edge[N];
int cap[N], siz[N], root[N];
int n;
int pq;
int ans;
int finds(int x) {
  if (root[x] == x) return x;
  return root[x] = finds(root[x]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++)
    scanf("%d %d %d", &edge[i].second.first, &edge[i].second.second,
          &edge[i].first);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &cap[i]);
    siz[i] = 1;
    root[i] = i;
    pq += cap[i];
  }
  sort(edge + 1, edge + n);
  for (int i = 1; i <= n; i++) {
    int x = finds(edge[i].second.first);
    int y = finds(edge[i].second.second);
    siz[x] += siz[y];
    cap[x] += cap[y];
    root[y] = root[x];
    if (edge[i].first == edge[i + 1].first) continue;
    if (siz[x] > pq - cap[x]) {
      ans = i;
      break;
    }
  }
  printf("%d\n", max(0, edge[ans].first));
  return !!0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Sasha and Dima want to buy two n-tier cakes. Each cake should consist of n different tiers: from the size of 1 to the size of n. Tiers should go in order from the smallest to the biggest (from top to bottom).

They live on the same street, there are 2 ⋅ n houses in a row from left to right. Each house has a pastry shop where you can buy a cake tier. Unfortunately, in each pastry shop you can buy only one tier of only one specific size: in the i-th house you can buy a tier of the size a_i (1 ≤ a_i ≤ n).

Since the guys carry already purchased tiers, and it is impossible to insert a new tier in the middle of the cake, they agreed to buy tiers from the smallest to the biggest. That is, each of them buys tiers in order: 1, then 2, then 3 and so on up to n.

Initially, Sasha and Dima are located near the first (leftmost) house. Output the minimum distance that they will have to walk in total to buy both cakes. The distance between any two neighboring houses is exactly 1.

Input

The first line of the input contains an integer number n — the number of tiers in each cake (1 ≤ n ≤ 10^5).

The second line contains 2 ⋅ n integers a_1, a_2, ..., a_{2n} (1 ≤ a_i ≤ n), where a_i is equal to the size of the tier, which can be bought in the i-th house. Remember that in each house you can buy only one tier. It is guaranteed that every number from 1 to n occurs in a exactly two times.

Output

Print one number — the minimum distance that the guys have to walk in total to buy both cakes. Guys can be near same house at the same time. They begin near the first (leftmost) house. Each of the guys should buy n tiers in ascending order of their sizes.

Examples

Input

3
1 1 2 2 3 3

Output

9

Input

2
2 1 1 2

Output

5

Input

4
4 1 3 2 2 3 1 4

Output

17

Note

In the first example, the possible optimal sequence of actions is:

  * Sasha buys a tier of size 1 near the 1-st house (a_1=1);
  * Dima goes to the house 2;
  * Dima buys a tier of size 1 near the 2-nd house (a_2=1);
  * Sasha goes to the house 4;
  * Sasha buys a tier of size 2 near the 4-th house (a_4=2);
  * Sasha goes to the house 5;
  * Sasha buys a tier of size 3 near the 5-th house (a_5=3);
  * Dima goes to the house 3;
  * Dima buys a tier of size 2 near the 3-rd house (a_3=2);
  * Dima goes to the house 6;
  * Dima buys a tier of size 3 near the 6-th house (a_6=3).

So, Sasha goes the distance 3+1=4, and Dima goes the distance 1+1+3=5. In total, they cover a distance of 4+5=9. You can make sure that with any other sequence of actions they will walk no less distance.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long a[100000][3];
int main() {
  long long n, i, d1, d2, s = 0, nr, D, S, dif1, dif2, p1, p2, poz1, poz2;
  scanf("%I64d", &n);
  for (i = 1; i <= 2 * n; i++) {
    scanf("%I64d", &nr);
    a[nr][++a[nr][0]] = i;
    if (a[nr][0] == 2)
      if (a[nr][1] > a[nr][2]) swap(a[nr][1], a[nr][2]);
  }
  D = S = 1;
  for (i = 1; i <= n; i++) {
    s = s + (abs)(S - a[i][1]);
    S = a[i][1];
    s = s + (abs)(D - a[i][2]);
    D = a[i][2];
  }
  printf("%I64d", s);
  return 0;
}

```


### Prompt

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

The smallest unit of data handled by a computer is called a bit, and the amount of information that represents multiple bits together is called a word. Currently, many computers process one word as 32 bits.

For a computer that represents one word in 32 bits, create a program that outputs the amount of data W given in word units in bit units.

Input

The input is given in the following format.

W

The input consists of one line and is given the amount of data W (0 ≤ W ≤ 100).

Output

Outputs the bitwise value on one line.

Examples

Input

4

Output

128

Input

3

Output

96

### Response

```cpp
#include<iostream>
using namespace std;
int main(){
int a;
cin>>a;
cout<<a*32<<endl;
return 0;
}
```


### Prompt

Please create a solution in Cpp to the following problem:

We have N logs of lengths A_1,A_2,\cdots A_N.

We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t.

Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.

Constraints

* 1 \leq N \leq 2 \times 10^5
* 0 \leq K \leq 10^9
* 1 \leq A_i \leq 10^9
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \cdots A_N

Output

Print an integer representing the answer.

Examples

Input

2 3
7 9

Output

4

Input

3 0
3 4 5

Output

5

Input

10 10
158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202

Output

292638192

### Response

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

const int N=2e5+20;

int n,k,a[N],ans;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);

	int lo=1,hi=*max_element(a,a+n);
	while(lo<=hi)
	{
		int mid=(lo+hi)>>1;

		long long cuts=0;
		for(int i=0;i<n;i++)
		{
			cuts+=(a[i]-1)/mid;
		}

		if(cuts<=k) ans=mid,hi=mid-1;
		else lo=mid+1;
	}
	printf("%d",ans);
}
```


### Prompt

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

You are given a rectangular field of n × m cells. Each cell is either empty or impassable (contains an obstacle). Empty cells are marked with '.', impassable cells are marked with '*'. Let's call two empty cells adjacent if they share a side.

Let's call a connected component any non-extendible set of cells such that any two of them are connected by the path of adjacent cells. It is a typical well-known definition of a connected component.

For each impassable cell (x, y) imagine that it is an empty cell (all other cells remain unchanged) and find the size (the number of cells) of the connected component which contains (x, y). You should do it for each impassable cell independently.

The answer should be printed as a matrix with n rows and m columns. The j-th symbol of the i-th row should be "." if the cell is empty at the start. Otherwise the j-th symbol of the i-th row should contain the only digit —- the answer modulo 10. The matrix should be printed without any spaces.

To make your output faster it is recommended to build the output as an array of n strings having length m and print it as a sequence of lines. It will be much faster than writing character-by-character.

As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use scanf/printf instead of cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.

Input

The first line contains two integers n, m (1 ≤ n, m ≤ 1000) — the number of rows and columns in the field.

Each of the next n lines contains m symbols: "." for empty cells, "*" for impassable cells.

Output

Print the answer as a matrix as described above. See the examples to precise the format of the output.

Examples

Input

3 3
*.*
.*.
*.*

Output

3.3
.5.
3.3

Input

4 5
**..*
..***
.*.*.
*.*.*

Output

46..3
..732
.6.4.
5.4.3

Note

In first example, if we imagine that the central cell is empty then it will be included to component of size 5 (cross). If any of the corner cell will be empty then it will be included to component of size 3 (corner).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int s[1000006], p[1000006];
long long int fin(long long int x) {
  if (x == p[x]) return x;
  return x = fin(p[x]);
}
void mak(long long int a, long long int b) {
  if (s[a] < s[b]) swap(a, b);
  s[a] += s[b];
  p[b] = a;
  s[b] = 0;
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int n, m, x, y;
  cin >> n >> m;
  string a[n];
  for (long long int i = 0; i <= n - 1; i++) cin >> a[i];
  for (long long int i = 0; i <= n - 1; i++)
    for (long long int j = 0; j <= m - 1; j++)
      if (a[i][j] == '.') {
        s[i * m + j] = 1;
        p[i * m + j] = i * m + j;
      }
  for (long long int i = 0; i <= n - 1; i++)
    for (long long int j = 0; j <= m - 1; j++)
      if (a[i][j] == '.') {
        if (i + 1 < n && a[i + 1][j] == '.') {
          x = fin(i * m + j);
          y = fin(m * (i + 1) + j);
          if (x != y) mak(x, y);
        }
        if (j + 1 < m && a[i][j + 1] == '.') {
          x = fin(i * m + j);
          y = fin(m * i + j + 1);
          if (x != y) mak(x, y);
        }
      }
  for (long long int i = 0; i <= n - 1; i++)
    for (long long int j = 0; j <= m - 1; j++)
      if (a[i][j] != '.') {
        set<long long int> se;
        long long int cnt = 1;
        if (i - 1 >= 0 && a[i - 1][j] == '.') se.insert(fin(m * (i - 1) + j));
        if (i + 1 < n && a[i + 1][j] == '.') se.insert(fin(m * (i + 1) + j));
        if (j - 1 >= 0 && a[i][j - 1] == '.') se.insert(fin(m * i + j - 1));
        if (j + 1 < m && a[i][j + 1] == '.') se.insert(fin(m * i + j + 1));
        for (auto it : se) cnt += s[it];
        cnt = cnt % 10;
        char c = cnt + '0';
        a[i][j] = c;
      }
  for (long long int i = 0; i <= n - 1; i++) cout << a[i] << "\n";
}

```


### Prompt

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

Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the i-th jury member gave ai points.

Polycarp does not remember how many points the participant had before this k marks were given, but he remembers that among the scores announced after each of the k judges rated the participant there were n (n ≤ k) values b1, b2, ..., bn (it is guaranteed that all values bj are distinct). It is possible that Polycarp remembers not all of the scores announced, i. e. n < k. Note that the initial score wasn't announced.

Your task is to determine the number of options for the score the participant could have before the judges rated the participant.

Input

The first line contains two integers k and n (1 ≤ n ≤ k ≤ 2 000) — the number of jury members and the number of scores Polycarp remembers.

The second line contains k integers a1, a2, ..., ak ( - 2 000 ≤ ai ≤ 2 000) — jury's marks in chronological order.

The third line contains n distinct integers b1, b2, ..., bn ( - 4 000 000 ≤ bj ≤ 4 000 000) — the values of points Polycarp remembers. Note that these values are not necessarily given in chronological order.

Output

Print the number of options for the score the participant could have before the judges rated the participant. If Polycarp messes something up and there is no options, print "0" (without quotes).

Examples

Input

4 1
-5 5 0 20
10

Output

3

Input

2 2
-2000 -2000
3998000 4000000

Output

1

Note

The answer for the first example is 3 because initially the participant could have  - 10, 10 or 15 points.

In the second example there is only one correct initial score equaling to 4 002 000.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, n;
  scanf("%d %d", &k, &n);
  unordered_map<int, int> scores;
  int s = 0;
  for (int i = 0; i < k; i++) {
    int a;
    scanf("%d", &a);
    s += a;
    if (scores.count(s))
      scores[s]++;
    else
      scores.insert({s, 1});
  }
  int b0;
  bool flag = false;
  unordered_map<int, int> points;
  for (int i = 0; i < n; i++) {
    int b;
    scanf("%d", &b);
    if (!flag) {
      b0 = b;
      flag = true;
    }
    if (points.count(b - b0))
      points[b - b0]++;
    else
      points.insert({b - b0, 1});
  }
  int ans = 0;
  for (auto score : scores) {
    bool found = true;
    for (auto point : points)
      if (!scores.count(score.first + point.first) ||
          scores[score.first + point.first] < point.second) {
        found = false;
        break;
      }
    if (found) ans++;
  }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

There are N apple trees in a row. People say that one of them will bear golden apples.

We want to deploy some number of inspectors so that each of these trees will be inspected.

Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).

Find the minimum number of inspectors that we need to deploy to achieve the objective.

Constraints

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

Input

Input is given from Standard Input in the following format:

N D

Output

Print the minimum number of inspectors that we need to deploy to achieve the objective.

Examples

Input

6 2

Output

2

Input

14 3

Output

2

Input

20 4

Output

3

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	cout<<(n+(m*2+1)-1)/(m*2+1);
}
```


### Prompt

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

There are well-known formulas: <image>, <image>, <image>. Also mathematicians found similar formulas for higher degrees.

Find the value of the sum <image> modulo 109 + 7 (so you should find the remainder after dividing the answer by the value 109 + 7).

Input

The only line contains two integers n, k (1 ≤ n ≤ 109, 0 ≤ k ≤ 106).

Output

Print the only integer a — the remainder after dividing the value of the sum by the value 109 + 7.

Examples

Input

4 1

Output

10

Input

4 2

Output

30

Input

4 3

Output

100

Input

4 0

Output

4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int K = 1000000 + 7;
const long long MOD = 1000000007;
long long n, k;
long long y[K];
long long pre[K], suf[K];
long long ifac[K];
long long f;
long long pow(long long a, long long k);
int main() {
  scanf("%lld%lld", &n, &k);
  pre[0] = ifac[0] = 1;
  for (long long i = 1; i <= k + 2; ++i) {
    y[i] = (y[i - 1] + pow(i, k)) % MOD;
    pre[i] = pre[i - 1] * (n - i + MOD) % MOD;
    ifac[i] = ifac[i - 1] * pow(i, MOD - 2) % MOD;
  }
  suf[k + 3] = 1;
  for (long long i = k + 2; i; --i) suf[i] = suf[i + 1] * (n - i + MOD) % MOD;
  for (long long i = 1, t; i <= k + 2; ++i) {
    t = y[i];
    if ((k + 2 - i) & 1) t = MOD - t;
    (t *= pre[i - 1] * suf[i + 1] % MOD) %= MOD;
    (t *= ifac[i - 1] * ifac[k + 2 - i] % MOD) %= MOD;
    (f += t) %= MOD;
  }
  printf("%lld", f);
  return 0;
}
long long pow(long long a, long long k) {
  long long t = 1;
  for (; k; a = a * a % MOD, k >>= 1)
    if (k & 1) t = t * a % MOD;
  return t;
}

```


### Prompt

Please create a solution in CPP to the following problem:

We will play a one-player game using a number line and N pieces.

First, we place each of these pieces at some integer coordinate.

Here, multiple pieces can be placed at the same coordinate.

Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:

Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.

Note that the coordinates where we initially place the pieces are already regarded as visited.

Find the minimum number of moves required to achieve the objective.

Constraints

* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.

Input

Input is given from Standard Input in the following format:

N M
X_1 X_2 ... X_M

Output

Find the minimum number of moves required to achieve the objective.

Examples

Input

2 5
10 12 1 2 14

Output

5

Input

3 7
-10 -3 0 9 -100 2 17

Output

19

Input

100 1
-100000

Output

0

### Response

```cpp
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
using namespace std;
int main(){
int n,m;
cin >> n >>m;
int x[100003];
for(int i=0;i<m;i++){
 cin >> x[i];
}
sort(x,x+m);

int y[100003];
for(int i=0;i<m-1;i++){
y[i]=x[i+1]-x[i];
}
sort(y,y+m-1);

int ans=0;
for(int i=0;i<m-n;i++){
 ans=ans+y[i];
}

cout << ans;

return 0;

}
```


### Prompt

Create a solution in Cpp for the following problem:

Before the start of the football season in Berland a strange magic ritual is held. The most experienced magicians have to find a magic matrix of the size n × n (n is even number). Gods will never allow to start the championship without it. Matrix should contain integers from 0 to n - 1, main diagonal should contain only zeroes and matrix should be symmetric. Moreover, all numbers in each row should be different. Magicians are very tired of the thinking process, so they ask you to write a program to find such matrix.

Input

The first line contains one integer n (2 ≤ n ≤ 1000), n is even.

Output

Output n lines with n numbers each — the required matrix. Separate numbers with spaces. If there are several solutions, output any.

Examples

Input

2

Output

0 1
1 0

Input

4

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, a[1005][1005];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n - 1; j++) {
      a[i][j] = (i + j) % (n - 1) + 1;
    }
  }
  for (int i = 0; i < n - 1; i++) {
    a[i][n - 1] = a[n - 1][i] = a[i][i];
    a[i][i] = 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      printf("%d ", a[i][j]);
    }
    printf("\n");
  }
}

```


### Prompt

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

You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).

You want to construct the array a of length n such that:

  * The first n/2 elements of a are even (divisible by 2);
  * the second n/2 elements of a are odd (not divisible by 2);
  * all elements of a are distinct and positive;
  * the sum of the first half equals to the sum of the second half (∑_{i=1}^{n/2} a_i = ∑_{i=n/2 + 1}^{n} a_i).

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

You have to answer t independent test cases.

Input

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

The only line of the test case contains one integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the length of the array. It is guaranteed that that n is even (i.e. divisible by 2).

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

Output

For each test case, print the answer — "NO" (without quotes), if there is no suitable answer for the given test case or "YES" in the first line and any suitable array a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) satisfying conditions from the problem statement on the second line.

Example

Input

5
2
4
6
8
10

Output

NO
YES
2 4 1 5
NO
YES
2 4 6 8 1 3 5 11
NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 987654321;
const int MOD = 1000000007;
map<int, bool> booleanMap;
map<int, int> integerMap;
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    ;
    if (n % 4 == 0) {
      cout << "YES\n";
      ;
      for (long long i = 1; i <= n / 2; i++) {
        cout << i * 2 << " ";
      }
      for (long long i = 1; i < n / 2; i++) {
        cout << i * 2 - 1 << " ";
      }
      cout << n + n / 2 - 1 << endl;
    } else {
      cout << "NO\n";
      ;
    }
  }
  return 0;
}

```


### Prompt

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

A permutation of length n is an array p=[p_1,p_2,...,p_n], which contains every integer from 1 to n (inclusive) and, moreover, each number appears exactly once. For example, p=[3,1,4,2,5] is a permutation of length 5.

For a given number n (n ≥ 2), find a permutation p in which absolute difference (that is, the absolute value of difference) of any two neighboring (adjacent) elements is between 2 and 4, inclusive. Formally, find such permutation p that 2 ≤ |p_i - p_{i+1}| ≤ 4 for each i (1 ≤ i < n).

Print any such permutation for the given integer n or determine that it does not exist.

Input

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

Each test case is described by a single line containing an integer n (2 ≤ n ≤ 1000).

Output

Print t lines. Print a permutation that meets the given requirements. If there are several such permutations, then print any of them. If no such permutation exists, print -1.

Example

Input

6
10
2
4
6
7
13

Output

9 6 10 8 4 7 3 1 5 2
-1
3 1 4 2
5 3 6 2 4 1
5 1 3 6 2 4 7
13 9 7 11 8 4 1 3 5 2 6 10 12

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC target("avx")
const long long MOD = 1000000007;
const long double PI = 3.1415926535898;
const long long LIM = 100005;
using namespace std;
long long fpow(long long x, long long y) {
  long long temp;
  if (y == 0) return 1;
  temp = fpow(x, y / 2);
  if (y % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void sieve(long long n) {
  bool prime[5 * LIM];
  memset(prime, true, sizeof(prime));
  for (long long p = 2; p * p <= n; p++)
    if (prime[p] == true)
      for (long long i = p * p; i <= n; i += p) prime[i] = false;
  prime[1] = 0;
}
inline long long read() {
  long long p = 1, ans = 0;
  char ch = getchar();
  while (ch < 48 || ch > 57) {
    if (ch == '-') p = -1;
    ch = getchar();
  }
  while (ch >= 48 && ch <= 57) {
    ans = (ans << 3) + (ans << 1) + ch - 48;
    ch = getchar();
  }
  return ans * p;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  for (long long tt = 1; tt <= t; ++tt) {
    long long n;
    cin >> n;
    if (n < 4) {
      cout << -1 << endl;
      continue;
    }
    long long ele = 0;
    if (n % 2 == 0)
      ele = n - 1;
    else
      ele = n;
    while (ele >= 1) {
      cout << ele << " ";
      ele -= 2;
    }
    cout << 4 << " " << 2 << " ";
    ele = 6;
    while (ele <= n) {
      cout << ele << " ";
      ele += 2;
    }
    cout << endl;
  }
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and swap specified elements by a list of the following operation:

* swapRange($b, e, t$): For each integer $k$ ($0 \leq k < (e - b)$, swap element $(b + k)$ and element $(t + k)$.

Constraints

* $1 \leq n \leq 1,000$
* $-1,000,000,000 \leq a_i \leq 1,000,000,000$
* $1 \leq q \leq 1,000$
* $0 \leq b_i < e_i \leq n$
* $0 \leq t_i < t_i + (e_i - b_i) \leq n$
* Given swap ranges do not overlap each other

Input

The input is given in the following format.

$n$
$a_0 \; a_1 \; ...,\; a_{n-1}$
$q$
$b_1 \; e_1 \; t_1$
$b_2 \; e_2 \; t_2$
:
$b_{q} \; e_{q} \; t_{q}$

In the first line, $n$ (the number of elements in $A$) is given. In the second line, $a_i$ (each element in $A$) are given. In the third line, the number of queries $q$ is given and each query is given by three integers $b_i \; e_i \; t_i$ in the following $q$ lines.

Output

Print all elements of $A$ in a line after performing the given operations. Put a single space character between adjacency elements and a newline at the end of the last element.

Example

Input

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

Output

1 8 9 10 5 6 7 2 3 4 11

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    int q; cin >> q;
    rep(i,q){
        int b, m, e;
        cin >> b >> m >> e;
        swap_ranges(a.begin()+b, a.begin()+m, a.begin()+e);
    }
    rep(i,n)cout << a[i] << ((i < n-1)?" ":"\n");
    return 0;
}

```


### Prompt

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

<image>

William really likes the cellular automaton called "Game of Life" so he decided to make his own version. For simplicity, William decided to define his cellular automaton on an array containing n cells, with each cell either being alive or dead.

Evolution of the array in William's cellular automaton occurs iteratively in the following way:

  * If the element is dead and it has exactly 1 alive neighbor in the current state of the array, then on the next iteration it will become alive. For an element at index i the neighbors would be elements with indices i - 1 and i + 1. If there is no element at that index, it is considered to be a dead neighbor.
  * William is a humane person so all alive elements stay alive.

Check the note section for examples of the evolution.

You are given some initial state of all elements and you need to help William find the state of the array after m iterations of evolution.

Input

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

The first line of each test case contains two integers n and m (2 ≤ n ≤ 10^3, 1 ≤ m ≤ 10^9), which are the total number of cells in the array and the number of iterations.

The second line of each test case contains a string of length n made up of characters "0" and "1" and defines the initial state of the array. "1" means a cell is alive and "0" means it is dead.

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

Output

In each test case output a string of length n, made up of characters "0" and "1" — the state of the array after m iterations of evolution.

Example

Input

4
11 3
01000000001
10 2
0110100101
5 2
10101
3 100
000

Output

11111001111
1110111101
10101
000

Note

Sequence of iterations of evolution for the first test case

  * 01000000001 — initial state
  * 11100000011 — first iteration of evolution
  * 11110000111 — second iteration of evolution
  * 11111001111 — third iteration of evolution

Sequence of iterations of evolution for the second test case

  * 0110100101 — initial state
  * 1110111101 — first iteration of evolution
  * 1110111101 — second iteration of evolution

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define fat(x) for(auto it:x)
#define  pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repp(i,a,b) for(int i=a;i>=b;i--)
#define mem(x) memset(x,0,sizeof(x))
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define mp make_pair
const int N = 1e3 + 5;
const ll MOD = 1e4 + 7;
const ll INF = 0x3f3f3f3f;
inline int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}
ll n, t, m;
ll a[N], a1[N];
string s;
int main()
{/*

	freopen("c:\\users\\雷神\\desktop\\题\\data.in", "r", stdin);
	freopen("c:\\users\\雷神\\desktop\\题\\myout.out", "w", stdout);*/
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> t;
	while (t--)
	{
		cin >> n >> m;
		cin >> s;
		mem(a);
		rep(i, 1, n)
		{
			a[i] = s[i - 1] - '0';
			a1[i] = a[i];
		}
		rep(j, 1, min(m, (ll)3000))
		{
			rep(i, 1, n)
				a[i] = a1[i];
			rep(i, 1, n)
			{
				if (a[i - 1] + a[i + 1] == 1 && a[i] == 0)
					a1[i] = 1;
			}
		}
		rep(i, 1, n)
			a[i] = a1[i];
		rep(i, 1, n)
			cout << a[i];
		cout << endl;
	}
	return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Problem statement

AOR Ika got a cabbage with $ N $ leaves. The leaves of this cabbage are numbered $ 1, \ ldots, N $ in order from the outside, and the dirtiness of the $ i $ th leaf is $ D_i $. The larger this value is, the worse the degree of dirt is. AOR Ika-chan decided to use the cabbage leaves for cooking, so she decided to select the dirty leaves to be discarded according to the following procedure.

1. Initialize the discard candidates to empty.
2. Focus on the outermost leaves that have not yet been examined. If all the items have been checked, the process ends.
3. If the leaf is dirty for $ A $ or more, add it to the discard candidate and return to 2. Otherwise it ends.

However, as a result of this operation, I noticed that the number of leaves that can be used for cooking may be extremely reduced. Therefore, I decided to reconsider the leaves to be discarded after the above operation and perform the following operations.

1. If there are less than $ M $ leaves that are not candidates for disposal, proceed to 2. Otherwise it ends.
2. Focus on the innermost leaf that has not been examined yet among the leaves that are candidates for disposal. If there are no leaves that are candidates for disposal, the process ends.
3. If the leaf is less than $ B $, remove it from the discard candidates and return to 2. Otherwise, discard all the leaves remaining in the discard candidates and finish.

When you perform these operations, find the number of leaves to be finally discarded.

Input constraints

$ 1 \ leq N \ leq 1000 $
$ 0 \ leq M \ leq N $
$ 1 \ leq A \ leq B \ leq 1000 $
$ 1 \ leq D_ {i} \ leq 1000 $

sample

Sample input 1

5 3 6 9
9 7 5 3 1

Sample output 1

2

Discard the first and second sheets.

Sample input 2

5 3 6 9
5 4 3 2 1

Sample output 2

0

Do not throw away from the first piece.

Sample input 3

5 3 6 9
10 8 6 4 2

Sample output 3

1

I tried to throw away the third one, but I reconsidered and decided not to throw away the second and third ones.

Sample input 4

5 3 6 9
5 10 8 6 4

Sample output 4

0

AOR Ika doesn't know that the second piece is dirty.

Sample input 5

5 0 6 9
9 9 8 8 7

Sample output 5

Five

I don't mind throwing everything away.

input

$ N \ M \ A \ B $
$ D_ {1} \ D_ {2} \ \ cdots \ D_ {N} $

output

Output the number of leaves to be finally thrown away.

Example

Input

5 3 6 9
9 7 5 3 1

Output

2

### Response

```cpp
#include<iostream>

#define MN 1000

int N, M, A, B;
int D[MN];
int disp[MN];

void input(){
	for( int i = 0; i < MN; i++ ){
		disp[i] = 0;
	}
	std::cin >> N >> M >> A >> B;
	for( int i = 0; i < N; i++ ){
		std::cin >> D[i];
	}
	return;
}

int run(){
	int num = 0, num2;
	for( int i = 0; i < N; i++ ){
		if( D[i] >= A ){
			disp[num++] = i;
		}else{
			break;
		}
	}
	if( N-num >= M ){ return num; }
	num2 = num;
	for( int i = num2-1; i >= 0; i-- ){
		if( D[disp[i]] > B ){ break; }
		num--;
	}
	return num;
}

int main(){
	input();
	std::cout << run() << std::endl;
	return 0;
}
```


### Prompt

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

The determinant of a matrix 2 × 2 is defined as follows:

<image>

A matrix is called degenerate if its determinant is equal to zero.

The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements.

You are given a matrix <image>. Consider any degenerate matrix B such that norm ||A - B|| is minimum possible. Determine ||A - B||.

Input

The first line contains two integers a and b (|a|, |b| ≤ 109), the elements of the first row of matrix A.

The second line contains two integers c and d (|c|, |d| ≤ 109) the elements of the second row of matrix A.

Output

Output a single real number, the minimum possible value of ||A - B||. Your answer is considered to be correct if its absolute or relative error does not exceed 10 - 9.

Examples

Input

1 2
3 4

Output

0.2000000000

Input

1 0
0 1

Output

0.5000000000

Note

In the first sample matrix B is <image>

In the second sample matrix B is <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long double a, b, c, d, aad = 1e300, bad = -1e300, abc = 1e300, bbc = -1e300;
bool solve(long double x) {
  aad = min(min(min((a - x) * (d - x), (a + x) * (d + x)), (a + x) * (d - x)),
            (a - x) * (d + x));
  bad = max(max(max((a - x) * (d - x), (a + x) * (d + x)), (a + x) * (d - x)),
            (a - x) * (d + x));
  abc = min(min(min((b - x) * (c - x), (b + x) * (c + x)), (b + x) * (c - x)),
            (b - x) * (c + x));
  bbc = max(max(max((b - x) * (c - x), (b + x) * (c + x)), (b + x) * (c - x)),
            (b - x) * (c + x));
  return (aad <= abc && abc <= bad) || (aad <= bbc && bbc <= bad) ||
         (abc <= aad && aad <= bbc) || (abc <= bad && bad <= bbc);
}
int main() {
  scanf("%Lf%Lf%Lf%Lf", &a, &b, &c, &d);
  long double cur = 0;
  for (long double i = 1e20; i >= 1e-20; i /= 2) {
    if (!solve(cur + i)) cur += i;
  }
  printf("%.15Lf", cur);
  printf("0000000%d", sizeof(a));
}

```


### Prompt

Create a solution in Cpp for the following problem:

Allen and Bessie are playing a simple number game. They both know a function f: \{0, 1\}^n → R, i. e. the function takes n binary arguments and returns a real value. At the start of the game, the variables x_1, x_2, ..., x_n are all set to -1. Each round, with equal probability, one of Allen or Bessie gets to make a move. A move consists of picking an i such that x_i = -1 and either setting x_i → 0 or x_i → 1.

After n rounds all variables are set, and the game value resolves to f(x_1, x_2, ..., x_n). Allen wants to maximize the game value, and Bessie wants to minimize it.

Your goal is to help Allen and Bessie find the expected game value! They will play r+1 times though, so between each game, exactly one value of f changes. In other words, between rounds i and i+1 for 1 ≤ i ≤ r, f(z_1, ..., z_n) → g_i for some (z_1, ..., z_n) ∈ \{0, 1\}^n. You are to find the expected game value in the beginning and after each change.

Input

The first line contains two integers n and r (1 ≤ n ≤ 18, 0 ≤ r ≤ 2^{18}).

The next line contains 2^n integers c_0, c_1, ..., c_{2^n-1} (0 ≤ c_i ≤ 10^9), denoting the initial values of f. More specifically, f(x_0, x_1, ..., x_{n-1}) = c_x, if x = \overline{x_{n-1} … x_0} in binary.

Each of the next r lines contains two integers z and g (0 ≤ z ≤ 2^n - 1, 0 ≤ g ≤ 10^9). If z = \overline{z_{n-1} ... z_0} in binary, then this means to set f(z_0, ..., z_{n-1}) → g.

Output

Print r+1 lines, the i-th of which denotes the value of the game f during the i-th round. Your answer must have absolute or relative error within 10^{-6}.

Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if \frac{|a - b|}{max{(1, |b|)}} ≤ 10^{-6}.

Examples

Input

2 2
0 1 2 3
2 5
0 4

Output

1.500000
2.250000
3.250000

Input

1 0
2 3

Output

2.500000

Input

2 0
1 1 1 1

Output

1.000000

Note

Consider the second test case. If Allen goes first, he will set x_1 → 1, so the final value will be 3. If Bessie goes first, then she will set x_1 → 0 so the final value will be 2. Thus the answer is 2.5.

In the third test case, the game value will always be 1 regardless of Allen and Bessie's play.

### Response

```cpp
#include <bits/stdc++.h>
int c[1 << 18];
int main() {
  int n, r, i, z, g;
  long long sum;
  scanf("%d%d", &n, &r);
  n = (1 << n);
  sum = 0;
  for (i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
    sum += c[i];
  }
  printf("%.12f\n", sum * 1.0 / n);
  while (r--) {
    scanf("%d%d", &z, &g);
    sum -= c[z];
    sum += (c[z] = g);
    printf("%.12f\n", sum * 1.0 / n);
  }
  return 0;
}

```


### Prompt

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

After battling Shikamaru, Tayuya decided that her flute is too predictable, and replaced it with a guitar. The guitar has 6 strings and an infinite number of frets numbered from 1. Fretting the fret number j on the i-th string produces the note a_{i} + j.

Tayuya wants to play a melody of n notes. Each note can be played on different string-fret combination. The easiness of performance depends on the difference between the maximal and the minimal indices of used frets. The less this difference is, the easier it is to perform the technique. Please determine the minimal possible difference.

For example, if a = [1, 1, 2, 2, 3, 3], and the sequence of notes is 4, 11, 11, 12, 12, 13, 13 (corresponding to the second example), we can play the first note on the first string, and all the other notes on the sixth string. Then the maximal fret will be 10, the minimal one will be 3, and the answer is 10 - 3 = 7, as shown on the picture.

<image>

Input

The first line contains 6 space-separated numbers a_{1}, a_{2}, ..., a_{6} (1 ≤ a_{i} ≤ 10^{9}) which describe the Tayuya's strings.

The second line contains the only integer n (1 ≤ n ≤ 100 000) standing for the number of notes in the melody.

The third line consists of n integers b_{1}, b_{2}, ..., b_{n} (1 ≤ b_{i} ≤ 10^{9}), separated by space. They describe the notes to be played. It's guaranteed that b_i > a_j for all 1≤ i≤ n and 1≤ j≤ 6, in other words, you can play each note on any string.

Output

Print the minimal possible difference of the maximal and the minimal indices of used frets.

Examples

Input

1 4 100 10 30 5
6
101 104 105 110 130 200

Output

0

Input

1 1 2 2 3 3
7
13 4 11 12 11 13 12

Output

7

Note

In the first sample test it is optimal to play the first note on the first string, the second note on the second string, the third note on the sixth string, the fourth note on the fourth string, the fifth note on the fifth string, and the sixth note on the third string. In this case the 100-th fret is used each time, so the difference is 100 - 100 = 0.

<image>

In the second test it's optimal, for example, to play the second note on the first string, and all the other notes on the sixth string. Then the maximal fret will be 10, the minimal one will be 3, and the answer is 10 - 3 = 7.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long infl = 0x3f3f3f3f3f3f3f3fLL;
const long long infi = 0x3f3f3f3f;
const long long mod = infl;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (long long i = 0; i < static_cast<long long>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res.push_back(static_cast<char>('0' + v[i]));
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
long long mygcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  return mygcd(b, a % b);
}
long long mypow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
void solve() {
  vector<long long> str(6);
  for (long long i = 0; i < 6; i++) {
    cin >> str[i];
  }
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<pair<long long, long long>> vp;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 6; j++) {
      long long f = v[i] - str[j];
      long long s = i;
      vp.push_back({f, s});
    }
  }
  sort(vp.begin(), vp.end());
  map<long long, long long> mm;
  long long r = vp.size() - 1;
  long long l = r;
  mm[vp[r].second]++;
  long long ans = infl;
  while (r != 0) {
    if (mm.size() == n) {
      long long ans_temp = vp[r].first - vp[l].first;
      ans = min(ans, ans_temp);
      mm[vp[r].second]--;
      if (mm[vp[r].second] == 0) {
        mm.erase(vp[r].second);
      }
      r--;
      continue;
    }
    l--;
    if (l < 0) {
      break;
    }
    mm[vp[l].second]++;
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

```


### Prompt

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

Let us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that the order of elements doesn't matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same set.

Specifying the number of set elements and their sum to be k and s, respectively, sets satisfying the conditions are limited. When n = 9, k = 3 and s = 23, {6, 8, 9} is the only such set. There may be more than one such set, in general, however. When n = 9, k = 3 and s = 22, both {5, 8, 9} and {6, 7, 9} are possible.

You have to write a program that calculates the number of the sets that satisfy the given conditions.

Input

The input consists of multiple datasets. The number of datasets does not exceed 100.

Each of the datasets has three integers n, k and s in one line, separated by a space. You may assume 1 ≤ n ≤ 20, 1 ≤ k ≤ 10 and 1 ≤ s ≤ 155.

The end of the input is indicated by a line containing three zeros.

Output

The output for each dataset should be a line containing a single integer that gives the number of the sets that satisfy the conditions. No other characters should appear in the output.

You can assume that the number of sets does not exceed 231 - 1.

Example

Input

9 3 23
9 3 22
10 3 28
16 10 107
20 8 102
20 10 105
20 10 155
3 4 3
4 2 11
0 0 0

Output

1
2
0
20
1542
5448
1
0
0

### Response

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

int main(){

  int n, k, s, f=0;
  while (scanf("%d%d%d", &n, &k, &s) && n!=0 && k!=0 && s!=0) {
    int ans = 0;
	for (int i = 1; i < 1<<n; i++) {
      int sum = 0, cnt = 0;
	  for (int j = 0; j < n; j++) {
        if (i & (1<<j)) {
          sum += (j+1);
  		  cnt++;
		}
	  }
	  if (cnt==k && sum==s)
   	    ans++;
	}
    printf("%d\n", ans);
  }

  return 0;
}
```


### Prompt

Develop a solution in Cpp to the problem described below:

Let p (i) be the i-th prime number from the smallest. For example, 7 is the fourth prime number from the smallest, 2, 3, 5, 7, so p (4) = 7.

Given n, the sum of p (i) from i = 1 to n s

s = p (1) + p (2) + .... + p (n)

Create a program that outputs. For example, when n = 9, s = 2 + 3 + 5 + 7 + 11 + 13 + 17 + 19 + 23 = 100.

Input

Given multiple datasets. Each dataset is given the integer n (n ≤ 10000). When n is 0, it is the last input. The number of datasets does not exceed 50.

Output

For n in each dataset, print s on one line.

Example

Input

2
9
0

Output

5
100

### Response

```cpp
#include<iostream>
using namespace std;
int main(){
	bool num[1000000] = {0};
	for(int i=2; i<1000; i++){
		if(!num[i]){
			for(int j=i*i; j<1000000; j+=i){num[j] = 1;}
		}
	}
	for(;;){
		int n,sum = 0;
		cin >>n;
		if(n == 0){break;}
		for(int i=2; n>0; i++){
			if(!num[i]){n--;sum+=i;}
		}
		cout <<sum<<endl;
	}
	return 0;
}
```


### Prompt

Develop a solution in CPP to the problem described below:

Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0, 0). The robot can process commands. There are four types of commands it can perform:

  * U — move from the cell (x, y) to (x, y + 1);
  * D — move from (x, y) to (x, y - 1);
  * L — move from (x, y) to (x - 1, y);
  * R — move from (x, y) to (x + 1, y).

Ivan entered a sequence of n commands, and the robot processed it. After this sequence the robot ended up in the starting cell (0, 0), but Ivan doubts that the sequence is such that after performing it correctly the robot ends up in the same cell. He thinks that some commands were ignored by robot. To acknowledge whether the robot is severely bugged, he needs to calculate the maximum possible number of commands that were performed correctly. Help Ivan to do the calculations!

Input

The first line contains one number n — the length of sequence of commands entered by Ivan (1 ≤ n ≤ 100).

The second line contains the sequence itself — a string consisting of n characters. Each character can be U, D, L or R.

Output

Print the maximum possible number of commands from the sequence the robot could perform to end up in the starting cell.

Examples

Input

4
LDUR

Output

4

Input

5
RRRUU

Output

0

Input

6
LLRRRR

Output

4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int dp[5];
int main() {
  int n;
  cin >> n;
  string a;
  cin >> a;
  for (int i = 0; i < a.size(); i++) {
    if (int(a[i]) == 'U') {
      dp[1]++;
    }
    if (int(a[i]) == 'D') {
      dp[2]++;
    }
    if (int(a[i]) == 'R') {
      dp[3]++;
    }
    if (int(a[i]) == 'L') {
      dp[4]++;
    }
  }
  int s = 0;
  s = min(dp[1], dp[2]) + min(dp[3], dp[4]);
  cout << s * 2;
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Joisino has a bar of length N, which has M marks on it. The distance from the left end of the bar to the i-th mark is X_i.

She will place several squares on this bar. Here, the following conditions must be met:

* Only squares with integral length sides can be placed.
* Each square must be placed so that its bottom side touches the bar.
* The bar must be completely covered by squares. That is, no square may stick out of the bar, and no part of the bar may be left uncovered.
* The boundary line of two squares may not be directly above a mark.

<image>

Examples of arrangements that satisfy/violate the conditions

The beauty of an arrangement of squares is defined as the product of the areas of all the squares placed. Joisino is interested in the sum of the beauty over all possible arrangements that satisfy the conditions. Write a program to find it. Since it can be extremely large, print the sum modulo 10^9+7.

Constraints

* All input values are integers.
* 1 \leq N \leq 10^9
* 0 \leq M \leq 10^5
* 1 \leq X_1 < X_2 < ... < X_{M-1} < X_M \leq N-1

Input

Input is given from Standard Input in the following format:

N M
X_1 X_2 ... X_{M-1} X_M

Output

Print the sum of the beauty over all possible arrangements that satisfy the conditions, modulo 10^9+7.

Examples

Input

3 1
2

Output

13

Input

5 2
2 3

Output

66

Input

10 9
1 2 3 4 5 6 7 8 9

Output

100

Input

1000000000 0

Output

693316425

### Response

```cpp
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
#define N 100005
#define mod 1000000007
int n, m, x[N];
struct Matrix
{
	int A[3][3];
	Matrix(){memset(A, 0, sizeof A);}
	Matrix operator * (const Matrix &b)const
	{
		Matrix c;
		for (int i = 0; i < 3; i++)
			for (int k = 0; k < 3; k++)
				for (int j = 0; j < 3; j++)
					c.A[i][j] = (c.A[i][j] + (ll)A[i][k] * b.A[k][j]) % mod;
		return c;
	}
	void Init()
	{
		for (int i = 0; i < 3; i++)
			for (int j = 0; j < 3; j++)
				A[i][j]=1;
		A[0][1] = A[2][1] = A[2][2]=2;
		A[1][0] = 0;
	}
}ans, now, oth, mat, one;
void Pow(int k)
{
	now = one;
	mat.Init();
	while (k)
	{
		if (k & 1)
			now = now * mat;
		mat = mat * mat;
		k >>= 1;
	}
}
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
		scanf("%d", &x[i]);
	x[++m] = n;
	oth.Init();
	oth.A[2][1] = oth.A[2][0] = 0;
	oth.A[2][2] = 1;
	for (int i = 0; i < 3; i++)
		one.A[i][i] = 1;
	ans.A[0][0] = 1;
	Pow(x[1]);
	ans = ans * now;
	for (int i = 1; i < m; i++)
		{
			ans = ans * oth;
			Pow(x[i + 1] - x[i] - 1);
			ans = ans * now;
		}
	printf("%d\n", ans.A[0][2]);
}

```


### Prompt

Create a solution in Cpp for the following problem:

Petya has recently learned data structure named "Binary heap".

The heap he is now operating with allows the following operations:

  * put the given number into the heap;
  * get the value of the minimum element in the heap;
  * extract the minimum element from the heap;

Thus, at any moment of time the heap contains several integers (possibly none), some of them might be equal.

In order to better learn this data structure Petya took an empty heap and applied some operations above to it. Also, he carefully wrote down all the operations and their results to his event log, following the format:

  * insert x — put the element with value x in the heap;
  * getMin x — the value of the minimum element contained in the heap was equal to x;
  * removeMin — the minimum element was extracted from the heap (only one instance, if there were many).

All the operations were correct, i.e. there was at least one element in the heap each time getMin or removeMin operations were applied.

While Petya was away for a lunch, his little brother Vova came to the room, took away some of the pages from Petya's log and used them to make paper boats.

Now Vova is worried, if he made Petya's sequence of operations inconsistent. For example, if one apply operations one-by-one in the order they are written in the event log, results of getMin operations might differ from the results recorded by Petya, and some of getMin or removeMin operations may be incorrect, as the heap is empty at the moment they are applied.

Now Vova wants to add some new operation records to the event log in order to make the resulting sequence of operations correct. That is, the result of each getMin operation is equal to the result in the record, and the heap is non-empty when getMin ad removeMin are applied. Vova wants to complete this as fast as possible, as the Petya may get back at any moment. He asks you to add the least possible number of operation records to the current log. Note that arbitrary number of operations may be added at the beginning, between any two other operations, or at the end of the log.

Input

The first line of the input contains the only integer n (1 ≤ n ≤ 100 000) — the number of the records left in Petya's journal.

Each of the following n lines describe the records in the current log in the order they are applied. Format described in the statement is used. All numbers in the input are integers not exceeding 109 by their absolute value.

Output

The first line of the output should contain a single integer m — the minimum possible number of records in the modified sequence of operations.

Next m lines should contain the corrected sequence of records following the format of the input (described in the statement), one per line and in the order they are applied. All the numbers in the output should be integers not exceeding 109 by their absolute value.

Note that the input sequence of operations must be the subsequence of the output sequence.

It's guaranteed that there exists the correct answer consisting of no more than 1 000 000 operations.

Examples

Input

2
insert 3
getMin 4

Output

4
insert 3
removeMin
insert 4
getMin 4

Input

4
insert 1
insert 1
removeMin
getMin 2

Output

6
insert 1
insert 1
removeMin
removeMin
insert 2
getMin 2

Note

In the first sample, after number 3 is inserted into the heap, the minimum number is 3. To make the result of the first getMin equal to 4 one should firstly remove number 3 from the heap and then add number 4 into the heap.

In the second sample case number 1 is inserted two times, so should be similarly removed twice.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct ops {
  string operation;
  int value;
};
int main() {
  set<int> heap;
  map<int, int> mapping;
  int number;
  vector<ops> op;
  cin >> number;
  for (int i = 0; i < number; i++) {
    string a;
    cin >> a;
    int val;
    if (a != "removeMin") {
      cin >> val;
    } else {
      val = -1;
    }
    ops opx;
    opx.operation = a;
    opx.value = val;
    op.push_back(opx);
  }
  vector<ops> final;
  for (int i = 0; i < op.size(); i++) {
    if (op[i].operation == "insert") {
      if (heap.find(op[i].value) == heap.end()) {
        mapping[op[i].value] = 1;
        heap.insert(op[i].value);
      } else {
        mapping[op[i].value] += 1;
      }
      final.push_back(op[i]);
    } else if (op[i].operation == "getMin") {
      while (1) {
        if (heap.empty() == true) {
          heap.insert(op[i].value);
          mapping[op[i].value] = 1;
          ops opx;
          opx.operation = "insert";
          opx.value = op[i].value;
          final.push_back(opx);
          final.push_back(op[i]);
          break;
        } else {
          set<int>::iterator it = heap.begin();
          if (*it == op[i].value) {
            final.push_back(op[i]);
            break;
          } else if (*it < op[i].value) {
            int temp = *it;
            if (mapping[*it] == 1) {
              heap.erase(*it);
            }
            mapping[*it] -= 1;
            ops opx;
            opx.operation = "removeMin";
            opx.value = temp;
            final.push_back(opx);
          } else {
            heap.insert(op[i].value);
            mapping[op[i].value] = 1;
            ops opx;
            opx.operation = "insert";
            opx.value = op[i].value;
            final.push_back(opx);
          }
        }
      }
    } else {
      if (heap.empty() == true) {
        heap.insert(op[i].value);
        mapping[op[i].value] = 1;
        ops opx;
        opx.operation = "insert";
        opx.value = op[i].value;
        final.push_back(opx);
      }
      set<int>::iterator it = heap.begin();
      if (mapping[*it] == 1) {
        heap.erase(*it);
      }
      mapping[*it] -= 1;
      final.push_back(op[i]);
    }
  }
  cout << final.size() << "\n";
  for (int i = 0; i < final.size(); i++) {
    if (final[i].operation == "removeMin") {
      cout << final[i].operation << "\n";
    } else {
      cout << final[i].operation << " " << final[i].value << "\n";
    }
  }
  return 0;
}

```


### Prompt

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

Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as possible. New app suggested n available Beru-taxi nearby. The i-th taxi is located at point (xi, yi) and moves with a speed vi.

Consider that each of n drivers will move directly to Vasiliy and with a maximum possible speed. Compute the minimum time when Vasiliy will get in any of Beru-taxi cars.

Input

The first line of the input contains two integers a and b ( - 100 ≤ a, b ≤ 100) — coordinates of Vasiliy's home.

The second line contains a single integer n (1 ≤ n ≤ 1000) — the number of available Beru-taxi cars nearby.

The i-th of the following n lines contains three integers xi, yi and vi ( - 100 ≤ xi, yi ≤ 100, 1 ≤ vi ≤ 100) — the coordinates of the i-th car and its speed.

It's allowed that several cars are located at the same point. Also, cars may be located at exactly the same point where Vasiliy lives.

Output

Print a single real value — the minimum time Vasiliy needs to get in any of the Beru-taxi cars. You answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

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

Examples

Input

0 0
2
2 0 1
0 2 2

Output

1.00000000000000000000

Input

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

Output

0.50000000000000000000

Note

In the first sample, first taxi will get to Vasiliy in time 2, and second will do this in time 1, therefore 1 is the answer.

In the second sample, cars 2 and 3 will arrive simultaneously.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int t;
  double min = INT_MAX;
  cin >> t;
  for (int i = 0; i < t; i++) {
    double x, y, v;
    cin >> x >> y >> v;
    double ti = sqrt(pow(abs(x - a), 2) + pow(abs(y - b), 2)) / v;
    if (min > ti) min = ti;
  }
  cout << fixed << setprecision(8) << min << "\n";
  return 0;
}

```


### Prompt

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

The sales department of Japanese Ancient Giant Corp. is visiting a hot spring resort for their recreational trip. For deepening their friendships, they are staying in one large room of a Japanese-style hotel called a ryokan.

In the ryokan, people sleep in Japanese-style beds called futons. They all have put their futons on the floor just as they like. Now they are ready for sleeping but they have one concern: they don’t like to go into their futons with their legs toward heads — this is regarded as a bad custom in Japanese tradition. However, it is not obvious whether they can follow a good custom. You are requested to write a program answering their question, as a talented programmer.

Here let's model the situation. The room is considered to be a grid on an xy-plane. As usual, x-axis points toward right and y-axis points toward up. Each futon occupies two adjacent cells. People put their pillows on either of the two cells. Their heads come to the pillows; their foots come to the other cells. If the cell of some person's foot becomes adjacent to the cell of another person's head, regardless their directions, then it is considered as a bad case. Otherwise people are all right.

Input

The input is a sequence of datasets. Each dataset is given in the following format:

n
x1 y1 dir1
...
xn yn dirn

n is the number of futons (1 ≤ n ≤ 20,000); (xi, yi) denotes the coordinates of the left-bottom corner of the i-th futon; diri is either 'x' or 'y' and denotes the direction of the i-th futon, where 'x' means the futon is put horizontally and 'y' means vertically. All coordinate values are non-negative integers not greater than 109 .

It is guaranteed that no two futons in the input overlap each other.

The input is terminated by a line with a single zero. This is not part of any dataset and thus should not be processed.

Output

For each dataset, print "Yes" in a line if it is possible to avoid a bad case, or "No" otherwise.

Example

Input

4
0 0 x
2 0 x
0 1 x
2 1 x
4
1 0 x
0 1 x
2 1 x
1 2 x
4
0 0 x
2 0 y
0 1 y
1 2 x
0

Output

Yes
No
Yes

### Response

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

using Graph=vector<vector<int>>;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

bool isBipartite(const Graph &g){
    int n=g.size();
    vector<int> color(n,-1);
    function<bool(int,int)> dfs=[&](int v,int c){
        if(color[v]!=-1){
            if(color[v]!=c) return false;
            return true;
        }
        color[v]=c;
        bool isok=true;
        for(auto &e:g[v]){
            isok&=dfs(e,!c);
        }
        return isok;
    };
    for(int i=0;i<n;i++){
        if(color[i]==-1){
            if(!dfs(i,0)){
                return false;
            }
        }
    }
    return true;
}

bool solve(int n){
    map<pair<int,int>,int> mp;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        char dir;
        cin>>dir;
        mp[{x,y}]=i;
        if(dir=='x') mp[{x+1,y}]=i+n;
        else mp[{x,y+1}]=i+n;
    }

    Graph g(2*n);
    for(int i=0;i<n;i++) g[i].push_back(i+n),g[i+n].push_back(i);
    for(auto &e:mp){
        int x=e.first.first,y=e.first.second;
        int idx=e.second;
        for(int i=0;i<4;i++){
            int tox=x+dx[i],toy=y+dy[i];
            if(mp.count({tox,toy})){
                if(mp[{tox,toy}]%n!=idx%n){
                    g[(idx+n)%(2*n)].push_back(mp[{tox,toy}]);
                }
            }
        }
    }
    return isBipartite(g);
}

int main(){
    int n;
    while(cin>>n,n){
        cout<<(solve(n) ? "Yes" : "No")<<endl;
    }
    return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.

Iroha is looking for X,Y,Z-Haiku (defined below) in integer sequences.

Consider all integer sequences of length N whose elements are between 1 and 10, inclusive. Out of those 10^N sequences, how many contain an X,Y,Z-Haiku?

Here, an integer sequence a_0, a_1, ..., a_{N-1} is said to contain an X,Y,Z-Haiku if and only if there exist four indices x, y, z, w (0 ≦ x < y < z < w ≦ N) such that all of the following are satisfied:

* a_x + a_{x+1} + ... + a_{y-1} = X
* a_y + a_{y+1} + ... + a_{z-1} = Y
* a_z + a_{z+1} + ... + a_{w-1} = Z

Since the answer can be extremely large, print the number modulo 10^9+7.

Constraints

* 3 ≦ N ≦ 40
* 1 ≦ X ≦ 5
* 1 ≦ Y ≦ 7
* 1 ≦ Z ≦ 5

Input

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

N X Y Z

Output

Print the number of the sequences that contain an X,Y,Z-Haiku, modulo 10^9+7.

Examples

Input

3 5 7 5

Output

1

Input

4 5 7 5

Output

34

Input

37 4 2 3

Output

863912418

Input

40 5 7 5

Output

562805100

### Response

```cpp
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXS 262144
#define MO 1000000007
int dp[2][MAXS+5];
using namespace std;
int N,X,Y,Z;
int PowMod(int a,int b)
{
	int ret=1;
	a%=MO;
	while(b)
	{
		if(b&1)
			ret=1LL*ret*a%MO;
		a=1LL*a*a%MO;
		b>>=1;
	}
	return ret;
}
int main()
{
	scanf("%d %d %d %d",&N,&X,&Y,&Z);
	int tot=(1<<(X+Y+Z-1));
	int all=(1<<(X+Y+Z));
	dp[0][0]=1;
	int ans=0;
	for(int i=1;i<=N;i++)
	{
		int id=i%2;
		for(int s1=0;s1<all;s1++)
			for(int k=1;k<=10;k++)
			{
				int s2=((s1<<k)+(1<<(k-1)))%all;
				dp[id][s2]=(1LL*dp[id][s2]+dp[!id][s1])%MO;
			}
		for(int s2=0;s2<all;s2++)
		{
			if((s2&tot)&&((1<<(Y+Z-1))&s2)&&((1<<(Z-1))&s2)&&(dp[id][s2]!=0))
				ans=(1LL*ans+1LL*dp[id][s2]*PowMod(10,N-i)%MO)%MO,dp[id][s2]=0;
		}
		memset(dp[!id],0,sizeof(dp[!id]));
	}
	printf("%d\n",ans);
	return 0;
}
```


### Prompt

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

On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.

Determine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected.

Input

The first line of the input contains five positive integers n, l, v1, v2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 109, 1 ≤ v1 < v2 ≤ 109, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus.

Output

Print the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10 - 6.

Examples

Input

5 10 1 2 5

Output

5.0000000000

Input

3 6 1 2 1

Output

4.7142857143

Note

In the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  int n, k;
  double x, t, l, v1, v2;
  int num;
  scanf("%d%lf%lf%lf%d", &n, &l, &v1, &v2, &k);
  num = n / k;
  if (n % k != 0) num += 1;
  x = (l * (v1 + v2)) / (2 * v1 * (num - 1) + v1 + v2);
  t = x / v2 + (l - x) / v1;
  printf("%.10lf", t);
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

You have k pieces of laundry, each of which you want to wash, dry and fold. You are at a laundromat that has n1 washing machines, n2 drying machines and n3 folding machines. Each machine can process only one piece of laundry at a time. You can't dry a piece of laundry before it is washed, and you can't fold it before it is dried. Moreover, after a piece of laundry is washed, it needs to be immediately moved into a drying machine, and after it is dried, it needs to be immediately moved into a folding machine.

It takes t1 minutes to wash one piece of laundry in a washing machine, t2 minutes to dry it in a drying machine, and t3 minutes to fold it in a folding machine. Find the smallest number of minutes that is enough to wash, dry and fold all the laundry you have.

Input

The only line of the input contains seven integers: k, n1, n2, n3, t1, t2, t3 (1 ≤ k ≤ 104; 1 ≤ n1, n2, n3, t1, t2, t3 ≤ 1000).

Output

Print one integer — smallest number of minutes to do all your laundry.

Examples

Input

1 1 1 1 5 5 5

Output

15

Input

8 4 3 2 10 5 2

Output

32

Note

In the first example there's one instance of each machine, each taking 5 minutes to complete. You have only one piece of laundry, so it takes 15 minutes to process it.

In the second example you start washing first two pieces at moment 0. If you start the third piece of laundry immediately, then by the time it is dried, there will be no folding machine available, so you have to wait, and start washing third piece at moment 2. Similarly, you can't start washing next piece until moment 5, since otherwise there will be no dryer available, when it is washed. Start time for each of the eight pieces of laundry is 0, 0, 2, 5, 10, 10, 12 and 15 minutes respectively. The last piece of laundry will be ready after 15 + 10 + 5 + 2 = 32 minutes.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int nmax = 1000 + 18;
int q1[nmax], q2[nmax], q3[nmax], e1, e2, e3, b1, b2, b3;
int t1, t2, t3;
int n1, n2, n3;
int k;
int T, ans;
int N1, N2, N3;
int ne1(int &a) {
  ++a;
  if (a > N1) a = 1;
  return a;
}
int ne2(int &a) {
  ++a;
  if (a > N2) a = 1;
  return a;
}
int ne3(int &a) {
  ++a;
  if (a > N3) a = 1;
  return a;
}
int main() {
  scanf("%d%d%d%d%d%d%d", &k, &n1, &n2, &n3, &t1, &t2, &t3);
  N1 = n1;
  N2 = n2;
  N3 = n3;
  b1 = b2 = b3 = 1;
  while (k) {
    if (n1 && n2 && n3) {
      q1[ne1(e1)] = t1 + T;
      q2[ne2(e2)] = t2 + T;
      q3[ne3(e3)] = t3 + T;
      ans = T + t1 + t2 + t3;
      --n1, --n2, --n3;
      --k;
    } else if (n1 < N1 && (n2 == N2 || q1[b1] <= q2[b2]) &&
               (n3 == N3 || q1[b1] <= q3[b3])) {
      T = q1[b1];
      ++n1;
      ne1(b1);
    } else if (n2 < N2 && (N1 == n1 || q2[b2] <= q1[b1]) &&
               (n3 == N3 || q2[b2] <= q3[b3])) {
      T = q2[b2];
      ++n2;
      ne2(b2);
    } else if (n3 < N3 && (n1 == N1 || q3[b3] <= q1[b1]) &&
               (n2 == N2 || q3[b3] <= q2[b2])) {
      T = q3[b3];
      ++n3;
      ne3(b3);
    }
  }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

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

You work as a system administrator in a dormitory, which has n rooms one after another along a straight hallway. Rooms are numbered from 1 to n.

You have to connect all n rooms to the Internet.

You can connect each room to the Internet directly, the cost of such connection for the i-th room is i coins.

Some rooms also have a spot for a router. The cost of placing a router in the i-th room is also i coins. You cannot place a router in a room which does not have a spot for it. When you place a router in the room i, you connect all rooms with the numbers from max(1,~i - k) to min(n,~i + k) inclusive to the Internet, where k is the range of router. The value of k is the same for all routers.

Calculate the minimum total cost of connecting all n rooms to the Internet. You can assume that the number of rooms which have a spot for a router is not greater than the number of routers you have.

Input

The first line of the input contains two integers n and k (1 ≤ n, k ≤ 2 ⋅ 10^5) — the number of rooms and the range of each router.

The second line of the input contains one string s of length n, consisting only of zeros and ones. If the i-th character of the string equals to '1' then there is a spot for a router in the i-th room. If the i-th character of the string equals to '0' then you cannot place a router in the i-th room.

Output

Print one integer — the minimum total cost of connecting all n rooms to the Internet.

Examples

Input

5 2
00100

Output

3

Input

6 1
000000

Output

21

Input

4 1
0011

Output

4

Input

12 6
000010000100

Output

15

Note

In the first example it is enough to place the router in the room 3, then all rooms will be connected to the Internet. The total cost of connection is 3.

In the second example you can place routers nowhere, so you need to connect all rooms directly. Thus, the total cost of connection of all rooms is 1 + 2 + 3 + 4 + 5 + 6 = 21.

In the third example you need to connect the room 1 directly and place the router in the room 3. Thus, the total cost of connection of all rooms is 1 + 3 = 4.

In the fourth example you need to place routers in rooms 5 and 10. Then all rooms will be connected to the Internet. The total cost of connection is 5 + 10 = 15.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 234567;
long long dp[N];
string s;
void solve() {
  int n, k;
  cin >> n >> k;
  cin >> s;
  s = "$" + s;
  for (int i = 1; i <= n; i++) {
    dp[i] = 1e15;
  }
  int rtx = 0;
  for (int i = 1; i <= n; i++) {
    while (rtx < i && (rtx < i - k || s[rtx] != '1')) {
      rtx++;
    }
    dp[i] = min(dp[i], dp[i - 1] + i);
    if (rtx != i && s[rtx] == '1')
      dp[i] = min(dp[i], dp[max(0, rtx - k - 1)] + rtx);
    if (s[i] == '1') {
      dp[i] = min(dp[i], dp[max(i - k - 1, 0)] + i);
      for (int j = i - 1; j >= 0 && s[j] != '1'; j--) {
        dp[j] = min(dp[j], dp[i]);
      }
    }
  }
  cout << dp[n];
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

```