### Prompt

Please formulate a CPP solution to the following problem:

Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.

Let's define a subarray as a segment of consecutive flowers. The mother suggested some set of subarrays. Alyona wants to choose several of the subarrays suggested by her mother. After that, each of the flowers will add to the girl's happiness its mood multiplied by the number of chosen subarrays the flower is in.

For example, consider the case when the mother has 5 flowers, and their moods are equal to 1, - 2, 1, 3, - 4. Suppose the mother suggested subarrays (1, - 2), (3, - 4), (1, 3), (1, - 2, 1, 3). Then if the girl chooses the third and the fourth subarrays then:

  * the first flower adds 1·1 = 1 to the girl's happiness, because he is in one of chosen subarrays,
  * the second flower adds ( - 2)·1 = - 2, because he is in one of chosen subarrays,
  * the third flower adds 1·2 = 2, because he is in two of chosen subarrays,
  * the fourth flower adds 3·2 = 6, because he is in two of chosen subarrays,
  * the fifth flower adds ( - 4)·0 = 0, because he is in no chosen subarrays.

Thus, in total 1 + ( - 2) + 2 + 6 + 0 = 7 is added to the girl's happiness. Alyona wants to choose such subarrays from those suggested by the mother that the value added to her happiness would be as large as possible. Help her do this!

Alyona can choose any number of the subarrays, even 0 or all suggested by her mother.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of flowers and the number of subarrays suggested by the mother.

The second line contains the flowers moods — n integers a1, a2, ..., an ( - 100 ≤ ai ≤ 100).

The next m lines contain the description of the subarrays suggested by the mother. The i-th of these lines contain two integers li and ri (1 ≤ li ≤ ri ≤ n) denoting the subarray a[li], a[li + 1], ..., a[ri].

Each subarray can encounter more than once.

Output

Print single integer — the maximum possible value added to the Alyona's happiness.

Examples

Input

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

Output

7

Input

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

Output

16

Input

2 2
-1 -2
1 1
1 2

Output

0

Note

The first example is the situation described in the statements.

In the second example Alyona should choose all subarrays.

The third example has answer 0 because Alyona can choose none of the subarrays.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  for (int i = 1; i <= n; i++) cin >> a[i];
  int prefixsum[n];
  prefixsum[1] = a[1];
  for (int i = 2; i <= n; i++) prefixsum[i] = prefixsum[i - 1] + a[i];
  int cnt = 0;
  while (m--) {
    int l, r;
    cin >> l >> r;
    if (l > 1) {
      if (prefixsum[r] - prefixsum[l - 1] > 0)
        cnt = cnt + (prefixsum[r] - prefixsum[l - 1]);
    } else if (l == 1) {
      if (prefixsum[r] > 0) cnt = cnt + prefixsum[r];
    }
  }
  cout << cnt << endl;
}

```


### Prompt

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

While Vasya finished eating his piece of pizza, the lesson has already started. For being late for the lesson, the teacher suggested Vasya to solve one interesting problem. Vasya has an array a and integer x. He should find the number of different ordered pairs of indexes (i, j) such that ai ≤ aj and there are exactly k integers y such that ai ≤ y ≤ aj and y is divisible by x.

In this problem it is meant that pair (i, j) is equal to (j, i) only if i is equal to j. For example pair (1, 2) is not the same as (2, 1).

Input

The first line contains 3 integers n, x, k (1 ≤ n ≤ 105, 1 ≤ x ≤ 109, 0 ≤ k ≤ 109), where n is the size of the array a and x and k are numbers from the statement.

The second line contains n integers ai (1 ≤ ai ≤ 109) — the elements of the array a.

Output

Print one integer — the answer to the problem.

Examples

Input

4 2 1
1 3 5 7

Output

3

Input

4 2 0
5 3 1 7

Output

4

Input

5 3 1
3 3 3 3 3

Output

25

Note

In first sample there are only three suitable pairs of indexes — (1, 2), (2, 3), (3, 4).

In second sample there are four suitable pairs of indexes(1, 1), (2, 2), (3, 3), (4, 4).

In third sample every pair (i, j) is suitable, so the answer is 5 * 5 = 25.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
long long a[maxn];
unordered_map<long long, long long> cnt;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int n;
  cin >> n;
  long long x, k;
  cin >> x >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    if (cnt[a[i]] != 0) {
      ans += cnt[a[i]];
      continue;
    }
    long long L = 0, R = 1e9 + 10;
    while (L + 1 < R) {
      long long M = (L + R) / 2LL;
      if (M * x >= a[i])
        R = M;
      else
        L = M;
    }
    long long l = R, r = R + k - 1;
    L = i - 1, R = n;
    while (L + 1 < R) {
      long long M = (L + R) / 2LL;
      if (a[M] >= r * x)
        R = M;
      else
        L = M;
    }
    if (R == n) continue;
    int index = R;
    L = R, R = n;
    while (L + 1 < R) {
      long long M = (L + R) / 2LL;
      if (a[M] < (r + 1LL) * x)
        L = M;
      else
        R = M;
    }
    if (a[L] < (r + 1LL) * x) {
      cnt[a[i]] = L - index + 1;
      ans += cnt[a[i]];
    }
  }
  cout << ans;
  return 0;
}

```


### Prompt

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

There were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of each type. y people have broken into the theater basement and each of them has taken exactly z swords of some single type. Note that different people might have taken different types of swords. Note that the values x, y and z are unknown for you.

The next morning the director of the theater discovers the loss. He counts all swords — exactly a_i swords of the i-th type are left untouched.

The director has no clue about the initial number of swords of each type in the basement, the number of people who have broken into the basement and how many swords each of them have taken.

For example, if n=3, a = [3, 12, 6] then one of the possible situations is x=12, y=5 and z=3. Then the first three people took swords of the first type and the other two people took swords of the third type. Note that you don't know values x, y and z beforehand but know values of n and a.

Thus he seeks for your help. Determine the minimum number of people y, which could have broken into the theater basement, and the number of swords z each of them has taken.

Input

The first line of the input contains one integer n (2 ≤ n ≤ 2 ⋅ 10^{5}) — the number of types of swords.

The second line of the input contains the sequence a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^{9}), where a_i equals to the number of swords of the i-th type, which have remained in the basement after the theft. It is guaranteed that there exists at least one such pair of indices (j, k) that a_j ≠ a_k.

Output

Print two integers y and z — the minimum number of people which could have broken into the basement and the number of swords each of them has taken.

Examples

Input

3
3 12 6

Output

5 3

Input

2
2 9

Output

1 7

Input

7
2 1000000000 4 6 8 4 2

Output

2999999987 2

Input

6
13 52 0 13 26 52

Output

12 13

Note

In the first example the minimum value of y equals to 5, i.e. the minimum number of people who could have broken into the basement, is 5. Each of them has taken 3 swords: three of them have taken 3 swords of the first type, and two others have taken 3 swords of the third type.

In the second example the minimum value of y is 1, i.e. the minimum number of people who could have broken into the basement, equals to 1. He has taken 7 swords of the first type.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[200010];
long long b[200010];
long long c;
long long gc;
long long y;
long long uclid(long long x, long long y) {
  if (x % y == 0)
    return y;
  else
    return uclid(y, x % y);
}
int main(void) {
  scanf("%lld", &n);
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  sort(a, a + n);
  for (long long i = 0; i < n - 1; i++) {
    if (a[n - 1] == a[i]) continue;
    b[c++] = a[n - 1] - a[i];
  }
  gc = b[0];
  for (long long i = 1; i < c; i++) {
    gc = uclid(gc, b[i]);
  }
  for (long long i = 0; i < c; i++) {
    y += b[i] / gc;
  }
  printf("%lld %lld", y, gc);
  return 0;
}

