### Prompt

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

You are given a connected weighted graph with n vertices and m edges. The graph doesn't contain loops nor multiple edges. Consider some edge with id i. Let's determine for this edge the maximum integer weight we can give to it so that it is contained in all minimum spanning trees of the graph if we don't change the other weights.

You are to determine this maximum weight described above for each edge. You should calculate the answer for each edge independently, it means there can't be two edges with changed weights at the same time.

Input

The first line contains two integers n and m (2 ≤ n ≤ 2·105, n - 1 ≤ m ≤ 2·105), where n and m are the number of vertices and the number of edges in the graph, respectively.

Each of the next m lines contains three integers u, v and c (1 ≤ v, u ≤ n, v ≠ u, 1 ≤ c ≤ 109) meaning that there is an edge between vertices u and v with weight c.

Output

Print the answer for each edge in the order the edges are given in the input. If an edge is contained in every minimum spanning tree with any weight, print -1 as the answer.

Examples

Input

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

Output

2 2 2 1

Input

4 3
1 2 2
2 3 2
3 4 2

Output

-1 -1 -1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct ed {
  int u, v, cost, idx;
  ed() {}
  ed(int uu, int vv, int cc, int idx) : u(uu), v(vv), cost(cc), idx(idx) {}
  bool operator<(const ed& a) const { return cost < a.cost; }
};
struct edge {
  int next, cost;
  edge() {}
  edge(int a, int c) : next(a), cost(c) {}
};
struct node {
  int height;
  int par[23];
  int chainNum;
  int heavyNode;
  int segNum;
  int cost[23];
  int childcnt;
};
int n, m;
node info[200001];
int chainHead[200001];
vector<edge> adj[200001];
bool visited[200001];
void dfs(int cur, int height) {
  int cnt = 1;
  int maxV = 0;
  int maxnode = 0;
  for (auto& a : adj[cur]) {
    if (!visited[a.next]) {
      visited[a.next] = true;
      info[a.next].height = height + 1;
      info[a.next].par[0] = cur;
      info[a.next].cost[0] = a.cost;
      dfs(a.next, height + 1);
      if (info[a.next].childcnt > maxV) {
        maxV = info[a.next].childcnt;
        maxnode = a.next;
      }
      cnt += info[a.next].childcnt;
    }
  }
  info[cur].heavyNode = maxnode;
  info[cur].childcnt = cnt;
  return;
}
void processLca(int n) {
  for (int i = 1; i < 23; i++)
    for (int j = 1; j <= n; j++) {
      info[j].par[i] = info[info[j].par[i - 1]].par[i - 1];
      info[j].cost[i] =
          max(info[info[j].par[i - 1]].cost[i - 1], info[j].cost[i - 1]);
    }
}
vector<int> seg;
vector<int> lazy;
void lazy_update(int idx, int s, int e) {
  if (lazy[idx] == (1987654321)) return;
  if (lazy[idx] < seg[idx]) {
    seg[idx] = lazy[idx];
    lazy[idx] = (1987654321);
    if (s != e) {
      lazy[idx * 2] = min(lazy[idx * 2], seg[idx]);
      lazy[idx * 2 + 1] = min(lazy[idx * 2 + 1], seg[idx]);
    }
  }
  return;
}
void seg_update(int idx, int s, int e, int l, int r, int val) {
  lazy_update(idx, s, e);
  if (e < l || s > r) return;
  if (l <= s && e <= r) {
    seg[idx] = min(seg[idx], val);
    if (s != e) {
      lazy[idx * 2] = min(lazy[idx * 2], val);
      lazy[idx * 2 + 1] = min(lazy[idx * 2 + 1], val);
    }
    return;
  }
  int mid = (s + e) / 2;
  seg_update(idx * 2, s, mid, l, r, val);
  seg_update(idx * 2 + 1, mid + 1, e, l, r, val);
  return;
}
int seg_min(int idx, int s, int e, int l, int r) {
  lazy_update(idx, s, e);
  if (e < l || s > r) return (1987654321);
  if (l <= s && e <= r) return seg[idx];
  int mid = (s + e) >> 1;
  int a = seg_min(idx * 2, s, mid, l, r);
  int b = seg_min(idx * 2 + 1, mid + 1, e, l, r);
  return min(a, b);
}
int chainCnt = 1;
int segcnt = 1;
int NodeNum[200001];
void HLD(int cur) {
  NodeNum[segcnt] = cur;
  info[cur].segNum = segcnt++;
  info[cur].chainNum = chainCnt;
  if (info[cur].heavyNode != 0) {
    visited[info[cur].heavyNode] = true;
    HLD(info[cur].heavyNode);
  }
  for (auto& a : adj[cur]) {
    if (!visited[a.next]) {
      visited[a.next] = true;
      chainCnt++;
      chainHead[chainCnt] = a.next;
      HLD(a.next);
    }
  }
  return;
}
int getLca(int a, int b) {
  int ha = info[a].height;
  int hb = info[b].height;
  if (ha != hb) {
    int cha;
    if (ha > hb) {
      swap(hb, ha);
      swap(a, b);
    }
    cha = hb - ha;
    for (int i = 22; i >= 0; i--) {
      if (cha & (1 << i)) {
        b = info[b].par[i];
      }
    }
  }
  if (a == b)
    return a;
  else {
    for (int i = 22; i >= 0; i--) {
      if (info[a].par[i] != info[b].par[i])
        a = info[a].par[i], b = info[b].par[i];
    }
  }
  return info[a].par[0];
}
int getMax(int lca, int b) {
  int hlc = info[lca].height;
  int hb = info[b].height;
  int cha = hb - hlc;
  int maxV = 0;
  for (int i = 23; i >= 0; i--) {
    if (cha & (1 << i)) {
      maxV = max(maxV, info[b].cost[i]);
      b = info[b].par[i];
    }
  }
  return maxV;
}
void update(int lca, int b, int v) {
  while (info[lca].chainNum != info[b].chainNum) {
    seg_update(1, 1, n, info[chainHead[info[b].chainNum]].segNum,
               info[b].segNum, v);
    b = info[chainHead[info[b].chainNum]].par[0];
  }
  if (b == lca) return;
  seg_update(1, 1, n, info[lca].segNum + 1, info[b].segNum, v);
}
int getMin(int a) { return seg_min(1, 1, n, info[a].segNum, info[a].segNum); }
ed edL[200001];
int par[200001];
int rr[200001];
bool inMst[200001];
int find(int a) {
  if (par[a] == a) return a;
  return par[a] = find(par[a]);
}
void merge(int a, int b) {
  int pa = find(a);
  int pb = find(b);
  if (rr[pa] > rr[pb]) swap(pa, pb);
  par[pa] = pb;
  if (rr[pa] == rr[pb]) rr[pb]++;
}
void MakeKruscal() {
  for (int i = 0; i < m; i++) {
    if (find(edL[i].u) == find(edL[i].v))
      inMst[edL[i].idx] = false;
    else {
      inMst[edL[i].idx] = true;
      merge(edL[i].u, edL[i].v);
      adj[edL[i].u].push_back(edge(edL[i].v, edL[i].cost));
      adj[edL[i].v].push_back(edge(edL[i].u, edL[i].cost));
    }
  }
}
int ans[200001];
int main(void) {
  scanf("%d %d", &n, &m);
  for (int i = 0, a, b, c; i < m; i++) {
    scanf("%d %d %d", &a, &b, &c);
    edL[i] = ed(a, b, c, i);
  }
  sort(edL, edL + m);
  for (int i = 1; i <= n; i++) par[i] = i;
  MakeKruscal();
  visited[1] = true;
  info[1].height = 1;
  dfs(1, 1);
  processLca(n);
  memset(visited, false, sizeof(visited));
  visited[1] = true;
  chainHead[chainCnt] = 1;
  HLD(1);
  seg.resize(533333, (1987654321));
  lazy.resize(533333, (1987654321));
  for (int i = 0; i < m; i++) {
    if (!inMst[edL[i].idx]) {
      int lc = getLca(edL[i].u, edL[i].v);
      ans[edL[i].idx] = max(getMax(lc, edL[i].u), getMax(lc, edL[i].v));
      update(lc, edL[i].u, edL[i].cost);
      update(lc, edL[i].v, edL[i].cost);
    }
  }
  for (int i = 0; i < m; i++) {
    if (inMst[edL[i].idx]) {
      if (info[edL[i].u].par[0] == edL[i].v)
        ans[edL[i].idx] = getMin(edL[i].u);
      else
        ans[edL[i].idx] = getMin(edL[i].v);
    }
  }
  for (int i = 0; i < m; i++) {
    if (ans[i] == (1987654321))
      printf("-1 ");
    else
      printf("%d ", ans[i] - 1);
  }
  return 0;
}

```


### Prompt

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

Anton likes permutations, especially he likes to permute their elements. Note that a permutation of n elements is a sequence of numbers {a1, a2, ..., an}, in which every number from 1 to n appears exactly once.

One day Anton got a new permutation and started to play with it. He does the following operation q times: he takes two elements of the permutation and swaps these elements. After each operation he asks his friend Vanya, how many inversions there are in the new permutation. The number of inversions in a permutation is the number of distinct pairs (i, j) such that 1 ≤ i < j ≤ n and ai > aj.

Vanya is tired of answering Anton's silly questions. So he asked you to write a program that would answer these questions instead of him.

Initially Anton's permutation was {1, 2, ..., n}, that is ai = i for all i such that 1 ≤ i ≤ n.

Input

The first line of the input contains two integers n and q (1 ≤ n ≤ 200 000, 1 ≤ q ≤ 50 000) — the length of the permutation and the number of operations that Anton does.

Each of the following q lines of the input contains two integers li and ri (1 ≤ li, ri ≤ n) — the indices of elements that Anton swaps during the i-th operation. Note that indices of elements that Anton swaps during the i-th operation can coincide. Elements in the permutation are numbered starting with one.

Output

Output q lines. The i-th line of the output is the number of inversions in the Anton's permutation after the i-th operation.

Examples

Input

5 4
4 5
2 4
2 5
2 2

Output

1
4
3
3

Input

2 1
2 1

Output

1

Input

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

Output

5
6
7
7
10
11
8

Note

Consider the first sample.

After the first Anton's operation the permutation will be {1, 2, 3, 5, 4}. There is only one inversion in it: (4, 5).

After the second Anton's operation the permutation will be {1, 5, 3, 2, 4}. There are four inversions: (2, 3), (2, 4), (2, 5) and (3, 4).

After the third Anton's operation the permutation will be {1, 4, 3, 2, 5}. There are three inversions: (2, 3), (2, 4) and (3, 4).

After the fourth Anton's operation the permutation doesn't change, so there are still three inversions.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, sqn = 447, sqt = 223, a[200069], pst[200069], udn = 0, sq[50069],
             sqb[469];
pair<long long, long long> qq[50069], qs[469];
bitset<200469> vtd;
void sw(long long x, long long y) {
  long long k = vtd[x];
  swap(a[x], a[y]);
  swap(pst[a[x]], pst[a[y]]);
  vtd[x] = vtd[y];
  vtd[y] = k;
}
void ud(long long x, long long w) {
  vtd[x] = vtd[x] + w;
  sqb[x / sqn] += w;
}
long long qr(long long lh, long long rh) {
  long long i, z = 0;
  for (i = lh / sqn; i <= rh / sqn; i++) {
    z += sqb[i];
  }
  for (i = lh / sqn * sqn; i < lh; i++) {
    z -= vtd[i];
  }
  for (i = rh + 1; i < (rh / sqn + 1) * sqn; i++) {
    z -= vtd[i];
  }
  return z;
}
int main() {
  long long t, rr, i, j, r, u, k, l, w, pz, ls, sm, kk, ll;
  scanf("%lld%lld", &n, &t);
  for (i = 1; i <= n; i++) {
    a[i] = i;
    pst[i] = i;
  }
  for (rr = 1; rr <= t; rr++) {
    scanf("%lld%lld", &k, &l);
    if (k > l) {
      swap(k, l);
    }
    udn++;
    qq[rr] = {k, l};
    sw(k, l);
    qs[udn * 2 - 1] = {min(a[k], a[l]), rr};
    qs[udn * 2] = {max(a[k], a[l]), rr};
    if (udn == sqt || rr == t) {
      ls = (rr - 1) / sqt * sqt;
      for (i = rr; i > ls; i--) {
        k = qq[i].first;
        l = qq[i].second;
        sw(k, l);
      }
      sort(qs + 1, qs + udn * 2 + 1);
      for (i = 0; i <= n / sqn; i++) {
        sqb[i] = 0;
      }
      vtd.reset();
      for (j = 1, i = 1; i <= udn * 2; i++) {
        w = qs[i].first;
        pz = qs[i].second;
        k = qq[pz].first;
        l = qq[pz].second;
        for (; j <= w; j++) {
          ud(pst[j], 1);
        }
        sm = qr(k + 1, l - 1);
        for (r = ls + 1; r <= pz; r++) {
          kk = qq[r].first;
          ll = qq[r].second;
          sm -= vtd[kk] * (kk > k && kk < l);
          sm -= vtd[ll] * (ll > k && ll < l);
          sw(kk, ll);
          sm += vtd[kk] * (kk > k && kk < l);
          sm += vtd[ll] * (ll > k && ll < l);
        }
        for (r = pz; r > ls; r--) {
          kk = qq[r].first;
          ll = qq[r].second;
          sw(kk, ll);
        }
        sq[pz] = sm - sq[pz];
      }
      for (i = ls + 1; i <= rr; i++) {
        k = qq[i].first;
        l = qq[i].second;
        sw(k, l);
      }
      udn = 0;
    }
  }
  for (rr = t; rr; rr--) {
    k = qq[rr].first;
    l = qq[rr].second;
    sw(k, l);
  }
  for (rr = 1; rr <= t; rr++) {
    k = qq[rr].first;
    l = qq[rr].second;
    sw(k, l);
    u = ((a[k] > a[l]) * 2 - 1) * (a[k] != a[l]);
    sq[rr] = sq[rr - 1] + (sq[rr] * 2 + 1) * u;
    printf("%lld\n", sq[rr]);
  }
}

```


