### Prompt

Create a solution in cpp for the following problem:

Fibonacci numbers are the sequence of integers: f0 = 0, f1 = 1, f2 = 1, f3 = 2, f4 = 3, f5 = 5, ..., fn = fn - 2 + fn - 1. So every next number is the sum of the previous two.

Bajtek has developed a nice way to compute Fibonacci numbers on a blackboard. First, he writes a 0. Then, below it, he writes a 1. Then he performs the following two operations:

  * operation "T": replace the top number with the sum of both numbers;
  * operation "B": replace the bottom number with the sum of both numbers.

If he performs n operations, starting with "T" and then choosing operations alternately (so that the sequence of operations looks like "TBTBTBTB..."), the last number written will be equal to fn + 1.

Unfortunately, Bajtek sometimes makes mistakes and repeats an operation two or more times in a row. For example, if Bajtek wanted to compute f7, then he would want to do n = 6 operations: "TBTBTB". If he instead performs the sequence of operations "TTTBBT", then he will have made 3 mistakes, and he will incorrectly compute that the seventh Fibonacci number is 10. The number of mistakes in the sequence of operations is the number of neighbouring equal operations («TT» or «BB»).

You are given the number n of operations that Bajtek has made in an attempt to compute fn + 1 and the number r that is the result of his computations (that is last written number). Find the minimum possible number of mistakes that Bajtek must have made and any possible sequence of n operations resulting in r with that number of mistakes.

Assume that Bajtek always correctly starts with operation "T".

Input

The first line contains the integers n and r (1 ≤ n, r ≤ 106).

Output

The first line of the output should contain one number — the minimum possible number of mistakes made by Bajtek. The second line should contain n characters, starting with "T", describing one possible sequence of operations with that number of mistakes. Each character must be either "T" or "B".

If the required sequence doesn't exist, output "IMPOSSIBLE" (without quotes).

Examples

Input

6 10

Output

2
TBBTTB

Input

4 5

Output

0
TBTB

Input

2 1

Output

IMPOSSIBLE

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void setIO(string name) {
  string is = name + ".in";
  string os = name + ".out";
  freopen(is.c_str(), "r", stdin);
}
int v;
int cnt, ans, stk[1000], stn;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void solve(int a, int b) {
  if (a == 1 || b == 1) {
    if (a == 1) {
      stk[stn++] = b - 1;
      cnt += b - 1;
      ans += b - 2;
      stk[stn++] = 1;
      cnt++;
    } else {
      stk[stn++] = a;
      cnt += a;
      ans += a - 1;
    }
  } else {
    if (a > b) {
      stk[stn++] = a / b;
      cnt += a / b;
      ans += a / b - 1;
      solve(a % b, b);
    } else {
      stk[stn++] = b / a;
      cnt += b / a;
      ans += b / a - 1;
      solve(a, b % a);
    }
  }
}
int best, pos, r, f;
void work() {
  scanf("%d %d", &r, &v);
  best = 0x7FFFFFFF;
  for (int i = 1; i <= v; i++) {
    if (gcd(i, v) == 1) {
      cnt = ans = stn = 0;
      solve(i, v);
      if (cnt == r) {
        if (ans < best) best = ans, pos = i, f = 0;
        ans = cnt = stn = 0;
        solve(v, i);
        if (ans < best) best = ans, pos = i, f = 1;
      }
    }
  }
  if (best == 0x7FFFFFFF) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    ans = cnt = stn = 0;
    if (f == 0)
      solve(pos, v);
    else
      solve(v, pos);
    if (ans < 0) ans = 0;
    cout << ans << endl;
    int flag = 0;
    for (int i = stn - 1; i >= 0; i--) {
      if (flag == 0) {
        for (int j = 0; j < stk[i]; j++) printf("T");
      } else
        for (int j = 0; j < stk[i]; j++) printf("B");
      flag ^= 1;
    }
    cout << endl;
  }
}
int main() {
  work();
  return 0;
}

```


### Prompt

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

problem

At IOI Confectionery, rice crackers are baked using the traditional method since the company was founded. This traditional method is to bake the front side for a certain period of time with charcoal, turn it over when the front side is baked, and bake the back side for a certain period of time with charcoal. While keeping this tradition, rice crackers are baked by machine. This machine arranges and bake rice crackers in a rectangular shape with vertical R (1 ≤ R ≤ 10) rows and horizontal C (1 ≤ C ≤ 10000) columns. Normally, it is an automatic operation, and when the front side is baked, the rice crackers are turned over and the back side is baked all at once.

One day, when I was baking rice crackers, an earthquake occurred just before turning over the rice crackers, and some rice crackers turned over. Fortunately, the condition of the charcoal fire remained appropriate, but if the front side was baked any more, the baking time set by the tradition since the establishment would be exceeded, and the front side of the rice cracker would be overcooked and could not be shipped as a product. .. Therefore, I hurriedly changed the machine to manual operation and tried to turn over only the rice crackers that had not been turned inside out. This machine can turn over several horizontal rows at the same time and several vertical columns at the same time, but unfortunately it cannot turn over rice crackers one by one.

If it takes time to turn it over, the front side of the rice cracker that was not turned over due to the earthquake will be overcooked and cannot be shipped as a product. Therefore, we decided to increase the number of rice crackers that can be baked on both sides without overcooking the front side, that is, the number of "rice crackers that can be shipped". Consider the case where no horizontal rows are flipped, or no vertical columns are flipped. Write a program that outputs the maximum number of rice crackers that can be shipped.

Immediately after the earthquake, the rice crackers are in the state shown in the following figure. The black circles represent the state where the front side is burnt, and the white circles represent the state where the back side is burnt.

<image>

If you turn the first line over, you will see the state shown in the following figure.

<image>

Furthermore, when the 1st and 5th columns are turned over, the state is as shown in the following figure. In this state, 9 rice crackers can be shipped.

<image>

input

The input consists of multiple datasets. Each dataset is given in the following format.

Two integers R and C (1 ≤ R ≤ 10, 1 ≤ C ≤ 10 000) are written on the first line of the input, separated by blanks. The following R line represents the state of the rice cracker immediately after the earthquake. In the (i + 1) line (1 ≤ i ≤ R), C integers ai, 1, ai, 2, ……, ai, C are written separated by blanks, and ai, j are i. It represents the state of the rice cracker in row j. If ai and j are 1, it means that the front side is burnt, and if it is 0, it means that the back side is burnt.

When both C and R are 0, it indicates the end of input. The number of data sets does not exceed 5.

output

For each data set, the maximum number of rice crackers that can be shipped is output on one line.

Examples

Input

2 5
0 1 0 1 0
1 0 0 0 1
3 6
1 0 0 0 1 0
1 1 1 0 1 0
1 0 1 1 0 1
0 0

Output

9
15

Input

None

Output

None

### Response

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

int R,C,senbei[10000][10],f[10],num;

void rec(int);
int count();

int main()
{
  int i,j;
  while(cin>>R>>C,R|C){
    for(j=0;j<R;j++)for(i=0;i<C;i++)cin>>senbei[i][j];
    rec(0);
    cout<<num<<endl;
  }
}

void rec(int k)
{
  if(k==R){
    num=max(num,count());
    return;
  }
  f[k]=0;
  rec(k+1);
  f[k]=1;
  rec(k+1);
}

int count()
{
  int n=0,i,j;
  for(i=0;i<C;i++){
    int cnt=0;
    for(j=0;j<R;j++)cnt+=senbei[i][j]^f[j];
    n+=max(cnt,R-cnt);
  }
  return n;
}
```


### Prompt

Please create a solution in CPP to the following problem:

One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems.

But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name.

It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita".

Names are case sensitive.

Input

The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem.

Output

Print "YES", if problem is from this contest, and "NO" otherwise.

Examples

Input

Alex_and_broken_contest

Output

NO

Input

NikitaAndString

Output

YES

Input

Danil_and_Olya

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}
int main() {
  int i, j, k;
  string s1, s2, s3, s4, s5;
  s1 = "Danil";
  s2 = "Olya";
  s3 = "Slava";
  s4 = "Ann";
  s5 = "Nikita";
  string s;
  cin >> s;
  int x = s1.size();
  int y = s.size();
  int cnt1 = 0;
  int chk = -1;
  if (x > y)
    cnt1 = 0;
  else {
    for (i = 0; i < y; i += 1) {
      chk = 1;
      if (y - i + 1 < x)
        break;
      else {
        k = i;
        for (j = 0; j < x; j += 1) {
          if (s1[j] != s[k]) {
            chk = -1;
            break;
          }
          k += 1;
        }
        if (chk == 1) cnt1 += 1;
      }
    }
  }
  x = s2.size();
  y = s.size();
  int cnt2 = 0;
  chk = -1;
  if (x > y)
    cnt2 = 0;
  else {
    for (i = 0; i < y; i += 1) {
      chk = 1;
      if (y - i + 1 < x)
        break;
      else {
        k = i;
        for (j = 0; j < x; j += 1) {
          if (s2[j] != s[k]) {
            chk = -1;
            break;
          }
          k += 1;
        }
        if (chk == 1) cnt2 += 1;
      }
    }
  }
  x = s3.size();
  y = s.size();
  int cnt3 = 0;
  chk = -1;
  if (x > y)
    cnt3 = 0;
  else {
    for (i = 0; i < y; i += 1) {
      chk = 1;
      if (y - i + 1 < x)
        break;
      else {
        k = i;
        for (j = 0; j < x; j += 1) {
          if (s3[j] != s[k]) {
            chk = -1;
            break;
          }
          k += 1;
        }
        if (chk == 1) cnt3 += 1;
      }
    }
  }
  x = s4.size();
  y = s.size();
  int cnt4 = 0;
  chk = -1;
  if (x > y)
    cnt4 = 0;
  else {
    for (i = 0; i < y; i += 1) {
      chk = 1;
      if (y - i + 1 < x)
        break;
      else {
        k = i;
        for (j = 0; j < x; j += 1) {
          if (s4[j] != s[k]) {
            chk = -1;
            break;
          }
          k += 1;
        }
        if (chk == 1) cnt4 += 1;
      }
    }
  }
  x = s5.size();
  y = s.size();
  int cnt5 = 0;
  chk = -1;
  if (x > y)
    cnt5 = 0;
  else {
    for (i = 0; i < y; i += 1) {
      chk = 1;
      if (y - i + 1 < x)
        break;
      else {
        k = i;
        for (j = 0; j < x; j += 1) {
          if (s5[j] != s[k]) {
            chk = -1;
            break;
          }
          k += 1;
        }
        if (chk == 1) cnt5 += 1;
      }
    }
  }
  int sum = cnt1 + cnt2 + cnt3 + cnt4 + cnt5;
  if (sum == 1)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}