```


### Prompt

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

    There was once young lass called Mary,
    Whose jokes were occasionally scary.
    On this April's Fool
    Fixed limerick rules
    Allowed her to trip the unwary.

    Can she fill all the lines
    To work at all times?
    On juggling the words
    Right around two-thirds
    She nearly ran out of rhymes.

Input

The input contains a single integer a (4 ≤ a ≤ 998). Not every integer in the range is a valid input for the problem; you are guaranteed that the input will be a valid integer.

Output

Output a single number.

Examples

Input

35

Output

57

Input

57

Output

319

Input

391

Output

1723

### Response

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

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Vasya has written some permutation p_1, p_2, …, p_n of integers from 1 to n, so for all 1 ≤ i ≤ n it is true that 1 ≤ p_i ≤ n and all p_1, p_2, …, p_n are different. After that he wrote n numbers next_1, next_2, …, next_n. The number next_i is equal to the minimal index i < j ≤ n, such that p_j > p_i. If there is no such j let's let's define as next_i = n + 1.

In the evening Vasya went home from school and due to rain, his notebook got wet. Now it is impossible to read some written numbers. Permutation and some values next_i are completely lost! If for some i the value next_i is lost, let's say that next_i = -1.

You are given numbers next_1, next_2, …, next_n (maybe some of them are equal to -1). Help Vasya to find such permutation p_1, p_2, …, p_n of integers from 1 to n, that he can write it to the notebook and all numbers next_i, which are not equal to -1, will be correct.

Input

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

Next 2 ⋅ t lines contains the description of test cases,two lines for each. The first line contains one integer n — the length of the permutation, written by Vasya (1 ≤ n ≤ 500 000). The second line contains n integers next_1, next_2, …, next_n, separated by spaces (next_i = -1 or i < next_i ≤ n + 1).

It is guaranteed, that the sum of n in all test cases doesn't exceed 500 000.

In hacks you can only use one test case, so T = 1.

Output

Print T lines, in i-th of them answer to the i-th test case.

If there is no such permutations p_1, p_2, …, p_n of integers from 1 to n, that Vasya could write, print the only number -1.

In the other case print n different integers p_1, p_2, …, p_n, separated by spaces (1 ≤ p_i ≤ n). All defined values of next_i which are not equal to -1 should be computed correctly p_1, p_2, …, p_n using defenition given in the statement of the problem. If there exists more than one solution you can find any of them.

Example

Input

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

Output

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

Note

In the first test case for permutation p = [1, 2, 3] Vasya should write next = [2, 3, 4], because each number in permutation is less than next. It's easy to see, that it is the only satisfying permutation.

In the third test case, any permutation can be the answer because all numbers next_i are lost.

In the fourth test case, there is no satisfying permutation, so the answer is -1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 10;
long long A[N];
long long ans[N];
long long rp[N];
void solve() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> A[i];
  }
  deque<long long> q;
  q.push_front(n + 1);
  for (long long i = 1; i <= n; i++) {
    if (q.front() == i) {
      q.pop_front();
    }
    if (A[i] != -1) {
      if (A[i] <= q.front()) {
        if (A[i] != q.front()) {
          q.push_front(A[i]);
        }
      } else {
        cout << -1 << endl;
        return;
      }
    }
    ans[i] = q.front();
  }
  vector<pair<long long, long long> > v;
  for (long long i = 1; i <= n; i++) {
    v.push_back({ans[i], -i});
  }
  sort(v.rbegin(), v.rend());
  for (long long i = 0; i < n; i++) {
    rp[-v[i].second] = n - i;
  }
  for (long long i = 1; i <= n; i++) {
    cout << rp[i] << " ";
  }
  cout << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(10);
  cout << fixed;
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Little Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a well-known data structure: multiset.

Artem wants to create a basic multiset of integers. He wants these structure to support operations of three types:

  1. Add integer to the multiset. Note that the difference between set and multiset is that multiset may store several instances of one integer.
  2. Remove integer from the multiset. Only one instance of this integer is removed. Artem doesn't want to handle any exceptions, so he assumes that every time remove operation is called, that integer is presented in the multiset.
  3. Count the number of instances of the given integer that are stored in the multiset.

But what about time machine? Artem doesn't simply apply operations to the multiset one by one, he now travels to different moments of time and apply his operation there. Consider the following example.

  * First Artem adds integer 5 to the multiset at the 1-st moment of time.
  * Then Artem adds integer 3 to the multiset at the moment 5.
  * Then Artem asks how many 5 are there in the multiset at moment 6. The answer is 1.
  * Then Artem returns back in time and asks how many integers 3 are there in the set at moment 4. Since 3 was added only at moment 5, the number of integers 3 at moment 4 equals to 0.
  * Then Artem goes back in time again and removes 5 from the multiset at moment 3.
  * Finally Artyom asks at moment 7 how many integers 5 are there in the set. The result is 0, since we have removed 5 at the moment 3.

Note that Artem dislikes exceptions so much that he assures that after each change he makes all delete operations are applied only to element that is present in the multiset. The answer to the query of the third type is computed at the moment Artem makes the corresponding query and are not affected in any way by future changes he makes.

Help Artem implement time travellers multiset.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of Artem's queries.

Then follow n lines with queries descriptions. Each of them contains three integers ai, ti and xi (1 ≤ ai ≤ 3, 1 ≤ ti, xi ≤ 109) — type of the query, moment of time Artem travels to in order to execute this query and the value of the query itself, respectively. It's guaranteed that all moments of time are distinct and that after each operation is applied all operations of the first and second types are consistent.

Output

For each ask operation output the number of instances of integer being queried at the given moment of time.

Examples

Input

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

Output

1
2
1

Input

3
1 1 1
2 2 1
3 3 1

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[100010], t[100010], x[100010];
std::vector<int> alll;
std::map<int, int> compressed;
std::vector<pair<int, pair<int, int> > > myUpdates[200010];
int BIT[1000010], answer[1000010];
void update(int index, int val) {
  while (index <= 1000000) {
    BIT[index] += val;
    index += (index) & (-index);
  }
}
int query(int index) {
  int ret = 0;
  while (index > 0) {
    ret = ret + BIT[index];
    index -= (index) & (-index);
  }
  return ret;
}
std::vector<int> printable;
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
    scanf("%d", &t[i]);
    scanf("%d", &x[i]);
    if (a[i] == 3) printable.push_back(i);
    alll.push_back(t[i]);
    alll.push_back(x[i]);
  }
  sort(alll.begin(), alll.end());
  int counter = 1;
  compressed[alll[0]] = counter++;
  for (int i = 1; i < alll.size(); i++) {
    if (alll[i] != alll[i - 1]) compressed[alll[i]] = counter++;
  }
  for (int i = 0; i < N; i++) {
    myUpdates[compressed[x[i]]].push_back(make_pair(i, make_pair(a[i], t[i])));
  }
  for (int i = 0; i < counter; i++) {
    for (int j = 0; j < myUpdates[i].size(); j++) {
      if (myUpdates[i][j].second.first == 1)
        update(compressed[myUpdates[i][j].second.second], 1);
      if (myUpdates[i][j].second.first == 2)
        update(compressed[myUpdates[i][j].second.second], -1);
      if (myUpdates[i][j].second.first == 3) {
        answer[myUpdates[i][j].first] =
            query(compressed[myUpdates[i][j].second.second]);
      }
    }
    for (int j = 0; j < myUpdates[i].size(); j++) {
      if (myUpdates[i][j].second.first == 1)
        update(compressed[myUpdates[i][j].second.second], -1);
      if (myUpdates[i][j].second.first == 2)
        update(compressed[myUpdates[i][j].second.second], 1);
    }
  }
  for (int i = 0; i < printable.size(); i++)
    cout << answer[printable[i]] << endl;
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second.

One day in 230 AD Shapur was trying to find out if any one can possibly do calculations faster than him. As a result he made a very great contest and asked every one to come and take part.

In his contest he gave the contestants many different pairs of numbers. Each number is made from digits 0 or 1. The contestants should write a new number corresponding to the given pair of numbers. The rule is simple: The i-th digit of the answer is 1 if and only if the i-th digit of the two given numbers differ. In the other case the i-th digit of the answer is 0.

Shapur made many numbers and first tried his own speed. He saw that he can perform these operations on numbers of length ∞ (length of a number is number of digits in it) in a glance! He always gives correct answers so he expects the contestants to give correct answers, too. He is a good fellow so he won't give anyone very big numbers and he always gives one person numbers of same length.

Now you are going to take part in Shapur's contest. See if you are faster and more accurate.

Input

There are two lines in each input. Each of them contains a single number. It is guaranteed that the numbers are made from 0 and 1 only and that their length is same. The numbers may start with 0. The length of each number doesn't exceed 100.

Output

Write one line — the corresponding answer. Do not omit the leading 0s.

Examples

Input

1010100
0100101

Output

1110001

Input

000
111

Output

111

Input

1110
1010

Output

0100

Input

01110
01100

Output

00010

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string first, second;
int main() {
  cin >> first >> second;
  for (int i = 0; i < first.size(); i++) {
    if (first[i] != second[i])
      printf("%c", '1');
    else
      printf("%c", '0');
  }
  printf("\n");
  return 0;
}

```


### Prompt

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

Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale:

"Once upon a time, there lived an emperor. He was very rich and had much grain. One day he ordered to build a huge barn to put there all his grain. Best builders were building that barn for three days and three nights. But they overlooked and there remained a little hole in the barn, from which every day sparrows came through. Here flew a sparrow, took a grain and flew away..."

More formally, the following takes place in the fairy tale. At the beginning of the first day the barn with the capacity of n grains was full. Then, every day (starting with the first day) the following happens:

  * m grains are brought to the barn. If m grains doesn't fit to the barn, the barn becomes full and the grains that doesn't fit are brought back (in this problem we can assume that the grains that doesn't fit to the barn are not taken into account).
  * Sparrows come and eat grain. In the i-th day i sparrows come, that is on the first day one sparrow come, on the second day two sparrows come and so on. Every sparrow eats one grain. If the barn is empty, a sparrow eats nothing.

Anton is tired of listening how Danik describes every sparrow that eats grain from the barn. Anton doesn't know when the fairy tale ends, so he asked you to determine, by the end of which day the barn will become empty for the first time. Help Anton and write a program that will determine the number of that day!

Input

The only line of the input contains two integers n and m (1 ≤ n, m ≤ 1018) — the capacity of the barn and the number of grains that are brought every day.

Output

Output one integer — the number of the day when the barn will become empty for the first time. Days are numbered starting with one.

Examples

Input

5 2

Output

4

Input

8 1

Output

5

Note

In the first sample the capacity of the barn is five grains and two grains are brought every day. The following happens:

  * At the beginning of the first day grain is brought to the barn. It's full, so nothing happens.
  * At the end of the first day one sparrow comes and eats one grain, so 5 - 1 = 4 grains remain.
  * At the beginning of the second day two grains are brought. The barn becomes full and one grain doesn't fit to it.
  * At the end of the second day two sparrows come. 5 - 2 = 3 grains remain.
  * At the beginning of the third day two grains are brought. The barn becomes full again.
  * At the end of the third day three sparrows come and eat grain. 5 - 3 = 2 grains remain.
  * At the beginning of the fourth day grain is brought again. 2 + 2 = 4 grains remain.
  * At the end of the fourth day four sparrows come and eat grain. 4 - 4 = 0 grains remain. The barn is empty.

So the answer is 4, because by the end of the fourth day the barn becomes empty.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int64_t n, k;
  cin >> n >> k;
  if (n <= k) {
    cout << n << endl;
  } else {
    n = n - k;
    int64_t l = 0, r = 2e9;
    while (l < r) {
      int64_t m = (l + r) / 2;
      int64_t val = m * (m + 1) / 2;
      if (val >= n) {
        r = m;
      } else {
        l = m + 1;
      }
    }
    cout << l + k << endl;
  }
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

You are given an integer x of n digits a_1, a_2, …, a_n, which make up its decimal notation in order from left to right.

Also, you are given a positive integer k < n.

Let's call integer b_1, b_2, …, b_m beautiful if b_i = b_{i+k} for each i, such that 1 ≤ i ≤ m - k.

You need to find the smallest beautiful integer y, such that y ≥ x.

Input

The first line of input contains two integers n, k (2 ≤ n ≤ 200 000, 1 ≤ k < n): the number of digits in x and k.

The next line of input contains n digits a_1, a_2, …, a_n (a_1 ≠ 0, 0 ≤ a_i ≤ 9): digits of x.

Output

In the first line print one integer m: the number of digits in y.

In the next line print m digits b_1, b_2, …, b_m (b_1 ≠ 0, 0 ≤ b_i ≤ 9): digits of y.

Examples

Input

3 2
353

Output

3
353

Input

4 2
1234

Output

4
1313

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9;
template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  string ret = "";
  for (int i = 0; i < n; i++) {
    ret += s[i % k];
  }
  cout << n << endl;
  if (ret >= s) {
    cout << ret << endl;
    return 0;
  }
  for (int i = k - 1; i >= 0; i--) {
    if (s[i] != '9') {
      s[i]++;
      break;
    }
    s[i] = '0';
  }
  ret = "";
  for (int i = 0; i < n; i++) {
    ret += s[i % k];
  }
  cout << ret << endl;
}

