### Prompt

Please formulate a Cpp solution to the following problem:

The Little Elephant loves the LCM (least common multiple) operation of a non-empty set of positive integers. The result of the LCM operation of k positive integers x1, x2, ..., xk is the minimum positive integer that is divisible by each of numbers xi.

Let's assume that there is a sequence of integers b1, b2, ..., bn. Let's denote their LCMs as lcm(b1, b2, ..., bn) and the maximum of them as max(b1, b2, ..., bn). The Little Elephant considers a sequence b good, if lcm(b1, b2, ..., bn) = max(b1, b2, ..., bn).

The Little Elephant has a sequence of integers a1, a2, ..., an. Help him find the number of good sequences of integers b1, b2, ..., bn, such that for all i (1 ≤ i ≤ n) the following condition fulfills: 1 ≤ bi ≤ ai. As the answer can be rather large, print the remainder from dividing it by 1000000007 (109 + 7).

Input

The first line contains a single positive integer n (1 ≤ n ≤ 105) — the number of integers in the sequence a. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 105) — sequence a.

Output

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

Examples

Input

4
1 4 3 2

Output

15

Input

2
6 3

Output

13

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
const long long md = 1e9 + 7;
int bit[maxn];
long long l[maxn];
vector<int> dv;
int occ[maxn];
long long modexp(long long a, long long ex) {
  long long ans = 1;
  while (ex > 0) {
    if ((ex & 1) == 1) ans = (ans * a) % md;
    a = (a * a) % md;
    ex >>= 1;
  }
  return ans;
}
int qry(int x) {
  int ans = 0;
  while (x > 0) {
    ans += bit[x];
    x -= x & (-x);
  }
  return ans;
}
void upd(int x, int v) {
  while (x < maxn) {
    bit[x] += v;
    x += x & (-x);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  fill(occ, occ + maxn, 0);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    occ[x]++;
  }
  int lft = n;
  long long ans = 0;
  for (int v = 1; v < maxn; v++) {
    dv.clear();
    for (int p = 1; p * p <= v; p++) {
      if (v % p != 0) continue;
      dv.push_back(p);
      if (v / p != p) dv.push_back(v / p);
    }
    sort(dv.begin(), dv.end());
    int cur = 0;
    long long c = 1, d = 1;
    for (int j = dv.size() - 1; j >= 0; j--) {
      int y = dv[j];
      int q = qry(y);
      c = (c * modexp(j + 1, q - cur)) % md;
      cur = q;
    }
    lft -= occ[v - 1];
    upd(1, -lft);
    upd(v, lft);
    upd(1, lft);
    upd(v + 1, -lft);
    cur = 0;
    for (int j = dv.size() - 1; j >= 0; j--) {
      int y = dv[j];
      int q = qry(y);
      d = (d * modexp(j + 1, q - cur)) % md;
      cur = q;
    }
    ans += d - c;
  }
  if (ans < 0) {
    ans = (-ans) % md;
    ans = (md - ans) % md;
  } else
    ans %= md;
  printf("%lld", (ans + 1) % md);
  printf("\n");
}

```


### Prompt

Create a solution in cpp for the following problem:

Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a grid:

    ABCDEFGHIJKLM
    NOPQRSTUVWXYZ

We say that two tiles are adjacent if they share a side or a corner. In the example grid above, the tile with the letter 'A' is adjacent only to the tiles with letters 'B', 'N', and 'O'. A tile is not adjacent to itself.

A sequence of tiles is called a path if each tile in the sequence is adjacent to the tile which follows it (except for the last tile in the sequence, which of course has no successor). In this example, "ABC" is a path, and so is "KXWIHIJK". "MAB" is not a path because 'M' is not adjacent to 'A'. A single tile can be used more than once by a path (though the tile cannot occupy two consecutive places in the path because no tile is adjacent to itself).

You’re given a string s which consists of 27 upper-case English letters. Each English letter occurs at least once in s. Find a grid that contains a path whose tiles, viewed in the order that the path visits them, form the string s. If there’s no solution, print "Impossible" (without the quotes).

Input

The only line of the input contains the string s, consisting of 27 upper-case English letters. Each English letter occurs at least once in s.

Output

Output two lines, each consisting of 13 upper-case English characters, representing the rows of the grid. If there are multiple solutions, print any of them. If there is no solution print "Impossible".

Examples

Input

ABCDEFGHIJKLMNOPQRSGTUVWXYZ

Output

YXWVUTGHIJKLM
ZABCDEFSRQPON

Input

BUVTYZFQSNRIWOXXGJLKACPEMDH

Output

Impossible

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n;
string s, ss[2];
string origS;
int dx[] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy[] = {1, 1, 1, 0, 0, -1, -1, -1};
void rotate() {
  char beg = ss[1][0];
  char end = ss[0][12];
  ss[0] = beg + ss[0].substr(0, 12);
  ss[1] = ss[1].substr(1, 12) + end;
}
bool pathExist(int count, int curx, int cury) {
  if (count == 26) {
    return true;
  }
  for (int i = 0; i < 8; i++) {
    int newx = curx + dx[i];
    int newy = cury + dy[i];
    if (newx >= 0 && newx < 26 && newy >= 0 && newy < 2 &&
        ss[newy][newx] == origS[count + 1]) {
      return pathExist(count + 1, newx, newy);
    }
  }
  return false;
}
int main() {
  cin >> s;
  origS = s;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == s[i + 1]) {
      cout << "Impossible" << endl;
      return 0;
    }
  }
  set<char> seen;
  for (int i = 0; i < 27; i++) {
    if (seen.count(s[i])) {
      s.erase(s.begin() + i);
      break;
    }
    seen.insert(s[i]);
  }
  ss[0] = s.substr(0, 13);
  ss[1] = s.substr(13, 13);
  reverse(ss[1].begin(), ss[1].end());
  for (int i = 0; i < 26; i++) {
    int j = 0, k = 0;
    for (j = 0; j < 2; j++) {
      for (k = 0; k < 13; k++) {
        if (ss[j][k] == origS[0]) break;
      }
      if (ss[j][k] == origS[0]) break;
    }
    if (pathExist(0, k, j)) {
      cout << ss[0] << endl << ss[1] << endl;
      return 0;
    }
    rotate();
  }
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Draw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'.

Constraints

* 1 ≤ H ≤ 300
* 1 ≤ W ≤ 300

Input

The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space.

The input ends with two 0 (when both H and W are zero).

Output

For each dataset, print the rectangle made of H × W '#'.

Print a blank line after each dataset.

Example

Input

3 4
5 6
2 2
0 0

Output

####
####
####

######
######
######
######
######

##
##

### Response

```cpp
#include<stdio.h>