```


### Prompt

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

There are N towns in Takahashi Kingdom. They are conveniently numbered 1 through N.

Takahashi the king is planning to go on a tour of inspection for M days. He will determine a sequence of towns c, and visit town c_i on the i-th day. That is, on the i-th day, he will travel from his current location to town c_i. If he is already at town c_i, he will stay at that town. His location just before the beginning of the tour is town 1, the capital. The tour ends at town c_M, without getting back to the capital.

The problem is that there is no paved road in this kingdom. He decided to resolve this issue by paving the road himself while traveling. When he travels from town a to town b, there will be a newly paved one-way road from town a to town b.

Since he cares for his people, he wants the following condition to be satisfied after his tour is over: "it is possible to travel from any town to any other town by traversing roads paved by him". How many sequences of towns c satisfy this condition?

Constraints

* 2≦N≦300
* 1≦M≦300

Input

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

N M

Output

Print the number of sequences of towns satisfying the condition, modulo 1000000007 (=10^9+7).

Examples

Input

3 3

Output

2

Input

150 300

Output

734286322

Input

300 150

Output

0

### Response

```cpp
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

ll p[301];
ll pas[301][301];
void init() {
	p[0] = 1;
	rep1(i, 300) {
		p[i] = p[i - 1] * i%mod;
	}
	rep(i, 301) {
		rep(j, 301) {
			if (i == 0 || j == 0)pas[i][j] = 1;
			else pas[i][j] = (pas[i - 1][j] + pas[i][j - 1]) % mod;
		}
	}
}
ll dp[301][301];
ll cop[301][301];
int main() {
	init();
	int n, m; cin >> n >> m;
	dp[1][0] = 1;
	rep(i, m) {
		rep(j, n+1) {
			rep(k, n+1) {
				cop[j][k] = 0;
			}
		}
		rep(j, n+1) {
			rep(k, n+1) {
				if (j + k > n)continue;
				(cop[j + k][0] += dp[j][k] * j%mod) %= mod;
				(cop[j][k] += dp[j][k] * k%mod) %= mod;
				if (j + k < n) {
					(cop[j][k + 1] += dp[j][k] * (n - j - k)%mod) %= mod;
				}
			}
		}

		rep(j, n+1) {
			rep(k, n+1) {
				dp[j][k] = cop[j][k];
			}
		}
	}
	cout << dp[n][0] << endl;
	//stop
	return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

You are given an integer N.

Find a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w.

If there are multiple solutions, any of them will be accepted.

Constraints

* It is guaranteed that, for the given integer N, there exists a solution such that h,n,w \leq 3500.

Inputs

Input is given from Standard Input in the following format:

N

Outputs

Print a triple of positive integers h, n and w that satisfies the condition, in the following format:

h n w

Examples

Input

2

Output

1 2 2

Input

3485

Output

872 1012974 1539173474040

Input

4664

Output

3498 3498 3498

### Response

```cpp
#include<bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
ll N;
int main(){
	cin>>N;
	ll n;
	FOR(h,1,3501){
		FOR(w,1,3501){
			if(4*h*w-N*w-N*h>0 && N*w*h%(4*h*w-N*w-N*h)==0){
				n=N*w*h/(4*h*w-N*w-N*h);
				cout<<h<<" "<<n<<" "<<w<<endl;
				return 0;
			}
		}
	}
}
```


### Prompt

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

There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.

When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).

In how many ways can the knight reach the square (X, Y)?

Find the number of ways modulo 10^9 + 7.

Constraints

* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

X Y

Output

Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.

Examples

Input

3 3

Output

2

Input

2 2

Output

0

Input

999999 999999

Output

151840682

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long m=1000000007,ans;
  int x,y,a,b;cin>>x>>y;
  if((x+y)%3==0){
    a=(2*y-x)/3;b=(2*x-y)/3;
    if(a<0||b<0)cout<<0<<endl;
    else{
    long long p=1,q=1;
    for(int i=a+b;i>a;i--){
      p*=i;
      p=p%m;
      q*=i-a;
      q=q%m;
    }
    for(int i=0;i<m;i++){
      if(i*q%m==p){ans=i;break;}
    }
    cout<<ans<<endl;
    }
  }
  else cout<<0<<endl;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Little Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vitaly's algorithm works with string s, consisting of characters "x" and "y", and uses two following operations at runtime:

  1. Find two consecutive characters in the string, such that the first of them equals "y", and the second one equals "x" and swap them. If there are several suitable pairs of characters, we choose the pair of characters that is located closer to the beginning of the string.
  2. Find in the string two consecutive characters, such that the first of them equals "x" and the second one equals "y". Remove these characters from the string. If there are several suitable pairs of characters, we choose the pair of characters that is located closer to the beginning of the string.

The input for the new algorithm is string s, and the algorithm works as follows:

  1. If you can apply at least one of the described operations to the string, go to step 2 of the algorithm. Otherwise, stop executing the algorithm and print the current string.
  2. If you can apply operation 1, then apply it. Otherwise, apply operation 2. After you apply the operation, go to step 1 of the algorithm.

Now Vitaly wonders, what is going to be printed as the result of the algorithm's work, if the input receives string s.

Input

The first line contains a non-empty string s.

It is guaranteed that the string only consists of characters "x" and "y". It is guaranteed that the string consists of at most 106 characters. It is guaranteed that as the result of the algorithm's execution won't be an empty string.

Output

In the only line print the string that is printed as the result of the algorithm's work, if the input of the algorithm input receives string s.

Examples

Input

x

Output

x

Input

yxyxy

Output

y

Input

xxxxxy

Output

xxxx

Note

In the first test the algorithm will end after the first step of the algorithm, as it is impossible to apply any operation. Thus, the string won't change.

In the second test the transformation will be like this:

  1. string "yxyxy" transforms into string "xyyxy";
  2. string "xyyxy" transforms into string "xyxyy";
  3. string "xyxyy" transforms into string "xxyyy";
  4. string "xxyyy" transforms into string "xyy";
  5. string "xyy" transforms into string "y".

As a result, we've got string "y".

In the third test case only one transformation will take place: string "xxxxxy" transforms into string "xxxx". Thus, the answer will be string "xxxx".

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  int num_x = 0, num_y = 0;
  char c;
  while ((c = getchar()) != '\n') {
    if (c == 'x') {
      ++num_x;
    } else if (c == 'y') {
      ++num_y;
    }
  }
  if (num_y > num_x) {
    for (int i = 0; i < (int)(num_y - num_x); ++i) {
      putchar('y');
    }
  } else {
    for (int i = 0; i < (int)(num_x - num_y); ++i) {
      putchar('x');
    }
  }
  putchar('\n');
  return 0;
}

