### Prompt

Please formulate a Cpp solution to the following problem:

Recently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integer x and decided to add or subtract it from arbitrary array elements. Formally, by applying single operation Maxim chooses integer i (1 ≤ i ≤ n) and replaces the i-th element of array ai either with ai + x or with ai - x. Please note that the operation may be applied more than once to the same position.

Maxim is a curious minimalis, thus he wants to know what is the minimum value that the product of all array elements (i.e. <image>) can reach, if Maxim would apply no more than k operations to it. Please help him in that.

Input

The first line of the input contains three integers n, k and x (1 ≤ n, k ≤ 200 000, 1 ≤ x ≤ 109) — the number of elements in the array, the maximum number of operations and the number invented by Maxim, respectively.

The second line contains n integers a1, a2, ..., an (<image>) — the elements of the array found by Maxim.

Output

Print n integers b1, b2, ..., bn in the only line — the array elements after applying no more than k operations to the array. In particular, <image> should stay true for every 1 ≤ i ≤ n, but the product of all array elements should be minimum possible.

If there are multiple answers, print any of them.

Examples

Input

5 3 1
5 4 3 5 2

Output

5 4 3 5 -1

Input

5 3 1
5 4 3 5 5

Output

5 4 0 5 5

Input

5 3 1
5 4 4 5 5

Output

5 1 4 5 5

Input

3 2 7
5 4 2

Output

5 11 -5

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct skaitlis {
  long long vertiba;
  bool pozitivs;
  long long indekss;
};
bool sakarto_pec_vertibam(const skaitlis &kreisais, const skaitlis &labais) {
  return kreisais.vertiba < labais.vertiba;
}
bool sakarto_pec_indeksiem(const skaitlis &kreisais, const skaitlis &labais) {
  return kreisais.indekss < labais.indekss;
}
void apmaina_sk(skaitlis &a, skaitlis &b) {
  skaitlis tmp;
  tmp.indekss = a.indekss;
  tmp.pozitivs = a.pozitivs;
  tmp.vertiba = a.vertiba;
  a.indekss = b.indekss;
  a.pozitivs = b.pozitivs;
  a.vertiba = b.vertiba;
  b.indekss = tmp.indekss;
  b.pozitivs = tmp.pozitivs;
  b.vertiba = tmp.vertiba;
}
void parkarto(skaitlis skaitli[], long long skaitlu_sk) {
  long long vecaka_indekss;
  long long kreisa_b_indekss;
  long long laba_b_indekss;
  vecaka_indekss = 0;
  kreisa_b_indekss = 1;
  laba_b_indekss = 2;
  while (kreisa_b_indekss < skaitlu_sk) {
    if (laba_b_indekss == skaitlu_sk ||
        skaitli[kreisa_b_indekss].vertiba <= skaitli[laba_b_indekss].vertiba) {
      if (skaitli[vecaka_indekss].vertiba > skaitli[kreisa_b_indekss].vertiba) {
        apmaina_sk(skaitli[vecaka_indekss], skaitli[kreisa_b_indekss]);
        vecaka_indekss = kreisa_b_indekss;
      } else
        break;
    } else {
      if (skaitli[vecaka_indekss].vertiba > skaitli[laba_b_indekss].vertiba) {
        apmaina_sk(skaitli[vecaka_indekss], skaitli[laba_b_indekss]);
        vecaka_indekss = laba_b_indekss;
      } else
        break;
    }
    kreisa_b_indekss = vecaka_indekss * 2 + 1;
    laba_b_indekss = vecaka_indekss * 2 + 2;
  }
}
void maksimilizacija(skaitlis skaitli[], long long skaitlu_sk,
                     long long atl_op_sk, long long operaciju_skaitlis) {
  sort(skaitli, skaitli + skaitlu_sk, sakarto_pec_vertibam);
  while (atl_op_sk > 0) {
    skaitli[0].vertiba += operaciju_skaitlis;
    atl_op_sk--;
    parkarto(skaitli, skaitlu_sk);
  }
}
int main() {
  long long skaitlu_sk;
  long long maks_op_sk;
  long long operaciju_skaitlis;
  skaitlis *skaitli;
  long long cur_skaitlis;
  int poz_skaits = 0;
  int neg_skaits = 0;
  skaitlis *mazakais = NULL;
  long long atl_op_sk;
  bool Vajag_Maks = false;
  cin >> skaitlu_sk >> maks_op_sk >> operaciju_skaitlis;
  skaitli = new skaitlis[skaitlu_sk];
  for (long long i = 0; i < skaitlu_sk; i++) {
    cin >> cur_skaitlis;
    if (cur_skaitlis >= 0) {
      poz_skaits++;
      skaitli[i].vertiba = cur_skaitlis;
      skaitli[i].pozitivs = true;
    } else if (cur_skaitlis < 0) {
      neg_skaits++;
      cur_skaitlis = -1 * cur_skaitlis;
      skaitli[i].vertiba = cur_skaitlis;
      skaitli[i].pozitivs = false;
    }
    skaitli[i].indekss = i;
    if (mazakais == NULL || cur_skaitlis < mazakais->vertiba)
      mazakais = &skaitli[i];
  }
  atl_op_sk = maks_op_sk;
  if (neg_skaits % 2 != 0) {
    Vajag_Maks = true;
  } else {
    if (mazakais->vertiba < operaciju_skaitlis * maks_op_sk) {
      atl_op_sk = maks_op_sk - (mazakais->vertiba / operaciju_skaitlis) - 1;
      mazakais->vertiba =
          mazakais->vertiba % operaciju_skaitlis - operaciju_skaitlis;
      mazakais->vertiba *= -1;
      if (mazakais->pozitivs)
        mazakais->pozitivs = false;
      else
        mazakais->pozitivs = true;
      Vajag_Maks = true;
    } else {
      mazakais->vertiba -= operaciju_skaitlis * maks_op_sk;
    }
  }
  if (Vajag_Maks && atl_op_sk > 0) {
    maksimilizacija(skaitli, skaitlu_sk, atl_op_sk, operaciju_skaitlis);
    sort(skaitli, skaitli + skaitlu_sk, sakarto_pec_indeksiem);
  }
  for (long long i = 0; i < skaitlu_sk; i++) {
    if (!skaitli[i].pozitivs) skaitli[i].vertiba *= -1;
    cout << skaitli[i].vertiba << " ";
  }
  cout << endl;
  delete[] skaitli;
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Alice and Brown loves games. Today, they will play the following game.

In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice:

* Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile.

The player who becomes unable to perform the operation, loses the game.

Given X and Y, determine the winner of the game, assuming that both players play optimally.

Constraints

* 0 ≤ X, Y ≤ 10^{18}

Input

Input is given from Standard Input in the following format:

X Y

Output

Print the winner: either `Alice` or `Brown`.

Examples

Input

2 1

Output

Brown

Input

5 0

Output

Alice

Input

0 0

Output

Brown

Input

4 8

Output

Alice

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int x,y;
  cin >> x >> y;
  if(abs(x-y)<=1){
    cout << "Brown" << endl;
  }else{
    cout << "Alice" << endl;
  }
}
```


### Prompt

Please create a solution in cpp to the following problem:

Drazil is playing a math game with Varda.

Let's define <image> for positive integer x as a product of factorials of its digits. For example, <image>.

First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions:

1. x doesn't contain neither digit 0 nor digit 1.

2. <image> = <image>.

Help friends find such number.

Input

The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a.

The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes.

Output

Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation.

Examples

Input

4
1234

Output

33222

Input

3
555

Output

555

Note

In the first case, <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  char a[20];
  vector<int> v;
  cin >> n;
  cin >> a;
  for (i = 0; i < n; i++) {
    if (a[i] - '0' == 4) {
      v.push_back(2);
      v.push_back(2);
      v.push_back(3);
    } else if (a[i] - '0' == 8) {
      v.push_back(2);
      v.push_back(2);
      v.push_back(2);
      v.push_back(7);
    } else if (a[i] - '0' == 9) {
      v.push_back(2);
      v.push_back(3);
      v.push_back(3);
      v.push_back(7);
    } else if (a[i] - '0' == 6) {
      v.push_back(5);
      v.push_back(3);
    } else
      v.push_back(a[i] - '0');
  }
  sort(v.begin(), v.end());
  for (vector<int>::iterator it = --v.end(); it != v.begin(); it--)
    if ((*it != 1) && (*it != 0)) cout << *it;
  if ((*v.begin() != 1) && (*v.begin() != 0)) cout << *v.begin();
  cout << endl;
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Bizon the Champion isn't just a bison. He also is a favorite of the "Bizons" team.

At a competition the "Bizons" got the following problem: "You are given two distinct words (strings of English letters), s and t. You need to transform word s into word t". The task looked simple to the guys because they know the suffix data structures well. Bizon Senior loves suffix automaton. By applying it once to a string, he can remove from this string any single character. Bizon Middle knows suffix array well. By applying it once to a string, he can swap any two characters of this string. The guys do not know anything about the suffix tree, but it can help them do much more.

Bizon the Champion wonders whether the "Bizons" can solve the problem. Perhaps, the solution do not require both data structures. Find out whether the guys can solve the problem and if they can, how do they do it? Can they solve it either only with use of suffix automaton or only with use of suffix array or they need both structures? Note that any structure may be used an unlimited number of times, the structures may be used in any order.

Input

The first line contains a non-empty word s. The second line contains a non-empty word t. Words s and t are different. Each word consists only of lowercase English letters. Each word contains at most 100 letters.

Output

In the single line print the answer to the problem. Print "need tree" (without the quotes) if word s cannot be transformed into word t even with use of both suffix array and suffix automaton. Print "automaton" (without the quotes) if you need only the suffix automaton to solve the problem. Print "array" (without the quotes) if you need only the suffix array to solve the problem. Print "both" (without the quotes), if you need both data structures to solve the problem.

It's guaranteed that if you can solve the problem only with use of suffix array, then it is impossible to solve it only with use of suffix automaton. This is also true for suffix automaton.

Examples

Input

automaton
tomat

Output

automaton

Input

array
arary

Output

array

Input

both
hot

Output

both

Input

need
tree

Output

need tree

Note

In the third sample you can act like that: first transform "both" into "oth" by removing the first character using the suffix automaton and then make two swaps of the string using the suffix array and get "hot".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b, c;
  cin >> a >> b;
  c = a;
  for (int i = 0; i < b.length(); i++)
    if (i < c.length() && b[i] != c[i]) c.erase(i, 1), i--;
  if (c.find(b) != -1) return cout << "automaton", 0;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (a == b) return cout << "array", 0;
  for (int i = 0; i < b.length(); i++)
    if (i < a.length() && b[i] != a[i]) a.erase(i, 1), i--;
  if (a.find(b) != -1) return cout << "both", 0;
  cout << "need tree";
  return 0;
}

```


### Prompt

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

Dreamoon likes strings. Today he created a game about strings:

String s_1, s_2, …, s_n is beautiful if and only if for each 1 ≤ i < n, s_i ≠ s_{i+1}.

Initially, Dreamoon has a string a. In each step Dreamoon can choose a beautiful substring of a and remove it. Then he should concatenate the remaining characters (in the same order).

Dreamoon wants to use the smallest number of steps to make a empty. Please help Dreamoon, and print any sequence of the smallest number of steps to make a empty.

Input

The first line contains an integer t (1 ≤ t ≤ 200 000), denoting the number of test cases in the input.

For each test case, there's one line with a non-empty string of lowercase Latin letters a.

The total sum of lengths of strings in all test cases is at most 200 000.

Output

For each test case, in the first line, you should print m: the smallest number of steps to make a empty. Each of the following m lines should contain two integers l_i, r_i (1 ≤ l_i ≤ r_i ≤ |a|), denoting, that the i-th step is removing the characters from index l_i to r_i in the current string. (indices are numbered starting from 1).

Note that after the deletion of the substring, indices of remaining characters may change, and r_i should be at most the current length of a.

