### Prompt

Generate a cpp solution to the following problem:

For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.

* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.
* dump($L$, $R$): Print elements $x$ in $S$ such that $L \leq x \leq R$.

Constraints

* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$
* The total number of elements printed by dump operations does not exceed $1,000,000$

Input

The input is given in the following format.

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

Each query $query_i$ is given by

0 $x$

or

1 $x$

or

2 $x$

or

3 $L$ $R$

where the first digits 0, 1, 2 and 3 represent insert, find, delete and dump operations respectively.

Output

For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.
For each dump operation, print the corresponding elements in ascending order. Print an element in a line.

Example

Input

9
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 4
3 2 4

Output

1
2
3
1
0
1
3
3
4

### Response

```cpp
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int q;cin>>q;
    set<int> st;
    rep(i,0,q){
        int a,b;cin>>a>>b;
        if(a==0){
            st.insert(b);
            cout<<st.size()<<endl;
        }else if(a==1){
            cout<<((st.find(b)==st.end())?0:1)<<endl;
        }else if(a==2){
            st.erase(b);
        }else {
            int r;cin>>r;
            auto it=st.lower_bound(b);
            for(;it!=st.end()&&*it<=r;it++){
                cout<<*it<<endl;
            }

        }
    }

}

/*

*/

```


### Prompt

Generate a Cpp solution to the following problem:

Panic is rising in the committee for doggo standardization — the puppies of the new brood have been born multi-colored! In total there are 26 possible colors of puppies in the nature and they are denoted by letters from 'a' to 'z' inclusive.

The committee rules strictly prohibit even the smallest diversity between doggos and hence all the puppies should be of the same color. Thus Slava, the committee employee, has been assigned the task to recolor some puppies into other colors in order to eliminate the difference and make all the puppies have one common color.

Unfortunately, due to bureaucratic reasons and restricted budget, there's only one operation Slava can perform: he can choose a color x such that there are currently at least two puppies of color x and recolor all puppies of the color x into some arbitrary color y. Luckily, this operation can be applied multiple times (including zero).

For example, if the number of puppies is 7 and their colors are represented as the string "abababc", then in one operation Slava can get the results "zbzbzbc", "bbbbbbc", "aaaaaac", "acacacc" and others. However, if the current color sequence is "abababc", then he can't choose x='c' right now, because currently only one puppy has the color 'c'.

Help Slava and the committee determine whether it is possible to standardize all the puppies, i.e. after Slava's operations all the puppies should have the same color.

Input

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

The second line contains a string s of length n consisting of lowercase Latin letters, where the i-th symbol denotes the i-th puppy's color.

Output

If it's possible to recolor all puppies into one color, print "Yes".

Otherwise print "No".

Output the answer without quotation signs.

Examples

Input

6
aabddc

Output

Yes

Input

3
abc

Output

No

Input

3
jjj

Output

Yes

Note

In the first example Slava can perform the following steps:

  1. take all puppies of color 'a' (a total of two) and recolor them into 'b';
  2. take all puppies of color 'd' (a total of two) and recolor them into 'c';
  3. take all puppies of color 'b' (three puppies for now) and recolor them into 'c'.

In the second example it's impossible to recolor any of the puppies.

In the third example all the puppies' colors are the same; thus there's no need to recolor anything.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int i = 0;
  if (n == 1) {
    cout << "Yes";
    return 0;
  }
  sort(s.begin(), s.end());
  while (i < n - 1) {
    if (s[i] == s[i + 1]) {
      cout << "Yes";
      return 0;
    }
    i++;
  }
  cout << "No";
}

```


### Prompt

Create a solution in cpp for the following problem:

You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:

* The string does not contain characters other than `A`, `C`, `G` and `T`.
* The string does not contain `AGC` as a substring.
* The condition above cannot be violated by swapping two adjacent characters once.

Constraints

* 3 \leq N \leq 100

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of strings of length N that satisfy the following conditions, modulo 10^9+7.

Examples

Input

3

Output

61

Input

4

Output

230

Input

100

Output

388130742

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  ll dp[n+1][64];
  rep(i,0,n+1){
    rep(j,0,64){
      dp[i][j]=0;
    }
  }
  dp[0][63]=1;
  rep(i,0,n){
    rep(j,0,64){
      int p=j%4;
      int q=j/4%4;
      int r=j/16%4;
      if(p==0 && q==1 && r==2) continue;
      if(p==1 && q==0 && r==2) continue;
      if(p==0 && q==2 && r==1) continue;
      rep(k,0,4){
        if(p==0 && q==1 && k==2) continue;
        if(q==0 && r==1 && k==2) continue;
        if(q==1 && r==0 && k==2) continue;
        if(q==0 && r==2 && k==1) continue;
        if(p==0 && r==1 && k==2) continue;
        dp[i+1][q+r*4+k*16]+=dp[i][j];
        dp[i+1][q+r*4+k*16]%=mod;
      }
    }
  }
  ll ans=0;
  rep(i,0,64){
    ans+=dp[n][i];
    ans%=mod;
  }
  cout<<ans<<endl;
}
```


### Prompt

Create a solution in cpp for the following problem:

To get on the Shinkansen, you need two tickets, a "ticket" and a "limited express ticket". These are separate tickets because some of the routes may not use the Shinkansen, but for routes that use only the Shinkansen, one ticket can be used as both a ticket and a limited express ticket. It may also be issued.

Automatic ticket gates must read these tickets and open the gate only when the correct ticket is inserted. Create a program that determines whether one "ticket" and one "limited express ticket" or both, or one "boarding / limited express ticket" has been inserted, and determines whether the door of the automatic ticket gate is open or closed. please do it.

input

The input is given in the following format.

b1 b2 b3

The input consists of one line and contains three integers separated by one space. b1 indicates the state in which the "ticket" is inserted, b2 indicates the state in which the "limited express ticket" is inserted, and b3 indicates the state in which the "boarding / limited express ticket" is inserted. The turned-in state is represented by 0 or 1, where 0 indicates a non-charged state, and 1 indicates a loaded state. However, the combination of expected input states is limited to the following cases.

Input | Input state | Door operation for input
--- | --- | ---
1 0 0 | Insert only "ticket" | Close
0 1 0 | Only "Limited Express Ticket" is introduced | Close
1 1 0 | Introducing "tickets" and "express tickets" | Open
0 0 1 | Introducing "Boarding / Limited Express Tickets" | Open
0 0 0 | No input | Close

output

Outputs Open or Close, which indicates the opening and closing of the automatic ticket gate, on one line.

Example

Input

0 0 1

Output

Open

### Response

```cpp
#include<cstdio>

#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n)
using namespace std;

int main(void){

	int b1,b2,b3;

	scanf("%d%d%d", &b1, &b2, &b3);

	if(b1 == b2 && b1 != b3)
		puts("Open");
	else
		puts("Close");

	return 0;
}
```


### Prompt

Generate a Cpp solution to the following problem:

Vasya is developing his own programming language VPL (Vasya Programming Language). Right now he is busy making the system of exceptions. He thinks that the system of exceptions must function like that.

The exceptions are processed by try-catch-blocks. There are two operators that work with the blocks:

  1. The try operator. It opens a new try-catch-block.
  2. The catch(<exception_type>, <message>) operator. It closes the try-catch-block that was started last and haven't yet been closed. This block can be activated only via exception of type <exception_type>. When we activate this block, the screen displays the <message>. If at the given moment there is no open try-catch-block, then we can't use the catch operator.

The exceptions can occur in the program in only one case: when we use the throw operator. The throw(<exception_type>) operator creates the exception of the given type.

Let's suggest that as a result of using some throw operator the program created an exception of type a. In this case a try-catch-block is activated, such that this block's try operator was described in the program earlier than the used throw operator. Also, this block's catch operator was given an exception type a as a parameter and this block's catch operator is described later that the used throw operator. If there are several such try-catch-blocks, then the system activates the block whose catch operator occurs earlier than others. If no try-catch-block was activated, then the screen displays message "Unhandled Exception".

To test the system, Vasya wrote a program that contains only try, catch and throw operators, one line contains no more than one operator, the whole program contains exactly one throw operator.

Your task is: given a program in VPL, determine, what message will be displayed on the screen.

Input

The first line contains a single integer: n (1 ≤ n ≤ 105) the number of lines in the program. Next n lines contain the program in language VPL. Each line contains no more than one operator. It means that input file can contain empty lines and lines, consisting only of spaces.

The program contains only operators try, catch and throw. It is guaranteed that the program is correct. It means that each started try-catch-block was closed, the catch operators aren't used unless there is an open try-catch-block. The program has exactly one throw operator. The program may have spaces at the beginning of a line, at the end of a line, before and after a bracket, a comma or a quote mark.

The exception type is a nonempty string, that consists only of upper and lower case english letters. The length of the string does not exceed 20 symbols. Message is a nonempty string, that consists only of upper and lower case english letters, digits and spaces. Message is surrounded with quote marks. Quote marks shouldn't be printed. The length of the string does not exceed 20 symbols.

Length of any line in the input file does not exceed 50 symbols.

Output

Print the message the screen will show after the given program is executed.

Examples

Input

8
try
    try
        throw ( AE )
    catch ( BE, "BE in line 3")

    try
    catch(AE, "AE in line 5")
catch(AE,"AE somewhere")

Output

AE somewhere

Input

8
try
    try
        throw ( AE )
    catch ( AE, "AE in line 3")

    try
    catch(BE, "BE in line 5")
catch(AE,"AE somewhere")

Output

AE in line 3

Input

8
try
    try
        throw ( CE )
    catch ( BE, "BE in line 3")

    try
    catch(AE, "AE in line 5")
catch(AE,"AE somewhere")

Output

Unhandled Exception

Note

In the first sample there are 2 try-catch-blocks such that try operator is described earlier than throw operator and catch operator is described later than throw operator: try-catch(BE,"BE in line 3") and try-catch(AE,"AE somewhere"). Exception type is AE, so the second block will be activated, because operator catch(AE,"AE somewhere") has exception type AE as parameter and operator catch(BE,"BE in line 3") has exception type BE.

In the second sample there are 2 try-catch-blocks such that try operator is described earlier than throw operator and catch operator is described later than throw operator: try-catch(AE,"AE in line 3") and try-catch(AE,"AE somewhere"). Exception type is AE, so both blocks can be activated, but only the first one will be activated, because operator catch(AE,"AE in line 3") is described earlier than catch(AE,"AE somewhere")

In the third sample there is no blocks that can be activated by an exception of type CE.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, pr[1 << 17], id, en[1 << 17];
char cmd[1 << 17], s[1 << 17];
string s1[1 << 17], s2[1 << 17], exc;
int st[1 << 17], ss;
int main() {
  scanf("%d\n", &n);
  int top = 0;
  for (int x = 0; x < n; x++) {
    gets(s);
    int i = 0;
    while (s[i] == ' ') i++;
    if (s[i] == 't' && s[i + 1] == 'r') {
      cmd[x] = 1;
    }
    if (s[i] == 't' && s[i + 1] == 'h') {
      id = x;
      i += 5;
      while (s[i] == ' ') i++;
      i++;
      while (s[i] == ' ') i++;
      int j = i;
      while (s[j] != ' ' && s[j] != ')' && s[j] != ',') j++;
      exc = string(s + i, s + j);
    }
    if (s[i] == 'c') {
      cmd[x] = 2;
      i += 5;
      while (s[i] == ' ') i++;
      i++;
      while (s[i] == ' ') i++;
      int j = i;
      while (s[j] != ' ' && s[j] != ')' && s[j] != ',') j++;
      s1[x] = string(s + i, s + j);
      i = j;
      while (s[i] != '"') i++;
      j = i + 1;
      while (s[j] != '"') j++;
      s2[x] = string(s + i + 1, s + j);
    }
  }
  for (int i = 0; i < n; i++) {
    if (!cmd[i]) continue;
    if (cmd[i] == 2) {
      ss--;
      en[st[ss]] = i;
    } else {
      if (ss)
        pr[i] = st[ss - 1];
      else
        pr[i] = -1;
      st[ss++] = i;
    }
  }
  int cp = id;
  while (cp >= 0 && (cmd[cp] != 1 || en[cp] <= id)) cp--;
  while (cp >= 0) {
    int end = en[cp];
    if (s1[end] == exc) {
      puts(s2[end].c_str());
      return 0;
    }
    cp = pr[cp];
  }
  puts("Unhandled Exception");
  return 0;
}