```


### Prompt

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

You are given two arrays a and b of positive integers, with length n and m respectively.

Let c be an n × m matrix, where c_{i,j} = a_i ⋅ b_j.

You need to find a subrectangle of the matrix c such that the sum of its elements is at most x, and its area (the total number of elements) is the largest possible.

Formally, you need to find the largest number s such that it is possible to choose integers x_1, x_2, y_1, y_2 subject to 1 ≤ x_1 ≤ x_2 ≤ n, 1 ≤ y_1 ≤ y_2 ≤ m, (x_2 - x_1 + 1) × (y_2 - y_1 + 1) = s, and $$$∑_{i=x_1}^{x_2}{∑_{j=y_1}^{y_2}{c_{i,j}}} ≤ x.$$$

Input

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

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 2000).

The third line contains m integers b_1, b_2, …, b_m (1 ≤ b_i ≤ 2000).

The fourth line contains a single integer x (1 ≤ x ≤ 2 ⋅ 10^{9}).

Output

If it is possible to choose four integers x_1, x_2, y_1, y_2 such that 1 ≤ x_1 ≤ x_2 ≤ n, 1 ≤ y_1 ≤ y_2 ≤ m, and ∑_{i=x_1}^{x_2}{∑_{j=y_1}^{y_2}{c_{i,j}}} ≤ x, output the largest value of (x_2 - x_1 + 1) × (y_2 - y_1 + 1) among all such quadruplets, otherwise output 0.

Examples

Input

3 3
1 2 3
1 2 3
9

Output

4

Input

5 1
5 4 2 4 5
2
5

Output

1

Note

Matrix from the first sample and the chosen subrectangle (of blue color):

<image>

Matrix from the second sample and the chosen subrectangle (of blue color):

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
const long long inf = 1e18 + 5;
long long n, m, x;
long long a[maxn], b[maxn];
long long ma[maxn * maxn], mb[maxn * maxn];
void input() {
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] += a[i - 1];
    ma[i] = inf;
  }
  for (long long i = 1; i <= m; ++i) {
    cin >> b[i];
    b[i] += b[i - 1];
    mb[i] = inf;
  }
  cin >> x;
}
void slove() {
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 0; j < i; ++j) {
      ma[i - j] = min(ma[i - j], a[i] - a[j]);
    }
  }
  for (long long i = 1; i <= m; ++i) {
    for (long long j = 0; j < i; ++j) {
      mb[i - j] = min(mb[i - j], b[i] - b[j]);
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= m; ++j) {
      if (ma[i] * mb[j] <= x) {
        ans = max(ans, i * j);
      }
    }
  }
  cout << ans << endl;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  input();
  slove();
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

Once upon a time in the galaxy of far, far away...

Darth Wader found out the location of a rebels' base. Now he is going to destroy the base (and the whole planet that the base is located at), using the Death Star.

When the rebels learnt that the Death Star was coming, they decided to use their new secret weapon — space mines. Let's describe a space mine's build.

Each space mine is shaped like a ball (we'll call it the mine body) of a certain radius r with the center in the point O. Several spikes protrude from the center. Each spike can be represented as a segment, connecting the center of the mine with some point P, such that <image> (transporting long-spiked mines is problematic), where |OP| is the length of the segment connecting O and P. It is convenient to describe the point P by a vector p such that P = O + p.

The Death Star is shaped like a ball with the radius of R (R exceeds any mine's radius). It moves at a constant speed along the v vector at the speed equal to |v|. At the moment the rebels noticed the Star of Death, it was located in the point A.

The rebels located n space mines along the Death Star's way. You may regard the mines as being idle. The Death Star does not know about the mines' existence and cannot notice them, which is why it doesn't change the direction of its movement. As soon as the Star of Death touched the mine (its body or one of the spikes), the mine bursts and destroys the Star of Death. A touching is the situation when there is a point in space which belongs both to the mine and to the Death Star. It is considered that Death Star will not be destroyed if it can move infinitely long time without touching the mines.

Help the rebels determine whether they will succeed in destroying the Death Star using space mines or not. If they will succeed, determine the moment of time when it will happen (starting from the moment the Death Star was noticed).

Input

The first input data line contains 7 integers Ax, Ay, Az, vx, vy, vz, R. They are the Death Star's initial position, the direction of its movement, and its radius ( - 10 ≤ vx, vy, vz ≤ 10, |v| > 0, 0 < R ≤ 100).

The second line contains an integer n, which is the number of mines (1 ≤ n ≤ 100). Then follow n data blocks, the i-th of them describes the i-th mine.

The first line of each block contains 5 integers Oix, Oiy, Oiz, ri, mi, which are the coordinates of the mine centre, the radius of its body and the number of spikes (0 < ri < 100, 0 ≤ mi ≤ 10). Then follow mi lines, describing the spikes of the i-th mine, where the j-th of them describes the i-th spike and contains 3 integers pijx, pijy, pijz — the coordinates of the vector where the given spike is directed (<image>).

The coordinates of the mines' centers and the center of the Death Star are integers, their absolute value does not exceed 10000. It is guaranteed that R > ri for any 1 ≤ i ≤ n. For any mines i ≠ j the following inequality if fulfilled: <image>. Initially the Death Star and the mines do not have common points.

Output

If the rebels will succeed in stopping the Death Star using space mines, print the time from the moment the Death Star was noticed to the blast.

If the Death Star will not touch a mine, print "-1" (without quotes).

For the answer the absolute or relative error of 10 - 6 is acceptable.

Examples

Input

0 0 0 1 0 0 5
2
10 8 0 2 2
0 -3 0
2 2 0
20 0 0 4 3
2 4 0
-4 3 0
1 -5 0

Output

10.0000000000

Input

8 8 4 4 4 2 6
1
-2 -2 -1 3 0

Output

-1

Input

30 30 2 1 2 1 20
3
0 0 40 5 1
1 4 4
-10 -40 -5 7 0
100 200 95 8 1
-10 0 0

Output

74.6757620881

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000;
const double eps = 1e-8;
const double PI = atan2(0.0, -1.0);
inline double sqr(double x) { return x * x; }
inline bool zero(double x) { return (x > 0 ? x : -x) < eps; }
inline int sgn(double x) { return (x > eps ? 1 : (x + eps < 0 ? -1 : 0)); }
struct point3 {
  double x, y, z;
  point3(double x, double y, double z) : x(x), y(y), z(z) {}
  point3() {}
  bool operator==(const point3& a) const {
    return sgn(x - a.x) == 0 && sgn(y - a.y) == 0 && sgn(z - a.z) == 0;
  }
  bool operator!=(const point3& a) const {
    return sgn(x - a.x) != 0 || sgn(y - a.y) != 0 || sgn(z - a.z) != 0;
  }
  bool operator<(const point3& a) const {
    return sgn(x - a.x) < 0 || sgn(x - a.x) == 0 && sgn(y - a.y) < 0 ||
           sgn(x - a.x) == 0 && sgn(y - a.y) == 0 && sgn(z - a.z) < 0;
  }
  point3 operator+(const point3& a) const {
    return point3(x + a.x, y + a.y, z + a.z);
  }
  point3 operator-(const point3& a) const {
    return point3(x - a.x, y - a.y, z - a.z);
  }
  point3 operator*(const double& a) const {
    return point3(x * a, y * a, z * a);
  }
  point3 operator/(const double& a) const {
    return point3(x / a, y / a, z / a);
  }
  point3 operator*(const point3& a) const {
    return point3(y * a.z - z * a.y, z * a.x - x * a.z, x * a.y - y * a.x);
  }
  double operator^(const point3& a) const {
    return x * a.x + y * a.y + z * a.z;
  }
  double sqrlen() const { return sqr(x) + sqr(y) + sqr(z); }
  double length() const { return sqrt(sqrlen()); }
  point3 trunc(double a) const { return (*this) * (a / length()); }
  point3 rotate(const point3& a, const point3& b, const point3& c) const {
    return point3(a ^ (*this), b ^ (*this), c ^ (*this));
  }
};
inline point3 pvec(const point3& a, const point3& b, const point3& c) {
  return (a - b) * (b - c);
}
inline bool dotsInline(const point3& a, const point3& b, const point3& c) {
  return zero(((a - b) * (b - c)).length());
}
inline bool dotOnlineIn(const point3& p, const point3& l1, const point3& l2) {
  return zero(((p - l1) * (p - l2)).length()) &&
         (l1.x - p.x) * (l2.x - p.x) < eps &&
         (l1.y - p.y) * (l2.y - p.y) < eps && (l1.z - p.z) * (l2.z - p.z) < eps;
}
inline int decideSide(const point3& p1, const point3& p2, const point3& l1,
                      const point3& l2) {
  return sgn(((l1 - l2) * (p1 - l2)) ^ ((l1 - l2) * (p2 - l2)));
}
inline int decideSide(const point3& p1, const point3& p2, const point3& a,
                      const point3& b, const point3& c) {
  return sgn((pvec(a, b, c) ^ (p1 - a)) * (pvec(a, b, c) ^ (p2 - a)));
}
inline bool parallel(const point3& u1, const point3& u2, const point3& v1,
                     const point3& v2) {
  return zero(((u1 - u2) * (v1 - v2)).length());
}
inline bool parallel(const point3& a, const point3& b, const point3& c,
                     const point3& d, const point3& e, const point3& f) {
  return zero((pvec(a, b, c) * pvec(d, e, f)).length());
}
inline bool parallel(const point3& l1, const point3& l2, const point3& a,
                     const point3& b, const point3& c) {
  return zero((l1 - l2) ^ pvec(a, b, c));
}
point3 intersection(const point3& l1, const point3& l2, const point3& a,
                    const point3& b, const point3& c) {
  point3 temp = pvec(a, b, c);
  return l1 + (l2 - l1) * ((temp ^ (a - l1)) / (temp ^ (l2 - l1)));
}
void intersection(const point3& a, const point3& b, const point3& c,
                  const point3& d, const point3& e, const point3& f, point3& p1,
                  point3& p2) {
  p1 = parallel(d, e, a, b, c) ? intersection(e, f, a, b, c)
                               : intersection(d, e, a, b, c);
  p2 = parallel(f, d, a, b, c) ? intersection(e, f, a, b, c)
                               : intersection(f, d, a, b, c);
}
inline point3 ptoline(const point3& p, const point3& l1, const point3& l2) {
  point3 temp = l2 - l1;
  return l1 + temp * ((p - l1) ^ temp) / (temp ^ temp);
}
inline point3 ptoplane(const point3& p, const point3& a, const point3& b,
                       const point3& c) {
  return intersection(p, p + pvec(a, b, c), a, b, c);
}
inline double dislinetoline(const point3& u1, const point3& u2,
                            const point3& v1, const point3& v2) {
  point3 temp = (u1 - u2) * (v1 - v2);
  return fabs((u1 - v1) ^ temp) / temp.length();
}
void linetoline(const point3& u1, const point3& u2, const point3& v1,
                const point3& v2, point3& p1, point3& p2) {
  point3 ab = u2 - u1, cd = v2 - v1, ac = v1 - u1;
  p2 = v1 + cd * (((ab ^ cd) * (ac ^ ab) - (ab ^ ab) * (ac ^ cd)) /
                  ((ab ^ ab) * (cd ^ cd) - sqr(ab ^ cd)));
  p1 = ptoline(p2, u1, u2);
}
const double EPS = 1e-8;
const double INF = 1e6;
double gao(const point3& u, const point3& v, double r) {
  double a = (v ^ v);
  double b = 2 * (u ^ v);
  double c = (u ^ u) - r * r;
  double d = b * b - 4 * a * c;
  if (d < -EPS) {
    return INF;
  }
  d = sqrt(max(0.0, d));
  double t1 = (-b - d) / (2 * a);
  double t2 = (-b + d) / (2 * a);
  if (t1 > t2) {
    swap(t1, t2);
  }
  if (t1 > -EPS) {
    return t1;
  } else if (t2 > -EPS) {
    return t2;
  } else {
    return INF;
  }
}
double dis(const point3& a, const point3& b, const point3& c) {
  if (dotOnlineIn(c, a, b)) {
    return 0.0;
  } else {
    return min((c - a).length(), (c - b).length());
  }
}
double gao(point3 a, point3 b, point3 c, point3 d) {
  double ret = min(min((c - a).length(), (d - a).length()),
                   min((c - b).length(), (d - b).length()));
  double tmp = dislinetoline(a, b, c, d);
  if (parallel(a, b, c, d)) {
    c = ptoline(c, a, b);
    d = ptoline(d, a, b);
    ret = min(ret, hypot(tmp, dis(a, b, c)));
    ret = min(ret, hypot(tmp, dis(a, b, d)));
    ret = min(ret, hypot(tmp, dis(c, d, a)));
    ret = min(ret, hypot(tmp, dis(c, d, b)));
  } else {
    point3 u, v;
    linetoline(a, b, c, d, u, v);
    if (dotOnlineIn(u, a, b) && dotOnlineIn(v, c, d)) {
      ret = min(ret, dislinetoline(a, b, c, d));
    }
    u = ptoline(a, c, d);
    if (dotOnlineIn(u, c, d)) {
      ret = min(ret, (a - u).length());
    }
    u = ptoline(b, c, d);
    if (dotOnlineIn(u, c, d)) {
      ret = min(ret, (b - u).length());
    }
    u = ptoline(c, a, b);
    if (dotOnlineIn(u, a, b)) {
      ret = min(ret, (c - u).length());
    }
    u = ptoline(d, a, b);
    if (dotOnlineIn(u, a, b)) {
      ret = min(ret, (d - u).length());
    }
  }
  return ret;
}
int main() {
  int n, m, p;
  point3 a[200], b[10000], c[1000], v;
  double r[200], lo = 0, up = INF;
  scanf("%lf%lf%lf%lf%lf%lf%lf", &a[0].x, &a[0].y, &a[0].z, &v.x, &v.y, &v.z,
        &r[0]);
  scanf("%d", &n);
  m = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%lf%lf%lf%lf%d", &a[i].x, &a[i].y, &a[i].z, &r[i], &p);
    up = min(up, gao(a[0] - a[i], v, r[0] + r[i]));
    for (int j = 0; j < p; ++j) {
      scanf("%lf%lf%lf", &c[m].x, &c[m].y, &c[m].z);
      b[m] = a[i];
      c[m] = b[m] + c[m];
      ++m;
    }
  }
  for (int tt = 0; tt < 1000; ++tt) {
    double mid = (lo + up) / 2;
    point3 aa = a[0] + v * mid;
    bool flag = true;
    for (int i = 0; flag && i < m; ++i) {
      if (gao(a[0], aa, b[i], c[i]) <= r[0]) {
        flag = false;
      }
    }
    if (flag) {
      lo = mid;
    } else {
      up = mid;
    }
  }
  lo = (lo + up) / 2;
  if (lo > INF / 2) {
    puts("-1");
  } else {
    printf("%.10lf\n", lo);
  }
  return 0;
}

```


### Prompt

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

C*++ language is quite similar to C++. The similarity manifests itself in the fact that the programs written in C*++ sometimes behave unpredictably and lead to absolutely unexpected effects. For example, let's imagine an arithmetic expression in C*++ that looks like this (expression is the main term):

  * expression ::= summand | expression + summand | expression - summand
  * summand ::= increment | coefficient*increment
  * increment ::= a++ | ++a
  * coefficient ::= 0|1|2|...|1000

For example, "5*a++-3*++a+a++" is a valid expression in C*++.