int main(void){
int H,W,i,I,j;
for(j=0;j<10000;j++){
	scanf("%d %d",&H,&W);
	if(H!=0){
	for(i=0;i<H;i++){
		for(I=0;I<W;I++){
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
}else{
	break;
}
}
return 0;

}

```


### Prompt

Create a solution in cpp for the following problem:

A factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-day period to do maintenance and construction; it cannot produce any thimbles during this time, but will be restored to its full production of a thimbles per day after the k days are complete.

Initially, no orders are pending. The factory receives updates of the form di, ai, indicating that ai new orders have been placed for the di-th day. Each order requires a single thimble to be produced on precisely the specified day. The factory may opt to fill as many or as few of the orders in a single batch as it likes.

As orders come in, the factory owner would like to know the maximum number of orders he will be able to fill if he starts repairs on a given day pi. Help the owner answer his questions.

Input

The first line contains five integers n, k, a, b, and q (1 ≤ k ≤ n ≤ 200 000, 1 ≤ b < a ≤ 10 000, 1 ≤ q ≤ 200 000) — the number of days, the length of the repair time, the production rates of the factory, and the number of updates, respectively.

The next q lines contain the descriptions of the queries. Each query is of one of the following two forms:

  * 1 di ai (1 ≤ di ≤ n, 1 ≤ ai ≤ 10 000), representing an update of ai orders on day di, or
  * 2 pi (1 ≤ pi ≤ n - k + 1), representing a question: at the moment, how many orders could be filled if the factory decided to commence repairs on day pi?

It's guaranteed that the input will contain at least one query of the second type.

Output

For each query of the second type, print a line containing a single integer — the maximum number of orders that the factory can fill over all n days.

Examples

Input

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

Output

3
6
4

Input

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

Output

7
1

Note

Consider the first sample.

We produce up to 1 thimble a day currently and will produce up to 2 thimbles a day after repairs. Repairs take 2 days.

For the first question, we are able to fill 1 order on day 1, no orders on days 2 and 3 since we are repairing, no orders on day 4 since no thimbles have been ordered for that day, and 2 orders for day 5 since we are limited to our production capacity, for a total of 3 orders filled.

For the third question, we are able to fill 1 order on day 1, 1 order on day 2, and 2 orders on day 5, for a total of 4 orders.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
struct Fenwick {
  long long fen[N];
  void clear() { memset(fen, 0, sizeof fen); }
  void ad(int p, long long val) {
    for (p++; p < N; p += p & -p) fen[p] += val;
  }
  long long gt(int p, long long ret = 0) {
    for (; p; p -= p & -p) ret += fen[p];
    return ret;
  }
};
long long n, k, a, b, q;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  Fenwick A, B;
  A.clear();
  B.clear();
  cin >> n >> k >> a >> b >> q;
  for (int i = 0; i < q; ++i) {
    int t;
    cin >> t;
    if (t == 1) {
      long long d, c;
      cin >> d >> c;
      long long x1 = A.gt(d + 1) - A.gt(d);
      long long x2 = B.gt(d + 1) - B.gt(d);
      A.ad(d, -x1);
      B.ad(d, -x2);
      x1 += c;
      x2 += c;
      A.ad(d, min(x1, a));
      B.ad(d, min(x2, b));
    } else {
      long long p;
      cin >> p;
      long long ans = 0;
      ans += B.gt(p);
      ans += A.gt(n + 1) - A.gt(p + k);
      cout << ans << "\n";
    }
  }
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

The city of D consists of n towers, built consecutively on a straight line. The height of the tower that goes i-th (from left to right) in the sequence equals hi. The city mayor decided to rebuild the city to make it beautiful. In a beautiful city all towers are are arranged in non-descending order of their height from left to right.

The rebuilding consists of performing several (perhaps zero) operations. An operation constitutes using a crane to take any tower and put it altogether on the top of some other neighboring tower. In other words, we can take the tower that stands i-th and put it on the top of either the (i - 1)-th tower (if it exists), or the (i + 1)-th tower (of it exists). The height of the resulting tower equals the sum of heights of the two towers that were put together. After that the two towers can't be split by any means, but more similar operations can be performed on the resulting tower. Note that after each operation the total number of towers on the straight line decreases by 1.

Help the mayor determine the minimum number of operations required to make the city beautiful.

Input

The first line contains a single integer n (1 ≤ n ≤ 5000) — the number of towers in the city. The next line contains n space-separated integers: the i-th number hi (1 ≤ hi ≤ 105) determines the height of the tower that is i-th (from left to right) in the initial tower sequence.

Output

Print a single integer — the minimum number of operations needed to make the city beautiful.

Examples

Input

5
8 2 7 3 1

Output

3

Input

3
5 2 1

Output

2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int ni() {
  int a;
  scanf("%d", &a);
  return a;
}
const int maxn = 5011;
const int inf = 1000000000;
int hs[maxn], d[maxn][maxn];
int main() {
  int n = ni();
  for (int i = 0; i < int(n); i++) hs[i] = ni();
  for (int i = 0; i < int(maxn); i++)
    for (int j = 0; j < int(maxn); j++) d[i][j] = inf;
  d[1][1] = 0;
  for (int taken = 1; taken <= n; taken++) {
    int lastSize = 0, curSize = 0, curPtr = taken;
    for (int lastSeg = 1; lastSeg <= taken; lastSeg++) {
      lastSize += hs[taken - lastSeg];
      while (curPtr < n && curSize < lastSize) {
        curSize += hs[curPtr];
        ++curPtr;
      }
      int minNeedTaken = -1;
      if (curSize >= lastSize) {
        minNeedTaken = curPtr - taken;
      }
      if (minNeedTaken != -1) {
        d[taken + minNeedTaken][minNeedTaken] =
            min(d[taken + minNeedTaken][minNeedTaken],
                d[taken][lastSeg] + (minNeedTaken - 1));
      }
      d[taken + 1][lastSeg + 1] =
          min(d[taken + 1][lastSeg + 1], d[taken][lastSeg] + 1);
    }
  }
  int res = inf;
  for (int i = 0; i < int(maxn); i++) res = min(res, d[n][i]);
  cout << res << endl;
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Write a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations:

* $update(s, t, x)$: change $a_s, a_{s+1}, ..., a_t$ to $x$.
* $getSum(s, t)$: print the sum of $a_s, a_{s+1}, ..., a_t$.

Note that the initial values of $a_i ( i = 0, 1, ..., n-1 )$ are 0.

Constraints

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

Input

$n$ $q$
$query_1$
$query_2$
:
$query_q$

In the first line, $n$ (the number of elements in $A$) and $q$ (the number of queries) are given. Then, $i$-th query $query_i$ 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 $update(s, t, x)$ and '1' denotes $find(s, t)$.

Output

For each $getSum$ query, print the sum in a line.

Example

Input

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

Output

-5
1
6
8

### Response

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

class segment_tree{
    vector<int64_t> val;
    vector<pair<int64_t, int64_t>> op;
    vector<pair<size_t, size_t>> range;

    size_t N, depth;

    void merge(size_t target, int64_t alpha, int64_t beta){
        op[target] = {op[target].first * alpha, op[target].second * alpha + beta};
    }
    void propagate(size_t target){
        // min, max -> width = 1
        val[target] = op[target].first * val[target] + op[target].second * (range[target].second - range[target].first);
        if(target  < N){
            merge(2*target, op[target].first, op[target].second);
            merge(2*target+1, op[target].first, op[target].second);
        }
        op[target] = {1, 0};
    }

    void eval(int n){
        stack<size_t> stk;
        for(;n>0;n>>=1) stk.push(n);
        while(!stk.empty()){
            propagate(stk.top());
            stk.pop();
        }
    }
    void get_target(vector<size_t> &target, size_t left, size_t right, stack<size_t> *refresh=nullptr){
        queue<size_t> partial;

        if(left <= 0 && right >= N) target.push_back(1);
        else partial.push(1);

        while(!partial.empty()){
            size_t i = partial.front();
            if(refresh != nullptr) refresh->push(i);
            partial.pop();

            propagate(i);

            if(left <= range[i].first){
                if(right < range[i*2].second) partial.push(i*2);
                else{
                    target.push_back(i*2);
                    if(range[i*2+1].first < right) partial.push(i*2+1);
                }
            }else{
                if(left < range[i*2].second){
                    partial.push(i*2);
                    if(range[i*2+1].second <= right) target.push_back(i*2+1);
                    else if(range[i*2].second < right) partial.push(i*2+1);
                }else{
                    if(left <= range[i*2+1].first && range[i*2+1].second <= right) target.push_back(i*2+1);
                    else partial.push(i*2+1);
                }
            }
        }
    }
public:
    segment_tree(size_t n){
        for(depth=0;(1ULL<<depth)<n;depth++);
        N = 1ULL<<depth;
        val.reserve(1ULL<<(++depth));
        op.reserve(1ULL<<depth);
        range.reserve(1ULL<<depth);
        for(size_t i=2*N-1;i>0;i--){
            if(i>=N) range[i] = {i-N, i-N+1};
            else range[i] = {range[2*i].first, range[2*i+1].second};
        }
    }
    int64_t operator[](size_t i){
        eval(N+i);
        return val[N+i];
    }
    void operate(int64_t alpha, int64_t beta, size_t left, size_t right){
        if(right <= left) return;

        vector<size_t> target;
        stack<size_t> refresh;
        get_target(target, left, right, &refresh);
        for(auto i : target){
            merge(i, alpha, beta);
            propagate(i);
        }
        while(!refresh.empty()){
            size_t i = refresh.top();
            refresh.pop();
            //min, max -> change
            propagate(i*2);
            propagate(i*2+1);
            val[i] = val[i*2] + val[i*2+1];
        }
    }
    int64_t get_sum(size_t left, size_t right){
        if(right <= left) return 0;

        vector<size_t> target;
        get_target(target, left, right);
        int64_t ret = 0;
        for(auto i : target){
            ret += op[i].first * val[i] + op[i].second * (range[i].second - range[i].first);
        }
        return ret;
    }
    void update(int64_t val, size_t pos){
        operate(0, val, pos, pos+1);
    }
    void update(int64_t val, size_t left, size_t right){
        operate(0, val, left, right);
    }
    void add(int64_t val, size_t pos){
        operate(1, val, pos, pos+1);
    }
    void add(int64_t val, size_t left, size_t right){
        operate(1, val, left, right);
    }

    void dump(){
        for(int i=1;i<2*N;i++){
            eval(i);
            cerr << val[i] << " ";
        }
        cerr << endl;
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    segment_tree st(n);

    for(int i=0;i<q;i++){
        int com;
        cin >> com;
        if(com == 0){
            int s, t, x;
            cin >> s >> t >> x;
            st.update(x, s, t+1);
        }else{
            int s, t;
            cin >> s >> t;
            cout << st.get_sum(s, t+1) << endl;
        }
        //st.dump();
    }

    return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the Internet, he learned about the Hamming distance between two strings S and T of the same length, which is defined as the number of positions in which S and T have different characters. For example, the Hamming distance between words "permanent" and "pergament" is two, as these words differ in the fourth and sixth letters.

Moreover, as he was searching for information, he also noticed that modern search engines have powerful mechanisms to correct errors in the request to improve the quality of search. Ford doesn't know much about human beings, so he assumed that the most common mistake in a request is swapping two arbitrary letters of the string (not necessarily adjacent). Now he wants to write a function that determines which two letters should be swapped in string S, so that the Hamming distance between a new string S and string T would be as small as possible, or otherwise, determine that such a replacement cannot reduce the distance between the strings.

Help him do this!

Input

The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T.

The second line contains string S.

The third line contains string T.

Each of the lines only contains lowercase Latin letters.

Output

In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S.

In the second line, either print the indexes i and j (1 ≤ i, j ≤ n, i ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or print "-1 -1", if it is not necessary to swap characters.

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

Examples

Input

9
pergament
permanent

Output

1
4 6

Input

6
wookie
cookie

Output

1
-1 -1

Input

4
petr
egor

Output

2
1 2

Input

6
double
bundle

Output

2
4 1

Note

In the second test it is acceptable to print i = 2, j = 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Letters {
  int num;
  char s;
  char t;
};
vector<Letters> Str1[30];
vector<Letters> Str2[30];
string S, T;
int main() {
  int n;
  while (cin >> n) {
    cin >> S >> T;
    for (int i = 0; i < 26; i++) {
      Str1[i].clear();
      Str2[i].clear();
    }
    Letters l;
    int k1, k2, tot = 0, ok;
    for (int i = 0; S[i]; i++) {
      if (S[i] != T[i]) {
        tot++;
        l.num = i + 1;
        l.s = S[i];
        l.t = T[i];
        k1 = S[i] - 'a';
        k2 = T[i] - 'a';
        ok = 1;
        for (int j = 0; j < Str1[k1].size(); j++) {
          if (Str1[k1][j].t == l.t) {
            ok = 0;
            break;
          }
        }
        if (ok) {
          Str1[k1].push_back(l);
          Str2[k2].push_back(l);
        }
      }
    }
    ok = 0;
    int x = -1, y = -1;
    for (int i = 0; i < 26; i++) {
      for (int j = 0; j < Str1[i].size(); j++) {
        for (int k = 0; k < Str2[i].size(); k++) {
          x = Str1[i][j].num;
          y = Str2[i][k].num;
          if (Str1[i][j].t == Str2[i][k].s) ok = 1;
          if (ok) break;
        }
        if (ok) break;
      }
      if (ok) break;
    }
    if (ok)
      tot -= 2;
    else if (x != -1)
      tot -= 1;
    cout << tot << endl;
    cout << x << " " << y << endl;
  }
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.

Innokentiy doesn't like to drink the same tea (green or black) more than k times in a row. Your task is to determine the order of brewing tea bags so that Innokentiy will be able to drink n cups of tea, without drinking the same tea more than k times in a row, or to inform that it is impossible. Each tea bag has to be used exactly once.

Input

The first line contains four integers n, k, a and b (1 ≤ k ≤ n ≤ 105, 0 ≤ a, b ≤ n) — the number of cups of tea Innokentiy wants to drink, the maximum number of cups of same tea he can drink in a row, the number of tea bags of green and black tea. It is guaranteed that a + b = n.

Output

If it is impossible to drink n cups of tea, print "NO" (without quotes).

Otherwise, print the string of the length n, which consists of characters 'G' and 'B'. If some character equals 'G', then the corresponding cup of tea should be green. If some character equals 'B', then the corresponding cup of tea should be black.

If there are multiple answers, print any of them.

Examples

Input

5 1 3 2

Output

GBGBG

Input

7 2 2 5

Output

BBGBGBB

Input

4 3 4 0

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void fn(int n, int k, int a, int b) {
  int i;
  if (a == b) {
    for (i = 0; i < a; i++) cout << 'G' << 'B';
    return;
  }
  if (a > b) {
    if (a > k && b > 0) {
      for (i = 0; i < k; i++) cout << 'G';
      cout << 'B';
      a -= k;
      b--;
      if (a > b) {
        fn(n - k - 1, k, a, b);
        return;
      }
      if (a == 0) return;
      cout << 'G';
      a--;
      fn(n - k - 2, k, a, b);
      return;
    }
    for (i = 0; i < a; i++) cout << 'G';
    for (i = 0; i < b; i++) cout << 'B';
    return;
  }
  if (b > k && a > 0) {
    for (i = 0; i < k; i++) cout << 'B';
    cout << 'G';
    b -= k;
    a--;
    if (b > a) {
      fn(n - k - 1, k, a, b);
      return;
    }
    if (b == 0) return;
    cout << 'B';
    b--;
    fn(n - k - 2, k, a, b);
    return;
  }
  for (i = 0; i < b; i++) cout << 'B';
  for (i = 0; i < a; i++) cout << 'G';
  return;
}
int main() {
  int n, k, a, b;
  cin >> n >> k >> a >> b;
  if ((n / (k + 1) > a) || (n / (k + 1) > b)) {
    cout << "NO" << endl;
  } else {
    fn(n, k, a, b);
    cout << endl;
  }
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Recently Bob invented a new game with a tree (we should remind you, that a tree is a connected graph without cycles): he deletes any (possibly, zero) amount of edges of the tree, and counts the product of sizes of the connected components left after the deletion. Your task is to find out the maximum number that Bob can get in his new game for a given tree.

Input

The first input line contains integer number n (1 ≤ n ≤ 700) — amount of vertices in the tree. The following n - 1 lines contain the description of the edges. Each line contains the pair of vertices' indexes, joined by an edge, ai, bi (1 ≤ ai, bi ≤ n). It's guaranteed that the graph described in the input is a tree.

Output

Output the only number — the maximum product of sizes of the connected components, that Bob can get after deleting some of the tree's edges.

Examples

Input

5
1 2
2 3
3 4
4 5

Output

6

Input

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

Output

18

Input

3
1 2
1 3

Output

3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
namespace Fastio {
enum io_flags {
  ignore_int = 1 << 0,
  flush_stdout = 1 << 1,
  flush_stderr = 1 << 2,
};
enum number_type_flags {
  output_double_stable = 1 << 0,
  output_double_faster = 1 << 1
};
struct Reader {
  char endch;
  Reader() { endch = '\0'; }
  Reader& operator>>(io_flags f) {
    if (f & ignore_int) {
      endch = getchar();
      while ((!isdigit(endch)) && endch != '-' && endch != EOF)
        endch = getchar();
      while (isdigit(endch = getchar()))
        ;
    }
    return *this;
  }
  Reader& operator>>(char& ch) {
    ch = getchar();
    while (ch == ' ' || ch == '\r' || ch == '\n' || ch == '\t') ch = getchar();
    return *this;
  }
  Reader& operator>>(double& lf) {
    bool flag = 0;
    endch = getchar();
    while ((!isdigit(endch)) && endch != '-' && endch != EOF) endch = getchar();
    if (endch == '-') flag = 1, endch = getchar();
    lf = endch & 15;
    while (isdigit(endch = getchar())) lf = lf * 10 + (endch & 15);
    if (endch == '.') {
      double digit = 0.1;
      while (isdigit(endch = getchar())) {
        lf += (endch & 15) * digit;
        digit *= 0.1;
      }
    }
    if (flag) lf = -lf;
    return *this;
  }
  template <typename Int>
  Reader& operator>>(Int& d) {
    bool flag = 0;
    endch = getchar();
    while ((!isdigit(endch)) && endch != '-' && endch != EOF) endch = getchar();
    if (endch == '-') flag = 1, endch = getchar();
    d = endch & 15;
    while (isdigit(endch = getchar())) d = (d << 3) + (d << 1) + (endch & 15);
    if (flag) d = -d;
    return *this;
  }
  template <typename Int>
  inline Int get() {
    bool flag = 0;
    endch = getchar();
    while ((!isdigit(endch)) && endch != '-' && endch != EOF) endch = getchar();
    if (endch == '-') flag = 1, endch = getchar();
    Int d = endch & 15;
    while (isdigit(endch = getchar())) d = (d << 3) + (d << 1) + (endch & 15);
    if (flag) d = -d;
    return d;
  }
} read;
struct Writer {
  Writer& operator<<(io_flags f) {
    if (f & flush_stdout) fflush(stdout);
    if (f & flush_stderr) fflush(stderr);
    return *this;
  }
  Writer& operator<<(const char* ch) {
    while (*ch) putchar(*(ch++));
    return *this;
  }
  Writer& operator<<(const char ch) {
    putchar(ch);
    return *this;
  }
  template <typename Int>
  Writer& operator<<(Int x) {
    static char buffer[33];
    static int top = 0;
    if (!x) {
      putchar('0');
      return *this;
    }
    if (x < 0) putchar('-'), x = ~x + 1;
    while (x) {
      buffer[++top] = '0' | (x % 10);
      x /= 10;
    }
    while (top) putchar(buffer[top--]);
    return *this;
  }
  inline void operator()(double val, int eps_digit = 6, char endch = '\0',
                         number_type_flags flg = output_double_faster) {
    if (flg & output_double_stable) {
      static char output_format[10];
      sprintf(output_format, "%%.%dlf", eps_digit);
      printf(output_format, val);
    } else if (flg & output_double_faster) {
      if (val < 0) {
        putchar('-');
        val = -val;
      }
      double eps_number = 0.5;
      for (int i = 1; i <= eps_digit; i++) eps_number /= 10;
      val += eps_number;
      (*this) << (long long)val;
      val -= (long long)val;
      if (eps_digit) putchar('.');
      while (eps_digit--) {
        val *= 10;
        putchar((int)val | '0');
        val -= (int)val;
      }
    } else {
      (*this) << '1';
      if (eps_digit) {
        (*this) << ".E";
        for (int i = 2; i <= eps_digit; i++) (*this) << '0';
      }
    }
    if (endch) putchar(endch);
  }
} write;
}  // namespace Fastio
using namespace Fastio;
namespace File_IO {
void init_IO(const char* file_name) {
  char buff[107];
  sprintf(buff, "%s.in", file_name);
  freopen(buff, "r", stdin);
  sprintf(buff, "%s.out", file_name);
  freopen(buff, "w", stdout);
}
}  // namespace File_IO
const int N = 700 + 3, DigByte = 100000000;
struct Bint {
  unsigned long long atom[17];
  int len;
  Bint(int number = 0) : len(0) {
    while (number) {
      atom[len++] = number % DigByte;
      number /= DigByte;
    }
  }
  Bint operator*(const Bint& b) const {
    Bint ret;
    memset(ret.atom, 0, sizeof(ret.atom));
    ret.len = len + b.len;
    for (int i = 0; i < len; i++)
      for (int j = 0; j < b.len; j++) ret.atom[i + j] += atom[i] * b.atom[j];
    for (int i = 1; i < ret.len; i++) {
      ret.atom[i] += ret.atom[i - 1] / DigByte;
      ret.atom[i - 1] %= DigByte;
    }
    if (!ret.atom[ret.len - 1]) --ret.len;
    return ret;
  }
  bool operator<(const Bint& b) const {
    if (len ^ b.len) return len < b.len;
    for (int i = len - 1; i >= 0; i--)
      if (atom[i] ^ b.atom[i]) return atom[i] < b.atom[i];
    return false;
  }
  void print(char endch = '\0') const {
    if (len <= 0) {
      putchar('0');
      if (endch) putchar(endch);
      return;
    }
    printf("%llu", atom[len - 1]);
    int i = len - 2;
    while (i >= 0) printf("%08llu", atom[i--]);
    if (endch) putchar(endch);
  }
};
int n;
Bint f[N][N], g[N];
vector<int> G[N];
int siz[N];
void sol(int u, int fa) {
  f[u][1] = f[u][0] = siz[u] = 1;
  for (size_t eid = 0; eid < G[u].size(); eid++) {
    int v = G[u][eid];
    if (v == fa) continue;
    sol(v, u);
    for (int i = 0; i <= siz[u] + siz[v]; i++) g[i] = 0;
    for (int i = 0; i <= siz[v]; i++)
      for (int j = 0; j <= siz[u]; j++)
        g[i + j] = max(g[i + j], f[u][j] * f[v][i]);
    siz[u] += siz[v];
    for (int i = 0; i <= siz[u]; i++) f[u][i] = g[i];
  }
  for (int i = 1; i <= siz[u]; i++) f[u][0] = max(f[u][0], f[u][i] * i);
}
signed main() {
  read >> n;
  for (int i = 1, u, v; i < n; i++) {
    read >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  sol(1, -1);
  f[1][0].print('\n');
  return 0;
}

```


### Prompt

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

Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.

A k-tree is an infinite rooted tree where:

  * each vertex has exactly k children;
  * each edge has some weight;
  * if we look at the edges that goes from some vertex to its children (exactly k edges), then their weights will equal 1, 2, 3, ..., k.

The picture below shows a part of a 3-tree.

<image>

As soon as Dima, a good friend of Lesha, found out about the tree, he immediately wondered: "How many paths of total weight n (the sum of all weights of the edges in the path) are there, starting from the root of a k-tree and also containing at least one edge of weight at least d?".

Help Dima find an answer to his question. As the number of ways can be rather large, print it modulo 1000000007 (109 + 7).

Input

A single line contains three space-separated integers: n, k and d (1 ≤ n, k ≤ 100; 1 ≤ d ≤ k).

Output

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

Examples

Input

3 3 2

Output

3

Input

3 3 3

Output

1

Input

4 3 2

Output

6

Input

4 5 2

Output

7

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
void add(int &a, int val) {
  a += val;
  a %= mod;
}
signed main() {
  int n, k, d;
  cin >> n >> k >> d;
  vector<vector<int>> dp(n + 1, vector<int>(2, 0));
  dp[0][0] = 1;
  dp[0][1] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= k; ++j) {
      if (j <= i) {
        if (j < d) {
          add(dp[i][0], dp[i - j][0]);
          add(dp[i][1], dp[i - j][1]);
        } else {
          add(dp[i][1], dp[i - j][1]);
          add(dp[i][1], dp[i - j][0]);
        }
      }
    }
  }
  cout << dp[n][1];
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Santa has to send presents to the kids. He has a large stack of n presents, numbered from 1 to n; the topmost present has number a_1, the next present is a_2, and so on; the bottom present has number a_n. All numbers are distinct.

Santa has a list of m distinct presents he has to send: b_1, b_2, ..., b_m. He will send them in the order they appear in the list.

To send a present, Santa has to find it in the stack by removing all presents above it, taking this present and returning all removed presents on top of the stack. So, if there are k presents above the present Santa wants to send, it takes him 2k + 1 seconds to do it. Fortunately, Santa can speed the whole process up — when he returns the presents to the stack, he may reorder them as he wishes (only those which were above the present he wanted to take; the presents below cannot be affected in any way).

What is the minimum time required to send all of the presents, provided that Santa knows the whole list of presents he has to send and reorders the presents optimally? Santa cannot change the order of presents or interact with the stack of presents in any other way.

Your program has to answer t different test cases.

Input

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

Then the test cases follow, each represented by three lines.

The first line contains two integers n and m (1 ≤ m ≤ n ≤ 10^5) — the number of presents in the stack and the number of presents Santa wants to send, respectively.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n, all a_i are unique) — the order of presents in the stack.