### Prompt

Generate a Cpp solution to the following problem:

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

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

Input

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

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

Output

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

Examples

Input

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

Output

2 2 3 1 2

Input

3
0 99990000 99970002
99990000 0 99980000
99970002 99980000 0

Output

9999 10000 9998

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int check[101];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long arr[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> arr[i][j];
    }
  }
  arr[0][0] = (long long)sqrt((arr[0][1] * arr[2][0]) / arr[2][1]);
  cout << arr[0][0] << ' ';
  for (int i = 1; i < n; i++) {
    arr[i][i] = arr[i][i - 1] / arr[i - 1][i - 1];
    cout << arr[i][i] << ' ';
  }
}

```


### Prompt

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

Little Chris is very keen on his toy blocks. His teacher, however, wants Chris to solve more problems, so he decided to play a trick on Chris.

There are exactly s blocks in Chris's set, each block has a unique number from 1 to s. Chris's teacher picks a subset of blocks X and keeps it to himself. He will give them back only if Chris can pick such a non-empty subset Y from the remaining blocks, that the equality holds:

<image> "Are you kidding me?", asks Chris.

For example, consider a case where s = 8 and Chris's teacher took the blocks with numbers 1, 4 and 5. One way for Chris to choose a set is to pick the blocks with numbers 3 and 6, see figure. Then the required sums would be equal: (1 - 1) + (4 - 1) + (5 - 1) = (8 - 3) + (8 - 6) = 7.

<image>

However, now Chris has exactly s = 106 blocks. Given the set X of blocks his teacher chooses, help Chris to find the required set Y!

Input

The first line of input contains a single integer n (1 ≤ n ≤ 5·105), the number of blocks in the set X. The next line contains n distinct space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 106), the numbers of the blocks in X.

Note: since the size of the input and output could be very large, don't use slow output techniques in your language. For example, do not use input and output streams (cin, cout) in C++.

Output

In the first line of output print a single integer m (1 ≤ m ≤ 106 - n), the number of blocks in the set Y. In the next line output m distinct space-separated integers y1, y2, ..., ym (1 ≤ yi ≤ 106), such that the required equality holds. The sets X and Y should not intersect, i.e. xi ≠ yj for all i, j (1 ≤ i ≤ n; 1 ≤ j ≤ m). It is guaranteed that at least one solution always exists. If there are multiple solutions, output any of them.

Examples

Input

3
1 4 5

Output

2
999993 1000000

Input

1
1

Output

1
1000000

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  t = 1;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> x(n);
    vector<long long int> sx(1000001, 0);
    for (long long int i = 0; i < n; i++) {
      cin >> x[i];
      sx[x[i]] = 1;
    }
    long long int s = 1e6;
    vector<long long int> a;
    for (long long int i = 0; i < s; i++) {
      if (sx[i + 1] == 0) {
        a.push_back(i + 1);
      }
    }
    vector<long long int> ans;
    vector<long long int> vis(1000001, 0);
    for (long long int i = 0; i < n; i++) {
      if (sx[s + 1 - x[i]] == 0) {
        ans.push_back(s + 1 - x[i]);
        vis[s + 1 - x[i]] = 1;
      }
    }
    vector<long long int> now;
    for (long long int i = 0; i < n; i++) {
      if (sx[a[i]] == 0 && sx[s + 1 - a[i]] == 0) {
        now.push_back(a[i]);
      }
    }
    long long int k = 0;
    for (long long int i = 0; i < n; i++) {
      if (vis[x[i]] == 0 && sx[s + 1 - x[i]] != 0) {
        ans.push_back(now[k]);
        ans.push_back(s + 1 - now[k]);
        vis[s + 1 - x[i]] = 1;
        ++k;
      }
    }
    cout << ans.size() << endl;
    for (long long int i = 0; i < ans.size(); i++) {
      cout << ans[i] << " ";
    }
  }
}

```


### Prompt

Create a solution in cpp for the following problem:

Tonight is brain dinner night and all zombies will gather together to scarf down some delicious brains. The artful Heidi plans to crash the party, incognito, disguised as one of them. Her objective is to get away with at least one brain, so she can analyze the zombies' mindset back home and gain a strategic advantage.

They will be N guests tonight: N - 1 real zombies and a fake one, our Heidi. The living-dead love hierarchies as much as they love brains: each one has a unique rank in the range 1 to N - 1, and Heidi, who still appears slightly different from the others, is attributed the highest rank, N. Tonight there will be a chest with brains on display and every attendee sees how many there are. These will then be split among the attendees according to the following procedure:

The zombie of the highest rank makes a suggestion on who gets how many brains (every brain is an indivisible entity). A vote follows. If at least half of the attendees accept the offer, the brains are shared in the suggested way and the feast begins. But if majority is not reached, then the highest-ranked zombie is killed, and the next zombie in hierarchy has to make a suggestion. If he is killed too, then the third highest-ranked makes one, etc. (It's enough to have exactly half of the votes – in case of a tie, the vote of the highest-ranked alive zombie counts twice, and he will of course vote in favor of his own suggestion in order to stay alive.)

You should know that zombies are very greedy and sly, and they know this too – basically all zombie brains are alike. Consequently, a zombie will never accept an offer which is suboptimal for him. That is, if an offer is not strictly better than a potential later offer, he will vote against it. And make no mistake: while zombies may normally seem rather dull, tonight their intellects are perfect. Each zombie's priorities for tonight are, in descending order:

  1. survive the event (they experienced death already once and know it is no fun),
  2. get as many brains as possible.

Heidi goes first and must make an offer which at least half of the attendees will accept, and which allocates at least one brain for Heidi herself.

What is the smallest number of brains that have to be in the chest for this to be possible?

Input

The only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 109).

Output

Output one integer: the smallest number of brains in the chest which allows Heidi to take one brain home.

Examples

Input

1

Output

1

Input

4

Output

2

Note

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  cout << (a + 1) / 2 << endl;
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Chouti is working on a strange math problem.

