### Prompt

Please create a solution in CPP to the following problem:

Problem

The popular video posting site "ZouTube" is now in the midst of an unprecedented "virtual ZouTuber" boom. Among them, the one that has been attracting particular attention recently is the junior virtual ZouTuber "Aizumarim (commonly known as Azurim)".

As a big fan of Azlim, you're going to send her a "special chat" on Azlim's live stream today.

"Special chat" is a "function that viewers give points to distributors" provided by ZouTube. Viewers can spend $ 500 $, $ 1000 $, $ 5000 $, or $ 10000 $ for each $ 1 special chat, and give the distributor the same amount of points as they spend.

Given the total amount of points you have now, spend those points to find the maximum total amount of points you can give to Azlim. You can have as many special chats as you like, as long as the amount of points you hold is not less than the amount of points you consume.

Constraints

The input satisfies the following conditions.

* $ 1 \ le P \ le 10 ^ 5 $

Input

The input is given in the following format.

$ P $

An integer $ P $ representing the total amount of points you have now is given in the $ 1 $ line.

Output

Output the maximum total amount of points that can be given to Azulim on the $ 1 $ line.

Examples

Input

5700

Output

5500

Input

1333

Output

1000

Input

100000

Output

100000

### Response

```cpp
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main(){

	int N;
	scanf("%d",&N);

	printf("%d\n",N-(N%500));

	return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Limak is a little bear who learns to draw. People usually start with houses, fences and flowers but why would bears do it? Limak lives in the forest and he decides to draw a tree.

Recall that tree is a connected graph consisting of n vertices and n - 1 edges.

Limak chose a tree with n vertices. He has infinite strip of paper with two parallel rows of dots. Little bear wants to assign vertices of a tree to some n distinct dots on a paper so that edges would intersect only at their endpoints — drawn tree must be planar. Below you can see one of correct drawings for the first sample test.

<image>

Is it possible for Limak to draw chosen tree?

Input

The first line contains single integer n (1 ≤ n ≤ 105).

Next n - 1 lines contain description of a tree. i-th of them contains two space-separated integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) denoting an edge between vertices ai and bi. It's guaranteed that given description forms a tree.

Output

Print "Yes" (without the quotes) if Limak can draw chosen tree. Otherwise, print "No" (without the quotes).

Examples

Input

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

Output

Yes

Input

13
1 2
1 3
1 4
2 5
2 6
2 7
3 8
3 9
3 10
4 11
4 12
4 13

Output

No

### Response

```cpp
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
struct edge {
  int v, next;
} e[200010];
int ecnt = 0, head[100010];
int n;
int d[100010];
int leg[100010];
void addedge(int a, int b) {
  e[++ecnt].v = b;
  e[ecnt].next = head[a];
  head[a] = ecnt;
}
void del(int x) {
  while (d[x] <= 2) {
    d[x] = 0;
    int xx = x;
    for (int i = head[x]; ~i; i = e[i].next) {
      if (d[e[i].v]) {
        x = e[i].v;
        break;
      }
    }
    if (x == xx) break;
  }
  leg[x]++;
}
bool solve() {
  for (int i = (1); i <= (n); i++) {
    if (d[i]) {
      int cnt = 0;
      for (int j = head[i]; ~j; j = e[j].next) {
        int v = e[j].v;
        if (d[v]) {
          if (leg[v] > 2)
            cnt++;
          else if (d[v] - leg[v] > 1)
            cnt++;
        }
      }
      if (cnt > 2) return false;
    }
  }
  return true;
}
int main() {
  cin >> n;
  memset((head), (-1), sizeof(head));
  memset((d), (0), sizeof(d));
  memset((leg), (0), sizeof(leg));
  for (int i = (1); i <= (n - 1); i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    addedge(u, v);
    addedge(v, u);
    d[u]++;
    d[v]++;
  }
  for (int i = (1); i <= (n); i++) {
    if (d[i] == 1) del(i);
  }
  puts(solve() ? "Yes" : "No");
  return 0;
}

```


### Prompt

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

You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it.

Can you make this graph [acyclic](https://en.wikipedia.org/wiki/Directed_acyclic_graph) by removing at most one edge from it? A directed graph is called acyclic iff it doesn't contain any cycle (a non-empty path that starts and ends in the same vertex).

Input

The first line contains two integers n and m (2 ≤ n ≤ 500, 1 ≤ m ≤ min(n(n - 1), 100000)) — the number of vertices and the number of edges, respectively.

Then m lines follow. Each line contains two integers u and v denoting a directed edge going from vertex u to vertex v (1 ≤ u, v ≤ n, u ≠ v). Each ordered pair (u, v) is listed at most once (there is at most one directed edge from u to v).

Output

If it is possible to make this graph acyclic by removing at most one edge, print YES. Otherwise, print NO.

Examples

Input

3 4
1 2
2 3
3 2
3 1

Output

YES

Input

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

Output

NO

Note

In the first example you can remove edge <image>, and the graph becomes acyclic.

In the second example you have to remove at least two edges (for example, <image> and <image>) in order to make the graph acyclic.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
const long long mod = (long long)1e9 + 7;
const double eps = (double)1e-9;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
const int N = 505;
bool found;
bool bad[N][N];
vector<pair<int, int> > e;
vector<int> g[N];
int n, m, u[N], pr[N];
bool get(int v) {
  u[v] = 1;
  for (auto to : g[v]) {
    if (!u[to]) {
      pr[to] = v;
      if (get(to)) return 1;
    } else if (u[to] == 1) {
      int u = v;
      e.push_back({v, to});
      while (u != to) {
        e.push_back({pr[u], u});
        u = pr[u];
      }
      return 1;
    }
  }
  u[v] = 2;
  return 0;
}
bool check(int v) {
  u[v] = 1;
  for (auto to : g[v]) {
    if (bad[v][to]) continue;
    if (!u[to] && !check(to))
      return 0;
    else if (u[to] == 1)
      return 0;
  }
  u[v] = 2;
  return 1;
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
  }
  for (int i = 1; i <= n; i++) {
    if (!u[i] && get(i)) {
      found = 1;
      break;
    }
  }
  if (!found) {
    cout << "YES";
    return 0;
  }
  for (auto i : e) {
    bad[i.first][i.second] = 1;
    memset(u, 0, sizeof(u));
    bool ok = 1;
    for (int j = 1; j <= n; j++)
      if (!u[j]) ok &= (check(j));
    if (ok) {
      cout << "YES";
      return 0;
    }
    bad[i.first][i.second] = 0;
  }
  cout << "NO";
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

You are given a string t consisting of n lowercase Latin letters and an integer number k.

Let's define a substring of some string s with indices from l to r as s[l ... r].

Your task is to construct such string s of minimum possible length that there are exactly k positions i such that s[i ... i + n - 1] = t. In other words, your task is to construct such string s of minimum possible length that there are exactly k substrings of s equal to t.

It is guaranteed that the answer is always unique.

Input

The first line of the input contains two integers n and k (1 ≤ n, k ≤ 50) — the length of the string t and the number of substrings.

The second line of the input contains the string t consisting of exactly n lowercase Latin letters.

Output

Print such string s of minimum possible length that there are exactly k substrings of s equal to t.

It is guaranteed that the answer is always unique.

Examples

Input

3 4
aba

Output

ababababa

Input

3 2
cat

Output

catcat

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, t;
  string s;
  cin >> n >> k >> s;
  for (int i = 0; i < n; i++) {
    if (s.substr(0, i) == s.substr(n - i, i)) t = i;
  }
  for (int i = 1; i < k; i++) {
    cout << s.substr(0, n - t);
  }
  cout << s << endl;
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

There are N balls in a row. Initially, the i-th ball from the left has the integer A_i written on it.

When Snuke cast a spell, the following happens:

* Let the current number of balls be k. All the balls with k written on them disappear at the same time.

Snuke's objective is to vanish all the balls by casting the spell some number of times. This may not be possible as it is. If that is the case, he would like to modify the integers on the minimum number of balls to make his objective achievable.

By the way, the integers on these balls sometimes change by themselves. There will be M such changes. In the j-th change, the integer on the X_j-th ball from the left will change into Y_j.

After each change, find the minimum number of modifications of integers on the balls Snuke needs to make if he wishes to achieve his objective before the next change occurs. We will assume that he is quick enough in modifying integers. Here, note that he does not actually perform those necessary modifications and leaves them as they are.

Constraints

* 1 \leq N \leq 200000
* 1 \leq M \leq 200000
* 1 \leq A_i \leq N
* 1 \leq X_j \leq N
* 1 \leq Y_j \leq N

Input

Input is given from Standard Input in the following format:

N M
A_1 A_2 ... A_N
X_1 Y_1
X_2 Y_2
:
X_M Y_M

Output

Print M lines. The j-th line should contain the minimum necessary number of modifications of integers on the balls to make Snuke's objective achievable.

Examples

Input

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

Output

0
1
1

Input

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

Output

0
1
2
3

Input

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

Output

1
0
1
2
2
3
3
3
3
2

### Response

```cpp
#include<bits/stdc++.h>

using namespace std;

int area, N, M, a[200009], ap[200009], f[200009];

void add (int i)
{
    if (i <= 0) return ;
    if (++ap[i] == 1)
        area ++;
}

void del (int i)
{
    if (i <= 0) return ;
    if (--ap[i] == 0)
        area --;
}

void increaseF (int x)
{
    f[x] ++;
    add (x - f[x] + 1);
}

void decreaseF (int x)
{
    del (x - f[x] + 1);
    f[x] --;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]), increaseF (a[i]);
while (M --)
{
    int pos, val;
    scanf ("%d %d", &pos, &val);
    decreaseF (a[pos]);
    a[pos] = val;
    increaseF (val);
    printf ("%d\n", N - area);
}
return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Vasya and Kolya play a game with a string, using the following rules. Initially, Kolya creates a string s, consisting of small English letters, and uniformly at random chooses an integer k from a segment [0, len(s) - 1]. He tells Vasya this string s, and then shifts it k letters to the left, i. e. creates a new string t = sk + 1sk + 2... sns1s2... sk. Vasya does not know the integer k nor the string t, but he wants to guess the integer k. To do this, he asks Kolya to tell him the first letter of the new string, and then, after he sees it, open one more letter on some position, which Vasya can choose.

Vasya understands, that he can't guarantee that he will win, but he wants to know the probability of winning, if he plays optimally. He wants you to compute this probability.

Note that Vasya wants to know the value of k uniquely, it means, that if there are at least two cyclic shifts of s that fit the information Vasya knowns, Vasya loses. Of course, at any moment of the game Vasya wants to maximize the probability of his win.

Input

The only string contains the string s of length l (3 ≤ l ≤ 5000), consisting of small English letters only.

Output

Print the only number — the answer for the problem. You answer is considered correct, if its absolute or relative error does not exceed 10 - 6.

Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if <image>

