### Prompt

Develop a solution in CPP to the problem described below:

Om Nom is the main character of a game "Cut the Rope". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him.

<image>

The park consists of 2n + 1 - 1 squares connected by roads so that the scheme of the park is a full binary tree of depth n. More formally, the entrance to the park is located at the square 1. The exits out of the park are located at squares 2n, 2n + 1, ..., 2n + 1 - 1 and these exits lead straight to the Om Nom friends' houses. From each square i (2 ≤ i < 2n + 1) there is a road to the square <image>. Thus, it is possible to go from the park entrance to each of the exits by walking along exactly n roads.

<image> To light the path roads in the evening, the park keeper installed street lights along each road. The road that leads from square i to square <image> has ai lights.

Om Nom loves counting lights on the way to his friend. Om Nom is afraid of spiders who live in the park, so he doesn't like to walk along roads that are not enough lit. What he wants is that the way to any of his friends should have in total the same number of lights. That will make him feel safe.

He asked you to help him install additional lights. Determine what minimum number of lights it is needed to additionally place on the park roads so that a path from the entrance to any exit of the park contains the same number of street lights. You may add an arbitrary number of street lights to each of the roads.

Input

The first line contains integer n (1 ≤ n ≤ 10) — the number of roads on the path from the entrance to any exit.

The next line contains 2n + 1 - 2 numbers a2, a3, ... a2n + 1 - 1 — the initial numbers of street lights on each road of the park. Here ai is the number of street lights on the road between squares i and <image>. All numbers ai are positive integers, not exceeding 100.

Output

Print the minimum number of street lights that we should add to the roads of the park to make Om Nom feel safe.

Examples

Input

2
1 2 3 4 5 6

Output

5

Note

Picture for the sample test. Green color denotes the additional street lights.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int bs(int *st, int *en, int val, char c) {
  int k;
  if (c == 'l') k = lower_bound(st, en, val) - st;
  if (c == 'u') k = upper_bound(st, en, val) - st;
  return k;
}
int prime[78500];
int sieve() {
  int a, b, c;
  c = 0;
  prime[c] = 2;
  bool *m = (bool *)calloc(1000006, sizeof(bool));
  for (a = 3; a <= 1000000; a = a + 2) {
    if (!m[a]) {
      prime[++c] = a;
      for (b = 2 * a; b <= 1000000; b = b + a) m[b] = true;
    }
  }
  free(m);
  return c;
}
long long bigmod(long long i, long long pow) {
  if (pow < 1) return 1;
  if (pow == 1) return i % 1000000007;
  long long j;
  if (pow % 2) {
    j = (i * bigmod(i, pow - 1)) % 1000000007;
  } else {
    j = bigmod(i, pow / 2);
    j = (j * j) % 1000000007;
  }
  return j;
}
struct st {
  int v;
  int mx;
};
st s[100000];
int N;
int MAX;
int n;
int dfs(int i, int l) {
  if (l > n) return 0;
  int a, b;
  b = max(dfs(i * 2, l + 1), dfs(i * 2 + 1, l + 1));
  s[i].mx = s[i].v + b;
  return s[i].mx;
}
int recur(int i, int l, int add) {
  if (l >= n) return 0;
  int a, b, c;
  c = 0;
  if (s[2 * i].mx + add == MAX)
    b = 0;
  else {
    b = MAX - s[2 * i].mx - add;
    s[2 * i].v = s[2 * i].v + b;
  }
  c = c + b + recur(2 * i, l + 1, add + s[2 * i].v);
  if (s[2 * i + 1].mx + add == MAX)
    b = 0;
  else {
    b = MAX - s[2 * i + 1].mx - add;
    s[2 * i + 1].v = s[2 * i + 1].v + b;
  }
  c = c + b + recur(2 * i + 1, l + 1, add + s[2 * i + 1].v);
  return c;
}
int main() {
  int a, b, c, d, e, x, y, z;
  scanf("%d", &n);
  N = (1 << (n + 1)) - 1;
  MAX = 0;
  for (a = 2; a <= N; a++) {
    scanf("%d", &s[a].v);
    s[a].mx = 0;
  }
  MAX = dfs(1, 0);
  y = recur(1, 0, 0);
  cout << y << endl;
  return 0;
}

```


### Prompt

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

Sasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are developing an algorithm for two bots playing a two-player game. The game is cooperative and turn based. In each turn, one of the players makes a move (it doesn’t matter which player, it's possible that players turns do not alternate).

Algorithm for bots that Sasha and Ira are developing works by keeping track of the state the game is in. Each time either bot makes a move, the state changes. And, since the game is very dynamic, it will never go back to the state it was already in at any point in the past.

Sasha and Ira are perfectionists and want their algorithm to have an optimal winning strategy. They have noticed that in the optimal winning strategy, both bots make exactly N moves each. But, in order to find the optimal strategy, their algorithm needs to analyze all possible states of the game (they haven’t learned about alpha-beta pruning yet) and pick the best sequence of moves.

They are worried about the efficiency of their algorithm and are wondering what is the total number of states of the game that need to be analyzed?

Input

The first and only line contains integer N.

  * 1 ≤ N ≤ 106

Output

Output should contain a single integer – number of possible states modulo 109 + 7.

Examples

Input

2

Output

19

Note

Start: Game is in state A.

  * Turn 1: Either bot can make a move (first bot is red and second bot is blue), so there are two possible states after the first turn – B and C.
  * Turn 2: In both states B and C, either bot can again make a turn, so the list of possible states is expanded to include D, E, F and G.
  * Turn 3: Red bot already did N=2 moves when in state D, so it cannot make any more moves there. It can make moves when in state E, F and G, so states I, K and M are added to the list. Similarly, blue bot cannot make a move when in state G, but can when in D, E and F, so states H, J and L are added.
  * Turn 4: Red bot already did N=2 moves when in states H, I and K, so it can only make moves when in J, L and M, so states P, R and S are added. Blue bot cannot make a move when in states J, L and M, but only when in H, I and K, so states N, O and Q are added.

Overall, there are 19 possible states of the game their algorithm needs to analyze.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
const long double PI = 2 * acos(0.0);
const long double eps = 1e-15;
const int infi = 1e9;
const long long Linfi = (long long)1e18;
const long long MOD = 1000000007;
const int CON = 5;
const int c2 = 37;
int n;
long long gt[2000005];
long long power(long long a, int p) {
  if (p == 0) return 1;
  if (p == 1) return a;
  long long ans = power(a, p / 2);
  ans = (ans * ans) % MOD;
  if (p % 2) ans = (ans * a) % MOD;
  return ans;
}
void solve() {
  gt[0] = 1;
  for (int i = 1; i <= 2000005 - 1; i++) gt[i] = (gt[i - 1] * i) % MOD;
  long long ans = (2 * gt[2 * n - 1]) % MOD;
  long long tmp = (gt[n] * gt[n - 1]) % MOD;
  tmp = power(tmp, MOD - 2);
  ans = ((ans * tmp) - 1 + MOD) % MOD;
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  n++;
  solve();
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

You are given a huge integer a consisting of n digits (n is between 1 and 3 ⋅ 10^5, inclusive). It may contain leading zeros.

You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by 2).

For example, if a = 032867235 you can get the following integers in a single operation:

  * 302867235 if you swap the first and the second digits;
  * 023867235 if you swap the second and the third digits;
  * 032876235 if you swap the fifth and the sixth digits;
  * 032862735 if you swap the sixth and the seventh digits;
  * 032867325 if you swap the seventh and the eighth digits.

Note, that you can't swap digits on positions 2 and 4 because the positions are not adjacent. Also, you can't swap digits on positions 3 and 4 because the digits have the same parity.

You can perform any number (possibly, zero) of such operations.

Find the minimum integer you can obtain.

Note that the resulting integer also may contain leading zeros.

Input

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

The only line of each test case contains the integer a, its length n is between 1 and 3 ⋅ 10^5, inclusive.

It is guaranteed that the sum of all values n does not exceed 3 ⋅ 10^5.

Output

For each test case print line — the minimum integer you can obtain.

Example

Input

3
0709
1337
246432

Output

0079
1337
234642

Note

In the first test case, you can perform the following sequence of operations (the pair of swapped digits is highlighted): 0 \underline{70} 9 → 0079.

In the second test case, the initial integer is optimal.

In the third test case you can perform the following sequence of operations: 246 \underline{43} 2 → 24 \underline{63}42 → 2 \underline{43} 642 → 234642.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    vector<long long> even;
    vector<long long> odd;
    long long n = 0;
    while (s[n] != NULL) {
      if ((s[n] - '0') % 2)
        odd.push_back(s[n] - '0');
      else
        even.push_back(s[n] - '0');
      n++;
    }
    long long i = 0;
    long long j = 0;
    vector<long long> v;
    while (i < even.size() and j < odd.size()) {
      if (even[i] >= odd[j]) {
        v.push_back(odd[j]);
        j++;
      } else {
        v.push_back(even[i]);
        i++;
      }
    }
    while (i < even.size()) {
      v.push_back(even[i]);
      i++;
    }
    while (j < odd.size()) {
      v.push_back(odd[j]);
      j++;
    }
    for (auto i : v) cout << i;
    cout << endl;
  }
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

You are given two positive integers a and b. There are two possible operations:

  1. multiply one of the numbers by some prime p;
  2. divide one of the numbers on its prime factor p.

What is the minimum number of operations required to obtain two integers having the same number of divisors? You are given several such pairs, you need to find the answer for each of them.

Input

The first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of pairs of integers for which you are to find the answer.

Each of the next t lines contain two integers a_i and b_i (1 ≤ a_i, b_i ≤ 10^6).

Output

Output t lines — the i-th of them should contain the answer for the pair a_i, b_i.

Example

Input

8
9 10
100 17
220 70
17 19
4 18
32 20
100 32
224 385

Output

1
3
1
0
1
0
1
1

Note

These are the numbers with equal number of divisors, which are optimal to obtain in the sample test case:

  * (27, 10), 4 divisors
  * (100, 1156), 9 divisors
  * (220, 140), 12 divisors
  * (17, 19), 2 divisors
  * (12, 18), 6 divisors
  * (50, 32), 6 divisors
  * (224, 1925), 12 divisors

Note that there can be several optimal pairs of numbers.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline bool isp(int x) {
  if (x <= 1) return 0;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return 0;
    }
  }
  return 1;
}
const int N = 1000000 + 5;
vector<vector<int>> a, b;
vector<int> cnt, aux, gen_primes;
vector<int> cntd;
inline void buildA(int i, int cur, int ant) {
  a.push_back(aux);
  for (int t = 1; t <= ant; t++) {
    if (cur * gen_primes[i] >= N) break;
    cur *= gen_primes[i];
    aux.push_back(t);
    buildA(i + 1, cur, t);
    aux.pop_back();
  }
}
inline void buildB(int cur, int ant) {
  b.push_back(aux);
  for (int t = 1; t <= ant; t++) {
    if (cur * (t + 1) > 1000) break;
    aux.push_back(t);
    buildB(cur * (t + 1), t);
    aux.pop_back();
  }
}
int ans[290][1005];
int best[290][290];
bool p[N];
vector<int> gr[N];
int rofl[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 1; i <= 1000; i++) {
    if (isp(i)) {
      gen_primes.push_back(i);
    }
  }
  buildA(0, 1, 1000);
  buildB(1, 1000);
  for (auto x : b) {
    int ans = 1;
    for (auto y : x) ans *= (y + 1);
    cntd.push_back(ans);
  }
  for (int i = 0; i < a.size(); i++) {
    for (int j = 1; j <= 1000; j++) ans[i][j] = 1e9;
    for (int j = 0; j < b.size(); j++) {
      int mx = max(a[i].size(), b[j].size()), sum = 0;
      for (int t = 0; t < mx; t++) {
        int add = 0;
        if (t < a[i].size()) add += a[i][t];
        if (t < b[j].size()) add -= b[j][t];
        sum += abs(add);
      }
      ans[i][cntd[j]] = min(ans[i][cntd[j]], sum);
    }
  }
  map<vector<int>, int> id;
  for (int i = 0; i < a.size(); i++) {
    id[a[i]] = i;
    for (int j = 0; j < a.size(); j++) {
      int sol = 1e9;
      for (int y = 1; y <= 1000; y++) {
        sol = min(sol, ans[i][y] + ans[j][y]);
      }
      best[i][j] = sol;
    }
  }
  for (int i = 2; i < N; i++) p[i] = 1;
  for (int i = 2; i < N; i++) {
    if (p[i]) {
      for (int j = i; j < N; j += i) {
        if (j > i) p[j] = 0;
        int aux = j, g = 0;
        while (aux % i == 0) {
          aux /= i;
          g++;
        }
        gr[j].push_back(g);
      }
    }
  }
  for (int i = 1; i < N; i++) {
    sort(gr[i].rbegin(), gr[i].rend());
    rofl[i] = id[gr[i]];
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    cout << best[rofl[a]][rofl[b]] << "\n";
  }
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.

Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Constraints

* 1 \leq X \leq 100
* 0 \leq N \leq 100
* 1 \leq p_i \leq 100
* p_1, \ldots, p_N are all distinct.
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

X N
p_1 ... p_N

Output

Print the answer.

Examples

Input

6 5
4 7 10 6 5

Output

8

Input

10 5
4 7 10 6 5

Output

9

Input

100 0

Output

100

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int x,n,p;
	cin >> x >> n;
	set< int > s;
	for (int i=0; i<n; i++) cin >> p, s.insert(p);
	int ans = 1e3, ansN = x-1;
	for (int i=x-100; i<=x+100; i++) {
		if (s.count(i) > 0) continue;
		int v = abs(x-i);
		if (v < ans) ans = v, ansN = i;
	}
	cout << ansN;
	return 0;
}

```