```


### Prompt

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

Let us remind you part of the rules of Codeforces. The given rules slightly simplified, use the problem statement as a formal document.

In the beginning of the round the contestants are divided into rooms. Each room contains exactly n participants. During the contest the participants are suggested to solve five problems, A, B, C, D and E. For each of these problem, depending on when the given problem was solved and whether it was solved at all, the participants receive some points. Besides, a contestant can perform hacks on other contestants. For each successful hack a contestant earns 100 points, for each unsuccessful hack a contestant loses 50 points. The number of points for every contestant is represented by the sum of points he has received from all his problems, including hacks.

You are suggested to determine the leader for some room; the leader is a participant who has maximum points.

Input

The first line contains an integer n, which is the number of contestants in the room (1 ≤ n ≤ 50). The next n lines contain the participants of a given room. The i-th line has the format of "handlei plusi minusi ai bi ci di ei" — it is the handle of a contestant, the number of successful hacks, the number of unsuccessful hacks and the number of points he has received from problems A, B, C, D, E correspondingly. The handle of each participant consists of Latin letters, digits and underscores and has the length from 1 to 20 characters. There are the following limitations imposed upon the numbers:

  * 0 ≤ plusi, minusi ≤ 50;
  * 150 ≤ ai ≤ 500 or ai = 0, if problem A is not solved;
  * 300 ≤ bi ≤ 1000 or bi = 0, if problem B is not solved;
  * 450 ≤ ci ≤ 1500 or ci = 0, if problem C is not solved;
  * 600 ≤ di ≤ 2000 or di = 0, if problem D is not solved;
  * 750 ≤ ei ≤ 2500 or ei = 0, if problem E is not solved.

All the numbers are integer. All the participants have different handles. It is guaranteed that there is exactly one leader in the room (i.e. there are no two participants with the maximal number of points).

Output

Print on the single line the handle of the room leader.

Examples

Input

5
Petr 3 1 490 920 1000 1200 0
tourist 2 0 490 950 1100 1400 0
Egor 7 0 480 900 950 0 1000
c00lH4x0R 0 10 150 0 0 0 0
some_participant 2 1 450 720 900 0 0

Output

tourist

Note

The number of points that each participant from the example earns, are as follows:

  * Petr — 3860
  * tourist — 4140
  * Egor — 4030
  * c00lH4x0R —  - 350
  * some_participant — 2220

Thus, the leader of the room is tourist.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S = "";
  int T = -1000000007;
  int _;
  scanf("%d", &_);
  while (_--) {
    string s;
    int a, b, c, d, e, f, g;
    cin >> s >> a >> b >> c >> d >> e >> f >> g;
    if (T < 100 * a - 50 * b + c + d + e + f + g)
      T = 100 * a - 50 * b + c + d + e + f + g, S = s;
  }
  cout << S << endl;
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS).

Note that a bracket sequence is correct if it is possible to get a correct mathematical expression by adding "+"-s and "1"-s to it. For example, sequences "(())()", "()" and "(()(()))" are correct, while ")(", "(()" and "(()))(" are not. Each bracket in CBS has a pair. For example, in "(()(()))":

  * 1st bracket is paired with 8th,
  * 2d bracket is paired with 3d,
  * 3d bracket is paired with 2d,
  * 4th bracket is paired with 7th,
  * 5th bracket is paired with 6th,
  * 6th bracket is paired with 5th,
  * 7th bracket is paired with 4th,
  * 8th bracket is paired with 1st.

Polycarp's editor currently supports only three operations during the use of CBS. The cursor in the editor takes the whole position of one of the brackets (not the position between the brackets!). There are three operations being supported:

  * «L» — move the cursor one position to the left,
  * «R» — move the cursor one position to the right,
  * «D» — delete the bracket in which the cursor is located, delete the bracket it's paired to and all brackets between them (that is, delete a substring between the bracket in which the cursor is located and the one it's paired to).

After the operation "D" the cursor moves to the nearest bracket to the right (of course, among the non-deleted). If there is no such bracket (that is, the suffix of the CBS was deleted), then the cursor moves to the nearest bracket to the left (of course, among the non-deleted).

There are pictures illustrated several usages of operation "D" below.

<image>

All incorrect operations (shift cursor over the end of CBS, delete the whole CBS, etc.) are not supported by Polycarp's editor.

Polycarp is very proud of his development, can you implement the functionality of his editor?

Input

The first line contains three positive integers n, m and p (2 ≤ n ≤ 500 000, 1 ≤ m ≤ 500 000, 1 ≤ p ≤ n) — the number of brackets in the correct bracket sequence, the number of operations and the initial position of cursor. Positions in the sequence are numbered from left to right, starting from one. It is guaranteed that n is even.

It is followed by the string of n characters "(" and ")" forming the correct bracket sequence.

Then follow a string of m characters "L", "R" and "D" — a sequence of the operations. Operations are carried out one by one from the first to the last. It is guaranteed that the given operations never move the cursor outside the bracket sequence, as well as the fact that after all operations a bracket sequence will be non-empty.

Output

Print the correct bracket sequence, obtained as a result of applying all operations to the initial sequence.

Examples

Input

8 4 5
(())()()
RDLD

Output

()

Input

12 5 3
((()())(()))
RRDLD

Output

(()(()))

Input

8 8 8
(())()()
LLLLLLDD

Output

()()

Note

In the first sample the cursor is initially at position 5. Consider actions of the editor:

  1. command "R" — the cursor moves to the position 6 on the right;
  2. command "D" — the deletion of brackets from the position 5 to the position 6. After that CBS takes the form (())(), the cursor is at the position 5;
  3. command "L" — the cursor moves to the position 4 on the left;
  4. command "D" — the deletion of brackets from the position 1 to the position 4. After that CBS takes the form (), the cursor is at the position 1.

Thus, the answer is equal to ().

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 500000 + 10;
int n, m, p, nx[MAX_N], pr[MAX_N], pa[MAX_N];
char s[MAX_N], mov[MAX_N];
vector<int> l;
int main() {
  cin >> n >> m >> p;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    if (s[i] == '(') {
      l.push_back(i);
    } else {
      pa[i] = l[l.size() - 1];
      pa[l[l.size() - 1]] = i;
      l.pop_back();
    }
  }
  for (int i = 1; i <= n; i++) {
    nx[i] = i + 1;
    pr[i] = i - 1;
  }
  nx[0] = 1;
  pr[n + 1] = n;
  for (int i = 1; i <= m; i++) {
    cin >> mov[i];
    if (mov[i] == 'R') {
      p = nx[p];
    }
    if (mov[i] == 'L') {
      p = pr[p];
    }
    if (mov[i] == 'D') {
      int par = pa[p];
      if (s[p] == '(') {
        nx[pr[p]] = nx[par];
        pr[nx[par]] = pr[p];
        if (nx[par] <= n) {
          p = nx[par];
        } else {
          p = pr[p];
        }
      } else {
        nx[pr[par]] = nx[p];
        pr[nx[p]] = pr[par];
        if (nx[p] <= n) {
          p = nx[p];
        } else {
          p = pr[par];
        }
      }
    }
  }
  p = nx[0];
  while (true) {
    cout << s[p];
    p = nx[p];
    if (p > n) {
      cout << endl;
      break;
    }
  }
}

```


### Prompt

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

Imagine a board with n pins put into it, the i-th pin is located at (x_i, y_i). For simplicity, we will restrict the problem to the case where the pins are placed in vertices of a convex polygon.

Then, take a non-stretchable string of length l, and put it around all the pins. Place a pencil inside the string and draw a curve around the pins, trying to pull the string in every possible direction. The picture below shows an example of a string tied around the pins and pulled by a pencil (a point P).

<image>

Your task is to find an area inside this curve. Formally, for a given convex polygon S and a length l let's define a fiber shape F(S, l) as a set of points t such that the perimeter of the convex hull of S ∪ \\{t\} does not exceed l. Find an area of F(S, l).

Input

The first line contains two integers n and l (3 ≤ n ≤ 10^4; 1 ≤ l ≤ 8 ⋅ 10^5) — the number of vertices of the polygon S and the length of the string. Next n lines contain integers x_i and y_i (-10^5 ≤ x_i, y_i ≤ 10^5) — coordinates of polygon's vertices in counterclockwise order. All internal angles of the polygon are strictly less than π. The length l exceeds the perimeter of the polygon by at least 10^{-3}.

Output

Output a single floating-point number — the area of the fiber shape F(S, l). Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.

Examples

Input

3 4
0 0
1 0
0 1

Output

3.012712585980357

Input

4 5
0 0
1 0
1 1
0 1

Output

5.682061989789656

Input

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

Output

37.719371276930820

Note

The following pictures illustrate the example tests.

<image> <image>

<image>

### Response

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

template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x_=0, T y_=0) : x(x_), y(y_) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
	friend ostream& operator<<(ostream& os, P p) {
		return os << "(" << p.x << "," << p.y << ")"; }
};
template<class P>
pair<int, P> lineInter(P s1, P e1, P s2, P e2) {
	auto d = (e1 - s1).cross(e2 - s2);
	if (d == 0) // if parallel
		return {-(s1.cross(e1, s2) == 0), P(0, 0)};
	auto p = s2.cross(e1, e2), q = s2.cross(e2, s1);
	return {1, (s1 * p + e1 * q) / d};
}
template<class P>
vector<P> circleLine(P c, double r, P a, P b) {
	P ab = b - a, p = a + ab * (c-a).dot(ab) / ab.dist2();
	double s = a.cross(b, c), h2 = r*r - s*s / ab.dist2();
	if (h2 < 0) return {};
	if (h2 == 0) return {p};
	P h = ab.unit() * sqrt(h2);
	return {p - h, p + h};
}

