### Prompt

Please formulate a cpp solution to the following problem:

The only difference between easy and hard versions is the constraints.

Polycarp has to write a coursework. The coursework consists of m pages.

Polycarp also has n cups of coffee. The coffee in the i-th cup has a_i caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He can drink cups in any order. Polycarp drinks each cup instantly and completely (i.e. he cannot split any cup into several days).

Surely, courseworks are not usually being written in a single day (in a perfect world of Berland, at least). Some of them require multiple days of hard work.

Let's consider some day of Polycarp's work. Consider Polycarp drinks k cups of coffee during this day and caffeine dosages of cups Polycarp drink during this day are a_{i_1}, a_{i_2}, ..., a_{i_k}. Then the first cup he drinks gives him energy to write a_{i_1} pages of coursework, the second cup gives him energy to write max(0, a_{i_2} - 1) pages, the third cup gives him energy to write max(0, a_{i_3} - 2) pages, ..., the k-th cup gives him energy to write max(0, a_{i_k} - k + 1) pages.

If Polycarp doesn't drink coffee during some day, he cannot write coursework at all that day.

Polycarp has to finish his coursework as soon as possible (spend the minimum number of days to do it). Your task is to find out this number of days or say that it is impossible.

Input

The first line of the input contains two integers n and m (1 ≤ n ≤ 100, 1 ≤ m ≤ 10^4) — the number of cups of coffee and the number of pages in the coursework.

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 100), where a_i is the caffeine dosage of coffee in the i-th cup.

Output

If it is impossible to write the coursework, print -1. Otherwise print the minimum number of days Polycarp needs to do it.

Examples

Input

5 8
2 3 1 1 2

Output

4

Input

7 10
1 3 4 2 1 4 2

Output

2

Input

5 15
5 5 5 5 5

Output

1

Input

5 16
5 5 5 5 5

Output

2

Input

5 26
5 5 5 5 5

Output

-1

Note

In the first example Polycarp can drink fourth cup during first day (and write 1 page), first and second cups during second day (and write 2 + (3 - 1) = 4 pages), fifth cup during the third day (and write 2 pages) and third cup during the fourth day (and write 1 page) so the answer is 4. It is obvious that there is no way to write the coursework in three or less days in this test.

In the second example Polycarp can drink third, fourth and second cups during first day (and write 4 + (2 - 1) + (3 - 2) = 6 pages) and sixth cup during second day (and write 4 pages) so the answer is 2. It is obvious that Polycarp cannot write the whole coursework in one day in this test.

In the third example Polycarp can drink all cups of coffee during first day and write 5 + (5 - 1) + (5 - 2) + (5 - 3) + (5 - 4) = 15 pages of coursework.

In the fourth example Polycarp cannot drink all cups during first day and should drink one of them during the second day. So during first day he will write 5 + (5 - 1) + (5 - 2) + (5 - 3) = 14 pages of coursework and during second day he will write 5 pages of coursework. This is enough to complete it.

