### Prompt

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

We saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At every dinner he eats some red and white flowers. Therefore a dinner can be represented as a sequence of several flowers, some of them white and some of them red.

But, for a dinner to be tasty, there is a rule: Marmot wants to eat white flowers only in groups of size k.

Now Marmot wonders in how many ways he can eat between a and b flowers. As the number of ways could be very large, print it modulo 1000000007 (109 + 7).

Input

Input contains several test cases.

The first line contains two integers t and k (1 ≤ t, k ≤ 105), where t represents the number of test cases.

The next t lines contain two integers ai and bi (1 ≤ ai ≤ bi ≤ 105), describing the i-th test.

Output

Print t lines to the standard output. The i-th line should contain the number of ways in which Marmot can eat between ai and bi flowers at dinner modulo 1000000007 (109 + 7).

Examples

Input

3 2
1 3
2 3
4 4

Output

6
5
5

Note

  * For K = 2 and length 1 Marmot can eat (R).
  * For K = 2 and length 2 Marmot can eat (RR) and (WW).
  * For K = 2 and length 3 Marmot can eat (RRR), (RWW) and (WWR).
  * For K = 2 and length 4 Marmot can eat, for example, (WWWW) or (RWWR), but for example he can't eat (WWWR).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int dp[100005];
vector<long long int> v(100005);
long long int t = 1000000007;
void arrfun(long long int k) {
  long long int i, j;
  v[0] = 0;
  dp[0] = 1;
  for (i = 1; i <= 100002; i++) {
    if (i < k) {
      dp[i] = 1;
      v[i] = v[i - 1] + dp[i];
    } else if (i == k) {
      dp[i] = 2;
      v[i] = v[i - 1] + dp[i];
    } else {
      dp[i] = ((dp[i - k]) + (dp[i - 1])) % t;
      v[i] = (v[i - 1] + dp[i]) % t;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int q, k, a, b;
  cin >> q >> k;
  arrfun(k);
  while (q--) {
    cin >> a >> b;
    cout << (v[b] - v[a - 1] + t) % t << "\n";
  }
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Given an n × n table T consisting of lowercase English letters. We'll consider some string s good if the table contains a correct path corresponding to the given string. In other words, good strings are all strings we can obtain by moving from the left upper cell of the table only to the right and down. Here's the formal definition of correct paths:

Consider rows of the table are numbered from 1 to n from top to bottom, and columns of the table are numbered from 1 to n from left to the right. Cell (r, c) is a cell of table T on the r-th row and in the c-th column. This cell corresponds to letter Tr, c.

A path of length k is a sequence of table cells [(r1, c1), (r2, c2), ..., (rk, ck)]. The following paths are correct:

  1. There is only one correct path of length 1, that is, consisting of a single cell: [(1, 1)];
  2. Let's assume that [(r1, c1), ..., (rm, cm)] is a correct path of length m, then paths [(r1, c1), ..., (rm, cm), (rm + 1, cm)] and [(r1, c1), ..., (rm, cm), (rm, cm + 1)] are correct paths of length m + 1.

We should assume that a path [(r1, c1), (r2, c2), ..., (rk, ck)] corresponds to a string of length k: Tr1, c1 + Tr2, c2 + ... + Trk, ck.

Two players play the following game: initially they have an empty string. Then the players take turns to add a letter to the end of the string. After each move (adding a new letter) the resulting string must be good. The game ends after 2n - 1 turns. A player wins by the following scenario:

  1. If the resulting string has strictly more letters "a" than letters "b", then the first player wins;
  2. If the resulting string has strictly more letters "b" than letters "a", then the second player wins;
  3. If the resulting string has the same number of letters "a" and "b", then the players end the game with a draw.

Your task is to determine the result of the game provided that both players played optimally well.

Input

The first line contains a single number n (1 ≤ n ≤ 20).

Next n lines contain n lowercase English letters each — table T.

Output

In a single line print string "FIRST", if the first player wins, "SECOND", if the second player wins and "DRAW", if the game ends with a draw.

Examples

Input

2
ab
cd

Output

DRAW

Input

2
xa
ay

Output

FIRST

Input

3
aab
bcb
bac

Output

DRAW

Note

Consider the first sample:

Good strings are strings: a, ab, ac, abd, acd.

The first player moves first and adds letter a to the string, as there is only one good string of length 1. Then the second player can add b or c and the game will end with strings abd or acd, correspondingly. In the first case it will be a draw (the string has one a and one b), in the second case the first player wins. Naturally, in this case the second player prefers to choose letter b and end the game with a draw.

Consider the second sample:

Good strings are: x, xa, xay.

We can see that the game will end with string xay and the first player wins.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, i, j, a[20][20], x;
char f[20 * 2][1 << 20];
bool bo[20 * 2][1 << 20];
char c[20][20];
char dfs(int dep, int mask) {
  if (dep == 2 * n - 2) return a[n - 1][n - 1];
  if (bo[dep][mask]) return f[dep][mask];
  bo[dep][mask] = 1;
  int i, x, m, y, v;
  if (dep & 1)
    f[dep][mask] = -100;
  else
    f[dep][mask] = 100;
  for (i = 0; i < n; ++i)
    if ((mask >> i) & 1) break;
  v = a[i][dep - i];
  for (i = 'a'; i <= 'z'; ++i) {
    m = 0;
    for (x = 0; x < n; ++x)
      if ((mask >> x) & 1) {
        y = dep - x;
        if (x + 1 < n && c[x + 1][y] == i) m |= 1 << (x + 1);
        if (y + 1 < n && c[x][y + 1] == i) m |= 1 << x;
      }
    if (m) {
      if (dep & 1)
        f[dep][mask] = max(f[dep][mask], char(dfs(dep + 1, m) + v));
      else
        f[dep][mask] = min(f[dep][mask], char(dfs(dep + 1, m) + v));
    }
  }
  return f[dep][mask];
}
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%s", c[i]);
    for (j = 0; j < n; ++j)
      if (c[i][j] == 'a')
        a[i][j] = 1;
      else if (c[i][j] == 'b')
        a[i][j] = -1;
  }
  x = dfs(0, 1);
  puts(x == 0 ? "DRAW" : x > 0 ? "FIRST" : "SECOND");
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph.

Ostap's tree now has n vertices. He wants to paint some vertices of the tree black such that from any vertex u there is at least one black vertex v at distance no more than k. Distance between two vertices of the tree is the minimum possible number of edges of the path between them.

As this number of ways to paint the tree can be large, Ostap wants you to compute it modulo 109 + 7. Two ways to paint the tree are considered different if there exists a vertex that is painted black in one way and is not painted in the other one.

Input

The first line of the input contains two integers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ min(20, n - 1)) — the number of vertices in Ostap's tree and the maximum allowed distance to the nearest black vertex. Don't miss the unusual constraint for k.

Each of the next n - 1 lines contain two integers ui and vi (1 ≤ ui, vi ≤ n) — indices of vertices, connected by the i-th edge. It's guaranteed that given graph is a tree.

Output

Print one integer — the remainder of division of the number of ways to paint the tree by 1 000 000 007 (109 + 7).

Examples

Input

2 0
1 2

Output

1

Input

2 1
1 2

Output

3

Input

4 1
1 2
2 3
3 4

Output

9

Input

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

Output

91

Note

In the first sample, Ostap has to paint both vertices black.

In the second sample, it is enough to paint only one of two vertices, thus the answer is 3: Ostap can paint only vertex 1, only vertex 2, vertices 1 and 2 both.

In the third sample, the valid ways to paint vertices are: {1, 3}, {1, 4}, {2, 3}, {2, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}, {1, 2, 3, 4}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
const int MAXK = 25;
const int MOD = 1e9 + 7;
int N, K;
vector<int> adj[MAXN], ch[MAXN];
int dp_rec[MAXN][MAXK][MAXN];
int dp_sum[MAXN][MAXK][MAXN];
int max_dep[MAXN];
void load() {
  scanf("%d%d", &N, &K);
  for (int i = 1; i < N; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
}
inline int add(int x, int y) {
  x += y;
  if (x >= MOD) return x - MOD;
  if (x < 0) return x + MOD;
  return x;
}
inline int mul(int x, int y) { return (long long)x * y % MOD; }
int rec(int, int, int);
int sum(int, int, int);
int sum(int node, int covered, int highest) {
  covered = max(covered, 0);
  int &ref = dp_sum[node][covered][highest];
  if (ref != -1) return ref;
  if (highest > max_dep[node] + 1) return ref = 0;
  return ref =
             add(rec(node, covered, highest), sum(node, covered, highest + 1));
}
int rec(int node, int covered, int highest) {
  covered = max(covered, 0);
  int &ref = dp_rec[node][covered][highest];
  if (ref != -1) return ref;
  if (highest > max_dep[node]) return ref = covered > max_dep[node];
  if (!covered && highest > K) return ref = 0;
  if (!highest) {
    ref = 1;
    for (auto it : ch[node]) ref = mul(ref, sum(it, K, 0));
    return ref;
  }
  vector<int> big;
  int nxt = max(covered - 1, K - highest);
  for (auto it : ch[node])
    if (max_dep[it] >= nxt) big.push_back(it);
  ref = 0;
  for (auto it : ch[node])
    if ((big.empty() || (big.size() == 1 && big[0] == it)) &&
        highest <= max_dep[it] + 1)
      ref = add(ref, rec(it, covered - 1, highest - 1));
  for (int sec = highest; sec <= max_dep[node] + 1; sec++)
    for (int val = sec; val <= sec + 1; val++) {
      int sz = ch[node].size();
      vector<int> suff(sz + 1);
      suff[sz] = 1;
      for (int i = sz - 1; i >= 0; i--)
        suff[i] = mul(suff[i + 1], sum(ch[node][i], nxt,
                                       min(val - 1, max_dep[ch[node][i]] + 1)));
      int pref = 1;
      for (int i = 0; i < sz; i++) {
        int tmp = mul(pref, suff[i + 1]);
        if (highest <= max_dep[ch[node][i]] + 1)
          ref = add(
              ref, mul(rec(ch[node][i], max(covered - 1, K - sec), highest - 1),
                       val == sec ? tmp : -tmp));
        pref = mul(pref,
                   sum(ch[node][i], nxt,
                       min(max(highest, val - 1), max_dep[ch[node][i]] + 1)));
      }
    }
  return ref;
}
int dfs(int x, int p) {
  int &ref = max_dep[x];
  for (auto it : adj[x])
    if (it != p) {
      ref = max(ref, dfs(it, x) + 1);
      ch[x].push_back(it);
    }
  return ref;
}
int solve() {
  memset(dp_rec, -1, sizeof dp_rec);
  memset(dp_sum, -1, sizeof dp_sum);
  dfs(1, 0);
  return sum(1, 0, 0);
}
int main() {
  load();
  printf("%d\n", solve());
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

— Thanks a lot for today.

— I experienced so many great things.

— You gave me memories like dreams... But I have to leave now...

— One last request, can you...

— Help me solve a Codeforces problem?

— ......

— What?

Chtholly has been thinking about a problem for days:

If a number is palindrome and length of its decimal representation without leading zeros is even, we call it a zcy number. A number is palindrome means when written in decimal representation, it contains no leading zeros and reads the same forwards and backwards. For example 12321 and 1221 are palindromes and 123 and 12451 are not. Moreover, 1221 is zcy number and 12321 is not.

Given integers k and p, calculate the sum of the k smallest zcy numbers and output this sum modulo p.

Unfortunately, Willem isn't good at solving this kind of problems, so he asks you for help!

Input

The first line contains two integers k and p (1 ≤ k ≤ 105, 1 ≤ p ≤ 109).

Output

Output single integer — answer to the problem.

Examples

Input

2 100

Output

33

Input

5 30

Output

15

Note

In the first example, the smallest zcy number is 11, and the second smallest zcy number is 22.

In the second example, <image>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long construct(int n) {
  long long o = n;
  while (n > 0) {
    o *= 10;
    o += n % 10;
    n /= 10;
  }
  return o;
}
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int k, p;
  cin >> k >> p;
  long long sum = 0;
  for (int i = 1; i < 2e9; i++) {
    k--;
    sum += construct(i);
    sum %= p;
    if (k == 0) break;
  }
  cout << sum << "\n";
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another.

(Cultural note: standing in huge and disorganized queues for hours is a native tradition in Russia, dating back to the Soviet period. Queues can resemble crowds rather than lines. Not to get lost in such a queue, a person should follow a strict survival technique: you approach the queue and ask who the last person is, somebody answers and you join the crowd. Now you're the last person in the queue till somebody else shows up. You keep an eye on the one who was last before you as he is your only chance to get to your destination) I'm sure many people have had the problem when a stranger asks who the last person in the queue is and even dares to hint that he will be the last in the queue and then bolts away to some unknown destination. These are the representatives of the modern world, in which the ratio of lack of time is so great that they do not even watch foreign top-rated TV series. Such people often create problems in queues, because the newcomer does not see the last person in the queue and takes a place after the "virtual" link in this chain, wondering where this legendary figure has left.

The Smart Beaver has been ill and he's made an appointment with a therapist. The doctor told the Beaver the sad news in a nutshell: it is necessary to do an electrocardiogram. The next day the Smart Beaver got up early, put on the famous TV series on download (three hours till the download's complete), clenched his teeth and bravely went to join a queue to the electrocardiogram room, which is notorious for the biggest queues at the clinic.

Having stood for about three hours in the queue, the Smart Beaver realized that many beavers had not seen who was supposed to stand in the queue before them and there was a huge mess. He came up to each beaver in the ECG room queue and asked who should be in front of him in the queue. If the beaver did not know his correct position in the queue, then it might be his turn to go get an ECG, or maybe he should wait for a long, long time...

As you've guessed, the Smart Beaver was in a hurry home, so he gave you all the necessary information for you to help him to determine what his number in the queue can be.

Input

The first line contains two integers n (1 ≤ n ≤ 103) and x (1 ≤ x ≤ n) — the number of beavers that stand in the queue and the Smart Beaver's number, correspondingly. All willing to get to the doctor are numbered from 1 to n.

The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ n) — the number of the beaver followed by the i-th beaver. If ai = 0, then the i-th beaver doesn't know who is should be in front of him. It is guaranteed that values ai are correct. That is there is no cycles in the dependencies. And any beaver is followed by at most one beaver in the queue.

The input limits for scoring 30 points are (subproblem B1):

  * It is guaranteed that the number of zero elements ai doesn't exceed 20.

The input limits for scoring 100 points are (subproblems B1+B2):

  * The number of zero elements ai is arbitrary.

Output

Print all possible positions of the Smart Beaver in the line in the increasing order.

Examples

Input

6 1
2 0 4 0 6 0

Output

2
4
6

Input

6 2
2 3 0 5 6 0

Output

2
5

Input

4 1
0 0 0 0

Output

1
2
3
4

Input

6 2
0 0 1 0 4 5

Output

1
3
4
6

Note

<image> Picture for the fourth test.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const int N = 1010;
bool used[N];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  --k;
  vector<int> a(n), p(n, -1);
  for (int i = 0; i < int(n); ++i) {
    scanf("%d", &a[i]);
    --a[i];
    if (a[i] >= 0) p[a[i]] = i;
  }
  int cnt = 0;
  int id = k;
  int bad = k;
  while (a[bad] != -1) {
    bad = a[bad];
  }
  while (id != -1) {
    used[id] = true;
    ++cnt;
    id = a[id];
  }
  printf("%d\n", cnt);
  vector<int> ans;
  for (int i = 0; i < int(n); ++i) {
    if (i == bad) continue;
    if (a[i] == -1) {
      int id = i;
      int c = 0;
      while (id != -1) {
        ++c;
        id = p[id];
      }
      int sz = ans.size();
      for (int j = 0; j < int(sz); ++j) ans.push_back(ans[j] + c);
      ans.push_back(c);
    }
  }
  sort(ans.begin(), ans.end());
  ans.erase(unique(ans.begin(), ans.end()), ans.end());
  for (int i = 0; i < int(ans.size()); ++i) printf("%d\n", ans[i] + cnt);
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:

* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.

Constraints

* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.

Input

Input is given from Standard Input in the following format:

S

Output

If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.

Examples

Input

AtCoder

Output

AC

Input

ACoder

Output

WA

Input

AcycliC

Output

WA

Input

AtCoCo

Output

WA

Input

Atcoder

Output

WA

### Response

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

char ch[100];

bool check(int t)
{
	if(ch[0]!='A')return 0;
	ch[0]='a';
	int k=0;
	for(int i=2;i<t-1;i++)
		if(ch[i]=='C')k++,ch[i]='c';
	if(k!=1)return 0;
	for(int i=0;i<t;i++)
		if(ch[i]<'a'||ch[i]>'z')return 0;
	return 1;
}

int main()
{
	scanf("%s",ch);

	if(!check(strlen(ch)))printf("WA");
	else printf("AC");

	return 0;
}
```


### Prompt

Create a solution in cpp for the following problem:

One day Om Nom found a thread with n beads of different colors. He decided to cut the first several beads from this thread to make a bead necklace and present it to his girlfriend Om Nelly.

<image>

Om Nom knows that his girlfriend loves beautiful patterns. That's why he wants the beads on the necklace to form a regular pattern. A sequence of beads S is regular if it can be represented as S = A + B + A + B + A + ... + A + B + A, where A and B are some bead sequences, " + " is the concatenation of sequences, there are exactly 2k + 1 summands in this sum, among which there are k + 1 "A" summands and k "B" summands that follow in alternating order. Om Nelly knows that her friend is an eager mathematician, so she doesn't mind if A or B is an empty sequence.

Help Om Nom determine in which ways he can cut off the first several beads from the found thread (at least one; probably, all) so that they form a regular pattern. When Om Nom cuts off the beads, he doesn't change their order.

Input

The first line contains two integers n, k (1 ≤ n, k ≤ 1 000 000) — the number of beads on the thread that Om Nom found and number k from the definition of the regular sequence above.

The second line contains the sequence of n lowercase Latin letters that represent the colors of the beads. Each color corresponds to a single letter.

Output

Print a string consisting of n zeroes and ones. Position i (1 ≤ i ≤ n) must contain either number one if the first i beads on the thread form a regular sequence, or a zero otherwise.

Examples

Input

7 2
bcabcab

Output

0000011

Input

21 2
ababaababaababaababaa

Output

000110000111111000011

Note

In the first sample test a regular sequence is both a sequence of the first 6 beads (we can take A = "", B = "bca"), and a sequence of the first 7 beads (we can take A = "b", B = "ca").

In the second sample test, for example, a sequence of the first 13 beads is regular, if we take A = "aba", B = "ba".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool debug;
const int inf = 1e9 + 5;
const int nax = 1e6 + 5;
const int czapa = (1 << 20);
long long P[2] = {(long long)1e6 + 33, (long long)1e6 + 37},
          mod[2] = {(long long)1e9 + 7, (long long)1e9 + 33};
long long pot[2][nax], hasz[2][nax];
char t[nax];
int n, k;
int d[2 * czapa];
long long get_hasz(int pocz, int dl) {
  if (pocz == 1) return hasz[0][dl];
  long long x = hasz[0][pocz + dl - 1] - hasz[0][pocz - 1] * pot[0][dl];
  x %= mod[0];
  x += mod[0];
  x %= mod[0];
  return x;
  long long y = hasz[1][pocz + dl - 1] - hasz[1][pocz - 1] * pot[1][dl];
  y %= mod[1];
  y += mod[1];
  y %= mod[1];
}
int query(int a) {
  a += czapa;
  int res = 0;
  while (a) {
    res |= d[a];
    a /= 2;
  }
  return res;
}
void insert(int a, int b) {
  a += czapa;
  b += czapa;
  d[a] = d[b] = 1;
  while (a / 2 != b / 2) {
    if (!(a & 1)) d[a + 1] = 1;
    if (b & 1) d[b - 1] = 1;
    a /= 2;
    b /= 2;
  }
}
void obczaj(int dl) {
  int b = k;
  auto x = get_hasz(1, dl);
  while (b) {
    if (b & 1) {
      if (get_hasz((b - 1) * dl + 1, dl) != x) return;
    }
    b /= 2;
    if (get_hasz(1, b * dl) != get_hasz(b * dl + 1, b * dl)) return;
  }
  int l = k * dl;
  int ile = 0;
  int zasieg = min(dl, n - k * dl);
  int pod = 1;
  while (pod <= zasieg) pod *= 2;
  pod /= 2;
  while (pod) {
    if (ile + pod <= zasieg &&
        get_hasz(1, ile + pod) == get_hasz(k * dl + 1, ile + pod))
      ile += pod;
    pod /= 2;
  }
  insert(l, l + ile);
}
int main(int argc, char* argv[]) {
  debug = argc > 1;
  scanf("%d%d", &n, &k);
  scanf(" %s", t + 1);
  for (int g = 0; g <= (2) - 1; ++g)
    for (int i = 1; i <= n; ++i)
      hasz[g][i] = (hasz[g][i - 1] * P[g] + t[i]) % mod[g];
  for (int g = 0; g <= (2) - 1; ++g) {
    pot[g][0] = 1;
    for (int i = 1; i <= n; ++i) pot[g][i] = (pot[g][i - 1] * P[g]) % mod[g];
  }
  for (int i = 1; i <= n / k; ++i) obczaj(i);
  for (int i = 1; i <= n; ++i) printf("%d", query(i));
  puts("");
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.

Let the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the nearest integer) lexicographically smallest one.

Constraints

* 1 \leq N,K \leq 3 × 10^5
* N and K are integers.

Input

Input is given from Standard Input in the following format:

K N

Output

Print the (X/2)-th (rounded up to the nearest integer) lexicographically smallest sequence listed in FEIS, with spaces in between, where X is the total number of sequences listed in FEIS.

Examples

Input

3 2

Output

2 1

Input

2 4

Output

1 2 2 2

Input

5 14

Output

3 3 3 3 3 3 3 3 3 3 3 3 2 2

### Response

```cpp
#include<cstdio>
using namespace std;
int n,l,a[300010],i,t,m;
int main()
{
	scanf("%d%d",&n,&l);
	if (n%2==0)
	{
		printf("%d ",n/2);
		for (i=2;i<=l;i++) printf("%d ",n);
		return 0;
	}
	t=l/2;
	m=n/2+1;
	for (i=1;i<=l;i++) a[i]=m;
	int k=l;
	//t=10;
	while (t--)
	{
		if (a[k]==1) k--;
		else
		{
			a[k]--;
			for (i=k+1;i<=l;i++) a[i]=n;
			k=l;
		}
		/*	for (i=1;i<=k;i++)
	{
		printf("%d ",a[i]);
	}
	printf("\n");*/
	}
	for (i=1;i<=k;i++)
	{
		printf("%d ",a[i]);
	}
}
```


### Prompt

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

Oleg came to see the maze of mirrors. The maze is a n by n room in which each cell is either empty or contains a mirror connecting opposite corners of this cell. Mirrors in this maze reflect light in a perfect way, which causes the interesting visual effects and contributes to the loss of orientation in the maze.

Oleg is a person of curious nature, so he decided to install n lasers facing internal of the maze on the south wall of the maze. On the north wall of the maze, Oleg installed n receivers, also facing internal of the maze. Let's number lasers and receivers from west to east with distinct integers from 1 to n. Each laser sends a beam of some specific kind and receiver with number a_i should receive the beam sent from laser number i. Since two lasers' beams can't come to the same receiver, these numbers form a permutation — each of the receiver numbers occurs exactly once.

You came to the maze together with Oleg. Help him to place the mirrors in the initially empty maze so that the maximum number of lasers' beams will come to the receivers they should. There are no mirrors outside the maze, so if the laser beam leaves the maze, it will not be able to go back.

Input

The first line contains a single integer n (1 ≤ n ≤ 1000) — the size of the maze.

The second line contains a permutation of n integers a_i (1 ≤ a_i ≤ n), where a_i defines the number of the receiver, to which the beam from i-th laser should come.

Output

In the first line print the maximum possible number of laser beams, which can come to the receivers they should.

In the next n lines of length n print the arrangement of mirrors, causing such number of laser beams to come where they should. If the corresponding cell is empty, print ".", otherwise print "/" or "\", depending on the orientation of the mirror.

In your output north should be above, south should be below, and west and east should be on left and on the right respectively.

It is allowed for laser beams to come not to the receivers they correspond to, but they are not counted in the answer.

If there are multiple arrangements of mirrors leading to the optimal answer — print any of them.

Example

Input

4
4 1 3 2

Output

3
...
\..
/../
...\

Note

The picture illustrates the arrangements of the mirrors in the first example.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int p[1010];
bool vis[1010];
char s[1010][1010];
int now;
void work(int x) {
  for (int i = x; !vis[i]; i = p[i]) {
    vis[i] = true;
    if (vis[p[i]]) break;
    now++;
    if (i < p[i])
      s[now][i] = s[now][p[i]] = '/';
    else
      s[now][i] = s[now][p[i]] = '\\';
  }
}
int main() {
  int n, ans;
  memset(s, 0, sizeof(s));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) s[i][j] = '.';
  ans = n;
  for (int i = 1; i <= n; i++)
    if (p[i] != i) ans = n - 1;
  memset(vis, 0, sizeof(vis));
  now = 0;
  work(p[n]);
  for (int i = 1; i < n; i++)
    if (!vis[i]) {
      if (i == p[i]) continue;
      now++;
      s[now][p[p[i]]] = '\\';
      s[now][n] = '\\';
      work(p[p[i]]);
      s[now][n] = '/';
    }
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++) printf("%s\n", s[i] + 1);
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

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

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

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

Input

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

Output

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

Examples

Input

1 10
11

Output

No

Input

2 3
4 4

Output

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

Input

3 6
1 2 3

Output

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

Note

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

### Response

```cpp
#include <bits/stdc++.h>
int main(void) {
  int n, W, a[105] = {}, sum = 0;
  int i, j;
  scanf("%d%d", &n, &W);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  if (sum < W || W <= 0)
    puts("No");
  else {
    if (W == 1) {
      for (i = 0; i < n; i++)
        if (a[i] == 1) break;
      if (i == n)
        puts("No");
      else {
        puts("Yes");
        printf("%d", i + 1);
        --a[i];
        for (j = 0; j < n; j++)
          while (a[j]--) printf(" %d %d", j + 1, j + 1);
        printf(" %d\n", i + 1);
      }
    } else if (n == 1) {
      if (W != sum)
        puts("No");
      else {
        puts("Yes");
        while (a[0]--) printf("%d %d ", 1, 1);
        puts("");
      }
    } else {
      --a[0];
      --a[1];
      puts("Yes");
      for (i = 0; i < n; i++)
        while (W > 2 && a[i] > 0) {
          --W;
          printf("%d %d ", i + 1, i + 1);
          --a[i];
        }
      printf("1 ");
      for (i = 1; i < n; i++)
        while (a[i] > 0) {
          printf("%d %d ", i + 1, i + 1);
          --a[i];
        }
      printf("1 2 ");
      while (a[0] > 0) {
        printf("1 1 ");
        --a[0];
      }
      printf("2\n");
    }
  }
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

So you decided to hold a contest on Codeforces. You prepared the problems: statements, solutions, checkers, validators, tests... Suddenly, your coordinator asks you to change all your tests to multiple testcases in the easiest problem!

Initially, each test in that problem is just an array. The maximum size of an array is k. For simplicity, the contents of arrays don't matter. You have n tests — the i-th test is an array of size m_i (1 ≤ m_i ≤ k).

Your coordinator asks you to distribute all of your arrays into multiple testcases. Each testcase can include multiple arrays. However, each testcase should include no more than c_1 arrays of size greater than or equal to 1 (≥ 1), no more than c_2 arrays of size greater than or equal to 2, ..., no more than c_k arrays of size greater than or equal to k. Also, c_1 ≥ c_2 ≥ ... ≥ c_k.

So now your goal is to create the new testcases in such a way that:

  * each of the initial arrays appears in exactly one testcase;
  * for each testcase the given conditions hold;
  * the number of testcases is minimum possible.

Print the minimum possible number of testcases you can achieve and the sizes of arrays included in each testcase.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 2 ⋅ 10^5) — the number of initial tests and the limit for the size of each array.

The second line contains n integers m_1, m_2, ..., m_n (1 ≤ m_i ≤ k) — the sizes of the arrays in the original tests.

The third line contains k integers c_1, c_2, ..., c_k (n ≥ c_1 ≥ c_2 ≥ ... ≥ c_k ≥ 1); c_i is the maximum number of arrays of size greater than or equal to i you can have in a single testcase.

Output

In the first line print a single integer ans (1 ≤ ans ≤ n) — the minimum number of testcases you can achieve.

Each of the next ans lines should contain the description of a testcase in the following format:

t a_1 a_2 ... a_{t} (1 ≤ t≤ n) — the testcase includes t arrays, a_i is the size of the i-th array in that testcase.

Each of the initial arrays should appear in exactly one testcase. In particular, it implies that the sum of t over all ans testcases should be equal to n.

Note that the answer always exists due to c_k ≥ 1 (and therefore c_1 ≥ 1).

If there are multiple answers, you can output any one of them.

Examples

Input

4 3
1 2 2 3
4 1 1

Output

3
1 2
2 1 3
1 2

Input

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

Output

2
3 8 5 7
3 10 8 1

Input

5 1
1 1 1 1 1
5

Output

1
5 1 1 1 1 1

Input

5 1
1 1 1 1 1
1

Output

5
1 1
1 1
1 1
1 1
1 1

Note

In the first example there is no way to distribute the tests into less than 3 testcases. The given answer satisfies the conditions: each of the testcases includes no more than 4 arrays of size greater than or equal to 1 and no more than 1 array of sizes greater than or equal to 2 and 3.

Note that there are multiple valid answers for this test. For example, testcases with sizes [[2], [1, 2], [3]] would also be correct.

However, testcases with sizes [[1, 2], [2, 3]] would be incorrect because there are 2 arrays of size greater than or equal to 2 in the second testcase.

Note the difference between the third and the fourth examples. You can include up to 5 arrays of size greater than or equal to 1 in the third example, so you can put all arrays into a single testcase. And you can have only up to 1 array in the fourth example. Thus, every array should be included in a separate testcase.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n), c(k);
  for (long long &i : a) cin >> i;
  for (long long &i : c) cin >> i;
  sort(a.rbegin(), a.rend());
  long long ans = 0;
  long long j = 0;
  long long tot = 0;
  for (long long i = k - 1; i >= 0; i--) {
    while (j < n and a[j] > i) j++, tot++;
    ans = max((tot + c[i] - 1) / c[i], ans);
  }
  vector<vector<long long>> test(ans);
  for (long long i = 0; i < n; i++) test[i % ans].push_back(a[i]);
  cout << ans << endl;
  for (auto it : test) {
    cout << it.size() << " ";
    for (auto i : it) cout << i << " ";
    cout << endl;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
  long long t_c = 1;
  while (t_c--) solve();
}

```


### Prompt

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

Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost fully covered with water.

The only dry land there is an archipelago of n narrow islands located in a row. For more comfort let's represent them as non-intersecting segments on a straight line: island i has coordinates [li, ri], besides, ri < li + 1 for 1 ≤ i ≤ n - 1.

To reach the goal, Andrewid needs to place a bridge between each pair of adjacent islands. A bridge of length a can be placed between the i-th and the (i + 1)-th islads, if there are such coordinates of x and y, that li ≤ x ≤ ri, li + 1 ≤ y ≤ ri + 1 and y - x = a.

The detective was supplied with m bridges, each bridge can be used at most once. Help him determine whether the bridges he got are enough to connect each pair of adjacent islands.

Input

The first line contains integers n (2 ≤ n ≤ 2·105) and m (1 ≤ m ≤ 2·105) — the number of islands and bridges.

Next n lines each contain two integers li and ri (1 ≤ li ≤ ri ≤ 1018) — the coordinates of the island endpoints.

The last line contains m integer numbers a1, a2, ..., am (1 ≤ ai ≤ 1018) — the lengths of the bridges that Andrewid got.

Output

If it is impossible to place a bridge between each pair of adjacent islands in the required manner, print on a single line "No" (without the quotes), otherwise print in the first line "Yes" (without the quotes), and in the second line print n - 1 numbers b1, b2, ..., bn - 1, which mean that between islands i and i + 1 there must be used a bridge number bi.

If there are multiple correct answers, print any of them. Note that in this problem it is necessary to print "Yes" and "No" in correct case.

Examples

Input

4 4
1 4
7 8
9 10
12 14
4 5 3 8

Output

Yes
2 3 1

Input

2 2
11 14
17 18
2 9

Output

No

Input

2 1
1 1
1000000000000000000 1000000000000000000
999999999999999999

Output

Yes
1

Note

In the first sample test you can, for example, place the second bridge between points 3 and 8, place the third bridge between points 7 and 10 and place the first bridge between points 10 and 14.

In the second sample test the first bridge is too short and the second bridge is too long, so the solution doesn't exist.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 200010;
int n, m;
struct node {
  long long l, r;
  int id;
  bool operator<(const node &rhs) const { return r > rhs.r; }
} a[N];
struct pp {
  long long x;
  int pos;
} p[N];
int ans[N];
priority_queue<node> q;
bool cmp(const pp &e, const pp &r) { return e.x < r.x; }
bool cmp1(const node &z, const node &x) { return z.l < x.l; }
int main() {
  while (~scanf("%d%d", &n, &m)) {
    while (!q.empty()) q.pop();
    long long l, r, lll, rrr;
    for (int i = 1; i <= n; ++i) {
      ans[i] = -1;
      scanf("%lld%lld", &l, &r);
      if (i >= 2) {
        a[i].l = l - rrr;
        a[i].r = r - lll;
        a[i].id = i;
      }
      lll = l;
      rrr = r;
    }
    for (int i = 1; i <= m; ++i) {
      scanf("%lld", &p[i].x);
      p[i].pos = i;
    }
    if (m < n - 1) {
      puts("No");
      continue;
    }
    sort(p + 1, p + m + 1, cmp);
    sort(a + 1, a + 1 + n, cmp1);
    int cur = 2;
    for (int i = 1; i <= m; ++i) {
      while (cur <= n && a[cur].l <= p[i].x) {
        q.push(a[cur]);
        cur++;
      }
      while (!q.empty()) {
        node c = q.top();
        q.pop();
        if (p[i].x <= c.r) {
          ans[c.id] = p[i].pos;
          break;
        }
      }
    }
    bool OK = 1;
    for (int i = 2; i <= n; ++i) {
      if (ans[i] == -1) {
        OK = 0;
        break;
      }
    }
    if (!OK)
      puts("No");
    else {
      puts("Yes");
      for (int i = 2; i <= n; ++i) printf("%d ", ans[i]);
      puts("");
    }
  }
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Omkar has a pie tray with k (2 ≤ k ≤ 20) spots. Each spot in the tray contains either a chocolate pie or a pumpkin pie. However, Omkar does not like the way that the pies are currently arranged, and has another ideal arrangement that he would prefer instead.

To assist Omkar, n elves have gathered in a line to swap the pies in Omkar's tray. The j-th elf from the left is able to swap the pies at positions a_j and b_j in the tray.

In order to get as close to his ideal arrangement as possible, Omkar may choose a contiguous subsegment of the elves and then pass his pie tray through the subsegment starting from the left. However, since the elves have gone to so much effort to gather in a line, they request that Omkar's chosen segment contain at least m (1 ≤ m ≤ n) elves.

Formally, Omkar may choose two integers l and r satisfying 1 ≤ l ≤ r ≤ n and r - l + 1 ≥ m so that first the pies in positions a_l and b_l will be swapped, then the pies in positions a_{l + 1} and b_{l + 1} will be swapped, etc. until finally the pies in positions a_r and b_r are swapped.

Help Omkar choose a segment of elves such that the amount of positions in Omkar's final arrangement that contain the same type of pie as in his ideal arrangement is the maximum possible. Note that since Omkar has a big imagination, it might be that the amounts of each type of pie in his original arrangement and in his ideal arrangement do not match.

Input

The first line contains three integers n, m, and k (1 ≤ m ≤ n ≤ 10^6 and 2 ≤ k ≤ 20) — the number of elves, the minimum subsegment length, and the number of spots in Omkar's tray respectively.

The second and third lines each contain a string of length k consisting of 0s and 1s that represent initial arrangement of pies and ideal arrangement of pies; the j-th character in each string is equal to 0 if the j-th spot in the arrangement contains a chocolate pie and is equal to 1 if the j-th spot in the arrangement contains a pumpkin pie. It is not guaranteed that the two strings have the same amount of 0s or the same amount of 1s.

n lines follow. The j-th of these lines contains two integers a_j and b_j (1 ≤ a_j, b_j ≤ k, a_j ≠ b_j) which indicate that the j-th elf from the left can swap the pies at positions a_j and b_j in the tray.

Output

Output two lines.

The first line should contain a single integer s (0 ≤ s ≤ k) equal to the amount of positions that contain the same type of pie in Omkar's final arrangement and in Omkar's ideal arrangement; s should be the maximum possible.

The second line should contain two integers l and r satisfying 1 ≤ l ≤ r ≤ n and r - l + 1 ≥ m, indicating that Omkar should pass his tray through the subsegment l, l + 1, ..., r to achieve a final arrangement with s positions having the same type of pie as his ideal arrangement.

If there are multiple answers you may output any of them.

Examples

Input

4 2 5
11000
00011
1 3
3 5
4 2
3 4

Output

5
1 3

Input

4 3 5
11000
00011
1 3
1 5
2 4
1 5

Output

3
1 4

Note

In the first test case, the swaps will go like this:

  * Swap 1 and 3: 11000 becomes 01100
  * Swap 3 and 5: 01100 becomes 01001
  * Swap 4 and 2: 01001 becomes 00011

The final arrangement is the same as the ideal arrangement 00011, so there are 5 positions with the same type of pie, which is optimal.

In the second test case, the swaps will go like this:

  * Swap 1 and 3: 11000 becomes 01100
  * Swap 1 and 5: 01100 becomes 01100
  * Swap 4 and 2: 01100 becomes 00110
  * Swap 1 and 5: 00110 becomes 00110

The final arrangement has 3 positions with the same type of pie as the ideal arrangement 00011, those being positions 1, 2, and 4. In this case the subsegment of elves (l, r) = (2, 3) is more optimal, but that subsegment is only length 2 and therefore does not satisfy the constraint that the subsegment be of length at least m = 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int nega = 1;
  while (!isdigit(ch)) {
    if (ch == '-') nega = -1;
    ch = getchar();
  }
  int ans = 0;
  while (isdigit(ch)) {
    ans = ans * 10 + ch - 48;
    ch = getchar();
  }
  if (nega == -1) return -ans;
  return ans;
}
inline char rdchar() {
  char ch = getchar();
  while (!(ch >= 'a' && ch <= 'z') && !(ch >= 'A' && ch <= 'Z') &&
         !(ch >= '0' && ch <= '9'))
    ch = getchar();
  return ch;
}
int a[(1 << 20)], b[(1 << 20)], l[(1 << 20)], r[(1 << 20)], n, m, k;
int v1[(1 << 20)], v2[(1 << 20)];
int f[(1 << 20)], g[(1 << 20)], p[(1 << 20)], rev[(1 << 20)], t[(1 << 20)];
int getv(int a[]) {
  int ans = 0;
  for (int i = 1; i <= k; i++) t[i] = a[p[i]];
  for (int i = 1; i <= k; i++)
    if (t[i]) ans |= (1 << (i - 1));
  return ans;
}
void doit(int x, int y) {
  int A = p[x], B = p[y];
  swap(p[x], p[y]), swap(rev[A], rev[B]);
}
signed main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) a[i] = rdchar() - '0';
  for (int i = 1; i <= k; i++) b[i] = rdchar() - '0';
  for (int i = 1; i <= n; i++) l[i] = read(), r[i] = read();
  for (int i = 1; i <= k; i++) p[i] = i, rev[i] = i;
  for (int i = 1; i <= n; i++) doit(l[i], r[i]);
  for (int i = 1; i <= n; i++) {
    v1[i] = getv(a);
    int x = rev[l[i]], y = rev[r[i]];
    doit(x, y);
  }
  for (int i = 1; i <= k; i++) p[i] = i, rev[i] = i;
  for (int i = 1; i <= n; i++) doit(l[i], r[i]);
  for (int i = 1; i <= n; i++) {
    int x = rev[l[i]], y = rev[r[i]];
    doit(x, y);
    v2[i] = getv(b);
  }
  for (int i = 0; i < 1 << k; i++) f[i] = 0x3f3f3f3f;
  for (int i = 1; i <= n; i++) f[v1[i]] = min(f[v1[i]], i);
  for (int i = 1; i <= n; i++) g[v2[i]] = i;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < 1 << k; j++) {
      if (!(j >> i & 1)) f[j] = min(f[j], f[j ^ (1 << i)]);
    }
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < 1 << k; j++) {
      if (!(j >> i & 1)) g[j] = max(g[j], g[j ^ (1 << i)]);
    }
  }
  int ans = 0, al = 1, ar = n;
  for (int i = 0; i < 1 << k; i++) {
    if (g[i] - f[i] + 1 >= m) {
      if (__builtin_popcount(i) > ans) {
        ans = __builtin_popcount(i);
        al = f[i], ar = g[i];
      }
    }
  }
  int c1 = 0, c2 = 0;
  for (int i = 1; i <= k; i++)
    if (a[i]) c1++;
  for (int i = 1; i <= k; i++)
    if (b[i]) c2++;
  cout << ans * 2 + k - c1 - c2 << endl;
  printf("%d %d\n", al, ar);
  return 0;
}

```


### Prompt

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

Snuke has decided to play with N cards and a deque (that is, a double-ended queue). Each card shows an integer from 1 through N, and the deque is initially empty.

Snuke will insert the cards at the beginning or the end of the deque one at a time, in order from 1 to N. Then, he will perform the following action N times: take out the card from the beginning or the end of the deque and eat it.

Afterwards, we will construct an integer sequence by arranging the integers written on the eaten cards, in the order they are eaten. Among the sequences that can be obtained in this way, find the number of the sequences such that the K-th element is 1. Print the answer modulo 10^{9} + 7.

Constraints

* 1 ≦ K ≦ N ≦ 2{,}000

Input

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

N K

Output

Print the answer modulo 10^{9} + 7.

Examples

Input

2 1

Output

1

Input

17 2

Output

262144

Input

2000 1000

Output

674286644

### Response

```cpp
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
const int maxn=2000;
int n,k;
int f[maxn+8][maxn+8],g[maxn+8][maxn+8];

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

int power(int a,int k)
{
    if (k<0) return 1;
    int sum=1;
    for (;k;k>>=1,a=1ll*a*a%mod)
    if (k&1)
        sum=1ll*sum*a%mod;
    return sum;
}

int main()
{
    n=read(),k=read();
    g[0][0]=1;
    for (int i=1;i<n;i++)
	{
	    g[i][0]=g[i-1][0];
	    for (int j=1;j<=i;j++)
		    g[i][j]=(g[i][j-1]+g[i-1][j])%mod;
	}
    int ans=g[n-1][k-1];
    ans=1ll*ans*power(2,n-k-1)%mod;
    printf("%d\n",ans);
    return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

There are n rabbits, one in each of the huts numbered 0 through n − 1.

At one point, information came to the rabbits that a secret organization would be constructing an underground passage. The underground passage would allow the rabbits to visit other rabbits' huts. I'm happy.

The passages can go in both directions, and the passages do not intersect. Due to various circumstances, the passage once constructed may be destroyed. The construction and destruction of the passages are carried out one by one, and each construction It is assumed that the rabbit stays in his hut.

Rabbits want to know in advance if one rabbit and one rabbit can play at some stage of construction. Rabbits are good friends, so they are free to go through other rabbit huts when they go out to play. Rabbits who like programming tried to solve a similar problem in the past, thinking that it would be easy, but they couldn't write an efficient program. Solve this problem instead of the rabbit.

Input

The first line of input is given n and k separated by spaces. 2 ≤ n ≤ 40 000, 1 ≤ k ≤ 40 000

In the following k lines, construction information and questions are combined and given in chronological order.

* “1 u v” — A passage connecting huts u and v is constructed. Appears only when there is no passage connecting huts u and v.
* “2 u v” — The passage connecting huts u and v is destroyed. Appears only when there is a passage connecting huts u and v.
* “3 u v” — Determine if the rabbits in the hut u and v can be played.

0 ≤ u <v <n

Output

For each question that appears in the input, output "YES" if you can play, or "NO" if not.

Example

Input

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

Output

YES
NO
YES

### Response

```cpp
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int,int>P;

int t[40000],u[40000],v[40000];
#define B 200

int par[40000];
int find(int x){
	if(par[x]==x)return x;
	return par[x]=find(par[x]);
}
void unite(int x,int y){
	x=find(x);y=find(y);
	par[x]=y;
}

multiset<int>E[40000];
int d[40000];

int main(){
	int n,k;scanf("%d%d",&n,&k);
	rep(i,k){
		scanf("%d%d%d",&t[i],&u[i],&v[i]);
	}
	set<P>se;
	for(int i=0;i<k;i+=B){
		set<P>s2,s3;
		for(int j=i;j<k&&j-i<B;j++){
			if(t[j]==2){
				if(se.count(P(u[j],v[j]))){
					se.erase(P(u[j],v[j]));
					s3.insert(P(u[j],v[j]));
				}
			}
		}
		rep(i,n)par[i]=i;
		for(auto p:se)unite(p.first,p.second);
		rep(j,n)E[j].clear();
		for(auto p:s3){
			E[find(p.first)].insert(find(p.second));
			E[find(p.second)].insert(find(p.first));
		}
		for(int j=i;j<k&&j-i<B;j++){
			if(t[j]==1){
				s2.insert(P(u[j],v[j]));
				u[j]=find(u[j]);v[j]=find(v[j]);
				E[u[j]].insert(v[j]);
				E[v[j]].insert(u[j]);
			}
			else if(t[j]==2){
				s2.erase(P(u[j],v[j]));
				u[j]=find(u[j]);v[j]=find(v[j]);
				E[u[j]].erase(E[u[j]].find(v[j]));
				E[v[j]].erase(E[v[j]].find(u[j]));
			}
			else{
				memset(d,0,sizeof(d));
				queue<int>que;
				d[find(u[j])]=1;
				que.push(find(u[j]));
				while(!que.empty()){
					int p=que.front();que.pop();
					for(int v:E[p]){
						if(d[v]==0){
							d[v]=1;que.push(v);
						}
					}
				}
				if(d[find(v[j])]==1)puts("YES");
				else puts("NO");
			}
		}
		for(auto p:s2)se.insert(p);
	}
}
```


### Prompt

Create a solution in cpp for the following problem:

Alice and Bob play a game. The game consists of several sets, and each set consists of several rounds. Each round is won either by Alice or by Bob, and the set ends when one of the players has won x rounds in a row. For example, if Bob won five rounds in a row and x = 2, then two sets ends.

You know that Alice and Bob have already played n rounds, and you know the results of some rounds. For each x from 1 to n, calculate the maximum possible number of sets that could have already finished if each set lasts until one of the players wins x rounds in a row. It is possible that the last set is still not finished — in that case, you should not count it in the answer.

Input

The first line contains one integer n (1 ≤ n ≤ 10^6) — the number of rounds.

The second line contains one string s of length n — the descriptions of rounds. If the i-th element of the string is 0, then Alice won the i-th round; if it is 1, then Bob won the i-th round, and if it is ?, then you don't know who won the i-th round.

Output

In the only line print n integers. The i-th integer should be equal to the maximum possible number of sets that could have already finished if each set lasts until one of the players wins i rounds in a row.

Examples

Input

6
11?000

Output

6 3 2 1 0 0

Input

5
01?01

Output

5 1 0 0 0

Input

12
???1??????1?

Output

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

Note

Let's consider the first test case:

  * if x = 1 and s = 110000 or s = 111000 then there are six finished sets;
  * if x = 2 and s = 110000 then there are three finished sets;
  * if x = 3 and s = 111000 then there are two finished sets;
  * if x = 4 and s = 110000 then there is one finished set;
  * if x = 5 then there are no finished sets;
  * if x = 6 then there are no finished sets.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1000006;
vector<int> p(N);
vector<vector<int>> lst(2, vector<int>(N));
vector<int> E[N];
int n;
int get(int x) {
  int R = x;
  while (x != p[x]) {
    x = p[x];
  }
  while (R != p[R]) {
    int aux = p[R];
    p[R] = x;
    R = aux;
  }
  return x;
}
void unite(int x, int y) {
  x = get(x);
  y = get(y);
  if (x > y) swap(x, y);
  p[x] = y;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  char c[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    p[i] = i;
  }
  lst[0][n + 1] = lst[1][n + 1] = n + 1;
  for (int i = n; i >= 1; i--) {
    lst[0][i] = lst[0][i + 1];
    lst[1][i] = lst[1][i + 1];
    if (c[i] == '?') continue;
    lst[c[i] - '0'][i] = i;
  }
  p[n + 1] = n + 1;
  for (int i = 1; i <= n; i++) {
    int to = max(lst[0][i], lst[1][i]);
    E[to - i].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    int now = get(1);
    while (now != n + 1) {
      ans += 1;
      now = get(now + i);
    }
    cout << ans << ' ';
    for (auto it : E[i]) {
      unite(it, it + 1);
    }
  }
  return 0;
}

```


### Prompt

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

Let’s play a stone removing game.

Initially, n stones are arranged on a circle and numbered 1, ... , n clockwise (Figure 1). You are also given two numbers k and m. From this state, remove stones one by one following the rules explained below, until only one remains. In step 1, remove stone m. In step 2, locate the k-th next stone clockwise from m and remove it. In subsequent steps, start from the slot of the stone removed in the last step, make k hops clockwise on the remaining stones and remove the one you reach. In other words, skip (k - 1) remaining stones clockwise and remove the next one. Repeat this until only one stone is left and answer its number.

For example, the answer for the case n = 8, k = 5, m = 3 is 1, as shown in Figure 1.

<image>

Figure 1: An example game

Initial state: Eight stones are arranged on a circle.

Step 1: Stone 3 is removed since m = 3.

Step 2: You start from the slot that was occupied by stone 3. You skip four stones 4, 5, 6 and 7 (since k = 5), and remove the next one, which is 8.

Step 3: You skip stones 1, 2, 4 and 5, and thus remove 6. Note that you only count stones that are still on the circle and ignore those already removed. Stone 3 is ignored in this case.

Steps 4-7: You continue until only one stone is left. Notice that in later steps when only a few stones remain, the same stone may be skipped multiple times. For example, stones 1 and 4 are skipped twice in step 7.

Final State: Finally, only one stone, 1, is on the circle. This is the final state, so the answer is 1.

Input

The input consists of multiple datasets each of which is formatted as follows.

n k m

The last dataset is followed by a line containing three zeros. Numbers in a line are separated by a single space. A dataset satisfies the following conditions.

2 ≤ n ≤ 10000, 1 ≤ k ≤ 10000, 1 ≤ m ≤ n

The number of datasets is less than 100.

Output

For each dataset, output a line containing the stone number left in the final state. No extra characters such as spaces should appear in the output.

Example

Input

8 5 3
100 9999 98
10000 10000 10000
0 0 0

Output

1
93
2019

### Response

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

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n,k,m; cin >> n >> k >> m;
		if(n==0&&k==0&&m==0)break;
		vector<int> a(n);
		for(int i=0;i<n;i++){
			a[i]=i+1;
		}
		int now=m-1;
		a.erase(a.begin()+m-1);
		while(a.size()>1){
			now=(now+k-1)%a.size();
			a.erase(a.begin()+now);
		}
		printf("%d\n",a[0]);
	}
}