The third line contains m integers b_1, b_2, ..., b_m (1 ≤ b_i ≤ n, all b_i are unique) — the ordered list of presents Santa has to send.

The sum of n over all test cases does not exceed 10^5.

Output

For each test case print one integer — the minimum number of seconds which Santa has to spend sending presents, if he reorders the presents optimally each time he returns them into the stack.

Example

Input

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

Output

5
8

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long power(long long x, long long n, long long mod) {
  if (n == 0) {
    return 1;
  }
  long long temp = power(x, n / 2, mod);
  if (n % 2 == 1) {
    return (x * temp * temp) % mod;
  } else {
    return (temp * temp) % mod;
  }
}
long long abs(long long a, long long b) {
  if (a > b) {
    return a - b;
  }
  return b - a;
}
long long n;
long long countt = 0;
long long binary(long long n) {
  long long sum = 0;
  if (n <= 0) {
    return 10000000;
  }
  while (n > 0) {
    if (n % 2 == 1) {
      sum++;
    }
    n /= 2;
  }
  return sum;
}
vector<long long> primes;
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  long long n, m;
  vector<long long> stackk;
  vector<long long> needed;
  long long temp;
  set<long long> passed;
  long long sol;
  long long biggest;
  for (long long i = 0; i <= t - 1; i++) {
    cin >> n >> m;
    stackk.clear();
    needed.clear();
    passed.clear();
    sol = 0;
    biggest = -1;
    for (long long j = 0; j <= n - 1; j++) {
      cin >> temp;
      stackk.push_back(temp);
    }
    for (long long j = 0; j <= m - 1; j++) {
      cin >> temp;
      needed.push_back(temp);
    }
    for (long long j = 0; j <= m - 1; j++) {
      if (passed.count(needed[j])) {
        sol++;
        continue;
      }
      for (long long k = biggest; k <= n - 1; k++) {
        passed.insert(stackk[k]);
        if (needed[j] == stackk[k]) {
          sol += 2 * (k - j) + 1;
          biggest = k;
          break;
        }
      }
    }
    cout << sol << endl;
  }
  return 0;
}