### Prompt

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

Vasya studies divisibility rules at school. Here are some of them:

  * Divisibility by 2. A number is divisible by 2 if and only if its last digit is divisible by 2 or in other words, is even.
  * Divisibility by 3. A number is divisible by 3 if and only if the sum of its digits is divisible by 3.
  * Divisibility by 4. A number is divisible by 4 if and only if its last two digits form a number that is divisible by 4.
  * Divisibility by 5. A number is divisible by 5 if and only if its last digit equals 5 or 0.
  * Divisibility by 6. A number is divisible by 6 if and only if it is divisible by 2 and 3 simultaneously (that is, if the last digit is even and the sum of all digits is divisible by 3).
  * Divisibility by 7. Vasya doesn't know such divisibility rule.
  * Divisibility by 8. A number is divisible by 8 if and only if its last three digits form a number that is divisible by 8.
  * Divisibility by 9. A number is divisible by 9 if and only if the sum of its digits is divisible by 9.
  * Divisibility by 10. A number is divisible by 10 if and only if its last digit is a zero.
  * Divisibility by 11. A number is divisible by 11 if and only if the sum of digits on its odd positions either equals to the sum of digits on the even positions, or they differ in a number that is divisible by 11.

Vasya got interested by the fact that some divisibility rules resemble each other. In fact, to check a number's divisibility by 2, 4, 5, 8 and 10 it is enough to check fulfiling some condition for one or several last digits. Vasya calls such rules the 2-type rules.

If checking divisibility means finding a sum of digits and checking whether the sum is divisible by the given number, then Vasya calls this rule the 3-type rule (because it works for numbers 3 and 9).

If we need to find the difference between the sum of digits on odd and even positions and check whether the difference is divisible by the given divisor, this rule is called the 11-type rule (it works for number 11).

In some cases we should divide the divisor into several factors and check whether rules of different types (2-type, 3-type or 11-type) work there. For example, for number 6 we check 2-type and 3-type rules, for number 66 we check all three types. Such mixed divisibility rules are called 6-type rules.

And finally, there are some numbers for which no rule works: neither 2-type, nor 3-type, nor 11-type, nor 6-type. The least such number is number 7, so we'll say that in such cases the mysterious 7-type rule works, the one that Vasya hasn't discovered yet.

Vasya's dream is finding divisibility rules for all possible numbers. He isn't going to stop on the decimal numbers only. As there are quite many numbers, ha can't do it all by himself. Vasya asked you to write a program that determines the divisibility rule type in the b-based notation for the given divisor d.

Input

The first input line contains two integers b and d (2 ≤ b, d ≤ 100) — the notation system base and the divisor. Both numbers are given in the decimal notation.

Output

On the first output line print the type of the rule in the b-based notation system, where the divisor is d: "2-type", "3-type", "11-type", "6-type" or "7-type". If there are several such types, print the one that goes earlier in the given sequence. If a number belongs to the 2-type, print on the second line the least number of the last b-based digits that we will need to use to check the divisibility.

Examples

Input

10 10

Output

2-type
1

Input

2 3

Output

11-type

Note

The divisibility rule for number 3 in binary notation looks as follows: "A number is divisible by 3 if and only if the sum of its digits that occupy the even places differs from the sum of digits that occupy the odd places, in a number that is divisible by 3". That's an 11-type rule. For example, 2110 = 101012. For it the sum of digits on odd positions equals 1 + 1 + 1 = 3, an on even positions — 0 + 0 = 0. The rule works and the number is divisible by 3.

In some notations a number can fit into the 3-type rule and the 11-type rule. In this case the correct answer is "3-type".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int SITO_MAX = 100000;
int f[SITO_MAX + 1];
vector<int> prosti;
struct sito {
  sito() {
    for (int i = 2; i <= SITO_MAX; i++) {
      if (f[i] == 0) {
        f[i] = i;
        prosti.push_back(i);
      }
      int j = 0;
      while (j < (int)prosti.size()) {
        if (prosti[j] > f[i]) {
          break;
        }
        int x = i * prosti[j];
        if (x > SITO_MAX) {
          break;
        }
        f[x] = prosti[j];
        j++;
      }
    }
  }
} sito_obj_983431;
vector<pair<int, int>> factor_small(int x) {
  vector<pair<int, int>> v;
  while (x > 1) {
    int p = f[x];
    int c = 0;
    while (x % p == 0) {
      x /= p;
      c++;
    }
    v.push_back({p, c});
  }
  return v;
}
vector<pair<int, int>> factor(int x) {
  vector<pair<int, int>> v;
  for (int p : prosti) {
    if (x % p == 0) {
      int c = 0;
      while (x % p == 0) {
        x /= p;
        c++;
      }
      v.push_back({p, c});
    }
  }
  if (x > 1) {
    v.push_back({x, 1});
  }
  return v;
}
bool is2(long long b, long long d) {
  long long p = 1;
  for (int i = 1; i <= 8; i++) {
    p *= b;
    if (p % d == 0) {
      return true;
    }
  }
  return false;
}
bool is3(long long b, long long d) { return (b - 1) % d == 0; }
bool is11(long long b, long long d) {
  return set<long long>{b % d, b * b % d} == set<long long>{1ll, d - 1};
}
bool is2311(long long b, long long d) {
  return is2(b, d) || is3(b, d) || is11(b, d);
}
long long pw(long long x, long long y) {
  long long p = 1;
  while (y--) p *= x;
  return p;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
  long long b, d;
  cin >> b >> d;
  {
    long long p = 1;
    for (int i = 1; i <= 8; i++) {
      p *= b;
      if (p % d == 0) {
        cout << "2-type\n" << i << '\n';
        return 0;
      }
    }
  }
  if (is3(b, d)) {
    cout << "3-type\n";
    return 0;
  }
  if (is11(b, d)) {
    cout << "11-type\n";
    return 0;
  }
  bool ok = 1;
  for (auto p : factor_small(d)) ok &= is2311(b, pw(p.first, p.second));
  if (ok) {
    cout << "6-type\n";
    return 0;
  }
  cout << "7-type\n";
}

```


### Prompt

Create a solution in CPP for the following problem:

You are given an image, that can be represented with a 2-d n by m grid of pixels. Each pixel of the image is either on or off, denoted by the characters "0" or "1", respectively. You would like to compress this image. You want to choose an integer k > 1 and split the image into k by k blocks. If n and m are not divisible by k, the image is padded with only zeros on the right and bottom so that they are divisible by k. Each pixel in each individual block must have the same value. The given image may not be compressible in its current state. Find the minimum number of pixels you need to toggle (after padding) in order for the image to be compressible for some k. More specifically, the steps are to first choose k, then the image is padded with zeros, then, we can toggle the pixels so it is compressible for this k. The image must be compressible in that state.

Input

The first line of input will contain two integers n, m (2 ≤ n, m ≤ 2 500), the dimensions of the image.

The next n lines of input will contain a binary string with exactly m characters, representing the image.

Output

Print a single integer, the minimum number of pixels needed to toggle to make the image compressible.

Example

Input

3 5
00100
10110
11001

Output

5

Note

We first choose k = 2.

The image is padded as follows:

    001000
    101100
    110010
    000000

We can toggle the image to look as follows:

    001100
    001100
    000000
    000000

We can see that this image is compressible for k = 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 5e2 + 5;
const int inf = 0x3f3f3f3f;
int mp[maxn][maxn];
char a[maxn];
int n, m;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", a + 1);
    for (int j = 1; j <= m; j++) {
      if (a[j] == '1') mp[i][j] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      mp[i][j] = mp[i - 1][j] + mp[i][j - 1] + mp[i][j] - mp[i - 1][j - 1];
    }
  }
  int ans = inf;
  int len = max(n, m);
  for (int k = 2; k <= len; k++) {
    int nn = n, mm = m;
    if (n % k != 0) nn = (n / k) * k + k;
    if (m % k != 0) mm = (m / k) * k + k;
    int tmp1 = 0;
    for (int i = 1; i <= nn / k; i++)
      for (int j = 1; j <= mm / k; j++) {
        int x1 = i * k > n ? n : i * k;
        int y1 = j * k > m ? m : j * k;
        int x2 = i * k - k + 1 > n ? n : i * k - k + 1;
        int y2 = j * k - k + 1 > m ? m : j * k - k + 1;
        int tmp =
            mp[x1][y1] + mp[x2 - 1][y2 - 1] - mp[x1][y2 - 1] - mp[x2 - 1][y1];
        if (tmp <= k * k / 2) {
          tmp1 += (tmp);
        } else {
          tmp1 += (k * k - tmp);
        }
      }
    ans = min(ans, tmp1);
  }
  printf("%d\n", ans);
}

```


### Prompt

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

You are given undirected weighted graph. Find the length of the shortest cycle which starts from the vertex 1 and passes throught all the edges at least once. Graph may contain multiply edges between a pair of vertices and loops (edges from the vertex to itself).

Input