using P = Point<double>;

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);

	int N; double L; cin >> N >> L;
	vector<P> pts(3*N);
	for (int i = 0; i < N; i++) {
		cin >> pts[i].x >> pts[i].y;
	}

	{
		P center = pts[0];
		double ang = (pts[0] - pts[N-1]).angle();
		for (int i = 0; i < N; i++) {
			pts[i] = pts[i] - center;
			pts[i] = pts[i].rotate(-ang);
		}
	}

	for (int i = 0; i < N; i++) {
		pts[2*N+i] = pts[N+i] = pts[i];
	}

	for (int i = 0; i < N; i++) {
		L -= (pts[i+1] - pts[i]).dist();
	}

	assert(L > 0);
	//for (int i = 0; i < N; i++) { cerr << i << ' ' << pts[i] << '\n'; }

	int lo = 0;
	int hi = 1;
	L += (pts[lo] + pts[hi]).dist();
	P cur_st;

	double ans = 0;
	while (lo < N+1) {
		//cerr << lo << ' ' << hi << ' ' << cur_st << '\n';
		P center = (pts[lo] + pts[hi]) / 2;
		P dir = pts[lo] - pts[hi];
		double ang = dir.angle();
		double major = L / 2;
		double minor = sqrt(major * major - dir.dist2() / 4);
		auto transform_pt = [&](P p) -> P {
			p = p - center;
			p = p.rotate(-ang);
			p.x /= major;
			p.y /= minor;
			return p;
		};
		auto untransform_pt = [&](P p) -> P {
			p.y *= minor;
			p.x *= major;
			p = p.rotate(ang);
			p = p + center;
			return p;
		};
		auto untransform_area = [&](double d) -> double {
			return d * minor * major;
		};

		P plo = transform_pt(pts[lo]);
		P plo1 = transform_pt(pts[lo+1]);
		P phi = transform_pt(pts[hi]);
		P phi1 = transform_pt(pts[hi+1]);

		P cndlo = circleLine(P(0,0), 1, plo, plo1)[1];
		P cndhi = circleLine(P(0,0), 1, phi, phi1)[0];
		double alo = (cndlo*-1).perp().angle();
		double ahi = (cndhi*-1).perp().angle();

		bool do_lo = alo < ahi;
		P nxt_st = untransform_pt(do_lo ? cndlo : cndhi);

		if (lo > 0) {
			P st = transform_pt(cur_st);
			double ast = (st*-1).perp().angle();
			double cur_val = untransform_area(((do_lo ? alo : ahi) - ast) / 2);

			// y dx from a to b
			auto seg_val = [&](P a, P b) -> double {
				return (b.x - a.x) * (b.y + a.y) / 2;
			};

			cur_val += seg_val(nxt_st, center) + seg_val(center, cur_st);
			ans += cur_val;
		}

		if (do_lo) {
			L -= (pts[lo+1] - pts[lo]).dist();
			lo++;
		} else {
			L += (pts[hi+1] - pts[hi]).dist();
			hi++;
		}
		cur_st = nxt_st;

		//cerr << lo << ' ' << hi << ' ' << cur_st << '\n';
	}

	cout << fixed << setprecision(15) << ans << '\n';

	return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

The first semester ended. You know, after the end of the first semester the holidays begin. On holidays Noora decided to return to Vičkopolis. As a modest souvenir for Leha, she brought a sausage of length m from Pavlopolis. Everyone knows that any sausage can be represented as a string of lowercase English letters, the length of which is equal to the length of the sausage.

Leha was very pleased with the gift and immediately ate the sausage. But then he realized that it was a quite tactless act, because the sausage was a souvenir! So the hacker immediately went to the butcher shop. Unfortunately, there was only another sausage of length n in the shop. However Leha was not upset and bought this sausage. After coming home, he decided to cut the purchased sausage into several pieces and number the pieces starting from 1 from left to right. Then he wants to select several pieces and glue them together so that the obtained sausage is equal to the sausage that Noora gave. But the hacker can glue two pieces together only when the number of the left piece is less than the number of the right piece. Besides he knows that if he glues more than x pieces, Noora will notice that he has falsified souvenir sausage and will be very upset. Of course Leha doesn’t want to upset the girl. The hacker asks you to find out whether he is able to cut the sausage he bought, and then glue some of the pieces so that Noora doesn't notice anything.

Formally, you are given two strings s and t. The length of the string s is n, the length of the string t is m. It is required to select several pairwise non-intersecting substrings from s, so that their concatenation in the same order as these substrings appear in s, is equal to the string t. Denote by f(s, t) the minimal number of substrings to be chosen so that their concatenation is equal to the string t. If it is impossible to choose such substrings, then f(s, t) = ∞. Leha really wants to know whether it’s true that f(s, t) ≤ x.

Input

The first line contains single integer n (1 ≤ n ≤ 105) — length of sausage bought by Leha, i.e. the length of the string s.

The second line contains string s of the length n consisting of lowercase English letters.

The third line contains single integer m (1 ≤ m ≤ n) — length of sausage bought by Noora, i.e. the length of the string t.

The fourth line contains string t of the length m consisting of lowercase English letters.

The fifth line contains single integer x (1 ≤ x ≤ 30) — the maximum number of pieces of sausage that Leha can glue so that Noora doesn’t notice anything.

Output

In the only line print "YES" (without quotes), if Leha is able to succeed in creating new sausage so that Noora doesn't notice anything. Otherwise print "NO" (without quotes).

Examples

Input

9
hloyaygrt
6
loyyrt
3

Output

YES

Input

9
hloyaygrt
6
loyyrt
2

Output

NO

Note

Let's consider the first sample.

In the optimal answer, Leha should cut the sausage he bought in the following way: hloyaygrt = h + loy + a + y + g + rt. Then he numbers received parts from 1 to 6:

  * h — number 1
  * loy — number 2
  * a — number 3
  * y — number 4
  * g — number 5
  * rt — number 6

Hereupon the hacker should glue the parts with numbers 2, 4 and 6 and get sausage loyygrt equal to one that is given by Noora. Thus, he will have to glue three pieces. Since x = 3 you should print "YES" (without quotes).

In the second sample both sausages coincide with sausages from the first sample. However since x = 2 you should print "NO" (without quotes).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
mt19937 twister(chrono::steady_clock().now().time_since_epoch().count());
const int mod = 1e9 + 7;
const int maxn = 2e5 + 88;
const int inf = 1e9 + 88;
const int logn = 22;
const int maxa = 3e6 + 88;
const char sgl[5] = {'a', 'e', 'i', 'o', 'u'};
const char sep = 'a' - 1;
int readint() {
  int cur;
  scanf("%d", &cur);
  return cur;
}
void maxi(int &a, int b) { a = max(a, b); }
void mini(int &a, int b) { a = min(a, b); }
int rnd(int l, int r) { return abs((int)twister()) % (r - l + 1) + l; }
string s, t, cur;
int dp[31][maxn];
int lcp[logn][maxn];
int suff[maxn], c[maxn], cursuff[maxn], curc[maxn], order[maxn];
int cnt[maxn];
int len[maxn];
void step(int h) {
  int i, l = cur.length();
  int no = 0;
  for (i = 0; i < l; i++) {
    cursuff[i] = suff[i] - (1 << h);
    if (cursuff[i] < 0) cursuff[i] += l;
    cnt[c[i]]++;
    no = max(no, c[i] + 1);
  }
  for (i = 1; i < no; i++) cnt[i] += cnt[i - 1];
  for (i = l - 1; i >= 0; i--) suff[--cnt[c[cursuff[i]]]] = cursuff[i];
  for (i = 0; i < no; i++) cnt[i] = 0;
  curc[suff[0]] = 0;
  no = 0;
  int last = suff[0] + (1 << h);
  if (last >= l) last -= l;
  for (i = 1; i < l; i++) {
    int now = suff[i] + (1 << h);
    if (now < 0) now += l;
    if (c[last] != c[now] || c[suff[i]] != c[suff[i - 1]]) no++;
    curc[suff[i]] = no;
    last = now;
  }
  for (i = 0; i < l; i++) c[i] = curc[i];
}
void buildsuff() {
  int l = cur.length(), i;
  for (i = 0; i < l; i++) cnt[cur[i] - sep]++;
  for (i = 1; i < 27; i++) cnt[i] += cnt[i - 1];
  for (i = l - 1; i >= 0; i--) suff[--cnt[cur[i] - sep]] = i;
  for (i = 0; i < 27; i++) cnt[i] = 0;
  c[suff[0]] = 0;
  int no = 0;
  for (i = 1; i < l; i++) {
    if (cur[suff[i]] != cur[suff[i - 1]]) no++;
    c[suff[i]] = no;
  }
  for (i = 0; (1 << i) < l; i++) step(i);
  for (i = 0; i < l; i++) order[suff[i]] = i;
}
void buildlcp() {
  int l = cur.length(), k = 0, i, j;
  lcp[0][0] = 0;
  for (i = 0; i < l; i++) {
    k = max(k - 1, 0);
    if (order[i] == l - 1) {
      lcp[0][order[i]] = k = 0;
      continue;
    }
    int suff1 = suff[order[i] + 1];
    while ((max(i, suff1) + k < l) && cur[i + k] == cur[suff1 + k] &&
           cur[i + k] != sep)
      k++;
    lcp[0][order[i]] = k;
  }
  for (i = 1; (1 << i) <= l; i++)
    for (j = 0; j + (1 << i) <= l; j++)
      lcp[i][j] = min(lcp[i - 1][j], lcp[i - 1][j + (1 << (i - 1))]);
}
int getlcp(int suff1, int suff2) {
  int no1 = order[suff1], no2 = order[suff2];
  if (no2 < no1) swap(no1, no2);
  int lg = len[no2 - no1];
  return min(lcp[lg][no1], lcp[lg][no2 - (1 << lg)]);
}
int main() {
  int n, m, x, i, j;
  cin >> n;
  cin >> s;
  cin >> m;
  cin >> t;
  cin >> x;
  cur = s + sep + t + sep;
  buildsuff();
  buildlcp();
  for (i = 1; (1 << i) < maxn; i++) len[1 << i]++;
  for (i = 2; i < maxn; i++) len[i] += len[i - 1];
  dp[0][0] = 0;
  for (j = 0; j <= n; j++)
    for (i = 0; i <= 30; i++) {
      maxi(dp[i][j + 1], dp[i][j]);
      if (i != 30) {
        int l = getlcp(j, n + dp[i][j] + 1);
        if (l != 0) maxi(dp[i + 1][j + l], dp[i][j] + l);
      }
    }
  for (i = 0; i <= x; i++)
    if (dp[i][n] == m) {
      cout << "YES";
      return 0;
    }
  cout << "NO";
  return 0;
}

```


### Prompt

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

There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i).

We will repeat the following operation as long as possible:

* Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at the remaining position.

We can prove that we can only do this operation a finite number of times. Find the maximum number of times we can do the operation.

Constraints

* 1 \leq N \leq 10^5
* 1 \leq x_i, y_i \leq 10^5
* If i \neq j, x_i \neq x_j or y_i \neq y_j.
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
:
x_N y_N

Output

Print the maximum number of times we can do the operation.

Examples

Input

3
1 1
5 1
5 5

Output

1

Input

2
10 10
20 20

Output

0

Input

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

Output

16

### Response

```cpp
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

typedef long long i64;

int main()
{
	const int MAX = 1e5;
	vector<vector<int>> g(2 * MAX);
	int n;

	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		x -= 1;
		y -= 1;
		g[x].push_back(MAX + y);
		g[MAX + y].push_back(x);
	}

	i64 ans = 0;
	vector<bool> visited(2 * MAX);

	for(int s = 0; s < 2 * MAX; s++) {

		if(visited[s]) {
			continue;
		}

		queue<int> q;
		int edges = 0;
		int x_vertices = 0, y_vertices = 0;

		q.push(s);

		while(!q.empty()) {

			int v = q.front();
			q.pop();

			if(visited[v]) {
				continue;
			}
			visited[v] = true;
			if(v < MAX) {
				x_vertices += 1;
			} else {
				y_vertices += 1;
			}

			for(auto& w : g[v]) {
				if(!visited[w]) {
					edges += 1;
				}
				q.push(w);
			}
		}

		ans += x_vertices * (i64)y_vertices - edges;
	}

	printf("%lld\n", ans);

	return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Genos has been given n distinct lines on the Cartesian plane. Let <image> be a list of intersection points of these lines. A single point might appear multiple times in this list if it is the intersection of multiple pairs of lines. The order of the list does not matter.