```


### Prompt

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

Let's denote d(n) as the number of divisors of a positive integer n. You are given three integers a, b and c. Your task is to calculate the following sum:

<image>

Find the sum modulo 1073741824 (230).

Input

The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 2000).

Output

Print a single integer — the required sum modulo 1073741824 (230).

Examples

Input

2 2 2

Output

20

Input

4 4 4

Output

328

Input

10 10 10

Output

11536

Note

For the first example.

  * d(1·1·1) = d(1) = 1;
  * d(1·1·2) = d(2) = 2;
  * d(1·2·1) = d(2) = 2;
  * d(1·2·2) = d(4) = 3;
  * d(2·1·1) = d(2) = 2;
  * d(2·1·2) = d(4) = 3;
  * d(2·2·1) = d(4) = 3;
  * d(2·2·2) = d(8) = 4.

So the result is 1 + 2 + 2 + 3 + 2 + 3 + 3 + 4 = 20.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXSIZE = 10000020;
int bufpos;
char buf[MAXSIZE];
void init() {
  buf[fread(buf, 1, MAXSIZE, stdin)] = '\0';
  bufpos = 0;
}
int readint() {
  int val = 0;
  for (; !isdigit(buf[bufpos]); bufpos++)
    ;
  for (; isdigit(buf[bufpos]); bufpos++) val = val * 10 + buf[bufpos] - '0';
  return val;
}
char readchar() {
  for (; isspace(buf[bufpos]); bufpos++)
    ;
  return buf[bufpos++];
}
int readstr(char* s) {
  int cur = 0;
  for (; isspace(buf[bufpos]); bufpos++)
    ;
  for (; !isspace(buf[bufpos]); bufpos++) s[cur++] = buf[bufpos];
  s[cur] = '\0';
  return cur;
}
int mu[5002], f[5002], c[5002];
void sieve(int n) {
  mu[1] = 1;
  for (int i = 1; i <= n; i++) {
    f[i]++;
    for (int j = i * 2; j <= n; j += i) mu[j] -= mu[i], f[j]++;
  }
  for (int i = 1; i <= n; i++) f[i] += f[i - 1];
}
int lcm__[5002][5002];
int deg[5002];
vector<int> a[5002];
int main() {
  init();
  int x = readint(), y = readint(), z = readint(), n = max(max(x, y), z);
  sieve(n);
  for (int i = 1; i <= n; i++) {
    lcm__[i][0] = lcm__[0][i] = i;
    for (int j = 1; j <= i; j++) lcm__[i][j] = lcm__[j][i] = lcm__[j][i % j];
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) lcm__[i][j] = i * j / lcm__[i][j];
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (lcm__[i][j] <= n) {
        a[i].push_back(j);
        a[j].push_back(i);
      }
  for (int i = 1; i <= n; i++) {
    int u = i;
    for (int j = 0; j < a[i].size(); j++) {
      int v = a[i][j];
      if (a[v].size() > a[i].size() || (a[v].size() == a[i].size() && i < v)) {
        for (int k = 0; k < a[i].size(); k++) {
          int w = a[i][k];
          if (lcm__[v][w] <= n && w != v) {
            ans +=
                mu[w] * mu[u] * mu[v] *
                (f[x / lcm__[u][v]] * f[y / lcm__[v][w]] * f[z / lcm__[u][w]] +
                 f[x / lcm__[u][v]] * f[y / lcm__[u][w]] * f[z / lcm__[v][w]]);
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < a[i].size(); j++) {
      int v = a[i][j], lc = lcm__[i][v];
      ans +=
          mu[i] * mu[i] * mu[v] *
          (f[x / i] * f[y / lc] * f[z / lc] + f[x / lc] * f[y / i] * f[z / lc] +
           f[x / lc] * f[y / lc] * f[z / i]);
    }
    ans += mu[i] * mu[i] * mu[i] * f[x / i] * f[y / i] * f[z / i];
  }
  printf("%d", ans & ((1 << 30) - 1));
}

```


### Prompt

Create a solution in Cpp for the following problem:

Given is a string S of length N-1. Each character in S is `<` or `>`.

A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \leq i \leq N-1):

* If S_i= `<`: a_i<a_{i+1}
* If S_i= `>`: a_i>a_{i+1}

Find the minimum possible sum of the elements of a good sequence of N non-negative integers.

Constraints

* 2 \leq N \leq 5 \times 10^5
* S is a string of length N-1 consisting of `<` and `>`.

Input

Input is given from Standard Input in the following format:

S

Output

Find the minimum possible sum of the elements of a good sequence of N non-negative integers.

Examples

Input

<>>

Output

3

Input

<>>><<><<<<<>>><

Output

28

### Response

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

char s[N];

int l[N],r[N];

int main(){
    scanf("%s",s+1);
    int n=strlen(s+1); long long ans=0;
    for(int i=1;i<=n;i++){
        if(s[i]=='<') l[i]=l[i-1]+1;
    }
    for(int i=n;i>=1;i--){
        if(s[i]=='>') r[i]=r[i+1]+1;
    }
    for(int i=1;i<=n+1;i++){
        ans+=max(l[i-1],r[i]);
    }
    cout<<ans<<endl;
}

```


### Prompt

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

You are given an integer a that consists of n digits. You are also given a sequence of digits s of length m. The digit in position j (1 ≤ j ≤ m) of sequence s means that you can choose an arbitrary position i (1 ≤ i ≤ n) in a and replace the digit in the chosen position i with sj. Each element in the sequence s can participate in no more than one replacing operation.

Your task is to perform such sequence of replacements, that the given number a gets maximum value. You are allowed to use not all elements from s.

Input

The first line contains positive integer a. Its length n is positive and doesn't exceed 105. The second line contains sequence of digits s. Its length m is positive and doesn't exceed 105. The digits in the sequence s are written consecutively without any separators.

The given number a doesn't contain leading zeroes.

Output

Print the maximum value that can be obtained from a after a series of replacements. You are allowed to use not all elements from s. The printed number shouldn't contain any leading zeroes.

Examples

Input

1024
010

Output

1124

Input

987
1234567

Output

987

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, s;
  char max;
  vector<char> v;
  cin >> a >> s;
  int i, j, sa, ss;
  sa = a.size();
  ss = s.size();
  for (i = 0; i < ss; i++) v.push_back(s[i]);
  sort(v.begin(), v.end());
  for (i = 0; i < sa; i++) {
    max = v[v.size() - 1];
    if (a[i] < max) {
      a[i] = max;
      v.pop_back();
    }
  }
  cout << a << endl;
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the shop: it is possible to buy one copybook for a rubles, a pack of two copybooks for b rubles, and a pack of three copybooks for c rubles. Alyona already has n copybooks.

What is the minimum amount of rubles she should pay to buy such number of copybooks k that n + k is divisible by 4? There are infinitely many packs of any type in the shop. Alyona can buy packs of different type in the same purchase.

Input

The only line contains 4 integers n, a, b, c (1 ≤ n, a, b, c ≤ 109).

Output

Print the minimum amount of rubles she should pay to buy such number of copybooks k that n + k is divisible by 4.

Examples

Input

1 1 3 4

Output

3

Input

6 2 1 1

Output

1

Input

4 4 4 4

Output

0

Input

999999999 1000000000 1000000000 1000000000

Output

1000000000

Note

In the first example Alyona can buy 3 packs of 1 copybook for 3a = 3 rubles in total. After that she will have 4 copybooks which she can split between the subjects equally.

In the second example Alyuna can buy a pack of 2 copybooks for b = 1 ruble. She will have 8 copybooks in total.

In the third example Alyona can split the copybooks she already has between the 4 subject equally, so she doesn't need to buy anything.

In the fourth example Alyona should buy one pack of one copybook.

### Response

```cpp
#include <bits/stdc++.h>
long long n, a, b, c, ans;
using namespace std;
int main(void) {
  cin >> n >> a >> b >> c;
  ans = -1;
  if (n % 4 == 0)
    ans = 0;
  else {
    for (long long i = 0; i < 30; i++)
      for (long long j = 0; j < 30; j++)
        for (long long k = 0; k < 30; k++)
          if ((n + i * 1 + j * 2 + k * 3) % 4 == 0)
            if (ans == -1 || ans > i * a + j * b + k * c)
              ans = i * a + j * b + k * c;
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

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

You are given three strings a, b and c of the same length n. The strings consist of lowercase English letters only. The i-th letter of a is a_i, the i-th letter of b is b_i, the i-th letter of c is c_i.

For every i (1 ≤ i ≤ n) you must swap (i.e. exchange) c_i with either a_i or b_i. So in total you'll perform exactly n swap operations, each of them either c_i ↔ a_i or c_i ↔ b_i (i iterates over all integers between 1 and n, inclusive).

For example, if a is "code", b is "true", and c is "help", you can make c equal to "crue" taking the 1-st and the 4-th letters from a and the others from b. In this way a becomes "hodp" and b becomes "tele".

Is it possible that after these swaps the string a becomes exactly the same as the string b?

Input

The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a string of lowercase English letters a.

The second line of each test case contains a string of lowercase English letters b.

The third line of each test case contains a string of lowercase English letters c.

It is guaranteed that in each test case these three strings are non-empty and have the same length, which is not exceeding 100.

Output

Print t lines with answers for all test cases. For each test case:

If it is possible to make string a equal to string b print "YES" (without quotes), otherwise print "NO" (without quotes).

You can print either lowercase or uppercase letters in the answers.

Example

Input

4
aaa
bbb
ccc
abc
bca
bca
aabb
bbaa
baba
imi
mii
iim

Output

NO
YES
YES
NO

Note

In the first test case, it is impossible to do the swaps so that string a becomes exactly the same as string b.

In the second test case, you should swap c_i with a_i for all possible i. After the swaps a becomes "bca", b becomes "bca" and c becomes "abc". Here the strings a and b are equal.

In the third test case, you should swap c_1 with a_1, c_2 with b_2, c_3 with b_3 and c_4 with a_4. Then string a becomes "baba", string b becomes "baba" and string c becomes "abab". Here the strings a and b are equal.

In the fourth test case, it is impossible to do the swaps so that string a becomes exactly the same as string b.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string a, b, c;
    cin >> a >> b >> c;
    int i, n = a.length();
    int check = 1;
    for (i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        if (a[i] == c[i] || b[i] == c[i])
          continue;
        else {
          check = 0;
          break;
        }
      } else if (a[i] == b[i]) {
        if (a[i] == c[i])
          continue;
        else {
          check = 0;
          break;
        }
      }
    }
    if (check == 0)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}