The first line of the input contains two integers n and m (1 ≤ n ≤ 15, 0 ≤ m ≤ 2000), n is the amount of vertices, and m is the amount of edges. Following m lines contain edges as a triples x, y, w (1 ≤ x, y ≤ n, 1 ≤ w ≤ 10000), x, y are edge endpoints, and w is the edge length.

Output

Output minimal cycle length or -1 if it doesn't exists.

Examples

Input

3 3
1 2 1
2 3 1
3 1 1

Output

3

Input

3 2
1 2 3
2 3 4

Output

14

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> deg(16);
vector<vector<int>> dist(16, vector<int>(16, 1000000000));
vector<int> temp(16);
int timer = 1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int x, y, w;
  long long res = 0;
  for (int i = 1; i <= n; i += 1) {
    dist[i][i] = 0;
  }
  for (int i = 1; i <= m; i += 1) {
    cin >> x >> y >> w;
    res += w;
    deg[x] += 1;
    deg[y] += 1;
    dist[x][y] = dist[y][x] = min(dist[x][y], w);
  }
  for (int k = 1; k <= n; k += 1) {
    for (int i = 1; i <= n; i += 1) {
      for (int j = 1; j <= n; j += 1) {
        if (dist[i][k] + dist[k][j] < dist[i][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
    }
  }
  for (int i = 2; i <= n; i += 1) {
    if (deg[i] && dist[1][i] == 1000000000) {
      cout << -1;
      return 0;
    }
  }
  for (int i = 1; i <= n; i += 1) {
    if (deg[i] & 1) {
      temp[timer++] = i;
    }
  }
  timer -= 1;
  vector<int> dp((1 << timer), 1000000000);
  dp[0] = 0;
  for (int mask = 0; mask < (1 << timer); mask += 1) {
    for (int i = 1; i <= timer; i += 1) {
      for (int j = 1; j <= timer; j += 1) {
        if (i == j || ((1 << (i - 1)) | mask) == mask ||
            ((1 << (j - 1)) | mask) == mask) {
          continue;
        }
        dp[mask | (1 << (i - 1)) | (1 << (j - 1))] =
            min(dp[mask | (1 << (i - 1)) | (1 << (j - 1))],
                dp[mask] + dist[temp[i]][temp[j]]);
      }
    }
  }
  cout << res + dp[(1 << timer) - 1];
}

```


### Prompt

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

This is an interactive problem.

Homer likes arrays a lot and he wants to play a game with you.

Homer has hidden from you a permutation a_1, a_2, ..., a_n of integers 1 to n. You are asked to find any index k (1 ≤ k ≤ n) which is a local minimum.

For an array a_1, a_2, ..., a_n, an index i (1 ≤ i ≤ n) is said to be a local minimum if a_i < min\\{a_{i-1},a_{i+1}\}, where a_0 = a_{n+1} = +∞. An array is said to be a permutation of integers 1 to n, if it contains all integers from 1 to n exactly once.

Initially, you are only given the value of n without any other information about this permutation.

At each interactive step, you are allowed to choose any i (1 ≤ i ≤ n) and make a query with it. As a response, you will be given the value of a_i.

You are asked to find any index k which is a local minimum after at most 100 queries.

Interaction

You begin the interaction by reading an integer n (1≤ n ≤ 10^5) on a separate line.

To make a query on index i (1 ≤ i ≤ n), you should output "? i" in a separate line. Then read the value of a_i in a separate line. The number of the "?" queries is limited within 100.

When you find an index k (1 ≤ k ≤ n) which is a local minimum, output "! k" in a separate line and terminate your program.

In case your query format is invalid, or you have made more than 100 "?" queries, you will receive Wrong Answer verdict.

After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

  * fflush(stdout) or cout.flush() in C++;
  * System.out.flush() in Java;
  * flush(output) in Pascal;
  * stdout.flush() in Python;
  * see documentation for other languages.

Hack Format

The first line of the hack should contain a single integer n (1 ≤ n ≤ 10^5).

The second line should contain n distinct integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n).

Example

Input

5
3
2
1
4
5

Output

? 1
? 2
? 3
? 4
? 5
! 3

Note

In the example, the first line contains an integer 5 indicating that the length of the array is n = 5.

The example makes five "?" queries, after which we conclude that the array is a = [3,2,1,4,5] and k = 3 is local minimum.

### Response

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

using namespace std ;

# define f first

# define s second

# define ll long long

# define pb push_back

# define mp make_pair

# define INF INT_MAX

# define INFL 1e18+10

# define mod 1000000007

# define rep( i , s , e ) for( int i = s ; i <= e ; i++ )

# define repR( i , e , s ) for( int i = e ; i >= s ; i-- )

const int maxN = 100001 ;

int arr[maxN] ;

int query( int id ) {

    if ( arr[id] ) return arr[id] ;

    cout << "? " << id << endl ;

    int a ;  cin >> a ;  return arr[id] = a ;
}

void ans( int id ) { cout << "! " << id ;  exit(0) ; }

void solve() {

    int n ;  cin >> n ;

    if ( n == 1 ) ans(1) ;

    int a = query(1) , b = query(2) ;

    if ( a < b ) ans(1) ;

    int c = query( n - 1 ) , d = query(n) ;

    if ( d < c ) ans(n) ;

    int l = 2 , r = n - 1 ;

    while ( l < r ) {

        int mid = ( l + r ) / 2 ;

        a = query( mid - 1 ) , b = query( mid ) , c = query( mid + 1 ) ;

        if ( a > b ) {

            if ( c > b ) ans( mid ) ;

            l = mid ;
        }

        else r = mid ;
    }

    ans(l) ;
}

int main() {

    ios_base::sync_with_stdio( false ) ;

    cin.tie(0) , cout.tie(0) ;

    solve() ;  return 0 ;
}
```


### Prompt

Construct a Cpp code solution to the problem outlined:

Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.

In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" contains a typo). Besides, a couple of identical letters immediately followed by another couple of identical letters is a typo too (for example, words "helloo" and "wwaatt" contain typos).

Write a code that deletes the minimum number of letters from a word, correcting described typos in the word. You are allowed to delete letters from both ends and from the middle of the word.

Input

The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.

Output

Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters.

If there are multiple solutions, print any of them.

Examples

Input

helloo

Output

hello

Input

woooooow

Output

woow

Note

The second valid answer to the test from the statement is "heloo".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int INF = 1000000005;
const long long int MAX_N = 1e5 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  string s, t = "";
  cin >> s;
  vector<pair<int, int> > v;
  int n = s.length();
  for (int i = 0; i < n; ++i) {
    char c = s[i];
    int len = 0, start = i;
    while (c == s[i] && i < n) {
      len++;
      i++;
    }
    i--;
    if (len >= 3) v.push_back({start, i});
  }
  int j = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (j < v.size() && v[j].first == i) {
      t += s[v[j].first];
      t += s[v[j].second];
      i = v[j].second;
      j++;
    } else
      t += s[i];
  }
  vector<int> invalid;
  n = t.length();
  for (int i = 0; i < n; i++) {
    char c = t[i];
    int len = 0;
    while (c == t[i] && i < n) {
      len++;
      i++;
    }
    if (len == 2 && i < n) {
      char c1 = t[i];
      int len1 = 0;
      while (c1 == t[i] && i < n) {
        len1++;
        i++;
      }
      i--;
      if (len1 == 2) invalid.push_back(i);
    } else
      i--;
  }
  j = 0;
  for (int i = 0; i < t.length(); i++) {
    if (j < invalid.size() && i == invalid[j]) {
      j++;
      continue;
    }
    cout << t[i];
  }
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

Heiankyo is known as a town with a grid of roads.

Hokusai, a cat who lives in Heiankyo, has to go from his home to a secret place on the outskirts of town every day for patrol. However, I get tired of following the same path every day, and there is a risk of being followed, so Hokusai wants to use a different route every day as much as possible. On the other hand, Hokusai has a troublesome smell, so I don't want to go down the road away from my destination.

There are Actinidia polygama on the roads here and there in Heiankyo, and Hokusai cannot go through the road where Actinidia polygama is falling. This is because if you go through such a road, you will be sick. Fortunately, there are no Actinidia polygama at the intersection.

Hokusai wants to know the number of possible routes from his home to a secret place. Here, Hokusai's home is at (0, 0) and the secret place is at (gx, gy). The roads are laid out in a grid with x = i (i is an integer) and y = j (j is an integer).

Notes on Submission

Multiple datasets are given in the above format. The first line of input data gives the number of datasets. Create a program that outputs the output for each data set in order in the above format.

Input

The first line of input is given the coordinates of the secret location (gx, gy). All of these are integers between 1 and 15 and are given separated by a single space. The second line is given the number of sections where Actinidia polygama is falling p (0 ≤ p ≤ 100), and the following lines p are given one section for each line where Actinidia polygama is falling. The p sections are different from each other. One interval is expressed in the form of x1 y1 x2 y2 and is a line segment of length 1 parallel to the x-axis or y-axis, with (x1, y1) and (x2, y2) as endpoints. x1 and x2 are in the range [0, gx] and y1 and y2 are in the range [0, gy].

Output

Output the number of possible routes. If there is no possible route, output "Miserable Hokusai!" On one line.

Example

Input

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

Output

6
Miserable Hokusai!
5
155117520

### Response

```cpp
#include<iostream>
using namespace std;
#define MAX 20
#define rep(i, n) for ( int i = 0; i < n; i++ )

void compute(){
    int gy, gx, n, sx, sy, tx, ty;
    bool G[MAX+1][MAX+1][MAX+1][MAX+1];
    int T[MAX+1][MAX+1];
    rep(i,MAX+1) rep(j,MAX+1) rep(k,MAX+1) rep(m,MAX+1) G[i][j][k][m] = false;
    rep(i, MAX+1) rep(j, MAX+1) T[i][j] = 0;
    cin >> gx >> gy >> n;
    rep(i, n){
	cin >> sx >> sy >> tx >> ty;
	G[sy][sx][ty][tx] = true;
	G[ty][tx][sy][sx] = true;
    }
    T[0][0] = 1;
    rep(y, gy+1) rep(x, gx+1){
	if ( x < gx && !G[y][x][y][x+1]) T[y][x+1] += T[y][x];
	if ( y < gy && !G[y][x][y+1][x]) T[y+1][x] += T[y][x];
    }

    if ( T[gy][gx] == 0 ) cout << "Miserable Hokusai!" << endl;
    else cout << T[gy][gx] << endl;
}

int main(){
    int tcase; cin >> tcase;
    for ( int i = 0; i < tcase; i++ ) compute();
}
```


### Prompt

Generate a CPP solution to the following problem:

Write a program which reads a sequence A of n elements and an integer M, and outputs "yes" if you can make M by adding elements in A, otherwise "no". You can use an element only once.

You are given the sequence A and q questions where each question contains Mi.

Notes

You can solve this problem by a Burte Force approach. Suppose solve(p, t) is a function which checkes whether you can make t by selecting elements after p-th element (inclusive). Then you can recursively call the following functions:

solve(0, M)
solve(1, M-{sum created from elements before 1st element})
solve(2, M-{sum created from elements before 2nd element})
...

The recursive function has two choices: you selected p-th element and not. So, you can check solve(p+1, t-A[p]) and solve(p+1, t) in solve(p, t) to check the all combinations.

For example, the following figure shows that 8 can be made by A[0] + A[2].

<image>

Constraints

* n ≤ 20
* q ≤ 200
* 1 ≤ elements in A ≤ 2000
* 1 ≤ Mi ≤ 2000

Input

In the first line n is given. In the second line, n integers are given. In the third line q is given. Then, in the fourth line, q integers (Mi) are given.

Output

For each question Mi, print yes or no.

Example

Input

5
1 5 7 10 21
8
2 4 17 8 22 21 100 35

Output

no
no
yes
yes
yes
yes
no
no

### Response

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

int n, q, m, a[20];

bool solve(int i, int m){
    if(m == 0) return true;
    if(i == n) return false;

    bool res = solve(i + 1, m) || solve(i + 1, m - a[i]);
    return res;
}

int main(){

    cin >> n;
    for(int i=0; i<n; ++i) cin >> a[i];
    cin >> q;

    while(q--){
        cin >> m;
        cout << (solve(0, m) ? "yes" : "no") << endl;
    }
}

```


### Prompt

Generate a CPP solution to the following problem:

You are given a set S of strings consisting of `0` and `1`, and an integer K.

Find the longest string that is a subsequence of K or more different strings in S. If there are multiple strings that satisfy this condition, find the lexicographically smallest such string.

Here, S is given in the format below:

* The data directly given to you is an integer N, and N+1 strings X_0,X_1,...,X_N. For every i (0\leq i\leq N), the length of X_i is 2^i.
* For every pair of two integers (i,j) (0\leq i\leq N,0\leq j\leq 2^i-1), the j-th character of X_i is `1` if and only if the binary representation of j with i digits (possibly with leading zeros) belongs to S. Here, the first and last characters in X_i are called the 0-th and (2^i-1)-th characters, respectively.
* S does not contain a string with length N+1 or more.

Here, a string A is a subsequence of another string B when there exists a sequence of integers t_1 < ... < t_{|A|} such that, for every i (1\leq i\leq |A|), the i-th character of A and the t_i-th character of B is equal.

Constraints

* 0 \leq N \leq 20
* X_i(0\leq i\leq N) is a string of length 2^i consisting of `0` and `1`.
* 1 \leq K \leq |S|
* K is an integer.

Input

Input is given from Standard Input in the following format:

N K
X_0
:
X_N

Output

Print the lexicographically smallest string among the longest strings that are subsequences of K or more different strings in S.

Examples

Input

3 4
1
01
1011
01001110

Output

10

Input

4 6
1
01
1011
10111010
1101110011111101

Output

100

Input

2 5
0
11
1111

Output

### Response

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
string S[21];

int cnt[21][1<<21];
int R[21][2];

int ID(int L,int x) {
	return (1<<L) + x;
}

void solve() {
	int i,j,k,l,r,x,y; string s;

	cin>>N>>K;
	FOR(i,N+1) {
		cin>>S[i];
		FOR(x,1<<i) cnt[0][ID(i,x)]=S[i][x]=='1';
	}

	for(i=N;i>=0;i--) {
		FOR(x,1<<i) {
			R[i][0]=R[i][1]=i;
			for(j=i-1;j>=0;j--) {
				R[j][0]=R[j+1][0];
				R[j][1]=R[j+1][1];
				int prefix = x>>(i-1-j);
				R[j][prefix&1]=j;
			}

			FOR(j,i) {
				int prefix = x>>(i-j);
				cnt[j][ID(j,prefix)]+=cnt[j][ID(i,x)];
				if(R[j][0]<i) {
					int nex=(prefix<<(i-R[j][0])) | (x&((1<<(i-R[j][0]))-1));
					cnt[j+1][ID(j+i-R[j][0],nex)]+=cnt[j][ID(i,x)];
				}
				if(R[j][1]<i) {
					int nex=(prefix<<(i-R[j][1])) | (x&((1<<(i-R[j][1]))-1));
					cnt[j+1][ID(j+i-R[j][1],nex)]+=cnt[j][ID(i,x)];
				}
			}

			if(cnt[i][ID(i,x)]>=K) {
				FOR(j,i) cout<<((x>>(i-1-j))&1);
				cout<<endl;
				return;
			}
		}
	}

}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Fibonacci numbers have the following form:

F1 = 1,  F2 = 2,  Fi = Fi - 1 + Fi - 2, i > 2.

Let's consider some non-empty set S = {s1, s2, ..., sk}, consisting of different Fibonacci numbers. Let's find the sum of values of this set's elements:

<image>

Let's call the set S a number n's decomposition into Fibonacci sum.

It's easy to see that several numbers have several decompositions into Fibonacci sum. For example, for 13 we have 13, 5 + 8, 2 + 3 + 8 — three decompositions, and for 16: 3 + 13, 1 + 2 + 13, 3 + 5 + 8, 1 + 2 + 5 + 8 — four decompositions.

By the given number n determine the number of its possible different decompositions into Fibonacci sum.

Input

The first line contains an integer t — the number of tests (1 ≤ t ≤ 105). Each of the following t lines contains one test.

Each test is an integer n (1 ≤ n ≤ 1018).

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

Output

For each input data test print a single number on a single line — the answer to the problem.

Examples

Input

2
13
16

Output

3
4

Note

Two decompositions are different if there exists a number that is contained in the first decomposition, but is not contained in the second one. Decompositions that differ only in the order of summands are considered equal.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<long long> fib;
vector<int> v;
long long f[100][2];
int main() {
  fib.push_back(1);
  fib.push_back(1);
  while (true) {
    long long a = fib.back() + fib[fib.size() - 2];
    if (a > 1e18) break;
    fib.push_back(a);
  }
  int test;
  scanf("%d", &test);
  for (int cas = 1; cas <= test; ++cas) {
    long long n;
    scanf("%I64d", &n);
    v.clear();
    for (int i = fib.size() - 1; i > 0; --i)
      if (n >= fib[i]) {
        v.push_back(i);
        n -= fib[i];
      }
    v.push_back(0);
    reverse(v.begin(), v.end());
    f[0][1] = 1;
    f[0][0] = 0;
    int k = v.size() - 1;
    for (int i = 1; i <= k; ++i) {
      f[i][1] = f[i - 1][1] + f[i - 1][0];
      f[i][0] = (v[i] - v[i - 1] - 1) / 2 * f[i - 1][1] +
                (v[i] - v[i - 1]) / 2 * f[i - 1][0];
    }
    printf("%I64d\n", f[k][1] + f[k][0]);
  }
  return 0;
}

```


### Prompt

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

Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles.

Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle.

Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number.

Input

The single line contains two integers, a and b (1 ≤ a ≤ 1000; 2 ≤ b ≤ 1000).

Output

Print a single integer — the number of hours Vasily can light up the room for.

Examples

Input

4 2

Output

7

Input

6 3

Output

8

Note

Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int ans = a;
  while (a >= b) {
    int tmp = 0;
    if (a % b != 0) tmp = a % b;
    a /= b;
    ans += a;
    a += tmp;
  }
  cout << ans;
}