In the fifth example Polycarp cannot write the whole coursework at all, even if he will drink one cup of coffee during each day, so the answer is -1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
map<int, int> cnt;
set<int> key;
struct comp {
  bool operator()(pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second) return a.second > b.second;
    return a.first > b.first;
  }
};
multiset<pair<int, int>, comp> heaps;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  long long int arr[n], sum = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }
  if (sum < m) {
    cout << "-1\n";
    return 0;
  }
  sort(arr, arr + n, greater<long long int>());
  long long int ans = n;
  for (int i = n; i >= 1; i--) {
    vector<long long int> temp[i];
    long long int d = 0;
    for (int j = 0; j < n; j++) {
      temp[d].push_back(arr[j]);
      d++;
      d %= i;
    }
    long long int sums = 0;
    for (int j = 0; j < i; j++)
      for (int k = 0; k < temp[j].size(); k++) sums += max(0ll, temp[j][k] - k);
    if (sums >= m) ans = i;
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

problem

JOI, who has been suffering from his winter vacation homework every time, decided to do his homework systematically this time. Homework is a national language and math drill, with a national language drill on page A and a math drill on page B.

JOI can advance the Japanese drill up to C pages and the math drill up to D pages a day, but if he does his homework, he can't play that day.

There are L days during the winter vacation, and JOI must finish his homework during the winter vacation. Create a program that asks how many days JOI can play during the winter vacation.

input

The input consists of 5 lines, with one positive integer written on each line.

The integer L (2 ≤ L ≤ 40) is written on the first line, which indicates the number of days of winter vacation.

The integer A (1 ≤ A ≤ 1000) is written on the second line, which indicates the number of pages of the Japanese drill.

The integer B (1 ≤ B ≤ 1000) is written on the third line, which indicates the number of pages of the math drill.

The integer C (1 ≤ C ≤ 100) is written on the 4th line, which indicates the maximum number of pages of a national language drill that JOI can advance in a day.

The integer D (1 ≤ D ≤ 100) is written on the 5th line, which indicates the maximum number of pages of the math drill that JOI can advance in a day.

However, given the input data, JOI is guaranteed to be able to finish his homework during the winter vacation and play for at least a day.

Example

Input

20
25
30
6
8

Output

15

### Response

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

int main(){
  int l,a,b,c,d,A,B;
  cin>>l>>a>>b>>c>>d;
  A=a/c;
  B=b/d;
  if(a%c)A++;
  if(b%d)B++;
  cout<<min(l-A,l-B)<<endl;
  return 0;
}
```


### Prompt

Please create a solution in cpp to the following problem:

N contestants participated in a competition. The total of N-1 matches were played in a knockout tournament. For some reasons, the tournament may not be "fair" for all the contestants. That is, the number of the matches that must be played in order to win the championship may be different for each contestant. The structure of the tournament is formally described at the end of this statement.

After each match, there were always one winner and one loser. The last contestant standing was declared the champion.

<image>

Figure: an example of a tournament

For convenience, the contestants were numbered 1 through N. The contestant numbered 1 was the champion, and the contestant numbered i(2 ≦ i ≦ N) was defeated in a match against the contestant numbered a_i.

We will define the depth of the tournament as the maximum number of the matches that must be played in order to win the championship over all the contestants.

Find the minimum possible depth of the tournament.

The formal description of the structure of the tournament is as follows. In the i-th match, one of the following played against each other:

* Two predetermined contestants
* One predetermined contestant and the winner of the j-th match, where j(j<i) was predetermined
* The winner of the j-th match and the winner of the k-th match, where j and k (j,k<i, j ≠ k) were predetermined

Such structure is valid structure of the tournament, if and only if no contestant who has already been defeated in a match will never play in a match, regardless of the outcome of the matches.

Constraints

* 2 ≦ N ≦ 10^5
* 1 ≦ a_i ≦ N(2 ≦ i ≦ N)
* It is guaranteed that the input is consistent (that is, there exists at least one tournament that matches the given information).

Input

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

N
a_2
:
a_N

Output

Print the minimum possible depth of the tournament.

Examples

Input

5
1
1
2
4

Output

3

Input

7
1
2
1
3
1
4

Output

3

Input

4
4
4
1

Output

3

### Response

```cpp
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,a;vector<int>x[120000];
int dfs(int p){
	vector<int>J;
	for(int i=0;i<x[p].size();i++){
		J.push_back(dfs(x[p][i]));
	}
	sort(J.begin(),J.end());int maxn=0;
	for(int i=0;i<(int)J.size();i++){
		maxn=max(maxn,J[i]+(int)J.size()-i);
	}
	return maxn;
}
int main(){
	cin>>n;for(int i=2;i<=n;i++){cin>>a;x[a].push_back(i);}
	cout<<dfs(1)<<endl;
	return 0;
}

```


### Prompt

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

Once when Gerald studied in the first year at school, his teacher gave the class the following homework. She offered the students a string consisting of n small Latin letters; the task was to learn the way the letters that the string contains are written. However, as Gerald is too lazy, he has no desire whatsoever to learn those letters. That's why he decided to lose some part of the string (not necessarily a connected part). The lost part can consist of any number of segments of any length, at any distance from each other. However, Gerald knows that if he loses more than k characters, it will be very suspicious.

Find the least number of distinct characters that can remain in the string after no more than k characters are deleted. You also have to find any possible way to delete the characters.

Input

The first input data line contains a string whose length is equal to n (1 ≤ n ≤ 105). The string consists of lowercase Latin letters. The second line contains the number k (0 ≤ k ≤ 105).

Output

Print on the first line the only number m — the least possible number of different characters that could remain in the given string after it loses no more than k characters.

Print on the second line the string that Gerald can get after some characters are lost. The string should have exactly m distinct characters. The final string should be the subsequence of the initial string. If Gerald can get several different strings with exactly m distinct characters, print any of them.

Examples

Input

aaaaa
4

Output

1
aaaaa

Input

abacaba
4

Output

1
aaaa

Input

abcdefgh
10

Output

0

Note

In the first sample the string consists of five identical letters but you are only allowed to delete 4 of them so that there was at least one letter left. Thus, the right answer is 1 and any string consisting of characters "a" from 1 to 5 in length.

In the second sample you are allowed to delete 4 characters. You cannot delete all the characters, because the string has length equal to 7. However, you can delete all characters apart from "a" (as they are no more than four), which will result in the "aaaa" string.

In the third sample you are given a line whose length is equal to 8, and k = 10, so that the whole line can be deleted. The correct answer is 0 and an empty string.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  pair<int, char> arr[26];
  for (int i = 0; i < 26; i++) {
    arr[i].first = 0;
    arr[i].second = i + 'a';
  }
  string s;
  cin >> s;
  int k;
  cin >> k;
  unordered_set<char> ss;
  for (int i = 0; i < s.size(); i++) {
    int mask = s[i] - 'a';
    ss.insert(s[i]);
    arr[mask].first++;
  }
  sort(arr, arr + 26, [](pair<int, char> lhs, pair<int, char> rhs) {
    if (lhs.first == 0) {
      return false;
    } else if (rhs.first == 0) {
      return true;
    }
    return lhs.first < rhs.first;
  });
  int removed = 0;
  int marked[26] = {0};
  for (int i = 0; i < 26; i++) {
    if (arr[i].first != 0) {
      if (k >= arr[i].first) {
        removed++;
        k -= arr[i].first;
        marked[arr[i].second - 'a'] = 1;
      } else {
        break;
      }
    }
  }
  cout << ss.size() - removed << '\n';
  for (auto each : s) {
    if (!marked[each - 'a']) {
      cout << each;
    }
  }
  cout << '\n';
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Heidi is terrified by your estimate and she found it unrealistic that her friends would collaborate to drive her into debt. She expects that, actually, each person will just pick a random friend to send Heidi to. (This randomness assumption implies, however, that she can now visit the same friend an arbitrary number of times...) Moreover, if a person only has one friend in common with Heidi (i.e., if that person is in a leaf of the tree), then that person will not send Heidi back (so that Heidi's travel will end at some point).

Heidi also found unrealistic the assumption that she can make all the travels in one day. Therefore now she assumes that every time she travels a route between two friends, she needs to buy a new ticket. She wants to know: how much should she expect to spend on the trips?

For what it's worth, Heidi knows that Jenny has at least two friends.

Input

The first line contains the number of friends n (3 ≤ n ≤ 105). The next n - 1 lines each contain three space-separated integers u, v and c (0 ≤ u, v ≤ n - 1, 1 ≤ c ≤ 104) meaning that u and v are friends and the cost for traveling between u and v is c (paid every time!).

It is again guaranteed that the social network of the input forms a tree.

Output

Assume that the expected cost of the trips is written as an irreducible fraction a / b (that is, a and b are coprime). Then Heidi, the weird cow that she is, asks you to output <image>. (Output a single integer between 0 and 109 + 6.)

Examples

Input

3
0 1 10
0 2 20

Output

15

Input

4
0 1 3
0 2 9
0 3 27

Output

13

Input

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

Output

400000019

Input

11
1 0 6646
2 0 8816
3 2 9375
4 2 5950
5 1 8702
6 2 2657
7 2 885
8 7 2660
9 2 5369
10 6 3798

Output

153869806

Input

6
0 1 8
0 2 24
1 3 40
1 4 16
4 5 8

Output

39

Note

In the first example, with probability 1 / 2 Heidi will go to 1 from 0, and with probability 1 / 2 she will go to 2. In the first case the cost would be 10, and in the second it would be 20. After reaching 1 or 2 she will stop, as 1 and 2 are leaves of the social tree. Hence, the expected cost she has to pay is 10·1 / 2 + 20·1 / 2 = 15.

In the third example, the expected cost is 81 / 5. You should output 400000019.

In her travels, Heidi has learned an intriguing fact about the structure of her social network. She tells you the following: The mysterious determinant that you might be wondering about is such that it does not cause strange errors in your reasonable solution... Did we mention that Heidi is a weird cow?

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int q = 1000000007;
int n, a[100010], b[200010], c[200010], d[200010], x[100010], f[100010],
    g[100010], f2[100010], g2[100010], p;
inline int power(int a, int b) {
  if (!b) return 1;
  int c = power(a, b >> 1);
  c = (long long)c * c % q;
  if (b & 1) c = (long long)c * a % q;
  return c;
}
inline void dp(int i, int j, int l) {
  int k;
  for (k = a[i]; k > 0; k = d[k])
    if (b[k] != j && x[b[k]] > 1) {
      dp(b[k], i, c[k]);
      f[i] = (f[i] + f[b[k]] + (long long)c[k] * f2[b[k]]) % q;
      f2[i] = (f2[i] + f2[b[k]]) % q;
    }
  f2[i] = power((x[i] - f2[i] + q) % q, q - 2);
  f[i] = ((long long)f[i] * f2[i] + l) % q * f2[i] % q;
}
inline void dp2(int i, int j, int l) {
  int k, u = (i == 1 ? 0 : (g[i] + (long long)l * g2[i]) % q),
         v = (i == 1 ? 0 : g2[i]);
  for (k = a[i]; k > 0; k = d[k])
    if (b[k] != j && x[b[k]] > 1) {
      u = (u + f[b[k]] + (long long)c[k] * f2[b[k]]) % q;
      v = (v + f2[b[k]]) % q;
    }
  for (k = a[i]; k > 0; k = d[k])
    if (b[k] != j) {
      g2[b[k]] = power(((long long)x[i] - (v - f2[b[k]]) + q) % q, q - 2);
      g[b[k]] =
          (((u - f[b[k]] - (long long)c[k] * f2[b[k]]) % q + q) * g2[b[k]] +
           c[k]) %
          q * g2[b[k]] % q;
    }
  for (k = a[i]; k > 0; k = d[k])
    if (b[k] != j) dp2(b[k], i, c[k]);
}
inline void dfs(int i, int j, int u, int v) {
  int k;
  for (k = a[i]; k > 0; k = d[k])
    if (b[k] != j)
      dfs(b[k], i, ((long long)u * g2[b[k]] + (long long)v * g[b[k]]) % q,
          (long long)v * g2[b[k]] % q);
  if (x[i] == 1) p = (p + u) % q;
}
int main() {
  int i, j, k, l;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d%d", &j, &k, &l);
    j++;
    k++;
    b[2 * i - 1] = k;
    c[2 * i - 1] = l;
    d[2 * i - 1] = a[j];
    a[j] = 2 * i - 1;
    b[2 * i] = j;
    c[2 * i] = l;
    d[2 * i] = a[k];
    a[k] = 2 * i;
    x[j]++;
    x[k]++;
  }
  dp(1, 0, 0);
  dp2(1, 0, 0);
  dfs(1, 0, 0, 1);
  printf("%d\n", p);
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Pasha has a wooden stick of some positive integer length n. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and the sum of these lengths will obviously be n.

Pasha likes rectangles but hates squares, so he wonders, how many ways are there to split a stick into four parts so that it's possible to form a rectangle using these parts, but is impossible to form a square.

Your task is to help Pasha and count the number of such ways. Two ways to cut the stick are considered distinct if there exists some integer x, such that the number of parts of length x in the first way differ from the number of parts of length x in the second way.

Input

The first line of the input contains a positive integer n (1 ≤ n ≤ 2·109) — the length of Pasha's stick.

Output

The output should contain a single integer — the number of ways to split Pasha's stick into four parts of positive integer length so that it's possible to make a rectangle by connecting the ends of these parts, but is impossible to form a square.

Examples

Input

6

Output

1

Input

20

Output

4

Note

There is only one way to divide the stick in the first sample {1, 1, 2, 2}.

Four ways to divide the stick in the second sample are {1, 1, 9, 9}, {2, 2, 8, 8}, {3, 3, 7, 7} and {4, 4, 6, 6}. Note that {5, 5, 5, 5} doesn't work.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
bool cmpManh(const std::pair<long long, long long>& l,
             const std::pair<long long, long long>& r) {
  return ((llabs(l.first) + llabs(l.second)) <
          (llabs(r.first) + llabs(r.second)));
}
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int main(void) {
  int n;
  scanf("%d", &n);
  int i = 1;
  int ans = 0, left;
  if (n % 2) {
    cout << 0 << '\n';
    return 0;
  }
  while (1) {
    left = (n - 2 * i) / 2;
    if (left <= i || left == 0) break;
    ans++;
    i++;
  }
  printf("%d\n", ans);
  return (0);
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Yet another Armageddon is coming! This time the culprit is the Julya tribe calendar.

The beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on it. The translation from Old Beaverish is as follows:

"May the Great Beaver bless you! May your chacres open and may your third eye never turn blind from beholding the Truth! Take the magic number, subtract a digit from it (the digit must occur in the number) and get a new magic number. Repeat this operation until a magic number equals zero. The Earth will stand on Three Beavers for the time, equal to the number of subtractions you perform!"

Distinct subtraction sequences can obviously get you different number of operations. But the Smart Beaver is ready to face the worst and is asking you to count the minimum number of operations he needs to reduce the magic number to zero.

Input

The single line contains the magic integer n, 0 ≤ n.

  * to get 20 points, you need to solve the problem with constraints: n ≤ 106 (subproblem C1);
  * to get 40 points, you need to solve the problem with constraints: n ≤ 1012 (subproblems C1+C2);
  * to get 100 points, you need to solve the problem with constraints: n ≤ 1018 (subproblems C1+C2+C3).

Output

Print a single integer — the minimum number of subtractions that turns the magic number to a zero.

Examples

Input

24

Output

5

Note

In the first test sample the minimum number of operations can be reached by the following sequence of subtractions:

24 → 20 → 18 → 10 → 9 → 0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
map<pair<long long, int>, pair<long long, int> > f;
pair<long long, int> solve(long long n, int mx) {
  if (n == 0) return make_pair(0, 0);
  if (n < 10) {
    pair<long long, int> ans = make_pair(1, 0);
    if (n < mx) ans.second = n - mx;
    return ans;
  }
  pair<long long, int> now = make_pair(n, mx);
  if (f.find(now) != f.end()) return f[now];
  long long t = 1;
  while (t <= n / 10) t *= 10;
  pair<long long, int> ans = make_pair(0, 0);
  while (true) {
    int nx = mx;
    int d = n / t;
    if (d > nx) nx = d;
    pair<long long, int> x = solve(n % t, nx);
    ans.first += x.first;
    n -= n % t;
    if (x.second < 0)
      n += x.second;
    else {
      n -= nx;
      if (nx > 0) ans.first++;
    }
    if (d == 0) break;
  }
  ans.second = n;
  f[now] = ans;
  return ans;
}
int main() {
  long long n;
  scanf("%I64d", &n);
  pair<long long, int> ans = solve(n, 0);
  printf("%I64d\n", ans.first);
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Making Lunch Boxes

Taro has been hooked on making lunch boxes recently. Taro has obtained a new lunch box recipe book today, and wants to try as many of the recipes listed in the book as possible.

Enough of the ingredients for all the recipes are at hand, but they all are in vacuum packs of two. If only one of them is used leaving the other, the leftover will be rotten easily, but making two of the same recipe is not interesting. Thus he decided to make a set of lunch boxes, each with different recipe, that wouldn't leave any unused ingredients.

Note that the book may include recipes for different lunch boxes made of the same set of ingredients.

How many lunch box recipes can Taro try today at most following his dogma?

Input

The input consists of at most 50 datasets, each in the following format.

n m
b1,1...b1,m
...
bn,1...bn,m

The first line contains n, which is the number of recipes listed in the book, and m, which is the number of ingredients. Both n and m are positive integers and satisfy 1 ≤ n ≤ 500, 1 ≤ m ≤ 500 and 1 ≤ n × m ≤ 500. The following n lines contain the information for each recipe with the string of length m consisting of 0 or 1. bi,j implies whether the i-th recipe needs the j-th ingredient. 1 means the ingredient is needed for the recipe and 0 means not. Each line contains at least one 1.

The end of the input is indicated by a line containing two zeros.

Output

For each dataset, output the maximum number of recipes Taro can try.

Sample Input

4 3
110
101
011
110
7 1
1
1
1
1
1
1
1
4 5
10000
01000
00100
00010
6 6
111111
011000
100000
000010
100001
100100
0 0

Output for the Sample Input

3
6
0
6

Example

Input

4 3
110
101
011
110
7 1
1
1
1
1
1
1
1
4 5
10000
01000
00100
00010
6 6
111111
011000
100000
000010
100001
100100
0 0

Output

3
6
0
6

### Response

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

vector<int> Prev(4200000), Next(4200000);

string field[505];

int main() {
    while(true) {
        int n, m;
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        for(int i = 1; i <= n; i++) cin >> field[i];
        if(m <= 22) {
            for(int i = 0; i < (1 << m); i++) {
                Prev[i] = -1e9;
                Next[i] = 1e9;
            }
            Prev[0] = 0;
            for(int i = 1; i <= n; i++) {
                int now = 0;
                for(int j = 0; j < m; j++) {
                    now *= 2;
                    if(field[i][j] == '1') now++;
                }
                //cerr << n << " " << m << " " << now << endl;
                for(int bit = 0; bit < (1 << m); bit++) {
                    Next[bit] = max(Prev[bit], Prev[bit ^ now] + 1);
                    //cerr << n << " " << bit << " " << Next[bit] << endl;
                }
                swap(Prev, Next);
            }
            cout << max(Prev[0], 0) << endl;
        } else {
            int res = 0;
            vector< bitset<500> > bs(n);
            for (int i = 0; i < n; ++i) bs[i] = bitset<500>(field[i + 1]);
            for (int bit = 0; bit < 1 << n; ++bit) {
                bitset<500> s;
                for (int i = 0; i < n; ++i) if (bit >> i & 1) {
                    s ^= bs[i];
                }
                if (!s.count()) {
                    res = max(res, __builtin_popcount(bit));
                }
            }
            cout << res << '\n';
        }
    }
    return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Have you ever played Pudding Monsters? In this task, a simplified one-dimensional model of this game is used.

<image>

Imagine an infinite checkered stripe, the cells of which are numbered sequentially with integers. Some cells of the strip have monsters, other cells of the strip are empty. All monsters are made of pudding, so if there are two monsters in the neighboring cells, they stick to each other (literally). Similarly, if several monsters are on consecutive cells, they all stick together in one block of monsters. We will call the stuck together monsters a block of monsters. A detached monster, not stuck to anyone else, is also considered a block.

In one move, the player can take any block of monsters and with a movement of his hand throw it to the left or to the right. The selected monsters will slide on until they hit some other monster (or a block of monsters).

For example, if a strip has three monsters in cells 1, 4 and 5, then there are only four possible moves: to send a monster in cell 1 to minus infinity, send the block of monsters in cells 4 and 5 to plus infinity, throw monster 1 to the right (it will stop in cell 3), throw a block of monsters in cells 4 and 5 to the left (they will stop in cells 2 and 3).

Some cells on the strip are marked with stars. These are the special cells. The goal of the game is to make the largest possible number of special cells have monsters on them.

You are given the numbers of the special cells on a strip as well as the initial position of all monsters. What is the maximum number of special cells that will contain monsters in the optimal game?

Input

The first line contains two integers n and m (1 ≤ n ≤ 105; 1 ≤ m ≤ 2000) — the number of monsters on the strip and the number of special cells.

The second line contains n distinct integers — the numbers of the cells with monsters, then the third line contains m distinct integers — the numbers of the special cells. It is guaranteed that all the numbers of the cells are positive integers not exceeding 2·105.

Output

Print a single integer — the maximum number of special cells that will contain monsters in the optimal game.

Examples

Input

3 2
1 3 5
2 4

Output

2

Input

4 2
1 3 4 6
2 5

Output

2

Input

4 2
1 8 4 5
7 2

Output

1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000;
int n, m;
int a[200010], b[200010], l[200010], r[200010], f[200010], g[200010],
    sum[200010];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]), sum[b[i]]++;
  sort(b + 1, b + m + 1);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= maxn; i++) sum[i] += sum[i - 1];
  for (int i = 1; i <= n; i++) l[i] = a[i] == a[i - 1] + 1 ? l[i - 1] : i;
  for (int i = n; i; i--) r[i] = a[i] == a[i + 1] - 1 ? r[i + 1] : i;
  for (int i = 1; i <= n; i++) {
    g[i] = max(g[i], f[i - 1] + sum[a[i]] - sum[a[i] - 1]);
    for (int j = 1; j <= m; j++) {
      int d = a[i] - b[j];
      if (d <= 0) break;
      if (d < i) g[i] = max(g[i], f[l[i - d] - 1] + sum[a[i]] - sum[b[j] - 1]);
    }
    f[i] = max(f[i], g[i]);
    for (int j = m; j; j--) {
      int d = b[j] - a[i];
      if (d <= 0) break;
      if (d <= n - i)
        f[r[i + d]] = max(f[r[i + d]], g[i] + sum[b[j]] - sum[a[i]]);
    }
  }
  printf("%d\n", f[n]);
}

```


### Prompt

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

Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together.

More detailed, there are n pairs of boys and girls standing in a circle. Initially, boy number 1 dances with a girl number 1, boy number 2 dances with a girl number 2 and so on. Girls are numbered in the clockwise order. During the dance different moves are announced and all pairs perform this moves. While performing moves boys move along the circle, while girls always stay at their initial position. For the purpose of this problem we consider two different types of moves:

  1. Value x and some direction are announced, and all boys move x positions in the corresponding direction.
  2. Boys dancing with even-indexed girls swap positions with boys who are dancing with odd-indexed girls. That is the one who was dancing with the girl 1 swaps with the one who was dancing with the girl number 2, while the one who was dancing with girl number 3 swaps with the one who was dancing with the girl number 4 and so one. It's guaranteed that n is even.

Your task is to determine the final position of each boy.

Input

The first line of the input contains two integers n and q (2 ≤ n ≤ 1 000 000, 1 ≤ q ≤ 2 000 000) — the number of couples in the rueda and the number of commands to perform, respectively. It's guaranteed that n is even.

Next q lines contain the descriptions of the commands. Each command has type as the integer 1 or 2 first. Command of the first type is given as x ( - n ≤ x ≤ n), where 0 ≤ x ≤ n means all boys moves x girls in clockwise direction, while  - x means all boys move x positions in counter-clockwise direction. There is no other input for commands of the second type.

Output

Output n integers, the i-th of them should be equal to the index of boy the i-th girl is dancing with after performing all q moves.

Examples

Input

6 3
1 2
2
1 2

Output

4 3 6 5 2 1

Input

2 3
1 1
2
1 -2

Output

1 2

Input

4 2
2
1 3

Output

1 4 3 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, y, sum, ans, s, a[1000005], pos[1000005], one = 1, two = 2,
                                                          three = 3;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &x);
    if (x == 1) {
      scanf("%d", &y);
      while (y < 0) y += n;
      one += y;
      if (one > n) one -= n;
      two += y;
      if (two > n) two -= n;
      three += y;
      if (three > n) three -= n;
    } else {
      if (one % 2 == 1)
        one++;
      else
        one--;
      if (two % 2 == 1)
        two++;
      else
        two--;
      if (three % 2 == 1)
        three++;
      else
        three--;
    }
  }
  if (n == 2) {
    if (one == 1)
      printf("1 2\n");
    else
      printf("2 1\n");
    return 0;
  }
  a[one] = 1;
  a[two] = 2;
  a[three] = 3;
  pos[1] = one;
  pos[2] = two;
  pos[3] = three;
  for (int i = 4; i <= n; i++) {
    int p = pos[i - 2] + (three - one);
    while (p <= 0) p += n;
    while (p > n) p -= n;
    a[p] = i;
    pos[i] = p;
  }
  for (int i = 1; i < n; i++) printf("%d ", a[i]);
  printf("%d\n", a[n]);
  return 0;
}