If there are several possible solutions, you can print any.

Example

Input

4
aabbcc
aaabbb
aaa
abacad

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Part {
  int cnt;
  int d;
  int l, r;
};
struct Fenwick {
  vector<int> data;
  int n;
  Fenwick(int n_) {
    n = n_ + 10;
    data.resize(n);
  }
  void add(int i, int v) {
    for (i += 5; i < n; i += i & -i) data[i] += v;
  }
  int sum(int i) {
    int sum = 0;
    for (i += 5; i; i -= i & -i) sum += data[i];
    return sum;
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int n = s.size();
    vector<pair<int, int>> cur = {{0, s[0] - 'a'}};
    for (char c : s) {
      if (c - 'a' != cur.back().second) cur.emplace_back(0, c - 'a');
      cur.back().first++;
    }
    map<int, Part> part;
    int cnt[26] = {};
    int pos = 0, sum = 0;
    for (auto [c, d] : cur) {
      cnt[d] += c - 1;
      sum += c - 1;
      if (c - 1) part[pos] = Part{c - 1, d, pos, pos + c - 1};
      pos += c;
    }
    int need = 1 + max(*max_element(cnt, cnt + 26), (sum + 1) / 2);
    map<int, set<int>> m;
    for (auto [l, p] : part) {
      auto a = part.find(l);
      auto b = next(a);
      if (b == part.end()) break;
      if (a->second.d != b->second.d) {
        m[a->second.d].insert(l);
        m[b->second.d].insert(l);
      }
    }
    vector<pair<int, int>> ans;
    while (1) {
      int mad = max_element(cnt, cnt + 26) - cnt;
      int found = 0;
      while (m[mad].size()) {
        auto it = m[mad].begin();
        int lit = *it;
        m[mad].erase(it);
        if (!part.count(lit)) continue;
        auto ait = part.find(lit);
        auto bit = next(ait);
        if (bit == part.end()) continue;
        Part& a = ait->second;
        Part& b = bit->second;
        if ((a.d == mad) + (b.d == mad) != 1) continue;
        found = 1;
        ans.emplace_back(a.r--, b.l++);
        assert(a.d != b.d);
        cnt[a.d]--;
        cnt[b.d]--;
        a.cnt--;
        b.cnt--;
        vector<int> x;
        if (ait != part.begin()) x.push_back(prev(ait)->first);
        if (a.cnt) x.push_back(ait->first);
        if (b.cnt) x.push_back(bit->first);
        if (next(bit) != part.end()) x.push_back(next(bit)->first);
        for (int i = 0; i + 1 < (int)x.size(); i++) {
          int ad = part[x[i]].d, bd = part[x[i + 1]].d;
          if (ad != bd) {
            m[ad].insert(x[i]);
            m[bd].insert(x[i]);
          }
        }
        if (!a.cnt) part.erase(ait);
        if (!b.cnt) part.erase(bit);
        break;
      }
      if (!found) {
        for (auto [l, p] : part) {
          for (int c = 0; c < p.cnt; c++) {
            int a = p.l++;
            ans.emplace_back(a, a);
          }
        }
        break;
      }
    }
    ans.emplace_back(-1, n);
    Fenwick tree(n);
    set<int> left;
    for (int i = 0; i < n; i++) {
      tree.add(i, 1);
      left.insert(i);
    }
    cout << ans.size() << '\n';
    assert((int)ans.size() == need);
    for (auto [l, r] : ans) {
      if (l == -1) l = *left.begin();
      if (r == n) r = *left.rbegin();
      cout << tree.sum(l) << ' ' << tree.sum(r) << '\n';
      assert(r >= l);
      assert(left.count(l));
      assert(left.count(r));
      vector<int> torem;
      auto it = left.find(l);
      char last = 0;
      while (1) {
        assert(it != left.end());
        char add = s[*it];
        assert(add != last);
        last = add;
        torem.push_back(*it);
        if (it == left.find(r)) break;
        ++it;
      };
      for (int i : torem) {
        tree.add(i, -1);
        left.erase(i);
      }
    }
  }
}

```


### Prompt

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

The only difference between easy and hard versions is constraints.

There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th kid (in case of i = p_i the kid will give his book to himself). It is guaranteed that all values of p_i are distinct integers from 1 to n (i.e. p is a permutation). The sequence p doesn't change from day to day, it is fixed.

For example, if n=6 and p=[4, 6, 1, 3, 5, 2] then at the end of the first day the book of the 1-st kid will belong to the 4-th kid, the 2-nd kid will belong to the 6-th kid and so on. At the end of the second day the book of the 1-st kid will belong to the 3-th kid, the 2-nd kid will belong to the 2-th kid and so on.

Your task is to determine the number of the day the book of the i-th child is returned back to him for the first time for every i from 1 to n.

Consider the following example: p = [5, 1, 2, 4, 3]. The book of the 1-st kid will be passed to the following kids:

  * after the 1-st day it will belong to the 5-th kid,
  * after the 2-nd day it will belong to the 3-rd kid,
  * after the 3-rd day it will belong to the 2-nd kid,
  * after the 4-th day it will belong to the 1-st kid.

So after the fourth day, the book of the first kid will return to its owner. The book of the fourth kid will return to him for the first time after exactly one day.

You have to answer q independent queries.

Input

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

The first line of the query contains one integer n (1 ≤ n ≤ 200) — the number of kids in the query. The second line of the query contains n integers p_1, p_2, ..., p_n (1 ≤ p_i ≤ n, all p_i are distinct, i.e. p is a permutation), where p_i is the kid which will get the book of the i-th kid.

Output

For each query, print the answer on it: n integers a_1, a_2, ..., a_n, where a_i is the number of the day the book of the i-th child is returned back to him for the first time in this query.

Example

Input

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

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[200005], ans[200005], vis[200005];
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]), vis[i] = 0;
    vector<int> q;
    for (int i = 1; i <= n; i++) {
      if (vis[i]) continue;
      q.clear();
      q.push_back(i);
      int num = 1, p = a[i];
      vis[i] = 1;
      while (p != i) {
        num++;
        vis[p] = 1;
        q.push_back(p);
        p = a[p];
      }
      for (int j = 0; j < q.size(); j++) {
        ans[q[j]] = num;
      }
    }
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    printf("\n");
  }
}

```


### Prompt

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

There are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x- or y- axis. You are given a character d_i that represents the specific direction in which the i-th point moves, as follows:

* If d_i = `R`, the i-th point moves in the positive x direction;
* If d_i = `L`, the i-th point moves in the negative x direction;
* If d_i = `U`, the i-th point moves in the positive y direction;
* If d_i = `D`, the i-th point moves in the negative y direction.

You can stop all the points at some moment of your choice after they start moving (including the moment they start moving). Then, let x_{max} and x_{min} be the maximum and minimum among the x-coordinates of the N points, respectively. Similarly, let y_{max} and y_{min} be the maximum and minimum among the y-coordinates of the N points, respectively.

Find the minimum possible value of (x_{max} - x_{min}) \times (y_{max} - y_{min}) and print it.

Constraints

* 1 \leq N \leq 10^5
* -10^8 \leq x_i,\ y_i \leq 10^8
* x_i and y_i are integers.
* d_i is `R`, `L`, `U`, or `D`.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1 d_1
x_2 y_2 d_2
.
.
.
x_N y_N d_N

Output

Print the minimum possible value of (x_{max} - x_{min}) \times (y_{max} - y_{min}).

The output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-9}.

Examples

Input

2
0 3 D
3 0 L

Output

0

Input

5
-7 -10 U
7 -6 U
-8 7 D
-3 3 D
0 -6 R

Output

97.5

Input

20
6 -10 R
-4 -9 U
9 6 D
-3 -2 R
0 7 D
4 5 D
10 -10 U
-1 -8 U
10 -6 D
8 -5 U
6 4 D
0 3 D
7 9 R
9 -4 R
3 10 D
1 9 U
1 -6 U
9 -8 R
6 7 D
7 -3 D

Output

273

### Response

```cpp
#include<algorithm>
#include<cmath>
#include<cstdio>
typedef long double llf;
const int MN=1e5+4;
const llf INF=1e100,EPS=7e-12,GR=(1+sqrt(5))/2.0;
int N;
llf ans=INF;
struct pnt {
    llf x, y;
    llf ox,oy;
    char c;
}pnts[MN];
static inline void mov(pnt &p,llf dt) {
    switch(p.c) {
        case 'R':
            p.x=p.ox+dt;
            p.y=p.oy;
            break;
        case 'L':
            p.x=p.ox-dt;
            p.y=p.oy;
            break;
        case 'U':
            p.x=p.ox;
            p.y=p.oy+dt;
            break;
        case 'D':
            p.x=p.ox;
            p.y=p.oy-dt;
            break;
    }
}
static inline llf bb() {
    llf mxx=-INF,mxy=-INF,mnx=INF,mny=INF;
    for(int i=0;i<N;++i) {
        mxx=std::max(mxx,pnts[i].x);
        mnx=std::min(mnx,pnts[i].x);
        mxy=std::max(mxy,pnts[i].y);
        mny=std::min(mny,pnts[i].y);
    }
    return (mxx-mnx)*(mxy-mny);
}
int main() {
    scanf("%d",&N);
    for(int i=0;i<N;++i) {
        scanf("%Lf %Lf %c",&pnts[i].ox,&pnts[i].oy,&pnts[i].c);
    }
    // do GSS
    llf lo=0,hi=1e9,mi1,mi2;
    for(int i=0;i<500;++i) {
        mi1=hi-(hi-lo)/GR;
        mi2=lo+(hi-lo)/GR;
        llf b1,b2;
        for(int i=0;i<N;++i)
            mov(pnts[i],mi1);
        b1=bb();
        for(int i=0;i<N;++i)
            mov(pnts[i],mi2);
        b2=bb();
        if(b1<b2) hi=mi2;
        else lo=mi1;
        ans=std::min(std::min(b1,b2),ans);
    }
    printf("%.9Lf\n",ans);
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

You are storing an integer array of length m in a database. To maintain internal integrity and protect data, the database stores n copies of this array.

Unfortunately, the recent incident may have altered the stored information in every copy in the database.

It's believed, that the incident altered at most two elements in every copy. You need to recover the original array based on the current state of the database.

In case there are multiple ways to restore the array, report any. If there is no array that differs from every copy in no more than two positions, report that as well.

Input

The first line contains integers n and m (2 ≤ n; 1 ≤ m; n ⋅ m ≤ 250 000) — the number of copies and the size of the array.

Each of the following n lines describes one of the currently stored copies in the database, it consists of m integers s_{i, 1}, s_{i, 2}, ..., s_{i, m} (1 ≤ s_{i, j} ≤ 10^9).

Output

If there is an array consistent with all given copies, print "Yes" and then the array itself. The array must have length m and contain integers between 1 and 10^9 only.

Otherwise, print "No".

If there are multiple possible arrays, print any of them.

Examples

Input

3 4
1 10 10 100
1 1 1 100
10 100 1 100

Output

Yes
1 10 1 100

Input

10 7
1 1 1 1 1 1 1
1 1 1 1 1 1 2
1 1 1 1 1 2 2
1 1 1 1 2 2 1
1 1 1 2 2 1 1
1 1 2 2 1 1 1
1 2 2 1 1 1 1
2 2 1 1 1 1 1
2 1 1 1 1 1 1
1 1 1 1 1 1 1

Output

Yes
1 1 1 1 1 1 1

Input

2 5
2 2 1 1 1
1 1 2 2 2

Output

No

Note

In the first example, the array [1, 10, 1, 100] differs from first and second copies in just one position, and from the third copy in two positions.

In the second example, array [1, 1, 1, 1, 1, 1, 1] is the same as the first copy and differs from all other copies in at most two positions.

In the third example, there is no array differing in at most two positions from every database's copy.

### Response

```cpp
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (register int i = a; i < b; ++i)

int N, M;

