### Prompt

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

Joe has been hurt on the Internet. Now he is storming around the house, destroying everything in his path.

Joe's house has n floors, each floor is a segment of m cells. Each cell either contains nothing (it is an empty cell), or has a brick or a concrete wall (always something one of three). It is believed that each floor is surrounded by a concrete wall on the left and on the right.

Now Joe is on the n-th floor and in the first cell, counting from left to right. At each moment of time, Joe has the direction of his gaze, to the right or to the left (always one direction of the two). Initially, Joe looks to the right.

Joe moves by a particular algorithm. Every second he makes one of the following actions:

  * If the cell directly under Joe is empty, then Joe falls down. That is, he moves to this cell, the gaze direction is preserved.
  * Otherwise consider the next cell in the current direction of the gaze.
    * If the cell is empty, then Joe moves into it, the gaze direction is preserved.
    * If this cell has bricks, then Joe breaks them with his forehead (the cell becomes empty), and changes the direction of his gaze to the opposite.
    * If this cell has a concrete wall, then Joe just changes the direction of his gaze to the opposite (concrete can withstand any number of forehead hits).

Joe calms down as soon as he reaches any cell of the first floor.

The figure below shows an example Joe's movements around the house.

<image>

Determine how many seconds Joe will need to calm down.

Input

The first line contains two integers n and m (2 ≤ n ≤ 100, 1 ≤ m ≤ 104).

Next n lines contain the description of Joe's house. The i-th of these lines contains the description of the (n - i + 1)-th floor of the house — a line that consists of m characters: "." means an empty cell, "+" means bricks and "#" means a concrete wall.

It is guaranteed that the first cell of the n-th floor is empty.

Output

Print a single number — the number of seconds Joe needs to reach the first floor; or else, print word "Never" (without the quotes), if it can never happen.

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

Examples

Input

3 5
..+.#
#+..+
+.#+.

Output

14

Input

4 10
...+.##+.+
+#++..+++#
++.#++++..
.+##.++#.+

Output

42

Input

2 2
..
++

Output