Given a query point (p, q), let <image> be the corresponding list of distances of all points in <image> to the query point. Distance here refers to euclidean distance. As a refresher, the euclidean distance between two points (x1, y1) and (x2, y2) is <image>.

Genos is given a point (p, q) and a positive integer m. He is asked to find the sum of the m smallest elements in <image>. Duplicate elements in <image> are treated as separate elements. Genos is intimidated by Div1 E problems so he asked for your help.

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 50 000) — the number of lines.

The second line contains three integers x, y and m (|x|, |y| ≤ 1 000 000, <image>) — the encoded coordinates of the query point and the integer m from the statement above. The query point (p, q) is obtained as <image>. In other words, divide x and y by 1000 to get the actual query point. <image> denotes the length of the list <image> and it is guaranteed that <image>.

Each of the next n lines contains two integers ai and bi (|ai|, |bi| ≤ 1 000 000) — the parameters for a line of the form: <image>. It is guaranteed that no two lines are the same, that is (ai, bi) ≠ (aj, bj) if i ≠ j.

Output

Print a single real number, the sum of m smallest elements of <image>. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

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

Examples

Input

4
1000 1000 3
1000 0
-1000 0
0 5000
0 -5000

Output

14.282170363

Input

2
-1000000 -1000000 1
1000000 -1000000
999999 1000000

Output

2000001000.999999500

Input

3
-1000 1000 3
1000 0
-1000 2000
2000 -1000

Output

6.000000000

Input

5
-303667 189976 10
-638 116487
-581 44337
1231 -756844
1427 -44097
8271 -838417

Output

12953.274911829

Note

In the first sample, the three closest points have distances <image> and <image>.

In the second sample, the two lines y = 1000x - 1000 and <image> intersect at (2000000, 1999999000). This point has a distance of <image> from ( - 1000, - 1000).

In the third sample, the three lines all intersect at the point (1, 1). This intersection point is present three times in <image> since it is the intersection of three pairs of lines. Since the distance between the intersection point and the query point is 2, the answer is three times that or 6.

### Response

```cpp
#include <bits/stdc++.h>
int n, m, p, q;
int a[50001], b[50001];
double K[50001], B[50001], fin;
struct point {
  double x, y;
  int ord;
} num[100001];
bool cmp(point a, point b) {
  return a.x < b.x || (a.x == b.x && a.ord < b.ord);
}
int ch[50001][2], size[50001], pri[50001], root;
std::pair<double, int> key[50001];
void pushup(int x) { size[x] = size[ch[x][0]] + size[ch[x][1]] + 1; }
void split(int now, int &x, int &y, const std::pair<double, int> &v) {
  if (!now)
    x = y = 0;
  else {
    if (key[now] <= v)
      x = now, split(ch[now][1], ch[now][1], y, v);
    else
      y = now, split(ch[now][0], x, ch[now][0], v);
    pushup(now);
  }
}
int merge(int x, int y) {
  if (!x || !y) return x | y;
  if (pri[x] < pri[y]) {
    ch[x][1] = merge(ch[x][1], y);
    pushup(x);
    return x;
  } else {
    ch[y][0] = merge(x, ch[y][0]);
    pushup(y);
    return y;
  }
}
long long calc(double mid) {
  root = 0;
  int top = 0;
  for (int i = 1; i <= n; i++) {
    double u = std::pow(K[i], 2) + 1.0, v = (-K[i] * B[i]),
           delt = u * mid - std::pow(B[i], 2);
    if (delt < 0.) continue;
    double x1 = (v - std::sqrt(delt)) / u, x2 = (v + std::sqrt(delt)) / u,
           y1 = atan2(K[i] * x1 + B[i], x1), y2 = atan2(K[i] * x2 + B[i], x2);
    if (y1 > y2) std::swap(y1, y2);
    num[++top] = (point){y1, y2, i};
    num[++top] = (point){y2, y2, -i};
  }
  std::sort(num + 1, num + top + 1, cmp);
  long long cnt = 0;
  for (int i = 1; i <= top; i++)
    if (num[i].ord > 0) {
      int u = num[i].ord;
      size[u] = 1;
      ch[u][0] = ch[u][1] = 0;
      key[u] = std::make_pair(num[i].y, u);
      int t1, t2;
      split(root, t1, t2, key[u]);
      cnt += size[t1];
      root = merge(t1, merge(u, t2));
    } else {
      int u = -num[i].ord;
      int t1, t2, t3;
      split(root, t1, t2, std::make_pair(num[i].y, u - 1));
      split(t2, t2, t3, key[u]);
      root = merge(t1, t3);
    }
  return cnt;
}
void dfs(int x, int u) {
  if (!x) return;
  dfs(ch[x][0], u);
  dfs(ch[x][1], u);
  double X = (B[x] - B[u]) / (K[u] - K[x]), Y = K[x] * X + B[x];
  fin += sqrt(X * X + Y * Y);
}
int main() {
  scanf("%d%d%d%d", &n, &p, &q, &m);
  for (int i = 1; i <= n; i++) pri[i] = rand();
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", a + i, b + i);
    K[i] = ((double)a[i]) / 1000.0;
    B[i] = ((double)b[i]) / 1000.0;
    B[i] += K[i] * ((double)p / 1000.0) - ((double)q / 1000.0);
  }
  double l = 0., r = 2000010000., mid, ans;
  int p = 0;
  while ((r - l) / (std::max(1., l)) >= 1e-6) {
    mid = (l + r) / 2.0;
    int u = calc(mid * mid);
    if (u < 1ll * m)
      ans = mid * mid, l = mid, p = u;
    else
      r = mid;
  }
  if (ans == 0.0) {
    printf("0.0");
    return 0;
  }
  fin = 1.0 * (m - p) * sqrt(ans);
  root = 0;
  int top = 0;
  for (int i = 1; i <= n; i++) {
    double u = pow(K[i], 2) + 1.0, v = (-K[i] * B[i]),
           delt = u * ans - pow(B[i], 2);
    if (delt < 0.) continue;
    double x1 = (v - sqrt(delt)) / u, x2 = (v + sqrt(delt)) / u,
           y1 = atan2(K[i] * x1 + B[i], x1), y2 = atan2(K[i] * x2 + B[i], x2);
    if (y1 > y2) std::swap(y1, y2);
    num[++top] = (point){y1, y2, i};
    num[++top] = (point){y2, y2, -i};
  }
  std::sort(num + 1, num + top + 1, cmp);
  for (int i = 1; i <= top; i++)
    if (num[i].ord > 0) {
      int u = num[i].ord;
      size[u] = 1;
      ch[u][0] = ch[u][1] = 0;
      key[u] = std::make_pair(num[i].y, u);
      int t1, t2;
      split(root, t1, t2, key[u]);
      dfs(t1, u);
      root = merge(t1, merge(u, t2));
    } else {
      int u = -num[i].ord;
      int t1, t2, t3;
      split(root, t1, t2, std::make_pair(num[i].y, u - 1));
      split(t2, t2, t3, key[u]);
      root = merge(t1, t3);
    }
  printf("%.7lf\n", fin);
}

```


### Prompt

Create a solution in cpp for the following problem:

Amr loves Geometry. One day he came up with a very interesting problem.

Amr has a circle of radius r and center in point (x, y). He wants the circle center to be in new position (x', y').

In one step Amr can put a pin to the border of the circle in a certain point, then rotate the circle around that pin by any angle and finally remove the pin.

Help Amr to achieve his goal in minimum number of steps.

Input

Input consists of 5 space-separated integers r, x, y, x' y' (1 ≤ r ≤ 105,  - 105 ≤ x, y, x', y' ≤ 105), circle radius, coordinates of original center of the circle and coordinates of destination center of the circle respectively.

Output

Output a single integer — minimum number of steps required to move the center of the circle to the destination point.

Examples

Input

2 0 0 0 4

Output

1

Input

1 1 1 4 4

Output

3

Input

4 5 6 5 6

Output

0

Note

In the first sample test the optimal way is to put a pin at point (0, 2) and rotate the circle by 180 degrees counter-clockwise (or clockwise, no matter).

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long r, x, y, xx, yy;
  cin >> r >> x >> y >> xx >> yy;
  long long g = (xx - x) * (xx - x);
  long long e = (yy - y) * (yy - y);
  int ans;
  double a = ceil(sqrt(e + g));
  ans = ceil(a / (r * 2));
  cout << ans;
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Alice and Bob are decorating a Christmas Tree.

Alice wants only 3 types of ornaments to be used on the Christmas Tree: yellow, blue and red. They have y yellow ornaments, b blue ornaments and r red ornaments.

In Bob's opinion, a Christmas Tree will be beautiful if:

  * the number of blue ornaments used is greater by exactly 1 than the number of yellow ornaments, and
  * the number of red ornaments used is greater by exactly 1 than the number of blue ornaments.

That is, if they have 8 yellow ornaments, 13 blue ornaments and 9 red ornaments, we can choose 4 yellow, 5 blue and 6 red ornaments (5=4+1 and 6=5+1).

Alice wants to choose as many ornaments as possible, but she also wants the Christmas Tree to be beautiful according to Bob's opinion.

In the example two paragraphs above, we would choose 7 yellow, 8 blue and 9 red ornaments. If we do it, we will use 7+8+9=24 ornaments. That is the maximum number.

Since Alice and Bob are busy with preparing food to the New Year's Eve, they are asking you to find out the maximum number of ornaments that can be used in their beautiful Christmas Tree!

It is guaranteed that it is possible to choose at least 6 (1+2+3=6) ornaments.

Input

The only line contains three integers y, b, r (1 ≤ y ≤ 100, 2 ≤ b ≤ 100, 3 ≤ r ≤ 100) — the number of yellow, blue and red ornaments.

It is guaranteed that it is possible to choose at least 6 (1+2+3=6) ornaments.

Output

Print one number — the maximum number of ornaments that can be used.

Examples

Input

8 13 9

Output

24

Input

13 3 6

Output

9

Note

In the first example, the answer is 7+8+9=24.

In the second example, the answer is 2+3+4=9.

### Response

```cpp
#include <bits/stdc++.h>
int main(void) {
  int initial_y, initial_b, initial_r;
  int max_y = 1;
  std::ios::sync_with_stdio(false);
  std::cin >> initial_y >> initial_b >> initial_r;
  for (int y = 1; y <= initial_y; y++) {
    if (y + 1 > initial_b || y + 2 > initial_r) {
      break;
    }
    max_y = y;
  }
  std::cout << 3 * (max_y + 1) << std::endl;
  return 0;
}

```


### Prompt

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

Sereja adores trees. Today he came up with a revolutionary new type of binary root trees.

His new tree consists of n levels, each vertex is indexed by two integers: the number of the level and the number of the vertex on the current level. The tree root is at level 1, its index is (1, 1). Here is a pseudo code of tree construction.

    //the global data are integer arrays cnt[], left[][], right[][]

    cnt[1] = 1;
    fill arrays left[][], right[][] with values -1;
    for(level = 1; level < n; level = level + 1){
        cnt[level + 1] = 0;
        for(position = 1; position <= cnt[level]; position = position + 1){
            if(the value of position is a power of two){ // that is, 1, 2, 4, 8...
                left[level][position] = cnt[level + 1] + 1;
                right[level][position] = cnt[level + 1] + 2;
                cnt[level + 1] = cnt[level + 1] + 2;
            }else{
                right[level][position] = cnt[level + 1] + 1;
                cnt[level + 1] = cnt[level + 1] + 1;
            }
        }
    }