```


### Prompt

Create a solution in cpp for the following problem:

Estimating the Flood Risk

Mr. Boat is the owner of a vast extent of land. As many typhoons have struck Japan this year, he became concerned of flood risk of his estate and he wants to know the average altitude of his land. The land is too vast to measure the altitude at many spots. As no steep slopes are in the estate, he thought that it would be enough to measure the altitudes at only a limited number of sites and then approximate the altitudes of the rest based on them.

Multiple approximations might be possible based on the same measurement results, in which case he wants to know the worst case, that is, one giving the lowest average altitude.

Mr. Boat’s estate, which has a rectangular shape, is divided into grid-aligned rectangular areas of the same size. Altitude measurements have been carried out in some of these areas, and the measurement results are now at hand. The altitudes of the remaining areas are to be approximated on the assumption that altitudes of two adjoining areas sharing an edge differ at most 1.

In the first sample given below, the land is divided into 5 × 4 areas. The altitudes of the areas at (1, 1) and (5, 4) are measured 10 and 3, respectively. In this case, the altitudes of all the areas are uniquely determined on the assumption that altitudes of adjoining areas differ at most 1.

In the second sample, there are multiple possibilities, among which one that gives the lowest average altitude should be considered.

In the third sample, no altitude assignments satisfy the assumption on altitude differences.

<image>

Your job is to write a program that approximates the average altitude of his estate. To be precise, the program should compute the total of approximated and measured altitudes of all the mesh-divided areas. If two or more different approximations are possible, the program should compute the total with the severest approximation, that is, one giving the lowest total of the altitudes.

Input

The input consists of a single test case of the following format.

$w$ $d$ $n$
$x_1$ $y_1$ $z_1$
.
.
.
$x_n$ $y_n$ $z_n$

Here, $w$, $d$, and $n$ are integers between $1$ and $50$, inclusive. $w$ and $d$ are the numbers of areas in the two sides of the land. $n$ is the number of areas where altitudes are measured. The $i$-th line of the following $n$ lines contains three integers, $x_i$, $y_i$, and $z_i$ satisfying $1 \leq x_i \leq w$, $1 \leq y_i \leq d$, and $−100 \leq z_i \leq 100$. They mean that the altitude of the area at $(x_i , y_i)$ was measured to be $z_i$. At most one measurement result is given for the same area, i.e., for $i \ne j$, $(x_i, y_i) \ne (x_j , y_j)$.

Output

If all the unmeasured areas can be assigned their altitudes without any conflicts with the measured altitudes assuming that two adjoining areas have the altitude difference of at most 1, output an integer that is the total of the measured or approximated altitudes of all the areas. If more than one such altitude assignment is possible, output the minimum altitude total among the possible assignments.

If no altitude assignments satisfy the altitude difference assumption, output No.

Sample Input 1

5 4 2
1 1 10
5 4 3

Sample Output 1

130

Sample Input 2

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

Sample Output 2

-14

Sample Input 3

3 3 2
1 1 8
3 3 3

Sample Output 3

No

Sample Input 4

2 2 1
1 1 -100

Sample Output 4

-404

Example

Input

5 4 2
1 1 10
5 4 3

Output

130

### Response

```cpp
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int w, d;
vector<vector<int>> cost;
queue<pair<int, int>> que;
set<pair<int, int>> st;