```


### Prompt

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

With your help, Heidi has prepared a plan of trap placement and defence. Yet suddenly, the Doctor popped out of the TARDIS and told her that he had spied on the Daleks' preparations, and there is more of them than ever. Desperate times require desperate measures, so Heidi is going to risk meeting with the Daleks and she will consider placing a trap along any Corridor.

This means she needs your help again in calculating E_{max}(c) – the largest e ≤ 10^9 such that if we changed the energy requirement of c to e, then the Daleks might use c in their invasion – but this time for all Time Corridors.

Input

First line: number n of destinations, number m of corridors (2 ≤ n ≤ 10^5, n - 1 ≤ m ≤ 10^6). The next m lines: destinations a, b and energy e (1 ≤ a, b ≤ n, a ≠ b, 0 ≤ e ≤ 10^9).

No pair \\{a, b\} will repeat. The graph is guaranteed to be connected. It is not guaranteed that all energy requirements e are distinct, or that the minimum spanning tree is unique.

Output

Output m lines, each containing one integer: E_{max}(c_i) for the i-th Corridor c_i from the input.

Example

Input

3 3
1 2 8
2 3 3
3 1 4

Output

4
8
8

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
  return x * f;
}
inline bool char_read() {
  char ch = getchar();
  while (!isalpha(ch)) return -1;
  return ch == 'B' ? 0 : 1;
}
void Write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) Write(x / 10);
  putchar(x % 10 + 48);
}
inline void writes(long long x) { Write(x), putchar(' '); }
inline void Writes(long long x) { Write(x), putchar('\n'); }
int n, m;
int fa[205000], fa_e[205000], size[205000];
int ans[2006000];
bool vis[2006000];
struct node {
  int x, y, z, id;
} E[2006000];
int head[205000], deg[205000], nxt[2006000], ver[2006000], edge[2006000],
    num[2006000], tot = 1;
int f[205000][22], maxn[205000][22], dep[205000];
queue<int> q;
void add(int x, int y, int z, int id) {
  ver[++tot] = y, nxt[tot] = head[x], head[x] = tot, edge[tot] = z,
  num[tot] = id;
}
bool cmp(const node &a, const node &b) { return a.z < b.z; }
bool ccmp(const node &a, const node &b) { return a.id < b.id; }
void Start() {
  for (int i = 1; i <= n; ++i) fa[i] = i;
}
int Get(int x) { return x == fa[x] ? x : fa[x] = Get(fa[x]); }
void Merge(int x, int y) { x = Get(x), y = Get(y), fa[x] = y; }
int GetMax(int x, int y) {
  int tmax = 0;
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 22 - 1; i >= 0; --i)
    if (dep[f[x][i]] >= dep[y]) tmax = max(maxn[x][i], tmax), x = f[x][i];
  if (x == y) return tmax;
  for (int i = 22 - 1; i >= 0; --i)
    if (f[x][i] != f[y][i])
      tmax = max(maxn[x][i], tmax), tmax = max(maxn[y][i], tmax), x = f[x][i],
      y = f[y][i];
  tmax = max(tmax, maxn[x][0]), tmax = max(tmax, maxn[y][0]);
  return tmax;
}
int Lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 22 - 1; i >= 0; --i)
    if (dep[f[x][i]] >= dep[y]) x = f[x][i];
  if (x == y) return x;
  for (int i = 22 - 1; i >= 0; --i)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
void dfs(int x, int in_edge) {
  fa_e[x] = in_edge;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y == f[x][0]) continue;
    dep[y] = dep[x] + 1, f[y][0] = x, maxn[y][0] = edge[i];
    for (int j = 1; j < 22; ++j)
      f[y][j] = f[f[y][j - 1]][j - 1],
      maxn[y][j] = max(maxn[y][j - 1], maxn[f[y][j - 1]][j - 1]);
    dfs(y, i);
  }
}
signed main() {
  n = read(), m = read();
  for (int i = 1, x, y, z; i <= m; ++i)
    x = read(), y = read(), z = read(), E[i] = (node){x, y, z, i};
  sort(E + 1, E + 1 + m, cmp);
  Start();
  for (int i = 1; i <= m; ++i) {
    int x = E[i].x, y = E[i].y, z = E[i].z, id = E[i].id;
    if (Get(x) == Get(y)) continue;
    Merge(x, y), ans[id] = 1000000000;
    add(x, y, z, i), add(y, x, z, i);
  }
  dep[1] = 1, dfs(1, 0);
  Start();
  for (int i = 1; i <= m; ++i) {
    int x = E[i].x, y = E[i].y, z = E[i].z, id = E[i].id;
    if (ans[id]) continue;
    int lca = Lca(x, y);
    while (1) {
      x = Get(x);
      if (dep[x] <= dep[lca]) break;
      ans[E[num[fa_e[x]]].id] = z;
      Merge(x, f[x][0]);
    }
    while (1) {
      y = Get(y);
      if (dep[y] <= dep[lca]) break;
      ans[E[num[fa_e[y]]].id] = z;
      Merge(y, f[y][0]);
    }
  }
  sort(E + 1, E + 1 + m, ccmp);
  for (int i = 1; i <= m; ++i) {
    int x = E[i].x, y = E[i].y, z = E[i].z, id = E[i].id;
    if (ans[id])
      Writes(ans[id]);
    else
      Writes(GetMax(x, y));
  }
  return 0;
}

```


### Prompt

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

In this task you need to process a set of stock exchange orders and use them to create order book.

An order is an instruction of some participant to buy or sell stocks on stock exchange. The order number i has price pi, direction di — buy or sell, and integer qi. This means that the participant is ready to buy or sell qi stocks at price pi for one stock. A value qi is also known as a volume of an order.

All orders with the same price p and direction d are merged into one aggregated order with price p and direction d. The volume of such order is a sum of volumes of the initial orders.

An order book is a list of aggregated orders, the first part of which contains sell orders sorted by price in descending order, the second contains buy orders also sorted by price in descending order.

An order book of depth s contains s best aggregated orders for each direction. A buy order is better if it has higher price and a sell order is better if it has lower price. If there are less than s aggregated orders for some direction then all of them will be in the final order book.

You are given n stock exhange orders. Your task is to print order book of depth s for these orders.

Input

The input starts with two positive integers n and s (1 ≤ n ≤ 1000, 1 ≤ s ≤ 50), the number of orders and the book depth.

Next n lines contains a letter di (either 'B' or 'S'), an integer pi (0 ≤ pi ≤ 105) and an integer qi (1 ≤ qi ≤ 104) — direction, price and volume respectively. The letter 'B' means buy, 'S' means sell. The price of any sell order is higher than the price of any buy order.

Output

Print no more than 2s lines with aggregated orders from order book of depth s. The output format for orders should be the same as in input.

Examples

Input

6 2
B 10 3
S 50 2
S 40 1
S 50 6
B 20 4
B 25 10

Output

S 50 8
S 40 1
B 25 10
B 20 4

Note

Denote (x, y) an order with price x and volume y. There are 3 aggregated buy orders (10, 3), (20, 4), (25, 10) and two sell orders (50, 8), (40, 1) in the sample.

You need to print no more than two best orders for each direction, so you shouldn't print the order (10 3) having the worst price among buy orders.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int by[100005], sl[100005];
int main() {
  int n, m, i, j, p, k, q;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    char ch;
    cin >> ch >> p >> q;
    if (ch == 'B')
      by[p] += q;
    else
      sl[p] += q;
  }
  int bm = m, sm = m;
  vector<int> vt;
  for (i = 0; i <= 100000; i++) {
    if (sl[i] > 0) {
      sm--;
      vt.push_back(i);
    }
    if (sm == 0) break;
  }
  for (i = vt.size() - 1; i >= 0; i--) {
    cout << "S " << vt[i] << " " << sl[vt[i]] << "\n";
  }
  for (i = 100000; i >= 0; i--) {
    if (by[i] > 0) {
      bm--;
      cout << "B " << i << " " << by[i] << "\n";
    }
    if (bm == 0) break;
  }
  return 0;
}