Thus, we have a sum consisting of several summands divided by signs "+" or "-". Every summand is an expression "a++" or "++a" multiplied by some integer coefficient. If the coefficient is omitted, it is suggested being equal to 1.

The calculation of such sum in C*++ goes the following way. First all the summands are calculated one after another, then they are summed by the usual arithmetic rules. If the summand contains "a++", then during the calculation first the value of the "a" variable is multiplied by the coefficient, then value of "a" is increased by 1. If the summand contains "++a", then the actions on it are performed in the reverse order: first "a" is increased by 1, then — multiplied by the coefficient.

The summands may be calculated in any order, that's why sometimes the result of the calculation is completely unpredictable! Your task is to find its largest possible value.

Input

The first input line contains an integer a ( - 1000 ≤ a ≤ 1000) — the initial value of the variable "a". The next line contains an expression in C*++ language of the described type. The number of the summands in the expression does not exceed 1000. It is guaranteed that the line describing the expression contains no spaces and tabulation.

Output

Output a single number — the maximal possible value of the expression.

Examples

Input

1
5*a++-3*++a+a++

Output

11

Input

3
a+++++a

Output

8

Note

Consider the second example. Initially a = 3. Suppose that at first the first summand is calculated, and then the second one is. The first summand gets equal to 3, and the value of a is increased by 1. At the calculation of the second summand a is increased once more (gets equal to 5). The value of the second summand is 5, and together they give 8. If we calculate the second summand first and the first summand later, then the both summands equals to 4, and the result is 8, too.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int eprintf(const char *format, ...) { return 0; }
char buf[65536];
int pos;
enum Ty { PREFIX, POSTFIX };
struct Sum {
  int k;
  Ty ty;
  Sum() { k = 0; }
  Sum(int _k, Ty _ty) {
    k = _k;
    ty = _ty;
  }
  bool operator<(const Sum &b) const {
    if (k < b.k) return true;
    if (k > b.k) return false;
    return !ty < !b.ty;
  }
};
Sum parseSum(int sgn) {
  bool wasK = false;
  int k = 0;
  while (buf[pos] >= '0' && buf[pos] <= '9') {
    wasK = true;
    k = k * 10 + buf[pos] - '0';
    pos++;
  }
  if (wasK)
    assert(buf[pos++] == '*');
  else
    k = 1;
  k *= sgn;
  if (buf[pos] == 'a') {
    pos++;
    assert(buf[pos++] == '+');
    assert(buf[pos++] == '+');
    return Sum(k, POSTFIX);
  } else {
    assert(buf[pos++] == '+');
    assert(buf[pos++] == '+');
    assert(buf[pos++] == 'a');
    return Sum(k, PREFIX);
  }
}
int main() {
  int a;
  while (scanf("%d%s", &a, buf) >= 2) {
    pos = 0;
    vector<Sum> expr;
    while (buf[pos]) {
      int sgn = 1;
      if (pos) {
        assert(buf[pos] == '+' || buf[pos] == '-');
        if (buf[pos] == '-') sgn = -1;
        pos++;
      }
      expr.push_back(parseSum(sgn));
    }
    sort(expr.begin(), expr.end());
    int res = 0;
    for (int i = 0; i < expr.size(); i++) {
      eprintf("%d (%d)\n", expr[i].k, expr[i].ty);
      switch (expr[i].ty) {
        case PREFIX:
          res += ++a * expr[i].k;
          break;
        case POSTFIX:
          res += a++ * expr[i].k;
          break;
      }
    }
    eprintf("---\n");
    printf("%d\n", res);
    break;
  }
  return 0;
}

```


### Prompt

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

There are lots of theories concerning the origin of moon craters. Most scientists stick to the meteorite theory, which says that the craters were formed as a result of celestial bodies colliding with the Moon. The other version is that the craters were parts of volcanoes.

An extraterrestrial intelligence research specialist professor Okulov (the namesake of the Okulov, the author of famous textbooks on programming) put forward an alternate hypothesis. Guess what kind of a hypothesis it was –– sure, the one including extraterrestrial mind involvement. Now the professor is looking for proofs of his hypothesis.

Professor has data from the moon robot that moves linearly in one direction along the Moon surface. The moon craters are circular in form with integer-valued radii. The moon robot records only the craters whose centers lay on his path and sends to the Earth the information on the distance from the centers of the craters to the initial point of its path and on the radii of the craters.

According to the theory of professor Okulov two craters made by an extraterrestrial intelligence for the aims yet unknown either are fully enclosed one in the other or do not intersect at all. Internal or external tangency is acceptable. However the experimental data from the moon robot do not confirm this theory! Nevertheless, professor Okulov is hopeful. He perfectly understands that to create any logical theory one has to ignore some data that are wrong due to faulty measuring (or skillful disguise by the extraterrestrial intelligence that will be sooner or later found by professor Okulov!) That’s why Okulov wants to choose among the available crater descriptions the largest set that would satisfy his theory.

Input

The first line has an integer n (1 ≤ n ≤ 2000) — the number of discovered craters. The next n lines contain crater descriptions in the "ci ri" format, where ci is the coordinate of the center of the crater on the moon robot’s path, ri is the radius of the crater. All the numbers ci and ri are positive integers not exceeding 109. No two craters coincide.

Output

In the first line output the number of craters in the required largest set. In the next line output space-separated numbers of craters that this set consists of. The craters are numbered from 1 to n in the order in which they were given in the input data. The numbers may be output in any order. If the result is not unique, output any.

Examples

Input

4
1 1
2 2
4 1
5 1

Output

3
1 2 4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int n, m;
int low[N], high[N];
int id[2 * N][2 * N];
vector<int> v[2 * N];
map<int, int> mp;
int dp[2 * N][2 * N];
vector<int> ansv;
int dfs(int l, int r) {
  int i;
  if (dp[l][r] != -1) return dp[l][r];
  if (l == r) return dp[l][r] = 0;
  int cur = 0;
  if (id[l][r] != -1) cur = 1;
  int ans = cur + dfs(l, r - 1);
  for (int i = 0; i < v[r].size(); i++) {
    int x = low[v[r][i]];
    if (x <= l) continue;
    int tmp = cur + dfs(l, x) + dfs(x, r);
    ans = max(ans, tmp);
  }
  return dp[l][r] = ans;
}
void path(int l, int r) {
  int i;
  if (l == r) return;
  int cur = 0;
  if (id[l][r] != -1) {
    cur = 1;
    ansv.push_back(id[l][r]);
  }
  if (dp[l][r] == cur + dp[l][r - 1]) {
    path(l, r - 1);
    return;
  }
  for (int i = 0; i < v[r].size(); i++) {
    int x = low[v[r][i]];
    if (x <= l) continue;
    if (dp[l][r] == cur + dp[l][x] + dp[x][r]) {
      path(l, x);
      path(x, r);
      return;
    }
  }
}
int main() {
  int i, j, c, r;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c >> r;
    low[i] = c - r;
    high[i] = c + r;
    mp[low[i]] = mp[high[i]] = 0;
  }
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    (itr->second) = m;
    m++;
  }
  for (int i = 0; i < n; i++) {
    low[i] = mp[low[i]];
    high[i] = mp[high[i]];
    v[high[i]].push_back(i);
  }
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) id[i][j] = -1;
  for (int i = 0; i < n; i++) id[low[i]][high[i]] = i;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++) dp[i][j] = -1;
  int ans = dfs(0, m - 1);
  cout << ans << endl;
  path(0, m - 1);
  for (int i = 0; i < ansv.size(); i++) cout << ansv[i] + 1 << ' ';
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

Piegirl found the red button. You have one last chance to change the inevitable end.

The circuit under the button consists of n nodes, numbered from 0 to n - 1. In order to deactivate the button, the n nodes must be disarmed in a particular order. Node 0 must be disarmed first. After disarming node i, the next node to be disarmed must be either node (2·i) modulo n or node (2·i) + 1 modulo n. The last node to be disarmed must be node 0. Node 0 must be disarmed twice, but all other nodes must be disarmed exactly once.

Your task is to find any such order and print it. If there is no such order, print -1.

Input

Input consists of a single integer n (2 ≤ n ≤ 105).

Output

Print an order in which you can to disarm all nodes. If it is impossible, print -1 instead. If there are multiple orders, print any one of them.

Examples

Input

2

Output

0 1 0

Input

3

Output

-1

Input

4

Output

0 1 3 2 0

Input

16

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
int q[100001];
int was[100001];
int w[100001];
int p[100001];
int bad = 0;
int go(int x, int y) {
  q[y] = x;
  if (y + 1 == n && (2 * x) % n == 0) {
    for (int i = 0; i <= y; i++) printf("%d ", q[i]);
    printf("0\n");
    return 1;
  }
  was[x] = 1;
  p[x] = rand() & 1;
  int a = (2 * x + p[x]) % n;
  int b = (2 * x + 1 - p[x]) % n;
  if (!was[a] && go(a, y + 1) || was[a] && !was[b] && go(b, y + 1)) return 1;
  if (!was[a] && !was[b] && bad) {
    bad--;
    if (go(b, y + 1)) return 1;
  }
  was[x] = 0;
  return 0;
}
int main() {
  scanf("%d", &n);
  if (n & 1)
    printf("-1");
  else {
    do {
      bad = 20;
      if (go(0, 0)) return 0;
    } while (true);
  }
  return 0;
}

```


### Prompt

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

Fennec and Snuke are playing a board game.

On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.

Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn:

* Fennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.
* Snuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.

A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.

Constraints

* 2 \leq N \leq 10^5
* 1 \leq a_i, b_i \leq N
* The given graph is a tree.

Input

Input is given from Standard Input in the following format:

N
a_1 b_1
:
a_{N-1} b_{N-1}

Output

If Fennec wins, print `Fennec`; if Snuke wins, print `Snuke`.

Examples

Input

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

Output

Fennec

Input

4
1 4
4 2
2 3

Output

Snuke

### Response

```cpp
#include<cstdio>
#include<vector>
using namespace std;
int n, m;
int depth[100010];
int sz[100010];
int parse[100010];
vector<vector<int>> vt;
void dfs(int here, int de)
{
	depth[here] = de;
	sz[here] = 1;
	for (int i = 0; i < vt[here].size(); i++)
	{
		int next = vt[here][i];
		if (!depth[next])
		{
			parse[next] = here;
			dfs(next, de + 1);
			sz[here] += sz[next];
		}
	}
}
int main()
{
	scanf("%d", &n);
	int sum = n;
	vt.resize(n + 1);
	for (int i = 0; i < n - 1; i++)
	{
		int q, w;
		scanf("%d %d", &q, &w);
		vt[q].push_back(w);
		vt[w].push_back(q);
	}
	dfs(1, 1);
	int ch = depth[n]-depth[1] - 1;
	int ch1 = 0, ch2 = 0;
	ch /= 2;
	while (ch--) {
		n = parse[n];
	}
	ch1 = sz[n];
	ch2 = sum - sz[n];
	if (ch1 >= ch2)
		puts("Snuke");
	else
		puts("Fennec");
}
```


### Prompt