```


### Prompt

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

Let's consider an n × n square matrix, consisting of digits one and zero.

We'll consider a matrix good, if it meets the following condition: in each row of the matrix all ones go in one group. That is, each row of the matrix looks like that 00...0011...1100...00 (or simply consists of zeroes if it has no ones).

You are given matrix a of size n × n, consisting of zeroes and ones. Your task is to determine whether you can get a good matrix b from it by rearranging the columns or not.

Input

The first line contains integer n (1 ≤ n ≤ 500) — the size of matrix a.

Each of n following lines contains n characters "0" and "1" — matrix a. Note that the characters are written without separators.

Output

Print "YES" in the first line, if you can rearrange the matrix columns so as to get a good matrix b. In the next n lines print the good matrix b. If there are multiple answers, you are allowed to print any of them.

If it is impossible to get a good matrix, print "NO".

Examples

Input

6
100010
110110
011001
010010
000100
011001

Output

YES
011000
111100
000111
001100
100000
000111

Input

3
110
101
011

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int maxN = 501;
char g[maxN][maxN][maxN];
int n;
char s[maxN][maxN];
bool used[maxN][maxN];
pair<int, int> order[maxN * maxN];
int m_order;
int comp[maxN][maxN];
void dfs1(int x, int y) {
  used[x][y] = true;
  for (int i = 0; i < n; ++i) {
    if ((g[x][y][i] & 1) && !used[x][i]) {
      dfs1(x, i);
    }
    if ((g[x][y][i] & 2) && !used[i][y]) {
      dfs1(i, y);
    }
  }
  order[m_order++] = make_pair(x, y);
}
void dfs2(int x, int y, int id) {
  comp[x][y] = id;
  if (comp[y][x] == id) {
    printf("NO\n");
    exit(0);
  }
  for (int i = 0; i < n; ++i) {
    if ((g[x][y][i] & 1) && comp[x][i] == -1) {
      dfs2(x, i, id);
    }
    if ((g[x][y][i] & 2) && comp[i][y] == -1) {
      dfs2(i, y, id);
    }
  }
}
bool h[maxN][maxN];
vector<int> r;
bool visited[maxN];
void dfs(int v) {
  visited[v] = true;
  for (int i = 0; i < n; ++i) {
    if (h[v][i] && !visited[i]) {
      dfs(i);
    }
  }
  r.push_back(v);
}
void solve() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i != j && !used[i][j]) {
        dfs1(i, j);
      }
    }
  }
  memset(comp, -1, sizeof(comp));
  int id = 0;
  reverse(order, order + m_order);
  for (int i = 0; i < m_order; ++i) {
    int x = order[i].first;
    int y = order[i].second;
    if (comp[x][y] == -1) {
      ++id;
      dfs2(x, y, id);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (comp[i][j] == comp[j][i]) {
        printf("NO\n");
        exit(0);
      } else {
        if (comp[i][j] > comp[j][i]) {
          h[i][j] = true;
        } else {
          h[j][i] = true;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (!visited[i]) {
      dfs(i);
    }
  }
  printf("YES\n");
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < r.size(); ++j) {
      printf("%c", s[i][r[j]]);
    }
    printf("\n");
  }
}
int ones[maxN], m;
void gen() {
  int n = 500;
  printf("%d\n", n);
  for (int i = 0; i < n; ++i) {
    int l = rand() % n;
    int r = rand() % n;
    if (l > r) {
      swap(l, r);
    }
    for (int j = 0; j < n; ++j) {
      printf("%c", '0' + (j >= l && j <= r));
    }
    printf("\n");
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", &s[i]);
  }
  for (int k = 0; k < n; ++k) {
    m = 0;
    for (int i = 0; i < n; ++i) {
      if (s[k][i] == '1') {
        ones[m++] = i;
      }
    }
    for (int i = 0; i < n; ++i) {
      if (s[k][i] == '1') {
        continue;
      }
      for (int j = 0; j < m; ++j) {
        int l = j + 1;
        if (l == m) {
          l = 0;
        }
        if (j == l) {
          continue;
        }
        g[i][ones[j]][ones[l]] |= 1;
        g[ones[j]][i][ones[l]] |= 2;
      }
    }
  }
  solve();
  cerr << clock() << endl;
  return 0;
}

```


### Prompt

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

Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion:

  * An 'L' indicates he should move one unit left.
  * An 'R' indicates he should move one unit right.
  * A 'U' indicates he should move one unit up.
  * A 'D' indicates he should move one unit down.

But now Memory wants to end at the origin. To do this, he has a special trident. This trident can replace any character in s with any of 'L', 'R', 'U', or 'D'. However, because he doesn't want to wear out the trident, he wants to make the minimum number of edits possible. Please tell Memory what is the minimum number of changes he needs to make to produce a string that, when walked, will end at the origin, or if there is no such string.

Input

The first and only line contains the string s (1 ≤ |s| ≤ 100 000) — the instructions Memory is given.

Output

If there is a string satisfying the conditions, output a single integer — the minimum number of edits required. In case it's not possible to change the sequence in such a way that it will bring Memory to to the origin, output -1.

Examples

Input

RRU

Output

-1

Input

UDUR

Output

1

Input

RUUR

Output

2

Note

In the first sample test, Memory is told to walk right, then right, then up. It is easy to see that it is impossible to edit these instructions to form a valid walk.

In the second sample test, Memory is told to walk up, then down, then up, then right. One possible solution is to change s to "LDUR". This string uses 1 edit, which is the minimum possible. It also ends at the origin.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long n;
  map<char, long> mp;
  mp['U'] = 0;
  mp['D'] = 0;
  mp['R'] = 0;
  mp['L'] = 0;
  if (s.size() % 2 != 0) {
    n = -1;
  } else {
    char c;
    for (int i = 0; i < s.size(); i++) {
      c = s[i];
      mp[c]++;
    }
    long ud = abs(mp['U'] - mp['D']);
    long rl = abs(mp['R'] - mp['L']);
    n = floor((ud + rl) / 2);
  }
  cout << n << endl;
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

In mathematics, the Pythagorean theorem — is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:

In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).

The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:

a2 + b2 = c2

where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.

<image>

Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 ≤ a ≤ b ≤ c ≤ n.

Input

The only line contains one integer n (1 ≤ n ≤ 104) as we mentioned above.

Output

Print a single integer — the answer to the problem.

Examples

Input

5

Output

1

Input

74

Output

35

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int z = 0;
  set<int> s;
  for (int i = 1; i <= 10000; ++i) s.insert(i * i);
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      if (s.find(i * i + j * j) != s.end() && i * i + j * j <= n * n) {
        ++z;
      }
    }
  }
  cout << z << endl;
  return 0;
}

```


### Prompt

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

The hero of our story, Valera, and his best friend Arcady are still in school, and therefore they spend all the free time playing turn-based strategy "GAGA: Go And Go Again". The gameplay is as follows.

There are two armies on the playing field each of which consists of n men (n is always even). The current player specifies for each of her soldiers an enemy's soldier he will shoot (a target) and then all the player's soldiers shot simultaneously. This is a game world, and so each soldier shoots perfectly, that is he absolutely always hits the specified target. If an enemy soldier is hit, he will surely die. It may happen that several soldiers had been indicated the same target. Killed soldiers do not participate in the game anymore.

The game "GAGA" consists of three steps: first Valera makes a move, then Arcady, then Valera again and the game ends.

You are asked to calculate the maximum total number of soldiers that may be killed during the game.

Input

The input data consist of a single integer n (2 ≤ n ≤ 108, n is even). Please note that before the game starts there are 2n soldiers on the fields.

Output

Print a single number — a maximum total number of soldiers that could be killed in the course of the game in three turns.

Examples

Input

2

Output

3

Input

4

Output

6

Note

The first sample test:

1) Valera's soldiers 1 and 2 shoot at Arcady's soldier 1.

2) Arcady's soldier 2 shoots at Valera's soldier 1.

3) Valera's soldier 1 shoots at Arcady's soldier 2.

There are 3 soldiers killed in total: Valera's soldier 1 and Arcady's soldiers 1 and 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x = 2 * n;
  int r = x / 4;
  cout << x - r;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Decimal numbers are a common notation system currently in use and use ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 to represent all numbers.

Binary numbers are a popular notation in the computer world and use two symbols, 0 and 1, to represent all numbers.

Only the four numbers 0, 1, 2, and 3 are used in quaternary numbers. In quaternary numbers, when the number is incremented from 0, it will be carried to the next digit when it reaches 4. Therefore, the decimal number 4 is carried to the expression "10".

Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ...
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |- ---
Binary | 0 | 1 | 10 | 11 | 100 | 101 | 110 | 111 | 1000 | 101 | 1010 | ...
Quadrant | 0 | 1 | 2 | 3 | 10 | 11 | 12 | 13 | 20 | 21 | 22 | ...

In Hawaii, fish and taro were counted between fingers in the old days, so it seems that they used quaternary numbers instead of decimal numbers.

Create a program that converts the integer n input in decimal to decimal and outputs it.

Input

A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of -1. One integer n (0 ≤ n ≤ 1000000) is given on one row for each dataset.

The number of datasets does not exceed 2000.

Output

The result of conversion to quaternary number for each input data set is output on one line.

Example

Input

7
4
0
12
10
10000
-1

Output

13
10
0
30
22
2130100

### Response

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int main() {
	int n;
	while (cin >> n, n != -1) {
		string ans = "";
		if (n == 0) ans.push_back('0');
		while (n > 0) {
			ans.push_back(n % 4 + '0');
			n = n / 4;
		}
		reverse(ans.begin(), ans.end());
		cout << ans << endl;
	}
	return 0;
}
```


### Prompt

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

What are you doing at the end of the world? Are you busy? Will you save us?

<image>

Nephren is playing a game with little leprechauns.

She gives them an infinite array of strings, f0... ∞.

f0 is "What are you doing at the end of the world? Are you busy? Will you save us?".