```


### Prompt

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

You are given a complete directed graph K_n with n vertices: each pair of vertices u ≠ v in K_n have both directed edges (u, v) and (v, u); there are no self-loops.

You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices).

We can write such cycle as a list of n(n - 1) + 1 vertices v_1, v_2, v_3, ..., v_{n(n - 1) - 1}, v_{n(n - 1)}, v_{n(n - 1) + 1} = v_1 — a visiting order, where each (v_i, v_{i + 1}) occurs exactly once.

Find the lexicographically smallest such cycle. It's not hard to prove that the cycle always exists.

Since the answer can be too large print its [l, r] segment, in other words, v_l, v_{l + 1}, ..., v_r.

Input

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

Next T lines contain test cases — one per line. The first and only line of each test case contains three integers n, l and r (2 ≤ n ≤ 10^5, 1 ≤ l ≤ r ≤ n(n - 1) + 1, r - l + 1 ≤ 10^5) — the number of vertices in K_n, and segment of the cycle to print.

It's guaranteed that the total sum of n doesn't exceed 10^5 and the total sum of r - l + 1 doesn't exceed 10^5.

Output

For each test case print the segment v_l, v_{l + 1}, ..., v_r of the lexicographically smallest cycle that visits every edge exactly once.

Example

Input

3
2 1 3
3 3 6
99995 9998900031 9998900031

Output

1 2 1
1 3 2 3
1

Note

In the second test case, the lexicographically minimum cycle looks like: 1, 2, 1, 3, 2, 3, 1.

In the third test case, it's quite obvious that the cycle should start and end in vertex 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long l, r;
  cin >> l >> r;
  if (l == r && l == (n * (n - 1) + 1)) {
    cout << 1 << '\n';
    return;
  }
  long long grp = n - 1;
  long long sum = 0;
  long long idx = 1;
  long long extra = 0;
  for (long long i = 1; i <= n - 1; i++) {
    sum += (grp * 2);
    if (sum >= l) {
      idx = i;
      sum -= (grp * 2);
      break;
    }
    grp--;
  }
  long long rem = l - sum;
  long long x = idx;
  long long y = idx + (rem + 1) / 2;
  for (long long i = l; i <= r; i++) {
    if (i == (n * (n - 1) + 1)) {
      cout << 1 << ' ';
    } else {
      if (i % 2) {
        cout << x << ' ';
      } else {
        cout << y << ' ';
        y++;
        if (y == n + 1) {
          x++;
          y = 1 + x;
        }
      }
    }
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

All techniques in the ninja world consist of hand seals. At the moment Naruto is learning a new technique, which consists of n⋅ m different seals, denoted by distinct numbers. All of them were written in an n× m table.

The table is lost now. Naruto managed to remember elements of each row from left to right, and elements of each column from top to bottom, but he doesn't remember the order of rows and columns. Please restore the table consistent with this data so that Naruto will be able to learn the new technique.

Input

The first line of the input contains the only integer t (1≤ t≤ 100 000) denoting the number of test cases. Their descriptions follow.

The first line of each test case description consists of two space-separated integers n and m (1 ≤ n, m ≤ 500) standing for the number of rows and columns in the table, respectively. All hand seals are encoded by the positive integers from 1 to n⋅ m.

The following n lines contain m space separated integers each, denoting elements of an arbitrary row in the table left to right.

The following m lines contain n space separated integers each, denoting elements of an arbitrary column in the table top to bottom.

Sum of nm over all test cases does not exceed 250 000. It is guaranteed that each row occurs in the input exactly once, as well as each column. It is also guaranteed that each number from 1 to nm occurs exactly once in all rows, as well as in all columns. Finally, it is guaranteed that a table consistent with the input exists.

Output

For each test case, output n lines with m space-separated integers each, denoting the restored table. One can show that the answer is always unique.

Example

Input

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

Output

1 2 3
6 5 4
3
1
2

Note

Consider the first test case. The matrix is 2 × 3. You are given the rows and columns in arbitrary order.

One of the rows is [6, 5, 4]. One of the rows is [1, 2, 3].

One of the columns is [1, 6]. One of the columns is [2, 5]. One of the columns is [3, 4].

You are to reconstruct the matrix. The answer is given in the output.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> narr(n);
  vector<vector<long long>> marr(m);
  for (long long i = 0; i <= n - 1; i += 1) {
    for (long long j = 0; j <= m - 1; j += 1) {
      long long val;
      cin >> val;
      narr[i].push_back(val);
    }
  }
  for (long long i = 0; i <= m - 1; i += 1) {
    for (long long j = 0; j <= n - 1; j += 1) {
      long long val;
      cin >> val;
      marr[i].push_back(val);
    }
  }
  long long k = 0;
  bool flag = 0;
  long long map = 0;
  vector<vector<long long>> sol;
  for (long long i = 0; i <= n - 1; i += 1) {
    long long fir = marr[0][i];
    if (flag == 1) {
      for (long long j = 0; j <= n - 1; j += 1) {
        if (narr[j][map] == fir) {
          sol.push_back(narr[j]);
          break;
        }
      }
    } else {
      for (long long i1 = 0; i1 <= n - 1; i1 += 1) {
        for (long long j1 = 0; j1 <= m - 1; j1 += 1) {
          if (narr[i1][j1] == fir) {
            flag = 1;
            sol.push_back(narr[i1]);
            map = j1;
            break;
          }
        }
        if (flag == 1) break;
      }
    }
  }
  for (long long i = 0; i <= n - 1; i += 1) {
    for (long long j = 0; j <= m - 1; j += 1) {
      cout << sol[i][j] << ' ';
    }
    cout << '\n';
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}

```