After the pseudo code is run, cell cnt[level] contains the number of vertices on level level. Cell left[level][position] contains the number of the vertex on the level level + 1, which is the left child of the vertex with index (level, position), or it contains -1, if the vertex doesn't have a left child. Similarly, cell right[level][position] is responsible for the right child. You can see how the tree with n = 4 looks like in the notes.

Serja loves to make things complicated, so he first made a tree and then added an empty set A(level, position) for each vertex. Then Sereja executes m operations. Each operation is of one of the two following types:

  * The format of the operation is "1 t l r x". For all vertices level, position (level = t; l ≤ position ≤ r) add value x to set A(level, position).
  * The format of the operation is "2 t v". For vertex level, position (level = t, position = v), find the union of all sets of vertices that are in the subtree of vertex (level, position). Print the size of the union of these sets.

Help Sereja execute the operations. In this problem a set contains only distinct values like std::set in C++.

Input

The first line contains integers n and m (1 ≤ n, m ≤ 7000).

Next m lines contain the descriptions of the operations. The operation of the first type is given by five integers: 1 t l r x (1 ≤ t ≤ n; 1 ≤ l ≤ r ≤ cnt[t]; 1 ≤ x ≤ 106). The operation of the second type is given by three integers: 2 t v (1 ≤ t ≤ n; 1 ≤ v ≤ cnt[t]).

Output

For each operation of the second type, print the answer on a single line.

Examples

Input

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

Output

2
0
1

Note

You can find the definitions that are used while working with root trees by this link: http://en.wikipedia.org/wiki/Tree_(graph_theory)

You can see an example of a constructed tree at n = 4 below.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 7010, M = 200010, MAX = 200000, TOT = 1000010;
struct data {
  int t, l, r, x;
} dat[N];
int n, m, lg[M], rec[N], cnt, tot, l[N], r[N];
bool vis[TOT];
void prework() {
  lg[1] = 1;
  for (int i = 2, j = 1; i <= MAX; ++i) {
    lg[i] = lg[i - 1];
    if (i == (1 << j)) ++lg[i], ++j;
  }
}
int solve(int t, int b) {
  int ans = 0, s;
  l[t] = b - 1, r[t] = b;
  for (int i = t + 1; i <= n; ++i) {
    l[i] = l[i - 1] + lg[l[i - 1]];
    r[i] = r[i - 1] + lg[r[i - 1]];
  }
  for (int i = 1; i <= cnt; ++i)
    if (dat[i].t >= t) {
      s = dat[i].t;
      if (((dat[i].l) > (l[s]) && (dat[i].l) <= (r[s])) ||
          ((dat[i].r) > (l[s]) && (dat[i].r) <= (r[s])) ||
          (dat[i].l <= l[s] && dat[i].r > r[s])) {
        if (!vis[dat[i].x]) ++ans, rec[++tot] = dat[i].x;
        vis[dat[i].x] = 1;
      }
    }
  while (tot) {
    vis[rec[tot--]] = 0;
  }
  return ans;
}
int main() {
  int tp, a, b, c, d;
  scanf("%d%d", &n, &m);
  prework();
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &tp);
    if (tp & 1) {
      scanf("%d%d%d%d", &a, &b, &c, &d);
      dat[++cnt] = (data){a, b, c, d};
    } else {
      scanf("%d%d", &a, &b);
      printf("%d\n", solve(a, b));
    }
  }
  return 0;
}

```


### Prompt

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

The bear has a string s = s1s2... s|s| (record |s| is the string's length), consisting of lowercase English letters. The bear wants to count the number of such pairs of indices i, j (1 ≤ i ≤ j ≤ |s|), that string x(i, j) = sisi + 1... sj contains at least one string "bear" as a substring.

String x(i, j) contains string "bear", if there is such index k (i ≤ k ≤ j - 3), that sk = b, sk + 1 = e, sk + 2 = a, sk + 3 = r.

Help the bear cope with the given problem.

Input

The first line contains a non-empty string s (1 ≤ |s| ≤ 5000). It is guaranteed that the string only consists of lowercase English letters.

Output

Print a single number — the answer to the problem.

Examples

Input

bearbtear

Output

6

Input

bearaabearc

Output

20

Note

In the first sample, the following pairs (i, j) match: (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9).

In the second sample, the following pairs (i, j) match: (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (2, 10), (2, 11), (3, 10), (3, 11), (4, 10), (4, 11), (5, 10), (5, 11), (6, 10), (6, 11), (7, 10), (7, 11).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int i = 0, j, k, l, pairs = 0, oldl;
  string s, s2;
  cin >> s;
  l = s.size();
  std::size_t found;
  oldl = l;
  while (s.size() > 0) {
    l = s.size();
    found = s.find("bear");
    if (found != std::string::npos) {
      pairs += ((found + 1) * (l - (found + 3)));
      s = s.substr(found + 1);
    } else
      break;
    oldl = l;
  }
  printf("%d\n", pairs);
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th square of the i-th row of k-th piece of the board has color ak, i, j; 1 being black and 0 being white.

Now Magnus wants to change color of some squares in such a way that he recolors minimum number of squares and obtained pieces form a valid chessboard. Every square has its color different to each of the neightbouring by side squares in a valid board. Its size should be 2n by 2n. You are allowed to move pieces but not allowed to rotate or flip them.

Input

The first line contains odd integer n (1 ≤ n ≤ 100) — the size of all pieces of the board.

Then 4 segments follow, each describes one piece of the board. Each consists of n lines of n characters; j-th one of i-th line is equal to 1 if the square is black initially and 0 otherwise. Segments are separated by an empty line.

Output

Print one number — minimum number of squares Magnus should recolor to be able to obtain a valid chessboard.

Examples

Input

1
0

0

1

0

Output

1

Input

3
101
010
101

101
000
101

010
101
011

010
101
010

Output

2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > t;
int main() {
  string s;
  t.resize(4);
  int n;
  cin >> n;
  for (int k = 0; k < 4; k++) {
    int ans = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      for (int j = 0; j < s.size(); j++)
        if ((i * n + j) % 2 == s[j] - '0') {
          ans++;
        }
    }
    t[k].first = ans;
    t[k].second = n * n - ans;
  }
  sort(t.begin(), t.end());
  long long s2 = (long long)t[0].first + (long long)t[1].first +
                 (long long)t[2].second + (long long)t[3].second;
  long long res = s2;
  do {
    s2 = (long long)t[0].first + (long long)t[1].first +
         (long long)t[2].second + (long long)t[3].second;
    res = min(s2, res);
  } while (next_permutation(t.begin(), t.end()));
  s2 = (long long)t[0].first + (long long)t[1].first + (long long)t[2].second +
       (long long)t[3].second;
  res = min(s2, res);
  cout << res << endl;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

We all know that GukiZ often plays with arrays.

Now he is thinking about this problem: how many arrays a, of length n, with non-negative elements strictly less then 2l meet the following condition: <image>? Here operation <image> means bitwise AND (in Pascal it is equivalent to and, in C/C++/Java/Python it is equivalent to &), operation <image> means bitwise OR (in Pascal it is equivalent to <image>, in C/C++/Java/Python it is equivalent to |).

Because the answer can be quite large, calculate it modulo m. This time GukiZ hasn't come up with solution, and needs you to help him!

Input

First and the only line of input contains four integers n, k, l, m (2 ≤ n ≤ 1018, 0 ≤ k ≤ 1018, 0 ≤ l ≤ 64, 1 ≤ m ≤ 109 + 7).

Output

In the single line print the number of arrays satisfying the condition above modulo m.

Examples

Input

2 1 2 10

Output

3

Input

2 1 1 3

Output

1

Input

3 3 2 10

Output

9

Note

In the first sample, satisfying arrays are {1, 1}, {3, 1}, {1, 3}.

In the second sample, only satisfying array is {1, 1}.

In the third sample, satisfying arrays are {0, 3, 3}, {1, 3, 2}, {1, 3, 3}, {2, 3, 1}, {2, 3, 3}, {3, 3, 0}, {3, 3, 1}, {3, 3, 2}, {3, 3, 3}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 50;
long long n, k, l, m;
vector<vector<long long> > mult(vector<vector<long long> > &A,
                                vector<vector<long long> > &B) {
  vector<vector<long long> > C(A.size(), vector<long long>(B[0].size()));
  for (int i = 0; i < A.size(); i++) {
    for (int k = 0; k < B.size(); k++) {
      for (int j = 0; j < B[0].size(); j++) {
        C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % m;
      }
    }
  }
  return C;
}
vector<vector<long long> > pow(vector<vector<long long> > A, long long n) {
  vector<vector<long long> > B(A.size(), vector<long long>(A.size()));
  for (int i = 0; i < A.size(); i++) {
    B[i][i] = 1;
  }
  while (n > 0) {
    if (n & 1) B = mult(B, A);
    A = mult(A, A);
    n >>= 1;
  }
  return B;
}
long long quick_pow(long long base, long long exponent) {
  long long ans = 1;
  while (exponent) {
    if (exponent & 1) ans *= base, ans %= m;
    base *= base;
    base %= m;
    exponent >>= 1;
  }
  return ans;
}
long long solve() {
  vector<vector<long long> > A(2, vector<long long>(2));
  A[0][0] = 1, A[0][1] = 1;
  A[1][0] = 1, A[1][1] = 0;
  A = pow(A, n - 1);
  vector<vector<long long> > ans(2, vector<long long>(1));
  ans[0][0] = 1, ans[1][0] = 1;
  ans = mult(A, ans);
  return ans[0][0] + ans[1][0];
}
int main() {
  cin >> n >> k >> l >> m;
  long long zero = solve(), one = ((quick_pow(2, n) - zero) % m + m) % m;
  long long ans = 1;
  for (int i = 0; i < l; i++) {
    if (k & (1ll << i))
      ans *= one;
    else
      ans *= zero;
    ans %= m;
    k = k - (k & (1ll << i));
  }
  if (k)
    cout << 0 << endl;
  else
    cout << ans % m << endl;
  return 0;
}

```


### Prompt

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

Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced programmer. Actually he is not a programmer at all. So he wasn't able to solve them. That's why he asked you to help him with these tasks. One of these tasks is the following.

A sequence of l integers b1, b2, ..., bl (1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n) is called good if each number divides (without a remainder) by the next number in the sequence. More formally <image> for all i (1 ≤ i ≤ l - 1).

Given n and k find the number of good sequences of length k. As the answer can be rather large print it modulo 1000000007 (109 + 7).

Input

The first line of input contains two space-separated integers n, k (1 ≤ n, k ≤ 2000).

Output

Output a single integer — the number of good sequences of length k modulo 1000000007 (109 + 7).

Examples

Input

3 2

Output

5

Input

6 4

Output

39

Input

2 1

Output

2

Note