int bfs(){
    int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
    while(!que.empty()) {
        int x, y;
        tie(y, x) = que.front(); que.pop();
        for(int i = 0; i < 4; i++) {
            int ny = y+dy[i], nx = x+dx[i];
            if(nx < 0 || ny < 0 || nx >= w || ny >= d) continue;
            // cout << ny << " " << nx << endl;

            if(cost[ny][nx] < cost[y][x]-1){
                if(st.count(make_pair(ny, nx)) > 0){
                    return -1;
                }

                cost[ny][nx] = cost[y][x]-1;
                que.push(make_pair(ny, nx));
            }
        }
    }
    return 0;
}

int main(){
    fastcin();
    int n;
    cin >> w >> d >> n;
    cost.assign(d, vector<int>(w, -INF));
    rep(i, n){
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        st.insert(make_pair(y, x));
        que.push(make_pair(y, x));
        cost[y][x] = z;
    }
    if(bfs() == -1){
        cout << "No" << endl;
        return 0;
    }
    LL ans = 0;
    rep(i, d)rep(j, w){
        assert(cost[i][j] != -INF);
        ans += cost[i][j];
    }
    cout << ans << endl;
    return 0;

}

```


### Prompt

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

Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him.

Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset.

Input

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point.

Output

Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9.

Examples

Input

4
0.1 0.2 0.3 0.8

Output

0.800000000000

Input

2
0.1 0.2

Output

0.260000000000

Note

In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one.

In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  double p[110], P = 1.0, S = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%lf", &p[i]);
  sort(p, p + n);
  double ans = 0.0;
  for (int i = n - 1; (S < 1.0) && (i >= 0); --i) {
    ans += p[i] * P * (1 - S);
    P *= (1 - p[i]);
    S += p[i] / (1 - p[i]);
  }
  printf("%.9lf\n", ans);
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

So, the Berland is at war with its eternal enemy Flatland again, and Vasya, an accountant, was assigned to fulfil his duty to the nation.

Right now the situation in Berland is dismal — their both cities are surrounded! The armies of flatlanders stand on the borders of circles, the circles' centers are in the surrounded cities. At any moment all points of the flatland ring can begin to move quickly in the direction of the city — that's the strategy the flatlanders usually follow when they besiege cities.

The berlanders are sure that they can repel the enemy's attack if they learn the exact time the attack starts. For that they need to construct a radar that would register any movement at the distance of at most r from it. Thus, we can install a radar at such point, that at least one point of the enemy ring will be in its detecting range (that is, at a distance of at most r). Then the radar can immediately inform about the enemy's attack.

Due to the newest technologies, we can place a radar at any point without any problems. But the problem is that the berlanders have the time to make only one radar. Besides, the larger the detection radius (r) is, the more the radar costs.

That's why Vasya's task (that is, your task) is to find the minimum possible detection radius for the radar. In other words, your task is to find the minimum radius r (r ≥ 0) such, that a radar with radius r can be installed at some point and it can register the start of the movements of both flatland rings from that point.

In this problem you can consider the cities as material points, the attacking enemy rings - as circles with centers in the cities, the radar's detection range — as a disk (including the border) with the center at the point where the radar is placed.

Input

The input files consist of two lines. Each line represents the city and the flatland ring that surrounds it as three space-separated integers xi, yi, ri (|xi|, |yi| ≤ 104; 1 ≤ ri ≤ 104) — the city's coordinates and the distance from the city to the flatlanders, correspondingly.

It is guaranteed that the cities are located at different points.

Output

Print a single real number — the minimum detection radius of the described radar. The answer is considered correct if the absolute or relative error does not exceed 10 - 6.

Examples

Input

0 0 1
6 0 3

Output

1.000000000000000

Input

-10 10 3
10 -10 3

Output

11.142135623730951

Note

The figure below shows the answer to the first sample. In this sample the best decision is to put the radar at point with coordinates (2, 0).

<image>

The figure below shows the answer for the second sample. In this sample the best decision is to put the radar at point with coordinates (0, 0).

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x1, y1, r1;
  int x2, y2, r2;
  cin >> x1 >> y1 >> r1;
  cin >> x2 >> y2 >> r2;
  long double dx = (x1 - x2);
  long double dy = y1 - y2;
  long double dist = sqrt(dx * dx + dy * dy);
  cout << fixed << setprecision(9);
  if (r1 + r2 >= dist) {
    if ((dist + r1 <= r2 || dist + r2 <= r1)) {
      cout << abs(max(r1, r2) - dist - min(r1, r2)) / 2.f << endl;
    } else
      cout << 0 << endl;
    return 0;
  }
  cout << abs(dist - r1 - r2) / 2 << endl;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

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

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

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

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

Constraints

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

Inputs

Input is given from Standard Input in the following format:

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

Outputs

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

Examples

Input

3
0 1 3
1 0 2
3 2 0

Output

3

Input

3
0 1 3
1 0 1
3 1 0

Output

-1

Input

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

Output

82

Input

3
0 1000000000 1000000000
1000000000 0 1000000000
1000000000 1000000000 0

Output

3000000000

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  vector<vector<long long>> a(n, vector<long long>(n));
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin >> a[i][j];
  for(int i=0;i<n;i++) {
    for(int j=i+1;j<n;j++) {
      bool need = true;
      for(int k=0;k<n;k++) {
        if(k == i || k == j) continue;
        if(a[i][j] < a[i][k] + a[k][j]) continue;
        else if(a[i][j] == a[i][k] + a[k][j]) need = false;
        else {
          ans = -1;
          break;
        }
      }
      if(ans == -1) break;
      if(need) ans += a[i][j];
    }
    if(ans == -1) break;
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

You are given an array of length n and a number k. Let's pick k non-overlapping non-empty subarrays of the initial array. Let si be the sum of the i-th subarray in order from left to right. Compute the maximum value of the following expression:

|s1 - s2| + |s2 - s3| + ... + |sk - 1 - sk|

Here subarray is a contiguous part of an array.

Input

The first line of input contains two integers n and k. The second line contains n integers — the elements of the array. The absolute values of elements do not exceed 104.

The problem consists of two subproblems. The subproblems have different constraints on the input. You will get some score for the correct submission of the subproblem. The description of the subproblems follows.

  * In subproblem E1 (9 points), constraints 2 ≤ n ≤ 400, 2 ≤ k ≤ min(n, 50) will hold.
  * In subproblem E2 (12 points), constraints 2 ≤ n ≤ 30000, 2 ≤ k ≤ min(n, 200) will hold.

Output

Output a single integer — the maximum possible value.

Examples

Input

5 3
5 2 4 3 1

Output

12

Input

4 2
7 4 3 7

Output

8

Note

Consider the first sample test. The optimal solution is obtained if the first subarray contains the first element only, the second subarray spans the next three elements and the last subarray contains the last element only. The sums of these subarrays are 5, 9 and 1, correspondingly.

Consider the second sample test. In the optimal solution, the first subarray consists of the first two elements and the second subarray consists of the third element only. Note that the last element does not belong to any subarray in this solution.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chkmax(T &x, T y) {
  x = x > y ? x : y;
}
template <typename T>
void chkmin(T &x, T y) {
  x = x > y ? y : x;
}
const int INF = (1ll << 30) - 1;
template <typename T>
void read(T &x) {
  x = 0;
  bool f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = 0;
  } while (ch > '9' || ch < '0');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  x = f ? x : -x;
}
template <typename T>
void write(T x) {
  if (x < 0) x = ~x + 1, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const int N = 3e4 + 5;
const int K = 200 + 5;
int n, m, a[N], f[N][K][4];
int main() {
  read(n);
  read(m);
  memset(f, -0x3f, sizeof(f));
  for (int i = 1; i <= n; i++) read(a[i]);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j < 4; j++) f[i][0][j] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int x = 1 + (j != 1 && j != m);
      f[i][j][0] = max(f[i - 1][j][0], f[i - 1][j - 1][3]) + x * a[i];
      f[i][j][1] = max(f[i][j][0], f[i - 1][j][1]);
      f[i][j][2] = max(f[i - 1][j][2], f[i - 1][j - 1][1]) - x * a[i];
      f[i][j][3] = max(f[i][j][2], f[i - 1][j][3]);
      if (x == 2) f[i][j][1] = max(f[i][j][1], f[i - 1][j - 1][1]);
      if (x == 2) f[i][j][3] = max(f[i][j][3], f[i - 1][j - 1][3]);
    }
  }
  int ans = 0;
  for (int i = 0; i < 4; i++) chkmax(ans, f[n][m][i]);
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

We're giving away nice huge bags containing number tiles! A bag we want to present to you contains n tiles. Each of them has a single number written on it — either 1 or 2.

However, there is one condition you must fulfill in order to receive the prize. You will need to put all the tiles from the bag in a sequence, in any order you wish. We will then compute the sums of all prefixes in the sequence, and then count how many of these sums are prime numbers. If you want to keep the prize, you will need to maximize the number of primes you get.

Can you win the prize? Hurry up, the bags are waiting!

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of number tiles in the bag. The following line contains n space-separated integers a_1, a_2, ..., a_n (a_i ∈ \{1, 2\}) — the values written on the tiles.

Output

Output a permutation b_1, b_2, ..., b_n of the input sequence (a_1, a_2, ..., a_n) maximizing the number of the prefix sums being prime numbers. If there are multiple optimal permutations, output any.

Examples

Input

5
1 2 1 2 1

Output

1 1 1 2 2

Input

9
1 1 2 1 1 1 2 1 1

Output

1 1 1 2 1 1 1 2 1

Note

The first solution produces the prefix sums 1, \mathbf{\color{blue}{2}}, \mathbf{\color{blue}{3}}, \mathbf{\color{blue}{5}}, \mathbf{\color{blue}{7}} (four primes constructed), while the prefix sums in the second solution are 1, \mathbf{\color{blue}{2}}, \mathbf{\color{blue}{3}}, \mathbf{\color{blue}{5}}, 6, \mathbf{\color{blue}{7}}, 8, 10, \mathbf{\color{blue}{11}} (five primes). Primes are marked bold and blue. In each of these cases, the number of produced primes is maximum possible.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, x, y;
int main() {
  int i, a;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a == 1)
      x++;
    else
      y++;
  }
  if (x == 0) {
    for (i = 0; i < y; i++) printf("2 ");
    printf("\n");
  } else if (y == 0) {
    for (i = 0; i < x; i++) printf("1 ");
    printf("\n");
  } else {
    printf("2 1 ");
    x--, y--;
    for (i = 0; i < y; i++) printf("2 ");
    for (i = 0; i < x; i++) printf("1 ");
    printf("\n");
  }
  return 0;
}

```