Generate a CPP solution to the following problem:

The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has business of national importance. For example, he has to pay an official visit to square t. As the king is not in habit of wasting his time, he wants to get from his current position s to square t in the least number of moves. Help him to do this.

<image>

In one move the king can get to the square that has a common side or a common vertex with the square the king is currently in (generally there are 8 different squares he can move to).

Input

The first line contains the chessboard coordinates of square s, the second line — of square t.

Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from a to h), the second one is a digit from 1 to 8.

Output

In the first line print n — minimum number of the king's moves. Then in n lines print the moves themselves. Each move is described with one of the 8: L, R, U, D, LU, LD, RU or RD.

L, R, U, D stand respectively for moves left, right, up and down (according to the picture), and 2-letter combinations stand for diagonal moves. If the answer is not unique, print any of them.

Examples

Input

a8
h1

Output

7
RD
RD
RD
RD
RD
RD
RD

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Move {
  int x, y, step;
  string mv;
};
int d[8][2] = {-1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -1, 1, 1, 1, 1, -1};
string dirs[8] = {"L\n", "R\n", "D\n", "U\n", "LD\n", "LU\n", "RU\n", "RD\n"};
int main() {
  int sx, ex, sy, ey;
  string s, e;
  cin >> s >> e;
  sx = s[0] - 'a';
  sy = s[1] - '1';
  ex = e[0] - 'a';
  ey = e[1] - '1';
  int visit[10][10];
  memset(visit, 0, sizeof(visit));
  Move tmp;
  tmp.x = sx, tmp.y = sy, tmp.step = 0, tmp.mv = "";
  queue<Move> qu;
  qu.push(tmp);
  while (!qu.empty()) {
    tmp = qu.front();
    qu.pop();
    if (tmp.x == ex && tmp.y == ey) {
      cout << tmp.step << endl;
      cout << tmp.mv;
      return 0;
    }
    Move q;
    for (int i = 0; i < 8; i++) {
      q = tmp;
      q.x += d[i][0];
      q.y += d[i][1];
      if (q.x < 0 || q.y < 0 || q.x > 7 || q.y > 7 || visit[q.x][q.y]) continue;
      visit[q.x][q.y] = true;
      ++q.step;
      q.mv += dirs[i];
      qu.push(q);
    }
  }
  return 0;
}

```


### Prompt

Generate a Cpp solution to 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 "bits/stdc++.h"
using namespace std;

long long INF = (1 << 31) - 1;

class LazySegmentTree {
private:
	long long Size;
	vector<long long> Node, Lazy;
public:
	LazySegmentTree(long long N) {
		Size = 1;
		while (Size < N) Size <<= 1;
		Node.assign(Size * 2, 0);
		Lazy.assign(Size * 2, 0);
	}
	void Eval(long long K, long long L, long long R) {
		if (Lazy[K] != 0) {
			Node[K] += Lazy[K];
			if (R - L > 1) {
				Lazy[K * 2] += Lazy[K];
				Lazy[K * 2 + 1] += Lazy[K];
			}
			Lazy[K] = 0;
		}
	}
	void Update(long long A, long long B, long long X, long long K, long long L, long long R) {
		Eval(K, L, R);
		if (B <= L || R <= A) return;
		if (A <= L && R <= B) {
			Lazy[K] += X;
			Eval(K, L, R);
			return;
		}
		Update(A, B, X, K * 2, L, (L + R) / 2);
		Update(A, B, X, K * 2 + 1, (L + R) / 2, R);
		Node[K] = min(Node[K * 2], Node[K * 2 + 1]);
	}
	void Update(long long A, long long B, long long X) {
		Update(A, B, X, 1, 0, Size);
		return;
	}
	long long Query(long long A, long long B, long long K, long long L, long long R) {
		Eval(K, L, R);
		if (B <= L || R <= A) return INF;
		if (A <= L && R <= B) return Node[K];
		return min(Query(A, B, K * 2, L, (L + R) / 2), Query(A, B, K * 2 + 1, (L + R) / 2, R));
	}
	long long Query(long long A, long long B) {
		return Query(A, B, 1, 0, Size);
	}
};

int main() {
	long long N, Q;
	cin >> N >> Q;
	LazySegmentTree Seg(N);
	for (int i = 0; i < Q; i++) {
		long long Mode;
		cin >> Mode;
		if (Mode == 0) {
			long long A, B, X;
			cin >> A >> B >> X;
			Seg.Update(A, B + 1, X);
		}
		else {
			long long A, B;
			cin >> A >> B;
			cout << Seg.Query(A, B + 1) << endl;
		}
	}
}

```


### Prompt

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

Sherlock Holmes found a mysterious correspondence of two VIPs and made up his mind to read it. But there is a problem! The correspondence turned out to be encrypted. The detective tried really hard to decipher the correspondence, but he couldn't understand anything.

At last, after some thought, he thought of something. Let's say there is a word s, consisting of |s| lowercase Latin letters. Then for one operation you can choose a certain position p (1 ≤ p < |s|) and perform one of the following actions:

  * either replace letter sp with the one that alphabetically follows it and replace letter sp + 1 with the one that alphabetically precedes it;
  * or replace letter sp with the one that alphabetically precedes it and replace letter sp + 1 with the one that alphabetically follows it.

Let us note that letter "z" doesn't have a defined following letter and letter "a" doesn't have a defined preceding letter. That's why the corresponding changes are not acceptable. If the operation requires performing at least one unacceptable change, then such operation cannot be performed.

Two words coincide in their meaning iff one of them can be transformed into the other one as a result of zero or more operations.

Sherlock Holmes needs to learn to quickly determine the following for each word: how many words can exist that coincide in their meaning with the given word, but differs from the given word in at least one character? Count this number for him modulo 1000000007 (109 + 7).

Input

The input data contains several tests. The first line contains the only integer t (1 ≤ t ≤ 104) — the number of tests.

Next t lines contain the words, one per line. Each word consists of lowercase Latin letters and has length from 1 to 100, inclusive. Lengths of words can differ.

Output

For each word you should print the number of different other words that coincide with it in their meaning — not from the words listed in the input data, but from all possible words. As the sought number can be very large, print its value modulo 1000000007 (109 + 7).

Examples

Input

1
ab

Output

1

Input

1
aaaaaaaaaaa

Output

0

Input

2
ya
klmbfxzb

Output

24
320092793

Note

Some explanations about the operation:

  * Note that for each letter, we can clearly define the letter that follows it. Letter "b" alphabetically follows letter "a", letter "c" follows letter "b", ..., "z" follows letter "y".
  * Preceding letters are defined in the similar manner: letter "y" precedes letter "z", ..., "a" precedes letter "b".
  * Note that the operation never changes a word's length.

In the first sample you can obtain the only other word "ba". In the second sample you cannot obtain any other word, so the correct answer is 0.

Consider the third sample. One operation can transform word "klmbfxzb" into word "klmcexzb": we should choose p = 4, and replace the fourth letter with the following one ("b"  →  "c"), and the fifth one — with the preceding one ("f"  →  "e"). Also, we can obtain many other words from this one. An operation can transform word "ya" only into one other word "xb".

Word "ya" coincides in its meaning with words "xb", "wc", "vd", ..., "ay" (overall there are 24 other words). The word "klmbfxzb has many more variants — there are 3320092814 other words that coincide with in the meaning. So the answer for the first word equals 24 and for the second one equals 320092793 — the number 3320092814 modulo 109 + 7

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int dp[105][2700];
int t;
string s;
void solve() {
  dp[0][0] = 1;
  for (int i = 0; i < 101; i++)
    for (int j = 0; j <= 25 * i; j++) {
      for (int k = 0; k < 26; k++) {
        dp[i + 1][j + k] += dp[i][j];
        dp[i + 1][j + k] %= MOD;
      }
    }
}
int main() {
  solve();
  cin >> t;
  while (t--) {
    cin >> s;
    int sum = 0;
    for (int i = 0; i < s.size(); i++) sum += s[i] - 'a';
    cout << dp[s.size()][sum] - 1 << endl;
  }
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

After celebrating the midcourse the students of one of the faculties of the Berland State University decided to conduct a vote for the best photo. They published the photos in the social network and agreed on the rules to choose a winner: the photo which gets most likes wins. If multiple photoes get most likes, the winner is the photo that gets this number first.

Help guys determine the winner photo by the records of likes.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the total likes to the published photoes.

The second line contains n positive integers a1, a2, ..., an (1 ≤ ai ≤ 1 000 000), where ai is the identifier of the photo which got the i-th like.

Output

Print the identifier of the photo which won the elections.

Examples

Input

5
1 3 2 2 1

Output

2

Input

9
100 200 300 200 100 300 300 100 200

Output

300

Note

In the first test sample the photo with id 1 got two likes (first and fifth), photo with id 2 got two likes (third and fourth), and photo with id 3 got one like (second).

Thus, the winner is the photo with identifier 2, as it got:

  * more likes than the photo with id 3;
  * as many likes as the photo with id 1, but the photo with the identifier 2 got its second like earlier.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, a, ans;
int b[1000005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    b[a]++;
    if (b[a] > b[ans]) ans = a;
  }
  cout << ans << endl;
}

```


### Prompt

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

Eleven wants to choose a new name for herself. As a bunch of geeks, her friends suggested an algorithm to choose a name for her. Eleven wants her name to have exactly n characters.

<image>

Her friend suggested that her name should only consist of uppercase and lowercase letters 'O'. More precisely, they suggested that the i-th letter of her name should be 'O' (uppercase) if i is a member of Fibonacci sequence, and 'o' (lowercase) otherwise. The letters in the name are numbered from 1 to n. Fibonacci sequence is the sequence f where

  * f1 = 1,
  * f2 = 1,
  * fn = fn - 2 + fn - 1 (n > 2).

As her friends are too young to know what Fibonacci sequence is, they asked you to help Eleven determine her new name.

Input

The first and only line of input contains an integer n (1 ≤ n ≤ 1000).

Output

Print Eleven's new name on the first and only line of output.

Examples

Input

8

Output

OOOoOooO

Input

15

Output

OOOoOooOooooOoo

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int check(int k, int a[10000], int n) {
  for (int i = 1; i <= n + 1; i++) {
    if (k == a[i]) return 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, c = 0;
  cin >> n;
  int a[n + 1];
  a[1] = 1;
  a[2] = 1;
  for (int i = 3; i <= n + 1; i++) {
    a[i] = a[i - 1] + a[i - 2];
  }
  for (int i = 1; i <= n; i++) {
    if (check(i, a, n) == 1)
      cout << "O";
    else
      cout << "o";
  }
}

```


### Prompt

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

Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.

The problem has N test cases.

For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.

See the Output section for the output format.

Constraints

* 1 \leq N \leq 10^5
* S_i is `AC`, `WA`, `TLE`, or `RE`.

Input

Input is given from Standard Input in the following format:

N
S_1
\vdots
S_N

Output

Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:

AC x C_0
WA x C_1
TLE x C_2
RE x C_3

Output

Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. Print the following:

AC x C_0
WA x C_1
TLE x C_2
RE x C_3

Examples

Input

6
AC
TLE
AC
AC
WA
TLE

Output

AC x 3
WA x 1
TLE x 2
RE x 0

Input

10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC

Output

AC x 10
WA x 0
TLE x 0
RE x 0

### Response

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

int main() {
 int n;
 cin>>n;
 string s;
 map <string,int> mp;
 while(n--)
 {
     cin>>s;
     mp[s]++;
 }
 cout<<"AC x "<<mp["AC"]<<endl;
 cout<<"WA x "<<mp["WA"]<<endl;
 cout<<"TLE x "<<mp["TLE"]<<endl;
 cout<<"RE x "<<mp["RE"]<<endl;
 return 0;
}

```


### Prompt

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

While sailing on a boat, Inessa noticed a beautiful water lily flower above the lake's surface. She came closer and it turned out that the lily was exactly H centimeters above the water surface. Inessa grabbed the flower and sailed the distance of L centimeters. Exactly at this point the flower touched the water surface.

<image>

Suppose that the lily grows at some point A on the lake bottom, and its stem is always a straight segment with one endpoint at point A. Also suppose that initially the flower was exactly above the point A, i.e. its stem was vertical. Can you determine the depth of the lake at point A?

Input

The only line contains two integers H and L (1 ≤ H < L ≤ 10^{6}).

Output

Print a single number — the depth of the lake at point A. The absolute or relative error should not exceed 10^{-6}.

Formally, let your answer be A, and the jury's answer be B. Your answer is accepted if and only if \frac{|A - B|}{max{(1, |B|)}} ≤ 10^{-6}.

Examples

Input

1 2

Output

1.5000000000000

Input

3 5

Output

2.6666666666667

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  double H, L;
  cin >> H >> L;
  cout.precision(13);
  cout << fixed << (L * L - H * H) / (2 * H);
}

```


### Prompt

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

Lenny had an n × m matrix of positive integers. He loved the matrix so much, because each row of the matrix was sorted in non-decreasing order. For the same reason he calls such matrices of integers lovely.

One day when Lenny was at school his little brother was playing with Lenny's matrix in his room. He erased some of the entries of the matrix and changed the order of some of its columns. When Lenny got back home he was very upset. Now Lenny wants to recover his matrix.

Help him to find an order for the columns of the matrix so that it's possible to fill in the erased entries of the matrix to achieve a lovely matrix again. Note, that you can fill the erased entries of the matrix with any integers.

Input

The first line of the input contains two positive integers n and m (1 ≤ n·m ≤ 105). Each of the next n lines contains m space-separated integers representing the matrix. An integer -1 shows an erased entry of the matrix. All other integers (each of them is between 0 and 109 inclusive) represent filled entries.

Output

If there exists no possible reordering of the columns print -1. Otherwise the output should contain m integers p1, p2, ..., pm showing the sought permutation of columns. So, the first column of the lovely matrix will be p1-th column of the initial matrix, the second column of the lovely matrix will be p2-th column of the initial matrix and so on.

Examples

Input

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

Output

3 1 2

Input

2 3
1 2 2
2 5 4

Output

1 3 2

Input

2 3
1 2 3
3 2 1

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int MAXM = 200005;
int n, m, deg[MAXM];
vector<int> a[MAXN], G[MAXM];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    a[i].resize(m);
    for (int j = 0; j < m; j++) scanf("%d", &a[i][j]);
  }
  int s = m;
  for (int i = 0; i < n; i++) {
    vector<pair<int, int> > p;
    for (int j = 0; j < m; j++)
      if (a[i][j] != -1) p.push_back({a[i][j], j});
    sort(p.begin(), p.end());
    for (int i = 0; i < p.size();) {
      int j = i + 1;
      while (j < p.size() && p[j].first == p[i].first) j++;
      int k = j + 1;
      while (k < p.size() && p[k].first == p[j].first) k++;
      if (j < p.size()) {
        for (int z = i; z < j; z++) {
          G[p[z].second].push_back(s);
          deg[s]++;
        }
        for (int z = j; z < k; z++) {
          G[s].push_back(p[z].second);
          deg[p[z].second]++;
        }
        s++;
        i = j;
      } else
        break;
    }
  }
  queue<int> q;
  for (int i = 0; i < s; i++)
    if (deg[i] == 0) q.push(i);
  vector<int> p;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (u < m) p.push_back(u);
    for (int v : G[u]) {
      deg[v]--;
      if (deg[v] == 0) q.push(v);
    }
  }
  if (p.size() < m)
    printf("-1\n");
  else {
    for (int i = 0; i < p.size(); i++) {
      if (i > 0) printf(" ");
      printf("%d", p[i] + 1);
    }
    printf("\n");
  }
  return 0;
}

```


### Prompt

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

The [BFS](https://en.wikipedia.org/wiki/Breadth-first_search) algorithm is defined as follows.

  1. Consider an undirected graph with vertices numbered from 1 to n. Initialize q as a new [queue](http://gg.gg/queue_en) containing only vertex 1, mark the vertex 1 as used.
  2. Extract a vertex v from the head of the queue q.
  3. Print the index of vertex v.
  4. Iterate in arbitrary order through all such vertices u that u is a neighbor of v and is not marked yet as used. Mark the vertex u as used and insert it into the tail of the queue q.
  5. If the queue is not empty, continue from step 2.
  6. Otherwise finish.

Since the order of choosing neighbors of each vertex can vary, it turns out that there may be multiple sequences which BFS can print.

In this problem you need to check whether a given sequence corresponds to some valid BFS traversal of the given tree starting from vertex 1. The [tree](http://gg.gg/tree_en) is an undirected graph, such that there is exactly one simple path between any two vertices.

Input

The first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5) which denotes the number of nodes in the tree.

The following n - 1 lines describe the edges of the tree. Each of them contains two integers x and y (1 ≤ x, y ≤ n) — the endpoints of the corresponding edge of the tree. It is guaranteed that the given graph is a tree.

The last line contains n distinct integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n) — the sequence to check.

Output

Print "Yes" (quotes for clarity) if the sequence corresponds to some valid BFS traversal of the given tree and "No" (quotes for clarity) otherwise.

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

Examples

Input

4
1 2
1 3
2 4
1 2 3 4

Output

Yes

Input

4
1 2
1 3
2 4
1 2 4 3

Output

No

Note

Both sample tests have the same tree in them.

In this tree, there are two valid BFS orderings:

  * 1, 2, 3, 4,
  * 1, 3, 2, 4.

The ordering 1, 2, 4, 3 doesn't correspond to any valid BFS order.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int n;
long long int a[200005];
vector<long long int> adj[200005];
set<long long int> nei[200005];
queue<long long int> q;
bool vis[200005];
void dfs(long long int i, long long int p) {
  for (auto j : adj[i])
    if (j != p) {
      nei[i].insert(j);
      dfs(j, i);
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    long long int x, y;
    cin >> x >> y;
    adj[x].push_back(y), adj[y].push_back(x);
  }
  dfs(1, 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (a[1] != 1) return cout << "No" << '\n', 0;
  q.push(1);
  long long int cur = 2;
  vis[1] = 1;
  while (q.size()) {
    long long int i = q.front();
    q.pop();
    for (int j = 1; j < adj[i].size() + (i == 1); j++) {
      if (nei[i].find(a[cur]) == nei[i].end()) return cout << "No" << '\n', 0;
      vis[a[cur]] = 1;
      q.push(a[cur]);
      cur++;
    }
  }
  cout << "Yes" << '\n';
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

Today Johnny wants to increase his contribution. His plan assumes writing n blogs. One blog covers one topic, but one topic can be covered by many blogs. Moreover, some blogs have references to each other. Each pair of blogs that are connected by a reference has to cover different topics because otherwise, the readers can notice that they are split just for more contribution. Set of blogs and bidirectional references between some pairs of them is called blogs network.

There are n different topics, numbered from 1 to n sorted by Johnny's knowledge. The structure of the blogs network is already prepared. Now Johnny has to write the blogs in some order. He is lazy, so each time before writing a blog, he looks at it's already written neighbors (the blogs referenced to current one) and chooses the topic with the smallest number which is not covered by neighbors. It's easy to see that this strategy will always allow him to choose a topic because there are at most n - 1 neighbors.

For example, if already written neighbors of the current blog have topics number 1, 3, 1, 5, and 2, Johnny will choose the topic number 4 for the current blog, because topics number 1, 2 and 3 are already covered by neighbors and topic number 4 isn't covered.

As a good friend, you have done some research and predicted the best topic for each blog. Can you tell Johnny, in which order he has to write the blogs, so that his strategy produces the topic assignment chosen by you?

Input

The first line contains two integers n (1 ≤ n ≤ 5 ⋅ 10^5) and m (0 ≤ m ≤ 5 ⋅ 10^5) — the number of blogs and references, respectively.

Each of the following m lines contains two integers a and b (a ≠ b; 1 ≤ a, b ≤ n), which mean that there is a reference between blogs a and b. It's guaranteed that the graph doesn't contain multiple edges.

The last line contains n integers t_1, t_2, …, t_n, i-th of them denotes desired topic number of the i-th blog (1 ≤ t_i ≤ n).

Output

If the solution does not exist, then write -1. Otherwise, output n distinct integers p_1, p_2, …, p_n (1 ≤ p_i ≤ n), which describe the numbers of blogs in order which Johnny should write them. If there are multiple answers, print any.

Examples

Input

3 3
1 2
2 3
3 1
2 1 3

Output

2 1 3

Input

3 3
1 2
2 3
3 1
1 1 1

Output

-1

Input

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

Output

2 5 1 3 4

Note

In the first example, Johnny starts with writing blog number 2, there are no already written neighbors yet, so it receives the first topic. Later he writes blog number 1, it has reference to the already written second blog, so it receives the second topic. In the end, he writes blog number 3, it has references to blogs number 1 and 2 so it receives the third topic.

Second example: There does not exist any permutation fulfilling given conditions.

Third example: First Johnny writes blog 2, it receives the topic 1. Then he writes blog 5, it receives the topic 1 too because it doesn't have reference to single already written blog 2. Then he writes blog number 1, it has reference to blog number 2 with topic 1, so it receives the topic 2. Then he writes blog number 3 which has reference to blog 2, so it receives the topic 2. Then he ends with writing blog number 4 which has reference to blog 5 and receives the topic 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> g[n];
  vector<pair<int, int>> top;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int val[n];
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    val[i] = -1;
    top.push_back({a, i});
  }
  sort(top.begin(), top.end());
  for (int i = 0; i < n; i++) {
    int idx = top[i].first;
    int a = top[i].second;
    bool mark[idx];
    for (int i = 0; i < idx; i++) {
      mark[i] = 0;
    }
    for (int j = 0; j < g[a].size(); j++) {
      if (val[g[a][j]] == idx) {
        cout << -1;
        return 0;
      }
      if (val[g[a][j]] > 0) mark[val[g[a][j]]] = 1;
    }
    for (int i = 1; i < idx; i++) {
      if (!mark[i]) {
        cout << -1;
        return 0;
      }
    }
    val[a] = idx;
  }
  for (int i = 0; i < n; i++) {
    cout << top[i].second + 1 << " ";
  }
}

```