In the first sample the good sequences are: [1, 1], [2, 2], [3, 3], [1, 2], [1, 3].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
long long int dp[2002][2002];
int main() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> v[2002];
  for (int i = 1; i < 2002; i++) {
    for (int j = i; j < 2002; j += i) {
      v[j].push_back(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    dp[1][i] = 1;
  }
  for (int i = 2; i <= k; i++) {
    for (int j = 1; j <= n; j++) {
      for (int l = 0; l < v[j].size(); l++) {
        dp[i][j] += dp[i - 1][v[j][l]] % mod;
        dp[i][j] %= mod;
      }
    }
  }
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += dp[k][i] % mod;
    ans %= mod;
  }
  cout << ans % mod << endl;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

The subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.

You are given an integer n.

You have to find a sequence s consisting of digits \{1, 3, 7\} such that it has exactly n subsequences equal to 1337.

For example, sequence 337133377 has 6 subsequences equal to 1337:

  1. 337\underline{1}3\underline{3}\underline{3}7\underline{7} (you can remove the second and fifth characters);
  2. 337\underline{1}\underline{3}3\underline{3}7\underline{7} (you can remove the third and fifth characters);
  3. 337\underline{1}\underline{3}\underline{3}37\underline{7} (you can remove the fourth and fifth characters);
  4. 337\underline{1}3\underline{3}\underline{3}\underline{7}7 (you can remove the second and sixth characters);
  5. 337\underline{1}\underline{3}3\underline{3}\underline{7}7 (you can remove the third and sixth characters);
  6. 337\underline{1}\underline{3}\underline{3}3\underline{7}7 (you can remove the fourth and sixth characters).

Note that the length of the sequence s must not exceed 10^5.

You have to answer t independent queries.

Input

The first line contains one integer t (1 ≤ t ≤ 10) — the number of queries.

Next t lines contains a description of queries: the i-th line contains one integer n_i (1 ≤ n_i ≤ 10^9).

Output

For the i-th query print one string s_i (1 ≤ |s_i| ≤ 10^5) consisting of digits \{1, 3, 7\}. String s_i must have exactly n_i subsequences 1337. If there are multiple such strings, print any of them.

Example

Input

2
6
1

Output

113337
1337

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", 3, "inline")
using namespace std;
template <typename _T>
inline void read(_T &f) {
  f = 0;
  _T fu = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') fu = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    f = (f << 3) + (f << 1) + (c & 15);
    c = getchar();
  }
  f *= fu;
}
template <typename T>
void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + 48);
  else
    print(x / 10), putchar(x % 10 + 48);
}
template <typename T>
void print(T x, char t) {
  print(x);
  putchar(t);
}
template <typename T>
struct hash_map_t {
  vector<T> v, val, nxt;
  vector<int> head;
  int mod, tot, lastv;
  T lastans;
  bool have_ans;
  hash_map_t(int md = 0) {
    head.clear();
    v.clear();
    val.clear();
    nxt.clear();
    tot = 0;
    mod = md;
    nxt.resize(1);
    v.resize(1);
    val.resize(1);
    head.resize(mod);
    have_ans = 0;
  }
  void clear() { *this = hash_map_t(mod); }
  bool count(int x) {
    int u = x % mod;
    for (register int i = head[u]; i; i = nxt[i]) {
      if (v[i] == x) {
        have_ans = 1;
        lastv = x;
        lastans = val[i];
        return 1;
      }
    }
    return 0;
  }
  void ins(int x, int y) {
    int u = x % mod;
    nxt.push_back(head[u]);
    head[u] = ++tot;
    v.push_back(x);
    val.push_back(y);
  }
  int qry(int x) {
    if (have_ans && lastv == x) return lastans;
    count(x);
    return lastans;
  }
};
int T, n, now;
inline int calc(int x) { return x * (x - 1) / 2; }
int main() {
  cin >> T;
  while (T--) {
    cin >> n;
    int las = 10000;
    while (n) {
      int now = las;
      while (calc(now) > n) --now;
      for (register int i = las; i > now; i--) putchar('3');
      putchar('1');
      n -= calc(now);
      las = now;
    }
    while (las--) putchar('3');
    print(7, '\n');
  }
  return 0;
}

```


### Prompt

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

You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of the longest non-decreasing sequence of the given array.

Input

The first line contains two space-separated integers: n, T (1 ≤ n ≤ 100, 1 ≤ T ≤ 107). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 300).

Output

Print a single number — the length of a sought sequence.

Examples

Input

4 3
3 1 4 2

Output

5

Note

The array given in the sample looks like that: 3, 1, 4, 2, 3, 1, 4, 2, 3, 1, 4, 2. The elements in bold form the largest non-decreasing subsequence.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 30001;
int a[N], f[N], d[N];
int bsearch(const int *f, int size, const int &a) {
  int l = 0, r = size - 1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (a >= d[mid - 1] && a < d[mid])
      return mid;
    else if (a < d[mid])
      r = mid - 1;
    else
      l = mid + 1;
  }
}
int LIS(const int *a, const int &n) {
  int i, j, size = 1;
  d[0] = a[0];
  f[0] = 1;
  for (i = 1; i < n; ++i) {
    if (a[i] < d[0])
      j = 0;
    else if (a[i] >= d[size - 1])
      j = size++;
    else
      j = bsearch(d, size, a[i]);
    d[j] = a[i];
    f[i] = j + 1;
  }
  return size;
}
int main() {
  int n, t;
  while (scanf("%d%d", &n, &t) != EOF) {
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    if (t < 103) {
      for (int i = 1; i < t; i++)
        for (int j = 0; j < n; j++) a[i * n + j] = a[j];
      printf("%d", LIS(a, n * t));
    } else {
      for (int i = 1; i < 103; i++)
        for (int j = 0; j < n; j++) a[i * n + j] = a[j];
      int zzz = LIS(a, n * 103);
      for (int j = 0; j < n; j++) a[103 * n + j] = a[j];
      int zzz2 = LIS(a, n * 104);
      printf("%d", zzz + (zzz2 - zzz) * (t - 103));
    }
  }
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.

Help Kurt find the maximum possible product of digits among all integers from 1 to n.

Input

The only input line contains the integer n (1 ≤ n ≤ 2⋅10^9).

Output

Print the maximum product of digits among all integers from 1 to n.

Examples

Input

390

Output

216

Input

7

Output

7

Input

1000000000

Output

387420489

Note

In the first example the maximum product is achieved for 389 (the product of digits is 3⋅8⋅9=216).

In the second example the maximum product is achieved for 7 (the product of digits is 7).

In the third example the maximum product is achieved for 999999999 (the product of digits is 9^9=387420489).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  int* digit = new int[15]();
  int count = 0;
  long long int max = 1;
  while (n > 0) {
    digit[count] = n % 10;
    max = max * digit[count];
    count++;
    n /= 10;
  }
  long long int fact = 1;
  for (int i = count - 1; i >= 0; --i) {
    long long int res = fact * (digit[i] - 1) * pow(9, i);
    if (i == count - 1 && digit[i] == 1) res = pow(9, i);
    if (res > max) max = res;
    fact *= digit[i];
  }
  cout << max;
  delete[] digit;
  return 0;
}

```


### Prompt

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

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

* $add(s, t, x)$ : add $x$ to $a_s, a_{s+1}, ..., a_t$.
* $find(s, t)$ : report the minimum value in $a_s, a_{s+1}, ..., a_t$.

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

Constraints

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

Input

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

In the first line, $n$ (the number of elements in $A$) and $q$ (the number of queries) are given. Then, $i$th query $query_i$ is given in the following format:

0 $s$ $t$ $x$

or

1 $s$ $t$

The first digit represents the type of the query. '0' denotes $add(s, t, x)$ and '1' denotes $find(s, t)$.

Output

For each $find$ query, print the minimum value.

Example

Input

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

Output

-2
0
1
-1

### Response

```cpp
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
struct segtree{
private:
  int siz;
  vector<ll> node,lazy;
  ll seg_inf;
public:
  segtree(ll n){
    siz=1;
    while(siz<=n) siz*=2;
    node.resize(siz*2-1,0);
    lazy.resize(siz*2-1,0);
    seg_inf=17441744174417;
  }
  void eval(ll k){
    node[k]+=lazy[k];
    if(k<siz-1){
      lazy[2*k+1]+=lazy[k];
      lazy[2*k+2]+=lazy[k];
    }
    lazy[k]=0;
  }
  void plus(ll a,ll b,ll x,ll k,ll l,ll r){
    eval(k);
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      lazy[k]+=x;
      eval(k);
    }
    else{
      plus(a,b,x,2*k+1,l,(l+r)/2);
      plus(a,b,x,2*k+2,(l+r)/2,r);
      node[k]=min(node[2*k+1],node[2*k+2]);
    }
  }
  void add(ll a,ll b,ll x){
    plus(a,b,x,0,0,siz);
  }
  ll get_min(ll a,ll b,ll k,ll l,ll r){
    eval(k);
    if(r<=a||b<=l) return seg_inf;
    if(a<=l&&r<=b) return node[k];
    else return min(get_min(a,b,2*k+1,l,(l+r)/2),get_min(a,b,2*k+2,(l+r)/2,r));
  }
  ll min_q(ll s,ll t){
    return get_min(s,t,0,0,siz);
  }
  void debug(int f){
    if(f==0){
      cout<<"node:";
      for(int i=0;i<node.size();i++) cout<<node[i]<<" ";
    }
    else{
      cout<<"lazy:";
      for(int i=0;i<lazy.size();i++) cout<<lazy[i]<<" ";
    }
    cout<<endl;
  }
};
int main(){
  int n,q;
  cin>>n>>q;
  segtree seg=segtree(n);
  for(int i=0;i<q;i++){
    int f;
    cin>>f;
    if(f==0){
      int s,t; ll x;
      cin>>s>>t>>x;
      seg.add(s,t+1,x);
    }
    else{
      int s,t;
      cin>>s>>t;
      cout<<seg.min_q(s,t+1)<<endl;
    }
  }
}

```


### Prompt

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

Xenia the mathematician has a sequence consisting of n (n is divisible by 3) positive integers, each of them is at most 7. She wants to split the sequence into groups of three so that for each group of three a, b, c the following conditions held:

  * a < b < c;
  * a divides b, b divides c.

Naturally, Xenia wants each element of the sequence to belong to exactly one group of three. Thus, if the required partition exists, then it has <image> groups of three.

Help Xenia, find the required partition or else say that it doesn't exist.

Input

The first line contains integer n (3 ≤ n ≤ 99999) — the number of elements in the sequence. The next line contains n positive integers, each of them is at most 7.

It is guaranteed that n is divisible by 3.

Output

If the required partition exists, print <image> groups of three. Print each group as values of the elements it contains. You should print values in increasing order. Separate the groups and integers in groups by whitespaces. If there are multiple solutions, you can print any of them.

If there is no solution, print -1.

Examples

Input

6
1 1 1 2 2 2

Output

-1

Input

6
2 2 1 1 4 6

Output

1 2 4
1 2 6

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const double EPS = 1e-15;
const long long INF = 1000000000 + 5;
const int MAXN2 = 2e5 + 5;
int b[MAXN][3];
int p[10];
int main() {
  int n, a;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    p[a]++;
  }
  int n2 = n / 3;
  bool good = true;
  if (p[1] != n2) {
    good = false;
  }
  int cur = 0;
  while (p[3] > 0 && p[6] > 0) {
    b[cur][0] = 1;
    b[cur][1] = 3;
    b[cur][2] = 6;
    p[3]--;
    p[1]--;
    p[6]--;
    cur++;
  }
  while (p[6] > 0 && p[2] > 0) {
    b[cur][0] = 1;
    b[cur][1] = 2;
    b[cur][2] = 6;
    p[2]--;
    p[6]--;
    p[1]--;
    cur++;
  }
  while (p[4] > 0 && p[2] > 0) {
    b[cur][0] = 1;
    b[cur][1] = 2;
    b[cur][2] = 4;
    p[2]--;
    p[1]--;
    p[4]--;
    cur++;
  }
  for (int i = 1; i < 8; i++) {
    if (p[i] > 0) {
      good = false;
      break;
    }
  }
  if (good) {
    for (int i = 0; i < n2; i++) {
      for (int j = 0; j < 3; j++) printf("%d ", b[i][j]);
      printf("\n");
    }
  } else
    printf("-1");
  return 0;
}