Examples

Input

technocup

Output

1.000000000000000

Input

tictictactac

Output

0.333333333333333

Input

bbaabaabbb

Output

0.100000000000000

Note

In the first example Vasya can always open the second letter after opening the first letter, and the cyclic shift is always determined uniquely.

In the second example if the first opened letter of t is "t" or "c", then Vasya can't guess the shift by opening only one other letter. On the other hand, if the first letter is "i" or "a", then he can open the fourth letter and determine the shift uniquely.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2000 * 100 + 5;
bool is_Prime(long long a) {
  for (long long i = 2; i * i <= a; ++i)
    if (a % i == 0) return false;
  return true;
}
bool ss(pair<long long, long long> a, pair<long long, long long> b) {
  return (a.second < b.second);
}
long long fact(long long n) {
  vector<long long> v;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      if (n / i == i)
        v.push_back(i);
      else {
        v.push_back(i);
        v.push_back(n / i);
      }
    }
  }
  return v.size();
}
long long C(long long n, long long r) {
  vector<vector<long long> > c(n + 1, vector<long long>(r + 1, 0));
  for (long long i = 0; i < n + 1; i++) {
    for (long long j = 0; j <= i && j <= r; j++)
      if (j == 0 || j == i)
        c[i][j] = 1;
      else
        c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % 1000000007;
  }
  return c[n][r] % 1000000007;
}
bool is_pl(string s, int n) {
  for (long long i = 0; i < n / 2; i++) {
    if (s[i] != s[n - i - 1]) return false;
  }
  return true;
}
void solve() {
  string s;
  cin >> s;
  int n = s.length(), res = 0;
  for (int c = 'a'; c <= 'z'; c++) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      vector<int> a(26, 0);
      for (int j = 0; j < n; j++) {
        if (s[j] == c) {
          int nxt = s[(j + i) % n];
          a[nxt - 'a']++;
        }
      }
      int chk = 0;
      for (int j = 0; j < 26; j++) chk += (a[j] == 1);
      cnt = max(cnt, chk);
    }
    res += cnt;
  }
  cout << setprecision(10) << res * 1.0 / n;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  ;
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

You are given two strings s and t. Both strings have length n and consist of lowercase Latin letters. The characters in the strings are numbered from 1 to n.

You can successively perform the following move any number of times (possibly, zero):

  * swap any two adjacent (neighboring) characters of s (i.e. for any i = \{1, 2, ..., n - 1\} you can swap s_i and s_{i + 1}).

You can't apply a move to the string t. The moves are applied to the string s one after another.

Your task is to obtain the string t from the string s. Find any way to do it with at most 10^4 such moves.

You do not have to minimize the number of moves, just find any sequence of moves of length 10^4 or less to transform s into t.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 50) — the length of strings s and t.

The second line of the input contains the string s consisting of n lowercase Latin letters.

The third line of the input contains the string t consisting of n lowercase Latin letters.

Output

If it is impossible to obtain the string t using moves, print "-1".

Otherwise in the first line print one integer k — the number of moves to transform s to t. Note that k must be an integer number between 0 and 10^4 inclusive.

In the second line print k integers c_j (1 ≤ c_j < n), where c_j means that on the j-th move you swap characters s_{c_j} and s_{c_j + 1}.

If you do not need to apply any moves, print a single integer 0 in the first line and either leave the second line empty or do not print it at all.

Examples

Input

6
abcdef
abdfec

Output

4
3 5 4 5

Input

4
abcd
accd

Output

-1

Note

In the first example the string s changes as follows: "abcdef" → "abdcef" → "abdcfe" → "abdfce" → "abdfec".

In the second example there is no way to transform the string s into the string t through any allowed moves.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int jabba;
  cin >> jabba;
  string a, b;
  cin >> a >> b;
  if (a.length() != b.length()) {
    cout << "-1";
    return 0;
  }
  int f1[26] = {0};
  int f2[26] = {0};
  for (int i = 0; i < a.length(); ++i) {
    f1[a[i] - 'a']++;
    f2[b[i] - 'a']++;
  }
  for (int i = 0; i < 26; ++i) {
    if (f1[i] != f2[i]) {
      cout << "-1";
      return 0;
    }
  }
  vector<int> m;
  int moves = 0;
  for (int i = 0; i < a.length(); ++i) {
    if (a[i] == b[i]) continue;
    int j;
    for (j = i + 1; a[j] != b[i]; ++j)
      ;
    while (a[i] != b[i]) {
      moves++;
      swap(a[j - 1], a[j]);
      moves++;
      m.push_back(j);
      j--;
    }
  }
  if (moves > 10000) {
    cout << "-1";
  } else {
    cout << m.size() << endl;
    for (int i = 0; i < m.size(); ++i) {
      cout << m[i] << " ";
    }
  }
  return 0;
}

```


### Prompt

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

There are n people in a row. The height of the i-th person is a_i. You can choose any subset of these people and try to arrange them into a balanced circle.

A balanced circle is such an order of people that the difference between heights of any adjacent people is no more than 1. For example, let heights of chosen people be [a_{i_1}, a_{i_2}, ..., a_{i_k}], where k is the number of people you choose. Then the condition |a_{i_j} - a_{i_{j + 1}}| ≤ 1 should be satisfied for all j from 1 to k-1 and the condition |a_{i_1} - a_{i_k}| ≤ 1 should be also satisfied. |x| means the absolute value of x. It is obvious that the circle consisting of one person is balanced.

Your task is to choose the maximum number of people and construct a balanced circle consisting of all chosen people. It is obvious that the circle consisting of one person is balanced so the answer always exists.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of people.

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 2 ⋅ 10^5), where a_i is the height of the i-th person.

Output

In the first line of the output print k — the number of people in the maximum balanced circle.

In the second line print k integers res_1, res_2, ..., res_k, where res_j is the height of the j-th person in the maximum balanced circle. The condition |res_{j} - res_{j + 1}| ≤ 1 should be satisfied for all j from 1 to k-1 and the condition |res_{1} - res_{k}| ≤ 1 should be also satisfied.

Examples

Input

7
4 3 5 1 2 2 1

Output

5
2 1 1 2 3

Input

5
3 7 5 1 5

Output

2
5 5

Input

3
5 1 4

Output

2
4 5

Input

7
2 2 3 2 1 2 2

Output

7
1 2 2 2 2 3 2

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("O3")
using namespace std;
int cnt[200005];
int sum[200005];
int nxt[200005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int first;
    scanf("%d", &first);
    cnt[first]++;
  }
  for (int i = 1; i <= 200001; i++) {
    sum[i] = sum[i - 1] + cnt[i];
  }
  int tmp = 200001;
  for (int i = 200000; i >= 0; i--) {
    nxt[i] = tmp;
    if (cnt[i] < 2) {
      tmp = i;
    }
  }
  int ma = 0, id;
  for (int i = 1; i <= 200000; i++) {
    if (cnt[i] == 0) continue;
    int rrr = nxt[i];
    int add = sum[rrr] - sum[i - 1];
    if (add > ma) {
      ma = add;
      id = i;
    }
  }
  vector<int> ans;
  int ed = nxt[id];
  for (int i = id; i <= ed; i++) {
    while (cnt[i] > 1) {
      ans.push_back(i);
      cnt[i]--;
    }
  }
  for (int i = ed; i >= id; i--) {
    while (cnt[i]) {
      ans.push_back(i);
      cnt[i]--;
    }
  }
  printf("%d\n", ans.size());
  for (int first : ans) {
    printf("%d ", first);
  }
}

```


### Prompt

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

A lot of frogs want to cross a river. A river is w units width, but frogs can only jump l units long, where l < w. Frogs can also jump on lengths shorter than l. but can't jump longer. Hopefully, there are some stones in the river to help them.

The stones are located at integer distances from the banks. There are a_i stones at the distance of i units from the bank the frogs are currently at. Each stone can only be used once by one frog, after that it drowns in the water.

What is the maximum number of frogs that can cross the river, given that then can only jump on the stones?

Input

The first line contains two integers w and l (1 ≤ l < w ≤ 10^5) — the width of the river and the maximum length of a frog's jump.

The second line contains w - 1 integers a_1, a_2, …, a_{w-1} (0 ≤ a_i ≤ 10^4), where a_i is the number of stones at the distance i from the bank the frogs are currently at.

Output

Print a single integer — the maximum number of frogs that can cross the river.

Examples

Input

10 5
0 0 1 0 2 0 0 1 0

Output

3

Input

10 3
1 1 1 1 2 1 1 1 1

Output

3

Note

In the first sample two frogs can use the different stones at the distance 5, and one frog can use the stones at the distances 3 and then 8.

In the second sample although there are two stones at the distance 5, that does not help. The three paths are: 0 → 3 → 6 → 9 → 10, 0 → 2 → 5 → 8 → 10, 0 → 1 → 4 → 7 → 10.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
void solve() {
  int l, w;
  cin >> l >> w;
  vector<int> a(l);
  vector<int> s(l, 0);
  int ans = 1e9;
  for (int i = 1; i < l; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < l; i++) {
    s[i] = s[i - 1] + a[i];
  }
  for (int i = w; i < l; i++) {
    ans = min(ans, s[i] - s[i - w]);
  }
  cout << (ans) << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

A stowaway and a controller play the following game.

The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two conditions — moving or idle. Every minute the players move.

The controller's move is as follows. The controller has the movement direction — to the train's head or to its tail. During a move the controller moves to the neighbouring wagon correspondingly to its movement direction. If at the end of his move the controller enters the 1-st or the n-th wagon, that he changes the direction of his movement into the other one. In other words, the controller cyclically goes from the train's head to its tail and back again during all the time of a game, shifting during each move by one wagon. Note, that the controller always have exactly one possible move.

The stowaway's move depends from the state of the train. If the train is moving, then the stowaway can shift to one of neighbouring wagons or he can stay where he is without moving. If the train is at a station and is idle, then the stowaway leaves the train (i.e. he is now not present in any train wagon) and then, if it is not the terminal train station, he enters the train again into any of n wagons (not necessarily into the one he's just left and not necessarily into the neighbouring one). If the train is idle for several minutes then each such minute the stowaway leaves the train and enters it back.

Let's determine the order of the players' moves. If at the given minute the train is moving, then first the stowaway moves and then the controller does. If at this minute the train is idle, then first the stowaway leaves the train, then the controller moves and then the stowaway enters the train.

If at some point in time the stowaway and the controller happen to be in one wagon, then the controller wins: he makes the stowaway pay fine. If after a while the stowaway reaches the terminal train station, then the stowaway wins: he simply leaves the station during his move and never returns there again.

At any moment of time the players know each other's positions. The players play in the optimal way. Specifically, if the controller wins, then the stowaway plays so as to lose as late as possible. As all the possible moves for the controller are determined uniquely, then he is considered to play optimally always. Determine the winner.