```


### Prompt

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

You are given a string s consisting only of first 20 lowercase Latin letters ('a', 'b', ..., 't').

Recall that the substring s[l; r] of the string s is the string s_l s_{l + 1} ... s_r. For example, the substrings of "codeforces" are "code", "force", "f", "for", but not "coder" and "top".

You can perform the following operation no more than once: choose some substring s[l; r] and reverse it (i.e. the string s_l s_{l + 1} ... s_r becomes s_r s_{r - 1} ... s_l).

Your goal is to maximize the length of the maximum substring of s consisting of distinct (i.e. unique) characters.

The string consists of distinct characters if no character in this string appears more than once. For example, strings "abcde", "arctg" and "minecraft" consist of distinct characters but strings "codeforces", "abacaba" do not consist of distinct characters.

Input

The only line of the input contains one string s consisting of no more than 10^6 characters 'a', 'b', ..., 't' (first 20 lowercase Latin letters).

Output

Print one integer — the maximum possible length of the maximum substring of s consisting of distinct characters after reversing no more than one its substring.

Examples

Input

abacaba

Output

3

Input

abcdecdf

Output

6

Input

aabbcc

Output

3

Input

abcdeefc

Output

6

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0);
int f[1 << 20];
int dp[1 << 20];
void solve() {
  string s;
  cin >> s;
  for (int i = 0; i < (int)s.size(); ++i) {
    int mask = 0;
    for (int j = i; j >= max(0, i - 19); --j) {
      if ((mask >> (s[j] - 'a')) & 1) {
        break;
      } else
        mask |= (1 << (s[j] - 'a'));
      f[mask]++;
    }
  }
  for (int i = 0; i < 1 << 20; ++i) {
    if (f[i]) {
      dp[i] = __builtin_popcount(i);
    }
  }
  for (int j = 0; j < 20; ++j) {
    for (int i = 0; i < 1 << 20; ++i) {
      if ((i >> j) & 1) {
        dp[i] = max(dp[i], dp[i ^ (1 << j)]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < 1 << 20; ++i) {
    if (f[i]) ans = max(ans, __builtin_popcount(i) + dp[((1 << 20) - 1) ^ i]);
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

This story is happening in a town named BubbleLand. There are n houses in BubbleLand. In each of these n houses lives a boy or a girl. People there really love numbers and everyone has their favorite number f. That means that the boy or girl that lives in the i-th house has favorite number equal to fi.

The houses are numerated with numbers 1 to n.

The houses are connected with n - 1 bidirectional roads and you can travel from any house to any other house in the town. There is exactly one path between every pair of houses.

A new dating had agency opened their offices in this mysterious town and the citizens were very excited. They immediately sent q questions to the agency and each question was of the following format:

  * a b — asking how many ways are there to choose a couple (boy and girl) that have the same favorite number and live in one of the houses on the unique path from house a to house b.

Help the dating agency to answer the questions and grow their business.

Input

The first line contains an integer n (1 ≤ n ≤ 105), the number of houses in the town.

The second line contains n integers, where the i-th number is 1 if a boy lives in the i-th house or 0 if a girl lives in i-th house.

The third line contains n integers, where the i-th number represents the favorite number fi (1 ≤ fi ≤ 109) of the girl or boy that lives in the i-th house.

The next n - 1 lines contain information about the roads and the i-th line contains two integers ai and bi (1 ≤ ai, bi ≤ n) which means that there exists road between those two houses. It is guaranteed that it's possible to reach any house from any other.

The following line contains an integer q (1 ≤ q ≤ 105), the number of queries.

Each of the following q lines represents a question and consists of two integers a and b (1 ≤ a, b ≤ n).

Output

For each of the q questions output a single number, the answer to the citizens question.

Example

Input

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

Output

2
3

Note

In the first question from house 1 to house 3, the potential couples are (1, 3) and (6, 3).

In the second question from house 7 to house 5, the potential couples are (7, 6), (4, 2) and (4, 5).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long INF = 1e18;
const long double PI = acos(-1);
const long double EPS = 1e-9;
int mod = 998244353;
const int MOD7 = 1000000007;
const int MOD9 = 1000000009;
const int MAXN = 2e5 + 228;
int tin[MAXN];
int cnt[MAXN][2];
int tout[MAXN];
int tl = 0;
vector<int> g[MAXN];
const int lgg = 17;
int up[MAXN][lgg];
int order[MAXN];
void dfs(int v, int p) {
  up[v][0] = p;
  order[tl] = v;
  tin[v] = tl++;
  for (int i = 1; i < lgg; ++i) up[v][i] = up[up[v][i - 1]][i - 1];
  for (int i : g[v]) {
    if (i != p) {
      dfs(i, v);
    }
  }
  order[tl] = v;
  tout[v] = tl++;
}
bool pp(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
int lca(int a, int b) {
  if (pp(a, b)) return a;
  if (pp(b, a)) return b;
  for (int i = lgg - 1; i >= 0; --i)
    if (!pp(up[a][i], b)) a = up[a][i];
  return up[a][0];
}
int f[MAXN];
int tp[MAXN];
int n;
int cum[MAXN];
long long ans = 0;
long long answers[MAXN];
void del(int x, int tp) {
  ans -= cnt[x][tp ^ 1];
  cnt[x][tp]--;
}
void add(int x, int tp) {
  ans += cnt[x][tp ^ 1];
  cnt[x][tp]++;
}
void change(int v) {
  cum[v]++;
  if (cum[v] % 2) {
    add(f[v], tp[v]);
  } else {
    del(f[v], tp[v]);
  }
}
const int bl = 400;
struct query {
  int l, r, i, pt;
};
bool cmp(query a, query b) {
  if (a.l / bl == b.l / bl) {
    if ((a.l / bl) % 2) return a.r < b.r;
    return a.r > b.r;
  }
  return a.l < b.l;
}
vector<query> queries;
signed main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  srand(time(NULL));
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> tp[i];
  for (int i = 1; i <= n; ++i) cin >> f[i];
  vector<int> tf;
  for (int i = 1; i <= n; ++i) tf.push_back(f[i]);
  sort((tf).begin(), (tf).end());
  (tf).resize(unique((tf).begin(), (tf).end()) - tf.begin());
  ;
  for (int i = 1; i <= n; ++i) {
    f[i] = lower_bound((tf).begin(), (tf).end(), f[i]) - tf.begin();
  }
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1, 1);
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int a, b;
    cin >> a >> b;
    int x = lca(a, b);
    if (tin[a] > tin[b]) swap(a, b);
    if (x == a) {
      queries.push_back({tin[x], tin[b], i, 0});
      continue;
    }
    queries.push_back({tout[a], tin[b], i, x});
  }
  sort((queries).begin(), (queries).end(), cmp);
  int l = 0, r = -1;
  for (auto i : queries) {
    while (l < i.l) change(order[l++]);
    while (l > i.l) change(order[--l]);
    while (r < i.r) change(order[++r]);
    while (r > i.r) change(order[r--]);
    if (i.pt) change(i.pt);
    answers[i.i] = ans;
    if (i.pt) change(i.pt);
  }
  for (int i = 0; i < q; ++i) {
    cout << answers[i] << '\n';
  }
}

```


### Prompt

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

Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process.

There are n + 1 cities consecutively numbered from 0 to n. City 0 is Metropolis that is the meeting point for all jury members. For each city from 1 to n there is exactly one jury member living there. Olympiad preparation is a long and demanding process that requires k days of work. For all of these k days each of the n jury members should be present in Metropolis to be able to work on problems.

You know the flight schedule in the country (jury members consider themselves important enough to only use flights for transportation). All flights in Metropolia are either going to Metropolis or out of Metropolis. There are no night flights in Metropolia, or in the other words, plane always takes off at the same day it arrives. On his arrival day and departure day jury member is not able to discuss the olympiad. All flights in Megapolia depart and arrive at the same day.

Gather everybody for k days in the capital is a hard objective, doing that while spending the minimum possible money is even harder. Nevertheless, your task is to arrange the cheapest way to bring all of the jury members to Metrpolis, so that they can work together for k days and then send them back to their home cities. Cost of the arrangement is defined as a total cost of tickets for all used flights. It is allowed for jury member to stay in Metropolis for more than k days.

Input

The first line of input contains three integers n, m and k (1 ≤ n ≤ 105, 0 ≤ m ≤ 105, 1 ≤ k ≤ 106).

The i-th of the following m lines contains the description of the i-th flight defined by four integers di, fi, ti and ci (1 ≤ di ≤ 106, 0 ≤ fi ≤ n, 0 ≤ ti ≤ n, 1 ≤ ci ≤ 106, exactly one of fi and ti equals zero), the day of departure (and arrival), the departure city, the arrival city and the ticket cost.

Output

Output the only integer that is the minimum cost of gathering all jury members in city 0 for k days and then sending them back to their home cities.

If it is impossible to gather everybody in Metropolis for k days and then send them back to their home cities, output "-1" (without the quotes).

Examples

Input

2 6 5
1 1 0 5000
3 2 0 5500
2 2 0 6000
15 0 2 9000
9 0 1 7000
8 0 2 6500

Output

24500

Input

2 4 5
1 2 0 5000
2 1 0 4500
2 1 0 3000
8 0 1 6000

Output

-1

Note

The optimal way to gather everybody in Metropolis in the first sample test is to use flights that take place on days 1, 2, 8 and 9. The only alternative option is to send jury member from second city back home on day 15, that would cost 2500 more.

In the second sample it is impossible to send jury member from city 2 back home from Metropolis.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct node {
  int d, f, t;
  long long c;
} a[100005];
int cmp(node a, node b) { return a.d < b.d; }
long long INF = 0x3f3f3f3f3f3f;
long long cost[100005];
int vis[100005];
int cnt1[1000006];
int cnt2[1000006];
long long sum2[1000006];
long long sum1[1000006];
int main() {
  int n, m, k;
  memset(cnt1, 0, sizeof(cnt1));
  memset(cnt2, 0, sizeof(cnt2));
  memset(vis, 0, sizeof(vis));
  memset(cost, INF, sizeof(cost));
  memset(sum1, 0, sizeof(sum1));
  memset(sum2, 0, sizeof(sum2));
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d%I64d", &a[i].d, &a[i].f, &a[i].t, &a[i].c);
  }
  sort(a + 1, a + 1 + m, cmp);
  int pre = 0;
  for (int i = 1; i <= m; i++) {
    if (a[i].f == 0) continue;
    int f = a[i].f;
    int d = a[i].d;
    sum1[d] = sum1[pre];
    cnt1[d] = cnt1[pre];
    if (cost[f] > a[i].c) {
      if (vis[f] == 1)
        sum1[d] = sum1[d] - cost[f] + a[i].c;
      else
        sum1[d] += a[i].c;
      cost[f] = a[i].c;
      if (vis[f] == 0) {
        cnt1[d]++;
        vis[f] = 1;
      }
    }
    pre = d;
  }
  for (int i = 1; i <= 1000000; i++) {
    if (cnt1[i] == 0) cnt1[i] = cnt1[i - 1];
    if (sum1[i] == 0) sum1[i] = sum1[i - 1];
  }
  memset(vis, 0, sizeof(vis));
  pre = 1000000;
  memset(cost, INF, sizeof(cost));
  for (int i = m; i >= 1; i--) {
    if (a[i].t == 0) continue;
    int d = a[i].d;
    int t = a[i].t;
    sum2[d] = sum2[pre];
    cnt2[d] = cnt2[pre];
    if (cost[t] > a[i].c) {
      if (vis[t] == 1)
        sum2[d] = sum2[d] - cost[t] + a[i].c;
      else
        sum2[d] += a[i].c;
      cost[t] = a[i].c;
      if (vis[t] == 0) {
        cnt2[d]++;
        vis[t] = 1;
      }
    }
    pre = d;
  }
  for (int i = 1000000; i >= 0; i--) {
    if (cnt2[i] == 0) cnt2[i] = cnt2[i + 1];
    if (sum2[i] == 0) sum2[i] = sum2[i + 1];
  }
  long long ans = INF;
  for (int i = 1; i <= 1000000; i++) {
    if (i + k + 1 > 1000000) break;
    if (cnt1[i] == n && cnt2[i + k + 1] == n)
      ans = min(ans, (long long)sum1[i] + sum2[i + k + 1]);
  }
  if (ans == INF) {
    printf("-1\n");
    return 0;
  }
  printf("%I64d\n", ans);
  return 0;
}

