### Prompt

Construct a Cpp code solution to the problem outlined:

Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every <image> the condition ai ≥ ai - 1 is met, so the sequence is sorted.

Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai (<image>).

Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously.

Input

The first line contains three integers n, k, x (1 ≤ k ≤ n ≤ 100, 1 ≤ x ≤ 99) — the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself.

The second line contains n integer numbers ai (2 ≤ ai ≤ 100) — the time Luba has to spend to do i-th chore.

It is guaranteed that <image>, and for each <image> ai ≥ ai - 1.

Output

Print one number — minimum time Luba needs to do all n chores.

Examples

Input

4 2 2
3 6 7 10

Output

13

Input

5 2 1
100 100 100 100 100

Output

302

Note

In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13.

In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100·3 + 2·1 = 302.

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  int a[100], b[100], c, d, e, i, j, k = 0, m, n, o;
  scanf("%d %d %d", &c, &d, &e);
  for (i = 0; i < c; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 0; i < c; i++) {
    for (j = 1; j < c; j++) {
      if (a[j - 1] > a[j]) {
        o = a[j - 1];
        a[j - 1] = a[j];
        a[j] = o;
      }
    }
  }
  m = c - d;
  for (j = 0; j < m; j++) {
    k = k + a[j];
  }
  n = k + d * e;
  printf("%d\n", n);
}

```


### Prompt

Please formulate a CPP solution to the following problem:

While creating high loaded systems one should pay a special attention to caching. This problem will be about one of the most popular caching algorithms called LRU (Least Recently Used).

Suppose the cache may store no more than k objects. At the beginning of the workflow the cache is empty. When some object is queried we check if it is present in the cache and move it here if it's not. If there are more than k objects in the cache after this, the least recently used one should be removed. In other words, we remove the object that has the smallest time of the last query.

Consider there are n videos being stored on the server, all of the same size. Cache can store no more than k videos and caching algorithm described above is applied. We know that any time a user enters the server he pick the video i with probability pi. The choice of the video is independent to any events before.

The goal of this problem is to count for each of the videos the probability it will be present in the cache after 10100 queries.

Input

The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 20) — the number of videos and the size of the cache respectively. Next line contains n real numbers pi (0 ≤ pi ≤ 1), each of them is given with no more than two digits after decimal point.

It's guaranteed that the sum of all pi is equal to 1.

Output

Print n real numbers, the i-th of them should be equal to the probability that the i-th video will be present in the cache after 10100 queries. You answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

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

Examples

Input

3 1
0.3 0.2 0.5

Output

0.3 0.2 0.5

Input

2 1
0.0 1.0

Output

0.0 1.0

Input

3 2
0.3 0.2 0.5

Output

0.675 0.4857142857142857 0.8392857142857143

Input

3 3
0.2 0.3 0.5

Output

1.0 1.0 1.0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 1000000000;
const int MAX = 22;
double P[MAX];
double D[1 << MAX];
int C[1 << MAX];
double R[MAX];
int main() {
  int n, m;
  cin >> n >> m;
  m = min(m, n);
  for (int i = (0); i < (n); ++i) {
    cin >> P[i];
  }
  for (int i = (1); i < (1 << n); ++i) {
    C[i] = C[i >> 1] + (i & 1);
  }
  D[0] = 1;
  for (int i = (0); i < (1 << n); ++i) {
    if (C[i] >= m) continue;
    double s = 0;
    for (int j = (0); j < (n); ++j) {
      if ((i & (1 << j)) == 0) s += P[j];
    }
    if (s != 0) {
      for (int j = (0); j < (n); ++j) {
        if ((i & (1 << j)) == 0) {
          D[i ^ (1 << j)] += D[i] * P[j] / s;
          R[j] += D[i] * P[j] / s;
        }
      }
    }
  }
  for (int i = (0); i < (n); ++i) {
    printf("%.9f ", R[i]);
  }
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number n, modulo m.

Number x is considered close to number n modulo m, if:

  * it can be obtained by rearranging the digits of number n,
  * it doesn't have any leading zeroes,
  * the remainder after dividing number x by m equals 0.

Roman is a good mathematician, but the number of such numbers is too huge for him. So he asks you to help him.

Input

The first line contains two integers: n (1 ≤ n < 1018) and m (1 ≤ m ≤ 100).

Output

In a single line print a single integer — the number of numbers close to number n modulo m.

Examples

Input

104 2

Output

3

Input

223 4

Output

1

Input

7067678 8

Output

47

Note

In the first sample the required numbers are: 104, 140, 410.

In the second sample the required number is 232.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int siz;
long long f[(1 << 18)][105];
bool chk[20];
int getbit(int mask, int k) { return ((mask >> (k - 1)) & 1); }
int cnt(int mask) {
  int tmp = 0;
  for (int i = 1; i <= siz; i++)
    if (getbit(mask, i)) tmp++;
  return tmp;
}
int main() {
  string s;
  int m;
  cin >> s >> m;
  siz = s.size();
  f[0][0] = 1;
  for (int i = 0; i < (1 << siz) - 1; i++) {
    int num = cnt(i);
    for (int k = 0; k < m; k++) {
      if (!f[i][k]) continue;
      memset(chk, 0, sizeof(chk));
      for (int j = 1; j <= siz; j++)
        if (getbit(i, j) == 0) {
          if ((s[j - 1] == '0' && num == 0) || chk[s[j - 1] - '0']) continue;
          f[i + (1 << (j - 1))][(10 * k + (s[j - 1] - '0')) % m] += f[i][k];
          chk[s[j - 1] - '0'] = 1;
        }
    }
  }
  cout << f[(1 << siz) - 1][0] << endl;
}

```


### Prompt

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

There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too.

Each shark will grow some number of flowers si. For i-th shark value si is random integer equiprobably chosen in range from li to ri. Wet Shark has it's favourite prime number p, and he really likes it! If for any pair of neighbouring sharks i and j the product si·sj is divisible by p, then Wet Shark becomes happy and gives 1000 dollars to each of these sharks.

At the end of the day sharks sum all the money Wet Shark granted to them. Find the expectation of this value.

Input

The first line of the input contains two space-separated integers n and p (3 ≤ n ≤ 100 000, 2 ≤ p ≤ 109) — the number of sharks and Wet Shark's favourite prime number. It is guaranteed that p is prime.

The i-th of the following n lines contains information about i-th shark — two space-separated integers li and ri (1 ≤ li ≤ ri ≤ 109), the range of flowers shark i can produce. Remember that si is chosen equiprobably among all integers from li to ri, inclusive.

Output

Print a single real number — the expected number of dollars that the sharks receive in total. You answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

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

Examples

Input

3 2
1 2
420 421
420420 420421

Output

4500.0

Input

3 5
1 4
2 3
11 14

Output

0.0

Note

A prime number is a positive integer number that is divisible only by 1 and itself. 1 is not considered to be prime.

Consider the first sample. First shark grows some number of flowers from 1 to 2, second sharks grows from 420 to 421 flowers and third from 420420 to 420421. There are eight cases for the quantities of flowers (s0, s1, s2) each shark grows:

  1. (1, 420, 420420): note that s0·s1 = 420, s1·s2 = 176576400, and s2·s0 = 420420. For each pair, 1000 dollars will be awarded to each shark. Therefore, each shark will be awarded 2000 dollars, for a total of 6000 dollars.
  2. (1, 420, 420421): now, the product s2·s0 is not divisible by 2. Therefore, sharks s0 and s2 will receive 1000 dollars, while shark s1 will receive 2000. The total is 4000.
  3. (1, 421, 420420): total is 4000
  4. (1, 421, 420421): total is 0.
  5. (2, 420, 420420): total is 6000.
  6. (2, 420, 420421): total is 6000.
  7. (2, 421, 420420): total is 6000.
  8. (2, 421, 420421): total is 4000.

The expected value is <image>.

In the second sample, no combination of quantities will garner the sharks any money.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int n, p;
const long long int N = 1e5;
long long int a[N];
long long int l[N], r[N];
void input() {
  scanf("%I64d %I64d", &n, &p);
  for (long long int i = 0; i < n; i++) scanf("%I64d %I64d", &l[i], &r[i]);
}
long long int good(long long int left, long long int right) {
  long long int ans = -(left - 1) / p + right / p;
  return ans;
}
long double cal(long long int i, long long int j) {
  long long int s1 = good(l[i], r[i]);
  long long int s2 = good(l[j], r[j]);
  long long int to1 = r[i] - l[i] + 1;
  long long int to2 = r[j] - l[j] + 1;
  s1 = to1 - s1;
  s2 = to2 - s2;
  long double ans =
      (long double)(s2 * s1 + 0.00) / (long double)(to1 * to2 + 0.00);
  ans = 1.00 - ans;
  return ans;
}
void solve() {
  long double ans = 0.00;
  for (long long int i = 0; i < n; i++) {
    long long int j = (i + 1) % n;
    ans += cal(i, j) * 2000.00;
  }
  cout << fixed << setprecision(10) << ans << endl;
}
int main() {
  input();
  solve();
}