### Prompt

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

There is an infinite board of square tiles. Initially all tiles are white.

Vova has a red marker and a blue marker. Red marker can color a tiles. Blue marker can color b tiles. If some tile isn't white then you can't use marker of any color on it. Each marker must be drained completely, so at the end there should be exactly a red tiles and exactly b blue tiles across the board.

Vova wants to color such a set of tiles that:

  * they would form a rectangle, consisting of exactly a+b colored tiles;
  * all tiles of at least one color would also form a rectangle.

Here are some examples of correct colorings:

<image>

Here are some examples of incorrect colorings:

<image>

Among all correct colorings Vova wants to choose the one with the minimal perimeter. What is the minimal perimeter Vova can obtain?

It is guaranteed that there exists at least one correct coloring.

Input

A single line contains two integers a and b (1 ≤ a, b ≤ 10^{14}) — the number of tiles red marker should color and the number of tiles blue marker should color, respectively.

Output

Print a single integer — the minimal perimeter of a colored rectangle Vova can obtain by coloring exactly a tiles red and exactly b tiles blue.

It is guaranteed that there exists at least one correct coloring.

Examples

Input

4 4

Output

12

Input

3 9

Output

14

Input

9 3

Output

14

Input

3 6

Output

12

Input

506 2708

Output

3218

Note

The first four examples correspond to the first picture of the statement.

Note that for there exist multiple correct colorings for all of the examples.

In the first example you can also make a rectangle with sides 1 and 8, though its perimeter will be 18 which is greater than 8.

In the second example you can make the same resulting rectangle with sides 3 and 4, but red tiles will form the rectangle with sides 1 and 3 and blue tiles will form the rectangle with sides 3 and 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
template <typename... Args>
void dbg(Args... args) {
  ((cout << args << " "), ...);
  cout << endl;
}
long long a, b;
long long solve(long long n) {
  long long nm = a + b;
  vector<pair<pair<long long, long long>, int>> posall;
  for (long long i = 1; i * i <= nm; i++)
    if (nm % i == 0) posall.push_back({{i, nm / i}, 1});
  for (long long i = 1; i * i <= n; i++)
    if (n % i == 0)
      posall.push_back({{i, n / i}, 0}), posall.push_back({{n / i, i}, 0});
  sort(posall.begin(), posall.end());
  long long last = 9123456789123456789;
  long long ret = 9123456789123456789;
  for (auto [x, y] : posall) {
    if (y) {
      if (last <= x.second) ret = min(ret, 2 * (x.first + x.second));
    } else
      last = x.second;
  }
  return ret;
}
int main() {
  use_cio();
  cin >> a >> b;
  cout << min(solve(a), solve(b));
}

```


### Prompt

Develop a solution in cpp to the problem described below:

— Thanks a lot for today.

— I experienced so many great things.

— You gave me memories like dreams... But I have to leave now...

— One last request, can you...

— Help me solve a Codeforces problem?

— ......

— What?

Chtholly has been thinking about a problem for days:

If a number is palindrome and length of its decimal representation without leading zeros is even, we call it a zcy number. A number is palindrome means when written in decimal representation, it contains no leading zeros and reads the same forwards and backwards. For example 12321 and 1221 are palindromes and 123 and 12451 are not. Moreover, 1221 is zcy number and 12321 is not.

Given integers k and p, calculate the sum of the k smallest zcy numbers and output this sum modulo p.

Unfortunately, Willem isn't good at solving this kind of problems, so he asks you for help!

Input

The first line contains two integers k and p (1 ≤ k ≤ 105, 1 ≤ p ≤ 109).

Output

Output single integer — answer to the problem.

Examples

Input

2 100

Output

33

Input

5 30

Output

15

Note

In the first example, the smallest zcy number is 11, and the second smallest zcy number is 22.

In the second example, <image>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int K, P;
long long A[10];
long long B[10];
long long R[100000];
int c = 0;
long long res = 0;
void solve(int n, int d) {
  if (c >= K) return;
  if (n == d / 2) {
    for (int i = 0; i < n; i++) {
      res += A[i] * B[i];
      res %= P;
      res += A[i] * B[d - i - 1];
      res %= P;
    }
    if (c < 100000) R[c] = res;
    c++;
  } else {
    for (int i = 0; i < 10; i++) {
      if (i == 0 && n == 0) continue;
      A[n] = i;
      solve(n + 1, d);
    }
  }
}
int main() {
  cin >> K >> P;
  long long res = 0;
  B[0] = 1;
  for (int i = 1; i < 10; i++) {
    B[i] = 10 * B[i - 1];
    B[i] = B[i] % P;
  }
  for (int i = 1; i <= 6; i++) solve(0, 2 * i);
  cout << R[K - 1] << endl;
  return 0;
}

```


### Prompt

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

At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite sequence of Picks.

Fortunately, Picks remembers how to repair the sequence. Initially he should create an integer array a[1], a[2], ..., a[n]. Then he should perform a sequence of m operations. An operation can be one of the following:

  1. Print operation l, r. Picks should write down the value of <image>.
  2. Modulo operation l, r, x. Picks should perform assignment a[i] = a[i] mod x for each i (l ≤ i ≤ r).
  3. Set operation k, x. Picks should set the value of a[k] to x (in other words perform an assignment a[k] = x).

Can you help Picks to perform the whole sequence of operations?

Input

The first line of input contains two integer: n, m (1 ≤ n, m ≤ 105). The second line contains n integers, separated by space: a[1], a[2], ..., a[n] (1 ≤ a[i] ≤ 109) — initial value of array elements.

Each of the next m lines begins with a number type <image>.

  * If type = 1, there will be two integers more in the line: l, r (1 ≤ l ≤ r ≤ n), which correspond the operation 1.
  * If type = 2, there will be three integers more in the line: l, r, x (1 ≤ l ≤ r ≤ n; 1 ≤ x ≤ 109), which correspond the operation 2.
  * If type = 3, there will be two integers more in the line: k, x (1 ≤ k ≤ n; 1 ≤ x ≤ 109), which correspond the operation 3.

Output

For each operation 1, please print a line containing the answer. Notice that the answer may exceed the 32-bit integer.

Examples

Input

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

Output

8
5

Input

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

Output

49
15
23
1
9

Note

Consider the first testcase:

  * At first, a = {1, 2, 3, 4, 5}.
  * After operation 1, a = {1, 2, 3, 0, 1}.
  * After operation 2, a = {1, 2, 5, 0, 1}.
  * At operation 3, 2 + 5 + 0 + 1 = 8.
  * After operation 4, a = {1, 2, 2, 0, 1}.
  * At operation 5, 1 + 2 + 2 = 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Lt {
  int x;
  long long s;
} Q[400000 + 3];
int n, m, Now, Lx, Rx;
void Edit(int w, int l, int r, int x) {
  if (l == r) {
    Q[w].x = Q[w].s = Now;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    Edit(w << 1, l, mid, x);
  else
    Edit(w << 1 | 1, mid + 1, r, x);
  Q[w].x = max(Q[w << 1].x, Q[w << 1 | 1].x);
  Q[w].s = Q[w << 1].s + Q[w << 1 | 1].s;
}
long long Get(int w, int l, int r) {
  if (r < Lx || l > Rx) return 0;
  if (Lx <= l && r <= Rx) return Q[w].s;
  int mid = (l + r) >> 1;
  return Get(w << 1, l, mid) + Get(w << 1 | 1, mid + 1, r);
}
void Mod(int w, int l, int r) {
  if (r < Lx || l > Rx) return;
  if (Q[w].x < Now) return;
  if (l == r) {
    Q[w].x %= Now, Q[w].s = Q[w].x;
    return;
  }
  int mid = (l + r) >> 1;
  Mod(w << 1, l, mid);
  Mod(w << 1 | 1, mid + 1, r);
  Q[w].x = max(Q[w << 1].x, Q[w << 1 | 1].x);
  Q[w].s = Q[w << 1].s + Q[w << 1 | 1].s;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &Now), Edit(1, 1, n, i);
  }
  for (int i = 1; i <= m; i++) {
    int ty;
    scanf("%d", &ty);
    if (ty == 1) {
      scanf("%d%d", &Lx, &Rx);
      printf("%I64d\n", Get(1, 1, n));
    }
    if (ty == 2) {
      scanf("%d%d%d", &Lx, &Rx, &Now);
      Mod(1, 1, n);
    }
    if (ty == 3) {
      int x;
      scanf("%d%d", &x, &Now);
      Edit(1, 1, n, x);
    }
  }
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

In the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.

In Taknese, the plural form of a noun is spelled based on the following rules:

* If a noun's singular form does not end with `s`, append `s` to the end of the singular form.
* If a noun's singular form ends with `s`, append `es` to the end of the singular form.