### Prompt

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

Having stayed home alone, Petya decided to watch forbidden films on the Net in secret. "What ungentlemanly behavior!" — you can say that, of course, but don't be too harsh on the kid. In his country films about the Martians and other extraterrestrial civilizations are forbidden. It was very unfair to Petya as he adored adventure stories that featured lasers and robots.

Today Petya is watching a shocking blockbuster about the Martians called "R2:D2". What can "R2:D2" possibly mean? It might be the Martian time represented in the Martian numeral system. Petya knows that time on Mars is counted just like on the Earth (that is, there are 24 hours and each hour has 60 minutes). The time is written as "a:b", where the string a stands for the number of hours (from 0 to 23 inclusive), and string b stands for the number of minutes (from 0 to 59 inclusive). The only thing Petya doesn't know is in what numeral system the Martian time is written.

Your task is to print the radixes of all numeral system which can contain the time "a:b".

Input

The first line contains a single string as "a:b" (without the quotes). There a is a non-empty string, consisting of numbers and uppercase Latin letters. String a shows the number of hours. String b is a non-empty string that consists of numbers and uppercase Latin letters. String b shows the number of minutes. The lengths of strings a and b are from 1 to 5 characters, inclusive. Please note that strings a and b can have leading zeroes that do not influence the result in any way (for example, string "008:1" in decimal notation denotes correctly written time).