There was a sequence of n positive integers x_1, x_2, …, x_n, where n is even. The sequence was very special, namely for every integer t from 1 to n, x_1+x_2+...+x_t is a square of some integer number (that is, a [perfect square](https://en.wikipedia.org/wiki/Square_number)).

Somehow, the numbers with odd indexes turned to be missing, so he is only aware of numbers on even positions, i.e. x_2, x_4, x_6, …, x_n. The task for him is to restore the original sequence. Again, it's your turn to help him.

The problem setter might make mistakes, so there can be no possible sequence at all. If there are several possible sequences, you can output any.

Input

The first line contains an even number n (2 ≤ n ≤ 10^5).

The second line contains n/2 positive integers x_2, x_4, …, x_n (1 ≤ x_i ≤ 2 ⋅ 10^5).

Output

If there are no possible sequence, print "No".

Otherwise, print "Yes" and then n positive integers x_1, x_2, …, x_n (1 ≤ x_i ≤ 10^{13}), where x_2, x_4, …, x_n should be same as in input data. If there are multiple answers, print any.

Note, that the limit for x_i is larger than for input data. It can be proved that in case there is an answer, there must be a possible sequence satisfying 1 ≤ x_i ≤ 10^{13}.

Examples

Input

6
5 11 44

Output

Yes
4 5 16 11 64 44

Input

2
9900

Output

Yes
100 9900

Input

6
314 1592 6535

Output

No

Note

In the first example

  * x_1=4
  * x_1+x_2=9
  * x_1+x_2+x_3=25
  * x_1+x_2+x_3+x_4=36
  * x_1+x_2+x_3+x_4+x_5=100
  * x_1+x_2+x_3+x_4+x_5+x_6=144

All these numbers are perfect squares.

In the second example, x_1=100, x_1+x_2=10000. They are all perfect squares. There're other answers possible. For example, x_1=22500 is another answer.

In the third example, it is possible to show, that no such sequence exists.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
vector<long long> E[maxn], ans;
void init() {
  for (int i = 1; i < maxn; i++) {
    for (int j = i; j < maxn; j += i) E[j].push_back(1ll * i);
  }
}
int main() {
  init();
  int n;
  cin >> n;
  long long now = 0, flag = 0;
  for (int i = 0; i < n / 2; i++) {
    long long x;
    cin >> x;
    if (flag) continue;
    long long cnt = maxn;
    for (int j = 0; j < E[x].size(); j++) {
      long long tmp = x / E[x][j];
      if (tmp % 2 != E[x][j] % 2) continue;
      long long mid = (tmp + E[x][j]) / 2, d = abs(tmp - E[x][j]) / 2;
      if (d <= now) continue;
      cnt = min(cnt, mid);
    }
    if (cnt == maxn)
      flag = 1;
    else {
      ans.push_back(cnt * cnt - x - now * now);
      ans.push_back(x);
      now = cnt;
    }
  }
  if (flag)
    cout << "No\n";
  else {
    cout << "Yes\n";
    for (int i = 0; i < n; i++)
      printf("%lld%c", ans[i], i == n - 1 ? '\n' : ' ');
  }
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

You are given n objects. Each object has two integer properties: val_i — its price — and mask_i. It is guaranteed that the sum of all prices is initially non-zero.

You want to select a positive integer s. All objects will be modified after that. The i-th object will be modified using the following procedure:

  * Consider mask_i and s in binary notation,
  * Compute the [bitwise AND](https://en.wikipedia.org/wiki/Bitwise_operation#AND) of s and mask_i (s  \&  mask_i),
  * If (s  \&  mask_i) contains an odd number of ones, replace the val_i with -val_i. Otherwise do nothing with the i-th object.

You need to find such an integer s that when the modification above is done the sum of all prices changes sign (if it was negative, it should become positive, and vice-versa; it is not allowed for it to become zero). The absolute value of the sum can be arbitrary.

Input

The first line contains a single integer n (1 ≤ n ≤ 3 ⋅ 10^5) — the number of objects.

The i-th of next n lines contains integers val_i and mask_i (-10^9 ≤ val_i ≤ 10^9, 1 ≤ mask_i ≤ 2^{62} - 1) — the price of the object and its mask.

It is guaranteed that the sum of val_i is initially non-zero.

Output

Print an integer s (1 ≤ s ≤ 2^{62} - 1), such that if we modify the objects as described above, the sign of the sum of val_i changes its sign.

If there are multiple such s, print any of them. One can show that there is always at least one valid s.

Examples

Input

5
17 206
-6 117
-2 151
9 93
6 117

Output

64

Input

1
1 1

Output

1

Note

In the first test sample all objects will change their prices except for the object with mask 151.

So their total sum will change its sign: initially 24, after modifications — -28.

In the second test sample the only object will change its price. So the total sum will change its sign.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int kN = 3e5 + 10;
int n;
int val[kN];
long long mask[kN];
int main() {
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 1; i <= n; i++)
    scanf("%d%lld", val + i, mask + i), sum += val[i];
  if (sum < 0) {
    for (int i = 1; i <= n; i++) val[i] = -val[i];
  }
  long long ans = 0;
  for (int j = 0; j < 62; j++) {
    long long tot = 0;
    for (int i = 1; i <= n; i++) {
      if (mask[i] == (1LL << j)) tot += val[i];
    }
    if (tot > 0) {
      ans |= (1LL << j);
      for (int i = 1; i <= n; i++)
        if (mask[i] & (1LL << j)) val[i] = -val[i];
    }
    for (int i = 1; i <= n; i++) {
      if (mask[i] & (1LL << j)) mask[i] ^= (1LL << j);
    }
  }
  printf("%lld\n", ans);
  return 0;
}

```


### Prompt

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

Vasya’s elder brother Petya loves playing computer games. In one of his favourite computer games Petya reached the final level where a fight with the boss take place.

While playing the game Petya found spell scrolls and now he is about to use them. Let’s describe the way fighting goes on this level:

1) The boss has two parameters: max — the initial amount of health and reg — regeneration rate per second.

2) Every scroll also has two parameters: powi — spell power measured in percents — the maximal amount of health counted off the initial one, which allows to use the scroll (i.e. if the boss has more than powi percent of health the scroll cannot be used); and dmgi the damage per second inflicted upon the boss if the scroll is used. As soon as a scroll is used it disappears and another spell is cast upon the boss that inflicts dmgi of damage per second upon him until the end of the game.

During the battle the actions per second are performed in the following order: first the boss gets the damage from all the spells cast upon him, then he regenerates reg of health (at the same time he can’t have more than max of health), then the player may use another scroll (no more than one per second).

The boss is considered to be defeated if at the end of a second he has nonpositive ( ≤ 0) amount of health.

Help Petya to determine whether he can win with the set of scrolls available to him and if he can, determine the minimal number of seconds he needs to do it.

Input

The first line contains three integers N, max and reg (1 ≤ N, max, reg ≤ 1000) –– the amount of scrolls and the parameters of the boss. The next N lines contain two integers powi and dmgi each — the parameters of the i-th scroll (0 ≤ powi ≤ 100, 1 ≤ dmgi ≤ 2000).

Output

In case Petya can’t complete this level, output in the single line NO.

Otherwise, output on the first line YES. On the second line output the minimal time after which the boss can be defeated and the number of used scrolls. In the next lines for each used scroll output space-separated number of seconds passed from the start of the battle to the moment the scroll was used and the number of the scroll. Scrolls are numbered starting from 1 in the input order. The first scroll is considered to be available to be used after 0 seconds.

Output scrolls in the order they were used. It is not allowed to use scrolls after the boss is defeated.

Examples

Input

2 10 3
100 3
99 1

Output

NO

Input

2 100 10
100 11
90 9

Output

YES
19 2
0 1
10 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool solve(int cn);
int main() {
  int sol = 0;
  int N, max, reg;
  if (!(cin >> N >> max >> reg)) return 1;
  vector<pair<int, int> > scrolls;
  stringstream ss;
  int in1, in2;
  for (int i = (0); i < (N); i++) {
    cin >> in1 >> in2;
    scrolls.push_back(pair<int, int>(in1, in2));
  }
  int life = max;
  int dmg = 0;
  int time = 0;
  int used = 0;
  int prevLife = life;
  while (true) {
    prevLife = life;
    life -= dmg;
    life = min(life + reg, max);
    if (life <= 0) {
      break;
    }
    int sel = -1;
    int mx = 0;
    int pc = ceil(((double)life * 100) / max);
    for (int i = (0); i < (N); i++) {
      if (scrolls[i].first >= pc) {
        if (mx < scrolls[i].second) {
          mx = scrolls[i].second;
          sel = i;
        }
      }
    }
    if (life == prevLife && sel == -1) {
      cout << "NO" << endl;
      return 0;
    } else if (sel >= 0) {
      scrolls[sel].first = -100;
      dmg += scrolls[sel].second;
      ss << time << " " << sel + 1 << endl;
      false && cerr << 59 << ": " << time << " " << sel + 1 << endl;
      false && cerr << 60 << ": " << pc << " " << life << endl;
      used++;
    }
    time++;
  }
  string tmp;
  tmp = ss.str();
  cout << "YES" << endl;
  cout << time << " " << used << endl;
  cout << tmp;
  return 0;
}

```


### Prompt

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

Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th square of the i-th row of k-th piece of the board has color ak, i, j; 1 being black and 0 being white.

Now Magnus wants to change color of some squares in such a way that he recolors minimum number of squares and obtained pieces form a valid chessboard. Every square has its color different to each of the neightbouring by side squares in a valid board. Its size should be 2n by 2n. You are allowed to move pieces but not allowed to rotate or flip them.

Input

The first line contains odd integer n (1 ≤ n ≤ 100) — the size of all pieces of the board.

Then 4 segments follow, each describes one piece of the board. Each consists of n lines of n characters; j-th one of i-th line is equal to 1 if the square is black initially and 0 otherwise. Segments are separated by an empty line.

Output

Print one number — minimum number of squares Magnus should recolor to be able to obtain a valid chessboard.

Examples

Input

1
0

0

1

0

Output

1

Input

3
101
010
101

101
000
101

010
101
011

010
101
010

Output

2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int makeq(int a[][101], int b[][101], int n) {
  int i, j, p = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      p += a[i][j] ^ b[i][j];
    }
  }
  return p;
}
int main() {
  int n, i, j, a1[101][101], a2[101][101], a3[101][101], a4[101][101],
      b1[101][101] = {0}, b2[101][101] = {0}, ans, p1, p2, p3, p4, p5, p6;
  char c[105][105];
  cin >> n;
  b1[0][0] = 0;
  b2[0][0] = 1;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (i != 0 && j == 0) {
        b1[i][j] = !b1[i - 1][n - 1];
        b2[i][j] = !b2[i - 1][n - 1];
      } else if (j != 0) {
        b1[i][j] = !b1[i][j - 1];
        b2[i][j] = !b2[i][j - 1];
      }
    }
  }
  for (i = 0; i < n; i++) cin >> c[i];
  for (i = 0; i < n; i++) {
    for (int l = 0; l < n; l++)
      for (j = 0; j < n; j++) a1[l][j] = c[l][j] - '0';
  }
  for (i = 0; i < n; i++) cin >> c[i];
  for (i = 0; i < n; i++) {
    for (int l = 0; l < n; l++)
      for (j = 0; j < n; j++) a2[l][j] = c[l][j] - '0';
  }
  for (i = 0; i < n; i++) cin >> c[i];
  for (i = 0; i < n; i++) {
    for (int l = 0; l < n; l++)
      for (j = 0; j < n; j++) a3[l][j] = c[l][j] - '0';
  }
  for (i = 0; i < n; i++) cin >> c[i];
  for (i = 0; i < n; i++) {
    for (int l = 0; l < n; l++)
      for (j = 0; j < n; j++) a4[l][j] = c[l][j] - '0';
  }
  p1 =
      makeq(a1, b1, n) + makeq(a2, b1, n) + makeq(a3, b2, n) + makeq(a4, b2, n);
  p2 =
      makeq(a1, b1, n) + makeq(a2, b2, n) + makeq(a3, b1, n) + makeq(a4, b2, n);
  p3 =
      makeq(a1, b1, n) + makeq(a2, b2, n) + makeq(a3, b2, n) + makeq(a4, b1, n);
  p4 =
      makeq(a1, b2, n) + makeq(a2, b1, n) + makeq(a3, b1, n) + makeq(a4, b2, n);
  p5 =
      makeq(a1, b2, n) + makeq(a2, b1, n) + makeq(a3, b2, n) + makeq(a4, b1, n);
  p6 =
      makeq(a1, b2, n) + makeq(a2, b2, n) + makeq(a3, b1, n) + makeq(a4, b1, n);
  ans = min(p1, min(p2, min(p3, min(p4, min(p5, p6)))));
  cout << ans;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

A tree is a connected graph without cycles.

Two trees, consisting of n vertices each, are called isomorphic if there exists a permutation p: {1, ..., n} → {1, ..., n} such that the edge (u, v) is present in the first tree if and only if the edge (pu, pv) is present in the second tree.

Vertex of the tree is called internal if its degree is greater than or equal to two.

Count the number of different non-isomorphic trees, consisting of n vertices, such that the degree of each internal vertex is exactly d. Print the answer over the given prime modulo mod.

Input

The single line of the input contains three integers n, d and mod (1 ≤ n ≤ 1000, 2 ≤ d ≤ 10, 108 ≤ mod ≤ 109) — the number of vertices in the tree, the degree of internal vertices and the prime modulo.

Output

Print the number of trees over the modulo mod.

Examples

Input

5 2 433416647

Output

1

Input

10 3 409693891

Output

2

Input

65 4 177545087

Output