Input

The first line contains three integers n, m and k. They represent the number of wagons in the train, the stowaway's and the controller's initial positions correspondingly (2 ≤ n ≤ 50, 1 ≤ m, k ≤ n, m ≠ k).

The second line contains the direction in which a controller moves. "to head" means that the controller moves to the train's head and "to tail" means that the controller moves to its tail. It is guaranteed that in the direction in which the controller is moving, there is at least one wagon. Wagon 1 is the head, and wagon n is the tail.

The third line has the length from 1 to 200 and consists of symbols "0" and "1". The i-th symbol contains information about the train's state at the i-th minute of time. "0" means that in this very minute the train moves and "1" means that the train in this very minute stands idle. The last symbol of the third line is always "1" — that's the terminal train station.

Output

If the stowaway wins, print "Stowaway" without quotes. Otherwise, print "Controller" again without quotes, then, separated by a space, print the number of a minute, at which the stowaway will be caught.

Examples

Input

5 3 2
to head
0001001

Output

Stowaway

Input

3 2 1
to tail
0001

Output

Controller 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, z, k;
  scanf("%d %d %d\n", &n, &z, &k);
  z--;
  k--;
  bool toHead;
  string s;
  cin >> s >> s;
  toHead = s == "head";
  string t;
  cin >> t;
  for (int i = 0; i < t.length(); ++i) {
    if (t[i] == '0') {
      if (k > z && z > 0)
        z--;
      else if (k < z && z < n - 1)
        z++;
    } else {
      if (toHead)
        z = n - 1;
      else
        z = 0;
    }
    if (toHead) {
      if (k > 0) k--;
      if (k == 0) toHead = false;
    } else {
      if (k < n - 1) k++;
      if (k == n - 1) toHead = true;
    }
    if (k == z) {
      cout << "Controller " << i + 1 << endl;
      return 0;
    }
  }
  cout << "Stowaway" << endl;
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

For a positive integer n let's define a function f:

f(n) = - 1 + 2 - 3 + .. + ( - 1)nn

Your task is to calculate f(n) for a given integer n.

Input

The single line contains the positive integer n (1 ≤ n ≤ 1015).

Output

Print f(n) in a single line.

Examples

Input

4

Output

2

Input

5

Output

-3

Note

f(4) = - 1 + 2 - 3 + 4 = 2

f(5) = - 1 + 2 - 3 + 4 - 5 = - 3

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  long long int n, sk = 0, a, b;
  scanf("%lld", &n);
  if (n % 2 == 0) {
    sk = n / 2;
    printf("%lld\n", sk);
  } else {
    n = n + 1;
    sk = n / 2;
    printf("-%lld\n", sk);
    return 0;
  }
}

```


### Prompt

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

Gargari got bored to play with the bishops and now, after solving the problem about them, he is trying to do math homework. In a math book he have found k permutations. Each of them consists of numbers 1, 2, ..., n in some order. Now he should find the length of the longest common subsequence of these permutations. Can you help Gargari?

You can read about longest common subsequence there: https://en.wikipedia.org/wiki/Longest_common_subsequence_problem

Input

The first line contains two integers n and k (1 ≤ n ≤ 1000; 2 ≤ k ≤ 5). Each of the next k lines contains integers 1, 2, ..., n in some order — description of the current permutation.

Output

Print the length of the longest common subsequence.

Examples

Input

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

Output

3

Note

The answer for the first test sample is subsequence [1, 2, 3].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long pos[6][1005];
long long a[6][1005];
long long dp[1005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  for (long long i = 1; i <= k; i++) {
    for (long long j = 1; j <= n; j++) {
      cin >> a[i][j];
      pos[i][a[i][j]] = j;
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long mx = 0;
    for (long long j = 1; j < i; j++) {
      bool f = true;
      for (long long p = 2; p <= k; p++) {
        if (pos[p][a[1][i]] < pos[p][a[1][j]]) {
          f = false;
          break;
        }
      }
      if (f) {
        mx = max(mx, dp[j]);
      }
    }
    dp[i] = mx + 1;
    ans = max(ans, dp[i]);
  }
  cout << ans << "\n";
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:

* Find the maximum value among the N-1 elements other than A_i in the sequence.

Constraints

* 2 \leq N \leq 200000
* 1 \leq A_i \leq 200000
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1
:
A_N

Output

Print N lines. The i-th line (1 \leq i \leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence.

Examples

Input

3
1
4
3

Output

4
3
4

Input

2
5
5

Output

5
5

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int n,s[200001],u[200001];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>s[i],u[i]=s[i];
	sort(s+1,s+n+1);
	for(int i=1;i<=n;i++)
	{
		if(s[n]==u[i])
			cout<<s[n-1]<<endl;
		else
			cout<<s[n]<<endl;
	}
	return 0;
}
```


### Prompt

Please create a solution in CPP to the following problem:

The Little Elephant loves numbers.

He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal representations.

Help the Little Elephant to find the described number.

Input

A single line contains a single integer x (1 ≤ x ≤ 109).

Output

In a single line print an integer — the answer to the problem.

Examples

Input

1

Output

1

Input

10

Output

2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, a[100], ans;
int find(int x) {
  while (x > 0) {
    if (a[x % 10]) return true;
    x /= 10;
  }
  return false;
}
int main() {
  scanf("%d", &n);
  memset(a, 0, sizeof(a));
  int tp = n;
  while (tp > 0) {
    a[tp % 10] = true;
    tp /= 10;
  }
  ans = 0;
  for (int i = 1; i * i <= n; i++)
    if (n % i == 0) {
      int tp = i;
      if (find(tp)) ans++;
      if (i != n / i && find(n / i)) ans++;
    }
  printf("%d\n", ans);
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Suppose you have a special x-y-counter. This counter can store some value as a decimal number; at first, the counter has value 0.

The counter performs the following algorithm: it prints its lowest digit and, after that, adds either x or y to its value. So all sequences this counter generates are starting from 0. For example, a 4-2-counter can act as follows:

  1. it prints 0, and adds 4 to its value, so the current value is 4, and the output is 0;
  2. it prints 4, and adds 4 to its value, so the current value is 8, and the output is 04;
  3. it prints 8, and adds 4 to its value, so the current value is 12, and the output is 048;
  4. it prints 2, and adds 2 to its value, so the current value is 14, and the output is 0482;
  5. it prints 4, and adds 4 to its value, so the current value is 18, and the output is 04824.

This is only one of the possible outputs; for example, the same counter could generate 0246802468024 as the output, if we chose to add 2 during each step.

You wrote down a printed sequence from one of such x-y-counters. But the sequence was corrupted and several elements from the sequence could be erased.

Now you'd like to recover data you've lost, but you don't even know the type of the counter you used. You have a decimal string s — the remaining data of the sequence.

For all 0 ≤ x, y < 10, calculate the minimum number of digits you have to insert in the string s to make it a possible output of the x-y-counter. Note that you can't change the order of digits in string s or erase any of them; only insertions are allowed.

Input

The first line contains a single string s (1 ≤ |s| ≤ 2 ⋅ 10^6, s_i ∈ \{0 - 9\}) — the remaining data you have. It's guaranteed that s_1 = 0.

Output

Print a 10 × 10 matrix, where the j-th integer (0-indexed) on the i-th line (0-indexed too) is equal to the minimum number of digits you have to insert in the string s to make it a possible output of the i-j-counter, or -1 if there is no way to do so.

Example

Input

0840

Output

-1 17 7 7 7 -1 2 17 2 7
17 17 7 5 5 5 2 7 2 7
7 7 7 4 3 7 1 7 2 5
7 5 4 7 3 3 2 5 2 3
7 5 3 3 7 7 1 7 2 7
-1 5 7 3 7 -1 2 9 2 7
2 2 1 2 1 2 2 2 0 1
17 7 7 5 7 9 2 17 2 3
2 2 2 2 2 2 0 2 2 2
7 7 5 3 7 7 1 3 2 7

Note

Let's take, for example, 4-3-counter. One of the possible outcomes the counter could print is 0(4)8(1)4(7)0 (lost elements are in the brackets).

One of the possible outcomes a 2-3-counter could print is 0(35)8(1)4(7)0.

The 6-8-counter could print exactly the string 0840.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m;
int dp[15][15][15][15];
char a[2100000];
int main() {
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      for (int num1 = 0; num1 <= 9; num1++)
        for (int num2 = 0; num2 <= 9; num2++) {
          int ans = 1e9 + 7;
          for (int s1 = 0; s1 <= 10; s1++) {
            for (int s2 = 0; s2 <= 10; s2++) {
              if (s1 + s2 == 0) continue;
              if ((num1 + s1 * i + s2 * j) % 10 == num2) {
                ans = min(ans, s1 + s2);
              }
            }
          }
          if (ans != 1e9 + 7) dp[i][j][num1][num2] = ans;
        }
    }
  }
  scanf("%s", a);
  int len = strlen(a);
  for (int i = 0; i <= 9; i++) {
    for (int j = 0; j <= 9; j++) {
      int ans = 0;
      bool judge = 1;
      for (int k = 1; k < len; k++) {
        int now1 = a[k - 1] - '0';
        int now2 = a[k] - '0';
        if (dp[i][j][now1][now2] == -1) {
          judge = 0;
          break;
        } else
          ans += dp[i][j][now1][now2];
      }
      if (!judge)
        printf("-1 ");
      else
        printf("%d ", max(ans - len + 1, 0));
    }
    printf("\n");
  }
  return 0;
}