She wants to let more people know about it, so she defines fi =  "What are you doing while sending "fi - 1"? Are you busy? Will you send "fi - 1"?" for all i ≥ 1.

For example, f1 is

"What are you doing while sending "What are you doing at the end of the world? Are you busy? Will you save us?"? Are you busy? Will you send "What are you doing at the end of the world? Are you busy? Will you save us?"?". Note that the quotes in the very beginning and in the very end are for clarity and are not a part of f1.

It can be seen that the characters in fi are letters, question marks, (possibly) quotation marks and spaces.

Nephren will ask the little leprechauns q times. Each time she will let them find the k-th character of fn. The characters are indexed starting from 1. If fn consists of less than k characters, output '.' (without quotes).

Can you answer her queries?

Input

The first line contains one integer q (1 ≤ q ≤ 10) — the number of Nephren's questions.

Each of the next q lines describes Nephren's question and contains two integers n and k (0 ≤ n ≤ 105, 1 ≤ k ≤ 1018).

Output

One line containing q characters. The i-th character in it should be the answer for the i-th query.

Examples

Input

3
1 1
1 2
1 111111111111

Output

Wh.

Input

5
0 69
1 194
1 139
0 47
1 66

Output

abdef

Input

10
4 1825
3 75
3 530
4 1829
4 1651
3 187
4 584
4 255
4 774
2 474

Output

Areyoubusy

Note

For the first two examples, refer to f0 and f1 given in the legend.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double Eps = 1e-8;
const long long Inf = 1000000000000000001LL;
const int Mod = 1e9 + 7;
const int maxn = 1e5 + 10;
string s =
    "What are you doing at the end of the world? Are you busy? Will you save "
    "us?";
string t =
    "What are you doing while sending \"\"? Are you busy? Will you send \"\"?";
long long Q, N, K, dp[maxn][5];
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(numeric_limits<double>::max_digits10 + 1);
  ;
  dp[0][4] = s.size();
  for (int i = 1; i <= 1e5; ++i) {
    dp[i][0] = 33;
    if (dp[i - 1][4] < Inf - 34)
      dp[i][1] = 34 + dp[i - 1][4];
    else
      dp[i][1] = Inf + 2;
    if (dp[i][1] < Inf - 31)
      dp[i][2] = dp[i][1] + 31;
    else
      dp[i][2] = Inf + 2;
    if (dp[i][2] < Inf && dp[i - 1][4] < Inf)
      dp[i][3] = dp[i][2] + dp[i - 1][4] + 1;
    else
      dp[i][3] = Inf + 2;
    if (dp[i][3] < Inf - 2)
      dp[i][4] = dp[i][3] + 2;
    else
      dp[i][4] = Inf + 2;
  }
  cin >> Q;
  while (Q--) {
    cin >> N >> K;
    if (K > dp[N][4]) {
      cout << ".";
      continue;
    }
    --K;
    for (int i = N; i >= 0; --i) {
      if (i == 0) {
        cout << s[K];
        break;
      }
      if (K <= dp[i][0]) {
        cout << t[K];
        break;
      }
      if (K < dp[i][1]) {
        K -= (dp[i][0] + 1);
        continue;
      }
      if (K <= dp[i][2]) {
        cout << t[K - dp[i - 1][4]];
        break;
      }
      if (K < dp[i][3]) {
        K -= (dp[i][2] + 1);
        continue;
      }
      cout << t[K - dp[i - 1][4] - dp[i - 1][4]];
      break;
    }
  }
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers the 2016 Robot Rap Battle Tournament, she notices that all of the robots operate under deterministic algorithms. In particular, robot i will beat robot j if and only if robot i has a higher skill level than robot j. And if robot i beats robot j and robot j beats robot k, then robot i will beat robot k. Since rapping is such a subtle art, two robots can never have the same skill level.

Given the results of the rap battles in the order in which they were played, determine the minimum number of first rap battles that needed to take place before Bessie could order all of the robots by skill level.

Input

The first line of the input consists of two integers, the number of robots n (2 ≤ n ≤ 100 000) and the number of rap battles m (<image>).

The next m lines describe the results of the rap battles in the order they took place. Each consists of two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi), indicating that robot ui beat robot vi in the i-th rap battle. No two rap battles involve the same pair of robots.

It is guaranteed that at least one ordering of the robots satisfies all m relations.

Output

Print the minimum k such that the ordering of the robots by skill level is uniquely defined by the first k rap battles. If there exists more than one ordering that satisfies all m relations, output -1.

Examples

Input

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

Output

4

Input

3 2
1 2
3 2

Output

-1

Note

In the first sample, the robots from strongest to weakest must be (4, 2, 1, 3), which Bessie can deduce after knowing the results of the first four rap battles.

In the second sample, both (1, 3, 2) and (3, 1, 2) are possible orderings of the robots from strongest to weakest after both rap battles.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, s;
vector<int> a[100010], b[100010];
bool c[100010];
int nop[100010], noc[100010];
pair<int, int> r[100010];
int count_child(int u) {
  if (noc[u] != -1) return noc[u];
  int cur = 1;
  for (int v : a[u]) {
    cur = max(cur, count_child(v) + 1);
  }
  return noc[u] = cur;
}
int count_parent(int u) {
  if (nop[u] != -1) return nop[u];
  int cur = 1;
  for (int v : b[u]) {
    cur = max(cur, count_parent(v) + 1);
  }
  return nop[u] = cur;
}
bool check(int x) {
  for (int i = 1; i <= n; i++) a[i].clear(), b[i].clear();
  memset(nop, -1, sizeof(nop));
  memset(noc, -1, sizeof(noc));
  for (int i = 1; i <= x; i++) {
    int u = r[i].first;
    int v = r[i].second;
    a[u].push_back(v);
    b[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (count_parent(i) + count_child(i) - 1 != n) return false;
  }
  return true;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    r[i] = pair<int, int>(u, v);
  }
  int l = 0, r = m + 1, mid;
  while (r - l > 1) {
    mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  if (r == m + 1)
    printf("-1\n");
  else
    printf("%d\n", r);
}

```


### Prompt

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

To stay woke and attentive during classes, Karen needs some coffee!

<image>

Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the universally acclaimed "The Art of the Covfefe".

She knows n coffee recipes. The i-th recipe suggests that coffee should be brewed between li and ri degrees, inclusive, to achieve the optimal taste.

Karen thinks that a temperature is admissible if at least k recipes recommend it.

Karen has a rather fickle mind, and so she asks q questions. In each question, given that she only wants to prepare coffee with a temperature between a and b, inclusive, can you tell her how many admissible integer temperatures fall within the range?

Input

The first line of input contains three integers, n, k (1 ≤ k ≤ n ≤ 200000), and q (1 ≤ q ≤ 200000), the number of recipes, the minimum number of recipes a certain temperature must be recommended by to be admissible, and the number of questions Karen has, respectively.

The next n lines describe the recipes. Specifically, the i-th line among these contains two integers li and ri (1 ≤ li ≤ ri ≤ 200000), describing that the i-th recipe suggests that the coffee be brewed between li and ri degrees, inclusive.

The next q lines describe the questions. Each of these lines contains a and b, (1 ≤ a ≤ b ≤ 200000), describing that she wants to know the number of admissible integer temperatures between a and b degrees, inclusive.

Output

For each question, output a single integer on a line by itself, the number of admissible integer temperatures between a and b degrees, inclusive.

Examples

Input

3 2 4
91 94
92 97
97 99
92 94
93 97
95 96
90 100

Output

3
3
0
4

Input

2 1 1
1 1
200000 200000
90 100

Output

0

Note

In the first test case, Karen knows 3 recipes.

  1. The first one recommends brewing the coffee between 91 and 94 degrees, inclusive.
  2. The second one recommends brewing the coffee between 92 and 97 degrees, inclusive.
  3. The third one recommends brewing the coffee between 97 and 99 degrees, inclusive.

A temperature is admissible if at least 2 recipes recommend it.

She asks 4 questions.

In her first question, she wants to know the number of admissible integer temperatures between 92 and 94 degrees, inclusive. There are 3: 92, 93 and 94 degrees are all admissible.

In her second question, she wants to know the number of admissible integer temperatures between 93 and 97 degrees, inclusive. There are 3: 93, 94 and 97 degrees are all admissible.

In her third question, she wants to know the number of admissible integer temperatures between 95 and 96 degrees, inclusive. There are none.

In her final question, she wants to know the number of admissible integer temperatures between 90 and 100 degrees, inclusive. There are 4: 92, 93, 94 and 97 degrees are all admissible.

In the second test case, Karen knows 2 recipes.

  1. The first one, "wikiHow to make Cold Brew Coffee", recommends brewing the coffee at exactly 1 degree.
  2. The second one, "What good is coffee that isn't brewed at at least 36.3306 times the temperature of the surface of the sun?", recommends brewing the coffee at exactly 200000 degrees.

A temperature is admissible if at least 1 recipe recommends it.

In her first and only question, she wants to know the number of admissible integer temperatures that are actually reasonable. There are none.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 131;
int node[maxn << 2];
int sum[maxn << 2];
int val[maxn << 2];
int n, k, q;
int l[maxn], r[maxn];
void pushUp(int rt) { sum[rt] = sum[rt << 1] + sum[rt << 1 | 1]; }
void pushDown(int rt) {
  if (val[rt] > 0) {
    node[rt] += val[rt];
    node[rt << 1] += val[rt];
    node[rt << 1 | 1] += val[rt];
    val[rt << 1] += val[rt];
    val[rt << 1 | 1] += val[rt];
    val[rt] = 0;
  }
}
void Build(int l, int r, int rt) {
  if (l == r) {
    if (node[rt] >= k)
      sum[rt] = 1;
    else
      sum[rt] = 0;
    return;
  }
  pushDown(rt);
  int m = (l + r) >> 1;
  Build(l, m, rt << 1);
  Build(m + 1, r, rt << 1 | 1);
  pushUp(rt);
}
void Update(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    val[rt]++;
    if (l == r) {
      node[rt]++;
      val[rt] = 0;
    }
    return;
  }
  pushDown(rt);
  int m = (l + r) >> 1;
  if (L <= m) Update(L, R, l, m, rt << 1);
  if (R > m) Update(L, R, m + 1, r, rt << 1 | 1);
}
int Query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    return sum[rt];
  }
  pushDown(rt);
  int res = 0;
  int m = (l + r) >> 1;
  if (L <= m) res += Query(L, R, l, m, rt << 1);
  if (R > m) res += Query(L, R, m + 1, r, rt << 1 | 1);
  pushUp(rt);
  return res;
}
void Clear() {
  memset(node, 0, sizeof(node));
  memset(sum, 0, sizeof(sum));
  memset(val, 0, sizeof(val));
}
int main() {
  Clear();
  scanf("%d%d%d", &n, &k, &q);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &l[i], &r[i]);
    Update(l[i], r[i], 0, 200000, 1);
  }
  Build(0, 200000, 1);
  while (q--) {
    int ll, rr;
    scanf("%d%d", &ll, &rr);
    int res = Query(ll, rr, 0, 200000, 1);
    printf("%d\n", res);
  }
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

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

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

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

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

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

Input

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

Output

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

Examples

Input

7 3

Output

16

Input

3 7

Output

0

Input

1337 42

Output

95147305

Input

1 1

Output

1

Input

500000 1

Output

500000

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353, maxn = 5e5 + 5, Log = 30;
int fact[maxn];
inline int sum(int a, int b) {
  if (a + b >= mod) {
    return a + b - mod;
  }
  if (a + b < 0) {
    return a + b + mod;
  }
  return a + b;
}
inline int mul(int a, int b) { return (long long)a * b % mod; }
int pot(int a, int b) {
  int sol = 1;
  for (int i = 0; i < Log; i++) {
    if (b & (1 << i)) {
      sol = mul(sol, a);
    }
    a = mul(a, a);
  }
  return sol;
}
int dijel(int a, int b) { return mul(a, pot(b, mod - 2)); }
int povrh(int a, int b) { return dijel(fact[a], mul(fact[b], fact[a - b])); }
void precompute() {
  fact[0] = 1;
  for (int i = 1; i < maxn; i++) {
    fact[i] = mul(fact[i - 1], i);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  precompute();
  int n, k;
  cin >> n >> k;
  int sol = 0;
  for (int i = 1; i <= n; i++) {
    if (n / i >= k) {
      sol = sum(sol, povrh(n / i - 1, k - 1));
    }
  }
  cout << sol << '\n';
  return 0;
}

```


### Prompt

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

Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left.

There were n classes of that subject during the semester and on i-th class professor mentioned some non-negative integer a_i to the students. It turned out, the exam was to tell the whole sequence back to the professor.

Sounds easy enough for those who attended every class, doesn't it?

Obviously Mishka didn't attend any classes. However, professor left some clues on the values of a to help out students like Mishka:

  * a was sorted in non-decreasing order (a_1 ≤ a_2 ≤ ... ≤ a_n);
  * n was even;
  * the following sequence b, consisting of \frac n 2 elements, was formed and given out to students: b_i = a_i + a_{n - i + 1}.

Professor also mentioned that any sequence a, which produces sequence b with the presented technique, will be acceptable.

Help Mishka to pass that last exam. Restore any sorted sequence a of non-negative integers, which produces sequence b with the presented technique. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b.

Input

The first line contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the length of sequence a. n is always even.

The second line contains \frac n 2 integers b_1, b_2, ..., b_{\frac n 2} (0 ≤ b_i ≤ 10^{18}) — sequence b, where b_i = a_i + a_{n - i + 1}.

It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b.

Output

Print n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^{18}) in a single line.