We consider characters 0, 1, ..., 9 as denoting the corresponding digits of the number's representation in some numeral system, and characters A, B, ..., Z correspond to numbers 10, 11, ..., 35.

Output

Print the radixes of the numeral systems that can represent the time "a:b" in the increasing order. Separate the numbers with spaces or line breaks. If there is no numeral system that can represent time "a:b", print the single integer 0. If there are infinitely many numeral systems that can represent the time "a:b", print the single integer -1.

Note that on Mars any positional numeral systems with positive radix strictly larger than one are possible.

Examples

Input

11:20

Output

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

Input

2A:13

Output

0

Input

000B:00001

Output

-1

Note

Let's consider the first sample. String "11:20" can be perceived, for example, as time 4:6, represented in the ternary numeral system or as time 17:32 in hexadecimal system.

Let's consider the second sample test. String "2A:13" can't be perceived as correct time in any notation. For example, let's take the base-11 numeral notation. There the given string represents time 32:14 that isn't a correct time.

Let's consider the third sample. String "000B:00001" can be perceived as a correct time in the infinite number of numeral systems. If you need an example, you can take any numeral system with radix no less than 12.

### Response

```cpp
#include <bits/stdc++.h>
int a[5], b[5];
int mu(int a, int n) {
  int i, kq = 1;
  for (i = 0; i < n; i++) {
    kq *= a;
  }
  return kq;
}
int tinh(int p[], int n, int base) {
  int i, sum = 0;
  for (i = n - 1; i >= 0; i--) {
    sum += p[i] * mu(base, n - i - 1);
  }
  return sum;
}
int main() {
  int i, na, nb, ma = 0, mb = 0, max, check = 0;
  char c;
  i = 0;
  while ((c = getchar()) != EOF) {
    if (c >= '0' && c < '9') a[i++] = c - '0';
    if (c >= 'A' && c <= 'Z') a[i++] = c - 'A' + 10;
    if (a[i - 1] > ma) ma = a[i - 1];
    if (c == ':') break;
  }
  na = i;
  i = 0;
  while ((c = getchar()) != EOF) {
    if (c >= '0' && c < '9') b[i++] = c - '0';
    if (c >= 'A' && c <= 'Z') b[i++] = c - 'A' + 10;
    if (b[i - 1] > mb) mb = b[i - 1];
    if (c == '\n') break;
  }
  nb = i;
  if (ma > mb)
    max = ma + 1;
  else
    max = mb + 1;
  if (tinh(a, na, max) > 23 || tinh(b, nb, max) > 59) {
    printf("0\n");
    return 0;
  }
  for (i = 0; i < na - 1; i++)
    if (a[i] != 0) check = 1;
  for (i = 0; i < nb - 1; i++)
    if (b[i] != 0) check = 1;
  if (check == 0) {
    printf("-1\n");
    return 0;
  }
  i = max;
  while (tinh(a, na, i) < 24 && tinh(b, nb, i) < 60) {
    printf("%d ", i);
    i++;
  }
  printf("\n");
  return 0;
}

```