```


### Prompt

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

There is a robot in a warehouse and n packages he wants to collect. The warehouse can be represented as a coordinate grid. Initially, the robot stays at the point (0, 0). The i-th package is at the point (x_i, y_i). It is guaranteed that there are no two packages at the same point. It is also guaranteed that the point (0, 0) doesn't contain a package.

The robot is semi-broken and only can move up ('U') and right ('R'). In other words, in one move the robot can go from the point (x, y) to the point (x + 1, y) or to the point (x, y + 1).

As we say above, the robot wants to collect all n packages (in arbitrary order). He wants to do it with the minimum possible number of moves. If there are several possible traversals, the robot wants to choose the lexicographically smallest path.

The string s of length n is lexicographically less than the string t of length n if there is some index 1 ≤ j ≤ n that for all i from 1 to j-1 s_i = t_i and s_j < t_j. It is the standard comparison of string, like in a dictionary. Most programming languages compare strings in this way.

Input

The first line of the input contains an integer t (1 ≤ t ≤ 100) — the number of test cases. Then test cases follow.

The first line of a test case contains one integer n (1 ≤ n ≤ 1000) — the number of packages.

The next n lines contain descriptions of packages. The i-th package is given as two integers x_i and y_i (0 ≤ x_i, y_i ≤ 1000) — the x-coordinate of the package and the y-coordinate of the package.

It is guaranteed that there are no two packages at the same point. It is also guaranteed that the point (0, 0) doesn't contain a package.

The sum of all values n over test cases in the test doesn't exceed 1000.

Output

Print the answer for each test case.

If it is impossible to collect all n packages in some order starting from (0,0), print "NO" on the first line.

Otherwise, print "YES" in the first line. Then print the shortest path — a string consisting of characters 'R' and 'U'. Among all such paths choose the lexicographically smallest path.

Note that in this problem "YES" and "NO" can be only uppercase words, i.e. "Yes", "no" and "YeS" are not acceptable.

Example

Input

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

Output

YES
RUUURRRRUU
NO
YES
RRRRUUU

Note

For the first test case in the example the optimal path RUUURRRRUU is shown below:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
} a[1000];
bool cmp(point a, point b) {
  if (a.x == b.x)
    return a.y < b.y;
  else
    return a.x < b.x;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    a[0].x = 0, a[0].y = 0;
    int n, i, j;
    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
      scanf("%d%d", &a[i].x, &a[i].y);
    }
    sort(a, a + 1 + n, cmp);
    for (i = 1; i <= n; i++) {
      if (a[i].y < a[i - 1].y) {
        printf("NO\n");
        goto label;
      }
    }
    printf("YES\n");
    for (i = 1; i <= n; i++) {
      for (j = a[i - 1].x; j < a[i].x; j++) printf("R");
      for (j = a[i - 1].y; j < a[i].y; j++) printf("U");
    }
    printf("\n");
  label:
    continue;
  }
}

```


### Prompt

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

Blake is a CEO of a large company called "Blake Technologies". He loves his company very much and he thinks that his company should be the best. That is why every candidate needs to pass through the interview that consists of the following problem.

We define function f(x, l, r) as a bitwise OR of integers xl, xl + 1, ..., xr, where xi is the i-th element of the array x. You are given two arrays a and b of length n. You need to determine the maximum value of sum f(a, l, r) + f(b, l, r) among all possible 1 ≤ l ≤ r ≤ n.

<image>

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the length of the arrays.

The second line contains n integers ai (0 ≤ ai ≤ 109).

The third line contains n integers bi (0 ≤ bi ≤ 109).

Output

Print a single integer — the maximum value of sum f(a, l, r) + f(b, l, r) among all possible 1 ≤ l ≤ r ≤ n.

Examples

Input

5
1 2 4 3 2
2 3 3 12 1

Output

22

Input

10
13 2 7 11 8 4 9 8 5 1
5 7 18 9 2 3 0 11 8 6

Output

46

Note

Bitwise OR of two non-negative integers a and b is the number c = a OR b, such that each of its digits in binary notation is 1 if and only if at least one of a or b have 1 in the corresponding position in binary notation.

In the first sample, one of the optimal answers is l = 2 and r = 4, because f(a, 2, 4) + f(b, 2, 4) = (2 OR 4 OR 3) + (3 OR 3 OR 12) = 7 + 15 = 22. Other ways to get maximum value is to choose l = 1 and r = 4, l = 1 and r = 5, l = 2 and r = 4, l = 2 and r = 5, l = 3 and r = 4, or l = 3 and r = 5.

In the second sample, the maximum value is obtained for l = 1 and r = 9.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MOD = 100999;
int n;
vector<int> a, b;
int main() {
  scanf("%d", &n);
  a.resize(n + 1);
  b.resize(n + 1);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  int maxx = -1;
  for (int i = 1; i <= n; i++) {
    int aSum = a[i], bSum = b[i];
    maxx = max(maxx, aSum + bSum);
    for (int j = i + 1; j <= n; j++) {
      aSum |= a[j], bSum |= b[j];
      maxx = max(maxx, aSum + bSum);
    }
  }
  printf("%d\n", maxx);
}

```


### Prompt

Generate a Cpp solution to the following problem:

You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table (also consisting of «A», «G», «C», «T»), that differs from the given table in the minimum number of characters.

Input

First line contains two positive integers n and m — number of rows and columns in the table you are given (2 ≤ n, m, n × m ≤ 300 000). Then, n lines describing the table follow. Each line contains exactly m characters «A», «G», «C», «T».

Output

Output n lines, m characters each. This table must be nice and differ from the input table in the minimum number of characters.

Examples

Input

2 2
AG
CT

Output

AG
CT

Input

3 5
AGCAG
AGCAG
AGCAG

Output

TGCAT
CATGC
TGCAT

Note

In the first sample, the table is already nice. In the second sample, you can change 9 elements to make the table nice.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXCELLS = 300000;
const char CHARS[4] = {'A', 'C', 'G', 'T'};
int h, w;
char s[MAXCELLS + 1];
char ans[MAXCELLS + 1];
char t[MAXCELLS + 1];
void solve() {
  int best = INT_MAX;
  for (int i = (0); i < (h * w); ++i) ans[i] = '?';
  t[h * w] = ans[h * w] = '\0';
  for (int a = (0); a < (4); ++a)
    for (int b = (a + 1); b < (4); ++b)
      for (int c = (0); c < (4); ++c)
        for (int d = (c + 1); d < (4); ++d) {
          if (c == a || c == b || d == a || d == b) continue;
          for (int x = (0); x < (h); ++x) {
            int u = x % 2 == 0 ? a : c, v = x % 2 == 0 ? b : d;
            int match[2];
            match[0] = match[1] = 0;
            for (int y = (0); y < (w); ++y)
              if (s[x * w + y] == CHARS[u])
                ++match[y % 2];
              else if (s[x * w + y] == CHARS[v])
                ++match[1 - y % 2];
            if (match[1] > match[0]) swap(u, v);
            for (int y = (0); y < (w); ++y)
              t[x * w + y] = y % 2 == 0 ? CHARS[u] : CHARS[v];
          }
          {
            int cur = 0;
            for (int i = (0); i < (h * w); ++i)
              if (s[i] != t[i]) ++cur;
            if (cur < best) {
              best = cur;
              for (int i = (0); i < (h * w); ++i) ans[i] = t[i];
            }
          }
          for (int y = (0); y < (w); ++y) {
            int u = y % 2 == 0 ? a : c, v = y % 2 == 0 ? b : d;
            int match[2];
            match[0] = match[1] = 0;
            for (int x = (0); x < (h); ++x)
              if (s[x * w + y] == CHARS[u])
                ++match[x % 2];
              else if (s[x * w + y] == CHARS[v])
                ++match[1 - x % 2];
            if (match[1] > match[0]) swap(u, v);
            for (int x = (0); x < (h); ++x)
              t[x * w + y] = x % 2 == 0 ? CHARS[u] : CHARS[v];
          }
          {
            int cur = 0;
            for (int i = (0); i < (h * w); ++i)
              if (s[i] != t[i]) ++cur;
            if (cur < best) {
              best = cur;
              for (int i = (0); i < (h * w); ++i) ans[i] = t[i];
            }
          }
        }
}
void run() {
  scanf("%d%d", &h, &w);
  for (int x = (0); x < (h); ++x) scanf("%s", s + x * w);
  solve();
  for (int x = (0); x < (h); ++x) printf("%.*s\n", w, ans + x * w);
}
int main() {
  run();
  return 0;
}

```


### Prompt

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

You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).

You want to construct the array a of length n such that:

  * The first n/2 elements of a are even (divisible by 2);
  * the second n/2 elements of a are odd (not divisible by 2);
  * all elements of a are distinct and positive;
  * the sum of the first half equals to the sum of the second half (∑_{i=1}^{n/2} a_i = ∑_{i=n/2 + 1}^{n} a_i).

If there are multiple answers, you can print any. It is not guaranteed that the answer exists.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.

The only line of the test case contains one integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the length of the array. It is guaranteed that that n is even (i.e. divisible by 2).

It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5 (∑ n ≤ 2 ⋅ 10^5).

Output

For each test case, print the answer — "NO" (without quotes), if there is no suitable answer for the given test case or "YES" in the first line and any suitable array a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) satisfying conditions from the problem statement on the second line.

Example

Input

5
2
4
6
8
10

Output

NO
YES
2 4 1 5
NO
YES
2 4 6 8 1 3 5 11
NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void answer() {
  long long n, m, x, ans = 0;
  cin >> n;
  std::vector<long long> v;
  if (n % 4 != 0) {
    cout << "NO\n";
    return;
  }
  cout << "YES\n";
  for (int i = 1; i <= n / 2; i++) {
    v.push_back(i * 2);
  }
  for (int i = 0; i < n / 4; i++) {
    v.push_back(v[i] - 1);
  }
  for (int i = n / 4; i < n / 2; i++) v.push_back(v[i] + 1);
  for (auto i : v) cout << i << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q;
  cin >> q;
  while (q--) answer();
  return 0;
}