a_1 ≤ a_2 ≤ ... ≤ a_n should be satisfied.

b_i = a_i + a_{n - i + 1} should be satisfied for all valid i.

Examples

Input

4
5 6

Output

2 3 3 3

Input

6
2 1 2

Output

0 0 1 1 1 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
long long b[maxn];
long long a[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n / 2; i++) {
    scanf("%lld", &b[i]);
  }
  a[1] = 0, a[n] = b[1];
  for (int i = 2; i <= n / 2; i++) {
    a[n - i + 1] = a[n - i + 2];
    a[i] = b[i] - a[n - i + 1];
    if (a[i] < a[i - 1]) {
      a[i] = a[i - 1];
      a[n - i + 1] = b[i] - a[i];
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%lld%c", a[i], i == n ? '\n' : ' ');
  }
}

```


### Prompt

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

The Cereal Guy's friend Serial Guy likes to watch soap operas. An episode is about to start, and he hasn't washed his plate yet. But he decided to at least put in under the tap to be filled with water. The plate can be represented by a parallelepiped k × n × m, that is, it has k layers (the first layer is the upper one), each of which is a rectangle n × m with empty squares ('.') and obstacles ('#'). The water can only be present in the empty squares. The tap is positioned above the square (x, y) of the first layer, it is guaranteed that this square is empty. Every minute a cubical unit of water falls into the plate. Find out in how many minutes the Serial Guy should unglue himself from the soap opera and turn the water off for it not to overfill the plate. That is, you should find the moment of time when the plate is absolutely full and is going to be overfilled in the next moment.

Note: the water fills all the area within reach (see sample 4). Water flows in each of the 6 directions, through faces of 1 × 1 × 1 cubes.

Input

The first line contains three numbers k, n, m (1 ≤ k, n, m ≤ 10) which are the sizes of the plate. Then follow k rectangles consisting of n lines each containing m characters '.' or '#', which represents the "layers" of the plate in the order from the top to the bottom. The rectangles are separated by empty lines (see the samples). The last line contains x and y (1 ≤ x ≤ n, 1 ≤ y ≤ m) which are the tap's coordinates. x is the number of the line and y is the number of the column. Lines of each layer are numbered from left to right by the integers from 1 to n, columns of each layer are numbered from top to bottom by the integers from 1 to m.

Output

The answer should contain a single number, showing in how many minutes the plate will be filled.

Examples

Input

1 1 1

.

1 1

Output

1

Input

2 1 1

.

#

1 1

Output

1

Input

2 2 2

.#
##

..
..

1 1

Output

5

Input

3 2 2

#.
##

#.
.#

..
..

1 2

Output

7

Input

3 3 3

.#.
###
##.

.##
###
##.

...
...
...

1 1

Output

13

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long Maxn = 3e5 + 270;
const long long Inf = 1e9 + 7;
const long long Mod = 1e9 + 7;
const long long Max = 5e2 + 7;
long long a[12][12][12], n, k, m, ans;
void dfs(long long x, long long y, long long z) {
  if (!a[z][x][y]) return;
  ans++;
  a[z][x][y] = 0;
  dfs(x + 1, y, z);
  dfs(x - 1, y, z);
  dfs(x, y + 1, z);
  dfs(x, y - 1, z);
  dfs(x, y, z + 1);
  dfs(x, y, z - 1);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long x, y;
  cin >> k >> n >> m;
  for (long long i = 1; i <= k; i++)
    for (long long j = 1; j <= n; j++)
      for (long long t = 1; t <= m; t++) {
        char c;
        cin >> c;
        a[i][j][t] = (c == '.') ? 1 : 0;
      }
  cin >> x >> y;
  dfs(x, y, 1);
  cout << ans << endl;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Petya and Vasya are playing a game. Petya's got n non-transparent glasses, standing in a row. The glasses' positions are indexed with integers from 1 to n from left to right. Note that the positions are indexed but the glasses are not.

First Petya puts a marble under the glass in position s. Then he performs some (possibly zero) shuffling operations. One shuffling operation means moving the glass from the first position to position p1, the glass from the second position to position p2 and so on. That is, a glass goes from position i to position pi. Consider all glasses are moving simultaneously during one shuffling operation. When the glasses are shuffled, the marble doesn't travel from one glass to another: it moves together with the glass it was initially been put in.

After all shuffling operations Petya shows Vasya that the ball has moved to position t. Vasya's task is to say what minimum number of shuffling operations Petya has performed or determine that Petya has made a mistake and the marble could not have got from position s to position t.

Input

The first line contains three integers: n, s, t (1 ≤ n ≤ 105; 1 ≤ s, t ≤ n) — the number of glasses, the ball's initial and final position. The second line contains n space-separated integers: p1, p2, ..., pn (1 ≤ pi ≤ n) — the shuffling operation parameters. It is guaranteed that all pi's are distinct.

Note that s can equal t.

Output

If the marble can move from position s to position t, then print on a single line a non-negative integer — the minimum number of shuffling operations, needed to get the marble to position t. If it is impossible, print number -1.

Examples

Input

4 2 1
2 3 4 1

Output

3

Input

4 3 3
4 1 3 2

Output

0

Input

4 3 4
1 2 3 4

Output

-1

Input

3 1 3
2 1 3

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, s, t;
  cin >> n >> s >> t;
  long long int ar[n];
  ar[0] = 0;
  for (long long int i = 1; i < n + 1; i++) cin >> ar[i];
  long long int p = s, c = 0;
  for (long long int i = 0; i < n + 1; i++) {
    if (p == t || ar[p] == p)
      break;
    else
      p = ar[p];
    c += 1;
  }
  if (p == t)
    cout << c << "\n";
  else
    cout << -1 << "\n";
  return 0;
}

```


### Prompt

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

On Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a square mesh is marked. They use only a single stone. The purpose of the game is to lead the stone from the start to the goal with the minimum number of moves.

Fig. D-1 shows an example of a game board. Some squares may be occupied with blocks. There are two special squares namely the start and the goal, which are not occupied with blocks. (These two squares are distinct.) Once the stone begins to move, it will proceed until it hits a block. In order to bring the stone to the goal, you may have to stop the stone by hitting it against a block, and throw again.

<image>
Fig. D-1: Example of board (S: start, G: goal)

The movement of the stone obeys the following rules:

* At the beginning, the stone stands still at the start square.
* The movements of the stone are restricted to x and y directions. Diagonal moves are prohibited.
* When the stone stands still, you can make it moving by throwing it. You may throw it to any direction unless it is blocked immediately(Fig. D-2(a)).
* Once thrown, the stone keeps moving to the same direction until one of the following occurs:
* The stone hits a block (Fig. D-2(b), (c)).
* The stone stops at the square next to the block it hit.
* The block disappears.
* The stone gets out of the board.
* The game ends in failure.
* The stone reaches the goal square.
* The stone stops there and the game ends in success.
* You cannot throw the stone more than 10 times in a game. If the stone does not reach the goal in 10 moves, the game ends in failure.

<image>
Fig. D-2: Stone movements