### Prompt

Please create a solution in Cpp to the following problem:

We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that a yuan for b kilos (You don't need to care about what "yuan" is), the same as a/b yuan for a kilo.

Now imagine you'd like to buy m kilos of apples. You've asked n supermarkets and got the prices. Find the minimum cost for those apples.

You can assume that there are enough apples in all supermarkets.

Input

The first line contains two positive integers n and m (1 ≤ n ≤ 5 000, 1 ≤ m ≤ 100), denoting that there are n supermarkets and you want to buy m kilos of apples.

The following n lines describe the information of the supermarkets. Each line contains two positive integers a, b (1 ≤ a, b ≤ 100), denoting that in this supermarket, you are supposed to pay a yuan for b kilos of apples.

Output

The only line, denoting the minimum cost for m kilos of apples. Please make sure that the absolute or relative error between your answer and the correct answer won't exceed 10^{-6}.

Formally, let your answer be x, and the jury's answer be y. Your answer is considered correct if \frac{|x - y|}{max{(1, |y|)}} ≤ 10^{-6}.

Examples

Input

3 5
1 2
3 4
1 3

Output

1.66666667

Input

2 1
99 100
98 99

Output

0.98989899

Note

In the first sample, you are supposed to buy 5 kilos of apples in supermarket 3. The cost is 5/3 yuan.

In the second sample, you are supposed to buy 1 kilo of apples in supermarket 2. The cost is 98/99 yuan.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  double n, m, mn = 101;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    double a, b;
    cin >> a >> b;
    double c = a / b;
    mn = min(mn, c);
  }
  printf("%.8f\n", (m * mn) * 1.00);
}

```


### Prompt

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

Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r).

He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the right, that is transform [l; r] to either segment [l - 1; r], or to segment [l; r + 1].

The value of a set of segments that consists of n segments [l1; r1], [l2; r2], ..., [ln; rn] is the number of integers x, such that there is integer j, for which the following inequality holds, lj ≤ x ≤ rj.

Find the minimum number of moves needed to make the value of the set of Polo's segments divisible by k.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space.

It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i < j ≤ n) the following inequality holds, min(ri, rj) < max(li, lj).

Output

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

Examples

Input

2 3
1 2
3 4

Output

2

Input

3 7
1 2
3 3
4 7

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long s = 0, n, k, x, y;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    s += y - x + 1;
  }
  long long h = k - (s % k);
  if (h == k) h = 0;
  cout << h;
}

```


### Prompt

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

Problem

Chocolate company Chinor Choco has decided to build n new stores.
For each store, ask each store manager to prepare two candidates for the place you want to build, and build it in either place.

Chinor Choco sells m types of chocolate, each manufactured at a different factory.
All types of chocolate are sold at all stores.
Chinor Choco owns only one truck to transport chocolate, and one truck can only carry one store's worth of chocolate.
Therefore, trucks need to go around all factories when moving from one store to another.

Find the maximum travel distance when the stores are arranged so that the maximum minimum travel distance when moving from one store to another is the minimum.

There can be multiple stores and factories in the same location.

Constraints

The input satisfies the following conditions.

* 2 ≤ n ≤ 200
* 1 ≤ m ≤ 15
* 0 ≤ ai, bi, ci, di, xi, yi ≤ 1000

Input

The input is given in the following format.

n m
a0 b0 c0 d0
...
an−1 bn−1 cn−1 dn−1
x0 y0
...
xm−1 ym−1

All inputs are given as integers.
On the first line, the number of Chinor chocolate shops n and the number of chocolate manufacturing factories m are given, separated by blanks.
From the second line to the nth line, the coordinates (ai, bi), (ci, di) of the candidate places to build each store are given separated by blanks.
2 & plus; Factory coordinates (xi, yi) are given from the nth line to the mth line, separated by blanks.

Output

Output the maximum travel distance when the store is arranged so that the maximum of the minimum travel distance is minimized.
The error should not exceed 10-6.

Examples

Input

2 1
0 0 5 5
3 3 6 6
2 2

Output

4.2426406871

Input

2 2
0 0 6 0
7 0 3 0
4 0
5 0

Output

3.0000000000

### Response

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

using namespace std;

struct StronglyConnectedComponents
{
  vector< vector< int > > gg, rg;
  vector< pair< int, int > > edges;
  vector< int > comp, order, used;

  StronglyConnectedComponents(size_t v) : gg(v), rg(v), comp(v, -1), used(v, 0) {}

  void add_edge(int x, int y)
  {
    gg[x].push_back(y);
    rg[y].push_back(x);
    edges.emplace_back(x, y);
  }

  int operator[](int k)
  {
    return (comp[k]);
  }