bool dfs(const vector<vector<int>>& arrs, vector<int>& ans, const vector<vector<int>>& diff, vector<int>& changes)
{
    int num_change = changes.size();
    FOR(i, 0, N)
    {
        auto curdiff = diff[i];

        for (auto j : changes) {
            auto p = find(curdiff.begin(), curdiff.end(), j);
            if (p == curdiff.end())
                curdiff.push_back(j);
            else if (arrs[i][j] == ans[j])
                curdiff.erase(p);
        }

        int num_diff = curdiff.size();

        if (num_diff <= 2)
            continue;
        if (num_diff > 4)
            return false;
        if (num_change == 2)
            return false;

        for (auto j : curdiff) {
            auto oldvalue = ans[j];
            ans[j] = arrs[i][j];
            changes.push_back(j);
            if (dfs(arrs, ans, diff, changes))
                return true;
            changes.pop_back();
            ans[j] = oldvalue;
        }
        return false;
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> M;

    vector<vector<int>> arrs(N, vector<int>(M, 0));

    for (auto& arr : arrs)
        for (auto& x : arr)
            cin >> x;

    vector<int> ans = arrs[0];

    vector<vector<int>> diff(N);

    vector<int> changes;

    for (register int i = 1; i < N; ++i)
        for (register int j = 0; j < M; ++j)
            if (arrs[i][j] != ans[j])
                diff[i].push_back(j);

    if (dfs(arrs, ans, diff, changes)) {
        cout << "Yes" << endl;
        for (auto& x : ans)
            cout << x << ' ';
        cout << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}
```


### Prompt

Create a solution in cpp for the following problem:

The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or water. The map is surrounded by the ocean.

Lakes are the maximal regions of water cells, connected by sides, which are not connected with the ocean. Formally, lake is a set of water cells, such that it's possible to get from any cell of the set to any other without leaving the set and moving only to cells adjacent by the side, none of them is located on the border of the rectangle, and it's impossible to add one more water cell to the set such that it will be connected with any other cell.

You task is to fill up with the earth the minimum number of water cells so that there will be exactly k lakes in Berland. Note that the initial number of lakes on the map is not less than k.

Input

The first line of the input contains three integers n, m and k (1 ≤ n, m ≤ 50, 0 ≤ k ≤ 50) — the sizes of the map and the number of lakes which should be left on the map.

The next n lines contain m characters each — the description of the map. Each of the characters is either '.' (it means that the corresponding cell is water) or '*' (it means that the corresponding cell is land).

It is guaranteed that the map contain at least k lakes.

Output

In the first line print the minimum number of cells which should be transformed from water to land.

In the next n lines print m symbols — the map after the changes. The format must strictly follow the format of the map in the input data (there is no need to print the size of the map). If there are several answers, print any of them.

It is guaranteed that the answer exists on the given data.

Examples

Input

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

Output

1
****
*..*
****
****
..**

Input

3 3 0
***
*.*
***

Output

1
***
***
***

Note

In the first example there are only two lakes — the first consists of the cells (2, 2) and (2, 3), the second consists of the cell (4, 3). It is profitable to cover the second lake because it is smaller. Pay attention that the area of water in the lower left corner is not a lake because this area share a border with the ocean.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXV = 3000;
string c;
int s[MAXV], p[MAXV], n, m, k, a[52][52];
int par(int x) { return (p[x] == x or p[x] == -1) ? p[x] : p[x] = par(p[x]); }
void uni(int x, int y) {
  if (par(x) == -1 or par(y) == -1) {
    if (par(x) != -1) p[par(x)] = -1;
    if (par(y) != -1) p[par(y)] = -1;
    return;
  }
  x = par(x);
  y = par(y);
  if (x == y) return;
  if (s[x] < s[y]) swap(x, y);
  s[x] += s[y];
  p[y] = x;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    cin >> c;
    for (int j = 1; j <= m; j++)
      if (c[j - 1] == '.') a[i][j] = 1;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      s[((i) * (m + 1) + (j))] = 1,
                         p[((i) * (m + 1) + (j))] = ((i) * (m + 1) + (j));
  for (int y = 1; y <= m; y++)
    p[((1) * (m + 1) + (y))] = -1, p[((n) * (m + 1) + (y))] = -1;
  for (int x = 1; x <= n; x++)
    p[((x) * (m + 1) + (1))] = -1, p[((x) * (m + 1) + (m))] = -1;
  for (int x = 2; x <= n; x++)
    for (int y = 2; y <= m; y++)
      if (a[x][y]) {
        for (int dx = -1; dx <= 1; dx++)
          for (int dy = -1; dy <= 1; dy++)
            if (abs(dx) + abs(dy) == 1 and (x + dx >= 1 and x + dx <= n) and
                (y + dy >= 1 and y + dy <= m) and a[x + dx][y + dy])
              uni(((x) * (m + 1) + (y)), ((x + dx) * (m + 1) + (y + dy)));
      }
  vector<pair<int, int> > v;
  for (int x = 1; x <= n; x++)
    for (int y = 1; y <= m; y++)
      if (p[((x) * (m + 1) + (y))] == ((x) * (m + 1) + (y)) and a[x][y])
        v.push_back({s[((x) * (m + 1) + (y))], ((x) * (m + 1) + (y))});
  sort(v.begin(), v.end());
  int res = 0;
  for (int i = 0; i <= ((int)((v).size())) - k - 1; i++)
    res += v[i].first, a[v[i].second / (m + 1)][v[i].second % (m + 1)] = 2;
  cout << res << endl;
  for (int x = 1; x <= n; x++)
    for (int y = 1; y <= m; y++) {
      if (a[par(((x) * (m + 1) + (y))) / (m + 1)]
           [par(((x) * (m + 1) + (y))) % (m + 1)] == 2 ||
          !a[x][y])
        cout << '*';
      else
        cout << '.';
      if (y == m) cout << endl;
    }
}

```


### Prompt

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

Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:

* add(s, t, x): add x to as, as+1, ..., at.
* getSum(s, t): report the sum of as, as+1, ..., at.

Note that the initial values of ai (i = 1, 2, . . . , n) are 0.

Constraints

* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 100000
* 1 ≤ s ≤ t ≤ n
* 0 ≤ x < 1000

Input

n q
query1
query2
:
queryq

In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:

0 s t x

or

1 s t

The first digit represents the type of the query. '0' denotes add(s, t, x) and '1' denotes getSum(s, t).

Output

For each getSum operation, print the sum;

Examples

Input

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

Output

4
8

Input

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

Output

0
4

### Response

```cpp
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int DAT_SIZE = (1 << 18) - 1;	//10^5?¨????

const int MAX_N = 100000;
const int MAX_Q = 100000;

int n,q;

//data??????????????????????§??????????????????????,datb????????????????????????
ll data[DAT_SIZE],datb[DAT_SIZE];

void add(int a,int b,int x,int k,int l,int r)
{
	if(a <= l && r <= b){
		data[k] += x;
	}
	else if(l < b && a < r){
		datb[k] += (min(b,r) - max(a,l)) * x;
		add(a,b,x,k*2+1,l,(l+r)/2);
		add(a,b,x,k*2+2,(l+r)/2,r);
	}
}

ll sum(int a,int b,int k,int l,int r)
{
	if(r <= a || b <= l){
		return 0;
	}
	else if(a <= l && r <= b){
		return data[k]*(r-l) + datb[k];
	}else{
		ll res = (min(b,r) - max(a,l))*data[k];	//??????data[k]??????????????£???????????????
		res += sum(a,b,k*2+1,l,(l+r)/2);
		res += sum(a,b,k*2+2,(l+r)/2,r);
		return res;
	}
}

int main()
{
	scanf("%d%d",&n,&q);
	rep(i,q){
		int x;
		scanf("%d",&x);
		if(x==0){
			int s,t,u;
			scanf("%d%d%d",&s,&t,&u);
			add(s-1,t,u,0,0,n);
		}else{
			int s,t;
			scanf("%d%d",&s,&t);
			printf("%lld\n",sum(s-1,t,0,0,n));
		}
	}
	return 0;
}
```


### Prompt

Generate a cpp solution to the following problem:

Digital collectible card games have become very popular recently. So Vova decided to try one of these.

Vova has n cards in his collection. Each of these cards is characterised by its power pi, magic number ci and level li. Vova wants to build a deck with total power not less than k, but magic numbers may not allow him to do so — Vova can't place two cards in a deck if the sum of the magic numbers written on these cards is a prime number. Also Vova cannot use a card if its level is greater than the level of Vova's character.

At the moment Vova's character's level is 1. Help Vova to determine the minimum level he needs to reach in order to build a deck with the required total power.

Input

The first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100000).

Then n lines follow, each of these lines contains three numbers that represent the corresponding card: pi, ci and li (1 ≤ pi ≤ 1000, 1 ≤ ci ≤ 100000, 1 ≤ li ≤ n).

Output

If Vova won't be able to build a deck with required power, print  - 1. Otherwise print the minimum level Vova has to reach in order to build a deck.

Examples

Input

5 8
5 5 1
1 5 4
4 6 3
1 12 4
3 12 1

Output

4

Input

3 7
4 4 1
5 8 2
5 3 3

Output

2

### Response

```cpp
#include <bits/stdc++.h>
namespace data {
int val[105], mag[105], lev[105], num, lit;
}
namespace init {
inline void in(int &justval) {
  int if_z = 1;
  justval = 0;
  char Cget = getchar();
  while (Cget > '9' || Cget < '0') {
    if (Cget == '-') if_z = -1;
    Cget = getchar();
  }
  while (Cget >= '0' && Cget <= '9') {
    justval = justval * 10 + Cget - '0';
    Cget = getchar();
  }
  justval *= if_z;
}
}  // namespace init
namespace solve {
struct EdgeType {
  int v, f;
  EdgeType *next, *another;
};
struct EdgeType *head[105], e[200005];
int que[200005], sum, prime[200005 * 10], num, cnt, s, t, deep[105];
bool p_[200005 * 10 - 1];
inline void edge_add(int u, int v, int f) {
  e[++cnt].v = v, e[cnt].f = f, e[cnt].next = head[u], head[u] = &e[cnt];
  e[++cnt].v = u, e[cnt].f = 0, e[cnt].next = head[v], head[v] = &e[cnt];
  e[cnt].another = &e[cnt - 1], e[cnt - 1].another = &e[cnt];
}
int min(const int &tops_, const int &tops__) {
  if (tops_ < tops__)
    return tops_;
  else
    return tops__;
}
inline bool bfs() {
  t = data::num + 1, s = 0;
  int h = 0, tail = 1;
  que[h] = s;
  for (int i = s; i <= t; i++) deep[i] = -1;
  deep[s] = 0;
  while (h < tail) {
    int now = que[h++];
    for (EdgeType *i = head[now]; i != NULL; i = i->next) {
      if (deep[i->v] < 0 && i->f) {
        deep[i->v] = deep[now] + 1;
        if (i->v == t) return true;
        que[tail++] = i->v;
      }
    }
  }
  return false;
}
int flowing(int now, int flow) {
  if (now == t || flow <= 0) return flow;
  int oldflow = 0;
  for (EdgeType *i = head[now]; i != NULL; i = i->next) {
    if (deep[i->v] == deep[now] + 1 && i->f) {
      int pos = flowing(i->v, min(i->f, flow));
      flow -= pos, oldflow += pos, i->f -= pos, i->another->f += pos;
      if (!flow) return oldflow;
    }
  }
  if (!oldflow) deep[now] = -1;
  return oldflow;
}
bool dinic(int res, int lit) {
  while (bfs()) res -= flowing(s, 0x7fffffff);
  return res >= lit;
}
void ouler(int limit) {
  for (int i = 2; i <= limit; i++) {
    if (!p_[i]) prime[++num] = i;
    for (int j = 1; prime[j] * i <= limit && j <= num; j++) {
      p_[i * prime[j]] = true;
      if (i % prime[j] == 0) break;
    }
  }
}
bool check(int x) {
  int n = data::num, k = data::lit, res = 0;
  s = 0, t = n + 1, cnt = 1;
  for (int i = s; i <= t; i++) head[i] = NULL;
  int idx__ = -1;
  for (int i = 1; i <= n; i++) {
    if (data::lev[i] > x) continue;
    if (data::mag[i] == 1 && data::val[i] > data::val[idx__]) idx__ = i;
  }
  for (int i = 1; i <= n; i++) {
    if (data::lev[i] > x || (data::mag[i] == 1 && idx__ != i)) continue;
    res += data::val[i];
    if (data::mag[i] & 1) {
      edge_add(s, i, data::val[i]);
      for (int j = 1; j <= n; j++) {
        if (data::lev[j] > x || i == j) continue;
        if (!(data::mag[j] & 1)) {
          if (!p_[data::mag[i] + data::mag[j]]) edge_add(i, j, 0x7fffffff);
        } else if (data::mag[i] + data::mag[j] == 2)
          edge_add(i, j, 0x7fffffff);
      }
    } else
      edge_add(i, t, data::val[i]);
  }
  return dinic(res, k);
}
void binary() {
  ouler(200005 * 10 - 1);
  int l = 1, r = data::num, ans = -1;
  while (l <= r) {
    int mid = l + r >> 1;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%d\n", ans);
}
}  // namespace solve
int main() {
  init::in(data::num), init::in(data::lit);
  for (int i = 1; i <= data::num; i++) {
    init::in(data::val[i]);
    init::in(data::mag[i]);
    init::in(data::lev[i]);
  }
  solve::binary();
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President of Berland, G.W. Boosch, to be signed.

This time mr. Boosch plans to sign 2k laws. He decided to choose exactly two non-intersecting segments of integers from 1 to n of length k and sign all laws, whose numbers fall into these segments. More formally, mr. Boosch is going to choose two integers a, b (1 ≤ a ≤ b ≤ n - k + 1, b - a ≥ k) and sign all laws with numbers lying in the segments [a; a + k - 1] and [b; b + k - 1] (borders are included).

As mr. Boosch chooses the laws to sign, he of course considers the public opinion. Allberland Public Opinion Study Centre (APOSC) conducted opinion polls among the citizens, processed the results into a report and gave it to the president. The report contains the absurdity value for each law, in the public opinion. As mr. Boosch is a real patriot, he is keen on signing the laws with the maximum total absurdity. Help him.

Input

The first line contains two integers n and k (2 ≤ n ≤ 2·105, 0 < 2k ≤ n) — the number of laws accepted by the parliament and the length of one segment in the law list, correspondingly. The next line contains n integers x1, x2, ..., xn — the absurdity of each law (1 ≤ xi ≤ 109).

Output

Print two integers a, b — the beginning of segments that mr. Boosch should choose. That means that the president signs laws with numbers from segments [a; a + k - 1] and [b; b + k - 1]. If there are multiple solutions, print the one with the minimum number a. If there still are multiple solutions, print the one with the minimum b.

Examples

Input

5 2
3 6 1 1 6

Output

1 4

Input

6 2
1 1 1 1 1 1

Output

1 3

Note

In the first sample mr. Boosch signs laws with numbers from segments [1;2] and [4;5]. The total absurdity of the signed laws equals 3 + 6 + 1 + 6 = 16.

In the second sample mr. Boosch signs laws with numbers from segments [1;2] and [3;4]. The total absurdity of the signed laws equals 1 + 1 + 1 + 1 = 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int a[200005], l[200005], r[200005], c[200005], maxl, maxr, imax,
    jmax;
int main() {
  long long int n, k, i, j;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    c[i] = c[i - 1] + a[i];
    if (i == k) {
      maxl = c[i] - c[i - k - 1];
      l[i] = i;
    }
    if (i > k) {
      if (c[i] - c[i - k] > c[l[i - 1]] - c[l[i - 1] - k]) {
        maxl = c[i] - c[i - k];
        l[i] = i;
      } else
        l[i] = l[i - 1];
    }
  }
  for (j = n - k + 1; j >= 1; j--) {
    if (j == n - k + 1) {
      maxr = c[j + k - 1] - c[j - 1];
      r[j] = j;
      continue;
    }
    if (c[j + k - 1] - c[j - 1] >= c[r[j + 1] + k - 1] - c[r[j + 1] - 1]) {
      maxr = c[j + k - 1] - c[j - 1];
      r[j] = j;
    } else
      r[j] = r[j + 1];
  }
  maxl = 0;
  maxr = 0;
  for (i = k; i <= n - k + 1; i++) {
    long long int left, right;
    left = c[l[i]] - c[l[i] - k];
    right = c[r[i + 1] + k - 1] - c[r[i + 1] - 1];
    if (left + right > maxl + maxr) {
      maxl = left;
      maxr = right;
      imax = l[i] - k + 1;
      jmax = r[i + 1];
    }
  }
  cout << imax << " " << jmax;
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

There are n robbers at coordinates (a_1, b_1), (a_2, b_2), ..., (a_n, b_n) and m searchlight at coordinates (c_1, d_1), (c_2, d_2), ..., (c_m, d_m).

In one move you can move each robber to the right (increase a_i of each robber by one) or move each robber up (increase b_i of each robber by one). Note that you should either increase all a_i or all b_i, you can't increase a_i for some points and b_i for some other points.

Searchlight j can see a robber i if a_i ≤ c_j and b_i ≤ d_j.

A configuration of robbers is safe if no searchlight can see a robber (i.e. if there is no pair i,j such that searchlight j can see a robber i).

What is the minimum number of moves you need to perform to reach a safe configuration?

Input

The first line of input contains two integers n and m (1 ≤ n, m ≤ 2000): the number of robbers and the number of searchlight.

Each of the next n lines contains two integers a_i, b_i (0 ≤ a_i, b_i ≤ 10^6), coordinates of robbers.

Each of the next m lines contains two integers c_i, d_i (0 ≤ c_i, d_i ≤ 10^6), coordinates of searchlights.

Output

Print one integer: the minimum number of moves you need to perform to reach a safe configuration.

Examples

Input

1 1
0 0
2 3

Output

3

Input

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

Output

4

Input

1 2
0 0
0 0
0 0

Output

1

Input

7 3
0 8
3 8
2 7
0 10
5 5
7 0
3 5
6 6
3 11
11 5

Output

6

Note

In the first test, you can move each robber to the right three times. After that there will be one robber in the coordinates (3, 0).

The configuration of the robbers is safe, because the only searchlight can't see the robber, because it is in the coordinates (2, 3) and 3 > 2.

In the second test, you can move each robber to the right two times and two times up. After that robbers will be in the coordinates (3, 8), (8, 3).

It's easy the see that the configuration of the robbers is safe.

It can be proved that you can't reach a safe configuration using no more than 3 moves.

### Response

```cpp
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using pii = pair<int, int>;
const int N = 2e3 + 10;
const int mod = 0;
const int INF = 2e6 + 10;
pii pr[N], pl[N];
std::vector<pii> v;
struct Seg {
  int l;
  int r;
  int val;
  int lazy;
} seg[(int)4e6 + 10];
void build(int id, int l, int r) {
  seg[id].l = l, seg[id].r = r, seg[id].val = 0, seg[id].lazy = -1;
  if (l == r) return;
  int mid = l + r >> 1;
  build(id * 2, l, mid), build(id * 2 + 1, mid + 1, r);
}
void push(int id) {
  if (seg[id].l == seg[id].r || seg[id].lazy == -1) return;
  seg[2 * id].val = max(seg[2 * id].val, seg[id].lazy);
  seg[2 * id].lazy = max(seg[2 * id].lazy, seg[id].lazy);
  seg[2 * id + 1].val = max(seg[2 * id + 1].val, seg[id].lazy);
  seg[2 * id + 1].lazy = max(seg[2 * id + 1].lazy, seg[id].lazy);
  seg[id].lazy = -1;
  return;
}
int query(int id, int l, int r) {
  if (seg[id].l > r || seg[id].r < l) return INF;
  push(id);
  if (seg[id].l >= l && seg[id].r <= r) return seg[id].val;
  return min(query(2 * id, l, r), query(2 * id + 1, l, r));
}
void update(int id, int l, int r, int val) {
  if (seg[id].l > r || seg[id].r < l) return;
  push(id);
  seg[id].val = max(seg[id].val, val);
  if (seg[id].l >= l && seg[id].r <= r) {
    seg[id].lazy = max(seg[id].lazy, val);
    return;
  }
  update(2 * id, l, r, val);
  update(2 * id + 1, l, r, val);
}
int dp[(int)1e6 + 10];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &pr[i].first, &pr[i].second);
  }
  for (int i = 0; i <= 1e6 + 5; i++) dp[i] = -1;
  int ma = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &pl[i].first, &pl[i].second);
    ma = max(ma, pl[i].second + 1);
  }
  build(1, 0, ma);
  sort(pl + 1, pl + m + 1);
  reverse(pl + 1, pl + m + 1);
  v.push_back({1e6 + 10, -1});
  pl[0] = {-1, -1};
  for (int i = 1; i <= m; i++) {
    if (pl[i].second > pl[i - 1].second) v.push_back(pl[i]);
  }
  v.push_back({-1, 1e6 + 10});
  for (int i = 1; i <= n; i++) {
    vector<pii> q;
    for (int j = 1; j < v.size(); j++) {
      pii it = v[j];
      if (it.first < pr[i].first) {
        int y = v[j - 1].second - pr[i].second + 1;
        if (y >= 0) q.push_back({y, 0});
        break;
      }
      if (it.second < pr[i].second) continue;
      int y = max(0, v[j - 1].second - pr[i].second + 1);
      q.push_back({y, it.first - pr[i].first + 1});
    }
    for (int i = 0; i < (int)q.size(); i++) {
      if (i != q.size() - 1)
        update(1, q[i].first, q[i + 1].first - 1, q[i].second);
      else
        update(1, q[i].first, ma, q[i].second);
    }
  }
  int mi = 3e6 + 10;
  for (int i = 0; i <= ma; i++) {
    mi = min(mi, query(1, i, i) + i);
  }
  printf("%d", mi);
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