Never

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
int cnt[100 + 2][N + 2];
string s[100 + 2];
set<int> on[100 + 2], of[100 + 2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    s[i] = "#" + s[i] + "#";
    for (int j = 1; j <= m; j++) {
      if (s[i][j] == '.')
        of[i].insert(j);
      else
        on[i].insert(j);
    }
    on[i].insert(0);
    on[i].insert(m + 1);
    of[i].insert(-1);
    of[i].insert(m + 2);
  }
  long long ans = 0;
  int a = 1, b = 1, d = 1;
  while (true) {
    if (clock() > CLOCKS_PER_SEC * 0.8) cout << "Never\n", exit(0);
    if (a == n) break;
    if (d) {
      int cr = *on[a].lower_bound(b);
      int nx = *of[a + 1].lower_bound(b);
      if (nx < cr) {
        ans += nx - b + 1;
        a++;
        b = nx;
      } else {
        ans += cr - b;
        b = cr - 1;
        d ^= 1;
        if (s[a][cr] == '+') {
          on[a].erase(cr);
          s[a][cr] = '.';
          of[a].insert(cr);
        }
      }
    } else {
      auto it1 = on[a].upper_bound(b);
      auto it2 = of[a + 1].upper_bound(b);
      it1--, it2--;
      int cr = *it1, nx = *it2;
      if (nx > cr) {
        ans += b - nx + 1;
        a++;
        b = nx;
      } else {
        ans += b - cr;
        b = cr + 1;
        d ^= 1;
        if (s[a][cr] == '+') {
          on[a].erase(cr);
          s[a][cr] = '.';
          of[a].insert(cr);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

There is a cube which consists of n × n × n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure.

<image>

Then, as shown in the figure above (right), make a hole that penetrates horizontally or vertically from the marked surface to the opposite surface.

Your job is to create a program that reads the positions marked n and counts the number of small cubes with no holes.

Input

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

n h
c1 a1 b1
c2 a2 b2
..
..
..
ch ah bh

h is an integer indicating the number of marks. The h lines that follow enter the positions of the h marks. The coordinate axes shown in the figure below will be used to specify the position of the mark. (x, y, z) = (1, 1, 1) is the lower left cube, and (x, y, z) = (n, n, n) is the upper right cube.

<image>

ci is a string indicating the plane marked with the i-th. ci is one of "xy", "xz", and "yz", indicating that the i-th mark is on the xy, xz, and yz planes, respectively.

ai and bi indicate the coordinates on the plane indicated by ci. For the xy, xz, and yz planes, ai and bi indicate the plane coordinates (x, y), (x, z), and (y, z), respectively. For example, in the above figure, the values of ci, ai, and bi of marks A, B, and C are "xy 4 4", "xz 1 2", and "yz 2 3", respectively.

When both n and h are 0, it indicates the end of input.

You can assume that n ≤ 500 and h ≤ 200.

Output

For each dataset, print the number of non-perforated cubes on one line.

Example

Input

4 3
xy 4 4
xz 1 2
yz 2 3
4 5
xy 1 1
xy 3 3
xz 3 3
yz 2 1
yz 3 3
0 0

Output

52
46

### Response

```cpp
#include<iostream>
#include<set>
using namespace std;
struct Point{int x,y,z;};
bool operator<(Point a,Point b)
{
  return a.x!=b.x?(a.x<b.x):(a.y!=b.y?a.y<b.y:a.z<b.z);
}
int main()
{
  int n,h,a,b;
  string c;
  int i;
  while(cin>>n>>h,n|h){
    set<Point>hole;
    while(h-->0){
      cin>>c>>a>>b;
      if(c=="xy"){
	for(i=n;i>=1;i--){
	  Point p={a,b,i};
	  hole.insert(p);
	}
      }else if(c=="xz"){
	for(i=n;i>=1;i--){
	  Point p={a,i,b};
	  hole.insert(p);
	}
      }else{
	for(i=n;i>=1;i--){
	  Point p={i,a,b};
	  hole.insert(p);
	}
      }
    }
    cout<<n*n*n-hole.size()<<endl;
  }
}
```


### Prompt

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

You are given a function f written in some basic language. The function accepts an integer value, which is immediately written into some variable x. x is an integer variable and can be assigned values from 0 to 2^{32}-1. The function contains three types of commands:

  * for n — for loop;
  * end — every command between "for n" and corresponding "end" is executed n times;
  * add — adds 1 to x.

After the execution of these commands, value of x is returned.

Every "for n" is matched with "end", thus the function is guaranteed to be valid. "for n" can be immediately followed by "end"."add" command can be outside of any for loops.

Notice that "add" commands might overflow the value of x! It means that the value of x becomes greater than 2^{32}-1 after some "add" command.

Now you run f(0) and wonder if the resulting value of x is correct or some overflow made it incorrect.

If overflow happened then output "OVERFLOW!!!", otherwise print the resulting value of x.

Input

The first line contains a single integer l (1 ≤ l ≤ 10^5) — the number of lines in the function.

Each of the next l lines contains a single command of one of three types:

  * for n (1 ≤ n ≤ 100) — for loop;
  * end — every command between "for n" and corresponding "end" is executed n times;
  * add — adds 1 to x.

Output

If overflow happened during execution of f(0), then output "OVERFLOW!!!", otherwise print the resulting value of x.

Examples

Input

9
add
for 43
end
for 10
for 15
add
end
add
end

Output

161

Input

2
for 62
end

Output

0

Input

11
for 100
for 100
for 100
for 100
for 100
add
end
end
end
end
end

Output

OVERFLOW!!!

Note

In the first example the first "add" is executed 1 time, the second "add" is executed 150 times and the last "add" is executed 10 times. Note that "for n" can be immediately followed by "end" and that "add" can be outside of any for loops.

In the second example there are no commands "add", thus the returning value is 0.

In the third example "add" command is executed too many times, which causes x to go over 2^{32}-1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MAX = 4294967295;
int main() {
  int l;
  string in;
  long long val = 0;
  cin >> l;
  long long x = 0;
  stack<long long> fors;
  for (int i = 0; i < l; i++) {
    cin >> in;
    if (in == "for") {
      cin >> val;
      long long curr = val;
      if (!fors.empty()) {
        if (fors.top() == -1) {
          curr = -1;
        } else {
          curr *= fors.top();
        }
      }
      if (curr > MAX) {
        curr = -1;
      }
      fors.push(curr);
    }
    if (in == "end") {
      fors.pop();
    }
    if (in == "add") {
      if (fors.empty()) {
        x++;
      } else {
        if (fors.top() == -1) {
          cout << "OVERFLOW!!!";
          return 0;
        }
        x += fors.top();
      }
      if (x > MAX) {
        cout << "OVERFLOW!!!";
        return 0;
      }
    }
  }
  cout << x;
  return 0;
}

```


### Prompt

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

How to make a cake you'll never eat.

Ingredients.

  * 2 carrots
  * 0 calories
  * 100 g chocolate spread
  * 1 pack of flour
  * 1 egg

Method.

  1. Put calories into the mixing bowl.
  2. Take carrots from refrigerator.
  3. Chop carrots.
  4. Take chocolate spread from refrigerator.
  5. Put chocolate spread into the mixing bowl.
  6. Combine pack of flour into the mixing bowl.
  7. Fold chocolate spread into the mixing bowl.
  8. Add chocolate spread into the mixing bowl.
  9. Put pack of flour into the mixing bowl.
  10. Add egg into the mixing bowl.
  11. Fold pack of flour into the mixing bowl.
  12. Chop carrots until choped.
  13. Pour contents of the mixing bowl into the baking dish.

Serves 1.

Input

The only line of input contains a sequence of integers a0, a1, ... (1 ≤ a0 ≤ 100, 0 ≤ ai ≤ 1000 for i ≥ 1).

Output

Output a single integer.

Examples

Input

4 1 2 3 4

Output

30

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  long long int res = 0;
  cin >> n;
  for (long long int i = 0; i < ((long long int)(n)); ++i) {
    long long int a;
    cin >> a;
    res += a * (i + 1);
  }
  cout << res << endl;
}

```


### Prompt

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

Life is not easy for the perfectly common variable named Vasya. Wherever it goes, it is either assigned a value, or simply ignored, or is being used!

Vasya's life goes in states of a program. In each state, Vasya can either be used (for example, to calculate the value of another variable), or be assigned a value, or ignored. Between some states are directed (oriented) transitions.

A path is a sequence of states v1, v2, ..., vx, where for any 1 ≤ i < x exists a transition from vi to vi + 1.

Vasya's value in state v is interesting to the world, if exists path p1, p2, ..., pk such, that pi = v for some i (1 ≤ i ≤ k), in state p1 Vasya gets assigned a value, in state pk Vasya is used and there is no state pi (except for p1) where Vasya gets assigned a value.

Help Vasya, find the states in which Vasya's value is interesting to the world.

Input

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 105) — the numbers of states and transitions, correspondingly.

The second line contains space-separated n integers f1, f2, ..., fn (0 ≤ fi ≤ 2), fi described actions performed upon Vasya in state i: 0 represents ignoring, 1 — assigning a value, 2 — using.

Next m lines contain space-separated pairs of integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi), each pair represents the transition from the state number ai to the state number bi. Between two states can be any number of transitions.

Output

Print n integers r1, r2, ..., rn, separated by spaces or new lines. Number ri should equal 1, if Vasya's value in state i is interesting to the world and otherwise, it should equal 0. The states are numbered from 1 to n in the order, in which they are described in the input.

Examples

Input

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

Output

1
1
1
1

Input

3 1
1 0 2
1 3

Output

1
0
1

Input

3 1
2 0 1
1 3

Output

0
0
0

Note

In the first sample the program states can be used to make the only path in which the value of Vasya interests the world, 1 <image> 2 <image> 3 <image> 4; it includes all the states, so in all of them Vasya's value is interesting to the world.

The second sample the only path in which Vasya's value is interesting to the world is , — 1 <image> 3; state 2 is not included there.

In the third sample we cannot make from the states any path in which the value of Vasya would be interesting to the world, so the value of Vasya is never interesting to the world.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653589793;
const int INF = 2000000000;
const int mod = 1000000007;
const int N = 100000000;
const int base = 10;
vector<int> read(string s) {
  vector<int> a;
  for (int i = (int)s.length(); i > 0; i -= 1)
    if (i < 1)
      a.push_back(atoi(s.substr(0, i).c_str()));
    else
      a.push_back(atoi(s.substr(i - 1, 1).c_str()));
  return a;
}
vector<int> add(vector<int> a, vector<int> b) {
  int carry = 0;
  for (size_t i = 0; i < max(a.size(), b.size()) || carry; ++i) {
    if (i == a.size()) a.push_back(0);
    a[i] += carry + (i < b.size() ? b[i] : 0);
    carry = a[i] >= base;
    if (carry) a[i] -= base;
  }
  return a;
}
vector<int> mul(vector<int> a, int b) {
  int carry = 0;
  for (size_t i = 0; i < a.size() || carry; ++i) {
    if (i == a.size()) a.push_back(0);
    long long cur = carry + a[i] * 1ll * b;
    a[i] = int(cur % base);
    carry = int(cur / base);
  }
  while (a.size() > 1 && a.back() == 0) a.pop_back();
  return a;
}
vector<int> c;
vector<int> a[100005], b[100005];
vector<bool> f;
vector<bool> f1;
int main() {
  vector<int> queue;
  int n, x, y, m;
  cin >> n >> m;
  for (int(i) = (0); (i) < (n); (i)++) {
    cin >> x;
    c.push_back(x);
  }
  for (int(i) = (0); (i) < (m); (i)++) {
    cin >> x >> y;
    x--;
    y--;
    a[x].push_back(y);
    b[y].push_back(x);
  }
  for (int(i) = (0); (i) < (c.size()); (i)++)
    if (c[i] == 1) {
      queue.push_back(i);
      f.push_back(true);
    } else {
      f.push_back(false);
    }
  for (int(i) = (0); (i) < (queue.size()); (i)++) {
    for (int(j) = (0); (j) < (a[queue[i]].size()); (j)++) {
      if (f[a[queue[i]][j]]) continue;
      queue.push_back(a[queue[i]][j]);
      f[a[queue[i]][j]] = true;
    }
  }
  queue.clear();
  for (int(i) = (0); (i) < (c.size()); (i)++)
    if (c[i] == 2) {
      queue.push_back(i);
      f1.push_back(true);
    } else {
      f1.push_back(false);
    }
  for (int(i) = (0); (i) < (queue.size()); (i)++) {
    for (int(j) = (0); (j) < (b[queue[i]].size()); (j)++) {
      if (f1[b[queue[i]][j]]) continue;
      f1[b[queue[i]][j]] = true;
      if (c[b[queue[i]][j]] == 1) continue;
      queue.push_back(b[queue[i]][j]);
    }
  }
  for (int(i) = (0); (i) < (n); (i)++)
    if (f[i] && f1[i]) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  return 0;
}

```


### Prompt

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

Vladimir wants to modernize partitions in his office. To make the office more comfortable he decided to remove a partition and plant several bamboos in a row. He thinks it would be nice if there are n bamboos in a row, and the i-th from the left is ai meters high.

Vladimir has just planted n bamboos in a row, each of which has height 0 meters right now, but they grow 1 meter each day. In order to make the partition nice Vladimir can cut each bamboo once at any height (no greater that the height of the bamboo), and then the bamboo will stop growing.

Vladimir wants to check the bamboos each d days (i.e. d days after he planted, then after 2d days and so on), and cut the bamboos that reached the required height. Vladimir wants the total length of bamboo parts he will cut off to be no greater than k meters.

What is the maximum value d he can choose so that he can achieve what he wants without cutting off more than k meters of bamboo?

Input

The first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 1011) — the number of bamboos and the maximum total length of cut parts, in meters.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the required heights of bamboos, in meters.

Output

Print a single integer — the maximum value of d such that Vladimir can reach his goal.

Examples

Input

3 4
1 3 5

Output

3

Input

3 40
10 30 50

Output

32

Note

In the first example Vladimir can check bamboos each 3 days. Then he will cut the first and the second bamboos after 3 days, and the third bamboo after 6 days. The total length of cut parts is 2 + 0 + 1 = 3 meters.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct query {
  long long l, r, x;
};
int n, a[109];
long long m;
int main() {
  cin >> n >> m;
  vector<query> v;
  vector<long long> cp = {1LL << 60};
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    int pr = sqrt(a[i]);
    for (int j = 1; j < pr; j++) {
      v.push_back(query{j, j + 1, (a[i] + j - 1) / j});
      cp.push_back(j);
    }
    cp.push_back(pr);
    int r = (a[i] + pr - 1) / pr, ptr = pr;
    for (int j = r; j > 1; j--) {
      v.push_back(query{ptr, (a[i] + j - 2) / (j - 1), j});
      ptr = v.back().r;
      cp.push_back(ptr);
    }
    v.push_back(query{ptr, 1LL << 60, 1});
  }
  sort(cp.begin(), cp.end());
  cp.erase(unique(cp.begin(), cp.end()), cp.end());
  vector<long long> sum(cp.size());
  for (query i : v) {
    int pl = lower_bound(cp.begin(), cp.end(), i.l) - cp.begin();
    int pr = lower_bound(cp.begin(), cp.end(), i.r) - cp.begin();
    sum[pl] += i.x;
    sum[pr] -= i.x;
  }
  for (int i = 1; i < cp.size(); i++) sum[i] += sum[i - 1];
  long long ret = 0;
  for (int i = 0; i < cp.size() - 1; i++) {
    long long r = min(cp[i + 1] - 1, (m + sum[0]) / sum[i]);
    if (cp[i] <= r) ret = max(ret, r);
  }
  cout << ret << endl;
  return 0;
}

```


### Prompt

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

Recently, Vladimir got bad mark in algebra again. To avoid such unpleasant events in future he decided to train his arithmetic skills. He wrote four integer numbers a, b, c, d on the blackboard. During each of the next three minutes he took two numbers from the blackboard (not necessarily adjacent) and replaced them with their sum or their product. In the end he got one number. Unfortunately, due to the awful memory he forgot that number, but he remembers four original numbers, sequence of the operations and his surprise because of the very small result. Help Vladimir remember the forgotten number: find the smallest number that can be obtained from the original numbers by the given sequence of operations.

Input

First line contains four integers separated by space: 0 ≤ a, b, c, d ≤ 1000 — the original numbers. Second line contains three signs ('+' or '*' each) separated by space — the sequence of the operations in the order of performing. ('+' stands for addition, '*' — multiplication)

Output

Output one integer number — the minimal result which can be obtained.

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d).

Examples

Input

1 1 1 1
+ + *

Output

3

Input

2 2 2 2
* * +

Output

8

Input

1 2 3 4
* + +

Output

9

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long a[5], ans = 0x7f7f7f7f7f7f7f7f;
char p[4];
inline void dfs(const int &left) {
  if (left == 1) {
    register long long s;
    for (register int i = 1; i <= 4; i++)
      if (a[i] != -1) {
        s = a[i];
        break;
      }
    ans = (ans < s ? ans : s);
    return;
  }
  for (register int i = 1; i <= 4; i++)
    for (register int j = i + 1; j <= 4; j++) {
      register int k = 4 - left + 1;
      if (a[i] == -1 || a[j] == -1 || p[k] == '-') continue;
      register long long x = a[i], y = a[j];
      register char t = p[k];
      p[k] = '-';
      a[j] = -1;
      if (t == '+')
        a[i] = x + y;
      else
        a[i] = x * y;
      dfs(left - 1);
      a[i] = x;
      a[j] = y;
      p[k] = t;
    }
}
int main() {
  for (register int i = 1; i <= 4; i++) cin >> a[i];
  for (register int i = 1; i <= 3; i++) cin >> p[i];
  dfs(4);
  cout << ans;
  return 0;
}

```


### Prompt

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

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::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  vector<long long int> v;
  long long int n, m, a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least 3 (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself k-multihedgehog.

Let us define k-multihedgehog as follows:

  * 1-multihedgehog is hedgehog: it has one vertex of degree at least 3 and some vertices of degree 1.
  * For all k ≥ 2, k-multihedgehog is (k-1)-multihedgehog in which the following changes has been made for each vertex v with degree 1: let u be its only neighbor; remove vertex v, create a new hedgehog with center at vertex w and connect vertices u and w with an edge. New hedgehogs can differ from each other and the initial gift.

Thereby k-multihedgehog is a tree. Ivan made k-multihedgehog but he is not sure that he did not make any mistakes. That is why he asked you to check if his tree is indeed k-multihedgehog.

Input

First line of input contains 2 integers n, k (1 ≤ n ≤ 10^{5}, 1 ≤ k ≤ 10^{9}) — number of vertices and hedgehog parameter.

Next n-1 lines contains two integers u v (1 ≤ u,    v ≤ n;    u ≠ v) — indices of vertices connected by edge.

It is guaranteed that given graph is a tree.

Output

Print "Yes" (without quotes), if given graph is k-multihedgehog, and "No" (without quotes) otherwise.

Examples

Input

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

Output

Yes

Input

3 1
1 3
2 3

Output

No

Note

2-multihedgehog from the first example looks like this:

<image>

Its center is vertex 13. Hedgehogs created on last step are: [4 (center), 1, 2, 3], [6 (center), 7, 8, 9], [5 (center), 10, 11, 12, 13].

Tree from second example is not a hedgehog because degree of center should be at least 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int n, k, l;
vector<vector<long long int> > adj;
vector<bool> visited;
long long int d[100006] = {INT_MAX};
long long int MOD = 1000000007;
long long int level[100006];
long long int dis2[100006];
long long int degree[100006] = {0};
long long int distance(long long int x) {
  long long int last = x;
  for (long long int j = 1; j <= n; j++) d[j] = INT_MAX;
  queue<long long int> q;
  q.push(x);
  d[x] = 0;
  long long int node = x;
  while (!q.empty()) {
    node = q.front();
    q.pop();
    for (auto it : adj[node]) {
      if (d[it] > (d[node] + 1)) {
        d[it] = d[node] + 1;
        q.push(it);
      }
    }
  }
  return node;
}
void get_farthest2(int node) {
  int i;
  for (i = 0; i <= 100001; i++) {
    dis2[i] = MOD;
  }
  dis2[node] = 0;
  queue<int> q;
  q.push(node);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto it : adj[x]) {
      if (dis2[it] > (dis2[x] + 1)) {
        dis2[it] = dis2[x] + 1;
        q.push(it);
      }
    }
  }
}
int main() {
  for (long long int i = 0; i <= 100001; i++) {
    level[i] = MOD;
    degree[i] = 0;
  }
  long long int i, a, b;
  cin >> n >> k;
  if (n == 1) {
    cout << "No" << endl;
    return 0;
  }
  adj.resize(n + 1);
  long long int center = 0;
  for (i = 1; i < n; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
    degree[a]++;
    degree[b]++;
  }
  long long int x = distance(1);
  long long int y = distance(x);
  get_farthest2(y);
  long long int ans = 1;
  if ((d[y] % 2 == 1) || k > n || (dis2[x] % 2 == 1)) {
    cout << "No" << endl;
    return 0;
  }
  for (i = 1; i <= n; i++)
    if ((d[i] == dis2[i]) && (adj[i].size() >= 3) && (d[i] == (d[y] / 2))) {
      center = i;
      break;
    }
  if (center == 0) {
    cout << "No" << endl;
    return 0;
  }
  queue<int> qu;
  long long int centre = center;
  qu.push(centre);
  level[centre] = 1;
  while (!qu.empty()) {
    int xx = qu.front();
    qu.pop();
    if (xx == centre && degree[xx] < 3) {
      cout << "No";
      return 0;
    } else if ((degree[xx] < 4) && (level[xx] <= k) && (xx != centre)) {
      cout << "No";
      return 0;
    } else if (level[xx] > k && degree[xx] != 1) {
      cout << "No";
      return 0;
    }
    for (auto it : adj[xx]) {
      if (level[it] > level[xx] + 1) {
        level[it] = level[xx] + 1;
        qu.push(it);
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

```


### Prompt

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

The fundamental prerequisite for justice is not to be correct, but to be strong. That's why justice is always the victor.

The Cinderswarm Bee. Koyomi knows it.

The bees, according to their nature, live in a tree. To be more specific, a complete binary tree with n nodes numbered from 1 to n. The node numbered 1 is the root, and the parent of the i-th (2 ≤ i ≤ n) node is <image>. Note that, however, all edges in the tree are undirected.

Koyomi adds m extra undirected edges to the tree, creating more complication to trick the bees. And you're here to count the number of simple paths in the resulting graph, modulo 109 + 7. A simple path is an alternating sequence of adjacent nodes and undirected edges, which begins and ends with nodes and does not contain any node more than once. Do note that a single node is also considered a valid simple path under this definition. Please refer to the examples and notes below for instances.

Input

The first line of input contains two space-separated integers n and m (1 ≤ n ≤ 109, 0 ≤ m ≤ 4) — the number of nodes in the tree and the number of extra edges respectively.

The following m lines each contains two space-separated integers u and v (1 ≤ u, v ≤ n, u ≠ v) — describing an undirected extra edge whose endpoints are u and v.

Note that there may be multiple edges between nodes in the resulting graph.

Output

Output one integer — the number of simple paths in the resulting graph, modulo 109 + 7.

Examples

Input

3 0

Output

9

Input

3 1
2 3

Output

15

Input

2 4
1 2
2 1
1 2
2 1

Output

12

Note

In the first example, the paths are: (1); (2); (3); (1, 2); (2, 1); (1, 3); (3, 1); (2, 1, 3); (3, 1, 2). (For the sake of clarity, the edges between nodes are omitted since there are no multiple edges in this case.)

In the second example, the paths are: (1); (1, 2); (1, 2, 3); (1, 3); (1, 3, 2); and similarly for paths starting with 2 and 3. (5 × 3 = 15 paths in total.)

In the third example, the paths are: (1); (2); any undirected edge connecting the two nodes travelled in either direction. (2 + 5 × 2 = 12 paths in total.)

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int add(int x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
int mul(int x, int y) {
  long long z = 1LL * x * y;
  return z - z / mod * mod;
}
vector<pair<int, int> > g[555];
unordered_map<int, int> q;
int d[555], w[555], p[555][555], tot, ans;
bool vis[555];
int get_id(int x) {
  if (q.find(x) == q.end()) {
    d[tot] = x;
    q[x] = tot++;
  }
  return q[x];
}
void add_edge(int x) {
  if (x == 1) return;
  int u = get_id(x), v = get_id(x >> 1);
  p[u][v] = p[v][u] = 1;
  add_edge(x >> 1);
}
int fcount(int x, int n) {
  int res = 0;
  if (q.find(x) == q.end()) {
    for (int i = 0; 1; i++) {
      if (((x + 1) << i) - 1 >= n) {
        if ((x << i) <= n) res += n - (x << i) + 1;
        break;
      } else
        res += 1 << i;
    }
  } else {
    res++;
    if ((x << 1) <= n && q.find(x << 1) == q.end()) res += fcount(x << 1, n);
    if ((x << 1 | 1) <= n && q.find(x << 1 | 1) == q.end())
      res += fcount(x << 1 | 1, n);
  }
  return res;
}
int dfs(int u) {
  if (vis[u]) return 0;
  vis[u] = 1;
  int res = w[u];
  for (auto v : g[u]) res = add(res, mul(v.second, dfs(v.first)));
  vis[u] = 0;
  return res;
}
int main() {
  int n, m, i, j, u[5], v[5];
  scanf("%d%d", &n, &m);
  if (!m) {
    printf("%d\n", mul(n, n));
    return 0;
  }
  for (i = 0; i < m; i++) {
    scanf("%d%d", &u[i], &v[i]);
    add_edge(u[i]);
    add_edge(v[i]);
  }
  for (i = 0; i < m; i++) {
    p[q[u[i]]][q[v[i]]]++;
    p[q[v[i]]][q[u[i]]]++;
  }
  for (i = 0; i < tot; i++) {
    for (j = 0; j < tot; j++) {
      if (p[i][j]) g[i].push_back(pair<int, int>(j, p[i][j]));
    }
  }
  for (i = 0; i < tot; i++) w[i] = fcount(d[i], n);
  for (i = 0; i < tot; i++) ans = add(ans, mul(w[i], dfs(i)));
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Snuke loves permutations. He is making a permutation of length N.

Since he hates the integer K, his permutation will satisfy the following:

* Let the permutation be a_1, a_2, ..., a_N. For each i = 1,2,...,N, |a_i - i| \neq K.

Among the N! permutations of length N, how many satisfies this condition?

Since the answer may be extremely large, find the answer modulo 924844033(prime).

Constraints

* 2 ≦ N ≦ 2000
* 1 ≦ K ≦ N-1

Input

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

N K

Output

Print the answer modulo 924844033.

Examples

Input

3 1

Output

2

Input

4 1

Output

5

Input

4 2

Output

9

Input

4 3

Output

14

Input

425 48

Output

756765083

### Response

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

const int Maxn = 2005, p = 924844033;
int n, k, ct, arr[Maxn];
long long ans, f[Maxn][Maxn][2][2], fac[Maxn];
int main()
{
	scanf("%d%d", &n, &k);
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = fac[i - 1] * i % p;
	for (int i = 1; i <= k; i++)
		for (int j = i; j <= n; j += k)
			arr[++ct] = j;
	arr[0] = -0x3f3f3f3f;
	f[0][0][0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		f[i][0][0][0] = 1;
		for (int j = 1; j <= i; j++)
		{
			f[i][j][0][0] = (f[i - 1][j][0][0] + f[i - 1][j][1][0] + f[i - 1][j - 1][0][0] * (arr[i] - arr[i - 1] == k)) % p;
			f[i][j][0][1] = (arr[i + 1] - arr[i] == k) * (f[i - 1][j - 1][0][0] + f[i - 1][j - 1][1][0]) % p;
			f[i][j][1][0] = (f[i - 1][j][0][1] + f[i - 1][j][1][1] + (arr[i] - arr[i - 1] == k) * f[i - 1][j - 1][0][1]) % p;
			f[i][j][1][1] = (arr[i + 1] - arr[i] == k) * (f[i - 1][j - 1][0][1] + f[i - 1][j - 1][1][1]) % p;
		}
	}
	for (int i = 0; i <= n; i++)
		(ans += (i & 1 ? p - 1 : 1) * fac[n - i] % p * (f[n][i][0][0] + f[n][i][1][0])) %= p;
	printf("%lld", ans);
	return 0;
}
```


### Prompt

Develop a solution in Cpp to the problem described below:

PolandBall is playing a game with EnemyBall. The rules are simple. Players have to say words in turns. You cannot say a word which was already said. PolandBall starts. The Ball which can't say a new word loses.

You're given two lists of words familiar to PolandBall and EnemyBall. Can you determine who wins the game, if both play optimally?

Input

The first input line contains two integers n and m (1 ≤ n, m ≤ 103) — number of words PolandBall and EnemyBall know, respectively.

Then n strings follow, one per line — words familiar to PolandBall.

Then m strings follow, one per line — words familiar to EnemyBall.

Note that one Ball cannot know a word more than once (strings are unique), but some words can be known by both players.

Each word is non-empty and consists of no more than 500 lowercase English alphabet letters.

Output

In a single line of print the answer — "YES" if PolandBall wins and "NO" otherwise. Both Balls play optimally.

Examples

Input

5 1
polandball
is
a
cool
character
nope

Output

YES

Input

2 2
kremowka
wadowicka
kremowka
wiedenska

Output

YES

Input

1 2
a
a
b

Output

NO

Note

In the first example PolandBall knows much more words and wins effortlessly.

In the second example if PolandBall says kremowka first, then EnemyBall cannot use that word anymore. EnemyBall can only say wiedenska. PolandBall says wadowicka and wins.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<long int, long int> &a,
               const pair<long int, long int> &b) {
  return (a.second < b.second);
}
int main() {
  long int n, m, i;
  cin >> n >> m;
  set<string> s;
  string s1;
  for (i = 0; i < n + m; i++) {
    cin >> s1;
    s.insert(s1);
  }
  i = n + m - s.size();
  if (i % 2 == 0) {
    n = n - i;
    m = m - i;
    if (n > m) {
      cout << "YES";
    } else {
      cout << "NO";
    }
  } else {
    n = n - i;
    m = m - i;
    m--;
    if (n > m) {
      cout << "YES";
    } else {
      cout << "NO";
    }
  }
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

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

Any balanced parentheses can be constructed using the following rules:

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

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

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

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

Input

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

$S$

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

Output

Print the answer in one line.

Examples

Input

((*)())

Output

2

Input

(*)

Output

1

Input

(()())*

Output

0

Input

()*()

Output

0

Input

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

Output

10

Input

*

Output

0

### Response

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

signed main(){

  string s;
  cin>>s;

  int cnt = 0;

  for(int i=0;i<s.size();i++){

    if( s[i] == '*' ) break;

    if( s[i] == '(' ) cnt++;

    if( s[i] == ')' ) cnt--;

  }

  cout<<cnt<<endl;

  return 0;
}

```


### Prompt

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

Since the giant heads have appeared in the sky all humanity is in danger, so all Ricks and Mortys from all parallel universes are gathering in groups to find a solution to get rid of them.

There are n parallel universes participating in this event (n Ricks and n Mortys). I. e. each of n universes has one Rick and one Morty. They're gathering in m groups. Each person can be in many groups and a group can contain an arbitrary number of members.

Ricks and Mortys have registered online in these groups. So, a person can have joined a group more than once (developer of this website hadn't considered this possibility).

<image>

Summer from universe #1 knows that in each parallel universe (including hers) exactly one of Rick and Morty from that universe is a traitor and is loyal, but no one knows which one. She knows that we are doomed if there's a group such that every member in that group is a traitor (they will plan and destroy the world).

Summer knows that if there's a possibility that world ends (there's a group where all members are traitors) she should immediately cancel this event. So she wants to know if she should cancel the event. You have to tell her yes if and only if there's at least one scenario (among all 2n possible scenarios, 2 possible scenarios for who a traitor in each universe) such that in that scenario the world will end.

Input

The first line of input contains two integers n and m (1 ≤ n, m ≤ 104) — number of universes and number of groups respectively.

The next m lines contain the information about the groups. i-th of them first contains an integer k (number of times someone joined i-th group, k > 0) followed by k integers vi, 1, vi, 2, ..., vi, k. If vi, j is negative, it means that Rick from universe number  - vi, j has joined this group and otherwise it means that Morty from universe number vi, j has joined it.

Sum of k for all groups does not exceed 104.

Output

In a single line print the answer to Summer's question. Print "YES" if she should cancel the event and "NO" otherwise.

Examples

Input

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

Output

YES

Input

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

Output

NO

Input

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

Output

YES

Note

In the first sample testcase, 1st group only contains the Rick from universe number 3, so in case he's a traitor, then all members of this group are traitors and so Summer should cancel the event.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, po, i, j, k, c;
  cin >> n >> m;
  po = 0;
  while (m--) {
    cin >> k;
    int a[k];
    for (i = 0; i <= k - 1; i++) cin >> a[i];
    c = 0;
    if (po == 0) {
      for (i = 0; i <= k - 1; i++) {
        for (j = 0; j <= k - 1; j++) {
          if (a[j] == -a[i] && j != i) {
            c = 1;
            break;
          }
        }
        if (c == 1) break;
      }
      if (c == 0) po = 1;
    }
  }
  if (po == 1)
    cout << "YES\n";
  else if (po == 0)
    cout << "NO\n";
}

```


### Prompt

Generate a Cpp solution to the following problem:

You are planning to build housing on a street. There are n spots available on the street on which you can build a house. The spots are labeled from 1 to n from left to right. In each spot, you can build a house with an integer height between 0 and h.

In each spot, if a house has height a, you will gain a^2 dollars from it.

The city has m zoning restrictions. The i-th restriction says that the tallest house from spots l_i to r_i (inclusive) must be at most x_i.

You would like to build houses to maximize your profit. Determine the maximum profit possible.

Input

The first line contains three integers n, h, and m (1 ≤ n,h,m ≤ 50) — the number of spots, the maximum height, and the number of restrictions.

Each of the next m lines contains three integers l_i, r_i, and x_i (1 ≤ l_i ≤ r_i ≤ n, 0 ≤ x_i ≤ h) — left and right limits (inclusive) of the i-th restriction and the maximum possible height in that range.

Output

Print a single integer, the maximum profit you can make.

Examples

Input

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

Output

14

Input

4 10 2
2 3 8
3 4 7

Output

262

Note

In the first example, there are 3 houses, the maximum height of a house is 3, and there are 3 restrictions. The first restriction says the tallest house between 1 and 1 must be at most 1. The second restriction says the tallest house between 2 and 2 must be at most 3. The third restriction says the tallest house between 3 and 3 must be at most 2.

In this case, it is optimal to build houses with heights [1, 3, 2]. This fits within all the restrictions. The total profit in this case is 1^2 + 3^2 + 2^2 = 14.

In the second example, there are 4 houses, the maximum height of a house is 10, and there are 2 restrictions. The first restriction says the tallest house from 2 to 3 must be at most 8. The second restriction says the tallest house from 3 to 4 must be at most 7.

In this case, it's optimal to build houses with heights [10, 8, 7, 7]. We get a profit of 10^2+8^2+7^2+7^2 = 262. Note that there are two restrictions on house 3 and both of them must be satisfied. Also, note that even though there isn't any explicit restrictions on house 1, we must still limit its height to be at most 10 (h=10).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 4005, inf = 1e9 + 7;
int d[maxn], v[maxn], cur[maxn], n, m;
int h;
struct edge {
  int u, v;
  long long c, f;
};
vector<int> g[maxn];
vector<edge> e;
void addedge(int x, int y, int c) {
  int id = e.size();
  g[x].push_back(id);
  e.push_back((edge){x, y, c, 0});
  g[y].push_back(++id);
  e.push_back((edge){y, x, 0, 0});
}
bool bfs(int s, int t) {
  memset(v, 0, sizeof(v));
  d[s] = 0;
  v[s] = 1;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    int sz = g[i].size();
    for (int k = 0; k < sz; k++) {
      int id = g[i][k];
      int j = e[id].v;
      if (v[j] || e[id].c - e[id].f == 0) continue;
      d[j] = d[i] + 1;
      q.push(j);
      v[j] = 1;
    }
  }
  return v[t];
}
long long dfs(int i, long long a, int T) {
  if (a == 0 || i == T) return a;
  long long flow = 0, f;
  int sz = g[i].size();
  for (int &k = cur[i]; k < sz; k++) {
    int id = g[i][k];
    int j = e[id].v;
    if (d[j] == d[i] + 1 && (f = dfs(j, min(a, e[id].c - e[id].f), T)) > 0) {
      e[id].f += f;
      e[id ^ 1].f -= f;
      flow += f;
      a -= f;
      if (a == 0) break;
    }
  }
  return flow;
}
long long maxflow(int s, int t) {
  long long flow = 0;
  while (bfs(s, t)) {
    memset(cur, 0, sizeof(cur));
    flow += dfs(s, inf, t);
  }
  return flow;
}
int idx(int x, int y) { return x * (h + 1) + (y + 1); }
int main() {
  cin >> n >> h >> m;
  int ans = h * h * n;
  int s = 0, t = n * (h + 1) + m + 1;
  for (int i = 0; i < n; i++) {
    addedge(s, idx(i, 0), inf);
    for (int j = 0; j < h; j++) {
      addedge(idx(i, j), idx(i, j + 1), h * h - j * j);
    }
  }
  for (int i = 1; i <= m; i++) {
    int l, r, x, c;
    cin >> l >> r >> x >> c;
    for (int j = l; j <= r; j++) {
      if (x < h) addedge(idx(j - 1, x + 1), n * (h + 1) + i, inf);
    }
    addedge(n * (h + 1) + i, t, c);
  }
  cout << ans - maxflow(s, t) << endl;
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Uncle Fyodor, Matroskin the Cat and Sharic the Dog live their simple but happy lives in Prostokvashino. Sometimes they receive parcels from Uncle Fyodor’s parents and sometimes from anonymous benefactors, in which case it is hard to determine to which one of them the package has been sent. A photographic rifle is obviously for Sharic who loves hunting and fish is for Matroskin, but for whom was a new video game console meant? Every one of the three friends claimed that the present is for him and nearly quarreled. Uncle Fyodor had an idea how to solve the problem justly: they should suppose that the console was sent to all three of them and play it in turns. Everybody got relieved but then yet another burning problem popped up — who will play first? This time Matroskin came up with a brilliant solution, suggesting the most fair way to find it out: play rock-paper-scissors together. The rules of the game are very simple. On the count of three every player shows a combination with his hand (or paw). The combination corresponds to one of three things: a rock, scissors or paper. Some of the gestures win over some other ones according to well-known rules: the rock breaks the scissors, the scissors cut the paper, and the paper gets wrapped over the stone. Usually there are two players. Yet there are three friends, that’s why they decided to choose the winner like that: If someone shows the gesture that wins over the other two players, then that player wins. Otherwise, another game round is required. Write a program that will determine the winner by the gestures they have shown.

Input

The first input line contains the name of the gesture that Uncle Fyodor showed, the second line shows which gesture Matroskin showed and the third line shows Sharic’s gesture.

Output

Print "F" (without quotes) if Uncle Fyodor wins. Print "M" if Matroskin wins and "S" if Sharic wins. If it is impossible to find the winner, print "?".

Examples

Input

rock
rock
rock

Output

?

Input

paper
rock
rock

Output

F

Input

scissors
rock
rock

Output

?

Input

scissors
paper
rock

Output

?

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string f;
  string m;
  string s;
  string F = "F";
  string M = "M";
  string S = "S";
  cin >> f >> m >> s;
  if (f == "rock" && m == "scissors" && s == "scissors") {
    cout << F << endl;
    return 0;
  }
  if (m == "rock" && f == "scissors" && s == "scissors") {
    cout << M << endl;
    return 0;
  }
  if (s == "rock" && m == "scissors" && f == "scissors") {
    cout << S << endl;
    return 0;
  }
  if (f == "paper" && m == "rock" && s == "rock") {
    cout << F << endl;
    return 0;
  }
  if (m == "paper" && f == "rock" && s == "rock") {
    cout << M << endl;
    return 0;
  }
  if (s == "paper" && m == "rock" && f == "rock") {
    cout << S << endl;
    return 0;
  }
  if (f == "scissors" && m == "paper" && s == "paper") {
    cout << F << endl;
    return 0;
  }
  if (m == "scissors" && f == "paper" && s == "paper") {
    cout << M << endl;
    return 0;
  }
  if (s == "scissors" && m == "paper" && f == "paper") {
    cout << S << endl;
    return 0;
  }
  cout << "?" << endl;
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Given an integer x, find 2 integers a and b such that:

  * 1 ≤ a,b ≤ x
  * b divides a (a is divisible by b).
  * a ⋅ b>x.
  * a/b<x.

Input

The only line contains the integer x (1 ≤ x ≤ 100).

Output

You should output two integers a and b, satisfying the given conditions, separated by a space. If no pair of integers satisfy the conditions above, print "-1" (without quotes).

Examples

Input

10

Output

6 3

Input

1

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  bool f = 0;
  for (int b = 1; b <= x; ++b) {
    for (int a = b; a <= x; ++a) {
      if (a % b == 0 && a * b > x && a / b < x) {
        f = 1;
        cout << a << ' ' << b << '\n';
        break;
      }
    }
    if (f) break;
  }
  if (!f) cout << -1 << '\n';
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Any resemblance to any real championship and sport is accidental.

The Berland National team takes part in the local Football championship which now has a group stage. Let's describe the formal rules of the local championship:

  * the team that kicked most balls in the enemy's goal area wins the game;
  * the victory gives 3 point to the team, the draw gives 1 point and the defeat gives 0 points;
  * a group consists of four teams, the teams are ranked by the results of six games: each team plays exactly once with each other team;
  * the teams that get places 1 and 2 in the group stage results, go to the next stage of the championship.

In the group stage the team's place is defined by the total number of scored points: the more points, the higher the place is. If two or more teams have the same number of points, then the following criteria are used (the criteria are listed in the order of falling priority, starting from the most important one):

  * the difference between the total number of scored goals and the total number of missed goals in the championship: the team with a higher value gets a higher place;
  * the total number of scored goals in the championship: the team with a higher value gets a higher place;
  * the lexicographical order of the name of the teams' countries: the country with the lexicographically smaller name gets a higher place.

The Berland team plays in the group where the results of 5 out of 6 games are already known. To be exact, there is the last game left. There the Berand national team plays with some other team. The coach asks you to find such score X:Y (where X is the number of goals Berland scored and Y is the number of goals the opponent scored in the game), that fulfills the following conditions:

  * X > Y, that is, Berland is going to win this game;
  * after the game Berland gets the 1st or the 2nd place in the group;
  * if there are multiple variants, you should choose such score X:Y, where value X - Y is minimum;
  * if it is still impossible to come up with one score, you should choose the score where value Y (the number of goals Berland misses) is minimum.

Input

The input has five lines.

Each line describes a game as "team1 team2 goals1:goals2" (without the quotes), what means that team team1 played a game with team team2, besides, team1 scored goals1 goals and team2 scored goals2 goals. The names of teams team1 and team2 are non-empty strings, consisting of uppercase English letters, with length of no more than 20 characters; goals1, goals2 are integers from 0 to 9.

The Berland team is called "BERLAND". It is guaranteed that the Berland team and one more team played exactly 2 games and the the other teams played exactly 3 games.

Output

Print the required score in the last game as X:Y, where X is the number of goals Berland scored and Y is the number of goals the opponent scored. If the Berland team does not get the first or the second place in the group, whatever this game's score is, then print on a single line "IMPOSSIBLE" (without the quotes).

Note, that the result score can be very huge, 10:0 for example.

Examples

Input

AERLAND DERLAND 2:1
DERLAND CERLAND 0:3
CERLAND AERLAND 0:1
AERLAND BERLAND 2:0
DERLAND BERLAND 4:0

Output

6:0

Input

AERLAND DERLAND 2:2
DERLAND CERLAND 2:3
CERLAND AERLAND 1:3
AERLAND BERLAND 2:1
DERLAND BERLAND 4:1

Output

IMPOSSIBLE

Note

In the first sample "BERLAND" plays the last game with team "CERLAND". If Berland wins with score 6:0, the results' table looks like that in the end:

  1. AERLAND (points: 9, the difference between scored and missed goals: 4, scored goals: 5)
  2. BERLAND (points: 3, the difference between scored and missed goals: 0, scored goals: 6)
  3. DERLAND (points: 3, the difference between scored and missed goals: 0, scored goals: 5)
  4. CERLAND (points: 3, the difference between scored and missed goals: -4, scored goals: 3)

In the second sample teams "AERLAND" and "DERLAND" have already won 7 and 4 points, respectively. The Berland team wins only 3 points, which is not enough to advance to the next championship stage.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Team {
  string name;
  int p, m, o, c;
  Team() { p = m = o = c = 0; }
  friend bool operator<(const Team& a, const Team& b) {
    if (a.o != b.o)
      return a.o > b.o;
    else if (a.p - a.m != b.p - b.m)
      return a.p - a.m > b.p - b.m;
    else if (a.p != b.p)
      return a.p > b.p;
    else
      return a.name < b.name;
  }
};
int main() {
  string t1, t2, t3, t4;
  int g1, g2;
  char z;
  map<string, Team> table;
  map<string, Team>::iterator it;
  for (int i = 0; i < 5; ++i) {
    cin >> t1 >> t2 >> g1 >> z >> g2;
    table[t1].p += g1;
    table[t1].m += g2;
    table[t1].o += 3 * (g1 > g2) + (g1 == g2);
    table[t1].c++;
    table[t1].name = t1;
    table[t2].p += g2;
    table[t2].m += g1;
    table[t2].o += 3 * (g2 > g1) + (g1 == g2);
    table[t2].c++;
    table[t2].name = t2;
  }
  t1 = "BERLAND";
  t3 = "";
  for (it = table.begin(); it != table.end(); ++it)
    if (it->first != "BERLAND") {
      if (it->second.c == 2)
        t2 = it->first;
      else if (t3 == "")
        t3 = it->first;
      else
        t4 = it->first;
    }
  for (int len = 1; len < 100; ++len) {
    for (int x = len; x < 100; ++x) {
      vector<Team> v;
      Team a, b;
      a = table[t1];
      b = table[t2];
      v.push_back(table[t3]);
      v.push_back(table[t4]);
      int y = x - len;
      a.p += x;
      a.m += y;
      a.o += 3;
      b.p += y;
      b.m += x;
      v.push_back(a);
      v.push_back(b);
      sort(v.begin(), v.end());
      if (v[0].name == "BERLAND" || v[1].name == "BERLAND") {
        cout << x << ":" << y << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

The time is 2020. There is data that saves the qualifying results of PC Koshien 2020. This data stores the reference number and the number of correct answers assigned to each team. Here, the ranking is determined by the number of correct answers, and the ranking is given in descending order of the number of correct answers, such as 1st, 2nd, and so on.

Enter the qualifying result data and reference number from the keyboard, and create a program that outputs the ranking of the team with that number.

Note

In the data of the input example, if the teams are arranged in order of the number of correct answers:

3,30
1,20
2,20
6,20
4,10
5,10

It will be. Here, in order to determine the ranking based on the number of correct answers, the 30-question correct answer team is ranked 1st, the 20-question correct answer team is ranked 2nd, and the 10-question correct answer team is ranked 3rd. Please note that this is different from the usual ranking with the correct team in 5th place).

Input

The input data consists of two parts. The first half is the qualifying result data, and the second half is the inquiry of the team number for which you want to know the ranking. The format of the qualifying result data is as follows.

p1, s1
p2, s2
...
...
0,0

pi (1 ≤ pi ≤ 100) and si (0 ≤ si ≤ 30) are integers representing the reference number and the number of correct answers for the i-th team, respectively. It is assumed that the input of this data is completed when both the reference number and the number of correct answers are 0.

Then multiple inquiries in the second half are given. The inquiry format is as follows.

q1
q2
::

Each query is given the reference number qi (1 ≤ qi ≤ 30) on one line. Please process this until the end of the input. The number of inquiries does not exceed 100.

Output

For each inquiry, print the team ranking on one line.

Example

Input

1,20
2,20
3,30
4,10
5,10
6,20
0,0
1
2
4
5

Output

2
2
3
3

### Response

```cpp
#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	vector<P> Vec;
	set<int, greater<int> > Set;
	int num, score;
	while(scanf("%d,%d", &num, &score))
	{
		if(num == 0 && score == 0)
		{
			break;
		}
		Set.insert(score);
		Vec.push_back(make_pair(num, score));
	}
	while(cin >> num)
	{
		for(int i = 0; i < Vec.size(); ++i)
		{
			if(Vec[i].first == num)
			{
				score = Vec[i].second;
				break;
			}
		}
		set<int, greater<int> >::iterator It = Set.begin();
		int count = 1;
		while(It != Set.end())
		{
			if(*It == score)
			{
				cout << count << endl;
			}
			++It;
			++count;
		}
	}
}

int main()
{
	solve();
	return(0);
}
```


### Prompt

Please create a solution in CPP to the following problem:

On one of the planets of Solar system, in Atmosphere University, many students are fans of bingo game.

It is well known that one month on this planet consists of n^2 days, so calendars, represented as square matrix n by n are extremely popular.

Weather conditions are even more unusual. Due to the unique composition of the atmosphere, when interacting with sunlight, every day sky takes one of three colors: blue, green or red.

To play the bingo, you need to observe the sky for one month — after each day, its cell is painted with the color of the sky in that day, that is, blue, green or red.

At the end of the month, students examine the calendar. If at least one row or column contains only cells of one color, that month is called lucky.

Let's call two colorings of calendar different, if at least one cell has different colors in them. It is easy to see that there are 3^{n ⋅ n} different colorings. How much of them are lucky? Since this number can be quite large, print it modulo 998244353.

Input

The first and only line of input contains a single integer n (1 ≤ n ≤ 1000 000) — the number of rows and columns in the calendar.

Output

Print one number — number of lucky colorings of the calendar modulo 998244353

Examples

Input

1

Output

3

Input

2

Output

63

Input

3

Output

9933

Note

In the first sample any coloring is lucky, since the only column contains cells of only one color.

In the second sample, there are a lot of lucky colorings, in particular, the following colorings are lucky:

<image>

While these colorings are not lucky:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353, N = 1e6 + 11;
int n, ans, res;
int fac[N], ifac[N];
inline int fp(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod)
    if (b & 1) res = 1ll * res * a % mod;
  return res;
}
inline void init(int n) {
  fac[0] = 1;
  for (register int i = 1; i <= n; ++i) fac[i] = 1ll * i * fac[i - 1] % mod;
  ifac[n] = fp(fac[n], mod - 2);
  for (register int i = n; i >= 1; --i) ifac[i - 1] = 1ll * i * ifac[i] % mod;
}
inline int C(int n, int m) {
  if (n < 0 || m < 0 || n < m) return 0;
  return 1ll * fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}
int main() {
  scanf("%d", &n);
  init(n);
  for (register int i = 1; i <= n; ++i)
    ans = (ans + (i & 1 ? 2ll : -2ll) *
                     fp(3, 1ll * n * (n - i) % (mod - 1) + i) * C(n, i) % mod) %
          mod;
  for (register int i = 0; i <= n - 1; ++i) {
    res = 3ll * C(n, i) % mod * (fp(1 - fp(3, i), n) - fp(-fp(3, i), n)) % mod;
    ans = (ans + ((i & 1) ? 1ll : -1ll) * res) % mod;
  }
  printf("%d\n", (ans + mod) % mod);
  return 0;
}

```


### Prompt

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

A famous sculptor Cicasso goes to a world tour!

Well, it is not actually a world-wide. But not everyone should have the opportunity to see works of sculptor, shouldn't he? Otherwise there will be no any exclusivity. So Cicasso will entirely hold the world tour in his native country — Berland.

Cicasso is very devoted to his work and he wants to be distracted as little as possible. Therefore he will visit only four cities. These cities will be different, so no one could think that he has "favourites". Of course, to save money, he will chose the shortest paths between these cities. But as you have probably guessed, Cicasso is a weird person. Although he doesn't like to organize exhibitions, he likes to travel around the country and enjoy its scenery. So he wants the total distance which he will travel to be as large as possible. However, the sculptor is bad in planning, so he asks you for help.

There are n cities and m one-way roads in Berland. You have to choose four different cities, which Cicasso will visit and also determine the order in which he will visit them. So that the total distance he will travel, if he visits cities in your order, starting from the first city in your list, and ending in the last, choosing each time the shortest route between a pair of cities — will be the largest.

Note that intermediate routes may pass through the cities, which are assigned to the tour, as well as pass twice through the same city. For example, the tour can look like that: <image>. Four cities in the order of visiting marked as overlines: [1, 5, 2, 4].

Note that Berland is a high-tech country. So using nanotechnologies all roads were altered so that they have the same length. For the same reason moving using regular cars is not very popular in the country, and it can happen that there are such pairs of cities, one of which generally can not be reached by car from the other one. However, Cicasso is very conservative and cannot travel without the car. Choose cities so that the sculptor can make the tour using only the automobile. It is guaranteed that it is always possible to do.

Input

In the first line there is a pair of integers n and m (4 ≤ n ≤ 3000, 3 ≤ m ≤ 5000) — a number of cities and one-way roads in Berland.

Each of the next m lines contains a pair of integers ui, vi (1 ≤ ui, vi ≤ n) — a one-way road from the city ui to the city vi. Note that ui and vi are not required to be distinct. Moreover, it can be several one-way roads between the same pair of cities.

Output

Print four integers — numbers of cities which Cicasso will visit according to optimal choice of the route. Numbers of cities should be printed in the order that Cicasso will visit them. If there are multiple solutions, print any of them.

Example

Input

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

Output

2 1 8 7

Note

Let d(x, y) be the shortest distance between cities x and y. Then in the example d(2, 1) = 3, d(1, 8) = 7, d(8, 7) = 3. The total distance equals 13.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[3005];
int dp[3005][3005];
int f[3005][5];
int Q[3005];
int ans[4];
int from[3005][4];
int to[3005][4];
int n, m, res;
void bfs(int s) {
  int f = 0;
  int r = 0;
  Q[++r] = s;
  for (int i = 1; i <= n; i++) {
    dp[s][i] = (s != i) ? -1e9 : 0;
  }
  while (r > f) {
    int u = Q[++f];
    for (int v : adj[u]) {
      if (dp[s][v] < 0) {
        dp[s][v] = dp[s][u] + 1;
        Q[++r] = v;
      }
    }
  }
}
void sort_from(int i) {
  for (int j = 0; j <= 3; j++)
    for (int k = j + 1; k <= 3; k++) {
      int u = from[i][j];
      int v = from[i][k];
      if (dp[i][u] < dp[i][v]) {
        swap(from[i][j], from[i][k]);
      }
    }
}
void sort_to(int i) {
  for (int j = 0; j <= 3; j++)
    for (int k = j + 1; k <= 3; k++) {
      int u = to[i][j];
      int v = to[i][k];
      if (dp[u][i] < dp[v][i]) {
        swap(to[i][j], to[i][k]);
      }
    }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    bfs(i);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      from[i][3] = j;
      to[i][3] = j;
      sort_to(i);
      sort_from(i);
    }
  for (int b = 1; b <= n; b++)
    for (int c = 1; c <= n; c++) {
      if (b == c) continue;
      for (int i = 0; i <= 2; i++)
        for (int j = 0; j <= 2; j++) {
          int a = to[b][i];
          int d = from[c][j];
          if (!a || !d) continue;
          if (a == b || a == c || d == b || d == c || a == d) continue;
          int sum = dp[a][b] + dp[b][c] + dp[c][d];
          if (sum > res) {
            res = sum;
            ans[0] = a;
            ans[1] = b;
            ans[2] = c;
            ans[3] = d;
          }
        }
    }
  for (int i : ans) cout << i << " ";
  return 0;
}