You are given the singular form S of a Taknese noun. Output its plural form.

Constraints

* S is a string of length 1 between 1000, inclusive.
* S contains only lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

Print the plural form of the given Taknese word.

Examples

Input

apple

Output

apples

Input

bus

Output

buses

Input

box

Output

boxs

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin>>s;
	int n=s.size();
	cout<<s;
	if(s[n-1]=='s')cout<<"es";
	else cout<<'s';
	return 0;
}
```


### Prompt

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

International Women's Day is coming soon! Polycarp is preparing for the holiday.

There are n candy boxes in the shop for sale. The i-th box contains d_i candies.

Polycarp wants to prepare the maximum number of gifts for k girls. Each gift will consist of exactly two boxes. The girls should be able to share each gift equally, so the total amount of candies in a gift (in a pair of boxes) should be divisible by k. In other words, two boxes i and j (i ≠ j) can be combined as a gift if d_i + d_j is divisible by k.

How many boxes will Polycarp be able to give? Of course, each box can be a part of no more than one gift. Polycarp cannot use boxes "partially" or redistribute candies between them.

Input

The first line of the input contains two integers n and k (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ k ≤ 100) — the number the boxes and the number the girls.

The second line of the input contains n integers d_1, d_2, ..., d_n (1 ≤ d_i ≤ 10^9), where d_i is the number of candies in the i-th box.

Output

Print one integer — the maximum number of the boxes Polycarp can give as gifts.

Examples

Input

7 2
1 2 2 3 2 4 10

Output

6

Input

8 2
1 2 2 3 2 4 6 10

Output

8

Input

7 3
1 2 2 3 2 4 5

Output

4

Note

In the first example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):

  * (2, 3);
  * (5, 6);
  * (1, 4).

So the answer is 6.

In the second example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):

  * (6, 8);
  * (2, 3);
  * (1, 4);
  * (5, 7).

So the answer is 8.

In the third example Polycarp can give the following pairs of boxes (pairs are presented by indices of corresponding boxes):

  * (1, 2);
  * (6, 7).

So the answer is 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const long long mod = 1e9 + 7;
long long cnt[101];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    cnt[x % k]++;
  }
  if (k == 1) {
    return cout << (n / 2) * 2, 0;
  }
  long long tot1 = (cnt[0] / 2) * 2, tot = 0;
  if (k & 1) {
    for (long long kk = 1; kk <= k / 2; kk++) {
      tot += min(cnt[kk], cnt[k - kk]);
    }
  } else {
    for (long long kk = 1; kk < k / 2; kk++) {
      tot += min(cnt[kk], cnt[k - kk]);
    }
    tot += (cnt[k / 2] / 2);
  }
  cout << tot1 + 2 * tot;
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Okabe likes to be able to walk through his city on a path lit by street lamps. That way, he doesn't get beaten up by schoolchildren.

Okabe's city is represented by a 2D grid of cells. Rows are numbered from 1 to n from top to bottom, and columns are numbered 1 to m from left to right. Exactly k cells in the city are lit by a street lamp. It's guaranteed that the top-left cell is lit.

Okabe starts his walk from the top-left cell, and wants to reach the bottom-right cell. Of course, Okabe will only walk on lit cells, and he can only move to adjacent cells in the up, down, left, and right directions. However, Okabe can also temporarily light all the cells in any single row or column at a time if he pays 1 coin, allowing him to walk through some cells not lit initially.

Note that Okabe can only light a single row or column at a time, and has to pay a coin every time he lights a new row or column. To change the row or column that is temporarily lit, he must stand at a cell that is lit initially. Also, once he removes his temporary light from a row or column, all cells in that row/column not initially lit are now not lit.

Help Okabe find the minimum number of coins he needs to pay to complete his walk!

Input

The first line of input contains three space-separated integers n, m, and k (2 ≤ n, m, k ≤ 104).

Each of the next k lines contains two space-separated integers ri and ci (1 ≤ ri ≤ n, 1 ≤ ci ≤ m) — the row and the column of the i-th lit cell.

It is guaranteed that all k lit cells are distinct. It is guaranteed that the top-left cell is lit.

Output

Print the minimum number of coins Okabe needs to pay to complete his walk, or -1 if it's not possible.

Examples

Input

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

Output

2

Input

5 5 4
1 1
2 1
3 1
3 2

Output

-1

Input

2 2 4
1 1
1 2
2 1
2 2

Output

0

Input

5 5 4
1 1
2 2
3 3
4 4

Output

3

Note

In the first sample test, Okabe can take the path <image>, paying only when moving to (2, 3) and (4, 4).

In the fourth sample, Okabe can take the path <image> <image>, paying when moving to (1, 2), (3, 4), and (5, 4).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T1, class T2>
inline void print(T1 x1, T2 x2) {
  printsp(x1), println(x2);
}
template <class T1, class T2, class T3>
inline void print(T1 x1, T2 x2, T3 x3) {
  printsp(x1), printsp(x2), println(x3);
}
template <class T1, class T2, class T3, class T4>
inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {
  printsp(x1), printsp(x2), printsp(x3), println(x4);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int r[20111], c[20111];
int dst[20111];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    pq;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int u;
  for (int i = 1; i <= k; i++) {
    gn(r[i], c[i]);
    if (r[i] == 1 and c[i] == 1) u = i;
  }
  memset(dst, 0x3f, sizeof dst);
  dst[u] = 0;
  pq.push(pair<int, int>(dst[u], u));
  while (!pq.empty()) {
    int v = pq.top().second;
    if (pq.top().first > dst[v]) {
      pq.pop();
      continue;
    }
    pq.pop();
    for (int i = 1; i <= k; i++) {
      int s = 1;
      if (abs(r[i] - r[v]) > 2 and abs(c[i] - c[v]) > 2) continue;
      if (r[i] == r[v] and abs(c[i] - c[v]) == 1) s = 0;
      if (c[i] == c[v] and abs(r[i] - r[v]) == 1) s = 0;
      if (dst[i] > dst[v] + s) {
        pq.push(pair<int, int>(dst[i] = dst[v] + s, i));
      }
    }
  }
  int ans = 0x3f3f3f3f;
  for (int i = 1; i <= k; i++) {
    if (r[i] == n and c[i] == m) smin(ans, dst[i]);
    if (r[i] >= n - 1) smin(ans, dst[i] + 1);
    if (c[i] >= m - 1) smin(ans, dst[i] + 1);
  }
  if (ans == 0x3f3f3f3f)
    puts("-1");
  else
    cout << ans << endl;
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

Takahashi loves takoyaki - a ball-shaped snack.

With a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.

How long does it take to make N takoyaki?

Constraints

* 1 \leq N,X,T \leq 1000
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N X T

Output

Print an integer representing the minimum number of minutes needed to make N pieces of takoyaki.

Examples

Input

20 12 6

Output

12

Input

1000 1 1000

Output

1000000

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main() {
	int X,N,T;
	cin>>N>>X>>T;
	int C = ((N+X-1)/X)*T;
	cout<<C<<endl;
}
```


### Prompt

Generate a cpp solution to the following problem:

Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as pi. We'll call number n the size or the length of permutation p1, p2, ..., pn.

Petya decided to introduce the sum operation on the set of permutations of length n. Let's assume that we are given two permutations of length n: a1, a2, ..., an and b1, b2, ..., bn. Petya calls the sum of permutations a and b such permutation c of length n, where ci = ((ai - 1 + bi - 1) mod n) + 1 (1 ≤ i ≤ n).

Operation <image> means taking the remainder after dividing number x by number y.

Obviously, not for all permutations a and b exists permutation c that is sum of a and b. That's why Petya got sad and asked you to do the following: given n, count the number of such pairs of permutations a and b of length n, that exists permutation c that is sum of a and b. The pair of permutations x, y (x ≠ y) and the pair of permutations y, x are considered distinct pairs.

As the answer can be rather large, print the remainder after dividing it by 1000000007 (109 + 7).

Input

The single line contains integer n (1 ≤ n ≤ 16).

Output

In the single line print a single non-negative integer — the number of such pairs of permutations a and b, that exists permutation c that is sum of a and b, modulo 1000000007 (109 + 7).

Examples

Input

3

Output

18

Input

5

Output

1800

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 200005;
const double eps = 1e-7;
const double DINF = 1e100;
const int INF = 1000000006;
const long long LINF = 1000000000000000005ll;
const int MOD = 1000000007;
int n;
int A[17] = {0, 1,         0, 18,        0, 1800,      0, 670320,
             0, 734832000, 0, 890786230, 0, 695720788, 0, 150347555};
int main() {
  cin >> n;
  cout << A[n] << endl;
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

A tennis tournament with n participants is running. The participants are playing by an olympic system, so the winners move on and the losers drop out.

The tournament takes place in the following way (below, m is the number of the participants of the current round):

  * let k be the maximal power of the number 2 such that k ≤ m,
  * k participants compete in the current round and a half of them passes to the next round, the other m - k participants pass to the next round directly,
  * when only one participant remains, the tournament finishes.

Each match requires b bottles of water for each participant and one bottle for the judge. Besides p towels are given to each participant for the whole tournament.

Find the number of bottles and towels needed for the tournament.

Note that it's a tennis tournament so in each match two participants compete (one of them will win and the other will lose).

Input

The only line contains three integers n, b, p (1 ≤ n, b, p ≤ 500) — the number of participants and the parameters described in the problem statement.

Output

Print two integers x and y — the number of bottles and towels need for the tournament.

Examples

Input

5 2 3

Output

20 15

Input

8 2 4

Output

35 32

Note

In the first example will be three rounds:

  1. in the first round will be two matches and for each match 5 bottles of water are needed (two for each of the participants and one for the judge),
  2. in the second round will be only one match, so we need another 5 bottles of water,
  3. in the third round will also be only one match, so we need another 5 bottles of water.

So in total we need 20 bottles of water.

In the second example no participant will move on to some round directly.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b, p;
  cin >> n >> b >> p;
  int x = n;
  int sol = 0;
  while (x != 1) {
    int d = 1;
    while (d * 2 < x) d *= 2;
    sol += 2 * d * b + d;
    x -= d;
  }
  printf("%i %i\n", sol, p * n);
  return 0;
}