```


### Prompt

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

Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.

Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.

This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn't contain any leading zeroes.

Thus, "localization" will be spelt as "l10n", and "internationalization» will be spelt as "i18n".

You are suggested to automatize the process of changing the words with abbreviations. At that all too long words should be replaced by the abbreviation and the words that are not too long should not undergo any changes.

Input

The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.

Output

Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.

Examples

Input

4
word
localization
internationalization
pneumonoultramicroscopicsilicovolcanoconiosis

Output

word
l10n
i18n
p43s

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  cin >> n;
  string arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (i = 0; i < n; i++) {
    if (arr[i].length() <= 10) {
      cout << arr[i] << endl;
    } else
      cout << arr[i].at(0) << arr[i].length() - 2
           << arr[i].at(arr[i].length() - 1) << endl;
  }
}

```


### Prompt

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

A positive (strictly greater than zero) integer is called round if it is of the form d00...0. In other words, a positive integer is round if all its digits except the leftmost (most significant) are equal to zero. In particular, all numbers from 1 to 9 (inclusive) are round.

For example, the following numbers are round: 4000, 1, 9, 800, 90. The following numbers are not round: 110, 707, 222, 1001.

You are given a positive integer n (1 ≤ n ≤ 10^4). Represent the number n as a sum of round numbers using the minimum number of summands (addends). In other words, you need to represent the given number n as a sum of the least number of terms, each of which is a round number.

Input

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

Each test case is a line containing an integer n (1 ≤ n ≤ 10^4).

Output

Print t answers to the test cases. Each answer must begin with an integer k — the minimum number of summands. Next, k terms must follow, each of which is a round number, and their sum is n. The terms can be printed in any order. If there are several answers, print any of them.

Example

Input

5
5009
7
9876
10000
10

Output

2
5000 9
1
7
4
800 70 6 9000
1
10000
1
10

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void digits(int n) {
  vector<int> d1;
  int s = 0;
  int t = 1;
  while (n != 0) {
    t = t * 10;
    if (n % 10 != 0) {
      s++;
    }
    d1.push_back(n % 10);
    n = n / 10;
  }
  t = t / 10;
  cout << s << endl;
  for (int i = d1.size() - 1; i >= 0; i--) {
    if (i == 0 && d1.at(i) != 0) {
      cout << d1.at(i) << " ";
      t = t / 10;
      ;
      continue;
    }
    if (d1.at(i) == 0) {
      t = t / 10;
    } else {
      cout << d1.at(i) * t << " ";
      t = t / 10;
    }
  }
  cout << endl;
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t) {
    int n;
    cin >> n;
    digits(n);
    t--;
  }
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

There are some beautiful girls in Arpa’s land as mentioned before.

Once Arpa came up with an obvious problem:

Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that <image>, where <image> is bitwise xor operation (see notes for explanation).

<image>

Immediately, Mehrdad discovered a terrible solution that nobody trusted. Now Arpa needs your help to implement the solution to that problem.

Input

First line contains two integers n and x (1 ≤ n ≤ 105, 0 ≤ x ≤ 105) — the number of elements in the array and the integer x.

Second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the elements of the array.

Output

Print a single integer: the answer to the problem.

Examples

Input

2 3
1 2

Output

1

Input

6 1
5 1 2 3 4 1

Output

2

Note

In the first sample there is only one pair of i = 1 and j = 2. <image> so the answer is 1.

In the second sample the only two pairs are i = 3, j = 4 (since <image>) and i = 1, j = 5 (since <image>).

A bitwise xor takes two bit integers of equal length and performs the logical xor operation on each pair of corresponding bits. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1. You can read more about bitwise xor operation here: <https://en.wikipedia.org/wiki/Bitwise_operation#XOR>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, x, ar[100001], ans = 0;
int main() {
  cin >> n >> x;
  for (int i = 1; i <= n; i++) {
    int tem;
    cin >> tem;
    ar[tem]++;
  }
  for (int i = 1; i < 100001; i++) {
    int t = x ^ i;
    if (i == t)
      ans += ar[i] * (ar[i] - 1);
    else if (t < 100001)
      ans += ar[i] * ar[t];
  }
  cout << ans / 2 << endl;
  return 0;
}