910726

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int N, d, mod, inv[12], dp[1009][1009][12];
int pow(int a, int b) {
  int p = 1;
  for (int i = 0; (1 << i) <= b; i++) {
    if (b & (1 << i)) p = (1LL * p * a) % mod;
    a = (1LL * a * a) % mod;
  }
  return p;
}
int main() {
  scanf("%d %d %d", &N, &d, &mod);
  if (N <= 2) {
    printf("1\n");
    return 0;
  }
  for (int i = 0; i <= N; i++) dp[1][i][0] = dp[1][i][d - 1] = 1;
  for (int i = 1; i <= 10; i++) inv[i] = pow(i, mod - 2);
  for (int i = 1; i <= N; i++)
    for (int k = 1; k <= d; k++) {
      if ((i - k - 1) % (d - 1) != 0) continue;
      for (int j = 1; j <= N; j++) {
        dp[i][j][k] = dp[i][j - 1][k];
        if (j > i) continue;
        int val = dp[j][j][d - 1], curr = 1;
        for (int p = 1; p <= k && j * p <= i; p++) {
          curr = (1LL * curr * (val + p - 1)) % mod;
          curr = (1LL * curr * inv[p]) % mod;
          dp[i][j][k] = ((long long)dp[i][j][k] +
                         1LL * curr * dp[i - j * p][j - 1][k - p]) %
                        mod;
        }
      }
    }
  int ans = dp[N][N / 2][d];
  if (N % 2 == 0) {
    ans = dp[N][N / 2 - 1][d];
    int val = dp[N / 2][N / 2][d - 1];
    val = (1LL * val * (val + 1)) % mod;
    val = (1LL * val * inv[2]) % mod;
    ans += val;
    if (ans >= mod) ans -= mod;
  }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

You are given a string s. Each character is either 0 or 1.

You want all 1's in the string to form a contiguous subsegment. For example, if the string is 0, 1, 00111 or 01111100, then all 1's form a contiguous subsegment, and if the string is 0101, 100001 or 11111111111101, then this condition is not met.

You may erase some (possibly none) 0's from the string. What is the minimum number of 0's that you have to erase?

Input

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

Then t lines follow, each representing a test case. Each line contains one string s (1 ≤ |s| ≤ 100); each character of s is either 0 or 1.

Output

Print t integers, where the i-th integer is the answer to the i-th testcase (the minimum number of 0's that you have to erase from s).

Example

Input

3
010011
0
1111000

Output

2
0
0

Note

In the first test case you have to delete the third and forth symbols from string 010011 (it turns into 0111).

### Response

```cpp
#include <bits/stdc++.h>
static long long int INF = 1e9 + 7;
using namespace std;
template <typename T>
bool comp(T a, T b) {
  if (a < b) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int inx = -1, inx2 = -1;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '1' && inx == -1) {
        inx = i;
      }
      if (s[i] == '1') inx2 = i;
    }
    int cnt = 0;
    for (int i = inx; i <= inx2; i++) {
      if (s[i] == '0') cnt++;
    }
    cout << cnt << "\n";
  }
}

```


### Prompt

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

At the first holiday in spring, the town Shortriver traditionally conducts a flower festival. Townsfolk wear traditional wreaths during these festivals. Each wreath contains exactly k flowers.

The work material for the wreaths for all n citizens of Shortriver is cut from the longest flowered liana that grew in the town that year. Liana is a sequence a_1, a_2, ..., a_m, where a_i is an integer that denotes the type of flower at the position i. This year the liana is very long (m ≥ n ⋅ k), and that means every citizen will get a wreath.

Very soon the liana will be inserted into a special cutting machine in order to make work material for wreaths. The machine works in a simple manner: it cuts k flowers from the beginning of the liana, then another k flowers and so on. Each such piece of k flowers is called a workpiece. The machine works until there are less than k flowers on the liana.

Diana has found a weaving schematic for the most beautiful wreath imaginable. In order to weave it, k flowers must contain flowers of types b_1, b_2, ..., b_s, while other can be of any type. If a type appears in this sequence several times, there should be at least that many flowers of that type as the number of occurrences of this flower in the sequence. The order of the flowers in a workpiece does not matter.

Diana has a chance to remove some flowers from the liana before it is inserted into the cutting machine. She can remove flowers from any part of the liana without breaking liana into pieces. If Diana removes too many flowers, it may happen so that some of the citizens do not get a wreath. Could some flowers be removed from the liana so that at least one workpiece would conform to the schematic and machine would still be able to create at least n workpieces?

Input

The first line contains four integers m, k, n and s (1 ≤ n, k, m ≤ 5 ⋅ 10^5, k ⋅ n ≤ m, 1 ≤ s ≤ k): the number of flowers on the liana, the number of flowers in one wreath, the amount of citizens and the length of Diana's flower sequence respectively.

The second line contains m integers a_1, a_2, ..., a_m (1 ≤ a_i ≤ 5 ⋅ 10^5) — types of flowers on the liana.

The third line contains s integers b_1, b_2, ..., b_s (1 ≤ b_i ≤ 5 ⋅ 10^5) — the sequence in Diana's schematic.

Output

If it's impossible to remove some of the flowers so that there would be at least n workpieces and at least one of them fullfills Diana's schematic requirements, output -1.

Otherwise in the first line output one integer d — the number of flowers to be removed by Diana.

In the next line output d different integers — the positions of the flowers to be removed.

If there are multiple answers, print any.

Examples

Input

7 3 2 2
1 2 3 3 2 1 2
2 2

Output

1
4

Input

13 4 3 3
3 2 6 4 1 4 4 7 1 3 3 2 4
4 3 4

Output

-1

Input

13 4 1 3
3 2 6 4 1 4 4 7 1 3 3 2 4
4 3 4

Output

9
1 2 3 4 5 9 11 12 13

Note

In the first example, if you don't remove any flowers, the machine would put out two workpieces with flower types [1, 2, 3] and [3, 2, 1]. Those workpieces don't fit Diana's schematic. But if you remove flower on 4-th place, the machine would output workpieces [1, 2, 3] and [2, 1, 2]. The second workpiece fits Diana's schematic.

In the second example there is no way to remove flowers so that every citizen gets a wreath and Diana gets a workpiece that fits here schematic.

In the third example Diana is the only citizen of the town and that means she can, for example, just remove all flowers except the ones she needs.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long mulMod(long long a, long long b) { return (a * b) % MOD; }
long long fast(long long a, long long b) {
  if (b == 0) return 1;
  long long tmp = fast(a, b / 2);
  tmp = mulMod(tmp, tmp);
  if (b & 1) tmp = mulMod(tmp, a);
  return tmp;
}
const int N = 5e5;
int cnt[N + 5], a[N + 5], b[N + 5];
int n, m, len, s;
int ct;
int mxRemove;
vector<int> ans;
bool solve(int l, int r) {
  ans.clear();
  int now = (l - 1) / len;
  int rem = l - 1 - now * len;
  int remov = 0;
  if (now + (m - max(0, len - (rem + r - l + 1))) / len + 1 < n) return false;
  int st, en, counter = 0;
  if (rem + r - l + 1 >= len) {
    remov = rem + r - l + 1 - len;
    if (remov > mxRemove) return false;
    st = now * len + 1;
    en = r;
    for (int i = st; i <= en; i += 1) {
      if (counter == remov) break;
      if (i >= l) {
        if (cnt[a[i]] == b[a[i]]) continue;
        cnt[a[i]]--;
      }
      counter++;
      ans.push_back(i);
    }
  } else {
  }
  return true;
}
bool findRange() {
  int ctt = 0;
  int l = 1;
  for (int i = 1; i <= m; i += 1) {
    cnt[a[i]]++;
    if (cnt[a[i]] == b[a[i]] && b[a[i]] > 0) {
      ctt++;
    }
    while (ctt == ct && l <= i) {
      if (solve(l, i)) {
        return true;
      }
      if (cnt[a[l]] == b[a[l]] && b[a[l]] > 0) {
        ctt--;
      }
      cnt[a[l]]--;
      l++;
    }
  }
  return false;
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(b, 0, sizeof b);
  cin >> m >> len >> n >> s;
  for (int i = 1; i <= m; i += 1) cin >> a[i];
  int x;
  ct = 0;
  for (int i = 1; i <= s; i += 1) {
    cin >> x;
    if (b[x] == 0) ct++;
    b[x]++;
  }
  mxRemove = m - n * len;
  if (findRange()) {
    cout << (int)ans.size() << endl;
    for (int i = 0; i <= (int)ans.size() - 1; i += 1) {
      if (i > 0) cout << " ";
      cout << ans[i];
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

```


### Prompt

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

As you know, lemmings like jumping. For the next spectacular group jump n lemmings gathered near a high rock with k comfortable ledges on it. The first ledge is situated at the height of h meters, the second one is at the height of 2h meters, and so on (the i-th ledge is at the height of i·h meters). The lemmings are going to jump at sunset, and there's not much time left.

Each lemming is characterized by its climbing speed of vi meters per minute and its weight mi. This means that the i-th lemming can climb to the j-th ledge in <image> minutes.

To make the jump beautiful, heavier lemmings should jump from higher ledges: if a lemming of weight mi jumps from ledge i, and a lemming of weight mj jumps from ledge j (for i < j), then the inequation mi ≤ mj should be fulfilled.

Since there are n lemmings and only k ledges (k ≤ n), the k lemmings that will take part in the jump need to be chosen. The chosen lemmings should be distributed on the ledges from 1 to k, one lemming per ledge. The lemmings are to be arranged in the order of non-decreasing weight with the increasing height of the ledge. In addition, each lemming should have enough time to get to his ledge, that is, the time of his climb should not exceed t minutes. The lemmings climb to their ledges all at the same time and they do not interfere with each other.

Find the way to arrange the lemmings' jump so that time t is minimized.

Input

The first line contains space-separated integers n, k and h (1 ≤ k ≤ n ≤ 105, 1 ≤ h ≤ 104) — the total number of lemmings, the number of ledges and the distance between adjacent ledges.

The second line contains n space-separated integers m1, m2, ..., mn (1 ≤ mi ≤ 109), where mi is the weight of i-th lemming.

The third line contains n space-separated integers v1, v2, ..., vn (1 ≤ vi ≤ 109), where vi is the speed of i-th lemming.

Output

Print k different numbers from 1 to n — the numbers of the lemmings who go to ledges at heights h, 2h, ..., kh, correspondingly, if the jump is organized in an optimal way. If there are multiple ways to select the lemmings, pick any of them.

Examples

Input

5 3 2
1 2 3 2 1
1 2 1 2 10

Output

5 2 4

Input

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

Output

4 3 1

Note

Let's consider the first sample case. The fifth lemming (speed 10) gets to the ledge at height 2 in <image> minutes; the second lemming (speed 2) gets to the ledge at height 4 in 2 minutes; the fourth lemming (speed 2) gets to the ledge at height 6 in 3 minutes. All lemmings manage to occupy their positions in 3 minutes.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Lem {
  int m, v, id;
  bool operator<(Lem b) const { return m < b.m || (m == b.m && v < b.v); }
};
int n, k, h;
Lem a[(100000 + 10)];
bool can(long double t) {
  int j = k;
  for (int i(n - 1), _l(0); i >= _l; --i) {
    if (j > 0 && (long double)j * h / a[i].v - t <= -1e-7) j--;
  }
  return j == 0;
}
void putAns(long double t) {
  int ans[(100000 + 10)];
  int j = k;
  for (int i(n - 1), _l(0); i >= _l; --i) {
    if (j > 0 && (long double)j * h / a[i].v - t <= -1e-7) ans[--j] = a[i].id;
  }
  for (int i(0), _n(k - 1); i < _n; ++i) printf("%d ", ans[i]);
  printf("%d\n", (ans[k - 1]));
}
int main() {
  scanf("%d", &(n)), scanf("%d", &(k)), scanf("%d", &(h));
  for (int i(0), _n(n); i < _n; ++i) scanf("%d", &(a[i].m)), a[i].id = i + 1;
  for (int i(0), _n(n); i < _n; ++i) scanf("%d", &(a[i].v));
  sort(a, a + n);
  long double l = 0, r = 1e10;
  int cnt = 100;
  while (cnt--) {
    long double mid = (l + r) / 2.0;
    if (can(mid))
      r = mid;
    else
      l = mid;
  }
  putAns(r);
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right.

In this table, Vanya chose n rectangles with sides that go along borders of squares (some rectangles probably occur multiple times). After that for each cell of the table he counted the number of rectangles it belongs to and wrote this number into it. Now he wants to find the sum of values in all cells of the table and as the table is too large, he asks you to help him find the result.

Input

The first line contains integer n (1 ≤ n ≤ 100) — the number of rectangles.

Each of the following n lines contains four integers x1, y1, x2, y2 (1 ≤ x1 ≤ x2 ≤ 100, 1 ≤ y1 ≤ y2 ≤ 100), where x1 and y1 are the number of the column and row of the lower left cell and x2 and y2 are the number of the column and row of the upper right cell of a rectangle.

Output

In a single line print the sum of all values in the cells of the table.

Examples

Input

2
1 1 2 3
2 2 3 3

Output

10

Input

2
1 1 3 3
1 1 3 3

Output

18

Note

Note to the first sample test:

Values of the table in the first three rows and columns will be as follows:

121

121

110

So, the sum of values will be equal to 10.

Note to the second sample test:

Values of the table in the first three rows and columns will be as follows:

222

222

222

So, the sum of values will be equal to 18.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, sum, x1, x2, y1, y2;
  scanf("%d", &n);
  sum = 0;
  while (n--) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    sum = sum + abs((x2 - x1 + 1) * (y2 - y1 + 1));
  }
  printf("%d\n", sum);
  return 0;
}

```


### Prompt

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

SmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the target in turns, and SmallR shoots first. The probability of shooting the target each time is <image> for SmallR while <image> for Zanoes. The one who shoots in the target first should be the winner.

Output the probability that SmallR will win the match.

Input

A single line contains four integers <image>.

Output

Print a single real number, the probability that SmallR will win the match.

The answer will be considered correct if the absolute or relative error doesn't exceed 10 - 6.

Examples

Input

1 2 1 2

Output

0.666666666667

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
double a, b, c, d;
int main() {
  scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
  printf("%.8lf", (a / b) / (1 - (1 - (a / b)) * (1 - (c / d))));
}

```


### Prompt

Please formulate a cpp solution to the following problem:

It is a balmy spring afternoon, and Farmer John's n cows are ruminating about link-cut cacti in their stalls. The cows, labeled 1 through n, are arranged so that the i-th cow occupies the i-th stall from the left. However, Elsie, after realizing that she will forever live in the shadows beyond Bessie's limelight, has formed the Mischievous Mess Makers and is plotting to disrupt this beautiful pastoral rhythm. While Farmer John takes his k minute long nap, Elsie and the Mess Makers plan to repeatedly choose two distinct stalls and swap the cows occupying those stalls, making no more than one swap each minute.

Being the meticulous pranksters that they are, the Mischievous Mess Makers would like to know the maximum messiness attainable in the k minutes that they have. We denote as pi the label of the cow in the i-th stall. The messiness of an arrangement of cows is defined as the number of pairs (i, j) such that i < j and pi > pj.

Input

The first line of the input contains two integers n and k (1 ≤ n, k ≤ 100 000) — the number of cows and the length of Farmer John's nap, respectively.

Output

Output a single integer, the maximum messiness that the Mischievous Mess Makers can achieve by performing no more than k swaps.

Examples

Input

5 2

Output

10

Input

1 10

Output

0

Note

In the first sample, the Mischievous Mess Makers can swap the cows in the stalls 1 and 5 during the first minute, then the cows in stalls 2 and 4 during the second minute. This reverses the arrangement of cows, giving us a total messiness of 10.

In the second sample, there is only one cow, so the maximum possible messiness is 0.

### Response

```cpp
#include <bits/stdc++.h>
long long n, k;
int main() {
  std::cin >> n >> k;
  long long ans = 0;
  for (int i = 0; i < k && n >= 2LL; i++) {
    ans += (n - 1LL) + (n - 2LL);
    n -= 2;
  }
  std::cout << ans << std::endl;
}

```


### Prompt

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

Takahashi is playing with N cards.

The i-th card has an integer X_i on it.

Takahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:

* The integers on the two cards are the same.
* The sum of the integers on the two cards is a multiple of M.

Find the maximum number of pairs that can be created.

Note that a card cannot be used in more than one pair.

Constraints

* 2≦N≦10^5
* 1≦M≦10^5
* 1≦X_i≦10^5

Input

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

N M
X_1 X_2 ... X_N

Output

Print the maximum number of pairs that can be created.

Examples

Input

7 5
3 1 4 1 5 9 2

Output

3

Input

15 10
1 5 6 10 11 11 11 20 21 25 25 26 99 99 99

Output

6

### Response

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_printf(x...) cerr << "line " << __LINE__ << " : "; debug_printf_in(x);

template <typename First>
void debug_printf_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_printf_in(First first, Rest... rest){
  cerr << first << " ";
  debug_printf_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };

    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

template <typename CLASS1, typename CLASS2>
bool operator==(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2){
  return hoge1.value == hoge2.value;
};

template <typename CLASS1, typename CLASS2>
bool operator<(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2){
  return hoge1.value < hoge2.value;
};

template <typename CLASS1, typename CLASS2>
bool operator>(const HOGE<CLASS1, CLASS2> &hoge1, const HOGE<CLASS1, CLASS2> &hoge2){
  return hoge1.value > hoge2.value;
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll N, M;
vll X;
vll dp;
vll dp2;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  IN(N,M);
  X.resize(N);
  ll X_max = M;
  REP(i,N){
    IN(X[i]);
    chmax(X_max, X[i]);
  }
  dp.resize(X_max+1, 0);
  REP(i,N){
    dp[X[i]]++;
  }
  dp2.resize(M, 0);
  REP(i,X_max+1){
    if(dp[i]>0){
      dp2[i%M] += dp[i]%2;
    }
  }
  FOR(i,M,X_max+1){
    dp[i%M] += dp[i];
  }

  /*
  printf("\n");
  REP(i,M){
    printf("%lld ", dp[i]);
  }
  printf("\n");
  REP(i,M){
    printf("%lld ", dp2[i]);
  }
  printf("\n");
  */

  ll ans = 0;

  REP(i,M){
    ll j = M-i;
    if(i==0){
      ans += dp[0]/2;
    }else if(i==j){
      ans += dp[i]/2;
      break;
    }else if(i>j){
      break;
    }else{
      ll tmp1 = i;
      ll tmp2 = j;
      if(dp[tmp1]<dp[tmp2]) swap(tmp1, tmp2);
      ans += dp[tmp2];
      ll tmp3 = min(dp[tmp2], dp2[tmp1]);
      //debug_printf(i, j, dp[tmp1], dp[tmp2], dp2[tmp1], tmp3, ans);
      dp[tmp1] -= tmp3;
      dp[tmp2] -= tmp3;
      dp2[tmp1] -= tmp3;
      //debug_printf(i, j, dp[tmp1], dp[tmp2], dp2[tmp1], tmp3, ans);
      if(dp[tmp2]==0){
        //debug_printf(dp[tmp1], dp2[tmp1]);
        ans += (dp[tmp1]-dp2[tmp1])/2;
      }else{
        //debug_printf(dp[tmp1], dp[tmp2]);
        ans += (dp[tmp1] - dp[tmp2])/2;
      }
      //debug_printf(i, j, ans);
    }
    //debug_printf(i, ans);
  }

  OUT(ans);

  return 0;
}
```


### Prompt

Please create a solution in cpp to the following problem:

Lee bought some food for dinner time, but Lee's friends eat dinner in a deadly way. Lee is so scared, he doesn't want to die, at least not before seeing Online IOI 2020...

There are n different types of food and m Lee's best friends. Lee has w_i plates of the i-th type of food and each friend has two different favorite types of food: the i-th friend's favorite types of food are x_i and y_i (x_i ≠ y_i).

Lee will start calling his friends one by one. Whoever is called will go to the kitchen and will try to eat one plate of each of his favorite food types. Each of the friends will go to the kitchen exactly once.

The only problem is the following: if a friend will eat at least one plate of food (in total) then he will be harmless. But if there is nothing left for him to eat (neither x_i nor y_i), he will eat Lee instead ×\\_×.

Lee can choose the order of friends to call, so he'd like to determine if he can survive dinner or not. Also, he'd like to know the order itself.

Input

The first line contains two integers n and m (2 ≤ n ≤ 10^5; 1 ≤ m ≤ 2 ⋅ 10^5) — the number of different food types and the number of Lee's friends.

The second line contains n integers w_1, w_2, …, w_n (0 ≤ w_i ≤ 10^6) — the number of plates of each food type.

The i-th line of the next m lines contains two integers x_i and y_i (1 ≤ x_i, y_i ≤ n; x_i ≠ y_i) — the favorite types of food of the i-th friend.

Output

If Lee can survive the dinner then print ALIVE (case insensitive), otherwise print DEAD (case insensitive).

Also, if he can survive the dinner, print the order Lee should call friends. If there are multiple valid orders, print any of them.

Examples

Input

3 3
1 2 1
1 2
2 3
1 3

Output

ALIVE
3 2 1

Input

3 2
1 1 0
1 2
1 3

Output

ALIVE
2 1

Input

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

Output

ALIVE
1 3 2 4

Input

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

Output

ALIVE
5 4 1 3 2

Input

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

Output

DEAD

Note

In the first example, any of the following orders of friends are correct : [1, 3, 2], [3, 1, 2], [2, 3, 1], [3, 2, 1].

In the second example, Lee should call the second friend first (the friend will eat a plate of food 1) and then call the first friend (the friend will eat a plate of food 2). If he calls the first friend sooner than the second one, then the first friend will eat one plate of food 1 and food 2 and there will be no food left for the second friend to eat.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool vis[200005];
vector<vector<long>> c;
long a[200005], b[200005], d[200005], cap[200005];
vector<long> ans;
void dfs(long idx) {
  if (vis[idx]) return;
  if (d[a[idx]] <= cap[a[idx]] || d[b[idx]] <= cap[b[idx]]) {
    d[a[idx]]--, d[b[idx]]--;
    vis[idx] = true;
    ans.push_back(idx);
    for (long &i : c[a[idx]]) dfs(i);
    for (long &i : c[b[idx]]) dfs(i);
  }
}
int main() {
  long n, m;
  cin >> n >> m;
  c.resize(n);
  for (long i = 0; i < n; i++) cin >> cap[i];
  for (long i = 0; i < m; i++) {
    long f1, f2;
    cin >> f1 >> f2;
    f1--, f2--;
    a[i] = f1, b[i] = f2;
    d[f1]++, d[f2]++;
    c[f1].push_back(i), c[f2].push_back(i);
  }
  memset(vis, false, sizeof(vis));
  for (long i = 0; i < m; i++) dfs(i);
  if ((long)(ans.size()) == m) {
    reverse(ans.begin(), ans.end());
    cout << "ALIVE" << '\n';
    for (long &i : ans) cout << i + 1 << " ";
  } else
    cout << "DEAD";
}

```


### Prompt

Generate a Cpp solution to the following problem:

An elementary school student Takahashi has come to a variety store.

He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?

Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.

Constraints

* All input values are integers.
* 1 \leq A, B \leq 500
* 1 \leq C \leq 1000

Input

Input is given from Standard Input in the following format:

A B C

Output

If Takahashi can buy the toy, print `Yes`; if he cannot, print `No`.

Examples

Input

50 100 120

Output

Yes

Input

500 100 1000

Output

No

Input

19 123 143

Output

No

Input

19 123 142

Output

Yes

### Response

```cpp
#include <iostream>

using namespace std;

int main(){
  int A,B,C; cin>>A>>B>>C;

  cout<<((A+B)>=C?"Yes":"No")<<endl;

  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

You are given an undirected connected weighted graph consisting of n vertices and m edges. Let's denote the length of the shortest path from vertex 1 to vertex i as d_i.

You have to erase some edges of the graph so that at most k edges remain. Let's call a vertex i good if there still exists a path from 1 to i with length d_i after erasing the edges.

Your goal is to erase the edges in such a way that the number of good vertices is maximized.

Input

The first line contains three integers n, m and k (2 ≤ n ≤ 3 ⋅ 10^5, 1 ≤ m ≤ 3 ⋅ 10^5, n - 1 ≤ m, 0 ≤ k ≤ m) — the number of vertices and edges in the graph, and the maximum number of edges that can be retained in the graph, respectively.

Then m lines follow, each containing three integers x, y, w (1 ≤ x, y ≤ n, x ≠ y, 1 ≤ w ≤ 10^9), denoting an edge connecting vertices x and y and having weight w.

The given graph is connected (any vertex can be reached from any other vertex) and simple (there are no self-loops, and for each unordered pair of vertices there exists at most one edge connecting these vertices).

Output

In the first line print e — the number of edges that should remain in the graph (0 ≤ e ≤ k).

In the second line print e distinct integers from 1 to m — the indices of edges that should remain in the graph. Edges are numbered in the same order they are given in the input. The number of good vertices should be as large as possible.

Examples

Input

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

Output

2
1 2

Input

4 5 2
4 1 8
2 4 1
2 1 3
3 4 9
3 1 5

Output

2
3 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to;
  long long cost;
  int num;
};
struct Node {
  long long dis;
  int id, num;
  bool operator<(const Node& p) const { return dis > p.dis; }
};
int V;
const long long INF = 1e18;
const int MAXV = 3e5 + 100;
vector<edge> G[MAXV];
long long d[MAXV];
int ans[MAXV];
int cnt = 0;
priority_queue<Node> que;
int k;
void dijkstra(int s) {
  for (int i = 0; i < MAXV; i++) {
    d[i] = INF;
  }
  d[s] = 0;
  que.push((Node){0, s, 0});
  while (!que.empty() && k >= 0) {
    Node p = que.top();
    que.pop();
    int v = p.id;
    if (d[v] < p.dis) continue;
    k--;
    ans[cnt++] = p.num;
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push((Node){d[e.to], e.to, e.num});
      }
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    int a, b;
    long long c;
    scanf("%d%d%lld", &a, &b, &c);
    G[a].push_back((edge){b, c, i});
    G[b].push_back((edge){a, c, i});
  }
  dijkstra(1);
  printf("%d\n", cnt - 1);
  for (int i = 1; i < cnt; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}

```


### Prompt

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

Once little Vasya read an article in a magazine on how to make beautiful handmade garland from colored paper. Vasya immediately went to the store and bought n colored sheets of paper, the area of each sheet is 1 square meter.

The garland must consist of exactly m pieces of colored paper of arbitrary area, each piece should be of a certain color. To make the garland, Vasya can arbitrarily cut his existing colored sheets into pieces. Vasya is not obliged to use all the sheets to make the garland.

Vasya wants the garland to be as attractive as possible, so he wants to maximize the total area of m pieces of paper in the garland. Calculate what the maximum total area of the pieces of paper in the garland Vasya can get.

Input

The first line contains a non-empty sequence of n (1 ≤ n ≤ 1000) small English letters ("a"..."z"). Each letter means that Vasya has a sheet of paper of the corresponding color.

The second line contains a non-empty sequence of m (1 ≤ m ≤ 1000) small English letters that correspond to the colors of the pieces of paper in the garland that Vasya wants to make.

Output

Print an integer that is the maximum possible total area of the pieces of paper in the garland Vasya wants to get or -1, if it is impossible to make the garland from the sheets he's got. It is guaranteed that the answer is always an integer.

Examples

Input

aaabbac
aabbccac

Output

6

Input

a
z

Output

-1

Note

In the first test sample Vasya can make an garland of area 6: he can use both sheets of color b, three (but not four) sheets of color a and cut a single sheet of color c in three, for example, equal pieces. Vasya can use the resulting pieces to make a garland of area 6.

In the second test sample Vasya cannot make a garland at all — he doesn't have a sheet of color z.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
char x[1005];
char y[1005];
int a[1005], b[1005];
int main() {
  while (scanf("%s%s", x, y) != EOF) {
    int l1 = strlen(x);
    int l2 = strlen(y);
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for (int i = 0; i < l1; i++) {
      a[x[i] - 'a']++;
    }
    for (int i = 0; i < l2; i++) {
      b[y[i] - 'a']++;
    }
    int sum = 0, flag = 0;
    for (int i = 0; i < 26; i++) {
      if (a[i] == 0 && b[i] != 0) {
        flag = 1;
        printf("-1\n");
        break;
      }
      if (a[i] != 0 && b[i] != 0) {
        if (a[i] < b[i])
          sum += a[i];
        else
          sum += b[i];
      }
    }
    if (flag == 0) printf("%d\n", sum);
  }
}

```


### Prompt

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

You are given a string s of length n, which consists only of the first k letters of the Latin alphabet. All letters in string s are uppercase.

A subsequence of string s is a string that can be derived from s by deleting some of its symbols without changing the order of the remaining symbols. For example, "ADE" and "BD" are subsequences of "ABCDE", but "DEA" is not.

A subsequence of s called good if the number of occurences of each of the first k letters of the alphabet is the same.

Find the length of the longest good subsequence of s.

Input

The first line of the input contains integers n (1≤ n ≤ 10^5) and k (1 ≤ k ≤ 26).

The second line of the input contains the string s of length n. String s only contains uppercase letters from 'A' to the k-th letter of Latin alphabet.

Output

Print the only integer — the length of the longest good subsequence of string s.

Examples

Input

9 3
ACAABCCAB

Output

6

Input

9 4
ABCABCABC

Output

0

Note

In the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.

In the second example, none of the subsequences can have 'D', hence the answer is 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
  int long long n, k, c = 0;
  cin >> n >> k;
  string s;
  cin >> s;
  int long long a[26] = {0};
  for (int i = 0; i < n; ++i) a[s[i] - 'A']++;
  c = a[0];
  for (int long long i = 1; i < k; ++i) {
    if (c > a[i]) {
      c = a[i];
    }
  }
  cout << c * k << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.

As for you, you're just a simple peasant. There's no surprise that you slept in this morning and were late for the tournament (it was a weekend, after all). Now you are really curious about the results of the tournament. This time the tournament in Berland went as follows:

  * There are n knights participating in the tournament. Each knight was assigned his unique number — an integer from 1 to n.
  * The tournament consisted of m fights, in the i-th fight the knights that were still in the game with numbers at least li and at most ri have fought for the right to continue taking part in the tournament.
  * After the i-th fight among all participants of the fight only one knight won — the knight number xi, he continued participating in the tournament. Other knights left the tournament.
  * The winner of the last (the m-th) fight (the knight number xm) became the winner of the tournament.

You fished out all the information about the fights from your friends. Now for each knight you want to know the name of the knight he was conquered by. We think that the knight number b was conquered by the knight number a, if there was a fight with both of these knights present and the winner was the knight number a.

Write the code that calculates for each knight, the name of the knight that beat him.

Input

The first line contains two integers n, m (2 ≤ n ≤ 3·105; 1 ≤ m ≤ 3·105) — the number of knights and the number of fights. Each of the following m lines contains three integers li, ri, xi (1 ≤ li < ri ≤ n; li ≤ xi ≤ ri) — the description of the i-th fight.

It is guaranteed that the input is correct and matches the problem statement. It is guaranteed that at least two knights took part in each battle.

Output

Print n integers. If the i-th knight lost, then the i-th number should equal the number of the knight that beat the knight number i. If the i-th knight is the winner, then the i-th number must equal 0.

Examples

Input

4 3
1 2 1
1 3 3
1 4 4

Output

3 1 4 0

Input

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

Output

0 8 4 6 4 8 6 1

Note

Consider the first test case. Knights 1 and 2 fought the first fight and knight 1 won. Knights 1 and 3 fought the second fight and knight 3 won. The last fight was between knights 3 and 4, knight 4 won.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int NMax = 300010;
const int INF = int(1e9);
const int cntTree = 262145;
const double eps = 1e-9;
const double PI = 3.141592653589793238462;
const int MOD = int(1e9 + 7);
int n, m;
int t[3000000], l[NMax], r[NMax], x[NMax];
void push(int v) {
  if (t[v] != -1) {
    t[2 * v] = t[2 * v + 1] = t[v];
    t[v] = -1;
  }
}
void update(int v, int tl, int tr, int l, int r, int NEW) {
  if (l > r) return;
  if (l == tl && r == tr) {
    t[v] = NEW;
    return;
  }
  push(v);
  int tm = (tl + tr) / 2;
  update(v * 2, tl, tm, l, ((r) > (tm) ? (tm) : (r)), NEW);
  update(v * 2 + 1, tm + 1, tr, ((l) > (tm + 1) ? (l) : (tm + 1)), r, NEW);
}
void get(int v, int tl, int tr, int pos, int &color) {
  if (tr == tl) {
    color = t[v];
    return;
  }
  push(v);
  int tm = (tl + tr) / 2;
  if (pos <= tm)
    get(v * 2, tl, tm, pos, color);
  else
    get(v * 2 + 1, tm + 1, tr, pos, color);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= int(2e6); i++) t[i] = -1;
  for (int i = 1; i <= m; i++) scanf("%i%i%i", &l[i], &r[i], &x[i]);
  for (int i = m; i > 0; i--) {
    if (l[i] == x[i])
      update(1, 1, n, l[i] + 1, r[i], x[i]);
    else if (r[i] == x[i])
      update(1, 1, n, l[i], r[i] - 1, x[i]);
    else {
      update(1, 1, n, l[i], x[i] - 1, x[i]);
      update(1, 1, n, x[i] + 1, r[i], x[i]);
    }
  }
  for (int i = 1; i <= n; i++) {
    int color = -1;
    get(1, 1, n, i, color);
    if (color == -1) color = 0;
    printf("%i ", color);
  }
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

We define x mod y as the remainder of division of x by y (\% operator in C++ or Java, mod operator in Pascal).

Let's call an array of positive integers [a_1, a_2, ..., a_k] stable if for every permutation p of integers from 1 to k, and for every non-negative integer x, the following condition is met:

 (((x mod a_1) mod a_2) ... mod a_{k - 1}) mod a_k = (((x mod a_{p_1}) mod a_{p_2}) ... mod a_{p_{k - 1}}) mod a_{p_k}

That is, for each non-negative integer x, the value of (((x mod a_1) mod a_2) ... mod a_{k - 1}) mod a_k does not change if we reorder the elements of the array a.

For two given integers n and k, calculate the number of stable arrays [a_1, a_2, ..., a_k] such that 1 ≤ a_1 < a_2 < ... < a_k ≤ n.

Input

The only line contains two integers n and k (1 ≤ n, k ≤ 5 ⋅ 10^5).

Output

Print one integer — the number of stable arrays [a_1, a_2, ..., a_k] such that 1 ≤ a_1 < a_2 < ... < a_k ≤ n. Since the answer may be large, print it modulo 998244353.

Examples

Input

7 3

Output

16

Input

3 7

Output

0

Input

1337 42

Output

95147305

Input

1 1

Output

1

Input

500000 1

Output

500000

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MAXI = 500000;
const long long pr = 998244353;
vector<unsigned long long> f(MAXI, 1), p(MAXI, 0);
unsigned long long moc(unsigned long long a, unsigned long long b,
                       unsigned long long c) {
  if (b == 0) return 1;
  unsigned long long pol = moc(a, b / 2, c);
  pol *= pol;
  pol %= c;
  if (b % 2 == 1) {
    pol *= a;
  }
  return pol % c;
}
unsigned long long invp(unsigned long long a) { return moc(a, pr - 2, pr); }
unsigned long long n_nad_k(long long n, long long k) {
  if (n < k) return 0;
  if (n / 2 < k) k = n - k;
  if (k == 0) return 1;
  if (k < 0) return 0;
  if (pr <= n) {
    unsigned long long dol = invp(f[k]) * invp(f[n - k]);
    unsigned long long ci = dol, cp = pr, cn = 0;
    while (cp < n) {
      cn += k / cp + ((n - k) / cp);
      cp *= pr;
    }
    if (cn != p[n]) return 0;
  }
  unsigned long long vys =
      ((((f[n] * invp(f[k])) % pr) * invp(f[n - k])) % pr) % pr;
  return vys;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (unsigned long long i = 1; i < MAXI; i++) {
    p[i] = p[i - 1];
    unsigned long long ci = i;
    unsigned long long cp = pr;
    while (ci % cp == 0) {
      cp *= pr;
      p[i]++;
    }
    f[i] = (f[i - 1] * (i / (cp / pr))) % pr;
  }
  long long n, k;
  cin >> n >> k;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long d = (n / i - 1);
    ans += n_nad_k(d, k - 1);
    ans %= pr;
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

At the beginning of the school year Berland State University starts two city school programming groups, for beginners and for intermediate coders. The children were tested in order to sort them into groups. According to the results, each student got some score from 1 to m points. We know that c1 schoolchildren got 1 point, c2 children got 2 points, ..., cm children got m points. Now you need to set the passing rate k (integer from 1 to m): all schoolchildren who got less than k points go to the beginner group and those who get at strictly least k points go to the intermediate group. We know that if the size of a group is more than y, then the university won't find a room for them. We also know that if a group has less than x schoolchildren, then it is too small and there's no point in having classes with it. So, you need to split all schoolchildren into two groups so that the size of each group was from x to y, inclusive.

Help the university pick the passing rate in a way that meets these requirements.

Input

The first line contains integer m (2 ≤ m ≤ 100). The second line contains m integers c1, c2, ..., cm, separated by single spaces (0 ≤ ci ≤ 100). The third line contains two space-separated integers x and y (1 ≤ x ≤ y ≤ 10000). At least one ci is greater than 0.

Output

If it is impossible to pick a passing rate in a way that makes the size of each resulting groups at least x and at most y, print 0. Otherwise, print an integer from 1 to m — the passing rate you'd like to suggest. If there are multiple possible answers, print any of them.

Examples

Input

5
3 4 3 2 1
6 8

Output

3

Input

5
0 3 3 4 2
3 10

Output

4

Input

2
2 5
3 6

Output

0

Note

In the first sample the beginner group has 7 students, the intermediate group has 6 of them.

In the second sample another correct answer is 3.

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  int n, i, j = 0, k = -1, s = 0, x, y;
  scanf("%d", &n);
  int arr[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    s += arr[i];
  }
  scanf("%d %d", &x, &y);
  for (i = 0; i < n; i++) {
    j += arr[i];
    if (j >= x && j <= y && s - j >= x && s - j <= y) {
      printf("%d\n", i + 2);
      return 0;
    }
  }
  printf("0\n");
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

There are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1).

You're given k subsets A_1, …, A_k of \{1, 2, ..., n\}, such that the intersection of any three subsets is empty. In other words, for all 1 ≤ i_1 < i_2 < i_3 ≤ k, A_{i_1} ∩ A_{i_2} ∩ A_{i_3} = ∅.

In one operation, you can choose one of these k subsets and switch the state of all lamps in it. It is guaranteed that, with the given subsets, it's possible to make all lamps be simultaneously on using this type of operation.

Let m_i be the minimum number of operations you have to do in order to make the i first lamps be simultaneously on. Note that there is no condition upon the state of other lamps (between i+1 and n), they can be either off or on.

You have to compute m_i for all 1 ≤ i ≤ n.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 3 ⋅ 10^5).

The second line contains a binary string of length n, representing the initial state of each lamp (the lamp i is off if s_i = 0, on if s_i = 1).

The description of each one of the k subsets follows, in the following format:

The first line of the description contains a single integer c (1 ≤ c ≤ n) — the number of elements in the subset.

The second line of the description contains c distinct integers x_1, …, x_c (1 ≤ x_i ≤ n) — the elements of the subset.

It is guaranteed that:

  * The intersection of any three subsets is empty;
  * It's possible to make all lamps be simultaneously on using some operations.

Output

You must output n lines. The i-th line should contain a single integer m_i — the minimum number of operations required to make the lamps 1 to i be simultaneously on.

Examples

Input

7 3
0011100
3
1 4 6
3
3 4 7
2
2 3

Output

1
2
3
3
3
3
3

Input

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

Output

1
1
1
1
1
1
4
4

Input

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

Output

1
1
1
1
1

Input

19 5
1001001001100000110
2
2 3
2
5 6
2
8 9
5
12 13 14 15 16
1
19

Output

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

Note

In the first example:

  * For i = 1, we can just apply one operation on A_1, the final states will be 1010110;
  * For i = 2, we can apply operations on A_1 and A_3, the final states will be 1100110;
  * For i ≥ 3, we can apply operations on A_1, A_2 and A_3, the final states will be 1111111.

In the second example:

  * For i ≤ 6, we can just apply one operation on A_2, the final states will be 11111101;
  * For i ≥ 7, we can apply operations on A_1, A_3, A_4, A_6, the final states will be 11111111.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6 + 100;
const int mod = (int)1e9 + 7;
int n, k, fa[maxn], tot[maxn], ans;
char s[maxn];
vector<int> v[maxn];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
void join(int x, int y) {
  x = find(x);
  y = find(y);
  if (x != y) fa[x] = y, tot[y] += tot[x];
}
int get(int x) { return min(tot[find(x)], tot[find(x + k)]); }
int main() {
  scanf("%d%d%s", &n, &k, s + 1);
  for (int i = (1); i <= (k); ++i) {
    int x, c;
    scanf("%d", &c);
    while (c--) scanf("%d", &x), v[x].push_back(i);
  }
  for (int i = (1); i <= (2 * k + 1); ++i) fa[i] = i, tot[i] = (i <= k);
  tot[2 * k + 1] = mod;
  for (int i = (1); i <= (n); ++i) {
    if (v[i].size() == 1) {
      int tmp = v[i][0] + (s[i] == '0') * k;
      ans -= get(v[i][0]);
      join(tmp, 2 * k + 1);
      ans += get(v[i][0]);
    }
    if (v[i].size() == 2) {
      int x = v[i][0], y = v[i][1];
      if (s[i] == '1' && find(x) != find(y)) {
        ans -= (get(x) + get(y));
        join(x, y);
        join(x + k, y + k);
        ans += get(x);
      }
      if (s[i] == '0' && find(x) != find(y + k)) {
        ans -= (get(x) + get(y));
        join(x, y + k);
        join(x + k, y);
        ans += get(x);
      }
    }
    printf("%d\n", ans);
  }
}

```


### Prompt

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

Princess Heidi decided to give orders to all her K Rebel ship commanders in person. Unfortunately, she is currently travelling through hyperspace, and will leave it only at N specific moments t1, t2, ..., tN. The meetings with commanders must therefore start and stop at those times. Namely, each commander will board her ship at some time ti and disembark at some later time tj. Of course, Heidi needs to meet with all commanders, and no two meetings can be held during the same time. Two commanders cannot even meet at the beginnings/endings of the hyperspace jumps, because too many ships in one position could give out their coordinates to the enemy.

Your task is to find minimum time that Princess Heidi has to spend on meetings, with her schedule satisfying the conditions above.

Input

The first line contains two integers K, N (2 ≤ 2K ≤ N ≤ 500000, K ≤ 5000). The second line contains N distinct integers t1, t2, ..., tN (1 ≤ ti ≤ 109) representing the times when Heidi leaves hyperspace.

Output

Output only one integer: the minimum time spent on meetings.

Examples

Input

2 5
1 4 6 7 12

Output

4

Input

3 6
6 3 4 2 5 1

Output

3

Input

4 12
15 7 4 19 3 30 14 1 5 23 17 25

Output

6

Note

In the first example, there are five valid schedules: [1, 4], [6, 7] with total time 4, [1, 4], [6, 12] with total time 9, [1, 4], [7, 12] with total time 8, [1, 6], [7, 12] with total time 10, and [4, 6], [7, 12] with total time 7. So the answer is 4.

In the second example, there is only 1 valid schedule: [1, 2], [3, 4], [5, 6].

For the third example, one possible schedule with total time 6 is: [1, 3], [4, 5], [14, 15], [23, 25].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500500, MAXK = 5005;
const int INF = 1e9 + 50;
int rng(pair<int, int> a) { return a.second - a.first; }
bool comp(pair<int, int> a, pair<int, int> b) { return rng(a) < rng(b); }
bool collide(pair<int, int> a, pair<int, int> b) {
  return a.second == b.first || a.first == b.second;
}
int n, k, T[MAXN];
vector<pair<int, int> > S;
int dp[2 * MAXK][MAXK];
int solve(int p, int rem) {
  if (rem == 0) return 0;
  if (p >= n) return INF;
  int &ret = dp[p][rem];
  if (ret != -1) return ret;
  int skip = solve(p + 1, rem);
  int keep = rng(S[p]) + ((p < n - 1 && !collide(S[p], S[p + 1]))
                              ? solve(p + 1, rem - 1)
                              : solve(p + 2, rem - 1));
  return ret = min(skip, keep);
}
int main() {
  while (scanf("%d %d", &k, &n) >= 1) {
    for (int i = (0); i < (int)(n); i++) scanf("%d", &T[i]);
    sort(T, T + n);
    S.clear();
    for (int i = (0); i < (int)(n - 1); i++) S.push_back({T[i], T[i + 1]});
    sort(S.begin(), S.end(), comp);
    S.resize(min(2 * k + 5, n - 1));
    sort(S.begin(), S.end());
    n = ((int)S.size());
    for (int i = (0); i < (int)(2 * MAXK); i++)
      for (int j = (0); j < (int)(MAXK); j++) dp[i][j] = -1;
    printf("%d\n", solve(0, k));
  }
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

Sasha likes programming. Once, during a very long contest, Sasha decided that he was a bit tired and needed to relax. So he did. But since Sasha isn't an ordinary guy, he prefers to relax unusually. During leisure time Sasha likes to upsolve unsolved problems because upsolving is very useful.

Therefore, Sasha decided to upsolve the following problem:

You have an array a with n integers. You need to count the number of funny pairs (l, r) (l ≤ r). To check if a pair (l, r) is a funny pair, take mid = (l + r - 1)/(2), then if r - l + 1 is an even number and a_l ⊕ a_{l+1} ⊕ … ⊕ a_{mid} = a_{mid + 1} ⊕ a_{mid + 2} ⊕ … ⊕ a_r, then the pair is funny. In other words, ⊕ of elements of the left half of the subarray from l to r should be equal to ⊕ of elements of the right half. Note that ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).

It is time to continue solving the contest, so Sasha asked you to solve this task.

Input

The first line contains one integer n (2 ≤ n ≤ 3 ⋅ 10^5) — the size of the array.

The second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i < 2^{20}) — array itself.

Output

Print one integer — the number of funny pairs. You should consider only pairs where r - l + 1 is even number.

Examples

Input

5
1 2 3 4 5

Output

1

Input

6
3 2 2 3 7 6

Output

3

Input

3
42 4 2

Output

0

Note

Be as cool as Sasha, upsolve problems!

In the first example, the only funny pair is (2, 5), as 2 ⊕ 3 = 4 ⊕ 5 = 1.

In the second example, funny pairs are (2, 3), (1, 4), and (3, 6).

In the third example, there are no funny pairs.

### Response

```cpp
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:5000000000")
const long long mod = 1000000007;
long long Inf = (long long)2e9;
long long LINF = (long long)1e18 + 1e17;
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  map<pair<int, int>, long long> cnt;
  long long ans = 0;
  int cur_xor = 0;
  int n;
  cin >> n;
  cnt[{1, 0}] = 1;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    cur_xor = (cur_xor ^ a);
    ans += cnt[{i % 2, cur_xor}];
    cnt[{i % 2, cur_xor}]++;
  }
  cout << ans;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Petya loves hockey very much. One day, as he was watching a hockey match, he fell asleep. Petya dreamt of being appointed to change a hockey team's name. Thus, Petya was given the original team name w and the collection of forbidden substrings s1, s2, ..., sn. All those strings consist of uppercase and lowercase Latin letters. String w has the length of |w|, its characters are numbered from 1 to |w|.

First Petya should find all the occurrences of forbidden substrings in the w string. During the search of substrings the case of letter shouldn't be taken into consideration. That is, strings "aBC" and "ABc" are considered equal.

After that Petya should perform the replacement of all letters covered by the occurrences. More formally: a letter in the position i should be replaced by any other one if for position i in string w there exist pair of indices l, r (1 ≤ l ≤ i ≤ r ≤ |w|) such that substring w[l ... r] is contained in the collection s1, s2, ..., sn, when using case insensitive comparison. During the replacement the letter's case should remain the same. Petya is not allowed to replace the letters that aren't covered by any forbidden substring.

Letter letter (uppercase or lowercase) is considered lucky for the hockey players. That's why Petya should perform the changes so that the letter occurred in the resulting string as many times as possible. Help Petya to find such resulting string. If there are several such strings, find the one that comes first lexicographically.

Note that the process of replacements is not repeated, it occurs only once. That is, if after Petya's replacements the string started to contain new occurrences of bad substrings, Petya pays no attention to them.

Input

The first line contains the only integer n (1 ≤ n ≤ 100) — the number of forbidden substrings in the collection. Next n lines contain these substrings. The next line contains string w. All those n + 1 lines are non-empty strings consisting of uppercase and lowercase Latin letters whose length does not exceed 100. The last line contains a lowercase letter letter.

Output

Output the only line — Petya's resulting string with the maximum number of letters letter. If there are several answers then output the one that comes first lexicographically.

The lexicographical comparison is performed by the standard < operator in modern programming languages. The line a is lexicographically smaller than the line b, if a is a prefix of b, or there exists such an i (1 ≤ i ≤ |a|), that ai < bi, and for any j (1 ≤ j < i) aj = bj. |a| stands for the length of string a.

Examples

Input

3
bers
ucky
elu
PetrLoveLuckyNumbers
t

Output

PetrLovtTttttNumtttt

Input

4
hello
party
abefglghjdhfgj
IVan
petrsmatchwin
a

Output

petrsmatchwin

Input

2
aCa
cba
abAcaba
c

Output

abCacba

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string s[105];
int mark[105];
int is_lower[105];
char lower(char &now) {
  if (now >= 'A' && now <= 'Z') now = now - 'A' + 'a';
  return now;
}
char upper(char &now) {
  if (now >= 'a' && now <= 'z') now = now - 'a' + 'A';
  return now;
}
int main() {
  int n;
  cin >> n;
  int i, j;
  for (i = 1; i <= n; i++) {
    cin >> s[i];
    for (j = 0; j < s[i].size(); j++) {
      s[i][j] = lower(s[i][j]);
    }
  }
  string ts;
  cin >> ts;
  char l;
  cin >> l;
  string st = ts;
  for (i = 0; i < st.size(); i++) {
    is_lower[i] = (st[i] >= 'a' && st[i] <= 'z');
    st[i] = lower(st[i]);
  }
  memset(mark, 0, sizeof(mark));
  for (i = 0; i < st.size(); i++)
    for (j = 1; j <= n; j++)
      if (st.size() - i >= s[j].size())
        if (st.substr(i, s[j].size()) == s[j])
          for (int k = 0; k < s[j].size(); k++) mark[i + k] = 1;
  for (i = 0; i < ts.size(); i++) {
    if (mark[i]) {
      if (lower(ts[i]) == lower(l)) {
        if (lower(l) == 'a') {
          ts[i] = is_lower[i] ? 'b' : 'B';
        } else {
          ts[i] = is_lower[i] ? 'a' : 'A';
        }
      } else {
        ts[i] = is_lower[i] ? lower(l) : upper(l);
      }
    }
  }
  cout << ts << endl;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Vanya and his friends are walking along the fence of height h and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed h. If the height of some person is greater than h he can bend down and then he surely won't be noticed by the guard. The height of the i-th person is equal to ai.

Consider the width of the person walking as usual to be equal to 1, while the width of the bent person is equal to 2. Friends want to talk to each other while walking, so they would like to walk in a single row. What is the minimum width of the road, such that friends can walk in a row and remain unattended by the guard?

Input

The first line of the input contains two integers n and h (1 ≤ n ≤ 1000, 1 ≤ h ≤ 1000) — the number of friends and the height of the fence, respectively.

The second line contains n integers ai (1 ≤ ai ≤ 2h), the i-th of them is equal to the height of the i-th person.

Output

Print a single integer — the minimum possible valid width of the road.

Examples

Input

3 7
4 5 14

Output

4

Input

6 1
1 1 1 1 1 1

Output

6

Input

6 5
7 6 8 9 10 5

Output

11

Note

In the first sample, only person number 3 must bend down, so the required width is equal to 1 + 1 + 2 = 4.

In the second sample, all friends are short enough and no one has to bend, so the width 1 + 1 + 1 + 1 + 1 + 1 = 6 is enough.

In the third sample, all the persons have to bend, except the last one. The required minimum width of the road is equal to 2 + 2 + 2 + 2 + 2 + 1 = 11.

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  int n, h;
  scanf("%d%d", &n, &h);
  int a[n];
  int c = 0;
  int d = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > h) {
      c = c + 2;
    } else if (a[i] <= h) {
      d = d + 1;
    }
  }
  printf("%d", c + d);
}

```


### Prompt

Generate a CPP solution to the following problem:

Time Limit: 8 sec / Memory Limit: 64 MB

Example

Input

2
4 2
4 0.4000000
3 0.5000000
4 1
5 0.3333333
5 3
5 0.7777777
4 0.1111111
2 0.0001111

Output

YES

### Response

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int t;
  cin >> t;
  double ma = 0;
  while ( t-- ) {
    int n, m;
    cin >> n >> m;
    double ave = 0;
    double sum_r = 0;
    for ( int i = 0; i < m; i++ ) {
      int v;
      double r;
      cin >> v >> r;
      ave += v*r;
      sum_r += r;
    }
    ave *= (1.0 / sum_r);
    ma = max(ma, ave);
  }

  int p, q;
  cin >> p >> q;
  double ave = 0;
  double sum_r = 0;
  for ( int i = 0; i < q; i++ ) {
    int v;
    double r;
    cin >> v >> r;
    ave += v*r;
    sum_r += r;
  }
  ave *= (1.0 / sum_r);

  if ( ma-0.0000001 >= ave ) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number.

At the beginning of the race Furik stands in a cell with coordinates (1, 1), and Rubik stands in a cell with coordinates (n, n). Right after the start Furik runs towards Rubik, besides, if Furik stands at a cell with coordinates (i, j), then he can move to cell (i + 1, j) or (i, j + 1). After Furik reaches Rubik, Rubik starts running from cell with coordinates (n, n) to cell with coordinates (1, 1). If Rubik stands in cell (i, j), then he can move to cell (i - 1, j) or (i, j - 1). Neither Furik, nor Rubik are allowed to go beyond the boundaries of the field; if a player goes beyond the boundaries, he will be disqualified.

To win the race, Furik and Rubik must earn as many points as possible. The number of points is the sum of numbers from the cells Furik and Rubik visited. Each cell counts only once in the sum.

Print the maximum number of points Furik and Rubik can earn on the relay race.

Input

The first line contains a single integer (1 ≤ n ≤ 300). The next n lines contain n integers each: the j-th number on the i-th line ai, j ( - 1000 ≤ ai, j ≤ 1000) is the number written in the cell with coordinates (i, j).

Output

On a single line print a single number — the answer to the problem.

Examples

Input

1
5

Output

5

Input

2
11 14
16 12

Output

53

Input

3
25 16 25
12 18 19
11 13 8

Output

136

Note

Comments to the second sample: The profitable path for Furik is: (1, 1), (1, 2), (2, 2), and for Rubik: (2, 2), (2, 1), (1, 1).

Comments to the third sample: The optimal path for Furik is: (1, 1), (1, 2), (1, 3), (2, 3), (3, 3), and for Rubik: (3, 3), (3, 2), (2, 2), (2, 1), (1, 1). The figure to the sample:

<image> Furik's path is marked with yellow, and Rubik's path is marked with pink.

### Response

```cpp
#include <bits/stdc++.h>
template <class T>
bool read(T &x) {
  char *s;
  s = (char *)malloc(10);
  if (sizeof(x) == 1)
    strcpy(s + 1, " %c");
  else if (sizeof(x) == 4)
    strcpy(s + 1, "%d");
  else if (sizeof(x) == 8)
    strcpy(s + 1, "%lld");
  int k = scanf(s + 1, &x);
  free(s);
  return k != -1;
}
using namespace std;
int N, A[305][305], dp[605][305][305];
int bul(int a, int x1, int x2) {
  int &ret = dp[a][x1][x2];
  if (ret != -99999999) return ret;
  int y1 = a - x1 + 1;
  int y2 = a - x2 + 1;
  ret = -99999999;
  if (x1 == N and y1 == N) return ret = A[N][N];
  if (x1 > N or y1 > N or x2 > N or y2 > N) return ret;
  ret = max(ret, bul(a + 1, x1, x2));
  ret = max(ret, bul(a + 1, x1 + 1, x2));
  ret = max(ret, bul(a + 1, x1, x2 + 1));
  ret = max(ret, bul(a + 1, x1 + 1, x2 + 1));
  ret += A[x1][y1] + A[x2][y2] * (x1 != x2);
  return ret;
}
int main() {
  read(N);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) read(A[i][j]);
  fill(dp[0][0], dp[604][304] + 304, -99999999);
  if (N == 1) {
    cout << A[1][1] << endl;
    return 0;
  }
  cout << bul(1, 1, 1) << endl;
}