```


### Prompt

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

Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) to be played in the event.

Takahashi knows that Person i's j-th favorite sport is Sport A_{ij}. Each person will only participate in his/her most favorite sport among the ones that are actually played in the event, and will not participate in the other sports.

Takahashi is worried that one of the sports will attract too many people. Therefore, he would like to carefully select sports to be played so that the number of the participants in the sport with the largest number of participants is minimized. Find the minimum possible number of the participants in the sport with the largest number of participants.

Constraints

* 1 \leq N \leq 300
* 1 \leq M \leq 300
* A_{i1} , A_{i2} , ... , A_{iM} is a permutation of the integers from 1 to M.

Input

Input is given from Standard Input in the following format:

N M
A_{11} A_{12} ... A_{1M}
A_{21} A_{22} ... A_{2M}
:
A_{N1} A_{N2} ... A_{NM}

Output

Print the minimum possible number of the participants in the sport with the largest number of participants.

Examples

Input

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

Output

2

Input

3 3
2 1 3
2 1 3
2 1 3

Output

3

### Response

```cpp
#include<cstdio>
#include<cstring>
using namespace std;
int l,r,mid,sum=0,ok,graph[305][305],i,j,n,m,ch[305],vis[305],tt;
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)scanf("%d",&graph[i][j]);
	l=1;r=n;
	while(l<r)
	{
		mid=(l+r)/2;
		memset(vis,0,sizeof(vis));
		for(i=1;i<=n;i++)ch[i]=1;
		ok=tt=0;
		while(!ok&&!tt)
		{
			ok=tt=1;
			for(i=1;i<=m;i++)
			{
				if(vis[i])continue;
				sum=tt=0;
				for(j=1;j<=n;j++)if(graph[j][ch[j]]==i)sum++;
				if(sum>mid)
				{
					vis[i]=1;ok=0;
					for(j=1;j<=n;j++)while(vis[graph[j][ch[j]]])ch[j]++;
				}
			}
		}
		if(tt)l=mid+1;
		else r=mid;
	}
	printf("%d",l);
	return 0;
}
```


### Prompt

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

Pig is visiting a friend.

Pig's house is located at point 0, and his friend's house is located at point m on an axis.

Pig can use teleports to move along the axis.

To use a teleport, Pig should come to a certain point (where the teleport is located) and choose where to move: for each teleport there is the rightmost point it can move Pig to, this point is known as the limit of the teleport.

Formally, a teleport located at point x with limit y can move Pig from point x to any point within the segment [x; y], including the bounds.

<image>

Determine if Pig can visit the friend using teleports only, or he should use his car.

Input

The first line contains two integers n and m (1 ≤ n ≤ 100, 1 ≤ m ≤ 100) — the number of teleports and the location of the friend's house.

The next n lines contain information about teleports.

The i-th of these lines contains two integers ai and bi (0 ≤ ai ≤ bi ≤ m), where ai is the location of the i-th teleport, and bi is its limit.

It is guaranteed that ai ≥ ai - 1 for every i (2 ≤ i ≤ n).

Output

Print "YES" if there is a path from Pig's house to his friend's house that uses only teleports, and "NO" otherwise.

You can print each letter in arbitrary case (upper or lower).

Examples

Input

3 5
0 2
2 4
3 5

Output

YES

Input

3 7
0 4
2 5
6 7

Output

NO

Note

The first example is shown on the picture below:

<image>

Pig can use the first teleport from his house (point 0) to reach point 2, then using the second teleport go from point 2 to point 3, then using the third teleport go from point 3 to point 5, where his friend lives.

The second example is shown on the picture below:

<image>

You can see that there is no path from Pig's house to his friend's house that uses only teleports.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int M = 1e9 + 7;
long long a[N];
long long b[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  if (a[0] != 0) return cout << "NO", 0;
  for (int i = 1; i < n; i++) {
    if (a[i] > b[i - 1]) return cout << "NO", 0;
    b[i] = max(b[i - 1], b[i]);
  }
  if (b[n - 1] != m) return cout << "NO", 0;
  cout << "YES";
}

```


### Prompt

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

Two participants are each given a pair of distinct numbers from 1 to 9 such that there's exactly one number that is present in both pairs. They want to figure out the number that matches by using a communication channel you have access to without revealing it to you.

Both participants communicated to each other a set of pairs of numbers, that includes the pair given to them. Each pair in the communicated sets comprises two different numbers.

Determine if you can with certainty deduce the common number, or if you can determine with certainty that both participants know the number but you do not.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 12) — the number of pairs the first participant communicated to the second and vice versa.

The second line contains n pairs of integers, each between 1 and 9, — pairs of numbers communicated from first participant to the second.

The third line contains m pairs of integers, each between 1 and 9, — pairs of numbers communicated from the second participant to the first.

All pairs within each set are distinct (in particular, if there is a pair (1,2), there will be no pair (2,1) within the same set), and no pair contains the same number twice.

It is guaranteed that the two sets do not contradict the statements, in other words, there is pair from the first set and a pair from the second set that share exactly one number.

Output

If you can deduce the shared number with certainty, print that number.

If you can with certainty deduce that both participants know the shared number, but you do not know it, print 0.

Otherwise print -1.

Examples

Input

2 2
1 2 3 4
1 5 3 4

Output

1

Input

2 2
1 2 3 4
1 5 6 4

Output

0

Input

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

Output

-1

Note

In the first example the first participant communicated pairs (1,2) and (3,4), and the second communicated (1,5), (3,4). Since we know that the actual pairs they received share exactly one number, it can't be that they both have (3,4). Thus, the first participant has (1,2) and the second has (1,5), and at this point you already know the shared number is 1.

In the second example either the first participant has (1,2) and the second has (1,5), or the first has (3,4) and the second has (6,4). In the first case both of them know the shared number is 1, in the second case both of them know the shared number is 4. You don't have enough information to tell 1 and 4 apart.

In the third case if the first participant was given (1,2), they don't know what the shared number is, since from their perspective the second participant might have been given either (1,3), in which case the shared number is 1, or (2,3), in which case the shared number is 2. While the second participant does know the number with certainty, neither you nor the first participant do, so the output is -1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, int> > np, mp;
int a, b;
bool check(int aa, int bb, vector<pair<int, int> >& op) {
  set<int> bbb;
  for (int i = 0; i < op.size(); i++) {
    pair<int, int> vv = op[i];
    if (vv.first == aa && vv.second == bb) {
      continue;
    }
    if (vv.first == aa || vv.second == bb || vv.first == bb ||
        vv.second == aa) {
      if (vv.first == aa || vv.second == aa) {
        bbb.insert(aa);
      } else {
        bbb.insert(bb);
      }
    }
  }
  if (bbb.size() == 1) {
    return true;
  } else if (bbb.size() == 0) {
    return false;
  }
  puts("-1");
  exit(0);
  return false;
}
int main() {
  set<int> ans;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    np.push_back({a, b});
  }
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    if (a > b) swap(a, b);
    mp.push_back({a, b});
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (np[i].first == mp[j].first && np[i].second == mp[j].second) {
        continue;
      }
      if (check(np[i].first, np[i].second, mp) &&
          check(mp[j].first, mp[j].second, np))
        if (np[i].first == mp[j].first || np[i].second == mp[j].second ||
            np[i].second == mp[j].first || np[i].first == mp[j].second) {
          if (np[i].first == mp[j].first || np[i].first == mp[j].second) {
            ans.insert(np[i].first);
          } else {
            ans.insert(np[i].second);
          }
        }
    }
  }
  if (ans.size() == 1) {
    printf("%d\n", *ans.begin());
  } else if (ans.size() > 0) {
    puts("0");
  } else {
    puts("-1");
  }
}

```


### Prompt

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

Vasya plays FreeDiv. In this game he manages a huge state, which has n cities and m two-way roads between them. Unfortunately, not from every city you can reach any other one moving along these roads. Therefore Vasya decided to divide the state into provinces so that in every province, one could reach from every city all the cities of the province, but there are no roads between provinces.

Unlike other turn-based strategies, in FreeDiv a player has the opportunity to build tunnels between cities. The tunnels are two-way roads along which one can move armies undetected by the enemy. However, no more than one tunnel can be connected to each city. As for Vasya, he wants to build a network of tunnels so that any pair of cities in his state were reachable by some path consisting of roads and a tunnels. But at that no more than k tunnels are connected to each province (otherwise, the province will be difficult to keep in case other provinces are captured by enemy armies).

Vasya discovered that maybe he will not be able to build such a network for the current condition of the state. Maybe he'll have first to build several roads between cities in different provinces to merge the provinces. Your task is to determine the minimum number of roads Vasya needs to build so that it was possible to build the required network of tunnels in the resulting state.

Input

The first line contains three integers n, m and k (1 ≤ n, k ≤ 106, 0 ≤ m ≤ 106). Each of the next m lines contains two integers. They are the numbers of cities connected by a corresponding road. No road connects city to itself and there is at most one road between each pair of cities.

Output

Print a single number, the minimum number of additional roads.

Examples

Input

3 3 2
1 2
2 3
3 1

Output

0

Input

4 2 2
1 2
3 4

Output

0

Input

4 0 2

Output

1

Note

In the first example only one province exists, so it is not necessary to build any tunnels or roads.

In the second example two provinces exist. It is possible to merge the provinces by building a tunnel between cities 1 and 3.

In the third example at least one additional road is necessary. For example it is possible to build additional road between cities 1 and 2 and build two tunnels between cities 1 and 3, 2 and 4 after that.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e6;
vector<int> nb[MAXn];
int comp[MAXn], cc;
bool mark[MAXn];
void dfs(int v) {
  mark[v] = true;
  comp[cc]++;
  for (int i = 0; i < (int)nb[v].size(); i++)
    if (!mark[nb[v][i]]) dfs(nb[v][i]);
}
int main() {
  ios::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    v1--;
    v2--;
    nb[v1].push_back(v2);
    nb[v2].push_back(v1);
  }
  int c1 = 0, c2 = 0;
  for (int i = 0; i < n; i++)
    if (!mark[i]) {
      dfs(i);
      comp[cc] = min(comp[cc], k);
      if (comp[cc] == 1)
        c1++;
      else
        c2 += comp[cc] - 2;
      cc++;
    }
  if (c1 - 2 <= c2)
    cout << 0 << endl;
  else if (k == 1)
    cout << max(0, c1 - 2) << endl;
  else
    cout << (c1 - 2 - c2 + 1) / 2 << endl;
  return 0;
}

```


### Prompt

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

BerOilGasDiamondBank has branches in n cities, at that n is an even number. The bank management wants to publish a calendar with the names of all those cities written in two columns: the calendar should consist of exactly n / 2 lines of strictly equal length, each of which contains exactly two names and exactly one separator character between them. The name of every city should be used in the calendar exactly once. For historical reasons the symbol d is used as the separator of words in the calendar.

The BerOilGasDiamondBank management wants to show that all its branches are equally important to it, that's why the order of their appearance in the calendar should be following: if we "glue"(concatinate) all the n / 2 calendar lines (from top to bottom) to make a single line, then the lexicographically minimal line is obtained. No separator character will be used to separate calendar lines. For example, if the lines are "bertown!berville", "newberville!bera", then the resulting line is "bertown!bervillenewberville!bera". In some sense one has to find the lexicographically minimal calendar, where the comparison of calendars happens line by line.

Help BerOilGasDiamondBank and construct the required calendar.

Input