```


### Prompt

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

There are N points in a two-dimensional plane. The initial coordinates of the i-th point are (x_i, y_i). Now, each point starts moving at a speed of 1 per second, in a direction parallel to the x- or y- axis. You are given a character d_i that represents the specific direction in which the i-th point moves, as follows:

* If d_i = `R`, the i-th point moves in the positive x direction;
* If d_i = `L`, the i-th point moves in the negative x direction;
* If d_i = `U`, the i-th point moves in the positive y direction;
* If d_i = `D`, the i-th point moves in the negative y direction.

You can stop all the points at some moment of your choice after they start moving (including the moment they start moving). Then, let x_{max} and x_{min} be the maximum and minimum among the x-coordinates of the N points, respectively. Similarly, let y_{max} and y_{min} be the maximum and minimum among the y-coordinates of the N points, respectively.

Find the minimum possible value of (x_{max} - x_{min}) \times (y_{max} - y_{min}) and print it.

Constraints

* 1 \leq N \leq 10^5
* -10^8 \leq x_i,\ y_i \leq 10^8
* x_i and y_i are integers.
* d_i is `R`, `L`, `U`, or `D`.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1 d_1
x_2 y_2 d_2
.
.
.
x_N y_N d_N

Output

Print the minimum possible value of (x_{max} - x_{min}) \times (y_{max} - y_{min}).

The output will be considered correct when its absolute or relative error from the judge's output is at most 10^{-9}.

Examples

Input

2
0 3 D
3 0 L

Output

0

Input

5
-7 -10 U
7 -6 U
-8 7 D
-3 3 D
0 -6 R

Output

97.5

Input

20
6 -10 R
-4 -9 U
9 6 D
-3 -2 R
0 7 D
4 5 D
10 -10 U
-1 -8 U
10 -6 D
8 -5 U
6 4 D
0 3 D
7 9 R
9 -4 R
3 10 D
1 9 U
1 -6 U
9 -8 R
6 7 D
7 -3 D

Output

273

### Response

```cpp
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

typedef unsigned long long ULL;
typedef long long ll;

int n;

struct node{
    double x,y;
    char dir[4];
}A[100050];

double cal(double x){
    double ml=1e10,mr=-1e10,mu=-1e10,md=1e10;
    FOR(i,1,n){
        pair<double,double>tmp;
        tmp.first=A[i].x,tmp.second=A[i].y;
        switch(A[i].dir[0]){
            case 'U':tmp.second+=x;break;
            case 'D':tmp.second-=x;break;
            case 'L':tmp.first-=x;break;
            case 'R':tmp.first+=x;break;
        }
        ml=min(ml,tmp.first);
        mr=max(mr,tmp.first);
        mu=max(mu,tmp.second);
        md=min(md,tmp.second);
    }
    //cout<<x<<" "<<(mr-ml)*(mu-md)<<endl;
    return (mr-ml)*(mu-md);
}

int main(){
    cin>>n;
    FOR(i,1,n){
        scanf("%lf%lf%s",&A[i].x,&A[i].y,A[i].dir);
    }
    double l=0,r=1e12,ans=1e18;
    FOR(k,0,300){
        double m1=(l+(r-l)/3),m2=(l+(r-l)*2/3);
        double tmp1=cal(m1),tmp2=cal(m2);
        if(tmp1>tmp2)l=m1;
        else r=m2;
        ans=min(ans,tmp1);
        ans=min(ans,tmp2);
    }
    printf("%.10f",ans);
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

This is the easy version of the problem. The difference is constraints on the number of wise men and the time limit. You can make hacks only if all versions of this task are solved.

n wise men live in a beautiful city. Some of them know each other.

For each of the n! possible permutations p_1, p_2, …, p_n of the wise men, let's generate a binary string of length n-1: for each 1 ≤ i < n set s_i=1 if p_i and p_{i+1} know each other, and s_i=0 otherwise.

For all possible 2^{n-1} binary strings, find the number of permutations that produce this binary string.

Input

The first line of input contains one integer n (2 ≤ n ≤ 14) — the number of wise men in the city.

The next n lines contain a binary string of length n each, such that the j-th character of the i-th string is equal to '1' if wise man i knows wise man j, and equals '0' otherwise.

It is guaranteed that if the i-th man knows the j-th man, then the j-th man knows i-th man and no man knows himself.

Output

Print 2^{n-1} space-separated integers. For each 0 ≤ x < 2^{n-1}:

  * Let's consider a string s of length n-1, such that s_i = ⌊ \frac{x}{2^{i-1}} ⌋ mod 2 for all 1 ≤ i ≤ n - 1.
  * The (x+1)-th number should be equal to the required answer for s.

Examples

Input

3
011
101
110

Output

0 0 0 6

Input

4
0101
1000
0001
1010

Output

2 2 6 2 2 6 2 2

Note

In the first test, each wise man knows each other, so every permutation will produce the string 11.

In the second test:

  * If p = \{1, 2, 3, 4\}, the produced string is 101, because wise men 1 and 2 know each other, 2 and 3 don't know each other, and 3 and 4 know each other;
  * If p = \{4, 1, 2, 3\}, the produced string is 110, because wise men 1 and 4 know each other, 1 and 2 know each other and 2, and 3 don't know each other;
  * If p = \{1, 3, 2, 4\}, the produced string is 000, because wise men 1 and 3 don't know each other, 3 and 2 don't know each other, and 2 and 4 don't know each other.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
mt19937 mt(736);
void solve(istream &cin = std::cin, ostream &cout = std::cout) {
  int n;
  cin >> n;
  vector<vector<bool>> gr(n, vector<bool>(n));
  for (auto &row : gr) {
    string str;
    cin >> str;
    for (int i = 0; i < str.size(); i++) row[i] = str[i] == '1';
  }
  vector<vector<vector<ll>>> dp(gr.size(), vector<vector<ll>>(1u << gr.size()));
  for (auto &row : dp)
    for (unsigned mask = 1; mask < row.size(); mask++)
      row[mask].resize(1u << (unsigned)(__builtin_popcount(mask) - 1));
  for (unsigned i = 0; i < gr.size(); i++) dp[i][1u << i][0] = 1;
  for (unsigned mask = 0; mask < dp.front().size(); mask++)
    for (int last = 0; last < n; last++)
      for (unsigned type = 0; type < dp[last][mask].size(); type++)
        for (size_t i = 0; i < gr.size(); i++)
          if (((1u << i) & mask) == 0)
            dp[i][mask | (1u << i)][(type << 1u) | (gr[last][i] ? 1u : 0u)] +=
                dp[last][mask][type];
  for (unsigned i = 0; i < (1u << (gr.size() - 1)); i++) {
    ll cnt = 0;
    for (int j = 0; j < gr.size(); j++) cnt += dp[j].back()[i];
    cout << cnt << ' ';
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed;
  solve();
  return 0;
}

```


### Prompt

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

In this problem we consider a very simplified model of Barcelona city.

Barcelona can be represented as a plane with streets of kind x = c and y = c for every integer c (that is, the rectangular grid). However, there is a detail which makes Barcelona different from Manhattan. There is an avenue called Avinguda Diagonal which can be represented as a the set of points (x, y) for which ax + by + c = 0.

One can walk along streets, including the avenue. You are given two integer points A and B somewhere in Barcelona. Find the minimal possible distance one needs to travel to get to B from A.

Input

The first line contains three integers a, b and c (-10^9≤ a, b, c≤ 10^9, at least one of a and b is not zero) representing the Diagonal Avenue.

The next line contains four integers x_1, y_1, x_2 and y_2 (-10^9≤ x_1, y_1, x_2, y_2≤ 10^9) denoting the points A = (x_1, y_1) and B = (x_2, y_2).

Output

Find the minimum possible travel distance between A and B. Your answer is considered correct if its absolute or relative error does not exceed 10^{-6}.

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

Examples

Input

1 1 -3
0 3 3 0

Output

4.2426406871

Input

3 1 -9
0 3 3 -1

Output

6.1622776602

Note

The first example is shown on the left picture while the second example us shown on the right picture below. The avenue is shown with blue, the origin is shown with the black dot.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
double a, b, c, ret, ans[4];
struct POINT {
  double x, y;
  void get() { scanf("%lf%lf", &x, &y); }
} A, B, C, D;
double dis(const POINT& AA, const POINT& BB) {
  return sqrt((AA.x - BB.x) * (AA.x - BB.x) + (AA.y - BB.y) * (AA.y - BB.y));
}
void deal() {
  ret = fabs(A.x - B.x) + fabs(A.y - B.y);
  C.y = A.y;
  C.x = -b / a * C.y - c / a;
  D.y = B.y;
  D.x = -b / a * D.y - c / a;
  ans[0] = dis(A, C) + dis(B, D) + dis(C, D);
  C.x = A.x;
  C.y = -a / b * C.x - c / b;
  D.x = B.x;
  D.y = -a / b * D.x - c / b;
  ans[1] = dis(A, C) + dis(B, D) + dis(C, D);
  C.x = A.x;
  C.y = -a / b * C.x - c / b;
  D.y = B.y;
  D.x = -b / a * D.y - c / a;
  ans[2] = dis(A, C) + dis(B, D) + dis(C, D);
  C.y = A.y;
  C.x = -b / a * C.y - c / a;
  D.x = B.x;
  D.y = -a / b * D.x - c / b;
  ans[3] = dis(A, C) + dis(B, D) + dis(C, D);
}
int main() {
  scanf("%lf%lf%lf", &a, &b, &c);
  A.get();
  B.get();
  deal();
  for (int i = 0; i < 4; ++i) ret = min(ret, ans[i]);
  printf("%.10lf\n", ret);
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

You are given two integers a and b. You may perform any number of operations on them (possibly zero).

During each operation you should choose any positive integer x and set a := a - x, b := b - 2x or a := a - 2x, b := b - x. Note that you may choose different values of x in different operations.

Is it possible to make a and b equal to 0 simultaneously?

Your program should answer t independent test cases.

Input

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

Then the test cases follow, each test case is represented by one line containing two integers a and b for this test case (0 ≤ a, b ≤ 10^9).

Output

For each test case print the answer to it — YES if it is possible to make a and b equal to 0 simultaneously, and NO otherwise.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).

Example

Input

3
6 9
1 1
1 2

Output

YES
NO
YES

Note

In the first test case of the example two operations can be used to make both a and b equal to zero:

  1. choose x = 4 and set a := a - x, b := b - 2x. Then a = 6 - 4 = 2, b = 9 - 8 = 1;
  2. choose x = 1 and set a := a - 2x, b := b - x. Then a = 2 - 2 = 0, b = 1 - 1 = 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 2;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int ko;
  cin >> ko;
  long long a, b;
  while (ko--) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    if ((2 * a) < b) {
      cout << "NO" << endl;
    } else if ((a + b) % 3 == 0) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Petya and Vasya are competing with each other in a new interesting game as they always do.

At the beginning of the game Petya has to come up with an array of N positive integers. Sum of all elements in his array should be equal to S. Then Petya has to select an integer K such that 0 ≤ K ≤ S.

In order to win, Vasya has to find a non-empty subarray in Petya's array such that the sum of all selected elements equals to either K or S - K. Otherwise Vasya loses.

You are given integers N and S. You should determine if Petya can win, considering Vasya plays optimally. If Petya can win, help him to do that.

Input

The first line contains two integers N and S (1 ≤ N ≤ S ≤ 10^{6}) — the required length of the array and the required sum of its elements.

Output

If Petya can win, print "YES" (without quotes) in the first line. Then print Petya's array in the second line. The array should contain N positive integers with sum equal to S. In the third line print K. If there are many correct answers, you can print any of them.

If Petya can't win, print "NO" (without quotes).

You can print each letter in any register (lowercase or uppercase).

Examples

Input

1 4

Output

YES
4
2

Input

3 4

Output

NO

Input

3 8

Output

YES
2 1 5
4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s;
  cin >> n >> s;
  int a[n + 1];
  int cnt = 0;
  for (int i = 1; i < n; ++i) {
    a[i] = 1;
    cnt++;
  }
  a[n] = s - cnt;
  s -= cnt;
  if (s - cnt < 2) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    for (int i = 1; i <= n; ++i) cout << a[i] << ' ';
    cout << endl;
    cout << (cnt + 1) << endl;
  }
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

There is an integer sequence A of length N whose values are unknown.

Given is an integer sequence B of length N-1 which is known to satisfy the following:

B_i \geq \max(A_i, A_{i+1})

Find the maximum possible sum of the elements of A.

Constraints

* All values in input are integers.
* 2 \leq N \leq 100
* 0 \leq B_i \leq 10^5

Input

Input is given from Standard Input in the following format:

N
B_1 B_2 ... B_{N-1}

Output

Print the maximum possible sum of the elements of A.

Examples

Input

3
2 5

Output

9

Input

2
3

Output

6

Input

6
0 153 10 10 23

Output

53

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;;
  cin>>n;
  vector<int> b(n);
  for(int i=0;i<n-1;i++){
    cin>>b[i];
  }
  b[n-1]=b[n-2];
  ans+=b[0];

  for(int i=0;i<n-1;i++){
    ans+=min(b[i],b[i+1]);

  }
 cout<<ans<<endl;
}
```


### Prompt

Create a solution in cpp for the following problem:

Let's solve the geometric problem

Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems.

Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in decimal is an infinite decimal number of 0.00011001100110011 ... in binary, but an error occurs when rounding this to a finite number of digits.

Positive integers p and q are given in decimal notation. Find the b-ary system (b is an integer greater than or equal to 2) so that the rational number p / q can be expressed as a decimal number with a finite number of digits. If there are more than one, output the smallest one.

Constraints

* 0 <p <q <10 ^ 9

Input Format

Input is given from standard input in the following format.

p q

Output Format

Print the answer in one line.

Sample Input 1

1 2

Sample Output 1

2

1/2 is binary 0.1

Sample Input 2

21 30

Sample Output 2

Ten

21/30 is 0.7 in decimal

Example

Input

1 2

Output

2

### Response

```cpp
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int calc(int x,int y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

int main(){

	int p,q,common,limit;
	scanf("%d %d",&p,&q);

	common = calc(p,q);

	p /= common;
	q /= common;

	limit = sqrt(q);

	int ans = 1;

	for(int i = 2; i <= limit; i++){
		if(q%i == 0){
			ans *= i;
			while(q % i == 0)q /= i;
		}
	}

	ans *= q;

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

	return 0;
}
```


### Prompt

Construct a cpp code solution to the problem outlined:

We will call a string that can be obtained by concatenating two equal strings an even string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not.

For a non-empty string S, we will define f(S) as the shortest even string that can be obtained by appending one or more characters to the end of S. For example, f(`abaaba`)=`abaababaab`. It can be shown that f(S) is uniquely determined for a non-empty string S.

You are given an even string S consisting of lowercase English letters. For each letter in the lowercase English alphabet, find the number of its occurrences from the l-th character through the r-th character of f^{10^{100}} (S).

Here, f^{10^{100}} (S) is the string f(f(f( ... f(S) ... ))) obtained by applying f to S 10^{100} times.

Constraints

* 2 \leq |S| \leq 2\times 10^5
* 1 \leq l \leq r \leq 10^{18}
* S is an even string consisting of lowercase English letters.
* l and r are integers.

Input

Input is given from Standard Input in the following format:

S
l r

Output

Print 26 integers in a line with spaces in between. The i-th integer should be the number of the occurrences of the i-th letter in the lowercase English alphabet from the l-th character through the r-th character of f^{10^{100}} (S).

Examples

Input

abaaba
6 10

Output

3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Input

xx
1 1000000000000000000

Output

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1000000000000000000 0 0

Input

vgxgpuamkvgxgvgxgpuamkvgxg
1 1000000000000000000

Output

87167725689669676 0 0 0 0 0 282080685775825810 0 0 0 87167725689669676 0 87167725689669676 0 0 87167725689669676 0 0 0 0 87167725689669676 141040342887912905 0 141040342887912905 0 0

### Response

```cpp
// luogu-judger-enable-o2
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define maxn 200010
using namespace std;
typedef long long ll;
char s[maxn];
ll L,R;
int n,T;
int fail[maxn];
void get_fail()
{
    fail[1]=0;
    for(int i=2;i<=n;i++)
    {
        int j=fail[i-1];
        while(j&&s[j+1]!=s[i])  j=fail[j];
        if(s[j+1]==s[i])  j++;
        fail[i]=j;
    }
    T=n-fail[n];
}
int sum[maxn][30];
ll calc(ll x,int c)
{
    if(x<=n)    return sum[x][c];
    if(x<=2*n)  return sum[n][c]+sum[x-n][c];
    ll f1=sum[n][c],f2=sum[n][c]+sum[T][c],l1=n,l2=n+T;
    while(x>l1+l2)
    {
        ll tmp=f2;
        f2+=f1;f1=tmp;
        tmp=l2;
        l2+=l1;l1=tmp;
    }
    return f2+calc(x-l2,c);
}
int main()
{
    scanf("%s",s+1);
    cin>>L>>R;
    n=strlen(s+1)/2;
    get_fail();
    for(int i=1;i<=n;i++)
    {
        memcpy(sum[i],sum[i-1],sizeof(sum[i-1]));
        sum[i][s[i]-'a']++;
    }
    for(int i=0;i<26;i++)  printf("%lld ",calc(R,i)-calc(L-1,i));
    puts("");
    return 0;
}
```


### Prompt

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

The R1 company wants to hold a web search championship. There were n computers given for the competition, each of them is connected to the Internet. The organizers believe that the data transfer speed directly affects the result. The higher the speed of the Internet is, the faster the participant will find the necessary information. Therefore, before the competition started, each computer had its maximum possible data transfer speed measured. On the i-th computer it was ai kilobits per second.

There will be k participants competing in the championship, each should get a separate computer. The organizing company does not want any of the participants to have an advantage over the others, so they want to provide the same data transfer speed to each participant's computer. Also, the organizers want to create the most comfortable conditions for the participants, so the data transfer speed on the participants' computers should be as large as possible.

The network settings of the R1 company has a special option that lets you to cut the initial maximum data transfer speed of any computer to any lower speed. How should the R1 company configure the network using the described option so that at least k of n computers had the same data transfer speed and the data transfer speed on these computers was as large as possible?

Input

The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 100) — the number of computers and the number of participants, respectively. In the second line you have a space-separated sequence consisting of n integers: a1, a2, ..., an (16 ≤ ai ≤ 32768); number ai denotes the maximum data transfer speed on the i-th computer.

Output

Print a single integer — the maximum Internet speed value. It is guaranteed that the answer to the problem is always an integer.

Examples

Input

3 2
40 20 30

Output

30

Input

6 4
100 20 40 20 50 50

Output

40

Note

In the first test case the organizers can cut the first computer's speed to 30 kilobits. Then two computers (the first and the third one) will have the same speed of 30 kilobits. They should be used as the participants' computers. This answer is optimal.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int INF = 10000000;
const long long int MAX_N = 1e6 + 2;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  sort((v).begin(), (v).end());
  cout << v[n - k];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) solve();
}