```


### Prompt

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

Vasya participates in a ski race along the X axis. The start is at point 0, and the finish is at L, that is, at a distance L meters from the start in the positive direction of the axis. Vasya has been training so hard that he can run one meter in exactly one second.

Besides, there are n take-off ramps on the track, each ramp is characterized by four numbers:

  * xi represents the ramp's coordinate
  * di represents from how many meters Vasya will land if he goes down this ramp
  * ti represents the flight time in seconds
  * pi is the number, indicating for how many meters Vasya should gather speed to get ready and fly off the ramp. As Vasya gathers speed, he should ski on the snow (that is, he should not be flying), but his speed still equals one meter per second.

Vasya is allowed to move in any direction on the X axis, but he is prohibited to cross the start line, that is go to the negative semiaxis. Vasya himself chooses which take-off ramps he will use and in what order, that is, he is not obliged to take off from all the ramps he encounters. Specifically, Vasya can skip the ramp. It is guaranteed that xi + di ≤ L, that is, Vasya cannot cross the finish line in flight.

Vasya can jump from the ramp only in the positive direction of X axis. More formally, when using the i-th ramp, Vasya starts gathering speed at point xi - pi, jumps at point xi, and lands at point xi + di. He cannot use the ramp in opposite direction.

Your task is to find the minimum time that Vasya will spend to cover the distance.

Input

The first line contains two integers n and L (0 ≤ n ≤ 105, 1 ≤ L ≤ 109). Then n lines contain the descriptions of the ramps, each description is on a single line. Each description is a group of four non-negative integers xi, di, ti, pi (0 ≤ xi ≤ L, 1 ≤ di, ti, pi ≤ 109, xi + di ≤ L).

Output

Print in the first line the minimum time in seconds Vasya needs to complete the track. Print in the second line k — the number of take-off ramps that Vasya needs to use, and print on the third line of output k numbers the number the take-off ramps Vasya used in the order in which he used them. Print each number exactly once, separate the numbers with a space. The ramps are numbered starting from 1 in the order in which they are given in the input.

Examples

Input

2 20
5 10 5 5
4 16 1 7

Output

15
1
1

Input

2 20
9 8 12 6
15 5 1 1

Output

16
1
2

Note

In the first sample, Vasya cannot use ramp 2, because then he will need to gather speed starting from point -3, which is not permitted by the statement. The optimal option is using ramp 1, the resulting time is: moving to the point of gathering speed + gathering speed until reaching the takeoff ramp + flight time + moving to the finish line = 0 + 5 + 5 + 5 = 15.

In the second sample using ramp 1 is not optimal for Vasya as t1 > d1. The optimal option is using ramp 2, the resulting time is: moving to the point of gathering speed + gathering speed until reaching the takeoff ramp + flight time + moving to the finish line = 14 + 1 + 1 + 0 = 16.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000001;
vector<pair<int, long long> > adj[MAXN];
vector<int> ramp[MAXN];
int n, L;
vector<int> pos;
int x[MAXN], d[MAXN], t[MAXN], p[MAXN], recover[MAXN];
long long dist[MAXN];
int pe[MAXN], pn[MAXN];
void addEdge(int u, int v, long long w, int di, int r) {
  if (di)
    ramp[u].push_back(r);
  else
    ramp[u].push_back(0), ramp[v].push_back(0);
  adj[u].push_back({v, w});
  if (!di) adj[v].push_back({u, w});
}
int get(vector<int> &v, int x) {
  return (int)(lower_bound(v.begin(), v.end(), x) - v.begin() + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> L;
  pos.push_back(0);
  pos.push_back(L);
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> d[i] >> t[i] >> p[i];
    pos.push_back(x[i]);
    pos.push_back(x[i] + d[i]);
    if (x[i] - p[i] >= 0) pos.push_back(x[i] - p[i]);
  }
  sort(pos.begin(), pos.end());
  pos.erase(unique(pos.begin(), pos.end()), pos.end());
  for (int i = 0; i < pos.size(); i++) {
    recover[get(pos, pos[i])] = pos[i];
  }
  for (int i = 0; i < pos.size() - 1; i++) {
    int u = get(pos, pos[i]);
    int v = get(pos, pos[i + 1]);
    addEdge(u, v, pos[i + 1] - pos[i], 0, 0);
  }
  for (int i = 1; i <= n; i++) {
    int xp = x[i] - p[i];
    int xi = x[i];
    int xd = x[i] + d[i];
    if (xp >= 0) {
      int u = get(pos, xp);
      int v = get(pos, xd);
      addEdge(u, v, p[i] + t[i], 1, i);
    }
  }
  priority_queue<pair<long long, int> > pq;
  pq.push({0, get(pos, 0)});
  for (int i = 0; i < MAXN; i++) dist[i] = 1e18;
  dist[get(pos, 0)] = 0;
  while (!pq.empty()) {
    int here = pq.top().second;
    long long cost = -pq.top().first;
    pq.pop();
    if (cost > dist[here]) continue;
    for (int i = 0; i < adj[here].size(); i++) {
      int there = adj[here][i].first;
      long long ndist = dist[here] + adj[here][i].second;
      if (dist[there] > ndist) {
        pn[there] = here;
        pe[there] = i;
        dist[there] = ndist;
        pq.push({-ndist, there});
      }
    }
  }
  cout << dist[get(pos, L)] << "\n";
  vector<int> ans;
  int st = get(pos, 0);
  int ed = get(pos, L);
  int node = ed;
  while (node != st) {
    int parent = pn[node];
    int en = pe[node];
    if (ramp[parent][en]) ans.push_back(ramp[parent][en]);
    node = parent;
  }
  reverse(ans.begin(), ans.end());
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Silver Fox is fighting with N monsters.

The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i.

Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all monsters between the coordinates x-D and x+D (inclusive) by A. There is no way other than bombs to decrease the monster's health.

Silver Fox wins when all the monsters' healths become 0 or below.

Find the minimum number of bombs needed to win.

Constraints

* 1 \leq N \leq 2 \times 10^5
* 0 \leq D \leq 10^9
* 1 \leq A \leq 10^9
* 0 \leq X_i \leq 10^9
* 1 \leq H_i \leq 10^9
* X_i are distinct.
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N D A
X_1 H_1
:
X_N H_N

Output

Print the minimum number of bombs needed to win.

Examples

Input

3 3 2
1 2
5 4
9 2

Output

2

Input

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

Output

5

Input

3 0 1
300000000 1000000000
100000000 1000000000
200000000 1000000000

Output

3000000000

### Response

```cpp
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int n;
	long long d, a;
	cin >> n >> d >> a;
	vector<pair<long long, long long>> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i].first >> v[i].second;
	}
	sort(v.begin(), v.end());
	queue<long long> q, p;
	long long cur = 0;
	long long ans = 0;
	for(auto i : v) {
		while(!q.empty() and q.front() < i.first - 2*d) {
			q.pop();
			cur -= p.front();
			p.pop();
		}
		if(i.second <= cur) continue;
		long long req = (i.second - cur)/a;
		if((i.second - cur) % a != 0) req++;
		cur += req * a;
		ans += req;
		q.push(i.first);
		p.push(req*a);
	}
	cout << ans << '\n';

	return 0;
}
```


### Prompt

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

On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.

Determine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected.

Input

The first line of the input contains five positive integers n, l, v1, v2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 109, 1 ≤ v1 < v2 ≤ 109, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus.

Output

Print the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10 - 6.

Examples

Input

5 10 1 2 5

Output

5.0000000000

Input

3 6 1 2 1

Output

4.7142857143

Note

In the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, l, v1, v2, k;
long long x1, x2;
long long vv1, vv2;
double t1, t2;
int main() {
  scanf("%I64d%I64d%I64d%I64d%I64d", &n, &l, &v1, &v2, &k);
  if (n % k)
    n = n / k + 1;
  else
    n = n / k;
  if (n == 1) {
    printf("%.10lf\n", l * 1.0 / v2);
    return 0;
  }
  x1 = 2 * l * (n - 1);
  vv1 = v1 + v2 + 2 * v1 * (n - 1);
  x2 = (v1 + v2) * l;
  vv2 = (v1 + v2 + 2 * v1 * (n - 1));
  t1 = 1.0 * x1 / vv1;
  t2 = 1.0 * x2 / vv2 / v2;
  printf("%.10lf", t1 + t2);
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

You have two positive integers w and h. Your task is to count the number of rhombi which have the following properties:

  * Have positive area.
  * With vertices at integer points.
  * All vertices of the rhombi are located inside or on the border of the rectangle with vertices at points (0, 0), (w, 0), (w, h), (0, h). In other words, for all vertices (xi, yi) of the rhombus the following conditions should fulfill: 0 ≤ xi ≤ w and 0 ≤ yi ≤ h.
  * Its diagonals are parallel to the axis.

Count the number of such rhombi.

Let us remind you that a rhombus is a quadrilateral whose four sides all have the same length.

Input

The first line contains two integers w and h (1 ≤ w, h ≤ 4000) — the rectangle's sizes.

Output

Print a single number — the number of sought rhombi.

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

Examples

Input

2 2

Output

1

Input

1 2

Output

0

Note

In the first example there exists only one such rhombus. Its vertices are located at points (1, 0), (2, 1), (1, 2), (0, 1).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int intf = 0x3f3f3f3f;
int main() {
  int a, b;
  cin >> a >> b;
  if (a < 2 || b < 2) {
    cout << 0 << endl;
    return 0;
  }
  long long aa = 0, bb = 0;
  for (int i = 2; i <= a; i += 2) {
    aa += (a - (i - 1));
  }
  for (int i = 2; i <= b; i += 2) {
    bb += (b - (i - 1));
  }
  long long ans = aa * bb;
  cout << ans << endl;
  return 0;
}

```


### Prompt

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

Life is not easy. Sometimes it is beyond your control. Now, as contestants of ACM ICPC, you might be just tasting the bitter of life. But don't worry! Do not look only on the dark side of life, but look also on the bright side. Life may be an enjoyable game of chance, like throwing dice. Do or die! Then, at last, you might be able to find the route to victory.

This problem comes from a game using a die. By the way, do you know a die? It has nothing to do with "death." A die is a cubic object with six faces, each of which represents a different number from one to six and is marked with the corresponding number of spots. Since it is usually used in pair, "a die" is rarely used word. You might have heard a famous phrase "the die is cast," though.

When a game starts, a die stands still on a flat table. During the game, the die is tumbled in all directions by the dealer. You will win the game if you can predict the number seen on the top face at the time when the die stops tumbling.

Now you are requested to write a program that simulates the rolling of a die. For simplicity, we assume that the die neither slip nor jumps but just rolls on the table in four directions, that is, north, east, south, and west. At the beginning of every game, the dealer puts the die at the center of the table and adjusts its direction so that the numbers one, two, and three are seen on the top, north, and west faces, respectively. For the other three faces, we do not explicitly specify anything but tell you the golden rule: the sum of the numbers on any pair of opposite faces is always seven.

Your program should accept a sequence of commands, each of which is either "north", "east", "south", or "west". A "north" command tumbles the die down to north, that is, the top face becomes the new north, the north becomes the new bottom, and so on. More precisely, the die is rotated around its north bottom edge to the north direction and the rotation angle is 9 degrees. Other commands also tumble the die accordingly to their own directions. Your program should calculate the number finally shown on the top after performing the commands in the sequence. Note that the table is sufficiently large and the die never falls off during the game.

Input

The input consists of one or more command sequences, each of which corresponds to a single game. The first line of a command sequence contains a positive integer, representing the number of the following command lines in the sequence. You may assume that this number is less than or equal to 1024. A line containing a zero indicates the end of the input. Each command line includes a command that is one of north, east, south, and west. You may assume that no white space occurs in any line.

Output

For each command sequence, output one line containing solely the number of the top face at the time when the game is finished.

Example

Input

1
north
3
north
east
south
0

Output

5
1

### Response

```cpp
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;

int dice[6] = {1,5,4,3,2,6};
void swap(int i, int j, int k, int l) {
	int temp = dice[l];
	dice[l] = dice[k];
	dice[k] = dice[j];
	dice[j] = dice[i];
	dice[i] = temp;
}
int main() {
	int n;
	while(cin >> n, n) {
		dice[0] = 1;
		dice[1] = 5;
		dice[2] = 4;
		dice[3] = 3;
		dice[4] = 2;
		dice[5] = 6;
		REP(i, n) {
			string in; cin >> in;
			if(in == "north")
				swap(0,4,5,1);
			else if(in == "south")
				swap(0,1,5,4);
			else if(in == "west")
				swap(0,3,5,2);
			else if(in == "east")
				swap(0,2,5,3);
		}
		cout << dice[0] << endl;
	}
	return 0;
}
```


### Prompt

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