```


### Prompt

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

Mike has discovered a new way to encode permutations. If he has a permutation P = [p1, p2, ..., pn], he will encode it in the following way:

Denote by A = [a1, a2, ..., an] a sequence of length n which will represent the code of the permutation. For each i from 1 to n sequentially, he will choose the smallest unmarked j (1 ≤ j ≤ n) such that pi < pj and will assign to ai the number j (in other words he performs ai = j) and will mark j. If there is no such j, he'll assign to ai the number  - 1 (he performs ai = - 1).

Mike forgot his original permutation but he remembers its code. Your task is simple: find any permutation such that its code is the same as the code of Mike's original permutation.

You may assume that there will always be at least one valid permutation.

Input

The first line contains single integer n (1 ≤ n ≤ 500 000) — length of permutation.

The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ n or ai = - 1) — the code of Mike's permutation.

You may assume that all positive values from A are different.

Output

In first and only line print n numbers p1, p2, ..., pn (1 ≤ pi ≤ n) — a permutation P which has the same code as the given one. Note that numbers in permutation are distinct.

Examples

Input

6
2 -1 1 5 -1 4

Output

2 6 1 4 5 3

Input

8
2 -1 4 -1 6 -1 8 -1

Output

1 8 2 7 3 6 4 5

Note

For the permutation from the first example:

i = 1, the smallest j is 2 because p2 = 6 > p1 = 2.

i = 2, there is no j because p2 = 6 is the greatest element in the permutation.

i = 3, the smallest j is 1 because p1 = 2 > p3 = 1.

i = 4, the smallest j is 5 (2 was already marked) because p5 = 5 > p4 = 4.

i = 5, there is no j because 2 is already marked.

i = 6, the smallest j is 4 because p4 = 4 > p6 = 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, a[N], b[N];
struct TNode {
  pair<int, int> v;
  int l, r;
} t[N << 2];
inline int lc(int pos) { return pos << 1; }
inline int rc(int pos) { return pos << 1 | 1; }
inline void pushup(int pos) { t[pos].v = max(t[lc(pos)].v, t[rc(pos)].v); }
void build(int pos, int l, int r) {
  t[pos].l = l;
  t[pos].r = r;
  if (l == r) {
    t[pos].v = {b[l], l};
    return;
  }
  int mid = (l + r) >> 1;
  build(lc(pos), l, mid);
  build(rc(pos), mid + 1, r);
  pushup(pos);
}
pair<int, int> query(int pos, int l, int r) {
  if (t[pos].l == l && t[pos].r == r) return t[pos].v;
  int mid = (t[pos].l + t[pos].r) >> 1;
  if (r <= mid)
    return query(lc(pos), l, r);
  else if (l > mid)
    return query(rc(pos), l, r);
  else
    return max(query(lc(pos), l, mid), query(rc(pos), mid + 1, r));
}
void del(int pos, int p) {
  if (t[pos].l == t[pos].r) {
    t[pos].v = {0, t[pos].l};
    return;
  }
  int mid = (t[pos].l + t[pos].r) >> 1;
  if (p <= mid)
    del(lc(pos), p);
  else
    del(rc(pos), p);
  pushup(pos);
}
int q[N], m, p[N];
bool vis[N];
void dfs(int pos) {
  vis[pos] = 1;
  del(1, pos);
  if (b[pos] != n + 1 && !vis[b[pos]]) dfs(b[pos]);
  if (a[pos] > 1)
    while (1) {
      auto ret = query(1, 1, a[pos] - 1);
      if (ret.first > pos)
        dfs(ret.second), assert(ret.second);
      else
        break;
    }
  q[++m] = pos;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] != -1)
      b[a[i]] = i;
    else
      a[i] = n + 1;
  }
  for (int i = 1; i <= n; i++)
    if (!b[i]) b[i] = n + 1;
  build(1, 1, n);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  m = 0;
  for (int i = 1; i <= n; i++) p[q[i]] = ++m;
  for (int i = 1; i <= n; i++) cout << p[i] << ' ';
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Recently Monocarp got a job. His working day lasts exactly m minutes. During work, Monocarp wants to drink coffee at certain moments: there are n minutes a_1, a_2, ..., a_n, when he is able and willing to take a coffee break (for the sake of simplicity let's consider that each coffee break lasts exactly one minute).

However, Monocarp's boss doesn't like when Monocarp takes his coffee breaks too often. So for the given coffee break that is going to be on minute a_i, Monocarp must choose the day in which he will drink coffee during the said minute, so that every day at least d minutes pass between any two coffee breaks. Monocarp also wants to take these n coffee breaks in a minimum possible number of working days (he doesn't count days when he is not at work, and he doesn't take coffee breaks on such days). Take into account that more than d minutes pass between the end of any working day and the start of the following working day.

For each of the n given minutes determine the day, during which Monocarp should take a coffee break in this minute. You have to minimize the number of days spent.

Input

The first line contains three integers n, m, d (1 ≤ n ≤ 2⋅10^{5}, n ≤ m ≤ 10^{9}, 1 ≤ d ≤ m) — the number of coffee breaks Monocarp wants to have, the length of each working day, and the minimum number of minutes between any two consecutive coffee breaks.

The second line contains n distinct integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ m), where a_i is some minute when Monocarp wants to have a coffee break.

Output

In the first line, write the minimum number of days required to make a coffee break in each of the n given minutes.

In the second line, print n space separated integers. The i-th of integers should be the index of the day during which Monocarp should have a coffee break at minute a_i. Days are numbered from 1. If there are multiple optimal solutions, you may print any of them.

Examples

Input

4 5 3
3 5 1 2

Output

3
3 1 1 2

Input

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

Output

2
2 1 1 2 2 1 2 1 1 2

Note

In the first example, Monocarp can take two coffee breaks during the first day (during minutes 1 and 5, 3 minutes will pass between these breaks). One break during the second day (at minute 2), and one break during the third day (at minute 3).

In the second example, Monocarp can determine the day of the break as follows: if the minute when he wants to take a break is odd, then this break is on the first day, if it is even, then this break is on the second day.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void solve() {
  int n, m, d;
  cin >> n >> m >> d;
  int a[n];
  set<pair<int, int>> s;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s.insert({a[i], i});
  }
  vector<int> ans(n, -1);
  int k = 0;
  while (s.size()) {
    k++;
    int pos = s.begin()->second;
    ans[pos] = k;
    s.erase(s.begin());
    while (1) {
      auto it = s.lower_bound({a[pos] + 1 + d, 0});
      if (it == s.end()) break;
      pos = it->second;
      s.erase(it);
      ans[pos] = k;
    }
  }
  cout << k << "\n";
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company.

Kefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend to feel poor compared to somebody else in the company (Kefa doesn't count). A friend feels poor if in the company there is someone who has at least d units of money more than he does. Also, Kefa wants the total friendship factor of the members of the company to be maximum. Help him invite an optimal company!

Input

The first line of the input contains two space-separated integers, n and d (1 ≤ n ≤ 105, <image>) — the number of Kefa's friends and the minimum difference between the amount of money in order to feel poor, respectively.

Next n lines contain the descriptions of Kefa's friends, the (i + 1)-th line contains the description of the i-th friend of type mi, si (0 ≤ mi, si ≤ 109) — the amount of money and the friendship factor, respectively.

Output

Print the maximum total friendship factir that can be reached.

Examples

Input

4 5
75 5
0 100
150 20
75 1

Output

100

Input

5 100
0 7
11 32
99 10
46 8
87 54

Output

111

Note

In the first sample test the most profitable strategy is to form a company from only the second friend. At all other variants the total degree of friendship will be worse.

In the second sample test we can take all the friends.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
vector<long long> v;
long long n, d;
long long sum = 0;
long long A[N];
long long f[N];
vector<pair<long long, long long>> vv;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  cin >> d;
  long long i;
  for (i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    vv.push_back({a, b});
  }
  sort(vv.begin(), vv.end());
  for (i = 0; i < n; i++) {
    sum += vv[i].second;
    A[i] = sum;
    f[i] = vv[i].second;
    v.push_back(vv[i].first);
  }
  long long best = INT_MIN;
  for (i = 0; i < n; i++) {
    long long xx = (v[i] - d);
    long long yy = (v[i] + d);
    auto p = upper_bound(v.begin(), v.end(), xx);
    long long xxx = p - v.begin();
    long long cur1 = A[i] - A[xxx] + f[xxx];
    auto q = lower_bound(v.begin(), v.end(), yy);
    long long yyy = q - v.begin();
    yyy--;
    long long cur2 = A[yyy] - A[i] + f[i];
    long long cur = max(cur1, cur2);
    if (cur > best) {
      best = cur;
    }
  }
  cout << best << "\n";
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Sereja has an array a, consisting of n integers a1, a2, ..., an. The boy cannot sit and do nothing, he decided to study an array. Sereja took a piece of paper and wrote out m integers l1, l2, ..., lm (1 ≤ li ≤ n). For each number li he wants to know how many distinct numbers are staying on the positions li, li + 1, ..., n. Formally, he want to find the number of distinct numbers among ali, ali + 1, ..., an.?

Sereja wrote out the necessary array elements but the array was so large and the boy was so pressed for time. Help him, find the answer for the described question for each li.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the array elements.

Next m lines contain integers l1, l2, ..., lm. The i-th line contains integer li (1 ≤ li ≤ n).

Output

Print m lines — on the i-th line print the answer to the number li.

Examples

Input

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

Output

6
6
6
6
6
5
4
3
2
1

### Response

```cpp
#include <bits/stdc++.h>
int a[100005], b[100005], c[100005];
int main() {
  int n, q, i, k, ans;
  while (~scanf("%d %d", &n, &q)) {
    memset(b, 0, sizeof(b));
    memset(c, 0, sizeof(c));
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    c[a[n - 1]] = 1;
    b[n - 1] = 1;
    for (i = n - 2; i >= 0; i--) {
      if (c[a[i]] != 1) {
        c[a[i]] = 1;
        b[i] = b[i + 1] + 1;
      } else {
        b[i] = b[i + 1];
      }
    }
    for (i = 0; i < q; i++) {
      scanf("%d", &k);
      printf("%d\n", b[k - 1]);
    }
  }
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN".

Find the number of cows that can currently show their hands without affecting any betting decisions.

Input

The first line contains a single integer, n (2 ≤ n ≤ 2·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED".

Output

The first line should contain a single integer denoting the number of players that can currently show their hands.

Examples

Input

6
AFFAAA

Output

4

Input

3
AFI

Output

1

Note

In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand.

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  long j, n, I, A, F;
  char aux;
  scanf("%li", &n);
  scanf("%c", &aux);
  A = I = F = 0;
  for (j = 1; j <= n; j++) {
    scanf("%c", &aux);
    if (aux == 'A') {
      A++;
    }
    if (aux == 'F') {
      F++;
    }
    if (aux == 'I') {
      I++;
    }
  }
  if (I == 1) {
    printf("1\n");
  } else {
    if (I > 1) {
      printf("0\n");
    } else {
      printf("%ld\n", A);
    }
  }
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

A wise king declared a new calendar. "Tomorrow shall be the first day of the calendar, that is, the day 1 of the month 1 of the year 1. Each year consists of 10 months, from month 1 through month 10, and starts from a big month. A common year shall start with a big month, followed by small months and big months one after another. Therefore the first month is a big month, the second month is a small month, the third a big month, ..., and the 10th and last month a small one. A big month consists of 20 days and a small month consists of 19 days. However years which are multiples of three, that are year 3, year 6, year 9, and so on, shall consist of 10 big months and no small month."

Many years have passed since the calendar started to be used. For celebration of the millennium day (the year 1000, month 1, day 1), a royal lottery is going to be organized to send gifts to those who have lived as many days as the number chosen by the lottery. Write a program that helps people calculate the number of days since their birthdate to the millennium day.

Input

The input is formatted as follows.

> n
>  Y1 M1 D1
>  Y2 M2 D2
>  ...
>  Yn Mn Dn

Here, the first line gives the number of datasets as a positive integer n, which is less than or equal to 100. It is followed by n datasets. Each dataset is formatted in a line and gives three positive integers, Yi (< 1000), Mi (≤ 10), and Di (≤ 20), that correspond to the year, month and day, respectively, of a person's birthdate in the king's calendar. These three numbers are separated by a space.

Output

For the birthdate specified in each dataset, print in a line the number of days from the birthdate, inclusive, to the millennium day, exclusive. Output lines should not contain any character other than this number.

Sample Input

8
1 1 1
344 3 1
696 5 1
182 9 5
998 8 7
344 2 19
696 4 19
999 10 20

Output for the Sample Input

196470
128976
59710
160715
252
128977
59712
1

Example

Input

8
1 1 1
344 3 1
696 5 1
182 9 5
998 8 7
344 2 19
696 4 19
999 10 20

Output

196470
128976
59710
160715
252
128977
59712
1

### Response

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

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		int Y, M, D;
		cin >> Y >> M >> D;

		int offset = (10 - M + 1) * 20 - (D - 1);
		if (Y % 3 != 0){
			offset -= (12 - M) / 2;
		}

		Y++;
		int uruutime = (1002 - Y) / 3;
		int ans = offset + 195 * (1000 - Y) + uruutime * 5;
		cout << ans << endl;
	}
	return 0;
}
```


### Prompt

Please formulate a Cpp solution to the following problem:

You are given a bipartite graph: the first part of this graph contains n_1 vertices, the second part contains n_2 vertices, and there are m edges. The graph can contain multiple edges.

Initially, each edge is colorless. For each edge, you may either leave it uncolored (it is free), paint it red (it costs r coins) or paint it blue (it costs b coins). No edge can be painted red and blue simultaneously.

There are three types of vertices in this graph — colorless, red and blue. Colored vertices impose additional constraints on edges' colours:

  * for each red vertex, the number of red edges indicent to it should be strictly greater than the number of blue edges incident to it;
  * for each blue vertex, the number of blue edges indicent to it should be strictly greater than the number of red edges incident to it.

Colorless vertices impose no additional constraints.

Your goal is to paint some (possibly none) edges so that all constraints are met, and among all ways to do so, you should choose the one with minimum total cost.

Input

The first line contains five integers n_1, n_2, m, r and b (1 ≤ n_1, n_2, m, r, b ≤ 200) — the number of vertices in the first part, the number of vertices in the second part, the number of edges, the amount of coins you have to pay to paint an edge red, and the amount of coins you have to pay to paint an edge blue, respectively.

The second line contains one string consisting of n_1 characters. Each character is either U, R or B. If the i-th character is U, then the i-th vertex of the first part is uncolored; R corresponds to a red vertex, and B corresponds to a blue vertex.

The third line contains one string consisting of n_2 characters. Each character is either U, R or B. This string represents the colors of vertices of the second part in the same way.

Then m lines follow, the i-th line contains two integers u_i and v_i (1 ≤ u_i ≤ n_1, 1 ≤ v_i ≤ n_2) denoting an edge connecting the vertex u_i from the first part and the vertex v_i from the second part.

The graph may contain multiple edges.

Output

If there is no coloring that meets all the constraints, print one integer -1.

Otherwise, print an integer c denoting the total cost of coloring, and a string consisting of m characters. The i-th character should be U if the i-th edge should be left uncolored, R if the i-th edge should be painted red, or B if the i-th edge should be painted blue. If there are multiple colorings with minimum possible cost, print any of them.

Examples

Input

3 2 6 10 15
RRB
UB
3 2
2 2
1 2
1 1
2 1
1 1

Output

35
BUURRU

Input

3 1 3 4 5
RRR
B
2 1
1 1
3 1

Output

-1

Input

3 1 3 4 5
URU
B
2 1
1 1
3 1

Output

14
RBB

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
namespace io {
template <class free>
inline void read(free&);
inline void read(char&);
template <class f1, class... f2>
inline void read(f1&, f2&...);
inline void read(char& c) {
  while (c = getchar(), c == ' ' || c == '\n' || c == '\r')
    ;
}
template <class f1, class... f2>
inline void read(f1& x, f2&... y) {
  read(x), read(y...);
}
template <class free>
inline void read(free& x) {
  x ^= x;
  register char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
}
}  // namespace io
using io::read;
struct point {
  int next, to, w, w1;
} ar[4050];
bool is[4050];
int ps, pt, a1[4050], a2[4050], pre[4050];
int tot, a[4050], head[4050], art(1), fee;
int ps1, pt1, T[4050], flow[4050], dis[4050];
inline bool bfs();
inline void link(int, int, int, int);
int main() {
  int n1, n2, m, r, b, ans(0);
  read(n1, n2, m, r, b), tot = n1 + n2;
  for (int i(1); i <= tot; ++i) {
    char c;
    switch (read(c), c) {
      case 'U':
        a[i] = -1;
        break;
      case 'R':
        a[i] = 0;
        break;
      case 'B':
        a[i] = 1;
        break;
    }
  }
  ps = ++tot, pt = ++tot;
  for (int i(1); i <= n1; ++i) {
    if (!~a[i]) {
      link(ps, i, 0x3f3f3f3f, 0), link(i, pt, 0x3f3f3f3f, 0);
      continue;
    }
    if (a[i])
      --a1[i], ++a1[pt], link(i, pt, 0x3f3f3f3f, 0);
    else
      ++a1[i], --a1[ps], link(ps, i, 0x3f3f3f3f, 0);
  }
  for (int i(n1 + 1); i <= n1 + n2; ++i) {
    if (!~a[i]) {
      link(ps, i, 0x3f3f3f3f, 0), link(i, pt, 0x3f3f3f3f, 0);
      continue;
    }
    if (a[i])
      ++a1[i], --a1[ps], link(ps, i, 0x3f3f3f3f, 0);
    else
      --a1[i], ++a1[pt], link(i, pt, 0x3f3f3f3f, 0);
  }
  for (int i(1), u, v; i <= m; ++i)
    read(u, v), link(u, v + n1, 1, r), a2[i] = art, link(v + n1, u, 1, b);
  link(pt, ps, 0x3f3f3f3f, 0), ps1 = ++tot, pt1 = ++tot;
  for (int i(1); i <= n1 + n2 + 2; ++i) {
    if (!a1[i]) continue;
    if (a1[i] > 0)
      link(ps1, i, a1[i], 0);
    else
      link(i, pt1, -a1[i], 0);
  }
  while (bfs())
    ;
  for (int i(head[ps1]); i; i = ar[i].next)
    if (ar[i].w) return puts("-1"), 0;
  printf("%d\n", fee);
  for (int i(1); i <= m; ++i)
    if (ar[a2[i]].w)
      putchar('R');
    else if (ar[a2[i] + 2].w)
      putchar('B');
    else
      putchar('U');
  return 0;
}
inline bool bfs() {
  memset(dis, 0x3f, tot + 1 << 2);
  int L(0), R(1);
  dis[T[1] = ps1] = 0, flow[ps1] = 0x3f3f3f3f;
  while (L++ ^ R)
    for (int i(head[is[T[L = L ^ 4050 ? L : 0]] = 0, T[L]]), i1; i;
         i = ar[i].next)
      if (ar[i].w && dis[i1 = ar[i].to] > dis[T[L]] + ar[i].w1) {
        dis[i1] = dis[T[L]] + ar[i].w1;
        flow[i1] = min(flow[T[L]], ar[i].w), pre[i1] = i;
        if (is[i1]) continue;
        is[T[++R, R = R ^ 4050 ? R : 4050] = i1] = 1;
      }
  if (dis[pt1] >= 0x3f3f3f3f) return false;
  for (int i(pt1); pre[i]; i = ar[pre[i] ^ 1].to)
    ar[pre[i]].w -= flow[pt1], ar[pre[i] ^ 1].w += flow[pt1];
  return fee += dis[pt1] * flow[pt1], true;
}
inline void link(int u, int v, int w, int w1) {
  ar[++art] = {head[u], v, w, w1}, head[u] = art;
  ar[++art] = {head[v], u, 0, -w1}, head[v] = art;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

We have a point A with coordinate x = n on OX-axis. We'd like to find an integer point B (also on OX-axis), such that the absolute difference between the distance from O to B and the distance from A to B is equal to k.

<image> The description of the first test case.

Since sometimes it's impossible to find such point B, we can, in one step, increase or decrease the coordinate of A by 1. What is the minimum number of steps we should do to make such point B exist?

Input

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

The only line of each test case contains two integers n and k (0 ≤ n, k ≤ 10^6) — the initial position of point A and desirable absolute difference.

Output

For each test case, print the minimum number of steps to make point B exist.

Example

Input

6
4 0
5 8
0 1000000
0 0
1 0
1000000 1000000

Output

0
3
1000000
0
1
0

Note

In the first test case (picture above), if we set the coordinate of B as 2 then the absolute difference will be equal to |(2 - 0) - (4 - 2)| = 0 and we don't have to move A. So the answer is 0.

In the second test case, we can increase the coordinate of A by 3 and set the coordinate of B as 0 or 8. The absolute difference will be equal to |8 - 0| = 8, so the answer is 3.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    if (n == k) {
      cout << 0 << "\n";
      continue;
    } else {
      if ((n + k) % 2 == 0) {
        if ((n + k) / 2 <= n) {
          cout << 0 << "\n";
          continue;
        } else {
          cout << k - n << "\n";
        }
      } else {
        n++;
        if ((n + k) / 2 <= n) {
          cout << 1 << "\n";
          continue;
        } else {
          cout << k - n + 1 << "\n";
        }
      }
    }
  }
}

```