### Prompt

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

Everything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as n holes in a row. We will consider the holes numbered from 1 to n, from left to right.

Ilya is really keep on helping his city. So, he wants to fix at least k holes (perharps he can fix more) on a single ZooVille road.

The city has m building companies, the i-th company needs ci money units to fix a road segment containing holes with numbers of at least li and at most ri. The companies in ZooVille are very greedy, so, if they fix a segment containing some already fixed holes, they do not decrease the price for fixing the segment.

Determine the minimum money Ilya will need to fix at least k holes.

Input

The first line contains three integers n, m, k (1 ≤ n ≤ 300, 1 ≤ m ≤ 105, 1 ≤ k ≤ n). The next m lines contain the companies' description. The i-th line contains three integers li, ri, ci (1 ≤ li ≤ ri ≤ n, 1 ≤ ci ≤ 109).

Output

Print a single integer — the minimum money Ilya needs to fix at least k holes.

If it is impossible to fix at least k holes, print -1.

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

Examples

Input

10 4 6
7 9 11
6 9 13
7 7 7
3 5 6

Output

17

Input

10 7 1
3 4 15
8 9 8
5 6 8
9 10 6
1 4 2
1 4 10
8 10 13

Output

2

Input

10 1 9
5 10 14

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long cost[303][303], dp[303][303];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  memset(cost, 0x3f3f3f3f3f3f3f3f, sizeof(cost));
  for (int i = 1; i <= m; i++) {
    int l, r;
    long long c;
    cin >> l >> r >> c;
    for (int j = l; j <= r; j++) cost[l][j] = min(cost[l][j], c);
  }
  memset(dp, 0x3f3f3f3f3f3f3f3f, sizeof(dp));
  for (int i = 0; i <= n; i++) dp[i][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      dp[i][j] = dp[i - 1][j];
      for (int k = 1; k <= j; k++)
        dp[i][j] = min(dp[i][j], cost[i - k + 1][i] + dp[i - k][j - k]);
    }
  }
  long long result = 0x3f3f3f3f3f3f3f3f;
  for (int i = k; i <= n; i++) result = min(result, dp[n][i]);
  if (result < 0x3f3f3f3f3f3f3f3f)
    cout << result << "\n";
  else
    cout << "-1\n";
}