  void dfs(int idx)
  {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt)
  {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  void build(vector< vector< int > > &t)
  {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;

    t.resize(ptr);
    set< pair< int, int > > connect;
    for(auto &e : edges) {
      int x = comp[e.first], y = comp[e.second];
      if(x == y) continue;
      if(connect.count({x, y})) continue;
      t[x].push_back(y);
      connect.emplace(x, y);
    }
  }
};

int N, M;
int A[200][2], B[200][2];
int X[15], Y[15];
double g[200][2][200][2];

int main()
{
  cin >> N >> M;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < 2; j++) {
      cin >> A[i][j] >> B[i][j];
    }
  }
  for(int i = 0; i < M; i++) {
    cin >> X[i] >> Y[i];
  }

  fill_n(***g, 200 * 2 * 200 * 2, 1e9);
  for(int i = 0; i < M; i++) {
    vector< vector< double > > dp(M, vector< double >(1 << M, 1e9));
    dp[i][1 << i] = 0.0;
    for(int j = 0; j < (1 << M); j++) {
      for(int k = 0; k < M; k++) {
        for(int l = 0; l < M; l++) {
          dp[l][j | (1 << l)] = min(dp[l][j | (1 << l)], dp[k][j] + sqrt(pow(X[k] - X[l], 2) + pow(Y[k] - Y[l], 2)));
        }
      }
    }
    for(int z = 0; z < M; z++) {
      for(int j = 0; j < N; j++) {
        for(int k = 0; k < 2; k++) {
          for(int l = 0; l < N; l++) {
            for(int m = 0; m < 2; m++) {
              double latte = sqrt(pow(A[j][k] - X[i], 2) + pow(B[j][k] - Y[i], 2));
              double malta = sqrt(pow(A[l][m] - X[z], 2) + pow(B[l][m] - Y[z], 2));
              g[j][k][l][m] = min(g[j][k][l][m], latte + malta + dp[z].back());
            }
          }
        }
      }
    }
  }

  auto check = [&](double dist)
  {
    StronglyConnectedComponents scc(N + N);
    for(int i = 0; i < N; i++) {
      for(int j = i + 1; j < N; j++) {
        bool b1 = g[i][0][j][0] > dist;
        bool b2 = g[i][0][j][1] > dist;
        bool b3 = g[i][1][j][0] > dist;
        bool b4 = g[i][1][j][1] > dist;
        if(b1) scc.add_edge(i << 1, (j << 1) | 1), scc.add_edge(j << 1, (i << 1) | 1);
        if(b2) scc.add_edge(i << 1, j << 1), scc.add_edge((j << 1) | 1, (i << 1) | 1);
        if(b3) scc.add_edge((i << 1) | 1, (j << 1) | 1), scc.add_edge(j << 1, i << 1);
        if(b4) scc.add_edge((i << 1) | 1, j << 1), scc.add_edge((j << 1) | 1, i << 1);
      }
    }
    vector< vector< int > > g;
    scc.build(g);
    for(int i = 0; i < N; i += 2) if(scc[i] == scc[i + 1]) return (false);
    return (true);
  };

  double low = 0, high = 1e6;
  for(int i = 0; i < 40; i++) {
    double mid = (low + high) * 0.5;
    if(check(mid)) high = mid;
    else low = mid;
  }

  cout << fixed << setprecision(10) << high << endl;
}
```


### Prompt

Please formulate a cpp solution to the following problem:

There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the appropriate coordinates of vertices.

Input

The first line contains two integers a, b (1 ≤ a, b ≤ 1000), separated by a single space.

Output

In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers — the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute value.

Examples

Input

1 1

Output

NO

Input

5 5

Output

YES
2 1
5 5
-2 4

Input

5 10

Output

YES
-10 4
-2 -2
1 2

### Response

```cpp
#include <bits/stdc++.h>
#pragma hdrstop
#pragma argsused
using namespace std;
int main(int argc, char* argv[]) {
  int a, b;
  cin >> a >> b;
  vector<pair<int, int> > spli_a;
  vector<pair<int, int> > spli_b;
  int sqa = a * a;
  int sqb = b * b;
  map<int, int> squarez;
  for (int i = 1; i < 2000; ++i) {
    squarez[i * i] = i;
  }
  for (int i = 1; i * i < sqa; ++i) {
    int ii = i * i;
    int dsq = sqa - ii;
    if (squarez.count(dsq) > 0) {
      spli_a.push_back(make_pair(i, squarez[dsq]));
      spli_a.push_back(make_pair(squarez[dsq], i));
    }
  }
  for (int i = 1; i * i < sqb; ++i) {
    int ii = i * i;
    int dsq = sqb - ii;
    if (squarez.count(dsq) > 0) {
      spli_b.push_back(make_pair(i, squarez[dsq]));
      spli_b.push_back(make_pair(squarez[dsq], i));
    }
  }
  for (int i = 0; i < spli_a.size(); ++i) {
    for (int j = 0; j < spli_b.size(); ++j) {
      if (spli_a[i].first != spli_b[j].first) {
        int vx1 = spli_a[i].first, vy1 = -spli_a[i].second;
        int vx2 = spli_b[j].first, vy2 = spli_b[j].second;
        if (0 == vx1 * vx2 + vy1 * vy2) {
          cout << "YES" << endl;
          cout << 0 << " " << 0 << endl;
          cout << vx1 << " " << vy1 << endl;
          cout << vx2 << " " << vy2 << endl;
          return 0;
        }
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}

```


### Prompt

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

Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not.

Two integers x, y are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the numbers, (x + y).

What is the minimum number of such operations one has to perform in order to make the given pair of integers m-perfect?

Input

Single line of the input contains three integers x, y and m ( - 1018 ≤ x, y, m ≤ 1018).

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

Output

Print the minimum number of operations or "-1" (without quotes), if it is impossible to transform the given pair to the m-perfect one.

Examples

Input

1 2 5

Output

2

Input

-1 4 15

Output

4

Input

0 -1 5

Output

-1

Note

In the first sample the following sequence of operations is suitable: (1, 2) <image> (3, 2) <image> (5, 2).

In the second sample: (-1, 4) <image> (3, 4) <image> (7, 4) <image> (11, 4) <image> (15, 4).

Finally, in the third sample x, y cannot be made positive, hence there is no proper sequence of operations.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, y, m;
  long long ans;
  cin >> x >> y >> m;
  ans = 0;
  if (x > y) swap(x, y);
  if (m <= y)
    cout << ans << endl;
  else if (x + y <= x)
    cout << -1 << endl;
  else {
    if (x < 0 && y > 0) {
      ans = -x / y + 1;
      x += y * ans;
    }
    if (x > y) swap(x, y);
    while (m > y) {
      long long t = x + y;
      x = y;
      y = t;
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

```


### Prompt

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

Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct.

Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X.

Find the duration of time when some song was played while Niwango was asleep.

Constraints

* 1 \leq N \leq 50
* s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.
* s_1,\ldots,s_N are distinct.
* There exists an integer i such that s_i = X.
* 1 \leq t_i \leq 1000
* t_i is an integer.

Input

Input is given from Standard Input in the following format:

N
s_1 t_1
\vdots
s_{N} t_N
X

Output

Print the answer.

Examples

Input

3
dwango 2
sixth 5
prelims 25
dwango

Output

30

Input

1
abcde 1000
abcde

Output

0

Input

15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu

Output

6348

### Response

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

int main() {
	int N;
	cin >>N;
	string s[N+1];
	int t[N+1];
	for(int i=1;i<=N;i++){
		cin >>s[i]>>t[i];
	}
	string X;
	cin >>X;
	int c,d;
	c=0;
	d=0;
	for(int i=1;i<=N;i++){
		c=c+d*t[i];
		if(X==s[i]){
			d=1;
		}
	}
	cout <<c<<endl;
}
```


### Prompt

Develop a solution in Cpp to the problem described below:

Little Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity.

There are n columns of toy cubes in the box arranged in a line. The i-th column contains ai cubes. At first, the gravity in the box is pulling the cubes downwards. When Chris switches the gravity, it begins to pull all the cubes to the right side of the box. The figure shows the initial and final configurations of the cubes in the box: the cubes that have changed their position are highlighted with orange.

<image>

Given the initial configuration of the toy cubes in the box, find the amounts of cubes in each of the n columns after the gravity switch!

Input

The first line of input contains an integer n (1 ≤ n ≤ 100), the number of the columns in the box. The next line contains n space-separated integer numbers. The i-th number ai (1 ≤ ai ≤ 100) denotes the number of cubes in the i-th column.

Output

Output n integer numbers separated by spaces, where the i-th number is the amount of cubes in the i-th column after the gravity switch.

Examples

Input

4
3 2 1 2

Output

1 2 2 3

Input

3
2 3 8

Output

2 3 8

Note

The first example case is shown on the figure. The top cube of the first column falls to the top of the last column; the top cube of the second column falls to the top of the third column; the middle cube of the first column falls to the top of the second column.

In the second example case the gravity switch does not change the heights of the columns.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  return 0;
}

```


### Prompt

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

Artsem is on vacation and wants to buy souvenirs for his two teammates. There are n souvenir shops along the street. In i-th shop Artsem can buy one souvenir for ai dollars, and he cannot buy more than one souvenir in one shop. He doesn't want to introduce envy in his team, so he wants to buy two souvenirs with least possible difference in price.

Artsem has visited the shopping street m times. For some strange reason on the i-th day only shops with numbers from li to ri were operating (weird? yes it is, but have you ever tried to come up with a reasonable legend for a range query problem?). For each visit, Artsem wants to know the minimum possible difference in prices of two different souvenirs he can buy in the opened shops.

In other words, for each Artsem's visit you should find the minimum possible value of |as - at| where li ≤ s, t ≤ ri, s ≠ t.

Input

The first line contains an integer n (2 ≤ n ≤ 105).

The second line contains n space-separated integers a1, ..., an (0 ≤ ai ≤ 109).

The third line contains the number of queries m (1 ≤ m ≤ 3·105).

Next m lines describe the queries. i-th of these lines contains two space-separated integers li and ri denoting the range of shops working on i-th day (1 ≤ li < ri ≤ n).

Output

Print the answer to each query in a separate line.

Example

Input

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

Output

0
1
1
3

### Response

```cpp
#include <bits/stdc++.h>
clock_t t = clock();
namespace my_std {
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
inline T rnd(T l, T r) {
  return uniform_int_distribution<T>(l, r)(rng);
}
template <typename T>
inline bool chkmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline void read(T &t) {
  t = 0;
  char f = 0, ch = getchar();
  double d = 0.1;
  while (ch > '9' || ch < '0') f |= (ch == '-'), ch = getchar();
  while (ch <= '9' && ch >= '0') t = t * 10 + ch - 48, ch = getchar();
  if (ch == '.') {
    ch = getchar();
    while (ch <= '9' && ch >= '0') t += d * (ch ^ 48), d *= 0.1, ch = getchar();
  }
  t = (f ? -t : t);
}
template <typename T, typename... Args>
inline void read(T &t, Args &...args) {
  read(t);
  read(args...);
}
char sr[1 << 21], z[20];
int C = -1, Z = 0;
inline void Ot() { fwrite(sr, 1, C + 1, stdout), C = -1; }
inline void print(register int x) {
  if (C > 1 << 20) Ot();
  if (x < 0) sr[++C] = '-', x = -x;
  while (z[++Z] = x % 10 + 48, x /= 10)
    ;
  while (sr[++C] = z[Z], --Z)
    ;
  sr[++C] = '\n';
}
void file() {}
inline void chktime() {}
long long ksm(long long x, int y) {
  long long ret = 1;
  for (; y; y >>= 1, x = x * x)
    if (y & 1) ret = ret * x;
  return ret;
}
}  // namespace my_std
using namespace my_std;
int n, m;
pair<int, int> a[402200];
int aa[402200];
int pre[402200], suf[402200];
void add(int p) { suf[pre[p]] = pre[suf[p]] = p; }
void del(int p) {
  suf[pre[p]] = suf[p];
  pre[suf[p]] = pre[p];
}
int Ans[402200];
int pos[402200], blo, num;
void init() {
  blo = sqrt(n);
  for (int i = (1); i <= (n); i++) pos[i] = (i - 1) / blo + 1;
  num = pos[n];
}
struct hh {
  int l, r, id;
} q[402200];
inline bool cmp(const hh &x, const hh &y) {
  return pos[x.l] == pos[y.l] ? x.r < y.r : pos[x.l] < pos[y.l];
}
int Lans[402200];
int update(int x) {
  int ret = 1e9;
  if (pre[x]) chkmin(ret, aa[x] - aa[pre[x]]);
  if (suf[x] != n + 1) chkmin(ret, aa[suf[x]] - aa[x]);
  return ret;
}
int main() {
  file();
  read(n);
  for (int i = (1); i <= (n); i++)
    read(a[i].first), a[i].second = i, aa[i] = a[i].first;
  sort(a + 1, a + n + 1);
  read(m);
  init();
  int x, y;
  for (int i = (1); i <= (m); i++) read(x, y), q[i] = (hh){x, y, i};
  sort(q + 1, q + m + 1, cmp);
  int p = 1;
  for (int _ = (1); _ <= (num); _++) {
    int L = (_ - 1) * blo + 1, R = min(_ * blo, n), posR = R;
    for (int i = (1); i <= (n); i++) Lans[i] = 1e9;
    int lst = 0;
    for (int i = (0); i <= (n + 1); i++) pre[i] = suf[i] = 0;
    for (int i = (1); i <= (n); i++)
      suf[lst] = a[i].second, pre[a[i].second] = lst, lst = a[i].second;
    pre[suf[lst] = n + 1] = lst;
    for (int i = (1); i <= (R); i++) del(i);
    for (int i = (n); i >= (R + 1); i--) del(i);
    for (int i = (R + 1); i <= (n); i++)
      add(i), Lans[i] = min(Lans[i - 1], update(i));
    for (int i = (R); i >= (L); i--) add(i);
    for (int i = (n); i >= (R + 1); i--) del(i);
    for (; p <= m && pos[q[p].l] == _; p++) {
      int ans = 1e9;
      if (q[p].r <= R) {
        for (int i = (L); i <= (q[p].l - 1); i++) del(i);
        for (int i = (R); i >= (q[p].l); i--) del(i);
        for (int i = (q[p].l); i <= (q[p].r); i++)
          add(i), chkmin(ans, update(i));
        for (int i = (q[p].r); i <= (R); i++) add(i);
        for (int i = (q[p].l - 1); i >= (L); i--) add(i);
        Ans[q[p].id] = ans;
      } else {
        while (posR < q[p].r) ++posR, add(posR);
        for (int i = (L); i <= (R); i++) del(i);
        for (int i = (R); i >= (q[p].l); i--) add(i), chkmin(ans, update(i));
        for (int i = (q[p].l - 1); i >= (L); i--) add(i);
        Ans[q[p].id] = min(ans, Lans[posR]);
      }
    }
  }
  for (int i = (1); i <= (m); i++) printf("%d\n", Ans[i]);
  return 0;
}

```


### Prompt

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

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

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

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

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

Each night, the following happens in this exact order:

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

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

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

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

Input

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

Output

Print one integer, equal to <image>.

Examples

Input

5 1 3

Output

32

Input

1 100 4

Output

4

Input

3 2 1

Output

7

Input

100 100 100

Output

381863924

Note

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

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

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

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize(2)
const int maxn = 1e5 + 5, maxm = 135;
int Okabe[maxm], Rintaro[maxm];
unsigned Chris[maxm], Tina[maxm];
int n, p, q;
unsigned answer = 0;
unsigned fastpow(unsigned x, unsigned y) {
  if (y == 0) return 1;
  unsigned tmp = fastpow(x, y >> 1);
  return y & 1 ? tmp * tmp * x : tmp * tmp;
}
int main() {
  scanf("%d%d%d", &n, &p, &q);
  if (p >= n) p = n - 1;
  for (int i = 0; i <= p; i++) {
    int now = i;
    while (now && now % 2 == 0) {
      Okabe[i]++;
      now >>= 1;
    }
    now = n - i;
    while (now && now % 2 == 0) {
      Rintaro[i]++;
      now >>= 1;
    }
  }
  for (int i = 0; i <= p; i++) {
    Chris[i] = 1;
    for (int k = 1; k <= i; k++) Chris[i] *= k / (1 << Okabe[k]);
    Chris[i] = fastpow(Chris[i], (1u << 31) - 1);
    int cnt = 0;
    Tina[i] = 1;
    for (int k = 1; k <= i; k++)
      cnt += Rintaro[k - 1] - Okabe[k],
          Tina[i] *= (n - k + 1) / (1 << Rintaro[k - 1]);
    Tina[i] *= 1u << cnt;
  }
  for (int i = 1; i <= q; i++) {
    unsigned now = 0, base = 1;
    for (int j = 0; j <= p; j++, base *= i) now += Chris[j] * Tina[j] * base;
    answer ^= ((unsigned)i * now);
  }
  printf("%u\n", answer);
  return 0;
}

```