### Prompt

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

There is a matrix A of size x × y filled with integers. For every <image>, <image> Ai, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix.

You have traversed some path in this matrix. Your path can be described as a sequence of visited cells a1, a2, ..., an denoting that you started in the cell containing the number a1, then moved to the cell with the number a2, and so on.

From the cell located in i-th line and j-th column (we denote this cell as (i, j)) you can move into one of the following cells:

  1. (i + 1, j) — only if i < x;
  2. (i, j + 1) — only if j < y;
  3. (i - 1, j) — only if i > 1;
  4. (i, j - 1) — only if j > 1.

Notice that making a move requires you to go to an adjacent cell. It is not allowed to stay in the same cell. You don't know x and y exactly, but you have to find any possible values for these numbers such that you could start in the cell containing the integer a1, then move to the cell containing a2 (in one step), then move to the cell containing a3 (also in one step) and so on. Can you choose x and y so that they don't contradict with your sequence of moves?

Input

The first line contains one integer number n (1 ≤ n ≤ 200000) — the number of cells you visited on your path (if some cell is visited twice, then it's listed twice).

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers in the cells on your path.

Output

If all possible values of x and y such that 1 ≤ x, y ≤ 109 contradict with the information about your path, print NO.

Otherwise, print YES in the first line, and in the second line print the values x and y such that your path was possible with such number of lines and columns in the matrix. Remember that they must be positive integers not exceeding 109.

Examples

Input

8
1 2 3 6 9 8 5 2

Output

YES
3 3

Input

6
1 2 1 2 5 3

Output

NO

Input

2
1 10

Output

YES
4 9

Note

The matrix and the path on it in the first test looks like this:

<image>

Also there exist multiple correct answers for both the first and the third examples.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long int Maxn3 = 1e3 + 10;
const long long int Maxn4 = 1e4 + 10;
const long long int Maxn5 = 1e5 + 10;
const long long int Maxn6 = 1e6 + 10;
const long long int Maxn7 = 1e7 + 10;
const long long int Maxn8 = 1e8 + 10;
const long long int Maxn9 = 1e9 + 10;
const long long int Maxn18 = 1e18 + 10;
const long long int Mod1 = 1e7 + 7;
const long long int Mod2 = 1e9 + 7;
const long long int LLMax = LLONG_MAX;
const long long int LLMin = LLONG_MIN;
const long long int INTMax = INT_MAX;
const long long int INTMin = INT_MIN;
long long int mn = LLMax, mx = LLMin;
const int MX = 2e5 + 100;
long long int c[MX];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int n, k = 0;
  cin >> n;
  for (long long int i = 0; i < n; i++) cin >> c[i];
  bool m = 0;
  for (long long int i = 1; i < n; i++) {
    long long int p = abs(c[i] - c[i - 1]);
    if (!p) return cout << "NO", 0;
    if (p > 1) {
      m = 1;
      k = p;
      break;
    }
  }
  if (!m) {
    cout << "YES" << '\n';
    return cout << 1 << ' ' << 1000000000, 0;
  }
  for (long long int i = 1; i < n; i++) {
    long long int p = abs(c[i] - c[i - 1]);
    if (!p || (p != 1 and p != k) ||
        (p == 1 and ((c[i] % k == 0 and c[i - 1] == c[i] + 1) ||
                     (c[i - 1] % k == 0 and c[i] == c[i - 1] + 1))))
      return cout << "NO", 0;
  }
  cout << "YES" << endl;
  cout << 1000000000 << ' ' << k;
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Sergey Semyonovich is a mayor of a county city N and he used to spend his days and nights in thoughts of further improvements of Nkers' lives. Unfortunately for him, anything and everything has been done already, and there are no more possible improvements he can think of during the day (he now prefers to sleep at night). However, his assistants have found a solution and they now draw an imaginary city on a paper sheet and suggest the mayor can propose its improvements.

Right now he has a map of some imaginary city with n subway stations. Some stations are directly connected with tunnels in such a way that the whole map is a tree (assistants were short on time and enthusiasm). It means that there exists exactly one simple path between each pair of station. We call a path simple if it uses each tunnel no more than once.

One of Sergey Semyonovich's favorite quality objectives is the sum of all pairwise distances between every pair of stations. The distance between two stations is the minimum possible number of tunnels on a path between them.

Sergey Semyonovich decided to add new tunnels to the subway map. In particular, he connected any two stations u and v that were not connected with a direct tunnel but share a common neighbor, i.e. there exists such a station w that the original map has a tunnel between u and w and a tunnel between w and v. You are given a task to compute the sum of pairwise distances between all pairs of stations in the new map.

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 200 000) — the number of subway stations in the imaginary city drawn by mayor's assistants. Each of the following n - 1 lines contains two integers u_i and v_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i), meaning the station with these indices are connected with a direct tunnel.