```


### Prompt

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

Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution to the following problem:

Find k integers such that the sum of two to the power of each number equals to the number n and the largest integer in the answer is as small as possible. As there may be multiple answers, you are asked to output the lexicographically largest one.

To be more clear, consider all integer sequence with length k (a1, a2, ..., ak) with <image>. Give a value <image> to each sequence. Among all sequence(s) that have the minimum y value, output the one that is the lexicographically largest.

For definitions of powers and lexicographical order see notes.

Input

The first line consists of two integers n and k (1 ≤ n ≤ 1018, 1 ≤ k ≤ 105) — the required sum and the length of the sequence.

Output

Output "No" (without quotes) in a single line if there does not exist such sequence. Otherwise, output "Yes" (without quotes) in the first line, and k numbers separated by space in the second line — the required sequence.

It is guaranteed that the integers in the answer sequence fit the range [ - 1018, 1018].

Examples

Input

23 5

Output

Yes
3 3 2 1 0

Input

13 2

Output

No

Input

1 2

Output

Yes
-1 -1

Note

Sample 1:

23 + 23 + 22 + 21 + 20 = 8 + 8 + 4 + 2 + 1 = 23

Answers like (3, 3, 2, 0, 1) or (0, 1, 2, 3, 3) are not lexicographically largest.

Answers like (4, 1, 1, 1, 0) do not have the minimum y value.

Sample 2:

It can be shown there does not exist a sequence with length 2.

Sample 3:

<image>

Powers of 2:

If x > 0, then 2x = 2·2·2·...·2 (x times).

If x = 0, then 2x = 1.

If x < 0, then <image>.

Lexicographical order:

Given two different sequences of the same length, (a1, a2, ... , ak) and (b1, b2, ... , bk), the first one is smaller than the second one for the lexicographical order, if and only if ai < bi, for the first i where ai and bi differ.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, K;
map<long long, long long> dd;
int main() {
  long long i;
  scanf("%lld%lld", &n, &K);
  for (i = 0; n; n /= 2, i++)
    if (n % 2) dd[i] = n % 2;
  K -= dd.size();
  if (K < 0) {
    puts("No");
    return 0;
  }
  puts("Yes");
  while (K) {
    auto p = *dd.rbegin();
    if (p.second <= K) {
      dd[p.first - 1] += p.second * 2;
      dd.erase(p.first);
      K -= p.second;
    } else {
      while (K) {
        K--;
        auto p2 = *dd.begin();
        dd[p2.first - 1] += 2;
        dd[p2.first]--;
        if (dd[p2.first] == 0) dd.erase(p2.first);
      }
    }
  }
  for (auto it = dd.rbegin(); it != dd.rend(); it++) {
    auto x = *it;
    for (i = 1; i <= x.second; i++) printf("%lld ", x.first);
  }
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.

Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced. So the word corrector works in such a way: as long as there are two consecutive vowels in the word, it deletes the first vowel in a word such that there is another vowel right before it. If there are no two consecutive vowels in the word, it is considered to be correct.

You are given a word s. Can you predict what will it become after correction?

In this problem letters a, e, i, o, u and y are considered to be vowels.

Input

The first line contains one integer n (1 ≤ n ≤ 100) — the number of letters in word s before the correction.

The second line contains a string s consisting of exactly n lowercase Latin letters — the word before the correction.

Output

Output the word s after the correction.

Examples

Input

5
weird

Output

werd

Input

4
word

Output

word

Input

5
aaeaa

Output

a

Note

Explanations of the examples:

  1. There is only one replace: weird <image> werd;
  2. No replace needed since there are no two consecutive vowels;
  3. aaeaa <image> aeaa <image> aaa <image> aa <image> a.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  cin >> n;
  string s, s1 = "";
  cin >> s;
  for (i = 0, j = 1; j < n; i++, j++) {
    if ((s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' ||
         s[i] == 'u' || s[i] == 'y') &&
        (s[j] == 'a' || s[j] == 'e' || s[j] == 'i' || s[j] == 'o' ||
         s[j] == 'u' || s[j] == 'y')) {
      i--;
    } else {
      s1 += s[i];
      i = j - 1;
    }
  }
  s1 += s[i];
  cout << s1;
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/nginx///sbin are equivalent. The character '/' (or some sequence of such characters) at the end of the path is required only in case of the path to the root directory, which can be represented as single character '/'.

A path called normalized if it contains the smallest possible number of characters '/'.

Your task is to transform a given path to the normalized form.

Input

The first line of the input contains only lowercase Latin letters and character '/' — the path to some directory. All paths start with at least one character '/'. The length of the given line is no more than 100 characters, it is not empty.

Output

The path in normalized form.

Examples

Input

//usr///local//nginx/sbin

Output

/usr/local/nginx/sbin

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  int n = s.length();
  int i = 1;
  string ans = "/";
  while (i != n) {
    if (s[i] == '/' && s[i - 1] == '/') {
      i++;
    } else {
      ans += s[i];
      i++;
    }
  }
  n = ans.length();
  if (ans[n - 1] == '/' && n > 1) {
    ans = ans.substr(0, n - 1);
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

```