```


### Prompt

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

There are N people standing in a queue from west to east.

Given is a string S of length N representing the directions of the people. The i-th person from the west is facing west if the i-th character of S is `L`, and east if that character of S is `R`.

A person is happy if the person in front of him/her is facing the same direction. If no person is standing in front of a person, however, he/she is not happy.

You can perform the following operation any number of times between 0 and K (inclusive):

Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.

What is the maximum possible number of happy people you can have?

Constraints

* N is an integer satisfying 1 \leq N \leq 10^5.
* K is an integer satisfying 1 \leq K \leq 10^5.
* |S| = N
* Each character of S is `L` or `R`.

Input

Input is given from Standard Input in the following format:

N K
S

Output

Print the maximum possible number of happy people after at most K operations.

Examples

Input

6 1
LRLRRL

Output

3

Input

13 3
LRRLRLRRLRLLR

Output

9

Input

10 1
LLLLLRRRRR

Output

9

Input

9 2
RRRLRLRLL

Output

7

### Response

```cpp
#include<iostream>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	int ans=0;
	for(int i=1;i<s.size();i++)
		ans+=s[i]==s[i-1];
	cout<<min(2*k+ans,n-1)<<endl;
	return 0;
}
```


### Prompt

Please formulate a Cpp solution to the following problem:

Consider a [billiard table](https://en.wikipedia.org/wiki/Billiard_table) of rectangular size n × m with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture).

<image>

There is one ball at the point (x, y) currently. Max comes to the table and strikes the ball. The ball starts moving along a line that is parallel to one of the axes or that makes a 45^{\circ} angle with them. We will assume that:

  1. the angles between the directions of the ball before and after a collision with a side are equal,
  2. the ball moves indefinitely long, it only stops when it falls into a pocket,
  3. the ball can be considered as a point, it falls into a pocket if and only if its coordinates coincide with one of the pockets,
  4. initially the ball is not in a pocket.

Note that the ball can move along some side, in this case the ball will just fall into the pocket at the end of the side.

Your task is to determine whether the ball will fall into a pocket eventually, and if yes, which of the four pockets it will be.

Input

The only line contains 6 integers n, m, x, y, v_x, v_y (1 ≤ n, m ≤ 10^9, 0 ≤ x ≤ n; 0 ≤ y ≤ m; -1 ≤ v_x, v_y ≤ 1; (v_x, v_y) ≠ (0, 0)) — the width of the table, the length of the table, the x-coordinate of the initial position of the ball, the y-coordinate of the initial position of the ball, the x-component of its initial speed and the y-component of its initial speed, respectively. It is guaranteed that the ball is not initially in a pocket.

Output

Print the coordinates of the pocket the ball will fall into, or -1 if the ball will move indefinitely.

Examples

Input

4 3 2 2 -1 1

Output

0 0

Input

4 4 2 0 1 1

Output

-1

Input

10 10 10 1 -1 0

Output

-1

Note

The first sample:

<image>

The second sample:

<image>

In the third sample the ball will never change its y coordinate, so the ball will never fall into a pocket.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const double PI = acos(-1);
template <class T, class S>
inline void add(T& a, S b) {
  a += b;
  if (a >= mod) a -= mod;
}
template <class T, class S>
inline void sub(T& a, S b) {
  a -= b;
  if (a < 0) a += mod;
}
template <class T, class S>
inline bool chkmax(T& a, S b) {
  return a < b ? a = b, true : false;
}
template <class T, class S>
inline bool chkmin(T& a, S b) {
  return a > b ? a = b, true : false;
}
long long x, y;
long long exgcd(long long a, long long b, long long& x, long long& y) {
  if (!b) {
    x = 1;
    y = 0;
    return a;
  } else {
    long long gcd, t;
    gcd = exgcd(b, a % b, x, y);
    t = x;
    x = y;
    y = t - (a / b) * y;
    return gcd;
  }
}
long long n, m, sx, sy, vx, vy;
long long gao(long long a, long long b, long long t1, long long t2) {
  long long c = t2 - t1;
  long long gcd = exgcd(a, b, x, y);
  if (c % gcd) return INF;
  x *= c / gcd;
  y *= c / gcd;
  long long mo = abs(b / gcd);
  x = (x % mo + mo) % mo;
  return 2 * n * x + t1;
}
long long calc(long long sx, long long sy, long long vx, long long vy,
               long long tx, long long ty) {
  long long t11 = 0, t12 = 0;
  long long t21 = 0, t22 = 0;
  if (vx > 0) {
    if (tx >= sx)
      t11 = tx - sx, t12 = t11 + 2 * (n - tx);
    else
      t11 = sx - tx + 2 * (n - sx), t12 = t11 + 2 * tx;
  } else {
    if (tx <= sx)
      t11 = sx - tx, t12 = t11 + 2 * tx;
    else
      t11 = tx - sx + 2 * sx, t12 = t11 + 2 * (n - tx);
  }
  if (vy > 0) {
    if (ty >= sy)
      t21 = ty - sy, t22 = t21 + 2 * (m - ty);
    else
      t21 = sy - ty + 2 * (m - sy), t22 = t21 + 2 * ty;
  } else {
    if (ty <= sy)
      t21 = sy - ty, t22 = t21 + 2 * ty;
    else
      t21 = ty - sy + 2 * sy, t22 = t21 + 2 * (m - ty);
  }
  long long tim = INF;
  chkmin(tim, gao(2 * n, -2 * m, t11, t21));
  chkmin(tim, gao(2 * n, -2 * m, t11, t22));
  chkmin(tim, gao(2 * n, -2 * m, t12, t21));
  chkmin(tim, gao(2 * n, -2 * m, t12, t22));
  return tim;
}
void print(int who) {
  if (who == 0)
    cout << "0 0"
         << "\n";
  else if (who == 1)
    cout << n << " "
         << "0\n";
  else if (who == 2)
    cout << "0 " << m << "\n";
  else if (who == 3)
    cout << n << " " << m << "\n";
  else
    cout << "-1"
         << "\n";
  exit(0);
}
int main() {
  cin >> n >> m >> sx >> sy >> vx >> vy;
  if (!vx) {
    if (sx == 0 && vy == 1)
      print(2);
    else if (sx == 0 && vy == -1)
      print(0);
    else if (sx == n && vy == 1)
      print(3);
    else if (sx == n && vy == -1)
      print(1);
    else
      print(-1);
  } else if (!vy) {
    if (sy == 0 && vx == 1)
      print(1);
    else if (sy == 0 && vx == -1)
      print(0);
    else if (sy == m && vx == 1)
      print(3);
    else if (sy == m && vx == -1)
      print(2);
    else
      print(-1);
  } else {
    long long tim = INF, who = -1;
    if (chkmin(tim, calc(sx, sy, vx, vy, 0, 0))) who = 0;
    if (chkmin(tim, calc(sx, sy, vx, vy, n, 0))) who = 1;
    if (chkmin(tim, calc(sx, sy, vx, vy, 0, m))) who = 2;
    if (chkmin(tim, calc(sx, sy, vx, vy, n, m))) who = 3;
    print(who);
  }
  return 0;
}

```


### Prompt

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

Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has n positions to install lamps, they correspond to the integer numbers from 0 to n - 1 on the OX axis. However, some positions are blocked and no post lamp can be placed there.

There are post lamps of different types which differ only by their power. When placed in position x, post lamp of power l illuminates the segment [x; x + l]. The power of each post lamp is always a positive integer number.

The post lamp shop provides an infinite amount of lamps of each type from power 1 to power k. Though each customer is only allowed to order post lamps of exactly one type. Post lamps of power l cost a_l each.

What is the minimal total cost of the post lamps of exactly one type Adilbek can buy to illuminate the entire segment [0; n] of the street? If some lamps illuminate any other segment of the street, Adilbek does not care, so, for example, he may place a lamp of power 3 in position n - 1 (even though its illumination zone doesn't completely belong to segment [0; n]).

Input

The first line contains three integer numbers n, m and k (1 ≤ k ≤ n ≤ 10^6, 0 ≤ m ≤ n) — the length of the segment of the street Adilbek wants to illuminate, the number of the blocked positions and the maximum power of the post lamp available.

The second line contains m integer numbers s_1, s_2, ..., s_m (0 ≤ s_1 < s_2 < ... s_m < n) — the blocked positions.

The third line contains k integer numbers a_1, a_2, ..., a_k (1 ≤ a_i ≤ 10^6) — the costs of the post lamps.

Output

Print the minimal total cost of the post lamps of exactly one type Adilbek can buy to illuminate the entire segment [0; n] of the street.

If illumintaing the entire segment [0; n] is impossible, print -1.

Examples

Input

6 2 3
1 3
1 2 3

Output

6

Input

4 3 4
1 2 3
1 10 100 1000

Output

1000

Input

5 1 5
0
3 3 3 3 3

Output

-1

Input

7 4 3
2 4 5 6
3 14 15

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int N = 1e6 + 10;
int n, m, k;
bool des[N];
int l[N], a[N];
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    int t;
    scanf("%d", &t);
    des[t] = true;
  }
  for (int i = 1; i <= k; i++) scanf("%d", &a[i]);
  if (des[0]) {
    printf("-1\n");
    return 0;
  }
  l[0] = 0;
  for (int i = 1; i < n; i++)
    if (des[i - 1])
      l[i] = l[i - 1];
    else
      l[i] = i;
  long long ans = 1ll << 62;
  for (int i = 1; i <= k; i++) {
    int cur = 0;
    long long tmp = 0;
    while (true) {
      tmp += a[i];
      cur += i;
      if (cur >= n) break;
      if (des[cur]) {
        if (cur - l[cur] + 1 >= i) {
          tmp = 1ll << 62;
          break;
        } else {
          cur = l[cur] - 1;
        }
      }
    }
    ans = min(ans, tmp);
  }
  if (ans == 1ll << 62)
    puts("-1");
  else
    cout << ans << endl;
}