It is guaranteed that these n stations and n - 1 tunnels form a tree.

Output

Print one integer that is equal to the sum of distances between all pairs of stations after Sergey Semyonovich draws new tunnels between all pairs of stations that share a common neighbor in the original map.

Examples

Input

4
1 2
1 3
1 4

Output

6

Input

4
1 2
2 3
3 4

Output

7

Note

In the first sample, in the new map all pairs of stations share a direct connection, so the sum of distances is 6.

In the second sample, the new map has a direct tunnel between all pairs of stations except for the pair (1, 4). For these two stations the distance is 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> ma[200005];
int p[200005];
long long yu;
void dfs(int pos, int fa, int now) {
  p[pos] = 1;
  yu += 1LL * now;
  int sz = ma[pos].size();
  for (int i = 0; i < sz; i++) {
    int to = ma[pos][i];
    if (to == fa) continue;
    dfs(to, pos, 1 - now);
    p[pos] += p[to];
  }
}
int main() {
  int n;
  scanf("%d", &n);
  yu = 0;
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    ma[a].push_back(b);
    ma[b].push_back(a);
  }
  dfs(1, -1, 0);
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    res += 1LL * p[i] * (n - p[i]);
  }
  res += yu * (n - yu);
  printf("%lld\n", res / 2);
}

```


### Prompt

Generate a CPP solution to the following problem:

At Moscow Workshops ICPC team gets a balloon for each problem they solved first. Team MSU Red Panda got so many balloons that they didn't know how to spend them. So they came up with a problem with them.

There are several balloons, not more than 10^6 in total, each one is colored in one of k colors. We can perform the following operation: choose k-1 balloons such that they are of k-1 different colors, and recolor them all into remaining color. We can perform this operation any finite number of times (for example, we can only perform the operation if there are at least k-1 different colors among current balls).

How many different balloon configurations can we get? Only number of balloons of each color matters, configurations differing only by the order of balloons are counted as equal. As this number can be very large, output it modulo 998244353.

Input

The first line contains a single integer k (2 ≤ k ≤ 10^5) —the number of colors.

The second line contains k integers a_1, a_2, …, a_k (0 ≤ a_i) —initial configuration of balloons. a_i is number of balloons of color i. The total number of balloons doesn't exceed 10^6. In other words,

a_1 + a_2 + a_3 + … + a_k ≤ 10^6.

Output

Output number of possible configurations modulo 998244353.

Examples

Input

3
0 1 2

Output

3

Input

4
1 1 1 1

Output

5

Input

5
0 0 1 2 3

Output

1

Input

3
2 2 8

Output

31

Note

In the first example, there are 3 configurations we can get: [0, 1, 2], [2, 0, 1], [1, 2, 0].

In the second example, we can apply the operation not more than once, and possible configurations are: [1, 1, 1, 1], [0, 0, 0, 4], [0, 0, 4, 0], [0, 4, 0, 0], [4, 0, 0, 0].

In the third example, we can't apply any operations, so the only achievable configuration is the starting one.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10, mod = 998244353;
const long long inf = 1e18;
int a[maxn], n, cnt[maxn], fac[maxn], ifac[maxn];
int C(int n, int k) {
  if (n < k) return 0;
  return 1ll * fac[n] * ifac[k] % mod * ifac[n - k] % mod;
}
int solve(int k) {
  int ls = 0, ans = 1;
  for (int i = 0; i < k; i++) {
    ls += cnt[i];
    ans = (ans + C(i + n - ls, n - 1)) % mod;
  }
  return ans;
}
int Pow(int a, int b) {
  int ans = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod) {
    if (b & 1) ans = 1ll * ans * a % mod;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  fac[0] = 1;
  for (int i = 1; i < maxn; i++) fac[i] = 1ll * i * fac[i - 1] % mod;
  ifac[maxn - 1] = Pow(fac[maxn - 1], mod - 2);
  for (int i = maxn - 2; i >= 0; i--)
    ifac[i] = 1ll * (i + 1) * ifac[i + 1] % mod;
  int sm = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sm += a[i] - (a[i] % n);
    cnt[a[i]]++;
  }
  sm /= n;
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (a[i] < i) {
      return cout << solve(a[i]) << endl, 0;
    }
  }
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < n; i++) {
    cnt[a[i] % n]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = (ans + C(sm + n - 1, n - 1)) % mod;
    sm++;
    sm -= cnt[i];
  }
  return cout << ans << endl, 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Wilbur the pig really wants to be a beaver, so he decided today to pretend he is a beaver and bite at trees to cut them down.

There are n trees located at various positions on a line. Tree i is located at position xi. All the given positions of the trees are distinct.

The trees are equal, i.e. each tree has height h. Due to the wind, when a tree is cut down, it either falls left with probability p, or falls right with probability 1 - p. If a tree hits another tree while falling, that tree will fall in the same direction as the tree that hit it. A tree can hit another tree only if the distance between them is strictly less than h.

For example, imagine there are 4 trees located at positions 1, 3, 5 and 8, while h = 3 and the tree at position 1 falls right. It hits the tree at position 3 and it starts to fall too. In it's turn it hits the tree at position 5 and it also starts to fall. The distance between 8 and 5 is exactly 3, so the tree at position 8 will not fall.

As long as there are still trees standing, Wilbur will select either the leftmost standing tree with probability 0.5 or the rightmost standing tree with probability 0.5. Selected tree is then cut down. If there is only one tree remaining, Wilbur always selects it. As the ground is covered with grass, Wilbur wants to know the expected total length of the ground covered with fallen trees after he cuts them all down because he is concerned about his grass-eating cow friends. Please help Wilbur.

Input

The first line of the input contains two integers, n (1 ≤ n ≤ 2000) and h (1 ≤ h ≤ 108) and a real number p (0 ≤ p ≤ 1), given with no more than six decimal places.

The second line of the input contains n integers, x1, x2, ..., xn ( - 108 ≤ xi ≤ 108) in no particular order.

Output

Print a single real number — the expected total length of the ground covered by trees when they have all fallen down. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

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

Examples

Input

2 2 0.500000
1 2

Output

3.250000000

Input

4 3 0.4
4 3 1 2

Output

6.631200000

Note

Consider the first example, we have 2 trees with height 2.

<image> There are 3 scenarios:

1. Both trees falls left. This can either happen with the right tree falling left first, which has <image> probability (also knocking down the left tree), or the left tree can fall left and then the right tree can fall left, which has <image> probability. Total probability is <image>.

2. Both trees fall right. This is analogous to (1), so the probability of this happening is <image>.

3. The left tree fall left and the right tree falls right. This is the only remaining scenario so it must have <image> probability.

Cases 1 and 2 lead to a total of 3 units of ground covered, while case 3 leads to a total of 4 units of ground covered. Thus, the expected value is <image>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int ll[2005], lr[2005];
double f[2005][2005][2][2];
int a[2005];
int n, h;
double k;
double dfs(int l, int r, int al, int ar) {
  if (l > r) return 0;
  if (f[l][r][al][ar] != 0) return f[l][r][al][ar];
  double s = 0;
  s += k * 0.5 * (min(a[l] - a[l - 1] - al * h, h) + dfs(l + 1, r, 0, ar));
  s +=
      (1 - k) * 0.5 * (min(a[r + 1] - a[r] - ar * h, h) + dfs(l, r - 1, al, 0));
  if (ll[r] <= l) {
    s += k * 0.5 * (min(a[l] - a[l - 1] - h * al, h) + a[r] - a[l]);
  } else
    s += k * 0.5 * (dfs(l, ll[r] - 1, al, 1) + a[r] - a[ll[r]] + h);
  if (lr[l] >= r) {
    s += (1 - k) * 0.5 * (min(a[r + 1] - a[r] - h * ar, h) + a[r] - a[l]);
  } else
    s += (1 - k) * 0.5 * (dfs(lr[l] + 1, r, 1, ar) + a[lr[l]] - a[l] + h);
  return f[l][r][al][ar] = s;
}
int main() {
  cin >> n >> h >> k;
  a[0] = -9999999999;
  a[n + 1] = 9999999999;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  memset(f, 0, sizeof(f));
  sort(a + 1, a + 1 + n);
  ll[1] = 1;
  lr[n] = n;
  for (int i = 2; i <= n; i++) {
    if (a[i] - h < a[i - 1]) {
      ll[i] = ll[i - 1];
    } else
      ll[i] = i;
  }
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] + h > a[i + 1]) {
      lr[i] = lr[i + 1];
    } else
      lr[i] = i;
  }
  printf("%.9lf\n", dfs(1, n, 0, 0));
}

```