### Prompt

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

You are playing a game where your character should overcome different obstacles. The current problem is to come down from a cliff. The cliff has height h, and there is a moving platform on each height x from 1 to h.

Each platform is either hidden inside the cliff or moved out. At first, there are n moved out platforms on heights p_1, p_2, ..., p_n. The platform on height h is moved out (and the character is initially standing there).

If you character is standing on some moved out platform on height x, then he can pull a special lever, which switches the state of two platforms: on height x and x - 1. In other words, the platform you are currently standing on will hide in the cliff and the platform one unit below will change it state: it will hide if it was moved out or move out if it was hidden. In the second case, you will safely land on it. Note that this is the only way to move from one platform to another.

Your character is quite fragile, so it can safely fall from the height no more than 2. In other words falling from the platform x to platform x - 2 is okay, but falling from x to x - 3 (or lower) is certain death.

Sometimes it's not possible to come down from the cliff, but you can always buy (for donate currency) several magic crystals. Each magic crystal can be used to change the state of any single platform (except platform on height h, which is unaffected by the crystals). After being used, the crystal disappears.

What is the minimum number of magic crystal you need to buy to safely land on the 0 ground level?

Input

The first line contains one integer q (1 ≤ q ≤ 100) — the number of queries. Each query contains two lines and is independent of all other queries.