```


### Prompt

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

There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty.

Aohashi would like to fill the empty squares with integers so that the following condition is satisfied:

* For any two adjacent squares, the (absolute) difference of the two integers in those squares is between C and D (inclusive).

As long as the condition is satisfied, it is allowed to use arbitrarily large or small integers to fill the squares. Determine whether it is possible to fill the squares under the condition.

Constraints

* 3 \leq N \leq 500000
* 0 \leq A \leq 10^9
* 0 \leq B \leq 10^9
* 0 \leq C \leq D \leq 10^9
* All input values are integers.

Input

Input is given from Standard Input in the following format:

N A B C D

Output

Print `YES` if it is possible to fill the squares under the condition; print `NO` otherwise.

Examples

Input

5 1 5 2 4

Output

YES

Input

4 7 6 4 5

Output

NO

Input

48792 105960835 681218449 90629745 90632170

Output

NO

Input

491995 412925347 825318103 59999126 59999339

Output

YES

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
#define M 500005
#define ll long long
ll n,a,b,c,d;
int main(){
	cin>>n>>a>>b>>c>>d;
	b-=a;
	for(ll i=1;i<=n;i++){
		ll L=c*(i-1)-d*(n-i);
		ll R=d*(i-1)-c*(n-i);
		if(L<=b&&b<=R){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}
```


### Prompt

Please create a solution in cpp to the following problem:

Inspired by the tv series Stranger Things, bear Limak is going for a walk between two mirror worlds.

There are two perfect binary trees of height H, each with the standard numeration of vertices from 1 to 2^H-1. The root is 1 and the children of x are 2 \cdot x and 2 \cdot x + 1.

Let L denote the number of leaves in a single tree, L = 2^{H-1}.

You are given a permutation P_1, P_2, \ldots, P_L of numbers 1 through L. It describes L special edges that connect leaves of the two trees. There is a special edge between vertex L+i-1 in the first tree and vertex L+P_i-1 in the second tree.

graph for sample1

drawing for the first sample test, permutation P = (2, 3, 1, 4), special edges in green

Let's define product of a cycle as the product of numbers in its vertices. Compute the sum of products of all simple cycles that have exactly two special edges, modulo (10^9+7).

A simple cycle is a cycle of length at least 3, without repeated vertices or edges.

Constraints

* 2 \leq H \leq 18
* 1 \leq P_i \leq L where L = 2^{H-1}
* P_i \neq P_j (so this is a permutation)

Input

Input is given from Standard Input in the following format (where L = 2^{H-1}).

H
P_1 P_2 \cdots P_L

Output

Compute the sum of products of simple cycles that have exactly two special edges. Print the answer modulo (10^9+7).

Examples

Input

3
2 3 1 4

Output

121788

Input

2
1 2

Output

36

Input

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

Output

10199246

### Response

```cpp
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>
#include <random>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << " = "; for (auto xxxx: a) cerr << xxxx << " "; cerr << endl

using namespace std;

#ifdef LOCAL
static struct __timestamper {
    string what;
    __timestamper(const char* what) : what(what){};
    __timestamper(const string& what) : what(what){};
    ~__timestamper(){
        TIMESTAMPf("%s", what.data());
    }
} __TIMESTAMPER("end");
#else
struct __timestamper {};
#endif

typedef long long ll;
typedef long double dbl;

const int MOD = (int)1e9 + 7;

void add(int &x, ll y) {
    x = (x + y) % MOD;
}

int mul(int x, int y) {
    return 1LL * x * y % MOD;
}

int solve(int h, vector<int> p) {
    int k = 1 << (h - 1);
    assert((int)p.size() == k);

    int n = 1 << h;
    vector<int> L(n), R(n);
    for (int i = 0; i < k; i++) L[k + i] = R[k + i] = i;
    for (int i = k - 1; i >= 1; i--) {
        L[i] = L[2 * i];
        R[i] = R[2 * i + 1];
    }

    vector<int> sum(n);
    auto enable = [&](int x, int prod) {
        x += k;
        while (x > 0) {
            prod = mul(prod, x);
            add(sum[x], prod);
            x >>= 1;
        }
    };

    vector<int> cprod(k);
    for (int i = 0; i < k; i++) cprod[i] = k + i;

    int ans = 0;
    for (int v = k - 1; v >= 1; v--) {
        for (int i = L[v * 2 + 1]; i <= R[v * 2 + 1]; i++) {
            enable(p[i], cprod[i]);
        }

        for (int i = L[v * 2]; i <= R[v * 2]; i++) {
            int oth = k + p[i];

            int rprod = mul(mul(v, cprod[i]), oth);
            while (oth > 1) {
                int pr = oth >> 1;
                rprod = mul(rprod, pr);
                add(ans, mul(rprod, sum[oth ^ 1]));
                oth = pr;
            }
        }

        for (int i = L[v * 2 + 1]; i <= R[v  * 2 + 1]; i++) {
            enable(p[i], mul(cprod[i], MOD - 1));
        }

        for (int i = L[v]; i <= R[v]; i++) cprod[i] = mul(cprod[i], v);
    }
    return ans;
}

int main() {
#ifdef LOCAL
    freopen("in", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int h;
    while (cin >> h) {
        int k = 1 << (h - 1);
        vector<int> p(k);
        for (int i = 0; i < k; i++) {
            cin >> p[i];
            p[i]--;
        }

        cout << solve(h, p) << endl;
    }

    return 0;
}

```


### Prompt

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

Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the same forward and backward. For example, "noon", "testset" and "a" are all palindromes, while "test" and "kitayuta" are not.) You can choose any n lowercase English letters, and insert each of them to any position of s, possibly to the beginning or the end of s. You have to insert exactly n letters even if it is possible to turn s into a palindrome by inserting less than n letters.

Find the number of the palindromes that can be obtained in this way, modulo 10007.

Input

The first line contains a string s (1 ≤ |s| ≤ 200). Each character in s is a lowercase English letter.

The second line contains an integer n (1 ≤ n ≤ 109).

Output

Print the number of the palindromes that can be obtained, modulo 10007.

Examples

Input

revive
1

Output

1

Input

add
2

Output

28

Note

For the first sample, you can obtain the palindrome "reviver" by inserting 'r' to the end of "revive".