### Prompt

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

Alice wants to send an email to Miku on her mobile phone.

The only buttons that can be used for input on mobile phones are number buttons. Therefore, in order to input characters, the number buttons are pressed several times to input characters. The following characters are assigned to the number buttons of the mobile phone, and the confirmation button is assigned to button 0. With this mobile phone, you are supposed to press the confirm button after you finish entering one character.

* 1:.,!? (Space)
* 2: a b c
* 3: d e f
* 4: g h i
* 5: j k l
* 6: m n o
* 7: p q r s
* 8: t u v
* 9: w x y z
* 0: Confirm button

For example, if you press button 2, button 2, or button 0, the letter changes from'a'to'b', and the confirm button is pressed here, so the letter b is output. If you enter the same number in succession, the changing characters will loop. That is, if you press button 2 five times and then button 0, the letters change from'a'→' b'→'c' →'a' →'b', and the confirm button is pressed here. 'b' is output.

You can press the confirm button when no button is pressed, but in that case no characters are output.

Your job is to recreate the message Alice created from a row of buttons pressed by Alice.

Input

The first line gives the number of test cases. Each test case is then given a string of digits up to 1024 in length in one row.

Output

Print the string of Alice's message line by line for each test case. However, you can assume that the output is one or more and less than 76 characters.

Example

Input

5
20
220
222220
44033055505550666011011111090666077705550301110
000555555550000330000444000080000200004440000

Output

a
b
b
hello, world!
keitai

### Response

```cpp
#include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		string key[]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
		string input;
		cin>>input;
		stringstream b(input);
		int num=0,count=0;
		while(1){
			char c;
			if(!(b>>c))break;
			int input=c-'0';
			if(input!=0){
				count++;
				num=input;
			}
			else {
				if(count!=0)
					cout<<key[num-1][(count-1)%key[num-1].size()];
				num=0;count=0;
			}
		}
		cout<<endl;
	}
	return 0;
}
```


### Prompt

Develop a solution in cpp to the problem described below:

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

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

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

Input

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

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

Output

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

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

Examples

Input

11:20

Output

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

Input

2A:13

Output

0

Input

000B:00001

Output

-1

Note

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

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

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool isprime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
vector<long long int> prime;
void sieve(int n) {
  bool bakh[n + 1];
  memset(bakh, true, sizeof(bakh));
  for (int p = 2; p * p <= n; p++) {
    if (bakh[p] == true) {
      for (int i = p * p; i <= n; i += p) bakh[i] = false;
    }
  }
  for (int p = 2; p <= n; p++)
    if (bakh[p]) prime.push_back(p);
}
long long int eulertotient(long long int z) {
  long long int fac = z;
  for (long long int i = 0; prime[i] * prime[i] <= z; i++) {
    if (z % prime[i] == 0) {
      fac -= (fac / prime[i]);
      while (z % prime[i] == 0) z /= prime[i];
    }
  }
  if (z > 1) fac -= (fac / z);
  return fac;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  long long int g = gcd(a, b);
  long long int ans = (a * b) / g;
  return ans;
}
long long int modInverse(long long int a, long long int m) {
  long long int hvf = gcd(a, m);
  if (hvf == 1) return power(a, m - 2, m);
  return -1;
}
void multiply(long long int F[2][2], long long int M[2][2]) {
  long long int x = F[0][0] * M[0][0] + F[0][1] * M[1][0];
  long long int y = F[0][0] * M[0][1] + F[0][1] * M[1][1];
  long long int z = F[1][0] * M[0][0] + F[1][1] * M[1][0];
  long long int w = F[1][0] * M[0][1] + F[1][1] * M[1][1];
  F[0][0] = x;
  F[0][1] = y;
  F[1][0] = z;
  F[1][1] = w;
}
void powermat(long long int F[2][2], long long int n) {
  if (n == 0 || n == 1) return;
  long long int M[2][2] = {{1, 1}, {1, 0}};
  powermat(F, n / 2);
  multiply(F, F);
  if (n % 2 != 0) multiply(F, M);
}
long long int fib(long long int n) {
  long long int F[2][2] = {{1, 1}, {1, 0}};
  if (n == 0) return 0;
  powermat(F, n - 1);
  return F[0][0];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  string st;
  cin >> st;
  long long int l = st.length();
  long long int p = st.find(':');
  long long int x, q = 0, Min = 0;
  for (long long int i = 0; i < l; i++) {
    if (st[i] == ':') continue;
    x = st[i] - 48;
    if (x > 9) x -= 7;
    q = max(q, x);
  }
  q += 1;
  long long int b[2];
  long long int k = 0;
  b[0] = 0;
  b[1] = 0;
  long long int c = 0;
  for (long long int i = q; i <= 60; i++) {
    k = 0;
    b[0] = 0;
    b[1] = 0;
    for (long long int j = 0; j < l; j++) {
      if (st[j] == ':') {
        k += 1;
        continue;
      }
      x = st[j] - 48;
      if (x > 9) x -= 7;
      q = max(q, x);
      b[k] = b[k] * i + x;
    }
    if (b[0] <= 23 && b[1] < 60)
      c++;
    else
      break;
  }
  if (c == 0) {
    cout << 0 << endl;
    return 0;
  }
  long long int s[2] = {0};
  k = 0;
  for (long long int i = 0; i < l; i++) {
    if (st[i] == ':') {
      k++;
      continue;
    }
    x = st[i] - 48;
    if (x > 9) x -= 7;
    q = max(q, x);
    s[k] = s[k] * 100 + x;
  }
  if (s[0] < 24 && s[1] < 60) {
    cout << -1 << endl;
    return 0;
  }
  for (long long int i = 0; i < c; i++) cout << q + i << " ";
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Let's look at the following process: initially you have an empty stack and an array s of the length l. You are trying to push array elements to the stack in the order s_1, s_2, s_3, ... s_{l}. Moreover, if the stack is empty or the element at the top of this stack is not equal to the current element, then you just push the current element to the top of the stack. Otherwise, you don't push the current element to the stack and, moreover, pop the top element of the stack.

If after this process the stack remains empty, the array s is considered stack exterminable.

There are samples of stack exterminable arrays:

  * [1, 1];
  * [2, 1, 1, 2];
  * [1, 1, 2, 2];
  * [1, 3, 3, 1, 2, 2];
  * [3, 1, 3, 3, 1, 3];
  * [3, 3, 3, 3, 3, 3];
  * [5, 1, 2, 2, 1, 4, 4, 5];

Let's consider the changing of stack more details if s = [5, 1, 2, 2, 1, 4, 4, 5] (the top of stack is highlighted).

  1. after pushing s_1 = 5 the stack turn into [5];
  2. after pushing s_2 = 1 the stack turn into [5, 1];
  3. after pushing s_3 = 2 the stack turn into [5, 1, 2];
  4. after pushing s_4 = 2 the stack turn into [5, 1];
  5. after pushing s_5 = 1 the stack turn into [5];
  6. after pushing s_6 = 4 the stack turn into [5, 4];
  7. after pushing s_7 = 4 the stack turn into [5];
  8. after pushing s_8 = 5 the stack is empty.

You are given an array a_1, a_2, …, a_n. You have to calculate the number of its subarrays which are stack exterminable.

Note, that you have to answer q independent queries.

Input

The first line contains one integer q (1 ≤ q ≤ 3 ⋅ 10^5) — the number of queries.

The first line of each query contains one integer n (1 ≤ n ≤ 3 ⋅ 10^5) — the length of array a.

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

It is guaranteed that the sum of all n over all queries does not exceed 3 ⋅ 10^5.

Output

For each test case print one integer in single line — the number of stack exterminable subarrays of the array a.

Example

Input

3
5
2 1 1 2 2
6
1 2 1 1 3 2
9
3 1 2 2 1 6 6 3 3

Output

4
1
8

Note

In the first query there are four stack exterminable subarrays: a_{1 … 4} = [2, 1, 1, 2], a_{2 … 3} = [1, 1], a_{2 … 5} = [1, 1, 2, 2], a_{4 … 5} = [2, 2].

In the second query, only one subarray is exterminable subarray — a_{3 … 4}.

In the third query, there are eight stack exterminable subarrays: a_{1 … 8}, a_{2 … 5}, a_{2 … 7}, a_{2 … 9}, a_{3 … 4}, a_{6 … 7}, a_{6 … 9}, a_{8 … 9}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1008691207;
const long long inf = mod * mod;
const long long d2 = (mod + 1) / 2;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);
const int C_SIZE = 3121000;
namespace {
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a, int b) {
  if (a < b || b < 0) return 0;
  return fact[a] * finv[b] % mod * finv[a - b] % mod;
}
void init_C(int n) {
  fact[0] = finv[0] = inv[1] = 1;
  for (int i = 2; i < n; i++) {
    inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
  }
  for (int i = 1; i < n; i++) {
    fact[i] = fact[i - 1] * i % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}
long long pw(long long a, long long b) {
  if (a < 0LL) return 0;
  if (b < 0LL) return 0;
  long long ret = 1;
  while (b) {
    if (b % 2) ret = ret * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return ret;
}
long long pw_mod(long long a, long long b, long long M) {
  if (a < 0LL) return 0;
  if (b < 0LL) return 0;
  long long ret = 1;
  while (b) {
    if (b % 2) ret = ret * a % M;
    a = a * a % M;
    b /= 2;
  }
  return ret;
}
int ABS(int a) { return max(a, -a); }
long long ABS(long long a) { return max(a, -a); }
double ABS(double a) { return max(a, -a); }
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}  // namespace
int p[310000];
int par[310000];
int num[310000];
int cnt[310000];
map<pair<int, int>, int> M;
int main() {
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int a;
    scanf("%d", &a);
    for (int i = 0; i < a; i++) {
      scanf("%d", p + i);
      p[i]--;
    }
    for (int i = 0; i <= a + 10; i++) {
      par[i] = num[i] = cnt[i] = 0;
    }
    M.clear();
    long long ret = 0;
    int at = 0;
    int sz = 1;
    num[at] = -1;
    cnt[at] = 1;
    for (int i = 0; i < a; i++) {
      if (p[i] == num[at]) {
        at = par[at];
      } else {
        if (M.count(make_pair(at, p[i]))) {
          int id = M[make_pair(at, p[i])];
          at = id;
        } else {
          M[make_pair(at, p[i])] = sz;
          num[sz] = p[i];
          par[sz] = at;
          at = sz;
          sz++;
        }
      }
      ret += cnt[at];
      cnt[at]++;
    }
    printf("%lld\n", ret);
  }
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Limak is a grizzly bear. He is big and dreadful. You were chilling in the forest when you suddenly met him. It's very unfortunate for you. He will eat all your cookies unless you can demonstrate your mathematical skills. To test you, Limak is going to give you a puzzle to solve.

It's a well-known fact that Limak, as every bear, owns a set of numbers. You know some information about the set:

  * The elements of the set are distinct positive integers.
  * The number of elements in the set is n. The number n is divisible by 5.
  * All elements are between 1 and b, inclusive: bears don't know numbers greater than b.
  * For each r in {0, 1, 2, 3, 4}, the set contains exactly <image> elements that give remainder r when divided by 5. (That is, there are <image> elements divisible by 5, <image> elements of the form 5k + 1, <image> elements of the form 5k + 2, and so on.)

Limak smiles mysteriously and gives you q hints about his set. The i-th hint is the following sentence: "If you only look at elements that are between 1 and upToi, inclusive, you will find exactly quantityi such elements in my set."

In a moment Limak will tell you the actual puzzle, but something doesn't seem right... That smile was very strange. You start to think about a possible reason. Maybe Limak cheated you? Or is he a fair grizzly bear?

Given n, b, q and hints, check whether Limak can be fair, i.e. there exists at least one set satisfying the given conditions. If it's possible then print ''fair". Otherwise, print ''unfair".

Input

The first line contains three integers n, b and q (5 ≤ n ≤ b ≤ 104, 1 ≤ q ≤ 104, n divisible by 5) — the size of the set, the upper limit for numbers in the set and the number of hints.

The next q lines describe the hints. The i-th of them contains two integers upToi and quantityi (1 ≤ upToi ≤ b, 0 ≤ quantityi ≤ n).

Output

Print ''fair" if there exists at least one set that has all the required properties and matches all the given hints. Otherwise, print ''unfair".

Examples

Input

10 20 1
10 10

Output

fair

Input

10 20 3
15 10
5 0
10 5

Output

fair

Input

10 20 2
15 3
20 10

Output

unfair

Note

In the first example there is only one set satisfying all conditions: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.

In the second example also there is only one set satisfying all conditions: {6, 7, 8, 9, 10, 11, 12, 13, 14, 15}.

Easy to see that there is no set satisfying all conditions from the third example. So Limak lied to you :-(

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 10105;
int n, b, q, st, ed;
int First[maxn], cnt, dis[maxn];
struct edge {
  int to, Next, flow, c;
} Tree[maxn * 100];
void init() {
  cnt = 0;
  memset(First, -1, sizeof(First));
}
void addedge(int from, int to, int flow) {
  Tree[cnt].to = to;
  Tree[cnt].Next = First[from];
  Tree[cnt].flow = flow;
  First[from] = cnt++;
  Tree[cnt].to = from;
  Tree[cnt].Next = First[to];
  Tree[cnt].flow = 0;
  First[to] = cnt++;
}
bool bfs(int st, int ed) {
  memset(dis, 0, sizeof(dis));
  queue<int> Q;
  dis[st] = 1;
  Q.push(st);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = First[u]; i != -1; i = Tree[i].Next) {
      int v = Tree[i].to;
      int flow = Tree[i].flow;
      if (flow && !dis[v]) {
        dis[v] = dis[u] + 1;
        if (v == ed) return true;
        Q.push(v);
      }
    }
  }
  return false;
}
int dfs(int u, int minf) {
  if (u == ed) {
    return minf;
  }
  if (minf == 0) return minf;
  int f = 0;
  for (int i = First[u]; i != -1; i = Tree[i].Next) {
    int v = Tree[i].to;
    if (Tree[i].flow && dis[v] == dis[u] + 1) {
      int tmp = dfs(v, min(Tree[i].flow, minf));
      Tree[i].flow -= tmp;
      Tree[i ^ 1].flow += tmp;
      f += tmp;
      minf -= tmp;
      if (minf == 0) return f;
    }
  }
  return f;
}
int dinic(int st, int ed) {
  int res = 0;
  while (bfs(st, ed)) res += dfs(st, INF);
  return res;
}
struct node {
  int up, num;
  bool operator<(const node& A) const {
    if (A.up != up) return A.up > up;
    return A.num > num;
  }
} ax[10005];
int sum[10];
int main() {
  init();
  scanf("%d%d%d", &n, &b, &q);
  st = 0, ed = q + 5 + 10;
  for (int i = 1; i <= q; i++) scanf("%d%d", &ax[i].up, &ax[i].num);
  sort(ax + 1, ax + 1 + q);
  ax[q + 1].up = b, ax[q + 1].num = n;
  for (int i = 1; i <= q + 1; i++) {
    int nowv = ax[i].up - ax[i - 1].up;
    int nowb = ax[i].num - ax[i - 1].num;
    if (ax[i].num > n || nowb > nowv || nowb < 0) {
      puts("unfair");
      return 0;
    }
    for (int j = ax[i - 1].up + 1; j <= ax[i].up; j++) {
      sum[j % 5]++;
    }
    for (int j = 0; j < 5; j++) addedge(i, q + j + 2, sum[j]);
    addedge(st, i, nowb);
    memset(sum, 0, sizeof(sum));
  }
  for (int i = 1; i <= 5; i++) addedge(q + i + 1, ed, n / 5);
  int max1 = dinic(st, ed);
  if (max1 == n)
    puts("fair");
  else
    puts("unfair");
  return 0;
}