In one very old text file there was written Great Wisdom. This Wisdom was so Great that nobody could decipher it, even Phong — the oldest among the inhabitants of Mainframe. But still he managed to get some information from there. For example, he managed to learn that User launches games for pleasure — and then terrible Game Cubes fall down on the city, bringing death to those modules, who cannot win the game...

For sure, as guard Bob appeared in Mainframe many modules stopped fearing Game Cubes. Because Bob (as he is alive yet) has never been defeated by User, and he always meddles with Game Cubes, because he is programmed to this.

However, unpleasant situations can happen, when a Game Cube falls down on Lost Angles. Because there lives a nasty virus — Hexadecimal, who is... mmm... very strange. And she likes to play very much. So, willy-nilly, Bob has to play with her first, and then with User.

This time Hexadecimal invented the following entertainment: Bob has to leap over binary search trees with n nodes. We should remind you that a binary search tree is a binary tree, each node has a distinct key, for each node the following is true: the left sub-tree of a node contains only nodes with keys less than the node's key, the right sub-tree of a node contains only nodes with keys greater than the node's key. All the keys are different positive integer numbers from 1 to n. Each node of such a tree can have up to two children, or have no children at all (in the case when a node is a leaf).

In Hexadecimal's game all the trees are different, but the height of each is not lower than h. In this problem «height» stands for the maximum amount of nodes on the way from the root to the remotest leaf, the root node and the leaf itself included. When Bob leaps over a tree, it disappears. Bob gets the access to a Cube, when there are no trees left. He knows how many trees he will have to leap over in the worst case. And you?

Input

The input data contains two space-separated positive integer numbers n and h (n ≤ 35, h ≤ n).

Output

Output one number — the answer to the problem. It is guaranteed that it does not exceed 9·1018.

Examples

Input

3 2

Output

5

Input

3 3

Output