The first line contains an integer n (1 ≤ n ≤ 104, n is even) which is the number of branches. Then follow n lines which are the names of the cities. All the names consist of lowercase Latin letters; their lengths are no less than 1 and no more than 10 symbols. The next line contains a single symbol d (d has an ASCII-code from 33 to 126 inclusively, excluding lowercase Latin letters) which is the separator between words in the calendar lines. It is guaranteed that the calendar is possible to be constructed and all the names are different.

Output

Print n / 2 lines of similar length which are the required calendar. Every line should contain exactly two words and exactly one separator between them. If there are several solutions, print the lexicographically minimal one. The lexicographical comparison of lines is realized by the "<" operator in the modern programming languages.

Examples

Input

4
b
aa
hg
c
.

Output

aa.b
c.hg

Input

2
aa
a
!

Output

a!aa

Input

2
aa
a
|

Output

aa|a

### Response

```cpp
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int n, fixxed = 0;
vector<string> dict;
char d;
bool comp(string x1, string x2) {
  if (x1.length() != x2.length()) {
    for (int i = 0; i < (int)(min(x1.length(), x2.length())); i++)
      if (x1[i] < x2[i])
        return true;
      else if (x1[i] > x2[i])
        return false;
      else if (x1[i] == x2[i] && i == min(x1.length(), x2.length()) - 1)
        return (x1.length() > x2.length());
  } else
    return (x1 < x2);
}
int main() {
  cin >> n;
  dict.resize(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> dict[i];
    fixxed += dict[i].length();
  }
  fixxed /= n / 2;
  cin >> d;
  if (d <= 'z')
    sort(dict.begin(), dict.end());
  else
    sort(dict.begin(), dict.end(), comp);
  for (int i = 0; i < n / 2; i++) {
    cout << dict[i] << d;
    for (int j = i + 1; j < dict.size(); j++)
      if (dict[i].length() + dict[j].length() == fixxed) {
        cout << dict[j] << endl;
        dict.erase(dict.begin() + j);
        break;
      }
  }
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Tenten runs a weapon shop for ninjas. Today she is willing to sell n shurikens which cost 1, 2, ..., n ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the beginning of the day. Her job is fairly simple: sometimes Tenten places another shuriken (from the available shurikens) on the showcase, and sometimes a ninja comes in and buys a shuriken from the showcase. Since ninjas are thrifty, they always buy the cheapest shuriken from the showcase.

Tenten keeps a record for all events, and she ends up with a list of the following types of records:

  * + means that she placed another shuriken on the showcase;
  * - x means that the shuriken of price x was bought.

Today was a lucky day, and all shurikens were bought. Now Tenten wonders if her list is consistent, and what could be a possible order of placing the shurikens on the showcase. Help her to find this out!

Input

The first line contains the only integer n (1≤ n≤ 10^5) standing for the number of shurikens.

The following 2n lines describe the events in the format described above. It's guaranteed that there are exactly n events of the first type, and each price from 1 to n occurs exactly once in the events of the second type.

Output

If the list is consistent, print "YES". Otherwise (that is, if the list is contradictory and there is no valid order of shurikens placement), print "NO".

In the first case the second line must contain n space-separated integers denoting the prices of shurikens in order they were placed. If there are multiple answers, print any.

Examples

Input

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

Output

YES
4 2 3 1

Input

1
- 1
+

Output

NO

Input

3
+
+
+
- 2
- 1
- 3

Output

NO

Note

In the first example Tenten first placed shurikens with prices 4 and 2. After this a customer came in and bought the cheapest shuriken which costed 2. Next, Tenten added a shuriken with price 3 on the showcase to the already placed 4-ryo. Then a new customer bought this 3-ryo shuriken. After this she added a 1-ryo shuriken. Finally, the last two customers bought shurikens 1 and 4, respectively. Note that the order [2, 4, 3, 1] is also valid.

In the second example the first customer bought a shuriken before anything was placed, which is clearly impossible.

In the third example Tenten put all her shurikens onto the showcase, after which a customer came in and bought a shuriken with price 2. This is impossible since the shuriken was not the cheapest, we know that the 1-ryo shuriken was also there.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void __print(long long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const long double pi = acos(-1.0);
long long int inf = 0x3f3f3f3f3f3f3f3f;
const long long int mod = 1e9 + 7;
const long long int mx = 5 * 1000000;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int ii = 0;
  long long int ans[n];
  bool posible = 1;
  stack<long long int> index;
  vector<char> order;
  vector<long long int> val;
  for (long long int i = 0; i < 2 * n; i++) {
    char in;
    cin >> in;
    order.push_back(in);
    if (in == '-') {
      long long int value;
      cin >> value;
      val.push_back(value);
      if (index.size() > 0) {
        long long int jj = index.top();
        index.pop();
        ans[jj] = value;
      } else {
        posible = false;
      }
    } else {
      index.push(ii++);
    }
  }
  long long int cur = 0;
  long long int val_cur = 0;
  set<long long int> taken;
  ;
  for (auto i : order) {
    if (i == '+') {
      taken.insert(ans[cur]);
      cur++;
    } else {
      long long int cur_val = val[val_cur++];
      if (taken.find(cur_val) == taken.end()) {
        posible = false;
        break;
      }
      auto lower = taken.lower_bound(cur_val);
      if (lower != taken.begin()) {
        posible = false;
        break;
      }
      taken.erase(cur_val);
    }
  };
  if (posible) {
    cout << "YES\n";
    for (long long int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
  } else
    cout << "NO\n";
}

```


### Prompt

Generate a Cpp solution to the following problem:

Let's call a positive integer composite if it has at least one divisor other than 1 and itself. For example:

  * the following numbers are composite: 1024, 4, 6, 9;
  * the following numbers are not composite: 13, 1, 2, 3, 37.

You are given a positive integer n. Find two composite integers a,b such that a-b=n.

It can be proven that solution always exists.

Input

The input contains one integer n (1 ≤ n ≤ 10^7): the given integer.

Output

Print two composite integers a,b (2 ≤ a, b ≤ 10^9, a-b=n).

It can be proven, that solution always exists.

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

Examples

Input

1

Output

9 8

Input

512

Output