Given a non-negative decimal integer $x$, convert it to binary representation $b$ of 32 bits. Then, print the result of the following operations to $b$ respecitvely.

* Inversion: change the state of each bit to the opposite state
* Logical left shift: shift left by 1
* Logical right shift: shift right by 1

Constraints

* $0 \leq x \leq 2^{32} - 1$

Input

The input is given in the following format.

$x$

Output

Print the given bits, results of inversion, left shift and right shift in a line respectively.

Examples

Input

8

Output

00000000000000000000000000001000
11111111111111111111111111110111
00000000000000000000000000010000
00000000000000000000000000000100

Input

13

Output

00000000000000000000000000001101
11111111111111111111111111110010
00000000000000000000000000011010
00000000000000000000000000000110

### Response

```cpp
#include <iostream>
#include <bitset>
using namespace std;
typedef bitset<32> b8;
int main(){
	unsigned int n;
	cin>>n;
	b8 b(n);
	cout<<b<<endl;
	cout<<~b<<endl;
	cout<<(b<<1)<<endl;
	cout<<(b>>1)<<endl;
}

```


### Prompt

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

DZY loves strings, and he enjoys collecting them.

In China, many people like to use strings containing their names' initials, for example: xyz, jcvb, dzy, dyh.

Once DZY found a lucky string s. A lot of pairs of good friends came to DZY when they heard about the news. The first member of the i-th pair has name ai, the second one has name bi. Each pair wondered if there is a substring of the lucky string containing both of their names. If so, they want to find the one with minimum length, which can give them good luck and make their friendship last forever.

Please help DZY for each pair find the minimum length of the substring of s that contains both ai and bi, or point out that such substring doesn't exist.

A substring of s is a string slsl + 1... sr for some integers l, r (1 ≤ l ≤ r ≤ |s|). The length of such the substring is (r - l + 1).

A string p contains some another string q if there is a substring of p equal to q.

Input

The first line contains a string s (1 ≤ |s| ≤ 50000).

The second line contains a non-negative integer q (0 ≤ q ≤ 100000) — the number of pairs. Each of the next q lines describes a pair, the line contains two space-separated strings ai and bi (1 ≤ |ai|, |bi| ≤ 4).

It is guaranteed that all the strings only consist of lowercase English letters.

Output

For each pair, print a line containing a single integer — the minimum length of the required substring. If there is no such substring, output -1.

Examples

Input

xudyhduxyz
3
xyz xyz
dyh xyz
dzy xyz

Output

3
8
-1

Input

abcabd
3
a c
ab abc
ab d

Output

2
3
3

Input

baabcabaaa
2
abca baa
aa aba

Output

6
4

Note

The shortest substrings in the first sample are: xyz, dyhduxyz.

The shortest substrings in the second sample are: ca, abc and abd.

The shortest substrings in the third sample are: baabca and abaa.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int gh(const string &s) {
  int r = 0;
  for (int i = 0, b = 1; i < s.size(); ++i, b *= 27) {
    r += (s[i] - 'a' + 1) * b;
  }
  return r;
}
int hl(int h) {
  for (int i = 1, b = 27;; ++i, b *= 27) {
    if (b > h) return i;
  }
}
signed main() {
  ios::sync_with_stdio(false);
  string T;
  cin >> T;
  int Q;
  cin >> Q;
  int B = T.size() / max<int>(1, sqrt(Q));
  vector<vector<int>> h2p(27 * 27 * 27 * 27);
  for (int i = 0; i < T.size(); ++i) {
    for (int l = 1; l <= 4 && i + l <= T.size(); ++l) {
      int h = gh(T.substr(i, l));
      h2p[h].emplace_back(i);
    }
  }
  vector<int> heavy_h;
  for (int i = 0; i < h2p.size(); ++i) {
    if (h2p[i].size() > B) {
      heavy_h.emplace_back(i);
    }
  }
  auto calc = [&](int ha, int hb) {
    int minl = 0x3f3f3f3f;
    if (h2p[ha].size() > h2p[hb].size()) swap(ha, hb);
    int la = hl(ha), lb = hl(hb);
    for (int ap : h2p[ha]) {
      auto it = lower_bound(h2p[hb].begin(), h2p[hb].end(), ap);
      if (it != h2p[hb].end()) {
        minl = min(minl, max(ap + la, *it + lb) - ap);
      }
      if (it != h2p[hb].begin()) {
        minl = min(minl, max(ap + la, *prev(it) + lb) - *prev(it));
      }
    }
    if (minl == 0x3f3f3f3f) minl = -1;
    return minl;
  };
  map<pair<int, int>, int> heavy_ans;
  for (int h : heavy_h) {
    for (int g : heavy_h) {
      heavy_ans[make_pair(h, g)] = calc(h, g);
    }
  }
  for (int qi = 0; qi < Q; ++qi) {
    string A, B;
    cin >> A >> B;
    int ha = gh(A);
    int hb = gh(B);
    if (heavy_ans.count(make_pair(ha, hb))) {
      cout << heavy_ans[make_pair(ha, hb)] << endl;
    } else {
      cout << calc(ha, hb) << endl;
    }
  }
  return 0;
}

```


### Prompt

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

All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats themselves. Formerly the choice was made by a cashier, but now this is the responsibility of a special seating program. It was found out that the large majority of Berland's inhabitants go to the cinema in order to watch a movie, that's why they want to sit as close to the hall center as possible. Moreover, a company of M people, who come to watch a movie, want necessarily to occupy M successive seats in one row. Let's formulate the algorithm, according to which the program chooses seats and sells tickets. As the request for M seats comes, the program should determine the row number x and the segment [yl, yr] of the seats numbers in this row, where yr - yl + 1 = M. From all such possible variants as a final result the program should choose the one with the minimum function value of total seats remoteness from the center. Say, <image> — the row and the seat numbers of the most "central" seat. Then the function value of seats remoteness from the hall center is <image>. If the amount of minimum function values is more than one, the program should choose the one that is closer to the screen (i.e. the row number x is lower). If the variants are still multiple, it should choose the one with the minimum yl. If you did not get yet, your task is to simulate the work of this program.

Input

The first line contains two integers N and K (1 ≤ N ≤ 1000, 1 ≤ K ≤ 99) — the amount of requests and the hall size respectively. The second line contains N space-separated integers Mi from the range [1, K] — requests to the program.

Output

Output N lines. In the i-th line output «-1» (without quotes), if it is impossible to find Mi successive seats in one row, otherwise output three numbers x, yl, yr. Separate the numbers with a space.

Examples

Input

2 1
1 1

Output

1 1 1
-1

Input

4 3
1 2 3 1

Output

2 2 2
1 1 2
3 1 3
2 1 1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int X = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') X = (X << 3) + (X << 1) + c - '0', c = getchar();
  return X * w;
}
bool a[110][110];
int main() {
  int n = read(), k = read();
  int xc = (k + 1) / 2, yc = (k + 1) / 2;
  while (n--) {
    int x = read();
    int X, Y, Min = 2147483647;
    for (int i = 1; i <= k; i++)
      for (register int j = 1; j <= k - x + 1; j++) {
        bool f = 1;
        int s = 0;
        for (register int t = j; t < j + x; t++) {
          if (a[i][t]) {
            f = 0;
            break;
          }
          s += abs(i - xc) + abs(t - yc);
        }
        if (f && s < Min) Min = s, X = i, Y = j;
      }
    if (Min == 2147483647)
      puts("-1");
    else {
      for (register int i = Y; i < Y + x; i++) a[X][i] = 1;
      printf("%d %d %d\n", X, Y, Y + x - 1);
    }
  }
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.

The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.

Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.

Constraints

* 1 \leq k \leq 15
* S is a string of length k consisting of `o` and `x`.

Input

Input is given from Standard Input in the following format:

S

Output

Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` otherwise.

Examples

Input

oxoxoxoxoxoxox

Output

YES

Input

xxxxxxxx

Output

NO

### Response

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

int main() {
	string S;
	cin >> S;
	int k = S.length();
	int win = 0;
	for (char c : S) win += (int)(c == 'o');
	cout << (15 - k + win >= 8 ? "YES" : "NO") << endl;
}
```


### Prompt

Construct a Cpp code solution to the problem outlined:

We have a square grid with N rows and M columns. Takahashi will write an integer in each of the squares, as follows:

* First, write 0 in every square.
* For each i=1,2,...,N, choose an integer k_i (0\leq k_i\leq M), and add 1 to each of the leftmost k_i squares in the i-th row.
* For each j=1,2,...,M, choose an integer l_j (0\leq l_j\leq N), and add 1 to each of the topmost l_j squares in the j-th column.

Now we have a grid where each square contains 0, 1, or 2. Find the number of different grids that can be made this way, modulo 998244353. We consider two grids different when there exists a square with different integers.

Constraints

* 1 \leq N,M \leq 5\times 10^5
* N and M are integers.

Input

Input is given from Standard Input in the following format:

N M

Output

Print the number of different grids that can be made, modulo 998244353.

Examples

Input

1 2

Output

8

Input

2 3

Output

234

Input

10 7

Output

995651918

Input

314159 265358

Output

70273732

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define LL long long
#define N 500011
LL n,m,fac[N],inv[N],ans;
LL q_pow(LL a,LL b){
	LL res=1;
	while(b){
		if(b&1ll) res=res*a%MOD;
		b>>=1ll;
		a=a*a%MOD;
	}
	return res;
}
LL C(LL x,LL y){
	if(x<y) return 0;
	if(!y) return 1;
	return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
int main(){
	scanf("%lld%lld",&n,&m);
	inv[0]=fac[0]=inv[1]=fac[1]=1;
	for(int i=1;i<=500000;i++) fac[i]=fac[i-1]*i%MOD;
	inv[500000]=q_pow(fac[500000],MOD-2);
	for(int i=499999;i>=2;i--) inv[i]=inv[i+1]*(i+1)%MOD;
	int typ=1;
	int nn=min(n,m);
	for(int i=0;i<=nn;i++){
		ans=(ans+typ*C(n,i)*C(m,i)%MOD*q_pow(m+1,n-i)%MOD*q_pow(n+1,m-i)%MOD*fac[i]%MOD)%MOD;
		if(ans<0) ans+=MOD;
		typ=typ*-1;
	}
	printf("%lld\n",ans);
}
```


### Prompt

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