For the second sample, the following 28 palindromes can be obtained: "adada", "adbda", ..., "adzda", "dadad" and "ddadd".

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int MAX = 1e5 + 5;
const long long MAX2 = 11;
const long long MOD = 10007;
const long long MOD2 = 1000005329;
const long long INF = 2e18;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1, 0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 555;
long long qp(long long a, long long b) {
  long long x = 1;
  a %= MOD;
  while (b) {
    if (b & 1) x = x * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return x;
}
namespace linear_seq {
inline vector<int> BM(vector<int> x) {
  vector<int> ls, cur;
  int lf, ld;
  for (int i = 0; i < int(x.size()); ++i) {
    long long t = 0;
    for (int j = 0; j < int(cur.size()); ++j)
      t = (t + x[i - j - 1] * (long long)cur[j]) % MOD;
    if ((t - x[i]) % MOD == 0) continue;
    if (!cur.size()) {
      cur.resize(i + 1);
      lf = i;
      ld = (t - x[i]) % MOD;
      continue;
    }
    long long k = -(x[i] - t) * qp(ld, MOD - 2) % MOD;
    vector<int> c(i - lf - 1);
    c.push_back(k);
    for (int j = 0; j < int(ls.size()); ++j) c.push_back(-ls[j] * k % MOD);
    if (c.size() < cur.size()) c.resize(cur.size());
    for (int j = 0; j < int(cur.size()); ++j) c[j] = (c[j] + cur[j]) % MOD;
    if (i - lf + (int)ls.size() >= (int)cur.size())
      ls = cur, lf = i, ld = (t - x[i]) % MOD;
    cur = c;
  }
  for (int i = 0; i < int(cur.size()); ++i) cur[i] = (cur[i] % MOD + MOD) % MOD;
  return cur;
}
int m;
long long a[233333], h[233333], t_[233333], s[233333], t[233333];
inline void mull(long long *p, long long *q) {
  for (int i = 0; i < m + m; ++i) t_[i] = 0;
  for (int i = 0; i < m; ++i)
    if (p[i])
      for (int j = 0; j < m; ++j) t_[i + j] = (t_[i + j] + p[i] * q[j]) % MOD;
  for (int i = m + m - 1; i >= m; --i)
    if (t_[i])
      for (int j = m - 1; ~j; --j)
        t_[i - j - 1] = (t_[i - j - 1] + t_[i] * h[j]) % MOD;
  for (int i = 0; i < m; ++i) p[i] = t_[i];
}
inline long long calc(long long K) {
  for (int i = m; ~i; --i) s[i] = t[i] = 0;
  s[0] = 1;
  if (m != 1)
    t[1] = 1;
  else
    t[0] = h[0];
  while (K) {
    if (K & 1) mull(s, t);
    mull(t, t);
    K >>= 1;
  }
  long long su = 0;
  for (int i = 0; i < m; ++i) su = (su + s[i] * a[i]) % MOD;
  return (su % MOD + MOD) % MOD;
}
inline int work(vector<int> x, long long n) {
  if (n < int(x.size())) return x[n];
  vector<int> v = BM(x);
  m = v.size();
  if (!m) return 0;
  for (int i = 0; i < m; ++i) h[i] = v[i], a[i] = x[i];
  return calc(n);
}
}  // namespace linear_seq
using linear_seq::work;
int n, dp[1005][201][201], sta;
bool st;
string s;
vector<int> sq;
int f(int rem, int le, int ri) {
  if (!rem) return le > ri;
  if (ri < 0) ri = 0;
  int &ret = dp[rem][le][ri];
  if (ret != -1) return ret;
  if (le > ri) return ret = 26 * f(rem - 1, le, ri) % MOD;
  if (rem == 1 && st && le != ri) return ret = 0;
  if (s[le] == s[ri])
    ret = (25 * f(rem - 1, le, ri) + f(rem - 1, le + 1, ri - 1)) % MOD;
  else
    ret = ret = (24 * f(rem - 1, le, ri) + f(rem - 1, le, ri - 1) +
                 f(rem - 1, le + 1, ri)) %
                MOD;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s >> n;
  if ((n + s.size()) & 1) st = 1;
  memset(dp, -1, sizeof dp);
  sta = s.size();
  if (n & 1) ++sta;
  sta = (sta + 1) / 2;
  for (int i = 0; i <= 900; ++i) sq.push_back(f(sta + i, 0, s.size() - 1));
  cout << work(sq, n / 2) << '\n';
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.

In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.

You can repeat the following operation any number of times:

* Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.

You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.

Determine whether this is possible.

Constraints

* 4 \leq N \leq 200\ 000
* S is a string of length N consisting of `.` and `#`.
* 1 \leq A, B, C, D \leq N
* Square A, B, C and D do not contain a rock.
* A, B, C and D are all different.
* A < B
* A < C
* B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

Print `Yes` if the objective is achievable, and `No` if it is not.

Examples

Input

7 1 3 6 7
.#..#..

Output

Yes

Input

7 1 3 7 6
.#..#..

Output

No

Input

15 1 3 15 13
...#.#...#.#...

Output

Yes

### Response

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

using namespace std;

const int MX = 200000;

void no() {
	printf("%s\n", "No");
	exit(0);
}

char s[MX + 1];

int main() {
	int n, a, b, c, d;
	ignore = scanf("%d %d %d %d %d %s", &n, &a, &b, &c, &d, s);
	a--;
	b--;
	c--;
	d--;

	for (int i = 0; i + 1 < n; i++)
		if (s[i] == '#' && s[i + 1] == '#') {
			if (a < i && i < c) no();
			if (b < i && i < d) no();
		}

	if (c > d) {
		bool ok = false;
		for (int i = b; i <= d; i++)
			if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.')
				ok = true;

		if (ok == false) no();
	}

	printf("%s\n", "Yes");

	return 0;
}

```


### Prompt

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

You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight different pokemons: Vaporeon, Jolteon, Flareon, Espeon, Umbreon, Leafeon, Glaceon, and Sylveon.

You know the length of the word in the crossword, and you already know some letters. Designers of the crossword made sure that the answer is unambiguous, so you can assume that exactly one pokemon out of the 8 that Eevee evolves into fits the length and the letters given. Your task is to find it.

Input

First line contains an integer n (6 ≤ n ≤ 8) – the length of the string.

Next line contains a string consisting of n characters, each of which is either a lower case english letter (indicating a known letter) or a dot character (indicating an empty cell in the crossword).

Output

Print a name of the pokemon that Eevee can evolve into that matches the pattern in the input. Use lower case letters only to print the name (in particular, do not capitalize the first letter).

Examples

Input

7
j......

Output

jolteon

Input

7
...feon

Output

leafeon

Input

7
.l.r.o.

Output

flareon

Note

Here's a set of names in a form you can paste into your solution:

["vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"]

{"vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"}

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string a[8] = {"vaporeon", "jolteon", "flareon", "espeon",
                 "umbreon",  "leafeon", "glaceon", "sylveon"};
  string s;
  cin >> s;
  int count = 0, count2 = 0;
  for (int i = 0; i < 8; i++) {
    if (a[i].length() == n) {
      for (int j = 0; j < n; j++)
        if (s[j] != '.') {
          count++;
          if (s[j] == a[i][j]) count2++;
        }
      if (count == count2 && count != 0) {
        cout << a[i] << endl;
        return 0;
      }
    }
    count = 0, count2 = 0;
  }
  for (int j = 0; j < n; j++)
    if (n == a[j].length()) {
      cout << a[j] << endl;
      return 0;
    }
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

A prisoner wants to escape from a prison. The prison is represented by the interior of the convex polygon with vertices P_1, P_2, P_3, …, P_{n+1}, P_{n+2}, P_{n+3}. It holds P_1=(0,0), P_{n+1}=(0, h), P_{n+2}=(-10^{18}, h) and P_{n+3}=(-10^{18}, 0).

<image>

The prison walls P_{n+1}P_{n+2}, P_{n+2}P_{n+3} and P_{n+3}P_1 are very high and the prisoner is not able to climb them. Hence his only chance is to reach a point on one of the walls P_1P_2, P_2P_3,..., P_{n}P_{n+1} and escape from there. On the perimeter of the prison, there are two guards. The prisoner moves at speed 1 while the guards move, remaining always on the perimeter of the prison, with speed v.

If the prisoner reaches a point of the perimeter where there is a guard, the guard kills the prisoner. If the prisoner reaches a point of the part of the perimeter he is able to climb and there is no guard there, he escapes immediately. Initially the prisoner is at the point (-10^{17}, h/2) and the guards are at P_1.

Find the minimum speed v such that the guards can guarantee that the prisoner will not escape (assuming that both the prisoner and the guards move optimally).

Notes:

  * At any moment, the guards and the prisoner can see each other.
  * The "climbing part" of the escape takes no time.
  * You may assume that both the prisoner and the guards can change direction and velocity instantly and that they both have perfect reflexes (so they can react instantly to whatever the other one is doing).
  * The two guards can plan ahead how to react to the prisoner movements.

Input

The first line of the input contains n (1 ≤ n ≤ 50).

The following n+1 lines describe P_1, P_2,..., P_{n+1}. The i-th of such lines contain two integers x_i, y_i (0≤ x_i, y_i≤ 1,000) — the coordinates of P_i=(x_i, y_i).

It is guaranteed that P_1=(0,0) and x_{n+1}=0. The polygon with vertices P_1,P_2,..., P_{n+1}, P_{n+2}, P_{n+3} (where P_{n+2}, P_{n+3} shall be constructed as described in the statement) is guaranteed to be convex and such that there is no line containing three of its vertices.

Output

Print a single real number, the minimum speed v that allows the guards to guarantee that the prisoner will not escape. Your answer will be considered correct if its relative or absolute error does not exceed 10^{-6}.

Examples

Input

2
0 0
223 464
0 749

Output

1

Input

3
0 0
2 2
2 4
0 6

Output

1.0823922

Input

4
0 0
7 3
7 4
5 7
0 8

Output

1.130309669

Input

5
0 0
562 248
460 610
281 702
206 723
0 746

Output

1.148649561

Input

7
0 0
412 36
745 180
747 184
746 268
611 359
213 441
0 450

Output

1.134745994

### Response

```cpp
#include <bits/stdc++.h>
using ld = long double;
using ul = std::size_t;
template <typename T, ul C>
using ar = std::array<T, C>;
const int MN = 55;
const ld INF = 1e10;
const ld EPS = 1e-9;
template <ul C>
ar<ld, C>& operator*=(ar<ld, C>& a, const ld& v) {
  for (ul i = 0; i < C; ++i) a[i] *= v;
  return a;
}
template <ul C>
ar<ld, C> operator*(ar<ld, C> a, const ld& v) {
  return a *= v;
}
template <ul C>
ar<ld, C>& operator+=(ar<ld, C>& a, const ar<ld, C>& b) {
  for (ul i = 0; i < C; ++i) a[i] += b[i];
  return a;
}
template <ul C>
ar<ld, C> operator+(ar<ld, C> a, const ar<ld, C>& b) {
  return a += b;
}
inline bool equ(const ld& a, const ld& b) { return std::abs(a - b) < EPS; }
struct vec {
 public:
  ld x, y;
  vec(ld _x = 0, ld _y = 0) : x(_x), y(_y) {}
  vec& operator+=(const vec& o) { return x += o.x, y += o.y, *this; }
  vec& operator-=(const vec& o) { return x -= o.x, y -= o.y, *this; }
  vec& operator*=(const ld& o) { return x *= o, y *= o, *this; }
  friend vec operator+(vec a, const vec& b) { return a += b; }
  friend vec operator-(vec a, const vec& b) { return a -= b; }
  friend vec operator*(vec a, const ld& b) { return a *= b; }
  ld mag() const { return hypot(x, y); }
};
struct range {
 public:
  ld l, r;
};
using ranges = std::vector<range>;
ranges unite(const ranges& a, const ranges& b) {
  ranges f(0);
  bool rdy = 0;
  ld l = -INF - 1, r = -INF - 1;
  auto add = [&]() {
    if (rdy)
      f.push_back({l, r});
    else
      rdy = 1;
  };
  range t;
  for (int i = 0, j = 0; i < a.size() || j < b.size();) {
    if (j < b.size() && (i == a.size() || b[j].l < a[i].l))
      t = b[j++];
    else
      t = a[i++];
    if (r + EPS < t.l) add(), l = t.l;
    r = std::max(r, t.r);
  }
  add();
  return f;
}
ranges isect(const ranges& a, const ranges& b) {
  ranges f;
  for (int i = 0, j = 0; i < a.size() && j < b.size();) {
    ld l = std::max(a[i].l, b[j].l);
    ld r = std::min(a[i].r, b[j].r);
    if (l + EPS < r) f.push_back({l, r});
    if (a[i].r < b[j].r)
      ++i;
    else
      ++j;
  }
  return f;
}
int N;
vec p[MN];
ld pf[MN];
ar<ld, 6> sqr(const ar<ld, 3>& a) {
  return {a[0] * a[0], 2 * a[0] * a[1], 2 * a[0] * a[2],
          a[1] * a[1], a[2] * a[2],     2 * a[1] * a[2]};
}
ranges neg(const ar<ld, 3>& a) {
  if (equ(a[2], 0)) {
    if (equ(a[1], 0))
      return a[0] < 0 ? ranges{{-INF, INF}} : ranges();
    else
      return a[1] < 0 ? ranges{{-a[0] / a[1], INF}}
                      : ranges{{-INF, -a[0] / a[1]}};
  } else if (a[2] < 0) {
    ld d = a[1] * a[1] - 4 * a[0] * a[2];
    if (d > EPS) {
      d = sqrt(d) / (2 * -a[2]);
      ld c = -a[1] / (2 * a[2]);
      return ranges{{-INF, c - d}, {c + d, INF}};
    }
    return ranges{{-INF, INF}};
  } else {
    ld d = a[1] * a[1] - 4 * a[0] * a[2];
    if (d > EPS) {
      d = sqrt(d) / (2 * a[2]);
      ld c = -a[1] / (2 * a[2]);
      return ranges{{c - d, c + d}};
    }
    return ranges();
  }
}
ranges eval(const ar<ld, 6>& a) {
  ranges f;
  f = neg({a[0], a[1], a[3]});
  f = unite(f, neg({a[0] + a[2] + a[4], a[1] + a[5], a[3]}));
  if (a[4] > EPS) {
    if (equ(a[5], 0)) {
      ld yv = a[2] / (-2 * a[4]);
      if (0 < yv && yv < 1)
        f = unite(f, neg({a[0] + a[2] * yv + a[4] * yv * yv, a[1], a[3]}));
    } else {
      range xr = {(-2 * a[4] - a[2]) / a[5], -a[2] / a[5]};
      if (a[5] < 0) xr = {xr.r, xr.l};
      f = unite(f, isect(ranges{xr}, neg({a[0] - a[2] * a[2] / (4 * a[4]),
                                          a[1] - 2 * a[2] * a[5] / (4 * a[4]),
                                          a[3] - a[5] * a[5] / (4 * a[4])})));
    }
  }
  return isect(f, ranges{{0, 1}});
}
bool ok(const ld& v) {
  ranges bot, top;
  for (int i = 0; i < N; ++i)
    for (int j = i + 1; j < N; ++j) {
      ld mi = (p[i + 1] - p[i]).mag();
      ld mj = (p[j + 1] - p[j]).mag();
      ar<ld, 6> L = sqr({pf[j] - pf[i], -mi, mj});
      ar<ld, 6> Dx =
          sqr({p[j].x - p[i].x, -p[i + 1].x + p[i].x, p[j + 1].x - p[j].x});
      ar<ld, 6> Dy =
          sqr({p[j].y - p[i].y, -p[i + 1].y + p[i].y, p[j + 1].y - p[j].y});
      L *= -1;
      Dx *= v * v;
      Dy *= v * v;
      ar<ld, 6> fin = L + Dx + Dy;
      ranges bot_ = eval(fin);
      std::swap(fin[1], fin[2]);
      std::swap(fin[3], fin[4]);
      ranges top_ = eval(fin);
      for (range& x : bot_) x.l = pf[i] + mi * x.l, x.r = pf[i] + mi * x.r;
      for (range& x : top_) x.l = pf[j] + mj * x.l, x.r = pf[j] + mj * x.r;
      bot = unite(bot, bot_);
      top = unite(top, top_);
    }
  return isect(bot, top).empty();
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i <= N; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    p[i] = {(ld)u, (ld)v};
  }
  for (int i = 0; i < N; ++i) pf[i + 1] = pf[i] + (p[i + 1] - p[i]).mag();
  ld l = 1, r = 5000;
  for (int i = 0; i < 100; ++i) {
    ld m = l + (r - l) / 2;
    if (ok(m))
      r = m;
    else
      l = m;
  }
  printf("%.9lf\n", (double)r);
  return 0;
}

```