The first line of each query contains two integers h and n (1 ≤ h ≤ 10^9, 1 ≤ n ≤ min(h, 2 ⋅ 10^5)) — the height of the cliff and the number of moved out platforms.

The second line contains n integers p_1, p_2, ..., p_n (h = p_1 > p_2 > ... > p_n ≥ 1) — the corresponding moved out platforms in the descending order of their heights.

The sum of n over all queries does not exceed 2 ⋅ 10^5.

Output

For each query print one integer — the minimum number of magic crystals you have to spend to safely come down on the ground level (with height 0).

Example

Input

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

Output

0
1
2
0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[200005], h, q, n;
int main() {
  scanf("%d", &q);
  while (q--) {
    memset(a, 0, sizeof(a));
    scanf("%d%d", &h, &n);
    int tmp;
    for (int i = 0; i < n; i++) {
      scanf("%d", &tmp);
      a[i] = tmp;
    }
    a[n] = 0;
    int cnt = 0;
    int i = 0;
    while (h > 0 && i < n - 1) {
      if (a[i + 1] < h - 1) {
        h = a[i + 1] + 1;
        a[i] = h;
        continue;
      }
      if (a[i + 2] == (h - 2) || h == 2) {
        h -= 2;
        i += 2;
      } else {
        cnt++;
        h -= 2;
        a[i + 1] = h;
        i++;
      }
    }
    if (h == (a[n - 2] + 1) && h > 3) cnt++;
    printf("%d\n", cnt);
  }
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.

As you may know, the coolest photos are on the film (because you can specify the hashtag #film for such).

Brain took a lot of colourful pictures on colored and black-and-white film. Then he developed and translated it into a digital form. But now, color and black-and-white photos are in one folder, and to sort them, one needs to spend more than one hour!

As soon as Brain is a photographer not programmer now, he asks you to help him determine for a single photo whether it is colored or black-and-white.

Photo can be represented as a matrix sized n × m, and each element of the matrix stores a symbol indicating corresponding pixel color. There are only 6 colors:

  * 'C' (cyan)
  * 'M' (magenta)
  * 'Y' (yellow)
  * 'W' (white)
  * 'G' (grey)
  * 'B' (black)

The photo is considered black-and-white if it has only white, black and grey pixels in it. If there are any of cyan, magenta or yellow pixels in the photo then it is considered colored.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 100) — the number of photo pixel matrix rows and columns respectively.

Then n lines describing matrix rows follow. Each of them contains m space-separated characters describing colors of pixels in a row. Each character in the line is one of the 'C', 'M', 'Y', 'W', 'G' or 'B'.

Output

Print the "#Black&White" (without quotes), if the photo is black-and-white and "#Color" (without quotes), if it is colored, in the only line.

Examples

Input

2 2
C M
Y Y

Output

#Color

Input

3 2
W W
W W
B B

Output

#Black&White

Input

1 1
W

Output

#Black&White

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  char c;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      cin >> c;
      if (c == 'C' || c == 'Y' || c == 'M') {
        puts("#Color");
        return 0;
      }
    }
  puts("#Black&White");
}