4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
const unsigned long long Mod = 1e9 + 7;
unsigned long long dp[37][37], n, h;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> h;
  1;
  dp[1][1] = 1;
  dp[0][0] = 1;
  for (int lng = 2; lng <= n; lng++) {
    1;
    for (int j = 1; j <= lng; j++) {
      1;
      for (int ls = 0; ls < lng; ls++) {
        for (int hgt = 0; hgt < j; hgt++) {
          1;
          if (hgt != j - 1)
            dp[lng][j] += 2 * dp[ls][hgt] * dp[lng - ls - 1][j - 1];
          else
            dp[lng][j] += dp[ls][hgt] * dp[lng - ls - 1][j - 1];
        }
      }
    }
  }
  unsigned long long ans = 0;
  for (int i = h; i <= n; i++) ans += dp[n][i];
  cout << ans << endl;
  return 0;
}

```


### Prompt

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

A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.

The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions:

  * Is it true that y is strictly larger than number x?
  * Is it true that y is strictly smaller than number x?
  * Is it true that y is larger than or equal to number x?
  * Is it true that y is smaller than or equal to number x?

On each question the host answers truthfully, "yes" or "no".

Given the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print "Impossible".

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is:

  * ">" (for the first type queries),
  * "<" (for the second type queries),
  * ">=" (for the third type queries),
  * "<=" (for the fourth type queries).

All values of x are integer and meet the inequation  - 109 ≤ x ≤ 109. The answer is an English letter "Y" (for "yes") or "N" (for "no").

Consequtive elements in lines are separated by a single space.

Output

Print any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation  - 2·109 ≤ y ≤ 2·109. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes).

Examples

Input

4
>= 1 Y
< 3 N
<= -3 N
> 55 N

Output

17

Input

2
> 100 Y
< -100 Y

Output

Impossible

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c, l, r, flag, m;
  char a[5], b[5];
  while (scanf("%d", &n) != EOF) {
    l = -2000000000;
    r = 2000000000;
    flag = 1;
    while (n--) {
      memset(a, 0, sizeof(a));
      memset(b, 0, sizeof(b));
      scanf("%s", a);
      scanf("%d", &c);
      scanf("%s", b);
      if (!flag) continue;
      int s = strlen(a);
      if (b[0] == 'Y')
        m = 1;
      else
        m = 0;
      if ((s == 2 && a[0] == '>') || (s == 1 && a[0] == '<')) {
        if ((s == 1 && m) || (s == 2 && !m)) {
          if (l >= c)
            flag = 0;
          else
            r = min(r, c - 1);
        } else {
          if (r < c)
            flag = 0;
          else
            l = max(l, c);
        }
      }
      if ((s == 2 && a[0] == '<') || (s == 1 && a[0] == '>')) {
        if ((s == 1 && m) || (s == 2 && !m)) {
          if (r < c)
            flag = 0;
          else
            l = max(l, c + 1);
        } else {
          if (l > c)
            flag = 0;
          else
            r = min(r, c);
        }
      }
    }
    if (!flag)
      printf("Impossible\n");
    else
      printf("%d\n", l);
  }
  return 0;
}

```


### Prompt

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

Sergei B., the young coach of Pokemons, has found the big house which consists of n flats ordered in a row from left to right. It is possible to enter each flat from the street. It is possible to go out from each flat. Also, each flat is connected with the flat to the left and the flat to the right. Flat number 1 is only connected with the flat number 2 and the flat number n is only connected with the flat number n - 1.

There is exactly one Pokemon of some type in each of these flats. Sergei B. asked residents of the house to let him enter their flats in order to catch Pokemons. After consulting the residents of the house decided to let Sergei B. enter one flat from the street, visit several flats and then go out from some flat. But they won't let him visit the same flat more than once.

Sergei B. was very pleased, and now he wants to visit as few flats as possible in order to collect Pokemons of all types that appear in this house. Your task is to help him and determine this minimum number of flats he has to visit.

Input

The first line contains the integer n (1 ≤ n ≤ 100 000) — the number of flats in the house.

The second line contains the row s with the length n, it consists of uppercase and lowercase letters of English alphabet, the i-th letter equals the type of Pokemon, which is in the flat number i.

Output

Print the minimum number of flats which Sergei B. should visit in order to catch Pokemons of all types which there are in the house.

Examples

Input

3
AaA

Output

2

Input

7
bcAAcbc

Output

3

Input

6
aaBCCe

Output

5

Note

In the first test Sergei B. can begin, for example, from the flat number 1 and end in the flat number 2.

In the second test Sergei B. can begin, for example, from the flat number 4 and end in the flat number 6.