```


### Prompt

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

VK news recommendation system daily selects interesting publications of one of n disjoint categories for each user. Each publication belongs to exactly one category. For each category i batch algorithm selects a_i publications.

The latest A/B test suggests that users are reading recommended publications more actively if each category has a different number of publications within daily recommendations. The targeted algorithm can find a single interesting publication of i-th category within t_i seconds.

What is the minimum total time necessary to add publications to the result of batch algorithm execution, so all categories have a different number of publications? You can't remove publications recommended by the batch algorithm.

Input

The first line of input consists of single integer n — the number of news categories (1 ≤ n ≤ 200 000).

The second line of input consists of n integers a_i — the number of publications of i-th category selected by the batch algorithm (1 ≤ a_i ≤ 10^9).

The third line of input consists of n integers t_i — time it takes for targeted algorithm to find one new publication of category i (1 ≤ t_i ≤ 10^5).

Output

Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.

Examples

Input

5
3 7 9 7 8
5 2 5 7 5

Output

6

Input

5
1 2 3 4 5
1 1 1 1 1

Output

0

Note

In the first example, it is possible to find three publications of the second type, which will take 6 seconds.

In the second example, all news categories contain a different number of publications.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long p = 1e9 + 7;
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b % 2) {
      res = (res * a) % p;
    }
    a = (a * a) % p;
    b /= 2;
  }
  return res;
}
long long inv(long long a) { return power(a, p - 2); }
void dijks(vector<vector<pair<int, int> > > &adj, int s, vector<int> &d) {
  d[s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  pq.push(make_pair(d[s], 0));
  while (!pq.empty()) {
    pair<int, int> temp = pq.top();
    pq.pop();
    int u = temp.second;
    if (d[u] < temp.first) continue;
    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i].first;
      int wt = adj[u][i].second;
      if (d[v] <= d[u] + wt)
        continue;
      else {
        d[v] = d[u] + wt;
        pq.push(make_pair(d[v], v));
      }
    }
  }
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
int main() {
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    vector<pair<long long, long long> > a(n);
    for (int i = 0; i < n; i++) cin >> a[i].first;
    for (int i = 0; i < n; i++) cin >> a[i].second;
    long long ans = 0;
    sort(a.begin(), a.end());
    priority_queue<long long> pq;
    long long sum = 0;
    for (int i = 0; i < n;) {
      long long ind = i;
      long long num = a[i].first;
      while (num == a[i].first) i++;
      if (!pq.empty() || i - ind > 1) {
        for (int x = ind; x < i; x++) {
          sum += a[x].second;
          pq.push(a[x].second);
        }
        while (i == n || num < a[i].first) {
          if (!pq.empty())
            sum -= pq.top();
          else
            break;
          pq.pop();
          ans += sum;
          num++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

```


### Prompt

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

Karen has just arrived at school, and she has a math test today!

<image>

The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual test. So, they just put one question in the test that is worth all the points.

There are n integers written on a row. Karen must alternately add and subtract each pair of adjacent integers, and write down the sums or differences on the next row. She must repeat this process on the values on the next row, and so on, until only one integer remains. The first operation should be addition.

Note that, if she ended the previous row by adding the integers, she should start the next row by subtracting, and vice versa.

The teachers will simply look at the last integer, and then if it is correct, Karen gets a perfect score, otherwise, she gets a zero for the test.

Karen has studied well for this test, but she is scared that she might make a mistake somewhere and it will cause her final answer to be wrong. If the process is followed, what number can she expect to be written on the last row?

Since this number can be quite large, output only the non-negative remainder after dividing it by 109 + 7.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 200000), the number of numbers written on the first row.

The next line contains n integers. Specifically, the i-th one among these is ai (1 ≤ ai ≤ 109), the i-th number on the first row.

Output

Output a single integer on a line by itself, the number on the final row after performing the process above.

Since this number can be quite large, print only the non-negative remainder after dividing it by 109 + 7.

Examples

Input

5
3 6 9 12 15

Output

36

Input

4
3 7 5 2

Output

1000000006

Note

In the first test case, the numbers written on the first row are 3, 6, 9, 12 and 15.

Karen performs the operations as follows:

<image>

The non-negative remainder after dividing the final number by 109 + 7 is still 36, so this is the correct output.

In the second test case, the numbers written on the first row are 3, 7, 5 and 2.

Karen performs the operations as follows:

<image>