```


### Prompt

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

Mike decided to teach programming to children in an elementary school. He knows that it is not an easy task to interest children in that age to code. That is why he decided to give each child two sweets.

Mike has n sweets with sizes a_1, a_2, …, a_n. All his sweets have different sizes. That is, there is no such pair (i, j) (1 ≤ i, j ≤ n) such that i ≠ j and a_i = a_j.

Since Mike has taught for many years, he knows that if he gives two sweets with sizes a_i and a_j to one child and a_k and a_p to another, where (a_i + a_j) ≠ (a_k + a_p), then a child who has a smaller sum of sizes will be upset. That is, if there are two children who have different sums of sweets, then one of them will be upset. Apparently, Mike does not want somebody to be upset.

Mike wants to invite children giving each of them two sweets. Obviously, he can't give one sweet to two or more children. His goal is to invite as many children as he can.

Since Mike is busy preparing to his first lecture in the elementary school, he is asking you to find the maximum number of children he can invite giving each of them two sweets in such way that nobody will be upset.

Input

The first line contains one integer n (2 ≤ n ≤ 1 000) — the number of sweets Mike has.

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^5) — the sizes of the sweets. It is guaranteed that all integers are distinct.

Output

Print one integer — the maximum number of children Mike can invite giving each of them two sweets in such way that nobody will be upset.

Examples

Input

8
1 8 3 11 4 9 2 7

Output

3

Input

7
3 1 7 11 9 2 12

Output

2

Note

In the first example, Mike can give 9+2=11 to one child, 8+3=11 to another one, and 7+4=11 to the third child. Therefore, Mike can invite three children. Note that it is not the only solution.

In the second example, Mike can give 3+9=12 to one child and 1+11 to another one. Therefore, Mike can invite two children. Note that it is not the only solution.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const int INF = 0x3f3f3f3f;
int arr[N];
map<int, int> mp;
int main() {
  mp.clear();
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      mp[arr[i] + arr[j]]++;
    }
  }
  int ans = 0;
  for (pair<int, int> p : mp) {
    ans = max(ans, p.second);
  }
  printf("%d\n", ans);
}

```


### Prompt

Create a solution in CPP for the following problem:

Nikita likes tasks on order statistics, for example, he can easily find the k-th number in increasing order on a segment of an array. But now Nikita wonders how many segments of an array there are such that a given number x is the k-th number in increasing order on this segment. In other words, you should find the number of segments of a given array such that there are exactly k numbers of this segment which are less than x.