In the third test Sergei B. must begin from the flat number 2 and end in the flat number 6.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
ll gcd(ll a, ll b) {
  ll t;
  while ((t = a % b) != 0) {
    a = b;
    b = t;
  }
  return b;
}
ll fast_exp(ll base, ll n, ll m) {
  if (n == 0) return 1;
  ll t = fast_exp(base, n / 2, m);
  if (n % 2 == 0)
    return (t * t) % m;
  else
    return (((t * t) % m) * base) % m;
}
ll binary_search_ub(vector<ll> vec, ll val) {
  ll low = 0, high = vec.size() - 1;
  if (vec[high] < val) return -1;
  while (low < high) {
    ll mid = low + (high - low) / 2;
    if (vec[mid] >= val)
      high = mid;
    else
      low = mid + 1;
  }
  return high;
}
ll binary_search_lb(vector<ll> vec, ll val) {
  ll low = 0, high = vec.size() - 1;
  if (vec[low] > val) return -1;
  while (low < high) {
    ll mid = low + (high - low + 1) / 2;
    if (vec[mid] <= val)
      low = mid;
    else
      high = mid - 1;
  }
  return low;
}
int small[26][100001], large[26][100001];
set<char> S;
int low = 1, n;
void foo(int b) {
  int high = n + 1;
  while (low < high) {
    int mid = low + (high - low) / 2;
    bool flag = true;
    for (auto c : S) {
      if (c >= 'a' && small[c - 'a'][mid] - small[c - 'a'][b - 1] >= 1)
        ;
      else if (c <= 'Z' && large[c - 'A'][mid] - large[c - 'A'][b - 1] >= 1)
        ;
      else {
        flag = false;
        break;
      }
    }
    if (flag)
      high = mid;
    else
      low = mid + 1;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  string s;
  cin >> s;
  s = " " + s;
  for (int i = 1; i <= n; i++) {
    S.insert(s[i]);
    for (int j = 0; j < 26; j++) {
      if (s[i] >= 'a' && s[i] - 'a' == j) {
        small[j][i] = small[j][i - 1] + 1;
        large[j][i] = large[j][i - 1];
      } else if (s[i] <= 'Z' && s[i] - 'A' == j) {
        large[j][i] = large[j][i - 1] + 1;
        small[j][i] = small[j][i - 1];
      } else {
        small[j][i] = small[j][i - 1];
        large[j][i] = large[j][i - 1];
      }
    }
  }
  int mi = 100001;
  for (int i = 1; i <= n; i++) {
    foo(i);
    if (low == n + 1) break;
    mi = min(mi, low - i + 1);
  }
  cout << mi << "\n";
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Everybody knows that lucky numbers are positive integers that contain only lucky digits 4 and 7 in their decimal representation. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Polo the Penguin have two positive integers l and r (l < r), both of them are lucky numbers. Moreover, their lengths (that is, the number of digits in the decimal representation without the leading zeroes) are equal to each other.

Let's assume that n is the number of distinct lucky numbers, each of them cannot be greater than r or less than l, and ai is the i-th (in increasing order) number of them. Find a1·a2 + a2·a3 + ... + an - 1·an. As the answer can be rather large, print the remainder after dividing it by 1000000007 (109 + 7).

Input

The first line contains a positive integer l, and the second line contains a positive integer r (1 ≤ l < r ≤ 10100000). The numbers are given without any leading zeroes.

It is guaranteed that the lengths of the given numbers are equal to each other and that both of them are lucky numbers.

Output

In the single line print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

Examples

Input

4
7

Output

28

Input

474
777

Output

2316330

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
namespace IO {
const int sz = 1 << 15;
char inbuf[sz], outbuf[sz];
char *pinbuf = inbuf + sz;
char *poutbuf = outbuf;
inline char _getchar() {
  if (pinbuf == inbuf + sz) fread(inbuf, 1, sz, stdin), pinbuf = inbuf;
  return *(pinbuf++);
}
inline void _putchar(char x) {
  if (poutbuf == outbuf + sz) fwrite(outbuf, 1, sz, stdout), poutbuf = outbuf;
  *(poutbuf++) = x;
}
inline void flush() {
  if (poutbuf != outbuf)
    fwrite(outbuf, 1, poutbuf - outbuf, stdout), poutbuf = outbuf;
}
}  // namespace IO
inline int read() {
  int x = 0, p = 1;
  char c = IO::_getchar();
  while (c < '0' || c > '9') {
    if (c == '-') p = -1;
    c = IO::_getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = IO::_getchar();
  return x * p;
}
namespace Mymath {
long long qp(long long x, long long p, long long mod) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = ans * x % mod;
    x = x * x % mod;
    p >>= 1;
  }
  return ans;
}
long long inv(long long x, long long mod) { return qp(x, mod - 2, mod); }
long long C(long long N, long long K, long long fact[], long long mod) {
  return fact[N] * inv(fact[K], mod) % mod * inv(fact[N - K], mod) % mod;
}
template <typename Tp>
Tp gcd(Tp A, Tp B) {
  if (B == 0) return A;
  return gcd(B, A % B);
}
template <typename Tp>
Tp lcm(Tp A, Tp B) {
  return A * B / gcd(A, B);
}
};  // namespace Mymath
namespace fwt {
using namespace Mymath;
void FWT(int a[], int n, long long mod) {
  for (int d = 1; d < n; d <<= 1)
    for (int m = d << 1, i = 0; i < n; i += m)
      for (int j = 0; j < d; j++) {
        int x = a[i + j], y = a[i + j + d];
        a[i + j] = (x + y) % mod, a[i + j + d] = (x - y + mod) % mod;
      }
}
void UFWT(int a[], int n, long long mod) {
  long long rev = inv(2, mod);
  for (int d = 1; d < n; d <<= 1)
    for (int m = d << 1, i = 0; i < n; i += m)
      for (int j = 0; j < d; j++) {
        int x = a[i + j], y = a[i + j + d];
        a[i + j] = 1LL * (x + y) * rev % mod,
              a[i + j + d] = (1LL * (x - y) * rev % mod + mod) % mod;
      }
}
void solve(int a[], int b[], int n, long long mod) {
  FWT(a, n, mod);
  FWT(b, n, mod);
  for (int i = 0; i < n; i++) a[i] = 1LL * a[i] * b[i] % mod;
  UFWT(a, n, mod);
}
};  // namespace fwt
namespace Maxflow {
const int Maxn = 1005;
struct edge {
  int to, rev, cap;
  edge(int _to, int _rev, int _cap) { to = _to, rev = _rev, cap = _cap; }
};
int src = 1002, snk = 1003;
vector<edge> G[Maxn];
int dist[Maxn], seen[Maxn];
int n;
void Clear() {
  for (int i = 0; i < Maxn; i++) G[i].clear();
}
void bfs(int s) {
  for (int i = 0; i < Maxn; i++) dist[i] = -1;
  dist[s] = 0;
  queue<int> Q;
  Q.push(s);
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    for (int i = 0; i < G[x].size(); i++) {
      edge &e = G[x][i];
      if (e.cap && dist[e.to] == -1) {
        dist[e.to] = dist[x] + 1;
        Q.push(e.to);
      }
    }
  }
}
int dfs(int now, int dest, int fl) {
  if (now == dest) return fl;
  for (int &i = seen[now]; i < G[now].size(); i++) {
    edge &ed = G[now][i];
    if (ed.cap && dist[ed.to] == dist[now] + 1) {
      int f = dfs(ed.to, dest, min(fl, ed.cap));
      if (f) {
        ed.cap -= f;
        G[ed.to][ed.rev].cap += f;
        return f;
      }
    }
  }
  return 0;
}
int dinic(int s = src, int t = snk) {
  int ret = 0;
  while (1) {
    memset(seen, 0, sizeof(seen));
    bfs(s);
    if (dist[t] == -1) return ret;
    int f = dfs(s, t, 2147483647);
    while (f) {
      ret += f;
      f = dfs(s, t, 2147483647);
    }
  }
}
};  // namespace Maxflow
namespace Geometry {
struct iP {
  long long x, y;
  iP(long long _x, long long _y) { x = _x, y = _y; }
  iP() { x = y = 0; }
  iP operator+(iP p) { return iP(x + p.x, y + p.y); }
  iP operator-(iP p) { return iP(x - p.x, y - p.y); }
  iP operator*(long long k) { return iP(x * k, y * k); }
  long long det(iP p) { return x * p.y - y * p.x; }
  long long dot(iP p) { return x * p.x + y * p.y; }
  long long dist() { return x * x + y * y; }
  bool operator<(const iP &p) const {
    if (x != p.x) return x < p.x;
    return y < p.y;
  }
};
struct dP {
  double x, y;
  dP(double _x, double _y) { x = _x, y = _y; }
  dP() { x = y = 0.0; }
  dP operator+(dP p) { return dP(x + p.x, y + p.y); }
  dP operator-(dP p) { return dP(x - p.x, y - p.y); }
  dP operator*(double k) { return dP(x * k, y * k); }
  double det(dP p) { return x * p.y - y * p.x; }
  double dot(dP p) { return x * p.x + y * p.y; }
  double dist() { return x * x + y * y; }
  bool operator<(const dP &p) const {
    if (x != p.x) return x < p.x;
    return y < p.y;
  }
};
vector<iP> convex_hull(iP X[], int l) {
  vector<iP> ret;
  sort(X + 1, X + 1 + l);
  ret.push_back(X[1]);
  for (int i = 2; i <= l; i++) {
    while (ret.size() >= 2 &&
           (ret[ret.size() - 2] - X[i]).det(ret[ret.size() - 1] - X[i]) >= 0) {
      ret.pop_back();
    }
    ret.push_back(X[i]);
  }
  int rs = ret.size() + 1;
  for (int i = l - 1; i >= 1; i--) {
    while (ret.size() >= rs &&
           (ret[ret.size() - 2] - X[i]).det(ret[ret.size() - 1] - X[i]) >= 0) {
      ret.pop_back();
    }
    ret.push_back(X[i]);
  }
  return ret;
}
};  // namespace Geometry
using namespace Mymath;
const int Maxn = 100005;
const long long mod = 1e9 + 7;
char tmp[Maxn];
long long p10[Maxn * 2], S[Maxn], S_2[Maxn];
int n;
struct lucky {
  int val[Maxn];
  lucky() { ; }
  void Plus() {
    for (int i = n - 1; i >= 0; i--) {
      if (val[i] == 4) {
        val[i] = 7;
        return;
      }
      val[i] = 4;
    }
  }
  void Minus() {
    for (int i = n - 1; i >= 0; i--) {
      if (val[i] == 7) {
        val[i] = 4;
        return;
      }
      val[i] = 7;
    }
  }
} L, R;
void _init() {
  p10[0] = 1;
  for (int i = 1; i < Maxn * 2; i++) {
    p10[i] = p10[i - 1] * 10 % mod;
  }
  S[0] = 0;
  for (int i = 1; i < Maxn; i++) {
    S[i] = S[i - 1] * 2 + p10[i - 1] * 11 % mod * qp(2, i - 1, mod) % mod;
    S[i] %= mod;
  }
  S_2[0] = 0;
  for (int i = 1; i < Maxn; i++) {
    S_2[i] = S_2[i - 1] * 2 + p10[2 * (i - 1)] * 65 % mod * qp(2, i - 1, mod) +
             22LL * p10[i - 1] % mod * S[i - 1];
    S_2[i] %= mod;
  }
}
long long Sqr(long long x) { return x * x % mod; }
long long sqrsum(lucky X) {
  long long ret = 0;
  long long pre = 0;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    if (X.val[i] == 4) {
      pre += 4 * p10[n - i - 1];
      pre %= mod;
      flag = true;
    } else {
      pre += 4 * p10[n - i - 1];
      pre %= mod;
      ret += Sqr(pre) * qp(2, n - i - 1, mod);
      ret %= mod;
      ret += S_2[n - i - 1];
      ret += pre * 2 * S[n - i - 1];
      ret %= mod;
      pre += 3 * p10[n - i - 1];
      pre %= mod;
    }
  }
  if (!flag) return 0;
  ret += pre * pre;
  ret %= mod;
  return ret;
}
long long rangesum[Maxn][2][2], rangecnt[Maxn];
bool issg[Maxn];
int main() {
  _init();
  scanf("%s", tmp);
  n = strlen(tmp);
  for (int i = 0; i < n; i++) {
    L.val[i] = tmp[i] - '0';
  }
  scanf("%s", tmp);
  for (int i = 0; i < n; i++) {
    R.val[i] = tmp[i] - '0';
  }
  R.Minus();
  L.Minus();
  long long ans = sqrsum(R) - sqrsum(L);
  ans = (ans % mod + mod) % mod;
  L.Plus();
  long long nowL = 0, nowR = 0;
  rangecnt[0] = 1;
  bool Sig = true;
  for (int i = 1; i <= n; i++) {
    long long ini =
        rangesum[i - 1][0][0] * 2 + 11 * rangecnt[i - 1] % mod * p10[n - i];
    rangecnt[i] = rangecnt[i - 1] * 2;
    rangecnt[i] %= mod;
    ini %= mod;
    nowL = nowL + p10[n - i] * L.val[i - 1];
    nowL %= mod;
    nowR = nowR + p10[n - i] * R.val[i - 1];
    nowR %= mod;
    if (L.val[i - 1] == 7) {
      ini -= nowL - 3 * p10[n - i];
      rangecnt[i]--;
    }
    if (R.val[i - 1] == 4) {
      ini -= nowR + 3 * p10[n - i];
      rangecnt[i]--;
    }
    if (rangecnt[i] != 1) Sig = false;
    ini = (ini % mod + mod) % mod;
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        rangesum[i][j][k] = ini - ((j == 0) ? 0 : nowL) - ((k == 0) ? 0 : nowR);
        rangesum[i][j][k] = (rangesum[i][j][k] % mod + mod) % mod;
        if (Sig && j == 1 && k == 1) rangesum[i][j][k] = 0;
      }
    }
    issg[i] = Sig;
  }
  long long dlt = 0;
  int l = 0, r = 0;
  long long Delta = 3;
  long long nowval = 4;
  for (int i = n - 1; i >= 0; i--) {
    int curl = l, curr = r;
    if (L.val[i] == 7) {
      curl = 1;
    }
    if (R.val[i] == 7) {
      curr = 0;
    }
    long long fuck = rangecnt[i];
    if (curl || curr) {
      if (issg[i]) {
        fuck = 0;
      } else {
        fuck = fuck - curl - curr;
        if (fuck < 0) fuck += mod;
      }
    }
    dlt += Delta * (rangesum[i][curl][curr] + fuck * nowval % mod);
    dlt %= mod;
    if (L.val[i] == 4) {
      l = 0;
    }
    if (R.val[i] == 4) {
      r = 1;
    }
    Delta = Delta * 10 - 3;
    Delta = (Delta % mod + mod) % mod;
    nowval = nowval * 10 + 7;
    nowval %= mod;
  }
  ans += dlt;
  ans %= mod;
  printf("%lld\n", ans);
  return ~~(0 ^ 0 ^ 0);
}

```


### Prompt

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

This time our child has a simple polygon. He has to find the number of ways to split the polygon into non-degenerate triangles, each way must satisfy the following requirements:

  * each vertex of each triangle is one of the polygon vertex;
  * each side of the polygon must be the side of exactly one triangle;
  * the area of intersection of every two triangles equals to zero, and the sum of all areas of triangles equals to the area of the polygon;
  * each triangle must be completely inside the polygon;
  * each side of each triangle must contain exactly two vertices of the polygon.

The picture below depicts an example of a correct splitting.

<image>

Please, help the child. Calculate the described number of ways modulo 1000000007 (109 + 7) for him.

Input

The first line contains one integer n (3 ≤ n ≤ 200) — the number of vertices of the polygon. Then follow n lines, each line containing two integers. The i-th line contains xi, yi (|xi|, |yi| ≤ 107) — the i-th vertex of the polygon in clockwise or counterclockwise order.

It's guaranteed that the polygon is simple.

Output

Output the number of ways modulo 1000000007 (109 + 7).

Examples

Input

4
0 0
0 1
1 1
1 0

Output

2

Input

4
0 0
1 0
0 1
-1 0

Output

1

Input

5
0 0
1 0
1 1
0 1
-2 -1

Output

3

Note

In the first sample, there are two possible splittings:

<image>

In the second sample, there are only one possible splitting:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
const int mo = 1e9 + 7;
long long dp[205][205];
struct point {
  int x, y;
  void input() { scanf("%d%d", &x, &y); }
  point operator-(const point &a) {
    point ret;
    ret.x = x - a.x;
    ret.y = y - a.y;
    return ret;
  }
} p[205];
long long cross(point a, point b, point c) {
  return 1ll * (b.x - a.x) * (c.y - a.y) - 1ll * (b.y - a.y) * (c.x - a.x);
}
long long dfs(int l, int r) {
  if (l + 1 == r) {
    dp[l][r] = 1;
  }
  if (dp[l][r] != -1) return dp[l][r];
  dp[l][r] = 0;
  for (int i = l + 1; i < r; ++i) {
    if (cross(p[l], p[r], p[i]) >= 0) continue;
    dp[l][r] = (dp[l][r] + dfs(l, i) * dfs(i, r) % mo) % mo;
  }
  return dp[l][r];
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    p[i].input();
  }
  double ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    ans += cross(p[0], p[i], p[i + 1]);
  }
  if (ans < 0) {
    reverse(p, p + n);
  }
  memset(dp, -1, sizeof(dp));
  dfs(0, n - 1);
  printf("%d\n", (int)dp[0][n - 1]);
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

There were n groups of students which came to write a training contest. A group is either one person who can write the contest with anyone else, or two people who want to write the contest in the same team.

The coach decided to form teams of exactly three people for this training. Determine the maximum number of teams of three people he can form. It is possible that he can't use all groups to form teams. For groups of two, either both students should write the contest, or both should not. If two students from a group of two will write the contest, they should be in the same team.

Input

The first line contains single integer n (2 ≤ n ≤ 2·105) — the number of groups.

The second line contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 2), where ai is the number of people in group i.

Output

Print the maximum number of teams of three people the coach can form.

Examples

Input

4
1 1 2 1

Output

1

Input

2
2 2

Output

0

Input

7
2 2 2 1 1 1 1

Output

3

Input

3
1 1 1

Output

1

Note

In the first example the coach can form one team. For example, he can take students from the first, second and fourth groups.

In the second example he can't make a single team.

In the third example the coach can form three teams. For example, he can do this in the following way:

  * The first group (of two people) and the seventh group (of one person),
  * The second group (of two people) and the sixth group (of one person),
  * The third group (of two people) and the fourth group (of one person).

### Response

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

```


### Prompt

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

A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.

The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions:

  * Is it true that y is strictly larger than number x?
  * Is it true that y is strictly smaller than number x?
  * Is it true that y is larger than or equal to number x?
  * Is it true that y is smaller than or equal to number x?

On each question the host answers truthfully, "yes" or "no".

Given the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print "Impossible".

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is:

  * ">" (for the first type queries),
  * "<" (for the second type queries),
  * ">=" (for the third type queries),
  * "<=" (for the fourth type queries).

All values of x are integer and meet the inequation  - 109 ≤ x ≤ 109. The answer is an English letter "Y" (for "yes") or "N" (for "no").