Takahashi received otoshidama (New Year's money gifts) from N of his relatives.

You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative.

For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins.

If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?

Constraints

* 2 \leq N \leq 10
* u_i = `JPY` or `BTC`.
* If u_i = `JPY`, x_i is an integer such that 1 \leq x_i \leq 10^8.
* If u_i = `BTC`, x_i is a decimal with 8 decimal digits, such that 0.00000001 \leq x_i \leq 100.00000000.

Input

Input is given from Standard Input in the following format:

N
x_1 u_1
x_2 u_2
:
x_N u_N

Output

If the gifts are worth Y yen in total, print the value Y (not necessarily an integer).

Output will be judged correct when the absolute or relative error from the judge's output is at most 10^{-5}.

Examples

Input

2
10000 JPY
0.10000000 BTC

Output

48000.0

Input

3
100000000 JPY
100.00000000 BTC
0.00000001 BTC

Output

138000000.0038

### Response

```cpp
#include<iostream>

int main() {
	int n;
	std::cin >> n;
	double ans = 0, x;
	char u[4];
	for (int i = 0; i < n; i++) {
		std::cin >> x >> u;
		if (u[0] == 'B')x *= 380000;
		ans += x;
	}

	printf("%lf\n", ans);
}
```


### Prompt

Create a solution in Cpp for the following problem:

Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems.

You are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 distinct leaves u, v and any real number x and add x to values written on all edges on the simple path between u and v.

For example, on the picture below you can see the result of applying two operations to the graph: adding 2 on the path from 7 to 6, and then adding -0.5 on the path from 4 to 5.

<image>

Is it true that for any configuration of real numbers written on edges, we can achieve it with a finite number of operations?

Leaf is a node of a tree of degree 1. Simple path is a path that doesn't contain any node twice.

Input

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

Each of the next n-1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v), meaning that there is an edge between nodes u and v. It is guaranteed that these edges form a tree.

Output

If there is a configuration of real numbers written on edges of the tree that we can't achieve by performing the operations, output "NO".

Otherwise, output "YES".

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

Examples

Input

2
1 2

Output

YES

Input

3
1 2
2 3

Output

NO

Input

5
1 2
1 3
1 4
2 5

Output

NO

Input

6
1 2
1 3
1 4
2 5
2 6

Output

YES

Note

In the first example, we can add any real x to the value written on the only edge (1, 2).

<image>

In the second example, one of configurations that we can't reach is 0 written on (1, 2) and 1 written on (2, 3).

<image>

Below you can see graphs from examples 3, 4:

<image> <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
vector<int> G[1024];
vector<pair<pair<int, int>, int>> e, ans, out;
int dfs(int u, int p) {
  for (int v : G[u])
    if (v != p) return dfs(v, u);
  return u;
}
int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v, val;
    cin >> u >> v >> val;
    G[u].push_back(v);
    G[v].push_back(u);
    e.push_back({{u, v}, val / 2});
  }
  for (int i = 1; i <= n; i++) {
    if (G[i].size() == 2) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  for (auto p : e) {
    int u = p.first.first, v = p.first.second, val = p.second;
    vector<int> x, y;
    for (int w : G[u]) {
      if (x.size() == 2) break;
      if (w != v) x.push_back(w);
    }
    for (int w : G[v]) {
      if (y.size() == 2) break;
      if (w != u) y.push_back(w);
    }
    int a, b, c, d;
    a = b = u, c = d = v;
    if (x.size()) a = dfs(x[0], u), b = dfs(x[1], u);
    if (y.size()) c = dfs(y[0], v), d = dfs(y[1], v);
    ans.push_back({{a, c}, val});
    ans.push_back({{b, d}, val});
    ans.push_back({{a, b}, -val});
    ans.push_back({{c, d}, -val});
  }
  for (auto p : ans) {
    if (p.first.first != p.first.second) out.push_back(p);
  }
  cout << out.size() << endl;
  for (auto p : out)
    cout << p.first.first << " " << p.first.second << " " << p.second << endl;
}

```


### Prompt

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

Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it.

He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles.

Input

The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≤ ai ≤ 1000) — the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists.

Output

Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.

Examples

Input

1 1 1 1 1 1

Output

6

Input

1 2 1 2 1 2

Output

13

Note

This is what Gerald's hexagon looks like in the first sample:

<image>

And that's what it looks like in the second sample:

<image>

### Response

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

```


### Prompt

Please create a solution in Cpp to the following problem:

Rumors say that one of Kamal-ol-molk's paintings has been altered. A rectangular brush has been moved right and down on the painting.

Consider the painting as a n × m rectangular grid. At the beginning an x × y rectangular brush is placed somewhere in the frame, with edges parallel to the frame, (1 ≤ x ≤ n, 1 ≤ y ≤ m). Then the brush is moved several times. Each time the brush is moved one unit right or down. The brush has been strictly inside the frame during the painting. The brush alters every cell it has covered at some moment.

You have found one of the old Kamal-ol-molk's paintings. You want to know if it's possible that it has been altered in described manner. If yes, you also want to know minimum possible area of the brush.

Input

The first line of input contains two integers n and m, (1 ≤ n, m ≤ 1000), denoting the height and width of the painting.

The next n lines contain the painting. Each line has m characters. Character 'X' denotes an altered cell, otherwise it's showed by '.'. There will be at least one altered cell in the painting.

Output

Print the minimum area of the brush in a line, if the painting is possibly altered, otherwise print  - 1.

Examples

Input

4 4
XX..
XX..
XXXX
XXXX

Output

4

Input

4 4
....
.XXX
.XXX
....

Output

2

Input

4 5
XXXX.
XXXX.
.XX..
.XX..

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int H, W;
string S[2001];
int sx, sy;
int SS[2002][2002];
int okok(int sy, int sx, int h, int w) {
  int a = SS[sy + h][sx + w] - SS[sy + h][sx] - SS[sy][sx + w] + SS[sy][sx];
  return a == w * h;
}
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> H >> W;
  for (y = 0; y < H; y++) cin >> S[y];
  sx = sy = -1;
  for (y = 0; y < H; y++)
    for (x = 0; x < W; x++)
      if (sy == -1 && S[y][x] == 'X') sy = y, sx = x;
  for (y = 0; y < H; y++)
    for (x = 0; x < W; x++)
      if (S[y][x] == 'X' && (y < sy || x < sx)) return (void)printf("-1\n");
  for (y = 0; y < H; y++) {
    for (x = 0; x < W; x++) SS[y + 1][x + 1] = SS[y + 1][x] + (S[y][x] == 'X');
    for (x = 0; x < W; x++) SS[y + 1][x + 1] += SS[y][x + 1];
  }
  int mi = 1 << 30;
  int w, h;
  for (h = 1; h <= H; h++)
    for (w = 1; w <= W; w++)
      if (okok(sy, sx, h, w) && h * w < mi) {
        int ng = 0;
        int tp = w * h;
        x = sx, y = sy;
        while (1) {
          int mr = 0, md = 0;
          if (x + w < W && S[y][x + w] == 'X') mr = 1;
          if (y + h < H && S[y + h][x] == 'X') md = 1;
          if (mr == md) break;
          if (mr) {
            tp += h;
            x++;
          } else {
            tp += w;
            y++;
          }
        }
        if (tp == SS[H][W]) mi = h * w;
      }
  if (mi == 1 << 30)
    (void)printf("-1\n");
  else
    (void)printf("%d\n", mi);
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false);
  for (i = 0; i < argc - 1; i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < s.size(); i++) ungetc(s[s.size() - 1 - i], stdin);
  solve();
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).

A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen.

Write a program that, when S is given, prints the price of the corresponding bowl of ramen.

Constraints

* S is a string of length 3.
* Each character in S is `o` or `x`.

Input

Input is given from Standard Input in the following format:

S

Output

Print the price of the bowl of ramen corresponding to S.

Examples

Input

oxo

Output

900

Input

ooo

Output

1000

Input

xxx

Output

700

### Response

```cpp
#include<stdio.h>
int main()
{
    char s[5];
    scanf("%s",s);
    int n=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='o') n++;
    }
    printf("%d00\n",n+7);
}

```


### Prompt

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

The Little Elephant loves to play with color cards.

He has n cards, each has exactly two colors (the color of the front side and the color of the back side). Initially, all the cards lay on the table with the front side up. In one move the Little Elephant can turn any card to the other side. The Little Elephant thinks that a set of cards on the table is funny if at least half of the cards have the same color (for each card the color of the upper side is considered).

Help the Little Elephant to find the minimum number of moves needed to make the set of n cards funny.

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of the cards. The following n lines contain the description of all cards, one card per line. The cards are described by a pair of positive integers not exceeding 109 — colors of both sides. The first number in a line is the color of the front of the card, the second one — of the back. The color of the front of the card may coincide with the color of the back of the card.

The numbers in the lines are separated by single spaces.

Output

On a single line print a single integer — the sought minimum number of moves. If it is impossible to make the set funny, print -1.

Examples

Input

3
4 7
4 7
7 4

Output

0

Input

5
4 7
7 4
2 11
9 7
1 1

Output

2

Note

In the first sample there initially are three cards lying with colors 4, 4, 7. Since two of the three cards are of the same color 4, you do not need to change anything, so the answer is 0.

In the second sample, you can turn the first and the fourth cards. After that three of the five cards will be of color 7.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
map<int, int> m1;
map<int, int> m2;
int main() {
  int n, u, v;
  scanf("%d", &n);
  int ans = n + 10;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &u, &v);
    if (u != v) m1[u]++;
    m1[v]++;
    m2[u]++;
    if (m1[u] >= (n + 1) / 2) ans = min(ans, max(0, (1 + n) / 2 - m2[u]));
    if (m1[v] >= (n + 1) / 2) ans = min(ans, max(0, (1 + n) / 2 - m2[v]));
  }
  if (ans > n)
    printf("-1\n");
  else
    printf("%d\n", ans);
  return 0;
}