4608 4096

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool a[10000001];
int main() {
  long long int n = 10000000;
  for (int i = 0; i <= n; ++i) {
    a[i] = false;
  }
  for (long long int i = 3; i <= n; i = i + 2) {
    if (a[i] == false) {
      for (long long int j = i * i; j <= n; j = j + (2 * i)) {
        a[j] = true;
      }
    }
  }
  a[0] = true;
  a[1] = true;
  a[2] = false;
  long long int o;
  cin >> o;
  if (o % 2 == 0) {
    if (o == 2) {
      cout << 6 << " " << 4 << endl;
      return 0;
    }
    cout << o * 2 << " " << o << endl;
    return 0;
  } else {
    if (o == 1) {
      cout << 9 << " " << 8 << endl;
      return 0;
    }
    if (a[o] == true) {
      cout << o * 2 << " " << o << endl;
      return 0;
    } else {
      for (int i = o; i <= n; i = i + 2) {
        if (a[i] == true) {
          cout << (o * 2) + (i - o) << " " << i << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}

```


### Prompt

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

Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees.

The game is played on a tree having n nodes, numbered from 1 to n. Each node i has an initial value initi, which is either 0 or 1. The root of the tree is node 1.

One can perform several (possibly, zero) operations on the tree during the game. The only available type of operation is to pick a node x. Right after someone has picked node x, the value of node x flips, the values of sons of x remain the same, the values of sons of sons of x flips, the values of sons of sons of sons of x remain the same and so on.

The goal of the game is to get each node i to have value goali, which can also be only 0 or 1. You need to reach the goal of the game by using minimum number of operations.

Input

The first line contains an integer n (1 ≤ n ≤ 105). Each of the next n - 1 lines contains two integers ui and vi (1 ≤ ui, vi ≤ n; ui ≠ vi) meaning there is an edge between nodes ui and vi.

The next line contains n integer numbers, the i-th of them corresponds to initi (initi is either 0 or 1). The following line also contains n integer numbers, the i-th number corresponds to goali (goali is either 0 or 1).

Output

In the first line output an integer number cnt, representing the minimal number of operations you perform. Each of the next cnt lines should contain an integer xi, representing that you pick a node xi.

Examples

Input

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

Output

2
4
7

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> ans, E[120000];
int aim[120000], a[120000], x, n, i, y;
void dfs(int x, int v0, int v1, int ff) {
  if (a[x] ^ v0 != aim[x]) {
    v0 ^= 1;
    ans.push_back(x);
  }
  for (int i = 0; i < E[x].size(); ++i)
    if (E[x][i] != ff) {
      dfs(E[x][i], v1, v0, x);
    }
}
int main() {
  scanf("%d", &n);
  for (i = 1; i < n; ++i) {
    scanf("%d%d", &x, &y);
    E[x].push_back(y);
    E[y].push_back(x);
  }
  for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (i = 1; i <= n; ++i) scanf("%d", &aim[i]);
  dfs(1, 0, 0, 0);
  printf("%d\n", ans.size());
  for (i = 0; i < ans.size(); ++i) printf("%d\n", ans[i]);
}

```


### Prompt

Please formulate a CPP solution to the following problem:

You are given a string $S$, which is balanced parentheses with a star symbol '*' inserted.

Any balanced parentheses can be constructed using the following rules:

* An empty string is balanced.
* Concatenation of two balanced parentheses is balanced.
* If $T$ is balanced parentheses, concatenation of '(', $T$, and ')' in this order is balanced.

For example, '()()' and '(()())' are balanced parentheses. ')(' and ')()(()' are not balanced parentheses.

Your task is to count how many matching pairs of parentheses surround the star.

Let $S_i$be the $i$-th character of a string $S$. The pair of $S_l$ and $S_r$ ($l < r$) is called a matching pair of parentheses if $S_l$ is '(', $S_r$ is ')' and the surrounded string by them is balanced when ignoring a star symbol.

Input

The input consists of a single test case formatted as follows.

$S$

$S$ is balanced parentheses with exactly one '*' inserted somewhere. The length of $S$ is between 1 and 100, inclusive.

Output

Print the answer in one line.

Examples

Input

((*)())

Output

2

Input

(*)

Output

1

Input

(()())*

Output

0

Input

()*()

Output

0

Input

((((((((((*))))))))))

Output

10

Input

*

Output

0

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;

int main(){
  string s;
  cin>>s;
  stack<int> a;
  a.push(0);
  int b=1;
  for(int i=0;i<s.size();i++){
    if(s[i]=='('){a.push(b);b++;}
    else if(s[i]==')'){b=a.top();a.pop();}
    else {cout<<a.top()<<endl;return 0;}
  }
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Little boy Petya loves stairs very much. But he is bored from simple going up and down them — he loves jumping over several stairs at a time. As he stands on some stair, he can either jump to the next one or jump over one or two stairs at a time. But some stairs are too dirty and Petya doesn't want to step on them.

Now Petya is on the first stair of the staircase, consisting of n stairs. He also knows the numbers of the dirty stairs of this staircase. Help Petya find out if he can jump through the entire staircase and reach the last stair number n without touching a dirty stair once.

One has to note that anyway Petya should step on the first and last stairs, so if the first or the last stair is dirty, then Petya cannot choose a path with clean steps only.

Input

The first line contains two integers n and m (1 ≤ n ≤ 109, 0 ≤ m ≤ 3000) — the number of stairs in the staircase and the number of dirty stairs, correspondingly. The second line contains m different space-separated integers d1, d2, ..., dm (1 ≤ di ≤ n) — the numbers of the dirty stairs (in an arbitrary order).

Output

Print "YES" if Petya can reach stair number n, stepping only on the clean stairs. Otherwise print "NO".

Examples

Input

10 5
2 4 8 3 6

Output

NO

Input

10 5
2 4 5 7 9

Output

YES

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, d;
  cin >> n >> d;
  long long arr[d];
  for (long long i = 0; i < d; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + d);
  int poss = 1;
  if (arr[0] == 1 || arr[d - 1] == n)
    poss = 0;
  else {
    for (int i = 0, j = 1, k = 2; k < d; i++, j++, k++) {
      if (arr[j] == arr[i] + 1 && arr[k] == arr[i] + 2) {
        poss = 0;
      }
    }
  }
  if (poss)
    cout << "YES\n";
  else {
    cout << "NO\n";
  }
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Game "Minesweeper 1D" is played on a line of squares, the line's height is 1 square, the line's width is n squares. Some of the squares contain bombs. If a square doesn't contain a bomb, then it contains a number from 0 to 2 — the total number of bombs in adjacent squares.

For example, the correct field to play looks like that: 001*2***101*. The cells that are marked with "*" contain bombs. Note that on the correct field the numbers represent the number of bombs in adjacent cells. For example, field 2* is not correct, because cell with value 2 must have two adjacent cells with bombs.

Valera wants to make a correct field to play "Minesweeper 1D". He has already painted a squared field with width of n cells, put several bombs on the field and wrote numbers into some cells. Now he wonders how many ways to fill the remaining cells with bombs and numbers are there if we should get a correct field in the end.

Input

The first line contains sequence of characters without spaces s1s2... sn (1 ≤ n ≤ 106), containing only characters "*", "?" and digits "0", "1" or "2". If character si equals "*", then the i-th cell of the field contains a bomb. If character si equals "?", then Valera hasn't yet decided what to put in the i-th cell. Character si, that is equal to a digit, represents the digit written in the i-th square.

Output

Print a single integer — the number of ways Valera can fill the empty cells and get a correct field.

As the answer can be rather large, print it modulo 1000000007 (109 + 7).

Examples

Input

?01???

Output

4

Input

?

Output

2

Input

**12

Output

0

Input

1

Output

0

Note

In the first test sample you can get the following correct fields: 001**1, 001***, 001*2*, 001*10.

### Response

```cpp
#include <bits/stdc++.h>
const int MaxN = 1e6;
const int Pt = 1e9 + 7;
using namespace std;
char s[MaxN + 5];
long long f[MaxN + 5][5];
int main() {
  while (~scanf("%s", s + 1)) {
    int len = strlen(s + 1);
    memset(f, 0, sizeof(f));
    if (s[1] == '?') {
      f[1][0] = 1;
      f[1][1] = f[1][4] = 1;
      f[1][2] = f[1][3] = 0;
    } else if (s[1] == '0')
      f[1][0] = 1;
    else if (s[1] == '1')
      f[1][1] = 1;
    else if (s[1] == '2')
      f[1][2] = 0;
    else if (s[1] == '*')
      f[1][4] = 1;
    for (int i = 2; i <= len; i++) {
      if (s[i] == '?') {
        f[i][0] = (f[i - 1][0] + f[i - 1][3]) % Pt;
        f[i][1] = (f[i - 1][0] + f[i - 1][3]) % Pt;
        f[i][2] = (f[i - 1][4]) % Pt;
        f[i][3] = f[i - 1][4] % Pt;
        f[i][4] = (f[i - 1][4] + f[i - 1][1] + f[i - 1][2]) % Pt;
      } else if (s[i] == '1') {
        f[i][1] = (f[i - 1][0] + f[i - 1][3]) % Pt;
        f[i][3] = f[i - 1][4] % Pt;
      } else if (s[i] == '0')
        f[i][0] = (f[i - 1][0] + f[i - 1][3]) % Pt;
      else if (s[i] == '2')
        f[i][2] = (f[i - 1][4]) % Pt;
      else if (s[i] == '*')
        f[i][4] = (f[i - 1][4] + f[i - 1][1] + f[i - 1][2]) % Pt;
    }
    printf("%d\n", (f[len][0] + f[len][3] + f[len][4]) % Pt);
  }
}

```


### Prompt

Generate a Cpp solution to the following problem:

Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya calls a number almost lucky if it could be evenly divided by some lucky number. Help him find out if the given number n is almost lucky.

Input

The single line contains an integer n (1 ≤ n ≤ 1000) — the number that needs to be checked.

Output

In the only line print "YES" (without the quotes), if number n is almost lucky. Otherwise, print "NO" (without the quotes).

Examples

Input

47

Output

YES

Input

16

Output

YES

Input

78

Output

NO

Note

Note that all lucky numbers are almost lucky as any number is evenly divisible by itself.

In the first sample 47 is a lucky number. In the second sample 16 is divisible by 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n;
  bool ok;
  for (int i = 1; i <= n; i++) {
    if (n % i == 0) {
      x = i;
      ok = false;
      while (x > 0) {
        if (x % 10 == 4 || x % 10 == 7) {
          x /= 10;
          ok = true;
        } else {
          ok = false;
          break;
        }
      }
      if (ok == true) {
        cout << "YES";
        return 0;
      }
    }
  }
  cout << "NO";
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Bob is a competitive programmer. He wants to become red, and for that he needs a strict training regime. He went to the annual meeting of grandmasters and asked n of them how much effort they needed to reach red.

"Oh, I just spent x_i hours solving problems", said the i-th of them.

Bob wants to train his math skills, so for each answer he wrote down the number of minutes (60 ⋅ x_i), thanked the grandmasters and went home. Bob could write numbers with leading zeroes — for example, if some grandmaster answered that he had spent 2 hours, Bob could write 000120 instead of 120.

Alice wanted to tease Bob and so she took the numbers Bob wrote down, and for each of them she did one of the following independently:

  * rearranged its digits, or
  * wrote a random number.

This way, Alice generated n numbers, denoted y_1, ..., y_n.

For each of the numbers, help Bob determine whether y_i can be a permutation of a number divisible by 60 (possibly with leading zeroes).

Input

The first line contains a single integer n (1 ≤ n ≤ 418) — the number of grandmasters Bob asked.

Then n lines follow, the i-th of which contains a single integer y_i — the number that Alice wrote down.

Each of these numbers has between 2 and 100 digits '0' through '9'. They can contain leading zeroes.

Output

Output n lines.

For each i, output the following. If it is possible to rearrange the digits of y_i such that the resulting number is divisible by 60, output "red" (quotes for clarity). Otherwise, output "cyan".

Example

Input

6
603
006
205
228
1053
0000000000000000000000000000000000000000000000

Output

red
red
cyan
cyan
cyan
red

Note

In the first example, there is one rearrangement that yields a number divisible by 60, and that is 360.

In the second example, there are two solutions. One is 060 and the second is 600.

In the third example, there are 6 possible rearrangments: 025, 052, 205, 250, 502, 520. None of these numbers is divisible by 60.

In the fourth example, there are 3 rearrangements: 228, 282, 822.

In the fifth example, none of the 24 rearrangements result in a number divisible by 60.

In the sixth example, note that 000...0 is a valid solution.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int N, len, sum;
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    char s[105];
    scanf("%s", s);
    len = strlen(s);
    sum = 0;
    bool zero = false, nonzero = false;
    int even = 0;
    for (int j = 0; j < len; j++) {
      sum += s[j] - '0';
      if (s[j] - '0' == 0)
        zero = true;
      else
        nonzero = true;
      if ((s[j] - '0') % 2 == 0) even++;
    }
    if (sum % 3 == 0 && zero && even > 1 || !nonzero)
      puts("red");
    else
      puts("cyan");
  }
  return 0;
}

```


### Prompt

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

You are given two integers A and B as the input. Output the value of A + B.

However, if A + B is 10 or greater, output `error` instead.

Constraints

* A and B are integers.
* 1 ≤ A, B ≤ 9

Input

Input is given from Standard Input in the following format:

A B

Output

If A + B is 10 or greater, print the string `error` (case-sensitive); otherwise, print the value of A + B.

Examples

Input

6 3

Output

9

Input

6 4

Output

error

### Response

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

int main(){

    int a,b;
    cin>>a>>b;

    (a+b<10)?cout<<a+b<<endl:cout<<"error"<<endl;

    return 0;
}

```


### Prompt

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

There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least ai candies.

Jzzhu asks children to line up. Initially, the i-th child stands at the i-th place of the line. Then Jzzhu start distribution of the candies. He follows the algorithm:

  1. Give m candies to the first child of the line.
  2. If this child still haven't got enough candies, then the child goes to the end of the line, else the child go home.
  3. Repeat the first two steps while the line is not empty.

Consider all the children in the order they go home. Jzzhu wants to know, which child will be the last in this order?

Input

The first line contains two integers n, m (1 ≤ n ≤ 100; 1 ≤ m ≤ 100). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 100).

Output

Output a single integer, representing the number of the last child.

Examples

Input

5 2
1 3 1 4 2

Output

4

Input

6 4
1 1 2 2 3 3

Output

6

Note

Let's consider the first sample.

Firstly child 1 gets 2 candies and go home. Then child 2 gets 2 candies and go to the end of the line. Currently the line looks like [3, 4, 5, 2] (indices of the children in order of the line). Then child 3 gets 2 candies and go home, and then child 4 gets 2 candies and goes to the end of the line. Currently the line looks like [5, 2, 4]. Then child 5 gets 2 candies and goes home. Then child 2 gets two candies and goes home, and finally child 4 gets 2 candies and goes home.

Child 4 is the last one who goes home.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  std::ios::sync_with_stdio(false);
  int n, m, a[1000], i, j;
  cin >> n >> m;
  for (i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] % m == 0)
      a[i] = a[i] / m;
    else
      a[i] = a[i] / m + 1;
  }
  j = n - 1;
  for (i = n - 1; i >= 0; --i) {
    if (a[i] > a[j]) j = i;
  }
  cout << j + 1 << "\n";
  return 0;
}

```