Consequtive elements in lines are separated by a single space.

Output

Print any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation  - 2·109 ≤ y ≤ 2·109. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes).

Examples

Input

4
>= 1 Y
< 3 N
<= -3 N
> 55 N

Output

17

Input

2
> 100 Y
< -100 Y

Output

Impossible

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFL = 0x3f3f3f3f3f3f3f3f;
int read();
char gchar();
const int maxn = 10000 + 50;
char FALSE[20] = "Impossible";
int main() {
  int n;
  scanf("%d", &n);
  int lans = -2e9;
  int rans = 2e9;
  char a, b, c;
  int d;
  for (int i = 1; i <= n; ++i) {
    a = gchar();
    b = getchar();
    scanf("%d", &d);
    c = gchar();
    if (c == 'Y') {
      if (a == '>') {
        if (b == ' ')
          lans = max(lans, d + 1);
        else
          lans = max(d, lans);
      } else {
        if (b == ' ')
          rans = min(d - 1, rans);
        else
          rans = min(d, rans);
      }
    } else {
      if (a == '<') {
        if (b == ' ')
          lans = max(lans, d);
        else
          lans = max(lans, d + 1);
      } else {
        if (b == ' ')
          rans = min(rans, d);
        else
          rans = min(rans, d - 1);
      }
    }
    if (rans < lans) {
      printf("%s\n", FALSE);
      exit(0);
    }
  }
  printf("%d\n", lans);
  return 0;
}
int read() {
  int ret = 0, flag = 1;
  char c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
  if (c == '-')
    flag = -1;
  else {
    ret = ret * 10;
    ret = ret + (c - '0');
  }
  c = getchar();
  while (c != ' ' && c != '\n' && '0' <= c && c <= '9') {
    ret = ret * 10;
    ret = ret + (c - '0');
    c = getchar();
  }
  return ret * flag;
}
char gchar() {
  char ret = getchar();
  while (ret == ' ' || ret == '\n') ret = getchar();
  return ret;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Problem Statement

There is a maze which can be described as a W \times H grid. The upper-left cell is denoted as (1, 1), and the lower-right cell is (W, H). You are now at the cell (1, 1) and have to go to the cell (W, H). However, you can only move to the right adjacent cell or to the lower adjacent cell. The following figure is an example of a maze.

...#......
a###.#####
.bc...A...
.#C#d#.#
.#B#.#.###
.#...#e.D.
.#A..###.#
..e.c#..E.
d###.#
....#.#.#
E...d.C.

In the maze, some cells are free (denoted by `.`) and some cells are occupied by rocks (denoted by `#`), where you cannot enter. Also there are jewels (denoted by lowercase alphabets) in some of the free cells and holes to place jewels (denoted by uppercase alphabets). Different alphabets correspond to different types of jewels, i.e. a cell denoted by `a` contains a jewel of type A, and a cell denoted by `A` contains a hole to place a jewel of type A. It is said that, when we place a jewel to a corresponding hole, something happy will happen.

At the cells with jewels, you can choose whether you pick a jewel or not. Similarly, at the cells with holes, you can choose whether you place a jewel you have or not. Initially you do not have any jewels. You have a very big bag, so you can bring arbitrarily many jewels. However, your bag is a stack, that is, you can only place the jewel that you picked up last.

On the way from cell (1, 1) to cell (W, H), how many jewels can you place to correct holes?

Input

The input contains a sequence of datasets. The end of the input is indicated by a line containing two zeroes. Each dataset is formatted as follows.

H W
C_{11} C_{12} ... C_{1W}
C_{21} C_{22} ... C_{2W}
...
C_{H1} C_{H2} ... C_{HW}

Here, H and W are the height and width of the grid. You may assume 1 \leq W, H \leq 50. The rest of the datasets consists of H lines, each of which is composed of W letters. Each letter C_{ij} specifies the type of the cell (i, j) as described before. It is guaranteed that C_{11} and C_{WH} are never `#`.

You may also assume that each lowercase or uppercase alphabet appear at most 10 times in each dataset.

Output

For each dataset, output the maximum number of jewels that you can place to corresponding holes. If you cannot reach the cell (W, H), output -1.

Examples

Input

3 3
ac#
b#C
.BA
3 3
aaZ
a#Z
aZZ
3 3
..#
.#.
#..
1 50
abcdefghijklmnopqrstuvwxyYXWVUTSRQPONMLKJIHGFEDCBA
1 50
aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY
1 50
abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXY
1 50
aaaaaaaaaabbbbbbbbbbcccccCCCCCBBBBBBBBBBAAAAAAAAAA
10 10
...#......
a###.#####
.bc...A...
##.#C#d#.#
.#B#.#.###
.#...#e.D.
.#A..###.#
..e.c#..E.
####d###.#
##E...D.C.
0 0

Output

2
0
-1
25
25
1
25
4

Input

3 3
ac#
b#C
.BA
3 3
aaZ
a#Z
aZZ
3 3
..#
.#.
..
1 50
abcdefghijklmnopqrstuvwxyYXWVUTSRQPONMLKJIHGFEDCBA
1 50
aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY
1 50
abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXY
1 50
aaaaaaaaaabbbbbbbbbbcccccCCCCCBBBBBBBBBBAAAAAAAAAA
10 10
...#......
a###.#####
.bc...A...
.#C#d#.#
.#B#.#.###
.#...#e.D.
.#A..###.#
..e.c#..E.
d###.#
E...D.C.
0 0

Output

2
0
-1
25
25
1
25
4

### Response

```cpp
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
vector<vector<vector<P> > >v;
int dp[51][51][51][51];
string s[51];
int h,w;
inline int dfs(int ly,int lx,int ry,int rx){

  int res=-1e7;

  if(ly<0||ry<0||ly>=h||ry>=h)return -1e7;
  if(lx<0||rx<0||lx>=w||rx>=w)return -1e7;
  if(s[ly][lx]=='#'||s[ry][rx]=='#')return -1e7;
  if(ly==ry&&lx==rx)return dp[ly][lx][ry][rx]=0;
  if(ly==ry&&lx==rx+1)return dp[ly][lx][ry][rx]=0;
  if(ly==ry+1&&lx==rx)return dp[ly][lx][ry][rx]=0;
  if(ly==ry+1&&lx==rx+1)return dp[ly][lx][ry][rx]=0;
  if(ly>ry||lx>rx)return -1e7;
  if(dp[ly][lx][ry][rx]!=-1e8)return dp[ly][lx][ry][rx];

  res=max(res,dfs(ly+1,lx,ry,rx));
  res=max(res,dfs(ly,lx+1,ry,rx));
  res=max(res,dfs(ly,lx,ry-1,rx));
  res=max(res,dfs(ly,lx,ry,rx-1));

  if(islower(s[ly][lx])){

    if(isupper(s[ry][rx])&&s[ly][lx]==tolower(s[ry][rx])){
      res=max(res,dfs(ly+1,lx,ry-1,rx)+1);
      res=max(res,dfs(ly,lx+1,ry-1,rx)+1);
      res=max(res,dfs(ly+1,lx,ry,rx-1)+1);
      res=max(res,dfs(ly,lx+1,ry,rx-1)+1);
    }

    else r(i,v[ly][lx].size()){
      int y=v[ly][lx][i].first;
      int x=v[ly][lx][i].second;
      if(!(ly<=y&&y<=ry&&lx<=x&&x<=rx))continue;
      res=max(res,dfs(ly,lx,y,x)+dfs(y,x,ry,rx));
    }

  }

  return dp[ly][lx][ry][rx]=res;
}
int main(){
  while(cin>>h>>w,h){
    r(i,51)r(j,51)r(k,51)r(l,51)dp[i][j][k][l]=-1e8;
    v.clear();
    v.resize(h,vector<vector<P> >(w));
    r(i,h)cin>>s[i];
    r(i,h)r(j,w)r(y,h)r(x,w){
      if(i<=y&&j<=x){
        if(islower(s[i][j])&&isupper(s[y][x])){
          if(s[i][j]==tolower(s[y][x])){
            v[i][j].push_back(P(y,x));
          }
        }
      }
    }
    cout<<(dfs(0,0,h-1,w-1)<0?-1:dp[0][0][h-1][w-1])<<endl;
  }
}

```


### Prompt

Please create a solution in CPP to the following problem:

Under the command "Save Sergeant Ryan," Aiz's rescue team fought fierce battles with enemy forces in the floating city of Lee, Germany. They successfully joined the sergeant, but there were many enemy tanks and they could not call a rescue herio. So, in order to confuse the enemy tanks, they decided to carry out an operation to blow up all the bridges in the city.

The operation was immediately communicated to HQ and preparations for a rescue helicopter were underway. In order to fly the rescue herio, you have to predict when all the bridges will be blown up. As a military programmer, your mission is to calculate the time the rescue team will need to blow up all the bridges.

The floating city is made up of N islands, with a bridge between the islands. All the islands are connected in a tree shape (see the figure below). There is only one route from one island to another. It takes a fixed amount of time to cross each bridge, and it is possible to cross the bridge in either direction at that time.

Rescue units do not have the means to move on the water, such as boats, so the only way to move between islands is through a bridge. Rescue units can instantly blow up the bridges adjacent to the island at that time. What is the minimum time required for a rescue unit to blow up all the bridges? However, we do not consider the travel time within the island.

Create a program that inputs the number of islands and information on each bridge and outputs the minimum time required to blow up all the bridges. Each island is represented by a number from 1 to N. There are N-1 bridges. The bridge information consists of the numbers (a, b) of the two islands adjacent to the bridge and the time t required to cross the bridge. Rescue units shall start on the island with island number 1.

<image>

Input

A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format.

N
a1 b1 t1
a2 b2 t2
::
aN-1 bN-1 tN-1

All inputs are given as integers. The number of islands N (2 ≤ N ≤ 20) is given on the first line.

The following N-1 line gives information on the i-th bridge. ai, bi, ti (1 ≤ ti ≤ 500) means that we can move between island ai and island bi in time ti through the i-th bridge.

The number of datasets does not exceed 100.

Output

For each dataset, print the minimum time required to blow up all the bridges on one line.

Example

Input

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

Output

12

### Response

```cpp
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<int, int> >X[20], Y[20]; int N, A, B, C, dist[20];
int main() {
	while (true) {
		for (int i = 0; i < 20; i++) { X[i].clear(); Y[i].clear(); dist[i] = 1 << 30; }
		cin >> N; int G = 0, J = 0; dist[0] = 0; if (N == 0)break;
		for (int i = 0; i < N - 1; i++) {
			cin >> A >> B >> C; A--; B--; X[A].push_back(make_pair(B, C)); X[B].push_back(make_pair(A, C));
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < X[i].size(); j++) {
				int st = i, go = X[i][j].first;
				if ((X[st].size() == 1 && st >= 1) || (X[go].size() == 1 && go >= 1))continue;
				Y[st].push_back(X[i][j]); G += X[i][j].second;
			}
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < Y[j].size(); k++) {
					dist[Y[j][k].first] = min(dist[Y[j][k].first], dist[j] + Y[j][k].second);
				}
			}
		}
		for (int i = 0; i < N; i++) { if (dist[i] < (1 << 30))J = max(J, dist[i]); }
		cout << G - J << endl;
	}
	return 0;
}
```


### Prompt

Generate a cpp solution to the following problem:

Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 percent. You can connect charger to a joystick only at the beginning of each minute. In one minute joystick either discharges by 2 percent (if not connected to a charger) or charges by 1 percent (if connected to a charger).

Game continues while both joysticks have a positive charge. Hence, if at the beginning of minute some joystick is charged by 1 percent, it has to be connected to a charger, otherwise the game stops. If some joystick completely discharges (its charge turns to 0), the game also stops.

Determine the maximum number of minutes that game can last. It is prohibited to pause the game, i. e. at each moment both joysticks should be enabled. It is allowed for joystick to be charged by more than 100 percent.

Input

The first line of the input contains two positive integers a1 and a2 (1 ≤ a1, a2 ≤ 100), the initial charge level of first and second joystick respectively.

Output

Output the only integer, the maximum number of minutes that the game can last. Game continues until some joystick is discharged.

Examples

Input

3 5

Output

6

Input

4 4

Output

5

Note

In the first sample game lasts for 6 minute by using the following algorithm:

  * at the beginning of the first minute connect first joystick to the charger, by the end of this minute first joystick is at 4%, second is at 3%;
  * continue the game without changing charger, by the end of the second minute the first joystick is at 5%, second is at 1%;
  * at the beginning of the third minute connect second joystick to the charger, after this minute the first joystick is at 3%, the second one is at 2%;
  * continue the game without changing charger, by the end of the fourth minute first joystick is at 1%, second one is at 3%;
  * at the beginning of the fifth minute connect first joystick to the charger, after this minute the first joystick is at 2%, the second one is at 1%;
  * at the beginning of the sixth minute connect second joystick to the charger, after this minute the first joystick is at 0%, the second one is at 2%.

After that the first joystick is completely discharged and the game is stopped.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  int ans = 0;
  while (true) {
    if (a > b) swap(a, b);
    a += 1;
    b -= 2;
    if (b == 0) {
      ans++;
      break;
    }
    if (b < 0) break;
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

You are given an array a of length n that consists of zeros and ones.

You can perform the following operation multiple times. The operation consists of two steps:

  1. Choose three integers 1 ≤ x < y < z ≤ n, that form an arithmetic progression (y - x = z - y).
  2. Flip the values a_x, a_y, a_z (i.e. change 1 to 0, change 0 to 1).

Determine if it is possible to make all elements of the array equal to zero. If yes, print the operations that lead the the all-zero state. Your solution should not contain more than (⌊ n/3 ⌋ + 12) operations. Here ⌊ q ⌋ denotes the number q rounded down. We can show that it is possible to make all elements equal to zero in no more than this number of operations whenever it is possible to do so at all.

Input

The first line contains a single integer n (3 ≤ n ≤ 10^5) — the length of the array.

The second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 1) — the elements of the array.

Output

Print "YES" (without quotes) if the answer exists, otherwise print "NO" (without quotes). You can print each letter in any case (upper or lower).

If there is an answer, in the second line print an integer m (0 ≤ m ≤ (⌊ n/3 ⌋ + 12)) — the number of operations in your answer.

After that in (i + 2)-th line print the i-th operations — the integers x_i, y_i, z_i. You can print them in arbitrary order.

Examples

Input

5
1 1 0 1 1

Output

YES
2
1 3 5
2 3 4

Input

3
0 1 0

Output

NO

Note

In the first sample the shown output corresponds to the following solution:

  * 1 1 0 1 1 (initial state);
  * 0 1 1 1 0 (the flipped positions are the first, the third and the fifth elements);
  * 0 0 0 0 0 (the flipped positions are the second, the third and the fourth elements).

Other answers are also possible. In this test the number of operations should not exceed ⌊ 5/3 ⌋ + 12 = 1 + 12 = 13.

In the second sample the only available operation is to flip all the elements. This way it is only possible to obtain the arrays 0 1 0 and 1 0 1, but it is impossible to make all elements equal to zero.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') f = -1, ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + ch - 48, ch = getchar();
  return x * f;
}
int n;
int a[N];
int m = 0;
struct Perf {
  int x, y, z;
  Perf() {}
  Perf(int _x, int _y, int _z) { x = _x, y = _y, z = _z; }
} p[N];
int find(int x, int dx) {
  while (!a[x] && 1 <= x && x <= n) x += dx;
  return x;
}
void pef(int x, int y, int z) {
  a[x] ^= 1, a[y] ^= 1, a[z] ^= 1;
  p[++m] = Perf(x, y, z);
}
int gettot() {
  int tot = 0;
  for (int i = 1; i <= n; i++) tot += a[i];
  return tot;
}
void del(int x) {
  pef(x - 6, x - 3, x);
  pef(x - 5, x - 4, x - 3);
  pef(x - 6, x - 5, x - 4);
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  int L = 1, R = n;
  while (L + 2 <= R) {
    if (a[L] && a[L + 1] && a[L + 2]) {
      pef(L, L + 1, L + 2);
      L += 3;
      continue;
    }
    if (a[R] && a[R - 1] && a[R - 2]) {
      pef(R - 2, R - 1, R);
      a[R - 2] = a[R - 1] = a[R] = 0;
      R -= 3;
    }
    if (!a[L]) {
      L++;
      continue;
    }
    if (!a[R]) {
      R--;
      continue;
    }
    int l = find(L + 1, 1);
    int r = find(R - 1, -1);
    if (l == R) break;
    if (l != L + 1 && 2 * l - L <= R) {
      pef(L, l, l * 2 - L);
      continue;
    } else if (r != R - 1 && 2 * r - R >= L) {
      pef(2 * r - R, r, R);
      continue;
    } else if (l == L + 1 && r == R - 1) {
      if ((R - L) % 2 == 0) {
        int m = (L + R) / 2;
        pef(L, m, R);
        pef(L + 1, m, R - 1);
        continue;
      } else {
        int m1 = (L + R) / 2, m2 = m1 + 1;
        pef(L, m1, R - 1);
        pef(L + 1, m2, R);
        continue;
      }
    } else if (l == L + 1 && 2 * r - R >= L) {
      pef(2 * r - R, r, R);
      continue;
    } else if (r == R - 1 && 2 * l - L <= R) {
      pef(L, l, l * 2 - L);
      continue;
    } else if (l == L + 1)
      pef(L, l, l + 1);
    else if (r == R - 1)
      pef(r - 1, r, R);
    else
      break;
  }
  if (gettot() > 0) {
    int l = find(1, 1);
    int r = find(n, -1);
    if (l != r) {
      while (r + 3 <= min(9, n)) {
        pef(r, r + 1, r + 2);
        pef(r + 1, r + 2, r + 3);
        r += 3;
      }
      while (l + 3 <= min(9, n)) {
        pef(l, l + 1, l + 2);
        pef(l + 1, l + 2, l + 3);
        l += 3;
      }
      if (gettot()) {
        if (l >= 7 && r >= 7) {
          del(l);
          del(r);
        } else {
          if ((l + r) % 2 == 0) return puts("NO"), 0;
          if (l + 1 != r) pef(l + 1, (l + r + 1) / 2, r);
          if (l + 2 <= n)
            pef(l, l + 1, l + 2), l = r = l + 2;
          else
            pef(l - 1, l, l + 1), l = r = l - 1;
        }
      }
    }
    if (gettot()) {
      while (l + 3 <= min(9, n)) {
        pef(l, l + 1, l + 2);
        pef(l + 1, l + 2, l + 3);
        l += 3;
      }
      if (l < 7) return puts("NO"), 0;
      del(l);
    }
  }
  puts("YES");
  printf("%d\n", m);
  for (int i = 1; i <= m; i++) printf("%d %d %d\n", p[i].x, p[i].y, p[i].z);
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

[Æsir - CHAOS](https://soundcloud.com/kivawu/aesir-chaos)

[Æsir - V.](https://soundcloud.com/kivawu/aesir-v)

"Everything has been planned out. No more hidden concerns. The condition of Cytus is also perfect.

The time right now...... 00:01:12......

It's time."

The emotion samples are now sufficient. After almost 3 years, it's time for Ivy to awake her bonded sister, Vanessa.

The system inside A.R.C.'s Library core can be considered as an undirected graph with infinite number of processing nodes, numbered with all positive integers (1, 2, 3, …). The node with a number x (x > 1), is directly connected with a node with number (x)/(f(x)), with f(x) being the lowest prime divisor of x.

Vanessa's mind is divided into n fragments. Due to more than 500 years of coma, the fragments have been scattered: the i-th fragment is now located at the node with a number k_i! (a factorial of k_i).

To maximize the chance of successful awakening, Ivy decides to place the samples in a node P, so that the total length of paths from each fragment to P is smallest possible. If there are multiple fragments located at the same node, the path from that node to P needs to be counted multiple times.

In the world of zeros and ones, such a requirement is very simple for Ivy. Not longer than a second later, she has already figured out such a node.

But for a mere human like you, is this still possible?

For simplicity, please answer the minimal sum of paths' lengths from every fragment to the emotion samples' assembly node P.

Input

The first line contains an integer n (1 ≤ n ≤ 10^6) — number of fragments of Vanessa's mind.

The second line contains n integers: k_1, k_2, …, k_n (0 ≤ k_i ≤ 5000), denoting the nodes where fragments of Vanessa's mind are located: the i-th fragment is at the node with a number k_i!.

Output

Print a single integer, denoting the minimal sum of path from every fragment to the node with the emotion samples (a.k.a. node P).

As a reminder, if there are multiple fragments at the same node, the distance from that node to P needs to be counted multiple times as well.

Examples

Input

3
2 1 4

Output

5

Input

4
3 1 4 4

Output

6

Input

4
3 1 4 1

Output

6

Input

5
3 1 4 1 5

Output

11

Note

Considering the first 24 nodes of the system, the node network will look as follows (the nodes 1!, 2!, 3!, 4! are drawn bold):

<image>

For the first example, Ivy will place the emotion samples at the node 1. From here:

  * The distance from Vanessa's first fragment to the node 1 is 1.
  * The distance from Vanessa's second fragment to the node 1 is 0.
  * The distance from Vanessa's third fragment to the node 1 is 4.

The total length is 5.

For the second example, the assembly node will be 6. From here:

  * The distance from Vanessa's first fragment to the node 6 is 0.
  * The distance from Vanessa's second fragment to the node 6 is 2.
  * The distance from Vanessa's third fragment to the node 6 is 2.
  * The distance from Vanessa's fourth fragment to the node 6 is again 2.

The total path length is 6.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long p[5000], elem, fact[700], f[5010], n, is_now[5010];
long long mini, a[5010][700];
long long calcul(long long x) {
  long long i;
  long long sol = 0, val, now;
  for (i = 1; i <= elem; i++) {
    val = p[i];
    now = 0;
    while (val <= x) {
      now += x / val;
      val = val * p[i];
    }
    a[x][i] = now;
    sol += now;
  }
  return sol;
}
long long verif(long long val) {
  long long i;
  long long sol = 0;
  for (i = 1; i <= 5000; i++) {
    if (!f[i]) continue;
    if (fact[val] <= a[i][val] && is_now[i]) sol += f[i];
  }
  return sol;
}
void solve(long long poz, long long sol) {
  long long i;
  long long here;
  for (i = elem; i; i--) {
    fact[i]++;
    here = verif(i);
    if (here > n - here) {
      sol = sol - here + n - here;
      mini = min(mini, sol);
      for (int j = 1; j <= 5000; j++) {
        if (!f[j]) continue;
        if (fact[i] > a[j][i] && is_now[j]) is_now[j] = 0;
      }
      i++;
    } else {
      fact[i]--;
      for (int j = 1; j <= 5000; j++) {
        if (!f[j]) continue;
        if (fact[i] != a[j][i] && is_now[j]) is_now[j] = 0;
      }
    }
  }
}
int main() {
  FILE *fin = stdin;
  FILE *fout = stdout;
  long long i, d, x, sol;
  fscanf(fin, "%lld", &n);
  for (i = 1; i <= n; i++) {
    fscanf(fin, "%lld", &x);
    f[x]++;
  }
  is_now[1] = 1;
  for (i = 2; i <= 5000; i++) {
    is_now[i] = 1;
    d = 2;
    while (d * d <= i && i % d != 0) {
      d++;
    }
    if (d * d > i) p[++elem] = i;
  }
  sol = 0;
  for (i = 1; i <= 5000; i++) sol = sol + calcul(i) * f[i];
  mini = sol;
  solve(elem, sol);
  fprintf(fout, "%lld", mini);
  return 0;
}

```