```


### Prompt

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

We have a permutation of the integers from 1 through N, p_1, p_2, .., p_N. We also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M). AtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N) such that p_i = i is maximized:

* Choose j such that 1 ≤ j ≤ M, and swap p_{x_j} and p_{y_j}.

Find the maximum possible number of i such that p_i = i after operations.

Constraints

* 2 ≤ N ≤ 10^5
* 1 ≤ M ≤ 10^5
* p is a permutation of integers from 1 through N.
* 1 ≤ x_j,y_j ≤ N
* x_j ≠ y_j
* If i ≠ j, \\{x_i,y_i\\} ≠ \\{x_j,y_j\\}.
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
p_1 p_2 .. p_N
x_1 y_1
x_2 y_2
:
x_M y_M

Output

Print the maximum possible number of i such that p_i = i after operations.

Examples

Input

5 2
5 3 1 4 2
1 3
5 4

Output

2

Input

3 2
3 2 1
1 2
2 3

Output

3

Input

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

Output

8

Input

5 1
1 2 3 4 5
1 5

Output

5

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100000
#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
int fa[MAXN+5], p[MAXN+5], n, m, Ans; inline int getf(int x){return x^fa[x]?fa[x]=getf(fa[x]):x;} inline void Union(int x, int y){(x=getf(x))^(y=getf(y))?fa[x]=y:0;}
unordered_set<int> G[MAXN+5];
int main()
{
	n = read(), m = read(); for(rint i = 1; i <= n; fa[i] = i, p[i] = read(), i++); for(rint i = 1; i <= m; Union(read(),read()), i++);
	for(rint i = 1; i <= n; G[getf(i)].insert(i), i++); for(rint i = 1; i <= n; Ans += G[getf(i)].count(p[i]), i++); printf("%d\n",Ans); return 0;
}
```