Nikita wants to get answer for this question for each k from 0 to n, where n is the size of the array.

Input

The first line contains two integers n and x (1 ≤ n ≤ 2 ⋅ 10^5, -10^9 ≤ x ≤ 10^9).

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

Output

Print n+1 integers, where the i-th number is the answer for Nikita's question for k=i-1.

Examples

Input

5 3
1 2 3 4 5

Output

6 5 4 0 0 0

Input

2 6
-5 9

Output

1 2 0

Input

6 99
-1 -1 -1 -1 -1 -1

Output

0 6 5 4 3 2 1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 8e5 + 10;
const long double Pi = 3.141592653589793;
int n, first;
int sum[N], a[N];
int rev[N];
pair<long double, long double> w[N];
pair<long double, long double> operator+(pair<long double, long double> a,
                                         pair<long double, long double> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
pair<long double, long double> operator-(pair<long double, long double> a,
                                         pair<long double, long double> b) {
  return make_pair(a.first - b.first, a.second - b.second);
}
pair<long double, long double> operator*(pair<long double, long double> a,
                                         pair<long double, long double> b) {
  return make_pair(a.first * b.first - a.second * b.second,
                   a.first * b.second + a.second * b.first);
}
pair<long double, long double> operator/(pair<long double, long double> a,
                                         long double t) {
  return make_pair(a.first / t, a.second / t);
}
void initrev(int n, int &lim) {
  lim = 1;
  for (; lim < n; lim <<= 1)
    ;
  for (int i = 1; i < lim; i++) {
    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) * (lim >> 1));
  }
  for (int i = 0; i < lim; i++)
    w[i] = make_pair(cos(Pi * 2 / lim * i), sin(Pi * 2 / lim * i));
  return;
}
void FFT(vector<pair<long double, long double> > &a, int t) {
  int lim = a.size();
  for (int i = 0; i < lim; i++)
    if (i < rev[i]) swap(a[i], a[rev[i]]);
  for (int i = 2; i <= lim; i <<= 1) {
    for (int j = 0; j < lim; j += i) {
      for (int k = 0; k < (i >> 1); k++) {
        pair<long double, long double> first = a[j + k],
                                       second =
                                           a[j + k + (i >> 1)] * w[lim / i * k];
        a[j + k] = (first + second);
        a[j + k + (i >> 1)] = (first - second);
      }
    }
  }
  if (t < 0) {
    reverse(a.begin() + 1, a.end());
    for (int i = 0; i < lim; i++) a[i] = a[i] / lim;
  }
  return;
}
int main() {
  scanf("%d%d", &n, &first);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i] = sum[i - 1];
    if (a[i] < first) sum[i]++;
  }
  int lim;
  initrev(n * 2 + 1, lim);
  vector<pair<long double, long double> > f(lim);
  for (int i = 0; i <= n; i++) f[sum[i]].first += 1;
  vector<pair<long double, long double> > g = f;
  reverse(f.begin(), f.begin() + n + 1);
  FFT(f, 1), FFT(g, 1);
  for (int i = 0; i < lim; i++) f[i] = f[i] * g[i];
  FFT(f, -1);
  printf("%lld ", (llround(f[n].first) - n - 1) / 2);
  for (int i = 1; i <= n; i++) printf("%lld ", llround(f[i + n].first));
  printf("\n");
  return 0;
}

```


### Prompt

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

Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and sabotage his research work.

The girl finds an important permutation for the research. The permutation contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ n). She replaces some of permutation elements with -1 value as a revenge.

When Iahub finds out his important permutation is broken, he tries to recover it. The only thing he remembers about the permutation is it didn't have any fixed point. A fixed point for a permutation is an element ak which has value equal to k (ak = k). Your job is to proof to Iahub that trying to recover it is not a good idea. Output the number of permutations which could be originally Iahub's important permutation, modulo 1000000007 (109 + 7).

Input

The first line contains integer n (2 ≤ n ≤ 2000). On the second line, there are n integers, representing Iahub's important permutation after Iahubina replaces some values with -1.

It's guaranteed that there are no fixed points in the given permutation. Also, the given sequence contains at least two numbers -1 and each positive number occurs in the sequence at most once. It's guaranteed that there is at least one suitable permutation.

Output

Output a single integer, the number of ways Iahub could recover his permutation, modulo 1000000007 (109 + 7).

Examples

Input

5
-1 -1 4 3 -1

Output

2

Note

For the first test example there are two permutations with no fixed points are [2, 5, 4, 3, 1] and [5, 1, 4, 3, 2]. Any other permutation would have at least one fixed point.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int n, arr[2002];
bool ele_used[2002], pos_used[2002];
long long DP[2002][2002][2];
long long dp(int rem_ele, int super_pos, bool start_new_chain) {
  if (super_pos < 0) return 0;
  if (rem_ele == 0) return 1;
  long long &ans = DP[rem_ele][super_pos][start_new_chain];
  if (ans != -1) return ans;
  ans = 0;
  if (start_new_chain) {
    ans = (ans + (rem_ele - 1) * dp(rem_ele - 1, super_pos + 1, false)) %
          (1000000007LL);
    ans = (ans + (super_pos)*dp(rem_ele - 1, super_pos, true)) % (1000000007LL);
    return ans;
  } else {
    ans = (ans + (rem_ele - 1) * dp(rem_ele - 1, super_pos, false)) %
          (1000000007LL);
    ans = (ans + super_pos * dp(rem_ele - 1, super_pos - 1, true)) %
          (1000000007LL);
    return ans;
  }
  assert(0);
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    if (arr[i] != -1) {
      ele_used[arr[i]] = pos_used[i] = true;
    }
  }
  int constrained = 0, super_ele = 0, super_pos = 0;
  for (int i = 1; i <= n; i++)
    if (!ele_used[i] && !pos_used[i])
      constrained++;
    else if (ele_used[i] && !pos_used[i])
      super_pos++;
    else if (pos_used[i] && !ele_used[i])
      super_ele++;
  memset(DP, -1, sizeof(DP));
  long long ans = dp(constrained, super_pos, true);
  while (super_ele > 0) {
    ans = (ans * super_ele) % (1000000007LL);
    super_ele--;
  }
  cout << ans;
  return 0;
}

```


### Prompt

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

Haiku is a genre of Japanese traditional poetry.

A haiku poem consists of 17 syllables split into three phrases, containing 5, 7 and 5 syllables correspondingly (the first phrase should contain exactly 5 syllables, the second phrase should contain exactly 7 syllables, and the third phrase should contain exactly 5 syllables). A haiku masterpiece contains a description of a moment in those three phrases. Every word is important in a small poem, which is why haiku are rich with symbols. Each word has a special meaning, a special role. The main principle of haiku is to say much using a few words.

To simplify the matter, in the given problem we will consider that the number of syllable in the phrase is equal to the number of vowel letters there. Only the following letters are regarded as vowel letters: "a", "e", "i", "o" and "u".

Three phases from a certain poem are given. Determine whether it is haiku or not.

Input

The input data consists of three lines. The length of each line is between 1 and 100, inclusive. The i-th line contains the i-th phrase of the poem. Each phrase consists of one or more words, which are separated by one or more spaces. A word is a non-empty sequence of lowercase Latin letters. Leading and/or trailing spaces in phrases are allowed. Every phrase has at least one non-space character. See the example for clarification.

Output

Print "YES" (without the quotes) if the poem is a haiku. Otherwise, print "NO" (also without the quotes).

Examples

Input

on  codeforces
beta round is running
   a rustling of keys

Output

YES

Input

how many gallons
of edo s rain did you drink
                                cuckoo

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string out[] = {"NO", "YES"};
  int a[4] = {};
  for (int i = 1; i <= 3; i++) {
    string line, se;
    getline(cin, line);
    stringstream str(line);
    while (str >> se) {
      for (char c : se) {
        a[i] += (set<char>{'a', 'e', 'i', 'o', 'u'}.count(c));
      }
    }
  }
  cout << out[a[1] == 5 && a[2] == 7 && a[3] == 5] << '\n';
}

```


### Prompt

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

A and B are preparing themselves for programming contests.

To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger.

For each chess piece we know its weight:

  * the queen's weight is 9,
  * the rook's weight is 5,
  * the bishop's weight is 3,
  * the knight's weight is 3,
  * the pawn's weight is 1,
  * the king's weight isn't considered in evaluating position.

The player's weight equals to the sum of weights of all his pieces on the board.

As A doesn't like counting, he asked you to help him determine which player has the larger position weight.

Input

The input contains eight lines, eight characters each — the board's description.

The white pieces on the board are marked with uppercase letters, the black pieces are marked with lowercase letters.

The white pieces are denoted as follows: the queen is represented is 'Q', the rook — as 'R', the bishop — as'B', the knight — as 'N', the pawn — as 'P', the king — as 'K'.

The black pieces are denoted as 'q', 'r', 'b', 'n', 'p', 'k', respectively.

An empty square of the board is marked as '.' (a dot).

It is not guaranteed that the given chess position can be achieved in a real game. Specifically, there can be an arbitrary (possibly zero) number pieces of each type, the king may be under attack and so on.

Output

Print "White" (without quotes) if the weight of the position of the white pieces is more than the weight of the position of the black pieces, print "Black" if the weight of the black pieces is more than the weight of the white pieces and print "Draw" if the weights of the white and black pieces are equal.

Examples

Input

...QK...
........
........
........
........
........
........
...rk...

Output

White

Input

rnbqkbnr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNR

Output

Draw

Input

rppppppr
...k....
........
........
........
........
K...Q...
........

Output

Black

Note

In the first test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals 5.

In the second test sample the weights of the positions of the black and the white pieces are equal to 39.

In the third test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals to 16.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string c[10];
int main() {
  int A = 0, B = 0;
  for (int i = 0; i < 8; ++i) cin >> c[i];
  for (int i = 0; i < 8; ++i) {
    for (int j = 0; j < 8; ++j) {
      if (c[i][j] == 'Q')
        A += 9;
      else if (c[i][j] == 'R')
        A += 5;
      else if (c[i][j] == 'B' || c[i][j] == 'N')
        A += 3;
      else if (c[i][j] == 'P')
        A++;
      else if (c[i][j] == 'q')
        B += 9;
      else if (c[i][j] == 'r')
        B += 5;
      else if (c[i][j] == 'b' || c[i][j] == 'n')
        B += 3;
      else if (c[i][j] == 'p')
        B++;
    }
  }
  if (A > B) {
    cout << "White\n";
    return 0;
  } else if (B > A) {
    cout << "Black\n";
    return 0;
  } else {
    cout << "Draw\n";
    return 0;
  }
  return 0;
}

```