```


### Prompt

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

While Duff was resting in the beach, she accidentally found a strange array b0, b1, ..., bl - 1 consisting of l positive integers. This array was strange because it was extremely long, but there was another (maybe shorter) array, a0, ..., an - 1 that b can be build from a with formula: bi = ai mod n where a mod b denoted the remainder of dividing a by b.

<image>

Duff is so curious, she wants to know the number of subsequences of b like bi1, bi2, ..., bix (0 ≤ i1 < i2 < ... < ix < l), such that:

  * 1 ≤ x ≤ k
  * For each 1 ≤ j ≤ x - 1, <image>
  * For each 1 ≤ j ≤ x - 1, bij ≤ bij + 1. i.e this subsequence is non-decreasing.

Since this number can be very large, she want to know it modulo 109 + 7.

Duff is not a programmer, and Malek is unavailable at the moment. So she asked for your help. Please tell her this number.

Input

The first line of input contains three integers, n, l and k (1 ≤ n, k, n × k ≤ 106 and 1 ≤ l ≤ 1018).

The second line contains n space separated integers, a0, a1, ..., an - 1 (1 ≤ ai ≤ 109 for each 0 ≤ i ≤ n - 1).

Output

Print the answer modulo 1 000 000 007 in one line.

Examples

Input

3 5 3
5 9 1

Output

10

Input

5 10 3
1 2 3 4 5

Output

25

Note

In the first sample case, <image>. So all such sequences are: <image>, <image>, <image>, <image>, <image>, <image>, <image>, <image>, <image> and <image>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 6;
const int MAXD = 1e6 + 5;
const int mod = 1e9 + 7;
inline void add_mod(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int a[MAXN];
struct Node {
  int x, id;
} b[MAXN];
inline bool cmp(const Node &p, const Node &q) { return p.x < q.x; }
struct Number {
  int x, cnt, ecnt;
} c[MAXN];
vector<int> f[MAXD];
int main(void) {
  int n, d;
  long long l;
  cin >> n >> l >> d;
  int nn = l % n;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) b[i] = (Node){a[i], i};
  sort(b + 1, b + n + 1, cmp);
  int m = 0;
  for (int i = 1, j = 1; j <= n; i = j) {
    c[++m].x = b[i].x;
    while (j <= n && b[j].x == b[i].x) {
      if (b[j].id <= nn) ++c[m].ecnt;
      ++j;
    }
    c[m].cnt = j - i;
  }
  for (int i = 0; i <= d; ++i) f[i].resize(m + 5);
  for (int i = 1; i <= m; ++i) f[0][i] = 1;
  int ans = 0;
  for (int i = 1; i <= d; ++i) {
    for (int j = 1; j <= m; ++j)
      f[i][j] = (long long)f[i - 1][j] * c[j].cnt % mod;
    for (int j = 1; j <= m; ++j) add_mod(f[i][j], f[i][j - 1]);
    if (i - 1 > l / n) continue;
    add_mod(ans, (long long)(l / n - i + 1) % mod * f[i][m] % mod);
    for (int j = 1; j <= m; ++j)
      add_mod(ans, (long long)f[i - 1][j] * c[j].ecnt % mod);
  }
  printf("%d", ans);
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

There are N lines in the xy-plane. The i-th line is represented by A_ix+B_iy=C_i. Any two lines among the N+2 lines, the above N lines plus the x-axis and y-axis, cross each other at exactly one point.

For each pair 1 \leq i < j \leq N, there is a car at the cross point of the i-th and j-th lines. Even where three or more lines intersect at a point, a car is individually placed for each pair of lines. That is, there will be k(k-1)/2 cars placed at the intersection of k lines.

Those cars are already very old, and can only be moved parallel to the x-axis or y-axis.

Takahashi will hold an exhibition of antique cars at a place on the xy-plane. In order to avoid damaging the half-broken cars too much, he will select the place of the exhibition so that the total distance covered will be minimized when all the cars are moved to the place. If such a place is not uniquely determined, among the places that satisfy the condition above, the place with the minimum x-coordinate will be selected. If the place is still not uniquely determined, among the places that satisfy the two conditions above, the place with the minimum y-coordinate will be selected.

Find the place of the exhibition that will be selected.

Constraints

* 2 \leq N \leq 4 × 10^4
* 1 \leq |A_i|,|B_i| \leq 10^4(1 \leq i \leq N)
* 0 \leq |C_i| \leq 10^4(1 \leq i \leq N)
* No two given lines are parallel.
* All input values are integers.

Inputs

Input is given from Standard Input in the following format:

N
A_1 B_1 C_1
:
A_N B_N C_N

Outputs

Print the x-coordinate and y-coordinate of the place of the exhibition that will be selected, in this order, with a space in between. The output will be judged as correct when the absolute or relative error is at most 10^{-9}.

Examples

Input

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

Output

1.000000000000000 1.000000000000000

Input

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

Output

-1.000000000000000 -1.000000000000000

Input

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

Output

-1.722222222222222 1.325000000000000

### Response

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;
//https://beta.atcoder.jp/contests/tenka1-2017/tasks/tenka1_2017_e

namespace Problem {
using namespace std;
struct Line {
  double a, b, c;
};
struct FindX {
  double operator()(Line &l, double y) {
    return (l.c - l.b * y) / l.a;
    //return (b.b * a.c - a.b * b.c) / (b.b * a.a - a.b * b.a);
  }
};
struct FindY {
  double operator()(Line &l, double x) {
    return (l.c - l.a * x) / l.b;
    //return (-b.a * a.c + a.a * b.c) / (b.b * a.a - a.b * b.a);
  }
};
struct sortByMinX {
  bool operator()(Line &a, Line &b) { return -a.a / a.b > -b.a / b.b; }
};
struct sortByMinY {
  bool operator()(Line &a, Line &b) { return -a.b / a.a > -b.b / b.a; }
};
template <typename T>
struct BIT {
  vector<T> bit;
  int size;
  BIT(int _size) : bit(vector<T>(_size + 1, 0)), size(_size) {}
  void add(int index, T value) {
    for (int i = index + 1; i <= size; i += (i & -i)) bit[i] += value;
  }
  T sum(int a, int b) {  //sum of[a,b)
    return sum(b) - sum(a);
  }
  T sum(int a) {  // sum of[0,a) = sum of bit[0]~bit[a]
    T ret = 0;
    for (int i = a; i > 0; i -= (i & -i)) ret += bit[i];
    return ret;
  }
};
class Solver {
 public:
  int n;
  vector<Line> line;
  Solver(LL n) : n(n), line(n){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> line[i].a >> line[i].b >> line[i].c;
    }
    cout << binarySearch<FindY, sortByMinX>() << ' ' << binarySearch<FindX, sortByMinY>() << endl;
  }
  template <class Calc, class S>
  double binarySearch() {
    Calc op;
    sort(line.rbegin(), line.rend(), S());
    double lb = -1e9, ub = 1e9;
    for (int i = 0; i < 80; ++i) {
      double mid = (lb + ub) / 2;
      vector<pair<double, int>> coord;
      for (int j = 0; j < n; ++j) {
        coord.emplace_back(op(line[j], mid), j);
      }
      sort(coord.begin(), coord.end());
      BIT<int> bit(n);
      int cnt = 0;
      for (int j = 0; j < n; ++j) {
        cnt += bit.sum(coord[j].second);
        bit.add(coord[j].second, 1);
      }
      DBG(mid, coord, cnt)
      if (cnt >= (n * (n - 1) / 2 + 1) / 2) {
        ub = mid;
      } else {
        lb = mid;
      }
    }
    return ub;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}
```