Under the rules, we would like to know whether the stone at the start can reach the goal and, if yes, the minimum number of moves required.

With the initial configuration shown in Fig. D-1, 4 moves are required to bring the stone from the start to the goal. The route is shown in Fig. D-3(a). Notice when the stone reaches the goal, the board configuration has changed as in Fig. D-3(b).

<image>
Fig. D-3: The solution for Fig. D-1 and the final board configuration

Input

The input is a sequence of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 100.

Each dataset is formatted as follows.

> the width(=w) and the height(=h) of the board
>  First row of the board
>  ...
>  h-th row of the board
>

The width and the height of the board satisfy: 2 <= w <= 20, 1 <= h <= 20.
Each line consists of w decimal numbers delimited by a space. The number describes the status of the corresponding square.

> 0 | vacant square
> ---|---
> 1 | block
> 2 | start position
> 3 | goal position

The dataset for Fig. D-1 is as follows:

> 6 6
>  1 0 0 2 1 0
>  1 1 0 0 0 0
>  0 0 0 0 0 3
>  0 0 0 0 0 0
>  1 0 0 0 0 1
>  0 1 1 1 1 1
>

Output

For each dataset, print a line having a decimal integer indicating the minimum number of moves along a route from the start to the goal. If there are no such routes, print -1 instead. Each line should not have any character other than this number.

Example

Input

2 1
3 2
6 6
1 0 0 2 1 0
1 1 0 0 0 0
0 0 0 0 0 3
0 0 0 0 0 0
1 0 0 0 0 1
0 1 1 1 1 1
6 1
1 1 2 1 1 3
6 1
1 0 2 1 1 3
12 1
2 0 1 1 1 1 1 1 1 1 1 3
13 1
2 0 1 1 1 1 1 1 1 1 1 1 3
0 0

Output

1
4
-1
4
10
-1

### Response

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

int X,Y;
vector<vector<int>> s;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
using P = pair<int,int>;

int solve(int y, int x, set<P> st){
    if((int)st.size() > 10) return INF;
    int res = INF;
    rep(k,4){
        int d = 1;
        while(true){
            int ny = y+d*dy[k], nx = x+d*dx[k];
            if(!(ny>=0 && nx>=0 && ny<Y && nx<X)) break;
            if(s[ny][nx] == 3) {
                // for(auto p : st){
                    // printf("(%d,%d)",p.first,p.second);
                // }
                // cout<<endl;
                return st.size();
            }
            if(s[ny][nx] == 1 && st.count({ny,nx})==0){
                if(d > 1){
                    st.insert({ny,nx});
                    res = min(solve(ny-dy[k],nx-dx[k],st),res);
                    st.erase({ny,nx});
                }
                break;
            }
            d++;
        }
    }
    return res;
}

int main(void){
    while(cin>>X>>Y, X|Y){
        s.clear(); s.resize(Y);
        int sy=0,sx=0;
        rep(y,Y){
            s[y].resize(X);
            rep(x,X){
                cin>>s[y][x];
                if(s[y][x] == 2) sy = y, sx = x;
            }
        }
        int res = solve(sy,sx,{{sy,sx}});
        cout<<(res>10 ? -1 : res)<<endl;
    }
    return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

You are given an array s consisting of n integers.

You have to find any array t of length k such that you can cut out maximum number of copies of array t from array s.

Cutting out the copy of t means that for each element t_i of array t you have to find t_i in s and remove it from s. If for some t_i you cannot find such element in s, then you cannot cut out one more copy of t. The both arrays can contain duplicate elements.

For example, if s = [1, 2, 3, 2, 4, 3, 1] and k = 3 then one of the possible answers is t = [1, 2, 3]. This array t can be cut out 2 times.

  * To cut out the first copy of t you can use the elements [1, \underline{2}, 3, 2, 4, \underline{3}, \underline{1}] (use the highlighted elements). After cutting out the first copy of t the array s can look like [1, 3, 2, 4].
  * To cut out the second copy of t you can use the elements [\underline{1}, \underline{3}, \underline{2}, 4]. After cutting out the second copy of t the array s will be [4].

Your task is to find such array t that you can cut out the copy of t from s maximum number of times. If there are multiple answers, you may choose any of them.

Input

The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 2 ⋅ 10^5) — the number of elements in s and the desired number of elements in t, respectively.

The second line of the input contains exactly n integers s_1, s_2, ..., s_n (1 ≤ s_i ≤ 2 ⋅ 10^5).

Output

Print k integers — the elements of array t such that you can cut out maximum possible number of copies of this array from s. If there are multiple answers, print any of them. The required array t can contain duplicate elements. All the elements of t (t_1, t_2, ..., t_k) should satisfy the following condition: 1 ≤ t_i ≤ 2 ⋅ 10^5.

Examples

Input

7 3
1 2 3 2 4 3 1

Output

1 2 3

Input

10 4
1 3 1 3 10 3 7 7 12 3

Output

7 3 1 3

Input

15 2
1 2 1 1 1 2 1 1 2 1 2 1 1 1 1

Output

1 1

Note

The first example is described in the problem statement.

In the second example the only answer is [7, 3, 1, 3] and any its permutations. It can be shown that you cannot choose any other array such that the maximum number of copies you can cut out would be equal to 2.

In the third example the array t can be cut out 5 times.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e9 + 7;
const long long int modc = 998244353;
long long int A[200005];
long long int check(long long int x, long long int n, long long int k,
                    long long int t) {
  map<long long int, long long int> cnt;
  for (long long int i = 0; i < n; i++) cnt[A[i]] += 1;
  long long int i = 0;
  vector<long long int> Ans;
  while (i < n && k > 0) {
    if (cnt[A[i]] >= x) Ans.push_back(A[i]), k -= 1, cnt[A[i]] -= x;
    i += 1;
  }
  if (t == 1) {
    for (auto x : Ans) cout << x << " ";
  }
  if (k == 0) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long int n, k;
  cin >> n >> k;
  for (long long int i = 0; i < n; i++) cin >> A[i];
  long long int l = 0, h = n;
  long long int ans = 0;
  while (l < h) {
    long long int mid = (l + h + 1) / 2;
    if (check(mid, n, k, 0)) {
      l = mid;
      ans = mid;
    } else
      h = mid - 1;
  }
  long long int a = check(ans, n, k, 1);
  return 0;
}

```


### Prompt

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

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

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

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

Input

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

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

Output

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

Examples

Input

aaabbac
aabbccac

Output

6

Input

a
z

Output

-1

Note

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

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string str1, str2;
  cin >> str1 >> str2;
  vector<int> data1(32), data2(32);
  for (int i = 0; i < str1.length(); ++i) {
    ++data1[str1[i] - 'a'];
  }
  for (int i = 0; i < str2.length(); ++i) {
    ++data2[str2[i] - 'a'];
  }
  int Answer = 0;
  for (int i = 0; i < 32; ++i) {
    if (data2[i]) {
      if (!data1[i]) {
        Answer = -1;
        break;
      } else {
        Answer += min(data1[i], data2[i]);
      }
    }
  }
  if (!Answer) Answer = -1;
  cout << Answer << endl;
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from 1 to n. For every edge e of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge e (and only this edge) is erased from the tree.

Monocarp has given you a list of n - 1 pairs of numbers. He wants you to provide an example of a tree that will produce the said list if this tree exists. If such tree does not exist, say so.

Input

The first line contains one integer n (2 ≤ n ≤ 1 000) — the number of vertices in the tree.

Each of the next n-1 lines contains two integers a_i and b_i each (1 ≤ a_i < b_i ≤ n) — the maximal indices of vertices in the components formed if the i-th edge is removed.

Output

If there is no such tree that can produce the given list of pairs, print "NO" (without quotes).

Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next n - 1 lines. Each of the last n - 1 lines should contain two integers x_i and y_i (1 ≤ x_i, y_i ≤ n) — vertices connected by an edge.

Note: The numeration of edges doesn't matter for this task. Your solution will be considered correct if your tree produces the same pairs as given in the input file (possibly reordered). That means that you can print the edges of the tree you reconstructed in any order.

Examples

Input

4
3 4
1 4
3 4

Output

YES
1 3
3 2
2 4

Input

3
1 3
1 3

Output

NO

Input

3
1 2
2 3

Output

NO

Note

Possible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7FFFFFFF;
const long long LINF = 0x7FFFFFFFFFFFFF;
void guan() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const long long mod = 1e9 + 7;
const int maxn = 202020;
typedef struct Node {
  int u, v;
  bool operator<(const struct Node& e) const {
    if (u == e.u) return v > e.v;
    return u > e.u;
  }
} node;
node a[maxn];
vector<int> g[maxn], id[maxn];
int vis[maxn];
queue<int> q;
pair<int, int> ans[maxn];
int main() {
  guan();
  int t;
  long long n, m, d, h;
  while (cin >> n) {
    memset(vis, 0, sizeof(vis));
    while (!q.empty()) q.pop();
    for (int i = 1; i <= n - 1; i++) {
      cin >> a[i].u >> a[i].v;
      vis[a[i].u] = 1;
      vis[a[i].v] = 1;
      if (a[i].u < a[i].v) swap(a[i].u, a[i].v);
    }
    sort(a + 1, a + n);
    for (int i = n; i >= 1; i--) {
      if (vis[i]) continue;
      q.push(i);
    }
    if (n > 1 && a[n - 1].u != n) {
      cout << "NO" << endl;
      continue;
    } else {
      int cnt = 0, ok = 1;
      for (int i = 1; i <= n - 1 && ok; i++) {
        vis[a[i].v] = 1;
        int u = n;
        while (a[i + 1].v == a[i].v && ok) {
          ans[++cnt] = pair<int, int>(u, q.front());
          if (q.front() > a[i].v) {
            ok = 0;
          }
          u = q.front();
          q.pop();
          i++;
        }
        ans[++cnt] = pair<int, int>(u, a[i].v);
      }
      if (ok) {
        cout << "YES" << endl;
        for (int i = 1; i <= cnt; i++)
          cout << ans[i].first << " " << ans[i].second << endl;
      } else {
        cout << "NO" << endl;
      }
    }
  }
  return 0;
}

```


### Prompt

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

Zxr960115 is owner of a large farm. He feeds m cute cats and employs p feeders. There's a straight road across the farm and n hills along the road, numbered from 1 to n from left to right. The distance between hill i and (i - 1) is di meters. The feeders live in hill 1.