```


### Prompt

Please create a solution in CPP to the following problem:

ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative.

Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...).

According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?

Constraints

* 1 ≤ K, A, B ≤ 10^{18}
* All input values are integers.

Input

Input is given from Standard Input in the following format:

K A B

Output

If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time.

Examples

Input

4000 2000 500

Output

5

Input

4000 500 2000

Output

-1

Input

1000000000000000000 2 1

Output

1999999999999999997

### Response

```cpp
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	long long k, a, b; cin >> k >> a >> b;
	if (a >= k)cout << "1\n";
	else if (a - b <= 0)cout << "-1\n";
	else {
		long long p = k - a;
		a -= b;
		if (p%a != 0)p += a - (p % a);
		cout << p / a * 2 + 1 << endl;
	}
	return 0;
}
```


### Prompt

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

There is a country with n citizens. The i-th of them initially has a_{i} money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently have.

Sometimes the government makes payouts to the poor: all citizens who have strictly less money than x are paid accordingly so that after the payout they have exactly x money. In this case the citizens don't send a receipt.

You know the initial wealth of every citizen and the log of all events: receipts and payouts. Restore the amount of money each citizen has after all events.

Input

The first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^{5}) — the numer of citizens.

The next line contains n integers a_1, a_2, ..., a_n (0 ≤ a_{i} ≤ 10^{9}) — the initial balances of citizens.

The next line contains a single integer q (1 ≤ q ≤ 2 ⋅ 10^{5}) — the number of events.

Each of the next q lines contains a single event. The events are given in chronological order.

Each event is described as either 1 p x (1 ≤ p ≤ n, 0 ≤ x ≤ 10^{9}), or 2 x (0 ≤ x ≤ 10^{9}). In the first case we have a receipt that the balance of the p-th person becomes equal to x. In the second case we have a payoff with parameter x.

Output

Print n integers — the balances of all citizens after all events.

Examples

Input

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

Output

3 2 3 4

Input

5
3 50 2 1 10
3
1 2 0
2 8
1 3 20

Output

8 8 20 8 10

Note

In the first example the balances change as follows: 1 2 3 4 → 3 3 3 4 → 3 2 3 4 → 3 2 3 4

In the second example the balances change as follows: 3 50 2 1 10 → 3 0 2 1 10 → 8 8 8 8 10 → 8 8 20 8 10

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct node {
  long long int ch, p, x;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, q;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cin >> q;
  vector<node> query(q);
  long long int ch, p, x, index;
  long long int track = -1;
  for (long long int i = 0; i < q; i++) {
    cin >> ch;
    if (ch == 1) {
      cin >> p >> x;
      node n1;
      n1.ch = 1;
      n1.p = p;
      n1.x = x;
      query[i] = n1;
    } else {
      cin >> x;
      if (x > track) {
        track = x;
        index = i;
      }
      node n1;
      n1.ch = 2;
      n1.p = -1;
      n1.x = x;
      query[i] = n1;
    }
  }
  if (track != -1) {
    vector<long long int> vis(n, 0);
    long long int maxm = 0;
    for (long long int i = q - 1; i >= 0; i--) {
      if (query[i].ch == 1 && vis[query[i].p - 1] == 0) {
        a[query[i].p - 1] = max(query[i].x, maxm);
        vis[query[i].p - 1] = 1;
      } else if (query[i].ch == 2) {
        maxm = max(maxm, query[i].x);
      }
    }
    for (long long int i = 0; i < n; i++) {
      if (vis[i] == 0) a[i] = max(a[i], track);
    }
  } else {
    vector<long long int> vis(n, 0);
    for (long long int i = q - 1; i >= 0; i--) {
      if (query[i].ch == 1 && vis[query[i].p - 1] == 0) {
        a[query[i].p - 1] = query[i].x;
        vis[query[i].p - 1] = 1;
      }
    }
  }
  for (long long int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.

Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.

Input

The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.

Output

Print the maximum possible even sum that can be obtained if we use some of the given integers.

Examples

Input

3
1 2 3

Output

6

Input

5
999999999 999999999 999999999 999999999 999999999

Output

3999999996

Note

In the first sample, we can simply take all three integers for a total sum of 6.

In the second sample Wet Shark should take any four out of five integers 999 999 999.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  vector<long long> odd;
  cin >> N;
  long long res = 0, x;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x % 2 == 0) {
      res += x;
    } else {
      odd.push_back(x);
    }
  }
  sort(odd.begin(), odd.end());
  for (int i = 0; i < odd.size(); i++) {
    res += odd[i];
  }
  if (res & 1) {
    res -= odd[0];
  }
  cout << res;
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

The city administration of IT City decided to fix up a symbol of scientific and technical progress in the city's main square, namely an indicator board that shows the effect of Moore's law in real time.

Moore's law is the observation that the number of transistors in a dense integrated circuit doubles approximately every 24 months. The implication of Moore's law is that computer performance as function of time increases exponentially as well.

You are to prepare information that will change every second to display on the indicator board. Let's assume that every second the number of transistors increases exactly 1.000000011 times.

Input

The only line of the input contains a pair of integers n (1000 ≤ n ≤ 10 000) and t (0 ≤ t ≤ 2 000 000 000) — the number of transistors in the initial time and the number of seconds passed since the initial time.

Output

Output one number — the estimate of the number of transistors in a dence integrated circuit in t seconds since the initial time. The relative error of your answer should not be greater than 10 - 6.

Examples

Input

1000 1000000

Output

1011.060722383550382782399454922040

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  int n, j, i, t;
  double m;
  while (scanf("%d%d", &n, &t) != EOF) {
    m = pow(1.000000011, t);
    m = n * m;
    printf("%lf\n", m);
  }
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti:

  * ti = 1, if the i-th child is good at programming,
  * ti = 2, if the i-th child is good at maths,
  * ti = 3, if the i-th child is good at PE

Each child happens to be good at exactly one of these three subjects.

The Team Scientific Decathlon Olympias requires teams of three students. The school teachers decided that the teams will be composed of three children that are good at different subjects. That is, each team must have one mathematician, one programmer and one sportsman. Of course, each child can be a member of no more than one team.

What is the maximum number of teams that the school will be able to present at the Olympiad? How should the teams be formed for that?

Input

The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.

Output

In the first line output integer w — the largest possible number of teams.

Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in the order of their appearance in the input. Each child must participate in no more than one team. If there are several solutions, print any of them.

If no teams can be compiled, print the only line with value w equal to 0.

Examples

Input

7
1 3 1 3 2 1 2

Output

2
3 5 2
6 7 4

Input

4
2 1 1 2

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> m;
  vector<int> s;
  vector<int> p;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    if (a == 1) {
      p.emplace_back(i);
    } else if (a == 2)
      m.emplace_back(i);
    else
      s.emplace_back(i);
  }
  if (m.size() >= 1 && s.size() >= 1 && p.size() >= 1)
    cout << min(min(m.size(), p.size()), s.size()) << endl;
  else
    cout << 0 << endl;
  do {
    if (m.size() && s.size() && p.size()) {
      cout << m.back() << " ";
      m.pop_back();
      cout << s.back() << " ";
      s.pop_back();
      cout << p.back();
      p.pop_back();
      cout << endl;
    } else {
      break;
    }
  } while (1);
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

It is said that a legendary treasure left by Mr. Yao is sleeping somewhere in Hachioji long ago. The treasure map, which is said to show its whereabouts, has been handed down by Yao's n descendants, divided into several pieces.

Now, the descendants of Mr. Yao were trying to cooperate to obtain the treasure. However, the treasure cannot be found only by a part of the treasure map that points to the location of the treasure. Therefore, all the descendants of Mr. Yao gathered and tried to collect the map in one place. However, even if I tried to put it into practice, I couldn't get together because I couldn't meet the schedule. However, this information about the treasure is valuable information that has been secretly passed down in the clan. Considering the risk of leakage, exchanging maps using public communication means is out of the question.

Therefore, I decided to collect the map for one descendant by repeating the process of meeting the descendants in person and handing over the map. There is no limit to the number of people that one person can meet in a day, but it is necessary that there is a schedule for each other.

Your job is to write a program that asks for at least how many days it will take to collect a map from a list of open days on schedule for each offspring.

By the way, the unity of the Yao clan is very tight. If the descendants who finally get the entire map betray the other descendants and take away the treasure, they will be sanctioned by the clan. The sanctions are so horrifying that it is virtually impossible for their descendants to actually carry away the treasure.

Input

The input consists of multiple datasets.

Each dataset consists of multiple rows. The first line contains the integer n (1 <n <= 50), which represents the number of people with a piece of the map. The next n lines contain the schedule for each descendant. Line i represents the schedule of the i-th descendant, with some integers separated by a single character space. The first integer fi (0 <= fi <= 30) is an integer that represents the number of days that the descendant's schedule is free. The following fi integers represent dates when the schedule is free. These dates differ from each other and are all greater than or equal to 1 and less than or equal to 30.

There is one line containing only 0 at the end of the input.

Output

Print one integer on one line for each dataset. If you can collect the map within 30 days, output the minimum number of days required to collect the map, otherwise output -1.

Addendum: The above "minimum number of days required to collect maps" means the date when all maps are collected earliest starting from one day.

Example

Input

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

Output

3

### Response

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

int main()
{
	int n, m, d;

	while (cin >> n, n) {
		vector<vector<int>> f(n, vector<int>(31, 0));
		vector<vector<long long>> dp(n, vector<long long>(31, 0));
		for (int i = 0; i < n; i++) {
			cin >> m;
			while (m--) {
				cin >> d;
				f[i][d] = 1;
			}
			dp[i][0] = 1L << i;
		}
		int res = -1;
		for (int i = 1; i < 31; i++) {
			for (int j = 0; j < n; j++) {
				if (!f[j][i]) {
					dp[j][i] = dp [j][i - 1];
					continue;
				}
				for (int k = 0; k < n; k++) {
					if (!f[k][i]) continue;
					dp[j][i] |= dp[k][i - 1];
				}
				if (dp[j][i] == (1L << n) - 1) {
					res = i;
					break;
				}
			}
			if (res != -1) break;
		}
		cout << res << endl;
	}

	return 0;
}
```


### Prompt

Develop a solution in Cpp to the problem described below:

Problem statement

Meatishi can increase or decrease the number of fingers.
There are n buns in front of Nikunishi-kun.
Meatishi is trying to count the number of steamed buns by breaking his finger.
There are only two shapes that Nishikun's fingers can take, whether they are broken or not.
Nikunishi understands binary numbers.
Nikunishi-kun can count numbers by associating each finger with a binary digit.
Nikunishi doesn't understand the logarithm.
Find the minimum number of fingers needed to count the buns instead of Nishikun.

input

n

Constraint

* An integer
* 0 ≤ n ≤ 1018

output

Print the answer on one line, and print a newline at the end.

sample

Sample input 1

0

Sample output 1

0

Sample input 2

Four

Sample output 2

3

Sample input 3

31

Sample output 3

Five

Sample input 4

36028797018963968

Sample output 4

56

Example

Input

0

Output

0

### Response

```cpp
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <limits>
#include <ctime>
#include <cassert>
#include <map>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <stack>
#include <queue>
#include <numeric>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)

template<typename ...> static inline int getchar_unlocked(void) { return getchar(); }
template<typename ...> static inline void putchar_unlocked(int c) { putchar(c); }
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int& x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; x = x * 10 + k - '0'; }if (m) x = -x; }
void reader(ll& x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; x = x * 10 + k - '0'; }if (m) x = -x; }
int reader(char c[]) { int i, s = 0; for (;;) { mygc(i); if (i != ' '&&i != '\n'&&i != '\r'&&i != '\t'&&i != EOF) break; }c[s++] = i; for (;;) { mygc(i); if (i == ' ' || i == '\n' || i == '\r' || i == '\t' || i == EOF) break; c[s++] = i; }c[s] = '\0'; return s; }
template <class T, class S> void reader(T& x, S& y) { reader(x); reader(y); }
template <class T, class S, class U> void reader(T& x, S& y, U& z) { reader(x); reader(y); reader(z); }
template <class T, class S, class U, class V> void reader(T& x, S& y, U& z, V & w) { reader(x); reader(y); reader(z); reader(w); }
void writer(int x, char c) { int s = 0, m = 0; char f[10]; if (x<0)m = 1, x = -x; while (x)f[s++] = x % 10, x /= 10; if (!s)f[s++] = 0; if (m)mypc('-'); while (s--)mypc(f[s] + '0'); mypc(c); }
void writer(ll x, char c) { int s = 0, m = 0; char f[20]; if (x<0)m = 1, x = -x; while (x)f[s++] = x % 10, x /= 10; if (!s)f[s++] = 0; if (m)mypc('-'); while (s--)mypc(f[s] + '0'); mypc(c); }
void writer(const char c[]) { int i; for (i = 0; c[i] != '\0'; i++)mypc(c[i]); }
void writer(const char x[], char c) { int i; for (i = 0; x[i] != '\0'; i++)mypc(x[i]); mypc(c); }
template<class T> void writerLn(T x) { writer(x, '\n'); }
template<class T, class S> void writerLn(T x, S y) { writer(x, ' '); writer(y, '\n'); }
template<class T, class S, class U> void writerLn(T x, S y, U z) { writer(x, ' '); writer(y, ' '); writer(z, '\n'); }
template<class T> void writerArr(T x[], int n) { if (!n) { mypc('\n'); return; }FOR(i, n - 1)writer(x[i], ' '); writer(x[n - 1], '\n'); }

ll mod_pow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }
template<class T> T extgcd(T a, T b, T& x, T& y) { for (T u = y = 1, v = x = 0; a;) { T q = b / a; swap(x -= q * u, u); swap(y -= q * v, v); swap(b -= q * a, a); } return b; }
template<class T> T mod_inv(T a, T m) { T x, y; extgcd(a, m, x, y); return (m + x % m) % m; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

int main() {
	ll n; cin >> n;
	int ans = 0;
	while (n) ans++, n /= 2;
	cout << ans << endl;
	return 0;
}
```