```


### Prompt

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

Polycarpus is an amateur programmer. Now he is analyzing a friend's program. He has already found there the function rangeIncrement(l, r), that adds 1 to each element of some array a for all indexes in the segment [l, r]. In other words, this function does the following:

    function rangeIncrement(l, r)
        for i := l .. r do
            a[i] = a[i] + 1

Polycarpus knows the state of the array a after a series of function calls. He wants to determine the minimum number of function calls that lead to such state. In addition, he wants to find what function calls are needed in this case. It is guaranteed that the required number of calls does not exceed 105.

Before calls of function rangeIncrement(l, r) all array elements equal zero.

Input

The first input line contains a single integer n (1 ≤ n ≤ 105) — the length of the array a[1... n].

The second line contains its integer space-separated elements, a[1], a[2], ..., a[n] (0 ≤ a[i] ≤ 105) after some series of function calls rangeIncrement(l, r).

It is guaranteed that at least one element of the array is positive. It is guaranteed that the answer contains no more than 105 calls of function rangeIncrement(l, r).

Output

Print on the first line t — the minimum number of calls of function rangeIncrement(l, r), that lead to the array from the input data. It is guaranteed that this number will turn out not more than 105.

Then print t lines — the descriptions of function calls, one per line. Each line should contain two integers li, ri (1 ≤ li ≤ ri ≤ n) — the arguments of the i-th call rangeIncrement(l, r). Calls can be applied in any order.

If there are multiple solutions, you are allowed to print any of them.

Examples

Input

6
1 2 1 1 4 1

Output

5
2 2
5 5
5 5
5 5
1 6

Input

5
1 0 1 0 1

Output

3
1 1
3 3
5 5

Note

The first sample requires a call for the entire array, and four additional calls:

  * one for the segment [2,2] (i.e. the second element of the array),
  * three for the segment [5,5] (i.e. the fifth element of the array).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, a[100010];
stack<pair<int, int> > st;
vector<pair<int, int> > v;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  pair<int, int> y = pair<int, int>(1, a[0]);
  for (int i = 1; i < n; i++) {
    pair<int, int> x(1, a[i]);
    for (; y.second > x.second;) {
      y.second--;
      v.push_back(pair<int, int>(i - y.first + 1, i));
      if (!st.empty()) {
        if (st.top().second == y.second) {
          y.first += (st.top().first);
          st.pop();
        }
      }
    }
    if (y.second == x.second)
      y.first += x.first;
    else {
      st.push(y);
      y = x;
    }
  }
  int m = n;
  for (; !st.empty();) {
    pair<int, int> x = st.top();
    st.pop();
    for (; y.second > x.second;) {
      y.second--;
      v.push_back(pair<int, int>(m - y.first + 1, m));
    }
    y.first += x.first;
    if (y.second == 0) {
      m -= y.first;
      if (st.empty()) break;
      y = st.top();
      st.pop();
    }
  }
  for (; y.second--;) v.push_back(pair<int, int>(1, y.first));
  printf("%d\n", v.size());
  for (int i = 0; i < (int)v.size(); i++)
    printf("%d %d\n", v[i].first, v[i].second);
  return 0;
}

```