### Prompt

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

While Grisha was celebrating New Year with Ded Moroz, Misha gifted Sasha a small rectangular pond of size n × m, divided into cells of size 1 × 1, inhabited by tiny evil fishes (no more than one fish per cell, otherwise they'll strife!).

The gift bundle also includes a square scoop of size r × r, designed for fishing. If the lower-left corner of the scoop-net is located at cell (x, y), all fishes inside the square (x, y)...(x + r - 1, y + r - 1) get caught. Note that the scoop-net should lie completely inside the pond when used.

Unfortunately, Sasha is not that skilled in fishing and hence throws the scoop randomly. In order to not frustrate Sasha, Misha decided to release k fishes into the empty pond in such a way that the expected value of the number of caught fishes is as high as possible. Help Misha! In other words, put k fishes in the pond into distinct cells in such a way that when the scoop-net is placed into a random position among (n - r + 1)·(m - r + 1) possible positions, the average number of caught fishes is as high as possible.

Input

The only line contains four integers n, m, r, k (1 ≤ n, m ≤ 105, 1 ≤ r ≤ min(n, m), 1 ≤ k ≤ min(n·m, 105)).

Output

Print a single number — the maximum possible expected number of caught fishes.

You answer is considered correct, is its absolute or relative error does not exceed 10 - 9. Namely, let your answer be a, and the jury's answer be b. Your answer is considered correct, if <image>.

Examples

Input

3 3 2 3

Output

2.0000000000

Input

12 17 9 40

Output

32.8333333333

Note

In the first example you can put the fishes in cells (2, 1), (2, 2), (2, 3). In this case, for any of four possible positions of the scoop-net (highlighted with light green), the number of fishes inside is equal to two, and so is the expected value.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
  x = 0;
  char c;
  int sign = 1;
  do {
    c = getchar();
    if (c == '-') sign = -1;
  } while (!isdigit(c));
  do {
    x = x * 10 + c - '0';
    c = getchar();
  } while (isdigit(c));
  x *= sign;
}
const int N = 100;
int n, m, r;
long long k;
long long f[100005], g[100005];
long long F[100005], G[100005];
priority_queue<pair<long long, pair<long long, long long> > > q;
map<long long, long long> mp[100005];
int main() {
  scanf("%d%d%d%I64d", &n, &m, &r, &k);
  long long m1 = 0, m2 = 0;
  for (int i = 1; i <= n; i++) {
    f[i] = min(min(r, n - r + 1), min(i, n - i + 1));
    F[f[i]]++;
    m1 = max(m1, f[i]);
  }
  for (int i = 1; i <= m; i++) {
    g[i] = min(min(m - r + 1, r), min(i, m - i + 1));
    G[g[i]]++;
    m2 = max(m2, g[i]);
  }
  double ans = 0;
  long long cnt = 0;
  q.push(make_pair(m1 * m2, make_pair(m1, m2)));
  while (cnt < k) {
    pair<long long, pair<long long, long long> > tmp = q.top();
    while (mp[tmp.second.first].count(tmp.second.second))
      q.pop(), tmp = q.top();
    q.pop();
    long long cc = F[tmp.second.first] * G[tmp.second.second];
    mp[tmp.second.first][tmp.second.second] = 1;
    if (cc >= k - cnt) cc = k - cnt;
    ans = ans + tmp.first * cc;
    cnt = cnt + cc;
    m1 = tmp.second.first, m2 = tmp.second.second;
    q.push(make_pair((m1 - 1) * m2, make_pair(m1 - 1, m2)));
    q.push(make_pair(m1 * (m2 - 1), make_pair(m1, m2 - 1)));
  }
  ans = ans / double(n - r + 1);
  ans = ans / double(m - r + 1);
  printf("%.12lf", ans);
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. Here, h_1 < h_2 < \cdots < h_N holds.

There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N:

* If the frog is currently on Stone i, jump to one of the following: Stone i + 1, i + 2, \ldots, N. Here, a cost of (h_j - h_i)^2 + C is incurred, where j is the stone to land on.

Find the minimum possible total cost incurred before the frog reaches Stone N.

Constraints

* All values in input are integers.
* 2 \leq N \leq 2 \times 10^5
* 1 \leq C \leq 10^{12}
* 1 \leq h_1 < h_2 < \cdots < h_N \leq 10^6

Input

Input is given from Standard Input in the following format:

N C
h_1 h_2 \ldots h_N

Output

Print the minimum possible total cost incurred.

Examples

Input

5 6
1 2 3 4 5

Output

20

Input

2 1000000000000
500000 1000000

Output

1250000000000

Input

8 5
1 3 4 5 10 11 12 13

Output

62

### Response

```cpp
#include <iostream>
#include <deque>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; long long c; cin >> n >> c;
    deque<pair<long long, long long> > hull;
    long long h, dp[n]; cin >> h;
    hull.push_back(make_pair(-2 * h, (dp[0] = 0) + h * h));
    for (int i = 1; i < n; i++) {
        cin >> h;
        while (hull.size() >= 2 && hull[0].first * h + hull[0].second >= hull[1].first * h + hull[1].second) hull.pop_front();
        dp[i] = hull[0].first * h + hull[0].second + h * h + c;
        hull.push_back(make_pair(-2 * h, dp[i] + h * h));
        while (hull.size() >= 3 && (hull[hull.size() - 2].second - hull[hull.size() - 3].second) * (hull[hull.size() - 2].first - hull[hull.size() - 1].first) >= (hull[hull.size() - 1].second - hull[hull.size() - 2].second) * (hull[hull.size() - 3].first - hull[hull.size() - 2].first)) {
            hull[hull.size() - 2] = hull[hull.size() - 1];
            hull.pop_back();
        }
    }
    cout << dp[n - 1];
    return 0;
}

```


### Prompt

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

Problem

If you bring an empty bottle of $ a $ milk, you can exchange it for a new bottle of $ b $ milk.
How many bottles of milk can Mr. Kawabayashi, who initially has a bottle of $ x $ milk, drink? Output the remainder after dividing by $ 1000000007 $.

Constraints

The input satisfies the following conditions.

* $ 1 \ leq a \ leq 10 ^ {15} $
* $ 0 \ leq b \ lt a $
* $ 0 \ leq x \ leq 10 ^ {15} $

Input

The input is given in the following format.

$ a $ $ b $ $ x $

Three integers $ a $, $ b $, $ x $ are given, separated by spaces.

Output

Print the answer on one line.

Examples

Input

3 1 5

Output

7

Input

3 2 5

Output

11

Input

82 69 64

Output

64

Input

316250877917604 316250877917599 681260158257385

Output

62687552

### Response

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

int main() {
    long long a,b,x;
    cin >> a >> b >> x;
    if (x < a) {
        cout << x % M << "\n";
    }
    else {
        cout << (((x - a) / (a - b) + 1) % M * (b % M) % M + x) % M << '\n';
    }
    return 0;
}

```


### Prompt

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

Let's define a function f(p) on a permutation p as follows. Let g_i be the [greatest common divisor (GCD)](https://en.wikipedia.org/wiki/Greatest_common_divisor) of elements p_1, p_2, ..., p_i (in other words, it is the GCD of the prefix of length i). Then f(p) is the number of distinct elements among g_1, g_2, ..., g_n.

Let f_{max}(n) be the maximum value of f(p) among all permutations p of integers 1, 2, ..., n.

Given an integers n, count the number of permutations p of integers 1, 2, ..., n, such that f(p) is equal to f_{max}(n). Since the answer may be large, print the remainder of its division by 1000 000 007 = 10^9 + 7.

Input

The only line contains the integer n (2 ≤ n ≤ 10^6) — the length of the permutations.

Output

The only line should contain your answer modulo 10^9+7.

Examples

Input

2

Output

1

Input

3

Output

4

Input

6

Output

120

Note

Consider the second example: these are the permutations of length 3:

  * [1,2,3], f(p)=1.
  * [1,3,2], f(p)=1.
  * [2,1,3], f(p)=2.
  * [2,3,1], f(p)=2.
  * [3,1,2], f(p)=2.
  * [3,2,1], f(p)=2.

The maximum value f_{max}(3) = 2, and there are 4 permutations p such that f(p)=2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int add(long long a, long long b) { return (a + b) % mod; }
int mul(long long a, long long b) { return (a * b) % mod; }
int n;
int dp[1000001][21][2];
int p2[30];
int pow2(int x) {
  if (p2[x] != 0) return p2[x];
  p2[x] = (1 << x);
  return p2[x];
}
int p3[2];
int pow3(int x) {
  if (p3[x] != 0) return p3[x];
  if (x == 0) return 1;
  p3[x] = pow3(x - 1) * 3;
  return p3[x];
}
int main(void) {
  cin >> n;
  int x = log2(n);
  dp[1][x][0] = 1;
  if ((1 << (x - 1)) * 3 <= n) dp[1][x - 1][1] = 1;
  for (int i = 1; i <= n - 1; i++) {
    for (int j = 0; j < 21; j++) {
      for (int k = 0; k < 2; k++) {
        if (dp[i][j][k] == 0) continue;
        int f = n / pow2(j) / pow3(k);
        dp[i + 1][j][k] = add(dp[i + 1][j][k], mul(dp[i][j][k], (f - i)));
        if (j > 0) {
          int ff = n / pow2(j - 1) / pow3(k);
          dp[i + 1][j - 1][k] =
              add(dp[i + 1][j - 1][k], mul(dp[i][j][k], (ff - f)));
        }
        if (k > 0) {
          int ff = n / pow2(j) / pow3(k - 1);
          dp[i + 1][j][k - 1] =
              add(dp[i + 1][j][k - 1], mul(dp[i][j][k], (ff - f)));
        }
      }
    }
  }
  cout << dp[n][0][0] << endl;
}

```


### Prompt

Generate a CPP solution to the following problem:

Dasha decided to have a rest after solving the problem. She had been ready to start her favourite activity — origami, but remembered the puzzle that she could not solve.

<image>

The tree is a non-oriented connected graph without cycles. In particular, there always are n - 1 edges in a tree with n vertices.

The puzzle is to position the vertices at the points of the Cartesian plane with integral coordinates, so that the segments between the vertices connected by edges are parallel to the coordinate axes. Also, the intersection of segments is allowed only at their ends. Distinct vertices should be placed at different points.

Help Dasha to find any suitable way to position the tree vertices on the plane.

It is guaranteed that if it is possible to position the tree vertices on the plane without violating the condition which is given above, then you can do it by using points with integral coordinates which don't exceed 1018 in absolute value.

Input

The first line contains single integer n (1 ≤ n ≤ 30) — the number of vertices in the tree.

Each of next n - 1 lines contains two integers ui, vi (1 ≤ ui, vi ≤ n) that mean that the i-th edge of the tree connects vertices ui and vi.

It is guaranteed that the described graph is a tree.

Output

If the puzzle doesn't have a solution then in the only line print "NO".

Otherwise, the first line should contain "YES". The next n lines should contain the pair of integers xi, yi (|xi|, |yi| ≤ 1018) — the coordinates of the point which corresponds to the i-th vertex of the tree.

If there are several solutions, print any of them.

Examples

Input

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

Output

YES
0 0
1 0
0 1
2 0
1 -1
-1 1
0 2

Input

6
1 2
2 3
2 4
2 5
2 6

Output

NO

Input

4
1 2
2 3
3 4

Output

YES
3 3
4 3
5 3
6 3

Note

In the first sample one of the possible positions of tree is: <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Node {
  long long x, y;
  Node() {}
  Node(long long a, long long b) {
    x = a;
    y = b;
  }
};
vector<int> eage[35];
int dir[4][2] = {-1, 0, 0, 1, 1, 0, 0, -1};
int deg[35];
int vis[35];
int n;
long long len = 1 << 30;
Node coor[35];
void dfs(int p, int d) {
  int di = 0;
  for (int i = 0; i < eage[p].size(); i++) {
    if (vis[eage[p][i]] == 0) {
      if (di == d) di = (di + 1) % 4;
      vis[eage[p][i]] = 1;
      coor[eage[p][i]].x = coor[p].x + dir[di][0] * len;
      coor[eage[p][i]].y = coor[p].y + dir[di][1] * len;
      len = len / 2;
      dfs(eage[p][i], (di + 2) % 4);
      di = (di + 1) % 4;
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    eage[a].push_back(b);
    eage[b].push_back(a);
    deg[a]++;
    deg[b]++;
  }
  for (int i = 1; i <= n; i++)
    if (deg[i] > 4) {
      printf("NO\n");
      return 0;
    }
  vis[1] = 1;
  dfs(1, -10);
  printf("YES\n");
  for (int i = 1; i <= n; i++) printf("%I64d %I64d\n", coor[i].x, coor[i].y);
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Koto Municipal Subway

Koto Municipal Subway

Koto City is a famous city whose roads are in a grid pattern, as shown in the figure below. The roads extending from north to south and the roads extending from east to west are lined up at intervals of 1 km each. Let Koto station at the southwestern intersection of Koto city be (0, 0), and mark x km east and y km north from it as (x, y) (0 ≤ x, y). ).

<image>

In anticipation of an increase in tourists due to the Olympic Games to be held five years later, the city has decided to build a new subway line starting from Koto station. Currently, we are planning to lay a rail to Shin-Koto station, which will be newly constructed as the next station after Koto station. The rail will be laid straight from Koto station to Shin-Koto station. Therefore, when the location of Shin-Koto station is (x, y), the length of the rail is √ (x2 + y2). The cost of laying the rail is the same as the length of the laid rail. Even if the rail length is a decimal number such as 1.5km, the cost is also 1.5.

The location (x, y) of Shin-Koto station has not been decided yet, and we plan to make it a location that meets the following conditions.

* It is an intersection. That is, x and y are integers, respectively.
* The shortest distance walked along the road from Koto station is exactly D. That is, x + y = D is satisfied.

Among the above two conditions, select the location of Shin-Koto station so that the difference between the rail budget E and the rail cost set by the city | √ (x2 + y2) --E | is minimized. Here, | A | represents the absolute value of A. Your job is to create a program that outputs the difference between the cost and budget for laying rails when the Shin-Koto station was constructed as described above.

Input

The input consists of multiple data sets, and the number of data sets contained in one input is 100 or less. The format of each data set is as follows.

> D E

D (1 ≤ D ≤ 100) is an integer that represents the shortest distance when walking along the road from Koto station to Shin-Koto station. E (1 ≤ E ≤ 100) is an integer representing the budget for rail construction.

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

Output

For each data set, output the difference between the cost and budget when laying the rail so as to satisfy the problem condition in one line. The answer must have an absolute error greater than 10-3. Note that if you do not output a line break at the end of each line, or if you output unnecessary characters, it will be judged as an incorrect answer.

Sample Input

twenty one
7 5
7 6
7 7
76 5
8 41
0 0

Output for Sample Input

0.4142135624
0
0.0827625303
0
48.7401153702
33

Hint

In the first data set, as shown in the figure below, an intersection 2 km along the road from Koto station is a candidate for a place to build Shin-Koto station.

<image>

When Shin-Koto station is constructed at each intersection, the difference between the cost for laying the rail and budget 1 is as follows.

* (2, 0): | √ (22 + 02) --1 | = 1.0
* (1, 1): | √ (12 + 12) --1 | = 0.4142135623 ...
* (0, 2): | √ (02 + 22) --1 | = 1.0

Therefore, the difference between the cost and the budget is minimized when the construction is done in (1, 1).

Example

Input

2 1
7 5
7 6
7 7
76 5
8 41
0 0

Output

0.4142135624
0
0.0827625303
0
48.7401153702
33

### Response

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

int main() {
  while (true) {
    int D, E;
    cin >> D >> E;

    if (D == 0) {
      break;
    }

    double minerr = abs(D - E);
    for (int x = 0; x <= D / 2; x++) {
      int y = D - x;
      double err = abs(sqrt(x * x + y * y) - E);

      if (err < minerr) {
	minerr = err;
      }
    }

    cout << minerr << endl;
  }

  return 0;
}
```


### Prompt

Generate a CPP solution to the following problem:

Lee is used to finish his stories in a stylish way, this time he barely failed it, but Ice Bear came and helped him. Lee is so grateful for it, so he decided to show Ice Bear his new game called "Critic"...

The game is a one versus one game. It has t rounds, each round has two integers s_i and e_i (which are determined and are known before the game begins, s_i and e_i may differ from round to round). The integer s_i is written on the board at the beginning of the corresponding round.

The players will take turns. Each player will erase the number on the board (let's say it was a) and will choose to write either 2 ⋅ a or a + 1 instead. Whoever writes a number strictly greater than e_i loses that round and the other one wins that round.

Now Lee wants to play "Critic" against Ice Bear, for each round he has chosen the round's s_i and e_i in advance. Lee will start the first round, the loser of each round will start the next round.

The winner of the last round is the winner of the game, and the loser of the last round is the loser of the game.

Determine if Lee can be the winner independent of Ice Bear's moves or not. Also, determine if Lee can be the loser independent of Ice Bear's moves or not.

Input

The first line contains the integer t (1 ≤ t ≤ 10^5) — the number of rounds the game has.

Then t lines follow, each contains two integers s_i and e_i (1 ≤ s_i ≤ e_i ≤ 10^{18}) — the i-th round's information.

The rounds are played in the same order as given in input, s_i and e_i for all rounds are known to everyone before the game starts.

Output

Print two integers.

The first one should be 1 if Lee can be the winner independent of Ice Bear's moves, and 0 otherwise.

The second one should be 1 if Lee can be the loser independent of Ice Bear's moves, and 0 otherwise.

Examples

Input

3
5 8
1 4
3 10

Output

1 1

Input

4
1 2
2 3
3 4
4 5

Output

0 0

Input

1
1 1

Output

0 1

Input

2
1 9
4 5

Output

0 0

Input

2
1 2
2 8

Output

1 0

Input

6
216986951114298167 235031205335543871
148302405431848579 455670351549314242
506251128322958430 575521452907339082
1 768614336404564650
189336074809158272 622104412002885672
588320087414024192 662540324268197150

Output

1 0

Note

Remember, whoever writes an integer greater than e_i loses.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long s[100100], e[100100];
int T;
bool f(long long a, long long b, bool c) {
  if (!c) {
    if (a > b / 2) {
      return true;
    } else {
      b = b / 2;
    }
  }
  while (true) {
    if (b % 2) {
      return (1 - a) % 2;
    } else {
      if (a > b / 2) {
        return a % 2;
      } else {
        b = b / 2;
        if (a > b / 2) {
          return true;
        }
        b = b / 2;
      }
    }
  }
}
bool solve(bool goal) {
  for (int i = T - 1; i >= 0; i--) {
    goal = !f(s[i], e[i], goal);
  }
  return !goal;
}
int main() {
  cin >> T;
  for (int i = 0; i < T; i++) {
    cin >> s[i] >> e[i];
  }
  cout << solve(true) << " " << solve(false) << endl;
}

```