One day, the cats went out to play. Cat i went on a trip to hill hi, finished its trip at time ti, and then waited at hill hi for a feeder. The feeders must take all the cats. Each feeder goes straightly from hill 1 to n without waiting at a hill and takes all the waiting cats at each hill away. Feeders walk at a speed of 1 meter per unit time and are strong enough to take as many cats as they want.

For example, suppose we have two hills (d2 = 1) and one cat that finished its trip at time 3 at hill 2 (h1 = 2). Then if the feeder leaves hill 1 at time 2 or at time 3, he can take this cat, but if he leaves hill 1 at time 1 he can't take it. If the feeder leaves hill 1 at time 2, the cat waits him for 0 time units, if the feeder leaves hill 1 at time 3, the cat waits him for 1 time units.

Your task is to schedule the time leaving from hill 1 for each feeder so that the sum of the waiting time of all cats is minimized.

Input

The first line of the input contains three integers n, m, p (2 ≤ n ≤ 105, 1 ≤ m ≤ 105, 1 ≤ p ≤ 100).

The second line contains n - 1 positive integers d2, d3, ..., dn (1 ≤ di < 104).

Each of the next m lines contains two integers hi and ti (1 ≤ hi ≤ n, 0 ≤ ti ≤ 109).

Output

Output an integer, the minimum sum of waiting time of all cats.

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

Examples

Input

4 6 2
1 3 5
1 0
2 1
4 9
1 10
2 10
3 12

Output

3

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
struct line {
  long long m, c;
  long long eval(long long x) { return m * x + c; }
  long long div(long long a, long long b) {
    return a / b - ((a ^ b) < 0 && a % b);
  }
  long long intersectX(line l) { return div(c - l.c, l.m - m); }
};
struct LineContainerFast {
  vector<line> v;
  int start, end;
  LineContainerFast() {
    start = 0;
    end = -1;
  }
  void add(long long m, long long c) {
    line l = {m, c};
    while (start < end && l.intersectX(v[end]) <= v[end].intersectX(v[end - 1]))
      --end;
    ++end;
    if (end == v.size())
      v.push_back(l);
    else
      v[end] = l;
  }
  long long query(long long x) {
    assert(start <= end);
    while (start < end && v[start].eval(x) <= v[start + 1].eval(x)) ++start;
    return v[start].eval(x);
  }
  void clear() {
    v.clear();
    start = 0;
    end = -1;
  }
};
void solve() {
  int n, m, P, h;
  long long t;
  cin >> n >> m >> P;
  int d[n];
  d[0] = 0;
  for (int i = 1; i < n; i++) {
    cin >> d[i];
    d[i] += d[i - 1];
  }
  vector<long long> cat(m);
  for (int i = 0; i < m; i++) {
    cin >> h >> t;
    cat[i] = t - d[h - 1];
  }
  sort((cat).begin(), (cat).end());
  long long dp[m], sum = 0;
  for (int i = 0; i < m; i++) {
    dp[i] = cat[i] * i - sum;
    sum += cat[i];
  }
  long long suff[m + 1], tmp;
  suff[m] = 0;
  for (int i = m - 1; i >= 0; i--) suff[i] = suff[i + 1] + cat[i];
  LineContainerFast l;
  for (int p = 2; p <= P; p++) {
    l.clear();
    for (int i = 0; i < p - 1; i++) l.add(i, suff[i + 1]);
    for (int i = p - 1; i < m; i++) {
      tmp = dp[i];
      dp[i] = i * cat[i] + suff[i + 1] - l.query(cat[i]);
      l.add(i, suff[i + 1] - tmp);
    }
  }
  cout << dp[m - 1] << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}

```


### Prompt

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

Some days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a big number with it.

But I also don't want to use many numbers, so I'll choose three positive integers (they don't have to be distinct) which are not greater than n. Can you help me to find the maximum possible least common multiple of these three integers?

Input

The first line contains an integer n (1 ≤ n ≤ 106) — the n mentioned in the statement.

Output

Print a single integer — the maximum possible LCM of three not necessarily distinct positive integers that are not greater than n.

Examples

Input

9

Output

504

Input

7

Output

210

Note

The least common multiple of some positive integers is the least positive integer which is multiple for each of them.

The result may become very large, 32-bit integer won't be enough. So using 64-bit integers is recommended.

For the last example, we can chose numbers 7, 6, 5 and the LCM of them is 7·6·5 = 210. It is the maximum value we can get.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline long long int read() {
  char c = getchar();
  long long int num, sign = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') sign = -1;
  for (num = 0; c >= '0' && c <= '9';) {
    c -= '0';
    num = num * 10 + c;
    c = getchar();
  }
  return num * sign;
}
inline long long int pw(long long int b, long long int p) {
  long long int ans = 1;
  while (p > 0) {
    if (p & 1) ans *= b;
    p >>= 1;
    b *= b;
  }
  return ans;
}
inline bool isPrime(long long int n) {
  if (n == 1) return false;
  if (n == 2) return true;
  if (!(n % 2)) return false;
  for (long long int i = 3; i <= sqrt(n); i += 2)
    if (!(n % i)) return false;
  return true;
}
inline long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n = read();
  if (n == 1)
    cout << 1 << endl;
  else if (n == 2)
    cout << 2 << endl;
  else if (n == 3)
    cout << 6 << endl;
  else if (n == 4)
    cout << 12 << endl;
  else if (n % 2)
    cout << n * (n - 1) * (n - 2) << endl;
  else if (!(n % 2) && !(n % 3))
    cout << (n - 1) * (n - 2) * (n - 3) << endl;
  else
    cout << n * (n - 1) * (n - 3) << endl;
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples:

  * for the array [0, 0, 1, 0, 2] MEX equals to 3 because numbers 0, 1 and 2 are presented in the array and 3 is the minimum non-negative integer not presented in the array;
  * for the array [1, 2, 3, 4] MEX equals to 0 because 0 is the minimum non-negative integer not presented in the array;
  * for the array [0, 1, 4, 3] MEX equals to 2 because 2 is the minimum non-negative integer not presented in the array.

You are given an empty array a=[] (in other words, a zero-length array). You are also given a positive integer x.

You are also given q queries. The j-th query consists of one integer y_j and means that you have to append one element y_j to the array. The array length increases by 1 after a query.

In one move, you can choose any index i and set a_i := a_i + x or a_i := a_i - x (i.e. increase or decrease any element of the array by x). The only restriction is that a_i cannot become negative. Since initially the array is empty, you can perform moves only after the first query.

You have to maximize the MEX (minimum excluded) of the array if you can perform any number of such operations (you can even perform the operation multiple times with one element).

You have to find the answer after each of q queries (i.e. the j-th answer corresponds to the array of length j).

Operations are discarded before each query. I.e. the array a after the j-th query equals to [y_1, y_2, ..., y_j].

Input

The first line of the input contains two integers q, x (1 ≤ q, x ≤ 4 ⋅ 10^5) — the number of queries and the value of x.

The next q lines describe queries. The j-th query consists of one integer y_j (0 ≤ y_j ≤ 10^9) and means that you have to append one element y_j to the array.

Output

Print the answer to the initial problem after each query — for the query j print the maximum value of MEX after first j queries. Note that queries are dependent (the array changes after each query) but operations are independent between queries.

Examples

Input

7 3
0
1
2
2
0
0
10

Output

1
2
3
3
4
4
7

Input

4 3
1
2
1
2

Output

0
0
0
0

Note

In the first example:

  * After the first query, the array is a=[0]: you don't need to perform any operations, maximum possible MEX is 1.
  * After the second query, the array is a=[0, 1]: you don't need to perform any operations, maximum possible MEX is 2.
  * After the third query, the array is a=[0, 1, 2]: you don't need to perform any operations, maximum possible MEX is 3.
  * After the fourth query, the array is a=[0, 1, 2, 2]: you don't need to perform any operations, maximum possible MEX is 3 (you can't make it greater with operations).
  * After the fifth query, the array is a=[0, 1, 2, 2, 0]: you can perform a[4] := a[4] + 3 = 3. The array changes to be a=[0, 1, 2, 2, 3]. Now MEX is maximum possible and equals to 4.
  * After the sixth query, the array is a=[0, 1, 2, 2, 0, 0]: you can perform a[4] := a[4] + 3 = 0 + 3 = 3. The array changes to be a=[0, 1, 2, 2, 3, 0]. Now MEX is maximum possible and equals to 4.
  * After the seventh query, the array is a=[0, 1, 2, 2, 0, 0, 10]. You can perform the following operations:
    * a[3] := a[3] + 3 = 2 + 3 = 5,
    * a[4] := a[4] + 3 = 0 + 3 = 3,
    * a[5] := a[5] + 3 = 0 + 3 = 3,
    * a[5] := a[5] + 3 = 3 + 3 = 6,
    * a[6] := a[6] - 3 = 10 - 3 = 7,
    * a[6] := a[6] - 3 = 7 - 3 = 4.
The resulting array will be a=[0, 1, 2, 5, 3, 6, 4]. Now MEX is maximum possible and equals to 7.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long q, x;
  cin >> q >> x;
  long long n = q;
  long long a[n];
  map<long long, long long> m;
  long long min = 0;
  map<long long, long long> f;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    long long mod = a[i] % x;
    f[mod]++;
    m[mod + ((f[mod] - 1) * x)]++;
    while (m[min] == 1) min++;
    cout << min << endl;
  }
  map<long long, long long>::iterator it;
}

```


### Prompt

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

The sequence of integers a_1, a_2, ..., a_k is called a good array if a_1 = k - 1 and a_1 > 0. For example, the sequences [3, -1, 44, 0], [1, -99] are good arrays, and the sequences [3, 7, 8], [2, 5, 4, 1], [0] — are not.

A sequence of integers is called good if it can be divided into a positive number of good arrays. Each good array should be a subsegment of sequence and each element of the sequence should belong to exactly one array. For example, the sequences [2, -3, 0, 1, 4], [1, 2, 3, -3, -9, 4] are good, and the sequences [2, -3, 0, 1], [1, 2, 3, -3 -9, 4, 1] — are not.

For a given sequence of numbers, count the number of its subsequences that are good sequences, and print the number of such subsequences modulo 998244353.

Input