### Prompt

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

Limak is a smart brown bear who loves chemistry, reactions and transforming elements.

In Bearland (Limak's home) there are n elements, numbered 1 through n. There are also special machines, that can transform elements. Each machine is described by two integers ai, bi representing two elements, not necessarily distinct. One can use a machine either to transform an element ai to bi or to transform bi to ai. Machines in Bearland aren't very resistant and each of them can be used at most once. It is possible that ai = bi and that many machines have the same pair ai, bi.

Radewoosh is Limak's biggest enemy and rival. He wants to test Limak in the chemistry. They will meet tomorrow and both of them will bring all their machines. Limak has m machines but he doesn't know much about his enemy. They agreed Radewoosh will choose two distinct elements, let's denote them as x and y. Limak will be allowed to use both his and Radewoosh's machines. He may use zero or more (maybe even all) machines to achieve the goal, each machine at most once. Limak will start from an element x and his task will be to first get an element y and then to again get an element x — then we say that he succeeds. After that Radewoosh would agree that Limak knows the chemistry (and Radewoosh would go away).

Radewoosh likes some particular non-empty set of favorite elements and he will choose x, y from that set. Limak doesn't know exactly which elements are in the set and also he doesn't know what machines Radewoosh has. Limak has heard q gossips (queries) though and each of them consists of Radewoosh's machines and favorite elements. For each gossip Limak wonders if he would be able to succeed tomorrow for every pair x, y chosen from the set of favorite elements. If yes then print "YES" (without the quotes). But if there exists a pair (x, y) from the given set that Limak wouldn't be able to succeed then you should print "NO" (without the quotes).

Input

The first line contains three integers n, m and q (1 ≤ n, q ≤ 300 000, 0 ≤ m ≤ 300 000) — the number of elements, the number of Limak's machines and the number of gossips, respectively.

Each of the next m lines contains two integers ai and bi (1 ≤ ai, bi ≤ n) describing one of Limak's machines.

Then, the description of q gossips follows.

The first line of the description of the i-th gossip contains two integers ni and mi (1 ≤ ni ≤ 300 000, 0 ≤ mi ≤ 300 000). The second line contains ni distinct integers xi, 1, xi, 2, ..., xi, ni (1 ≤ xi, j ≤ n) — Radewoosh's favorite elements in the i-th gossip. Note that ni = 1 is allowed, in this case there are no pairs of distinct elements, so Limak automatically wins (the answer is "YES"). Then mi lines follow, each containing two integers ai, j, bi, j (1 ≤ ai, j, bi, j) describing one of Radewoosh's machines in the i-th gossip.

The sum of ni over all gossips won't exceed 300 000. Also, the sum of mi over all gossips won't exceed 300 000.

Important: Because we want you to process the gossips online, in order to know the elements in Radewoosh's favorite set and elements that his machines can transform, for on each number that denotes them in the input you should use following function:

    int rotate(int element)
    {
       element=(element+R)%n;

       if (element==0) {
           element=n;
       }

       return element;
    }

where R is initially equal to 0 and is increased by the number of the query any time the answer is "YES". Queries are numbered starting with 1 in the order they appear in the input.

Output

You should print q lines. The i-th of them should contain "YES" (without quotes) if for the i-th gossip for each pair of elements x and y (in the set xi, 1, xi, 2, ..., xi, ni) Limak is able to succeed. Otherwise you should print "NO" (without quotes).

Examples

Input

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

Output

YES
NO
YES
YES

Input

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

Output

NO
YES

Note

Lets look at first sample:

In first gossip Radewoosh's favorite set is {4, 2} and he has no machines. Limak can tranform element 4 into 2 (so half of a task is complete) and then 2 into 3, and 3 into 4. Answer is "YES", so R is increased by 1.

In second gossip set in the input is denoted by {6, 2} and machine by (3, 4), but R is equal to 1, so set is {1, 3} and machine is (4, 5). Answer is "NO", so R isn't changed.

In third gossip set {6, 4, 3} and machines (2, 5) and (4, 6) are deciphered to be {1, 5, 4}, (3, 6) and (5, 1).

Consider Radewoosh's choices:

  * If he chooses elements 1 and 5, then Limak is able to transform 1 into 5, then 6 into 3, 3 into 2 and 2 into 1.
  * If he chooses elements 5 and 4, then Limak is able to transform 5 into 6, 6 into 3, 3 into 4 (half way already behind him), 4 into 2, 2 into 1, 1 into 5.
  * If he chooses elements 1 and 4, then Limak is able to transform 1 into 2, 2 into 4, 4 into 3, 3 into 6, 6 into 5 and 5 into 1.

So Limak is able to execute task. Answer is "YES" and R is increased by 3 (it's equal to 4 now).

In last gossip {1, 2} and (1, 2) are deciphered to be {5, 6} and (5, 6). Now there are 2 machines (5, 6) so Limak is able to execute task again.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int p1, p2, p3, p4;
vector<pair<int, int> > graph[1000007];
int l;
int pre[1000007];
int low[1000007];
vector<int> vec;
int bic[1000007];
int b;
vector<int> bgraph[1000007];
int bpre[1000007];
int bpost[1000007];
int c;
int conn[1000007];
int dis[1000007];
vector<int> jump[1000007];
vector<int> subset;
vector<pair<int, int> > edges;
int trans[1000007];
vector<int> sta;
vector<pair<int, int> > ngraph[1000007];
int bic2[1000007];
int res;
void dfs1(int v, int p) {
  l++;
  pre[v] = l;
  low[v] = l;
  sta.push_back(v);
  for (int i = 0; i < graph[v].size(); i++) {
    if (graph[v][i].second == p) continue;
    if (pre[graph[v][i].first]) {
      low[v] = min(low[v], pre[graph[v][i].first]);
    } else {
      dfs1(graph[v][i].first, graph[v][i].second);
      low[v] = min(low[v], low[graph[v][i].first]);
    }
  }
  if (pre[v] == low[v]) {
    b++;
    while (sta.back() != v) {
      bic[sta.back()] = b;
      sta.pop_back();
    }
    bic[sta.back()] = b;
    sta.pop_back();
  }
}
void dfs2(int v, int p) {
  l++;
  bpre[v] = l;
  conn[v] = c;
  jump[v].push_back(p);
  while (jump[v].back()) {
    p1 = jump[v].size() - 1;
    p2 = jump[v].back();
    jump[v].push_back(jump[p2][min(p1, (int)jump[p2].size() - 1)]);
  }
  for (int i = 0; i < bgraph[v].size(); i++) {
    if (bgraph[v][i] != p) {
      dis[bgraph[v][i]] = dis[v] + 1;
      dfs2(bgraph[v][i], v);
    }
  }
  l++;
  bpost[v] = l;
}
int lca(int v, int u) {
  if (conn[v] != conn[u]) return 0;
  for (int i = jump[v].size() - 1; i >= 0; i--) {
    if (i < jump[v].size() && dis[jump[v][i]] >= dis[u]) {
      v = jump[v][i];
    }
  }
  for (int i = jump[u].size() - 1; i >= 0; i--) {
    if (i < jump[u].size() && dis[jump[u][i]] >= dis[v]) {
      u = jump[u][i];
    }
  }
  for (int i = jump[v].size() - 1; i >= 0; i--) {
    if (i < jump[v].size() && i < jump[u].size() && jump[v][i] != jump[u][i]) {
      v = jump[v][i];
      u = jump[u][i];
    }
  }
  if (v != u) v = jump[v][0];
  return v;
}
bool comp(int v, int u) { return bpre[v] < bpre[u]; }
void filtr() {
  vector<int> vec2 = vec;
  vec.clear();
  sort(vec2.begin(), vec2.end(), comp);
  for (int i = 0; i < vec2.size(); i++) {
    if (!vec2[i]) continue;
    if (!i || vec2[i] != vec2[i - 1]) {
      vec.push_back(vec2[i]);
    }
  }
}
void dfs3(int v, int p) {
  l++;
  pre[v] = l;
  low[v] = l;
  sta.push_back(v);
  for (int i = 0; i < ngraph[v].size(); i++) {
    if (ngraph[v][i].second == p) continue;
    if (pre[ngraph[v][i].first]) {
      low[v] = min(low[v], pre[ngraph[v][i].first]);
    } else {
      dfs3(ngraph[v][i].first, ngraph[v][i].second);
      low[v] = min(low[v], low[ngraph[v][i].first]);
    }
  }
  if (pre[v] == low[v]) {
    b++;
    while (sta.back() != v) {
      bic2[sta.back()] = b;
      sta.pop_back();
    }
    bic2[sta.back()] = b;
    sta.pop_back();
  }
}
long long R;
int rotate(int element) {
  element = (element + R) % n;
  if (element == 0) element = n;
  return element;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &p1, &p2);
    graph[p1].push_back(make_pair(p2, i));
    graph[p2].push_back(make_pair(p1, i));
  }
  for (int i = 1; i <= n; i++) {
    if (!pre[i]) {
      dfs1(i, 0);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < graph[i].size(); j++) {
      if (bic[i] != bic[graph[i][j].first]) {
        bgraph[bic[i]].push_back(bic[graph[i][j].first]);
      }
    }
  }
  l = 0;
  for (int i = 1; i <= b; i++) {
    if (!bpre[i]) {
      c++;
      dfs2(i, 0);
    }
  }
  for (int h = 1; h <= q; h++) {
    subset.clear();
    edges.clear();
    vec.clear();
    scanf("%d%d", &p1, &p2);
    while (p1--) {
      scanf("%d", &p3);
      p3 = rotate(p3);
      subset.push_back(bic[p3]);
      vec.push_back(bic[p3]);
    }
    while (p2--) {
      scanf("%d%d", &p3, &p4);
      p3 = rotate(p3);
      p4 = rotate(p4);
      edges.push_back(make_pair(bic[p3], bic[p4]));
      vec.push_back(bic[p3]);
      vec.push_back(bic[p4]);
    }
    sort(vec.begin(), vec.end(), comp);
    for (int i = vec.size() - 1; i; i--) {
      vec.push_back(lca(vec[i], vec[i - 1]));
    }
    filtr();
    c = vec.size();
    for (int i = 0; i < c; i++) {
      trans[vec[i]] = i + 1;
      ngraph[i + 1].clear();
      pre[i + 1] = 0;
      low[i + 1] = 0;
    }
    l = 0;
    sta.clear();
    for (int i = 0; i < c; i++) {
      while (!sta.empty() && bpost[vec[i]] > bpost[sta.back()]) {
        sta.pop_back();
      }
      if (!sta.empty()) {
        l++;
        ngraph[trans[vec[i]]].push_back(make_pair(trans[sta.back()], l));
        ngraph[trans[sta.back()]].push_back(make_pair(trans[vec[i]], l));
      }
      sta.push_back(vec[i]);
    }
    sta.clear();
    for (int i = 0; i < edges.size(); i++) {
      l++;
      ngraph[trans[edges[i].first]].push_back(
          make_pair(trans[edges[i].second], l));
      ngraph[trans[edges[i].second]].push_back(
          make_pair(trans[edges[i].first], l));
    }
    b = 0;
    l = 0;
    for (int i = 1; i <= c; i++) {
      if (!pre[i]) {
        dfs3(i, 0);
      }
    }
    res = 1;
    for (int i = 1; i < subset.size(); i++) {
      if (bic2[trans[subset[i]]] != bic2[trans[subset[0]]]) {
        res = 0;
      }
    }
    if (res) {
      printf("YES\n");
      R += h;
    } else {
      printf("NO\n");
    }
  }
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Little boy Gerald studies at school which is quite far from his house. That's why he has to go there by bus every day. The way from home to school is represented by a segment of a straight line; the segment contains exactly n + 1 bus stops. All of them are numbered with integers from 0 to n in the order in which they follow from Gerald's home. The bus stop by Gerald's home has number 0 and the bus stop by the school has number n.

There are m buses running between the house and the school: the i-th bus goes from stop si to ti (si < ti), visiting all the intermediate stops in the order in which they follow on the segment. Besides, Gerald's no idiot and he wouldn't get off the bus until it is still possible to ride on it closer to the school (obviously, getting off would be completely pointless). In other words, Gerald can get on the i-th bus on any stop numbered from si to ti - 1 inclusive, but he can get off the i-th bus only on the bus stop ti.

Gerald can't walk between the bus stops and he also can't move in the direction from the school to the house.

Gerald wants to know how many ways he has to get from home to school. Tell him this number. Two ways are considered different if Gerald crosses some segment between the stops on different buses. As the number of ways can be too much, find the remainder of a division of this number by 1000000007 (109 + 7).

Input

The first line contains two space-separated integers: n and m (1 ≤ n ≤ 109, 0 ≤ m ≤ 105). Then follow m lines each containing two integers si, ti. They are the numbers of starting stops and end stops of the buses (0 ≤ si < ti ≤ n).

Output

Print the only number — the number of ways to get to the school modulo 1000000007 (109 + 7).

Examples

Input

2 2
0 1
1 2

Output

1

Input

3 2
0 1
1 2

Output

0

Input

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

Output

16

Note

The first test has the only variant to get to school: first on bus number one to the bus stop number one; then on bus number two to the bus stop number two.

In the second test no bus goes to the third bus stop, where the school is positioned. Thus, the correct answer is 0.

In the third test Gerald can either get or not on any of the first four buses to get closer to the school. Thus, the correct answer is 24 = 16.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
const int MOD = 1000000007;
map<int, int> mark;
pair<int, int> ar[MAXN];
vector<int> tmp;
int N, M, K;
int KD[MAXN * 3];
int update(int b, int s, int k, int konum, int sayi) {
  if (konum < b || konum > s) return KD[k];
  if (b == s && b == konum) return KD[k] = sayi;
  return KD[k] = (update(b, (b + s) / 2, k * 2, konum, sayi) +
                  update((b + s) / 2 + 1, s, k * 2 + 1, konum, sayi)) %
                 MOD;
}
int find(int b, int s, int k, int a1, int a2) {
  if (a1 <= b && s <= a2) return KD[k];
  if (a2 < b || a1 > s) return 0;
  return (find(b, (b + s) / 2, k * 2, a1, a2) +
          find((b + s) / 2 + 1, s, k * 2 + 1, a1, a2)) %
         MOD;
}
int main() {
  int a, b, t, k;
  scanf(" %d %d", &N, &M);
  for (int i = 1; i <= M; i++) {
    scanf(" %d %d", &a, &b);
    tmp.push_back(a);
    tmp.push_back(b);
    ar[i] = pair<int, int>(b, a);
  }
  tmp.push_back(N);
  tmp.push_back(-1);
  tmp.push_back(0);
  sort(tmp.begin(), tmp.end());
  sort(ar + 1, ar + M + 1);
  vector<int>::iterator it = unique(tmp.begin(), tmp.end());
  tmp.resize(it - tmp.begin());
  K = tmp.size() - 1;
  update(1, K, 1, 1, 1);
  for (int i = 1; i <= K; i++) mark[tmp[i]] = i;
  for (int i = 1; i <= M; i++) {
    a = mark[ar[i].second];
    b = mark[ar[i].first];
    t = find(1, K, 1, a, b - 1);
    k = find(1, K, 1, b, b);
    update(1, K, 1, b, (k + t) % MOD);
  }
  t = find(1, K, 1, K, K);
  cout << t << endl;
  return 0;
}

```


### Prompt

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

Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string s = s_1 s_2 ... s_{n} of length n where each letter is either R, S or P.

While initializing, the bot is choosing a starting index pos (1 ≤ pos ≤ n), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of s_{pos}:

  * if s_{pos} is equal to R the bot chooses "Rock";
  * if s_{pos} is equal to S the bot chooses "Scissors";
  * if s_{pos} is equal to P the bot chooses "Paper";

In the second round, the bot's choice is based on the value of s_{pos + 1}. In the third round — on s_{pos + 2} and so on. After s_n the bot returns to s_1 and continues his game.

You plan to play n rounds and you've already figured out the string s but still don't know what is the starting index pos. But since the bot's tactic is so boring, you've decided to find n choices to each round to maximize the average number of wins.

In other words, let's suggest your choices are c_1 c_2 ... c_n and if the bot starts from index pos then you'll win in win(pos) rounds. Find c_1 c_2 ... c_n such that (win(1) + win(2) + ... + win(n))/(n) is maximum possible.

Input

The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.

Next t lines contain test cases — one per line. The first and only line of each test case contains string s = s_1 s_2 ... s_{n} (1 ≤ n ≤ 2 ⋅ 10^5; s_i ∈ \{R, S, P\}) — the string of the bot.

It's guaranteed that the total length of all strings in one test doesn't exceed 2 ⋅ 10^5.

Output

For each test case, print n choices c_1 c_2 ... c_n to maximize the average number of wins. Print them in the same manner as the string s.

If there are multiple optimal answers, print any of them.

Example

Input

3
RRRR
RSP
S

Output

PPPP
RSP
R

Note

In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all n = 4 rounds, so the average is also equal to 4.

In the second test case:

  * if bot will start from pos = 1, then (s_1, c_1) is draw, (s_2, c_2) is draw and (s_3, c_3) is draw, so win(1) = 0;
  * if bot will start from pos = 2, then (s_2, c_1) is win, (s_3, c_2) is win and (s_1, c_3) is win, so win(2) = 3;
  * if bot will start from pos = 3, then (s_3, c_1) is lose, (s_1, c_2) is lose and (s_2, c_3) is lose, so win(3) = 0;

The average is equal to (0 + 3 + 0)/(3) = 1 and it can be proven that it's the maximum possible average.

A picture from Wikipedia explaining "Rock paper scissors" game:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long r = 0, p = 0, a = 0;
    for (long long i = 0; i < s.size(); i++) {
      if (s[i] == 'R') r++;
      if (s[i] == 'P') p++;
      if (s[i] == 'S') a++;
    }
    if (r >= p && r >= a) {
      for (long long i = 0; i < s.size(); i++) cout << 'P';
      cout << endl;
    } else if (p >= r && p >= a) {
      for (long long i = 0; i < s.size(); i++) cout << 'S';
      cout << endl;
    } else {
      for (long long i = 0; i < s.size(); i++) cout << 'R';
      cout << endl;
    }
  }
}

```


### Prompt

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

You are given a positive integer x. Check whether the number x is representable as the sum of the cubes of two positive integers.

Formally, you need to check if there are two integers a and b (1 ≤ a, b) such that a^3+b^3=x.

For example, if x = 35, then the numbers a=2 and b=3 are suitable (2^3+3^3=8+27=35). If x=4, then no pair of numbers a and b is suitable.

Input

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

Each test case contains one integer x (1 ≤ x ≤ 10^{12}).

Please note, that the input for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language.

Output

For each test case, output on a separate line:

  * "YES" if x is representable as the sum of the cubes of two positive integers.
  * "NO" otherwise.

You can output "YES" and "NO" in any case (for example, the strings yEs, yes, Yes and YES will be recognized as positive).

Example

Input

7
1
2
4
34
35
16
703657519796

Output

NO
YES
NO
NO
YES
YES
YES

Note

The number 1 is not representable as the sum of two cubes.

The number 2 is represented as 1^3+1^3.

The number 4 is not representable as the sum of two cubes.

The number 34 is not representable as the sum of two cubes.

The number 35 is represented as 2^3+3^3.

The number 16 is represented as 2^3+2^3.

The number 703657519796 is represented as 5779^3+7993^3.

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>mp;
void excel()
{
	for(ll i=1;i<=10000;i++)
	  mp[i*i*i]=1;
}
void solve()
{
	ll x,a,b;
	cin>>x;
	for(ll i=1;i<=10000;i++)
	{
		if(mp[x-i*i*i]==1)
		{
			cout<<"YES"<<endl;
			return;
		}
	}
	cout<<"NO"<<endl;
	return;
}
int main()
{
    ll t;
    cin>>t;
    excel();
    while(t--)  solve();
    return 0;
}
```