The non-negative remainder after dividing the final number by 109 + 7 is 109 + 6, so this is the correct output.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, MOD = 1000000007;
template <typename T>
void read(T &x) {
  bool neg = false;
  unsigned char c = getchar();
  for (; (c ^ 48) > 9; c = getchar())
    if (c == '-') neg = true;
  for (x = 0; (c ^ 48) < 10; c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
  if (neg) x = -x;
}
int n, a[N], f[N] = {1}, m, ans;
inline int pow(int a1, int b) {
  long long a = a1, c = 1;
  while (b) {
    if (b & 1) c *= a, c %= MOD;
    a *= a, a %= MOD;
    b >>= 1;
  }
  return (int)c;
}
inline int inv(int a) { return pow(a, MOD - 2); }
int main() {
  read(n);
  for (int i = 0, i_end = n; i < i_end; ++i) read(a[i]);
  if (n == 1) return printf("%d\n", a[0]), 0;
  m = (n >> 1) - 1;
  for (int i = 1, i_end = m + 1; i < i_end; ++i)
    f[i] = (long long)f[i - 1] * i % MOD;
  if (((long long)n * (n - 1)) & 2) {
    if (n & 1)
      for (int i = 0, i_end = --n; i < i_end; ++i)
        if (i & 1)
          a[i] -= a[i + 1];
        else
          a[i] += a[i + 1];
    for (int i = 0, i_end = n; i < i_end; ++i) a[i] %= MOD;
    for (int i = 0, i_end = n >> 1; i < i_end; ++i) {
      long long b = a[i << 1] + a[(i << 1) + 1];
      ans += b * f[m] % MOD * inv((long long)f[i] * f[m - i] % MOD) % MOD;
      ans %= MOD;
    }
  } else {
    if (n & 1)
      for (int i = 0, i_end = --n; i < i_end; ++i)
        if (i & 1)
          a[i] -= a[i + 1];
        else
          a[i] += a[i + 1];
    for (int i = 0, i_end = n; i < i_end; ++i) a[i] %= MOD;
    for (int i = 0, i_end = n >> 1; i < i_end; ++i) {
      long long b = a[i << 1] - a[(i << 1) + 1];
      ans += b * f[m] % MOD * inv((long long)f[i] * f[m - i] % MOD) % MOD;
      ans %= MOD;
    }
  }
  ans += MOD;
  ans %= MOD;
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

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

Little Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them.

Consider two dices. When thrown each dice shows some integer from 1 to n inclusive. For each dice the probability of each outcome is given (of course, their sum is 1), and different dices may have different probability distributions.

We throw both dices simultaneously and then calculate values max(a, b) and min(a, b), where a is equal to the outcome of the first dice, while b is equal to the outcome of the second dice. You don't know the probability distributions for particular values on each dice, but you know the probability distributions for max(a, b) and min(a, b). That is, for each x from 1 to n you know the probability that max(a, b) would be equal to x and the probability that min(a, b) would be equal to x. Find any valid probability distribution for values on the dices. It's guaranteed that the input data is consistent, that is, at least one solution exists.

Input

First line contains the integer n (1 ≤ n ≤ 100 000) — the number of different values for both dices.

Second line contains an array consisting of n real values with up to 8 digits after the decimal point — probability distribution for max(a, b), the i-th of these values equals to the probability that max(a, b) = i. It's guaranteed that the sum of these values for one dice is 1. The third line contains the description of the distribution min(a, b) in the same format.

Output

Output two descriptions of the probability distribution for a on the first line and for b on the second line.

The answer will be considered correct if each value of max(a, b) and min(a, b) probability distribution values does not differ by more than 10 - 6 from ones given in input. Also, probabilities should be non-negative and their sums should differ from 1 by no more than 10 - 6.

Examples

Input

2
0.25 0.75
0.75 0.25

Output

0.5 0.5
0.5 0.5

Input

3
0.125 0.25 0.625
0.625 0.25 0.125

Output

0.25 0.25 0.5
0.5 0.25 0.25

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
double prea[maxn], sufb[maxn];
double sum1[maxn], sum2[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    double x;
    scanf("%lf", &x);
    prea[i] = prea[i - 1] + x;
  }
  for (int i = 1; i <= n; i++) scanf("%lf", &sufb[i]);
  for (int i = n; i >= 1; i--) sufb[i] += sufb[i + 1];
  for (int i = 1; i <= n; i++) {
    double aa = 1;
    double bb = -(1 + prea[i] - sufb[i + 1]);
    double cc = prea[i];
    double delta = max(0.0, bb * bb - 4 * aa * cc);
    sum1[i] = (-bb - sqrt(delta)) / (2 * aa);
    sum2[i] = (-bb + sqrt(delta)) / (2 * aa);
  }
  for (int i = 1; i <= n; i++)
    printf("%.12f%c", sum2[i] - sum2[i - 1], i == n ? '\n' : ' ');
  for (int i = 1; i <= n; i++)
    printf("%.12f%c", sum1[i] - sum1[i - 1], i == n ? '\n' : ' ');
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

The Smart Beaver from ABBYY has a long history of cooperating with the "Institute of Cytology and Genetics". Recently, the Institute staff challenged the Beaver with a new problem. The problem is as follows.

There is a collection of n proteins (not necessarily distinct). Each protein is a string consisting of lowercase Latin letters. The problem that the scientists offered to the Beaver is to select a subcollection of size k from the initial collection of proteins so that the representativity of the selected subset of proteins is maximum possible.

The Smart Beaver from ABBYY did some research and came to the conclusion that the representativity of a collection of proteins can be evaluated by a single number, which is simply calculated. Let's suppose we have a collection {a1, ..., ak} consisting of k strings describing proteins. The representativity of this collection is the following value:

<image>

where f(x, y) is the length of the longest common prefix of strings x and y; for example, f("abc", "abd") = 2, and f("ab", "bcd") = 0.

Thus, the representativity of collection of proteins {"abc", "abd", "abe"} equals 6, and the representativity of collection {"aaa", "ba", "ba"} equals 2.

Having discovered that, the Smart Beaver from ABBYY asked the Cup contestants to write a program that selects, from the given collection of proteins, a subcollection of size k which has the largest possible value of representativity. Help him to solve this problem!

Input

The first input line contains two integers n and k (1 ≤ k ≤ n), separated by a single space. The following n lines contain the descriptions of proteins, one per line. Each protein is a non-empty string of no more than 500 characters consisting of only lowercase Latin letters (a...z). Some of the strings may be equal.

The input limitations for getting 20 points are:

  * 1 ≤ n ≤ 20

The input limitations for getting 50 points are:

  * 1 ≤ n ≤ 100

The input limitations for getting 100 points are:

  * 1 ≤ n ≤ 2000

Output

Print a single number denoting the largest possible value of representativity that a subcollection of size k of the given collection of proteins can have.

Examples

Input

3 2
aba
bzd
abq

Output

2

Input

4 3
eee
rrr
ttt
qqq

Output

0

Input

4 3
aaa
abba
abbc
abbd

Output

9

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
int n, k;
string a[MAXN];
int lcp[MAXN];
int dp[MAXN * 2][MAXN], cn = 0;
int work(int l, int r) {
  cn++;
  if (l == r) return cn;
  int d = cn;
  int p = l;
  for (int i = l; i < r; i++)
    if (lcp[i] < lcp[p]) p = i;
  int lch = work(l, p);
  int rch = work(p + 1, r);
  for (int i = 0; i <= p - l + 1; i++)
    for (int j = 0; j <= r - p; j++) {
      int tmp = dp[lch][i] + dp[rch][j] + lcp[p] * i * j;
      if (tmp > dp[d][i + j]) dp[d][i + j] = tmp;
    }
  return d;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (int i = 1; i < n; i++) {
    lcp[i] = -1;
    for (int j = 0; j < a[i].length() && j < a[i + 1].length(); j++)
      if (a[i][j] != a[i + 1][j]) {
        lcp[i] = j;
        break;
      }
    if (lcp[i] == -1) lcp[i] = min(a[i].length(), a[i + 1].length());
  }
  work(1, n);
  cout << dp[1][k] << endl;
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with that.

The box's lock looks as follows: it contains 4 identical deepenings for gems as a 2 × 2 square, and some integer numbers are written at the lock's edge near the deepenings. The example of a lock is given on the picture below.

<image>

The box is accompanied with 9 gems. Their shapes match the deepenings' shapes and each gem contains one number from 1 to 9 (each number is written on exactly one gem). The box will only open after it is decorated with gems correctly: that is, each deepening in the lock should be filled with exactly one gem. Also, the sums of numbers in the square's rows, columns and two diagonals of the square should match the numbers written at the lock's edge. For example, the above lock will open if we fill the deepenings with gems with numbers as is shown on the picture below.

<image>

Now Vasilisa the Wise wants to define, given the numbers on the box's lock, which gems she should put in the deepenings to open the box. Help Vasilisa to solve this challenging task.

Input

The input contains numbers written on the edges of the lock of the box. The first line contains space-separated integers r1 and r2 that define the required sums of numbers in the rows of the square. The second line contains space-separated integers c1 and c2 that define the required sums of numbers in the columns of the square. The third line contains space-separated integers d1 and d2 that define the required sums of numbers on the main and on the side diagonals of the square (1 ≤ r1, r2, c1, c2, d1, d2 ≤ 20). Correspondence between the above 6 variables and places where they are written is shown on the picture below. For more clarifications please look at the second sample test that demonstrates the example given in the problem statement.

<image>

Output

Print the scheme of decorating the box with stones: two lines containing two space-separated integers from 1 to 9. The numbers should be pairwise different. If there is no solution for the given lock, then print the single number "-1" (without the quotes).

If there are several solutions, output any.

Examples

Input

3 7
4 6
5 5

Output

1 2
3 4

Input

11 10
13 8
5 16

Output

4 7
9 1

Input

1 2
3 4
5 6

Output

-1

Input

10 10
10 10
10 10

Output

-1

Note

Pay attention to the last test from the statement: it is impossible to open the box because for that Vasilisa the Wise would need 4 identical gems containing number "5". However, Vasilisa only has one gem with each number from 1 to 9.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int c1, c2, d1, d2, r1, r2, i, j, k, l;
  cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;
  for (i = 1; i < 10; i++) {
    j = r1 - i;
    k = c1 - i;
    l = d1 - i;
    if (i != j && i != k && i != l && j != k && j != l && k != l && j < 10 &&
        k < 10 && l < 10 && j > 0 && k > 0 && l > 0) {
      if (c2 == j + l && r2 == k + l && d2 == k + j) {
        cout << i << " " << j << "\n" << k << " " << l;
        return 0;
      }
    }
  }
  cout << "-1";
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) for her studies, and she wants to close all the tabs that don't belong to this segment as fast as possible.

Each second Luba can either try moving the cursor to the left or to the right (if the cursor is currently at the tab i, then she can move it to the tab max(i - 1, a) or to the tab min(i + 1, b)) or try closing all the tabs to the left or to the right of the cursor (if the cursor is currently at the tab i, she can close all the tabs with indices from segment [a, i - 1] or from segment [i + 1, b]). In the aforementioned expressions a and b denote the minimum and maximum index of an unclosed tab, respectively. For example, if there were 7 tabs initially and tabs 1, 2 and 7 are closed, then a = 3, b = 6.

What is the minimum number of seconds Luba has to spend in order to leave only the tabs with initial indices from l to r inclusive opened?

Input

The only line of input contains four integer numbers n, pos, l, r (1 ≤ n ≤ 100, 1 ≤ pos ≤ n, 1 ≤ l ≤ r ≤ n) — the number of the tabs, the cursor position and the segment which Luba needs to leave opened.

Output

Print one integer equal to the minimum number of seconds required to close all the tabs outside the segment [l, r].

Examples

Input

6 3 2 4

Output

5

Input

6 3 1 3

Output

1

Input

5 2 1 5

Output

0

Note

In the first test Luba can do the following operations: shift the mouse cursor to the tab 2, close all the tabs to the left of it, shift the mouse cursor to the tab 3, then to the tab 4, and then close all the tabs to the right of it.

In the second test she only needs to close all the tabs to the right of the current position of the cursor.

In the third test Luba doesn't need to do anything.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, pos, l, r;
  cin >> n >> pos >> l >> r;
  int res = 0;
  if (l == 1 and r == n) {
    return cout << res, 0;
  }
  if (l == 1) {
    if (pos <= r) {
      res += (r - pos + 1);
    } else {
      res += (pos - r + 1);
    }
    return cout << res, 0;
  }
  if (r == n) {
    if (pos >= l) {
      res += (pos - l + 1);
    } else {
      res += (l - pos + 1);
    }
    return cout << res, 0;
  }
  if (pos >= l and pos <= r) {
    int d = (l + r) / 2;
    if (pos > d) {
      res += (r - pos) + 1;
      res += (r - l) + 1;
    } else {
      res += (pos - l) + 1;
      res += (r - l) + 1;
    }
  } else if (pos < l) {
    res += (l - pos) + 1;
    res += (r - l) + 1;
  } else if (pos > r) {
    res += (pos - r + 1);
    res += (r - l) + 1;
  }
  cout << res;
}

```


### Prompt

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

Vasya learns to type. He has an unusual keyboard at his disposal: it is rectangular and it has n rows of keys containing m keys in each row. Besides, the keys are of two types. Some of the keys have lowercase Latin letters on them and some of the keys work like the "Shift" key on standard keyboards, that is, they make lowercase letters uppercase.

Vasya can press one or two keys with one hand. However, he can only press two keys if the Euclidean distance between the centers of the keys does not exceed x. The keys are considered as squares with a side equal to 1. There are no empty spaces between neighbouring keys.

Vasya is a very lazy boy, that's why he tries to type with one hand as he eats chips with his other one. However, it is possible that some symbol can't be typed with one hand only, because the distance between it and the closest "Shift" key is strictly larger than x. In this case he will have to use his other hand. Having typed the symbol, Vasya returns other hand back to the chips.

You are given Vasya's keyboard and the text. Count the minimum number of times Vasya will have to use the other hand.

Input

The first line contains three integers n, m, x (1 ≤ n, m ≤ 30, 1 ≤ x ≤ 50).

Next n lines contain descriptions of all the keyboard keys. Each line contains the descriptions of exactly m keys, without spaces. The letter keys are marked with the corresponding lowercase letters. The "Shift" keys are marked with the "S" symbol.

Then follow the length of the text q (1 ≤ q ≤ 5·105). The last line contains the text T, which consists of q symbols, which are uppercase and lowercase Latin letters.

Output

If Vasya can type the text, then print the minimum number of times he will have to use his other hand. Otherwise, print "-1" (without the quotes).

Examples

Input

2 2 1
ab
cd
1
A

Output

-1

Input

2 2 1
ab
cd
1
e

Output

-1

Input

2 2 1
ab
cS
5
abcBA

Output

1

Input

3 9 4
qwertyuio
asdfghjkl
SzxcvbnmS
35
TheQuIcKbRoWnFOXjummsovertHeLazYDOG

Output

2

Note

In the first sample the symbol "A" is impossible to print as there's no "Shift" key on the keyboard.

In the second sample the symbol "e" is impossible to print as there's no such key on the keyboard.

In the fourth sample the symbols "T", "G" are impossible to print with one hand. The other letters that are on the keyboard can be printed. Those symbols come up in the text twice, thus, the answer is 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x;
  cin >> n >> m >> x;
  char a[34][34];
  vector<pair<int, int> > v;
  map<int, bool> p;
  map<int, bool> r;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      r[a[i][j]] = true;
      if (a[i][j] == 'S') v.push_back(make_pair(i, j));
    }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] != 'S') {
        for (int q = 0; q < v.size(); q++) {
          int u = (abs(v[q].first - i)), hz = abs(v[q].second - j);
          u *= u;
          hz *= hz;
          if (u + hz <= x * x) {
            p[a[i][j]] = true;
            break;
          }
        }
      }
    }
  }
  int z;
  cin >> z;
  string s;
  cin >> s;
  int ans = 0;
  int w = 'a' - 'A';
  for (int i = 0; i < z; i++) {
    if (s[i] >= 'A' && s[i] <= 'Z') {
      if (v.size() == 0) {
        cout << -1;
        return 0;
      }
      char c = tolower(s[i]);
      if (!r[c]) {
        cout << -1;
        return 0;
      } else if (!p[c])
        ans++;
    } else {
      if (!r[s[i]]) {
        cout << -1;
        return 0;
      }
    }
  }
  cout << ans;
}

```


### Prompt

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

Let's define an unambiguous arithmetic expression (UAE) as follows.

  * All non-negative integers are UAE's. Integers may have leading zeroes (for example, 0000 and 0010 are considered valid integers).
  * If X and Y are two UAE's, then "(X) + (Y)", "(X) - (Y)", "(X) * (Y)", and "(X) / (Y)" (all without the double quotes) are UAE's.
  * If X is an UAE, then " - (X)" and " + (X)" (both without the double quotes) are UAE's.

You are given a string consisting only of digits ("0" - "9") and characters "-", "+", "*", and "/". Your task is to compute the number of different possible unambiguous arithmetic expressions such that if all brackets (characters "(" and ")") of that unambiguous arithmetic expression are removed, it becomes the input string. Since the answer may be very large, print it modulo 1000003 (106 + 3).

Input

The first line is a non-empty string consisting of digits ('0'-'9') and characters '-', '+', '*', and/or '/'. Its length will not exceed 2000. The line doesn't contain any spaces.

Output

Print a single integer representing the number of different unambiguous arithmetic expressions modulo 1000003 (106 + 3) such that if all its brackets are removed, it becomes equal to the input string (character-by-character).

Examples

Input

1+2*3

Output

2

Input

03+-30+40

Output

3

Input

5//4

Output

0

Input

5/0

Output

1

Input

1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1

Output

100728

Note

For the first example, the two possible unambiguous arithmetic expressions are:

    ((1) + (2)) * (3)
    (1) + ((2) * (3))

For the second example, the three possible unambiguous arithmetic expressions are:

    (03) + (( - (30)) + (40))
    (03) + ( - ((30) + (40)))
    ((03) + ( - (30))) + (40)

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
const int MAXN = 2000 + 5;
const int ha = 1e6 + 3;
char str[MAXN];
int a[MAXN];
int n;
int f[MAXN][MAXN], g[MAXN][MAXN];
int main() {
  scanf("%s", str + 1);
  int len = strlen(str + 1);
  for (register int i = 1; i <= len; ++i) {
    if (isdigit(str[i])) {
      a[++n] = 0;
      while (isdigit(str[i])) ++i;
      --i;
    } else {
      if (str[i] == '+' || str[i] == '-')
        a[++n] = 1;
      else
        a[++n] = 2;
    }
  }
  for (register int i = 1; i <= n; ++i) f[i][i] = g[i][i] = !a[i];
  for (register int l = n - 1; l >= 1; --l)
    if (a[l] != 2) {
      int *p1 = f[l] - 1;
      for (register int r = l + 1; r <= n; ++r)
        if (!a[r]) {
          long long t = 0;
          if (a[l] == 1) t = f[l + 1][r];
          int *p2 = g[r] + 1;
          for (register int k = l + 1; k <= r - 1; ++k)
            if (a[k]) t += 1ll * p1[k] * p2[k];
          f[l][r] = g[r][l] = t % ha;
        }
    }
  printf("%d\n", f[1][n]);
  return 0;
}

```


### Prompt

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

You are given strings S and T consisting of lowercase English letters.

You can perform the following operation on S any number of times:

Operation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.

Determine if S and T can be made equal by performing the operation zero or more times.

Constraints

* 1 \leq |S| \leq 2 \times 10^5
* |S| = |T|
* S and T consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T

Output

If S and T can be made equal, print `Yes`; otherwise, print `No`.

Examples

Input

azzel
apple

Output

Yes

Input

chokudai
redcoder

Output

No

Input

abcdefghijklmnopqrstuvwxyz
ibyhqfrekavclxjstdwgpzmonu

Output

Yes

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
string s,t;
int main(void)
{
	int i;
	int cnta[26]={0};
	int cntb[26]={0};
	cin>>s>>t;
	for(i=0;i<s.size();i++)
	{
		cnta[s[i]-'a']++;
	}
	for(i=0;i<t.size();i++)
	{
		cntb[t[i]-'a']++;
	}
	sort(cnta,cnta+26);
	sort(cntb,cntb+26);
	for(i=0;i<26;i++)
	{
		if(cnta[i]!=cntb[i])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?

Constraints

* 0 ≤ a ≤ b ≤ 10^{18}
* 1 ≤ x ≤ 10^{18}

Input

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

a b x

Output

Print the number of the integers between a and b, inclusive, that are divisible by x.

Examples

Input

4 8 2

Output

3

Input

0 5 1

Output

6

Input

9 9 2

Output

0

Input

1 1000000000000000000 3

Output

333333333333333333

### Response

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

int main(){
  int64_t a,b,x;
  cin >>a>>b>>x;
  int64_t ans;
  ans=b/x-a/x;
  if(a%x==0)
    ans++;
  cout <<ans<<endl;
}
```


### Prompt

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

Find the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.

Constraints

* 2\leq K\leq 100
* K is an integer.

Input

Input is given from Standard Input in the following format:

K

Output

Print the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive).

Examples

Input

3

Output

2

Input

6

Output

9

Input

11

Output

30

Input

50

Output

625

### Response

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

int main(void){
  int n;
  cin >> n;
  cout << n/2*(n-n/2) << endl;
}
```