The first line contains the number n~(1 ≤ n ≤ 10^3) — the length of the initial sequence. The following line contains n integers a_1, a_2, ..., a_n~(-10^9 ≤ a_i ≤ 10^9) — the sequence itself.

Output

In the single line output one integer — the number of subsequences of the original sequence that are good sequences, taken modulo 998244353.

Examples

Input

3
2 1 1

Output

2

Input

4
1 1 1 1

Output

7

Note

In the first test case, two good subsequences — [a_1, a_2, a_3] and [a_2, a_3].

In the second test case, seven good subsequences — [a_1, a_2, a_3, a_4], [a_1, a_2], [a_1, a_3], [a_1, a_4], [a_2, a_3], [a_2, a_4] and [a_3, a_4].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long INF = 1e18;
long long factorial[1001];
long long inverse(long long a) {
  long long ans = 1, mult = a, exp = mod - 2;
  while (exp) {
    if (exp & 1) ans = (ans * mult) % mod;
    mult = (mult * mult) % mod;
    exp >>= 1;
  }
  return ans;
}
long long bin(long long n, long long r) {
  long long ans = ((factorial[n] % mod) * (inverse(factorial[r]) % mod)) % mod;
  return (ans * inverse(factorial[n - r])) % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  factorial[0] = 1;
  for (long long i = 1; i < 1001; i++)
    factorial[i] = factorial[i - 1] * i % mod;
  long long n;
  cin >> n;
  vector<long long> v(n), dp(n, 0), suf(n, 0);
  for (int i = 0; i < n; i++) cin >> v[i];
  long long ans = 0;
  for (long long i = n - 2; i >= 0; i--) {
    if (v[i] > 0 && i + v[i] < n) {
      for (long long k = i + v[i]; k < n; k++) {
        long long b = bin(k - i - 1, v[i] - 1);
        dp[i] += b + (k != n - 1 ? b * suf[k + 1] : 0);
        dp[i] %= mod;
      }
    }
    suf[i] = (suf[i + 1] + dp[i]) % mod;
    ans = (ans + dp[i]) % mod;
  }
  cout << ans;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

This is the easy version of this problem. The only difference is the limit of n - the length of the input string. In this version, 1 ≤ n ≤ 2000. The hard version of this challenge is not offered in the round for the second division.

Let's define a correct bracket sequence and its depth as follow:

  * An empty string is a correct bracket sequence with depth 0.
  * If "s" is a correct bracket sequence with depth d then "(s)" is a correct bracket sequence with depth d + 1.
  * If "s" and "t" are both correct bracket sequences then their concatenation "st" is a correct bracket sequence with depth equal to the maximum depth of s and t.

For a (not necessarily correct) bracket sequence s, we define its depth as the maximum depth of any correct bracket sequence induced by removing some characters from s (possibly zero). For example: the bracket sequence s = "())(())" has depth 2, because by removing the third character we obtain a correct bracket sequence "()(())" with depth 2.

Given a string a consists of only characters '(', ')' and '?'. Consider all (not necessarily correct) bracket sequences obtained by replacing all characters '?' in a by either '(' or ')'. Calculate the sum of all the depths of all these bracket sequences. As this number can be large, find it modulo 998244353.

Hacks in this problem in the first division can be done only if easy and hard versions of this problem was solved.

Input

The only line contains a non-empty string consist of only '(', ')' and '?'. The length of the string is at most 2000.

Output

Print the answer modulo 998244353 in a single line.

Examples

Input

??

Output

1

Input

(?(?))

Output

9

Note

In the first test case, we can obtain 4 bracket sequences by replacing all characters '?' with either '(' or ')':

  * "((". Its depth is 0;
  * "))". Its depth is 0;
  * ")(". Its depth is 0;
  * "()". Its depth is 1.

So, the answer is 1 = 0 + 0 + 0 + 1.

In the second test case, we can obtain 4 bracket sequences by replacing all characters '?' with either '(' or ')':

  * "(((())". Its depth is 2;
  * "()()))". Its depth is 2;
  * "((()))". Its depth is 3;
  * "()(())". Its depth is 2.

So, the answer is 9 = 2 + 2 + 3 + 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 9, mod = 998244353;
inline long long read() {
  register long long x = 0, f = 1;
  register char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - 48, c = getchar();
  }
  return x * f;
}
long long n, inv[N], fac[N], ifac[N], ans;
char s[N];
void pre() {
  inv[0] = inv[1] = fac[0] = fac[1] = ifac[0] = ifac[1] = 1;
  for (register long long i = (2); i <= (n); i++)
    inv[i] = inv[mod % i] * (mod - mod / i) % mod;
  for (register long long i = (2); i <= (n); i++) fac[i] = fac[i - 1] * i % mod;
  for (register long long i = (2); i <= (n); i++)
    ifac[i] = ifac[i - 1] * inv[i] % mod;
}
long long C(long long x, long long y) {
  if (x < 0 || y < 0 || x < y)
    return 0;
  else
    return fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}
signed main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  pre();
  long long l = 0, r = 0, x = 0, y = 0;
  for (register long long i = (n); i >= (1); i--) {
    if (s[i] == '?')
      r++;
    else if (s[i] == ')')
      y++;
  }
  for (register long long pos = (1); pos <= (n - 1); pos++) {
    if (s[pos] == '?')
      l++, r--;
    else if (s[pos] == ')')
      y--;
    else
      x++;
    ans = (ans + x * C(l + r, r + y - x) % mod +
           l * C(l + r - 1, r + y - x - 1) % mod) %
          mod;
  }
  printf("%lld\n", ans);
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score.

Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack.

All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer.

Input

The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted.

The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i.

The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively.

Output

Print a single integer, the value of Kevin's final score.

Examples

Input

20 40 60 80 100
0 1 2 3 4
1 0

Output

4900

Input

119 119 119 119 119
0 0 0 0 0
10 0

Output

4930

Note

In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int a[] = {500, 1000, 1500, 2000, 2500};
int m[11], w[11], hs, hu;
int main() {
  for (int i = 0; i < 5; i++) cin >> m[i];
  for (int j = 0; j < 5; j++) cin >> w[j];
  int sum = 0;
  for (int i = 0; i < 5; i++)
    sum += max((a[i] / 10) * 3, (a[i] - (m[i] * a[i]) / 250) - 50 * w[i]);
  cin >> hs >> hu;
  sum += hs * 100 - 50 * hu;
  cout << sum;
  return 0;
}

```


### Prompt

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

There are n bears in the inn and p places to sleep. Bears will party together for some number of nights (and days).

Bears love drinking juice. They don't like wine but they can't distinguish it from juice by taste or smell.

A bear doesn't sleep unless he drinks wine. A bear must go to sleep a few hours after drinking a wine. He will wake up many days after the party is over.

Radewoosh is the owner of the inn. He wants to put some number of barrels in front of bears. One barrel will contain wine and all other ones will contain juice. Radewoosh will challenge bears to find a barrel with wine.

Each night, the following happens in this exact order:

  1. Each bear must choose a (maybe empty) set of barrels. The same barrel may be chosen by many bears.
  2. Each bear drinks a glass from each barrel he chose.
  3. All bears who drink wine go to sleep (exactly those bears who chose a barrel with wine). They will wake up many days after the party is over. If there are not enough places to sleep then bears lose immediately.

At the end, if it's sure where wine is and there is at least one awake bear then bears win (unless they have lost before because of the number of places to sleep).

Radewoosh wants to allow bears to win. He considers q scenarios. In the i-th scenario the party will last for i nights. Then, let Ri denote the maximum number of barrels for which bears surely win if they behave optimally. Let's define <image>. Your task is to find <image>, where <image> denotes the exclusive or (also denoted as XOR).

Note that the same barrel may be chosen by many bears and all of them will go to sleep at once.

Input

The only line of the input contains three integers n, p and q (1 ≤ n ≤ 109, 1 ≤ p ≤ 130, 1 ≤ q ≤ 2 000 000) — the number of bears, the number of places to sleep and the number of scenarios, respectively.

Output

Print one integer, equal to <image>.

Examples

Input

5 1 3

Output

32

Input

1 100 4

Output

4

Input

3 2 1

Output

7

Input

100 100 100

Output

381863924

Note

In the first sample, there are 5 bears and only 1 place to sleep. We have R1 = 6, R2 = 11, R3 = 16 so the answer is <image>. Let's analyze the optimal strategy for scenario with 2 days. There are R2 = 11 barrels and 10 of them contain juice.

  * In the first night, the i-th bear chooses a barrel i only.
    * If one of the first 5 barrels contains wine then one bear goes to sleep. Then, bears win because they know where wine is and there is at least one awake bear.
    * But let's say none of the first 5 barrels contains wine. In the second night, the i-th bear chooses a barrel 5 + i.
      * If one of barrels 6 – 10 contains wine then one bear goes to sleep. And again, bears win in such a situation.
      * If nobody went to sleep then wine is in a barrel 11.

In the second sample, there is only one bear. He should choose an empty set of barrels in each night. Otherwise, he would maybe get wine and bears would lose (because there must be at least one awake bear). So, for any number of days we have Ri = 1. The answer is <image>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
unsigned int n, p, q;
unsigned int a[132], b[132];
unsigned int c[132], ans;
unsigned int gcd(unsigned int a, unsigned int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
unsigned int ksm(unsigned int x, unsigned int y) {
  unsigned int sum = 1;
  while (y) {
    if (y & 1) sum = sum * x;
    y >>= 1;
    x = x * x;
  }
  return sum;
}
signed main() {
  cin >> n >> p >> q;
  p = min(p, n - 1);
  c[0] = 1;
  for (unsigned int k = 1; k <= p; k++) {
    c[k] = 1;
    for (unsigned int i = 1; i <= k; i++) a[i] = n - i + 1, b[i] = i;
    for (unsigned int i = 1; i <= k; i++) {
      for (unsigned int j = 2; j <= k; j++) {
        unsigned int tp = gcd(a[i], b[j]);
        if (tp != 1) a[i] /= tp, b[j] /= tp;
      }
    }
    for (unsigned int i = 1; i <= k; i++) c[k] = c[k] * a[i];
  }
  for (unsigned int i = 1; i <= q; i++) {
    unsigned int tmp = 0;
    for (unsigned int j = 0; j <= p; j++) tmp = (tmp + (c[j] * ksm(i, j)));
    ans = ans ^ (tmp * i);
  }
  cout << ans;
}

```