```


### Prompt

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

Students went into a class to write a test and sat in some way. The teacher thought: "Probably they sat in this order to copy works of each other. I need to rearrange them in such a way that students that were neighbors are not neighbors in a new seating."

The class can be represented as a matrix with n rows and m columns with a student in each cell. Two students are neighbors if cells in which they sit have a common side.

Let's enumerate students from 1 to n·m in order of rows. So a student who initially sits in the cell in row i and column j has a number (i - 1)·m + j. You have to find a matrix with n rows and m columns in which all numbers from 1 to n·m appear exactly once and adjacent numbers in the original matrix are not adjacent in it, or determine that there is no such matrix.

Input

The only line contains two integers n and m (1 ≤ n, m ≤ 105; n·m ≤ 105) — the number of rows and the number of columns in the required matrix.

Output

If there is no such matrix, output "NO" (without quotes).

Otherwise in the first line output "YES" (without quotes), and in the next n lines output m integers which form the required matrix.

Examples

Input

2 4

Output

YES
5 4 7 2
3 6 1 8

Input

2 1

Output

NO

Note

In the first test case the matrix initially looks like this:

    1 2 3 4
    5 6 7 8

It's easy to see that there are no two students that are adjacent in both matrices.

In the second test case there are only two possible seatings and in both of them students with numbers 1 and 2 are neighbors.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int SZ = 1000010, INF = 0x7FFFFFFF;
const double EPS = 1e-9;
int arr[SZ];
int n, m;
void init() {
  for (int i = 0; i < n * m; ++i) arr[i] = i + 1;
}
bool chk(int row, int col, int val) {
  if (row != 0 && arr[(row - 1) * m + col] == val) return 1;
  if (col != 0 && arr[row * m + col - 1] == val) return 1;
  if (row != (m - 1) && arr[row * m + col + 1] == val) return 1;
  if (row != (n - 1) && arr[(row + 1) * m + col] == val) return 1;
  return 0;
}
bool work() {
  clock_t bg = clock();
  for (;;) {
    clock_t end = clock();
    if (end - bg > 1000) break;
    init();
    random_shuffle(arr, arr + n * m);
    int ok = 1;
    for (int i = 0; i < n * m; ++i) {
      int row = i / m;
      int col = i % m;
      if (chk(row, col, arr[i] - m)) {
        ok = 0;
        break;
      }
      if (chk(row, col, arr[i] - 1)) {
        ok = 0;
        break;
      }
      if (chk(row, col, arr[i] + 1)) {
        ok = 0;
        break;
      }
      if (chk(row, col, arr[i] + m)) {
        ok = 0;
        break;
      }
    }
    if (ok) return 1;
  }
  return 0;
}
void show() {
  for (int i = 0; i < n * m; ++i) {
    cout << arr[i];
    if (i % m == m - 1)
      cout << endl;
    else
      cout << " ";
  }
}
void shift() {
  for (int i = 1; i < n; i += 2) {
    int a = arr[i * m], b = arr[i * m + 1];
    for (int j = m - 1; j > 1; --j) {
      arr[i * m + (j + 2) % m] = arr[i * m + j];
    }
    arr[i * m + 2] = a, arr[i * m + 3] = b;
  }
  for (int j = 1; j < m; j += 2) {
    int a = arr[j];
    for (int i = 1; i < n; ++i) {
      arr[(i - 1) * m + j] = arr[i * m + j];
    }
    arr[(n - 1) * m + j] = a;
  }
}
void shift2() {
  for (int i = 1; i < n; i += 2) {
    int a = arr[i * m];
    for (int j = m - 1; j > 0; --j) {
      arr[i * m + (j + 1) % m] = arr[i * m + j];
    }
    arr[i * m + 1] = a;
  }
  for (int j = 1; j < m; j += 2) {
    int a = arr[j], b = arr[1 * m + j];
    for (int i = n - 1; i > 1; --i) {
      arr[((i + 2) % n) * m + j] = arr[i * m + j];
    }
    arr[2 * m + j] = a, arr[3 * m + j] = b;
  }
}
int main() {
  std::ios::sync_with_stdio(0);
  cin >> n >> m;
  if (n >= 2 && m >= 4) {
    cout << "YES" << endl;
    init();
    shift();
    show();
  } else if (n >= 4 && m >= 2) {
    cout << "YES" << endl;
    init();
    shift2();
    show();
  } else {
    if (work()) {
      cout << "YES" << endl;
      show();
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

You are given two arrays A and B, each of size n. The error, E, between these two arrays is defined <image>. You have to perform exactly k1 operations on array A and exactly k2 operations on array B. In one operation, you have to choose one element of the array and increase or decrease it by 1.

Output the minimum possible value of error after k1 operations on array A and k2 operations on array B have been performed.

Input

The first line contains three space-separated integers n (1 ≤ n ≤ 103), k1 and k2 (0 ≤ k1 + k2 ≤ 103, k1 and k2 are non-negative) — size of arrays and number of operations to perform on A and B respectively.

Second line contains n space separated integers a1, a2, ..., an ( - 106 ≤ ai ≤ 106) — array A.

Third line contains n space separated integers b1, b2, ..., bn ( - 106 ≤ bi ≤ 106)— array B.

Output

Output a single integer — the minimum possible value of <image> after doing exactly k1 operations on array A and exactly k2 operations on array B.

Examples

Input

2 0 0
1 2
2 3

Output

2

Input

2 1 0
1 2
2 2

Output

0

Input

2 5 7
3 4
14 4

Output

1

Note

In the first sample case, we cannot perform any operations on A or B. Therefore the minimum possible error E = (1 - 2)2 + (2 - 3)2 = 2.

In the second sample case, we are required to perform exactly one operation on A. In order to minimize error, we increment the first element of A by 1. Now, A = [2, 2]. The error is now E = (2 - 2)2 + (2 - 2)2 = 0. This is the minimum possible error obtainable.

In the third sample case, we can increase the first element of A to 8, using the all of the 5 moves available to us. Also, the first element of B can be reduced to 8 using the 6 of the 7 available moves. Now A = [8, 4] and B = [8, 4]. The error is now E = (8 - 8)2 + (4 - 4)2 = 0, but we are still left with 1 move for array B. Increasing the second element of B to 5 using the left move, we get B = [8, 5] and E = (8 - 8)2 + (4 - 5)2 = 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1e5 + 4;
int main() {
  int n, k1, k2;
  scanf("%d", &n);
  scanf("%d", &k1);
  scanf("%d", &k2);
  int a[n], b[n];
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  multiset<int, greater<int>> st;
  for (int i = 0; i < n; i++) st.insert(abs(a[i] - b[i]));
  k1 += k2;
  while (st.size()) {
    if (k1 == 0) break;
    auto it = *st.begin();
    st.erase(st.find(it));
    if (it) {
      it--;
      st.insert(it);
      k1--;
    }
  }
  long long ans = 0;
  for (int it : st) {
    long long here = 1LL * it * it;
    ans += here;
  }
  ans += (k1 % 2);
  printf("%lld", ans);
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

Polycarp has x of red and y of blue candies. Using them, he wants to make gift sets. Each gift set contains either a red candies and b blue candies, or a blue candies and b red candies. Any candy can belong to at most one gift set.

Help Polycarp to find the largest number of gift sets he can create.

For example, if x = 10, y = 12, a = 5, and b = 2, then Polycarp can make three gift sets:

  * In the first set there will be 5 red candies and 2 blue candies;
  * In the second set there will be 5 blue candies and 2 red candies;
  * In the third set will be 5 blue candies and 2 red candies.

Note that in this example there is one red candy that Polycarp does not use in any gift set.

Input

The first line contains an integer t (1 ≤ t ≤ 10^4). Then t test cases follow.

Each test case consists of a single string containing four integers x, y, a, and b (1 ≤ x, y, a, b ≤ 10^9).

Output

For each test case, output one number — the maximum number of gift sets that Polycarp can make.

Example

Input

9
10 12 2 5
1 1 2 2
52 311 13 27
1000000000 1000000000 1 1
1000000000 1 1 1000000000
1 1000000000 1000000000 1
1 2 1 1
7 8 1 2
4 1 2 3

Output

3
0
4
1000000000
1
1
1
5
0

### Response

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

#define int int64_t
#define sz(x) (int) x.size()
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define pi pair<int, int>

int x, y, a, b;

bool Check(int u) {
  int xx = x - a * u;
  int yy = y - a * u;
  if (a == b) {
    return (xx >= 0 && yy >= 0);
  }
  if (xx < 0 || yy < 0) return false;
  xx /= (b - a);
  yy /= (b - a);
  return (xx + yy >= u);
}

void solve() {
  cin >> x >> y >> a >> b;
  if (a > b) swap(a, b);
  int lo = 0, hi = (int) 1.1e9;
  while (lo < hi) {
    int mid = (lo + hi) >> 1;
    if (Check(mid + 1)) lo = mid + 1;
    else hi = mid;
  }
  cout << lo << "\n";
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    solve();
  }
  return 0;
}
```


### Prompt

Please formulate a Cpp solution to the following problem:

There are n boxes with colored balls on the table. Colors are numbered from 1 to n. i-th box contains ai balls, all of which have color i. You have to write a program that will divide all balls into sets such that:

  * each ball belongs to exactly one of the sets,
  * there are no empty sets,
  * there is no set containing two (or more) balls of different colors (each set contains only balls of one color),
  * there are no two sets such that the difference between their sizes is greater than 1.

Print the minimum possible number of sets.

Input

The first line contains one integer number n (1 ≤ n ≤ 500).

The second line contains n integer numbers a1, a2, ... , an (1 ≤ ai ≤ 109).

Output

Print one integer number — the minimum possible number of sets.

Examples

Input

3
4 7 8

Output

5

Input

2
2 7

Output

4

Note

In the first example the balls can be divided into sets like that: one set with 4 balls of the first color, two sets with 3 and 4 balls, respectively, of the second color, and two sets with 4 balls of the third color.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
int sz(const T &a) {
  return int(a.size());
}
const int MAXN = 501;
ll arr[MAXN];
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<ll> nums;
  for (ll i = 1; (i - 1) * (i - 1) <= arr[0]; i++) {
    if ((arr[0] + i - 1) / i >= i * ((arr[0] + i - 1) / i) - arr[0])
      nums.push_back(i);
    ll ne = arr[0] / i;
    if (ne > 0 &&
        (arr[0] + ne - 1) / ne >= ne * ((arr[0] + ne - 1) / ne) - arr[0])
      nums.push_back(ne);
    ne += 1;
    while (ne > 0 &&
           (arr[0] + ne - 1) / ne >= ne * ((arr[0] + ne - 1) / ne) - arr[0]) {
      nums.push_back(ne);
      ne++;
    }
  }
  for (int i = 1; i < n; i++) {
    vector<ll> te;
    for (auto x : nums)
      if ((arr[i] + x - 1) / x >= x * ((arr[i] + x - 1) / x) - arr[i])
        te.push_back(x);
    nums = te;
  }
  ll best = *max_element(nums.begin(), nums.end());
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (arr[i] + best - 1) / best;
  }
  printf("%lli\n", ans);
  return 0;
}

```


### Prompt

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

Mishka has got n empty boxes. For every i (1 ≤ i ≤ n), i-th box is a cube with side length ai.

Mishka can put a box i into another box j if the following conditions are met:

  * i-th box is not put into another box;
  * j-th box doesn't contain any other boxes;
  * box i is smaller than box j (ai < aj).

Mishka can put boxes into each other an arbitrary number of times. He wants to minimize the number of visible boxes. A box is called visible iff it is not put into some another box.

Help Mishka to determine the minimum possible number of visible boxes!

Input

The first line contains one integer n (1 ≤ n ≤ 5000) — the number of boxes Mishka has got.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is the side length of i-th box.

Output

Print the minimum possible number of visible boxes.

Examples

Input

3
1 2 3

Output

1

Input

4
4 2 4 3

Output

2

Note

In the first example it is possible to put box 1 into box 2, and 2 into 3.

In the second example Mishka can put box 2 into box 3, and box 4 into box 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int ans = -1e9;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    mp[x]++;
    ans = max(mp[x], ans);
  }
  cout << ans << endl;
}

```