### Prompt

Generate a cpp solution to the following problem:

You've got table a, consisting of n rows, numbered from 1 to n. The i-th line of table a contains ci cells, at that for all i (1 < i ≤ n) holds ci ≤ ci - 1.

Let's denote s as the total number of cells of table a, that is, <image>. We know that each cell of the table contains a single integer from 1 to s, at that all written integers are distinct.

Let's assume that the cells of the i-th row of table a are numbered from 1 to ci, then let's denote the number written in the j-th cell of the i-th row as ai, j. Your task is to perform several swap operations to rearrange the numbers in the table so as to fulfill the following conditions:

  1. for all i, j (1 < i ≤ n; 1 ≤ j ≤ ci) holds ai, j > ai - 1, j;
  2. for all i, j (1 ≤ i ≤ n; 1 < j ≤ ci) holds ai, j > ai, j - 1.

In one swap operation you are allowed to choose two different cells of the table and swap the recorded there numbers, that is the number that was recorded in the first of the selected cells before the swap, is written in the second cell after it. Similarly, the number that was recorded in the second of the selected cells, is written in the first cell after the swap.

Rearrange the numbers in the required manner. Note that you are allowed to perform any number of operations, but not more than s. You do not have to minimize the number of operations.

Input

The first line contains a single integer n (1 ≤ n ≤ 50) that shows the number of rows in the table. The second line contains n space-separated integers ci (1 ≤ ci ≤ 50; ci ≤ ci - 1) — the numbers of cells on the corresponding rows.

Next n lines contain table а. The i-th of them contains ci space-separated integers: the j-th integer in this line represents ai, j.

It is guaranteed that all the given numbers ai, j are positive and do not exceed s. It is guaranteed that all ai, j are distinct.

Output

In the first line print a single integer m (0 ≤ m ≤ s), representing the number of performed swaps.

In the next m lines print the description of these swap operations. In the i-th line print four space-separated integers xi, yi, pi, qi (1 ≤ xi, pi ≤ n; 1 ≤ yi ≤ cxi; 1 ≤ qi ≤ cpi). The printed numbers denote swapping the contents of cells axi, yi and api, qi. Note that a swap operation can change the contents of distinct table cells. Print the swaps in the order, in which they should be executed.

Examples

Input

3
3 2 1
4 3 5
6 1
2

Output

2
1 1 2 2
2 1 3 1

Input

1
4
4 3 2 1

Output

2
1 1 1 4
1 2 1 3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<long, long> > vp;
  pair<long, long> p;
  vector<long> vl;
  long n, i, j, a, b = 0, m[52][52] = {}, c, d, ob[2500][4] = {}, l = 0;
  cin >> n;
  vl.push_back(0);
  for (i = 0; i < n; i++) {
    cin >> a;
    vl.push_back(a);
    b += a;
  }
  p.first = 0;
  p.second = 0;
  vp.assign(b + 1, p);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= vl[i]; j++) {
      cin >> a;
      m[i][j] = a;
      vp[a].first = i;
      vp[a].second = j;
    }
  c = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= vl[i]; j++) {
      c++;
      a = vp[c].first;
      b = vp[c].second;
      d = m[i][j];
      if ((i != a) || (b != j)) {
        l++;
        vp[d].first = a;
        vp[d].second = b;
        m[a][b] = m[i][j];
        m[i][j] = c;
        vp[c].first = i;
        vp[c].second = j;
        ob[l - 1][0] = a;
        ob[l - 1][1] = b;
        ob[l - 1][2] = i;
        ob[l - 1][3] = j;
      }
    }
  cout << l << endl;
  for (i = 0; i < l; i++)
    cout << ob[i][0] << " " << ob[i][1] << " " << ob[i][2] << " " << ob[i][3]
         << endl;
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below.

Alice goes first and then they take alternating turns. In the i-th turn, the player whose turn it is selects a prime number smaller than the current number, and announces the smallest multiple of this prime number that is not smaller than the current number.

Formally, he or she selects a prime p < Xi - 1 and then finds the minimum Xi ≥ Xi - 1 such that p divides Xi. Note that if the selected prime p already divides Xi - 1, then the number does not change.

Eve has witnessed the state of the game after two turns. Given X2, help her determine what is the smallest possible starting number X0. Note that the players don't necessarily play optimally. You should consider all possible game evolutions.

Input

The input contains a single integer X2 (4 ≤ X2 ≤ 106). It is guaranteed that the integer X2 is composite, that is, is not prime.

Output

Output a single integer — the minimum possible X0.

Examples

Input

14

Output

6

Input

20

Output

15

Input

8192

Output

8191

Note

In the first test, the smallest possible starting number is X0 = 6. One possible course of the game is as follows:

  * Alice picks prime 5 and announces X1 = 10
  * Bob picks prime 7 and announces X2 = 14.

In the second case, let X0 = 15.

  * Alice picks prime 2 and announces X1 = 16
  * Bob picks prime 5 and announces X2 = 20.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long int inf64 = 1e18 + 5;
const int MAX = 1e6 + 5;
bool prime[MAX];
int smf[MAX];
void sieve() {
  memset(prime, true, sizeof(prime));
  prime[0] = prime[1] = false;
  for (int i = 2; i < MAX; i++) {
    if (prime[i]) {
      smf[i] = i;
      for (int j = 2 * i; j < MAX; j += i) {
        if (prime[j]) smf[j] = i;
        prime[j] = false;
      }
    }
  }
}
vector<int> fac(int x) {
  vector<int> v;
  while (x > 1) {
    int y = smf[x];
    v.push_back(y);
    while (x % y == 0) x /= y;
  }
  return v;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  sieve();
  int n, i;
  cin >> n;
  vector<int> v = fac(n);
  if (prime[n])
    cout << n << '\n';
  else {
    int st = n - *max_element(v.begin(), v.end()) + 1;
    int ans = n;
    for (i = st; i < n; i++) {
      v = fac(i);
      if (v.size() == 1)
        ans = min(ans, (i == v[0] ? i : i - v[0] + 1));
      else {
        int res = i - *max_element(v.begin(), v.end()) + 1;
        ans = min(ans, res);
      }
    }
    cout << ans << '\n';
  }
}

```


### Prompt

Please create a solution in CPP to the following problem:

Being stuck at home, Ray became extremely bored. To pass time, he asks Lord Omkar to use his time bending power: Infinity Clock! However, Lord Omkar will only listen to mortals who can solve the following problem:

You are given an array a of n integers. You are also given an integer k. Lord Omkar wants you to do k operations with this array.

Define one operation as the following:

  1. Set d to be the maximum value of your array.
  2. For every i from 1 to n, replace a_{i} with d-a_{i}.

The goal is to predict the contents in the array after k operations. Please help Ray determine what the final sequence will look like!

Input

Each test contains multiple test cases. The first line contains the number of cases t (1 ≤ t ≤ 100). Description of the test cases follows.

The first line of each test case contains two integers n and k (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ k ≤ 10^{18}) – the length of your array and the number of operations to perform.

The second line of each test case contains n integers a_{1},a_{2},...,a_{n} (-10^9 ≤ a_{i} ≤ 10^9) – the initial contents of your array.

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

Output

For each case, print the final version of array a after k operations described above.

Example

Input

3
2 1
-199 192
5 19
5 -1 4 2 0
1 2
69

Output

391 0
0 6 1 3 5
0

Note

In the first test case the array changes as follows:

  * Initially, the array is [-199, 192]. d = 192.

  * After the operation, the array becomes [d-(-199), d-192] = [391, 0].

### Response

```cpp
#include <bits/stdc++.h>
long long k;
int _, n, a[200020];
int main() {
  for (scanf("%d", &_); _--;) {
    scanf("%d%lld", &n, &k);
    for (int i = 0; i < n; i++) scanf("%d", a + i);
    for (int i = 0; i < (k & 1) + 2; i++)
      for (int i = 0, d = *std::max_element(a, a + n); i < n; i++)
        a[i] = d - a[i];
    for (int i = 0 * puts(""); i < n; i++) printf("%d ", a[i]);
  }
}

```


### Prompt

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

Takahashi has A cookies, and Aoki has B cookies. Takahashi will do the following action K times:

* If Takahashi has one or more cookies, eat one of his cookies.
* Otherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.
* If they both have no cookies, do nothing.

In the end, how many cookies will Takahashi and Aoki have, respectively?

Constraints

* 0 \leq A \leq 10^{12}
* 0 \leq B \leq 10^{12}
* 0 \leq K \leq 10^{12}
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B K

Output

Print the numbers of Takahashi's and Aoki's cookies after K actions.

Examples

Input

2 3 3

Output

0 2

Input

500000000000 500000000000 1000000000000

Output

0 0

### Response

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

int main(){
    long long int a,b,k;
    cin>>a>>b>>k;
    long long int x=min(a,k);
    a-=x;
    k-=x;
    b-=min(b,k);
    cout<<a<<" "<<b<<endl;

}
```


### Prompt

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

There is a forest that we model as a plane and live n rare animals. Animal number i has its lair in the point (x_{i}, y_{i}). In order to protect them, a decision to build a nature reserve has been made.

The reserve must have a form of a circle containing all lairs. There is also a straight river flowing through the forest. All animals drink from this river, therefore it must have at least one common point with the reserve. On the other hand, ships constantly sail along the river, so the reserve must not have more than one common point with the river.

For convenience, scientists have made a transformation of coordinates so that the river is defined by y = 0. Check whether it is possible to build a reserve, and if possible, find the minimum possible radius of such a reserve.

Input

The first line contains one integer n (1 ≤ n ≤ 10^5) — the number of animals.

Each of the next n lines contains two integers x_{i}, y_{i} (-10^7 ≤ x_{i}, y_{i} ≤ 10^7) — the coordinates of the i-th animal's lair. It is guaranteed that y_{i} ≠ 0. No two lairs coincide.

Output

If the reserve cannot be built, print -1. Otherwise print the minimum radius. Your answer will be accepted if absolute or relative error does not exceed 10^{-6}.

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

Examples

Input

1
0 1

Output

0.5

Input

3
0 1
0 2
0 -3

Output

-1

Input

2
0 1
1 1

Output

0.625

Note

In the first sample it is optimal to build the reserve with the radius equal to 0.5 and the center in (0,\ 0.5).

In the second sample it is impossible to build a reserve.

In the third sample it is optimal to build the reserve with the radius equal to 5/8 and the center in (1/2,\ 5/8).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) { return uniform_int_distribution<int>(0, x - 1)(rng); }
const int maxn = 1e6 + 7;
const long double inf = 1e9;
const long long md = 1e9 + 7;
long long gcd(long long x, long long y) {
  if (x < y) return gcd(y, x);
  if (y == 0) return x;
  return gcd(y, x % y);
}
long double x[maxn];
long double y[maxn];
long double f[maxn];
long double g[maxn];
int n;
long double calc(long double X) {
  long double r = 0.0;
  for (int i = 1; i <= n; i++) {
    long double rc = y[i] * y[i] + (X - x[i]) * (X - x[i]);
    rc /= y[i] + y[i];
    r = max(r, rc);
  }
  return r;
}
int main() {
  {
    ios ::sync_with_stdio(false);
    cin.tie(0);
  };
  cin >> n;
  int pos = 0, neg = 0;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    if (y[i] > 0) pos++;
    if (y[i] < 0) neg++;
  }
  if (neg > 0 && pos > 0) {
    cout << -1 << "\n";
    return 0;
  }
  if (neg > 0) {
    for (int i = 1; i <= n; i++) y[i] = -y[i];
  }
  long double l = -inf, r = inf;
  for (int j = 1; j <= 200; j++) {
    long double m1 = (l + l + r) / 3, m2 = (l + r + r) / 3;
    long double r1 = calc(m1), r2 = calc(m2);
    if (r1 < r2) {
      r = m2;
    } else {
      l = m1;
    }
  }
  cout << fixed << setprecision(12) << calc(l) << "\n";
}

```


### Prompt

Develop a solution in cpp to the problem described below:

You are given an array a_1, a_2, ..., a_n, consisting of n positive integers.

Initially you are standing at index 1 and have a score equal to a_1. You can perform two kinds of moves:

  1. move right — go from your current index x to x+1 and add a_{x+1} to your score. This move can only be performed if x<n.
  2. move left — go from your current index x to x-1 and add a_{x-1} to your score. This move can only be performed if x>1. Also, you can't perform two or more moves to the left in a row.

You want to perform exactly k moves. Also, there should be no more than z moves to the left among them.

What is the maximum score you can achieve?

Input

The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.

The first line of each testcase contains three integers n, k and z (2 ≤ n ≤ 10^5, 1 ≤ k ≤ n - 1, 0 ≤ z ≤ min(5, k)) — the number of elements in the array, the total number of moves you should perform and the maximum number of moves to the left you can perform.

The second line of each testcase contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^4) — the given array.

The sum of n over all testcases does not exceed 3 ⋅ 10^5.

Output

Print t integers — for each testcase output the maximum score you can achieve if you make exactly k moves in total, no more than z of them are to the left and there are no two or more moves to the left in a row.

Example

Input

4
5 4 0
1 5 4 3 2
5 4 1
1 5 4 3 2
5 4 4
10 20 30 40 50
10 7 3
4 6 8 2 9 9 7 4 10 9

Output

15
19
150
56

Note

In the first testcase you are not allowed to move left at all. So you make four moves to the right and obtain the score a_1 + a_2 + a_3 + a_4 + a_5.

In the second example you can move one time to the left. So we can follow these moves: right, right, left, right. The score will be a_1 + a_2 + a_3 + a_2 + a_3.

In the third example you can move four times to the left but it's not optimal anyway, you can just move four times to the right and obtain the score a_1 + a_2 + a_3 + a_4 + a_5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int min(long long int a, long long int b) { return a < b ? a : b; }
long long int min(long long int a, long long int b, long long int c) {
  a = min(a, b);
  a = min(a, c);
  return a;
}
long long int max(long long int a, long long int b) { return a > b ? a : b; }
long long int max(long long int a, long long int b, long long int c) {
  a = max(a, b);
  a = max(a, c);
  return a;
}
long long int dsum(long long int n) {
  long long int ans = 0;
  while (n) {
    ans += (n % 10);
    n /= 10;
  }
  return ans;
}
long long int power(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
long long int power(long long int a, long long int b, long long int m) {
  if (b == 0) return 1;
  if (b == 1) return a % m;
  long long int res = 1;
  a = a % m;
  while (b) {
    if (b & 1) {
      res = (res * a) % m;
    }
    a = ((a % m) * (a % m)) % m;
    b >>= 1;
  }
  return res;
}
long long int Ceil(long long int a, long long int b) {
  long long int res = a / b;
  if (a % b != 0) res++;
  return res;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &t : v) is >> t;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (const T &t : v) {
    os << t << " ";
  }
  os << '\n';
  return os;
}
long long int dxx[] = {1, 1, 0, -1, -1, -1, 0, 1};
long long int dyy[] = {0, 1, 1, 1, 0, -1, -1, -1};
long long int dx[] = {1, 0, -1, 0};
long long int dy[] = {0, 1, 0, -1};
struct pll {
  long long int x, y;
};
bool comp(pll a, pll b) {
  if (a.x == b.x)
    return a.y < b.y;
  else
    return a.x < b.x;
}
void solve(long long int the) {
  char ch;
  long double aa, bb, cc, dd, xx;
  string s1, s2, s3, s4, str;
  long long int i, j, k, a, b, c, d, l, m, n, r, x, y, z, low, high, mid,
      sum = 0, ans = 0, temp, t;
  cin >> n >> k >> z;
  vector<long long int> v(n);
  cin >> v;
  long long int P[n];
  P[0] = v[0];
  P[1] = v[0] + v[1];
  for (i = 2; i < n; i++) {
    P[i] = max(P[i - 1], v[i] + v[i - 1]);
  }
  long long int pre = v[0];
  ans = 0;
  for (i = 1; i < k + 1; i++) {
    pre += v[i];
    a = k - i;
    sum = pre;
    long long int left = (a + 1) / 2;
    if (left <= z) {
      if (a & 1) {
        sum += (left * P[i]);
        sum -= v[i];
      } else {
        sum += (left * P[i]);
      }
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
int main() {
  long long int t = 1, c = 1;
  scanf("%lld", &t);
  while (t--) {
    solve(c);
    c++;
  }
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

Takahashi is playing with N cards.

The i-th card has an integer X_i on it.

Takahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions:

* The integers on the two cards are the same.
* The sum of the integers on the two cards is a multiple of M.

Find the maximum number of pairs that can be created.

Note that a card cannot be used in more than one pair.

Constraints

* 2≦N≦10^5
* 1≦M≦10^5
* 1≦X_i≦10^5

Input

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

N M
X_1 X_2 ... X_N

Output

Print the maximum number of pairs that can be created.

Examples

Input

7 5
3 1 4 1 5 9 2

Output

3

Input

15 10
1 5 6 10 11 11 11 20 21 25 25 26 99 99 99

Output

6

### Response

```cpp
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

/*
 貪欲
 ①決定問題 必ず解に含まれる(含むように変換できる)ものから決めていく みんプロ本選B
 ②最適化問題 任意の解から評価を落とさず解に含められるようなものから決めていく 区間スケジューリングとか
 ③
 */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vector<ll> x(n);
	REP(i,n) cin>>x[i];
	if(m==1) {
		cout<<n/2<<endl;
		return 0;
	}
	vector<vector<ll>> s(m);
	REP(i,n) {
		s[x[i]%m].pb(x[i]);
	}
	ll ret=0;
	ret+=(ll)s[0].size()/2;
	for(ll i=1; m-i>=i; i++) {
		if(m-i==i) {
			ret+=(ll)s[i].size()/2;
			continue;
		}
		ll sml=i,bg=m-i;
		if((ll)s[sml].size()>(ll)s[bg].size()) swap(sml,bg);
		sort(ALL(s[bg]));
		ll cnt=0,buf=0;
		FOR(j,1,(ll)s[bg].size()) {
			if(s[bg][j]==s[bg][j-1]) {
				if(buf==0) buf=2;
				else buf++;
			}
			else {
				cnt+=buf/2;
				buf=0;
			}
		}
		cnt+=buf/2;
		ret+=(ll)s[sml].size();
		ret+=min(((ll)s[bg].size()-(ll)s[sml].size())/2,cnt);
	}
	cout<<ret<<endl;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set of sand cells to be island if it is possible to get from each of them to each of them by moving only through sand cells and by moving from a cell only to a side-adjacent cell. The cells are called to be side-adjacent if they share a vertical or horizontal side. It is easy to see that islands do not share cells (otherwise they together form a bigger island).

Find a way to cover some cells with sand so that exactly k islands appear on the n × n map, or determine that no such way exists.

Input

The single line contains two positive integers n, k (1 ≤ n ≤ 100, 0 ≤ k ≤ n2) — the size of the map and the number of islands you should form.

Output

If the answer doesn't exist, print "NO" (without the quotes) in a single line.

Otherwise, print "YES" in the first line. In the next n lines print the description of the map. Each of the lines of the description must consist only of characters 'S' and 'L', where 'S' is a cell that is occupied by the sea and 'L' is the cell covered with sand. The length of each line of the description must equal n.

If there are multiple answers, you may print any of them.

You should not maximize the sizes of islands.

Examples

Input

5 2

Output

YES
SSSSS
LLLLL
SSSSS
LLLLL
SSSSS

Input

5 25

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, k;
char a[110][110];
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) a[i][j] = 'S';
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (k <= 0) break;
      if (a[i - 1][j] != 'L' && a[i + 1][j] != 'L' && a[i][j - 1] != 'L' &&
          a[i][j + 1] != 'L') {
        a[i][j] = 'L';
        k--;
      }
    }
  if (k > 0)
    cout << "NO";
  else {
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) cout << a[i][j];
      cout << endl;
    }
  }
  return 0;
}

```


### Prompt

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

There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N).

For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.

We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:

* For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.

Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Constraints

* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

If a good set of choices does not exist, print `-1`.

If a good set of choices exists, print one such set of choices in the following format:

M
b_1 b_2 ... b_M

where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order.

Examples

Input

3
1 0 0

Output

1
1

Input

5
0 0 0 0 0

Output

0

### Response

```cpp
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(1 + N);
	for (int i = 1; i <= N; ++i) {
		cin >> A[i];
	}
	int cnt = 0;
	for (int i = N; i >= 1; --i) {
		for (int j = i * 2; j <= N; j += i) {
			A[i] ^= A[j];
		}
		cnt += A[i];
	}
	cout << cnt << endl;
	for (int i = 1; i <= N; ++i) {
		if (A[i] == 1) {
			cout << i << ((--cnt) == 0 ? '\n' : ' ');
		}
	}
	return 0;
}
```


### Prompt

Create a solution in Cpp for the following problem:

Genos needs your help. He was asked to solve the following programming problem by Saitama:

The length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as <image>, where si is the i-th character of s and ti is the i-th character of t. For example, the Hamming distance between string "0011" and string "0110" is |0 - 0| + |0 - 1| + |1 - 1| + |1 - 0| = 0 + 1 + 0 + 1 = 2.

Given two binary strings a and b, find the sum of the Hamming distances between a and all contiguous substrings of b of length |a|.

Input

The first line of the input contains binary string a (1 ≤ |a| ≤ 200 000).

The second line of the input contains binary string b (|a| ≤ |b| ≤ 200 000).

Both strings are guaranteed to consist of characters '0' and '1' only.

Output

Print a single integer — the sum of Hamming distances between a and all contiguous substrings of b of length |a|.

Examples

Input

01
00111

Output

3

Input

0011
0110

Output

2

Note

For the first sample case, there are four contiguous substrings of b of length |a|: "00", "01", "11", and "11". The distance between "01" and "00" is |0 - 0| + |1 - 0| = 1. The distance between "01" and "01" is |0 - 0| + |1 - 1| = 0. The distance between "01" and "11" is |0 - 1| + |1 - 1| = 1. Last distance counts twice, as there are two occurrences of string "11". The sum of these edit distances is 1 + 0 + 1 + 1 = 3.

The second sample case is described in the statement.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int F[200005][2];
int main() {
  string a, b;
  cin >> a >> b;
  for (int i = 1; i <= b.size(); i++) {
    for (int j = 0; j < 2; j++) {
      F[i][j] = F[i - 1][j];
    }
    ++F[i][b[i - 1] - '0'];
  }
  long long int res = 0;
  for (int i = 0; i < a.size(); i++) {
    int c = a[i] - '0';
    for (int j = 0; j < 2; j++) {
      res += abs(c - j) * (F[b.size() - a.size() + i + 1][j] - F[i][j]);
    }
  }
  cout << res << endl;
  return 0;
}

```


### Prompt

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

Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive).

There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them.

Since this sum can be enormous, print the value modulo (10^9+7).

Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1, ..., A_N.

Constraints

* 2 \leq N \leq 10^5
* 1 \leq K \leq 10^5
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the sum of \gcd(A_1, ..., A_N) over all K^N sequences, modulo (10^9+7).

Examples

Input

3 2

Output

9

Input

3 200

Output

10813692

Input

100000 100000

Output

742202979

### Response

```cpp
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

ll modpow(ll a,ll n){
  a%=MOD;
  ll res=1;
  while(n){
    if(n&1) res=res*a%MOD;
    a=a*a%MOD;
    n>>=1;
  }
  return res;
}

int main(){
  ll n,k;
  cin>>n>>k;
  ll cnt[100005];
  for(ll gcd=1;gcd<=k;gcd++){
    ll d=k/gcd;
    cnt[gcd]=modpow(d,n);
  }
  for(ll gcd=k;gcd>=1;gcd--){
    for(int i=2*gcd;i<=k;i+=gcd){
      cnt[gcd]=(cnt[gcd]-cnt[i]+MOD)%MOD;
    }
  }
  ll ans=0;
  for(ll gcd=1;gcd<=k;gcd++){
    ans=(ans+(gcd*cnt[gcd])%MOD)%MOD;
  }
  cout<<ans<<endl;
  return 0;
}

```


### Prompt

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

It turns out that you are a great fan of rock band AC/PE. Peter learned that and started the following game: he plays the first song of the list of n songs of the group, and you have to find out the name of the song. After you tell the song name, Peter immediately plays the following song in order, and so on.

The i-th song of AC/PE has its recognizability pi. This means that if the song has not yet been recognized by you, you listen to it for exactly one more second and with probability of pi percent you recognize it and tell it's name. Otherwise you continue listening it. Note that you can only try to guess it only when it is integer number of seconds after the moment the song starts playing.

In all AC/PE songs the first words of chorus are the same as the title, so when you've heard the first ti seconds of i-th song and its chorus starts, you immediately guess its name for sure.

For example, in the song Highway To Red the chorus sounds pretty late, but the song has high recognizability. In the song Back In Blue, on the other hand, the words from the title sound close to the beginning of the song, but it's hard to name it before hearing those words. You can name both of these songs during a few more first seconds.

Determine the expected number songs of you will recognize if the game lasts for exactly T seconds (i. e. you can make the last guess on the second T, after that the game stops).

If all songs are recognized faster than in T seconds, the game stops after the last song is recognized.

Input

The first line of the input contains numbers n and T (1 ≤ n ≤ 5000, 1 ≤ T ≤ 5000), separated by a space. Next n lines contain pairs of numbers pi and ti (0 ≤ pi ≤ 100, 1 ≤ ti ≤ T). The songs are given in the same order as in Petya's list.

Output

Output a single number — the expected number of the number of songs you will recognize in T seconds. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

Examples

Input

2 2
50 2
10 1

Output

1.500000000

Input

2 2
0 2
100 2

Output

1.000000000

Input

3 3
50 3
50 2
25 2

Output

1.687500000

Input

2 2
0 2
0 2

Output

1.000000000

### Response

```cpp
#include <bits/stdc++.h>
double f[5000 + 5][5000 + 5];
int p[5000 + 5], t[5000 + 5];
double ksm(double x, int y) {
  double ans = 1.0;
  for (int i = 0; i < y; i++) {
    ans *= x;
  }
  return ans;
}
int main() {
  int n, T;
  scanf("%d%d", &n, &T);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &p[i], &t[i]);
  }
  double ans = 0.0, pp;
  double r_1, r_2, now;
  f[0][0] = 1;
  for (int i = 0; i < n; i++) {
    pp = p[i] / 100.0;
    now = 0.0;
    r_2 = ksm(1 - pp, t[i] - 1);
    r_1 = r_2 * pp;
    for (int j = 0; j < T; j++) {
      now *= (1 - pp);
      now += f[i][j] * pp;
      if (j + 1 >= t[i]) {
        now -= f[i][j + 1 - t[i]] * r_1;
        f[i + 1][j + 1] += now + f[i][j + 1 - t[i]] * r_2;
      } else {
        f[i + 1][j + 1] += now;
      }
    }
    for (int j = 0; j <= T; j++) {
      ans += f[i + 1][j];
    }
  }
  printf("%.9lf\n", ans);
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Emergency Evacuation

The Japanese government plans to increase the number of inbound tourists to forty million in the year 2020, and sixty million in 2030. Not only increasing touristic appeal but also developing tourism infrastructure further is indispensable to accomplish such numbers.

One possible enhancement on transport is providing cars extremely long and/or wide, carrying many passengers at a time. Too large a car, however, may require too long to evacuate all passengers in an emergency. You are requested to help estimating the time required.

The car is assumed to have the following seat arrangement.

* A center aisle goes straight through the car, directly connecting to the emergency exit door at the rear center of the car.
* The rows of the same number of passenger seats are on both sides of the aisle.

A rough estimation requested is based on a simple step-wise model. All passengers are initially on a distinct seat, and they can make one of the following moves in each step.

* Passengers on a seat can move to an adjacent seat toward the aisle. Passengers on a seat adjacent to the aisle can move sideways directly to the aisle.
* Passengers on the aisle can move backward by one row of seats. If the passenger is in front of the emergency exit, that is, by the rear-most seat rows, he/she can get off the car.

The seat or the aisle position to move to must be empty; either no other passenger is there before the step, or the passenger there empties the seat by moving to another position in the same step. When two or more passengers satisfy the condition for the same position, only one of them can move, keeping the others wait in their original positions.

The leftmost figure of Figure C.1 depicts the seat arrangement of a small car given in Sample Input 1. The car have five rows of seats, two seats each on both sides of the aisle, totaling twenty. The initial positions of seven passengers on board are also shown.

The two other figures of Figure C.1 show possible positions of passengers after the first and the second steps. Passenger movements are indicated by fat arrows. Note that, two of the passengers in the front seat had to wait for a vacancy in the first step, and one in the second row had to wait in the next step.

Your task is to write a program that gives the smallest possible number of steps for all the passengers to get off the car, given the seat arrangement and passengers' initial positions.

<image>
Figure C.1

Input

The input consists of a single test case of the following format.

$r$ $s$ $p$
$i_1$ $j_1$
...
$i_p$ $j_p$

Here, $r$ is the number of passenger seat rows, $s$ is the number of seats on each side of the aisle, and $p$ is the number of passengers. They are integers satisfying $1 \leq r \leq 500$, $1 \leq s \leq 500$, and $1 \leq p \leq 2rs$.

The following $p$ lines give initial seat positions of the passengers. The $k$-th line with $i_k$ and $j_k$ means that the $k$-th passenger's seat is in the $i_k$-th seat row and it is the $j_k$-th seat on that row. Here, rows and seats are counted from front to rear and left to right, both starting from one. They satisfy $1 \leq i_k \leq r$ and $1 \leq j_k \leq 2s$. Passengers are on distinct seats, that is, $i_k \ne= i_l$ or $j_k \ne j_l$ holds if $k \ne l$.

Output

The output should be one line containing a single integer, the minimum number of steps required for all the passengers to get off the car.

Sample Input 1

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

Sample Output 1

9

Sample Input 2

500 500 16
1 1
1 2
1 999
1 1000
2 1
2 2
2 999
2 1000
3 1
3 2
3 999
3 1000
499 500
499 501
499 999
499 1000

Sample Output 2

1008

Example

Input

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

Output

9

### Response

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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> a(1000000);
    while (K--) {
        int i, j;
        scanf("%d%d", &i, &j);
        i--; j--;
        if (j >= M) j++;
        a[N - i + abs(j - M)]++;
    }
    int ans = 0;
    rep(d, 1000000) {
        if (a[d]) {
            ans = d;
            a[d + 1] += a[d] - 1;
        }
    }
    cout << ans << endl;
}

```


### Prompt

Create a solution in cpp for the following problem:

In Walrusland public transport tickets are characterized by two integers: by the number of the series and by the number of the ticket in the series. Let the series number be represented by a and the ticket number — by b, then a ticket is described by the ordered pair of numbers (a, b).

The walruses believe that a ticket is lucky if a * b = rev(a) * rev(b). The function rev(x) reverses a number written in the decimal system, at that the leading zeroes disappear. For example, rev(12343) = 34321, rev(1200) = 21.

The Public Transport Management Committee wants to release x series, each containing y tickets, so that at least w lucky tickets were released and the total number of released tickets (x * y) were minimum. The series are numbered from 1 to x inclusive. The tickets in each series are numbered from 1 to y inclusive. The Transport Committee cannot release more than maxx series and more than maxy tickets in one series.

Input

The first line contains three integers maxx, maxy, w (1 ≤ maxx, maxy ≤ 105, 1 ≤ w ≤ 107).

Output

Print on a single line two space-separated numbers, the x and the y. If there are several possible variants, print any of them. If such x and y do not exist, print a single number  - 1.

Examples

Input

2 2 1

Output

1 1

Input

132 10 35

Output

7 5

Input

5 18 1000

Output

-1

Input

48 132 235

Output

22 111

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> hash1, hash2;
int gcd(int x, int y) {
  if (x == 0) return y;
  return gcd(y % x, x);
}
int rev(int x) {
  int sum = 0;
  while (x) {
    sum *= 10;
    sum += x % 10;
    x /= 10;
  }
  return sum;
}
int main() {
  int x, y, w;
  cin >> x >> y >> w;
  for (int i = 1; i <= x; ++i) {
    int re = rev(i);
    int t = gcd(i, re);
    ++hash1[make_pair(i / t, re / t)];
  }
  int j = 0;
  long long bestx = x, besty = y, e = 0;
  long long sum = 0;
  for (; x;) {
    while (j < y && sum < w) {
      int l = rev(++j), jj;
      jj = gcd(j, l);
      pair<int, int> tmp = make_pair(l / jj, j / jj);
      sum += hash1[tmp];
      ++hash2[tmp];
    }
    if (sum >= w) {
      if (besty * bestx >= (long long)j * x) {
        bestx = x;
        besty = j;
        e = 1;
      }
    }
    int re = rev(x);
    int st = gcd(re, x);
    pair<int, int> tmp = make_pair(x / st, re / st);
    sum -= hash2[tmp];
    --hash1[tmp];
    --x;
  }
  if (e)
    cout << bestx << ' ' << besty << endl;
  else
    puts("-1");
  return 0;
}

```


### Prompt

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

Everybody knows that lucky numbers are positive integers that contain only lucky digits 4 and 7 in their decimal representation. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Polo the Penguin have two positive integers l and r (l < r), both of them are lucky numbers. Moreover, their lengths (that is, the number of digits in the decimal representation without the leading zeroes) are equal to each other.

Let's assume that n is the number of distinct lucky numbers, each of them cannot be greater than r or less than l, and ai is the i-th (in increasing order) number of them. Find a1·a2 + a2·a3 + ... + an - 1·an. As the answer can be rather large, print the remainder after dividing it by 1000000007 (109 + 7).

Input

The first line contains a positive integer l, and the second line contains a positive integer r (1 ≤ l < r ≤ 10100000). The numbers are given without any leading zeroes.

It is guaranteed that the lengths of the given numbers are equal to each other and that both of them are lucky numbers.

Output

In the single line print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

Examples

Input

4
7

Output

28

Input

474
777

Output

2316330

### Response

```cpp
#include <bits/stdc++.h>
const int md = 1000000007, MX = 100100;
int i, st, n;
char s[MX], t[MX];
long long x, y, cnt, sum, res, a[MX], b[MX], c[MX], l[MX], r[MX], p[MX], es[MX],
    et[MX];
int main() {
  scanf("%s", s);
  scanf("%s", t);
  n = strlen(s);
  p[0] = 1;
  c[0] = 1;
  for (i = 1; i <= n; i++) {
    x = (4LL * p[i - 1]) % md;
    y = (7LL * p[i - 1]) % md;
    a[i] = (((x + y) % md) * c[i - 1] + 2LL * a[i - 1]) % md;
    cnt = (c[i - 1] + md - 1) % md;
    sum = ((2LL * a[i - 1]) % md + md - l[i - 1] + md - r[i - 1]) % md;
    b[i] = (2 * b[i - 1]) % md;
    b[i] = (((x * x + y * y) % md) * cnt + b[i]) % md;
    b[i] = ((((x + y) % md) * sum) % md + b[i]) % md;
    b[i] = (x * y + b[i]) % md;
    b[i] = (r[i - 1] * y + b[i]) % md;
    b[i] = (x * l[i - 1] + b[i]) % md;
    b[i] = (r[i - 1] * l[i - 1] + b[i]) % md;
    c[i] = (2 * c[i - 1]) % md;
    l[i] = (x + l[i - 1]) % md;
    r[i] = (y + r[i - 1]) % md;
    p[i] = (10LL * p[i - 1]) % md;
  }
  for (i = 0; i < n; i++) {
    es[i] = (es[i - 1] + p[n - i - 1] * (s[i] - '0')) % md;
    et[i] = (et[i - 1] + p[n - i - 1] * (t[i] - '0')) % md;
  }
  for (st = 0; s[st] == t[st]; st++)
    ;
  for (i = n - 1; i > st; i--)
    if (s[i] == '4') {
      x = (es[i - 1] + 4LL * p[n - i - 1]) % md;
      y = (es[i - 1] + 7LL * p[n - i - 1]) % md;
      res = (res + b[n - i - 1]) % md;
      cnt = (c[n - i - 1] + md - 1) % md;
      sum =
          ((2LL * a[n - i - 1]) % md + md - l[n - i - 1] + md - r[n - i - 1]) %
          md;
      res = (((y * y) % md) * cnt + res) % md;
      res = ((y * sum) % md + res) % md;
      res = (x * y + res) % md;
      res = (r[n - i - 1] * y + res) % md;
      res = (x * l[n - i - 1] + res) % md;
      res = (r[n - i - 1] * l[n - i - 1] + res) % md;
    }
  x = es[st];
  y = et[st];
  res = (x * y + res) % md;
  res = (r[n - st - 1] * y + res) % md;
  res = (x * l[n - st - 1] + res) % md;
  res = (r[n - st - 1] * l[n - st - 1] + res) % md;
  for (i = st + 1; i < n; i++)
    if (t[i] == '7') {
      x = (et[i - 1] + 7LL * p[n - i - 1]) % md;
      y = (et[i - 1] + 4LL * p[n - i - 1]) % md;
      res = (res + b[n - i - 1]) % md;
      cnt = (c[n - i - 1] + md - 1) % md;
      sum =
          ((2LL * a[n - i - 1]) % md + md - l[n - i - 1] + md - r[n - i - 1]) %
          md;
      res = (((y * y) % md) * cnt + res) % md;
      res = ((y * sum) % md + res) % md;
      res = (x * y + res) % md;
      res = (l[n - i - 1] * y + res) % md;
      res = (x * r[n - i - 1] + res) % md;
      res = (r[n - i - 1] * l[n - i - 1] + res) % md;
    }
  printf("%I64d\n", res);
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

For a given polygon g, print "1" if g is a convex polygon, "0" otherwise. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees.

g is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n-1) are sides of the polygon. The line segment connecting pn and p1 is also a side of the polygon.

Constraints

* 3 ≤ n ≤ 100
* -10000 ≤ xi, yi ≤ 10000
* No point of the polygon will occur more than once.
* Two sides of the polygon can intersect only at a common endpoint.

Input

g is given by coordinates of the points p1,..., pn in the following format:

n
x1 y1
x2 y2
:
xn yn

The first integer n is the number of points. The coordinate of a point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them.

Output

Print "1" or "0" in a line.

Examples

Input

4
0 0
3 1
2 3
0 3

Output

1

Input

5
0 0
2 0
1 1
2 2
0 2

Output

0

### Response

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

inline double add(double a, double b){
    return abs(a+b)<(1e-10)*(abs(a)+abs(b)) ? 0.0 : a+b;
}

struct vec{
    double x,y;
    vec operator-(vec b){
        return (vec){add(x,-b.x),add(y,-b.y)};
    }
    vec operator+(vec b){
        return (vec){add(x,b.x),add(y,b.y)};
    }
    vec operator*(double d){
        return (vec){x*d,y*d};
    }
    double dot(vec v){
        return add(x*v.x,y*v.y);
    }
    double cross(vec v){
        return add(x*v.y,-y*v.x);
    }
    double norm(){
        return sqrt(x*x+y*y);
    }
};
typedef vector<vec> polygon;

int ccw(vec& a, vec& b, vec& c){
    vec ab = b-a, ac = c-a;
    double o = ab.cross(ac);
    if(o>0) return 1; //CCW
    if(o<0) return -1; //CW
    if(ab.dot(ac)<0){
        return 2; //C-A-B
    }else{
        if(ab.dot(ab)<ac.dot(ac)){
            return -2; //A-B-C
        }else{
            return 0; //A-C-B
        }
    }
}

bool isConvex(polygon& g){
    int n=g.size()-2;
    for(int i=0;i<n;i++){
        if(!~ccw(g[i],g[i+1],g[i+2]))return false;
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    polygon g;
    vec v;
    while(n--){
        cin >> v.x >> v.y;
        g.push_back(v);
    }
    g.push_back(g[0]);
    g.push_back(g[1]);
    cout.precision(1);
    cout << fixed;
    cout << (isConvex(g)?1:0) << endl;
    return 0;
}
```


### Prompt

Construct a Cpp code solution to the problem outlined:

Tanya has n candies numbered from 1 to n. The i-th candy has the weight a_i.

She plans to eat exactly n-1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day.

Your task is to find the number of such candies i (let's call these candies good) that if dad gets the i-th candy then the sum of weights of candies Tanya eats in even days will be equal to the sum of weights of candies Tanya eats in odd days. Note that at first, she will give the candy, after it she will eat the remaining candies one by one.

For example, n=4 and weights are [1, 4, 3, 3]. Consider all possible cases to give a candy to dad:

  * Tanya gives the 1-st candy to dad (a_1=1), the remaining candies are [4, 3, 3]. She will eat a_2=4 in the first day, a_3=3 in the second day, a_4=3 in the third day. So in odd days she will eat 4+3=7 and in even days she will eat 3. Since 7 ≠ 3 this case shouldn't be counted to the answer (this candy isn't good).
  * Tanya gives the 2-nd candy to dad (a_2=4), the remaining candies are [1, 3, 3]. She will eat a_1=1 in the first day, a_3=3 in the second day, a_4=3 in the third day. So in odd days she will eat 1+3=4 and in even days she will eat 3. Since 4 ≠ 3 this case shouldn't be counted to the answer (this candy isn't good).
  * Tanya gives the 3-rd candy to dad (a_3=3), the remaining candies are [1, 4, 3]. She will eat a_1=1 in the first day, a_2=4 in the second day, a_4=3 in the third day. So in odd days she will eat 1+3=4 and in even days she will eat 4. Since 4 = 4 this case should be counted to the answer (this candy is good).
  * Tanya gives the 4-th candy to dad (a_4=3), the remaining candies are [1, 4, 3]. She will eat a_1=1 in the first day, a_2=4 in the second day, a_3=3 in the third day. So in odd days she will eat 1+3=4 and in even days she will eat 4. Since 4 = 4 this case should be counted to the answer (this candy is good).

In total there 2 cases which should counted (these candies are good), so the answer is 2.

Input

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

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^4), where a_i is the weight of the i-th candy.

Output

Print one integer — the number of such candies i (good candies) that if dad gets the i-th candy then the sum of weights of candies Tanya eats in even days will be equal to the sum of weights of candies Tanya eats in odd days.

Examples

Input

7
5 5 4 5 5 5 6

Output

2

Input

8
4 8 8 7 8 4 4 5

Output

2

Input

9
2 3 4 2 2 3 2 2 4

Output

3

Note

In the first example indices of good candies are [1, 2].

In the second example indices of good candies are [2, 3].

In the third example indices of good candies are [4, 5, 9].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  int arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long sodd = 0;
  long long seven = 0;
  for (long long i = 0; i < n; i++) {
    if (i % 2 == 1)
      seven += arr[i];
    else
      sodd += arr[i];
  }
  long long gsodd = sodd;
  long long gseven = seven;
  long long c = 0;
  long long csodd = 0;
  long long cseven = 0;
  for (long long i = 0; i < n; i++) {
    if (i % 2 == 0) {
      csodd += arr[i];
    } else {
      cseven += arr[i];
    }
    if (i % 2 == 0) {
      if (csodd + seven - cseven - arr[i] == sodd - csodd + cseven) {
        c++;
      }
    } else {
      if (csodd + seven - cseven == cseven - arr[i] + sodd - csodd) {
        c++;
      }
    }
  }
  cout << c << endl;
  return 0;
}

```


### Prompt

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

Petya is preparing for his birthday. He decided that there would be n different dishes on the dinner table, numbered from 1 to n. Since Petya doesn't like to cook, he wants to order these dishes in restaurants.

Unfortunately, all dishes are prepared in different restaurants and therefore Petya needs to pick up his orders from n different places. To speed up this process, he wants to order courier delivery at some restaurants. Thus, for each dish, there are two options for Petya how he can get it:

  * the dish will be delivered by a courier from the restaurant i, in this case the courier will arrive in a_i minutes,
  * Petya goes to the restaurant i on his own and picks up the dish, he will spend b_i minutes on this.

Each restaurant has its own couriers and they start delivering the order at the moment Petya leaves the house. In other words, all couriers work in parallel. Petya must visit all restaurants in which he has not chosen delivery, he does this consistently.

For example, if Petya wants to order n = 4 dishes and a = [3, 7, 4, 5], and b = [2, 1, 2, 4], then he can order delivery from the first and the fourth restaurant, and go to the second and third on your own. Then the courier of the first restaurant will bring the order in 3 minutes, the courier of the fourth restaurant will bring the order in 5 minutes, and Petya will pick up the remaining dishes in 1 + 2 = 3 minutes. Thus, in 5 minutes all the dishes will be at Petya's house.

Find the minimum time after which all the dishes can be at Petya's home.

Input

The first line contains one positive integer t (1 ≤ t ≤ 2 ⋅ 10^5) — the number of test cases. Then t test cases follow.

Each test case begins with a line containing one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of dishes that Petya wants to order.

The second line of each test case contains n integers a_1 … a_n (1 ≤ a_i ≤ 10^9) — the time of courier delivery of the dish with the number i.

The third line of each test case contains n integers b_1 … b_n (1 ≤ b_i ≤ 10^9) — the time during which Petya will pick up the dish with the number i.

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

Output

For each test case output one integer — the minimum time after which all dishes can be at Petya's home.

Example

Input

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

Output

5
3
2
3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void fastIO() {
  ios_base::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(10);
  cout.tie(nullptr);
  cin.tie(nullptr);
}
template <class T>
T power(T N, T P) {
  return (P == 0) ? 1 : N * power(N, P - 1);
}
template <class T>
T GCD(T A, T B) {
  return (A % B == 0) ? B : GCD(B, A % B);
}
const int MOD = 1e9 + 7;
const int MX = 2e5 + 5;
const double delta = 1e-9;
const long long INF = 1e18;
const long double PI = acos((long double)-1);
void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(), "w", stdout); }
bool sort_rev(int a, int b) { return a > b; }
bool sort_(pair<string, int> &p1, pair<string, int> &p2) {
  if (p1.first == p2.first) return p1.second < p2.second;
  return p1.first < p2.first;
}
bool func(pair<int, int> a, pair<int, int> b) { return a.first > b.first; }
int main() {
  fastIO();
  int t = 1;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    pair<int, int> ara[n + 1];
    for (int i = 0; i < n; i++) {
      cin >> ara[i].first;
    }
    for (int i = 0; i < n; i++) cin >> ara[i].second;
    sort(ara, ara + n, func);
    long long aa = 0, bb = 0;
    for (int i = 0; i < n; i++) {
      long long canB = bb + ara[i].second;
      long long canA = max(aa, (long long)ara[i].first);
      if (canA <= canB)
        aa = canA;
      else
        bb = canB;
    }
    cout << max(aa, bb) << "\n";
  }
  return 0;
}

```


### Prompt

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

You are given two integers a and b.

In one move, you can choose some integer k from 1 to 10 and add it to a or subtract it from a. In other words, you choose an integer k ∈ [1; 10] and perform a := a + k or a := a - k. You may use different values of k in different moves.

Your task is to find the minimum number of moves required to obtain b from a.

You have to answer t independent test cases.

Input

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

The only line of the test case contains two integers a and b (1 ≤ a, b ≤ 10^9).

Output

For each test case, print the answer: the minimum number of moves required to obtain b from a.

Example

Input

6
5 5
13 42
18 4
1337 420
123456789 1000000000
100500 9000

Output

0
3
2
92
87654322
9150

Note

In the first test case of the example, you don't need to do anything.

In the second test case of the example, the following sequence of moves can be applied: 13 → 23 → 32 → 42 (add 10, add 9, add 10).

In the third test case of the example, the following sequence of moves can be applied: 18 → 10 → 4 (subtract 8, subtract 6).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const int N = int(2e5) + 99;
const int INF = int(1e9) + 99;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    if (a == b)
      cout << 0 << '\n';
    else if (a > b) {
      if ((a - b) % 2)
        cout << 2 << '\n';
      else
        cout << 1 << '\n';
    } else {
      if ((b - a) % 2)
        cout << 1 << '\n';
      else
        cout << 2 << '\n';
    }
  }
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Ruritania is a country with a very badly maintained road network, which is not exactly good news for lorry drivers that constantly have to do deliveries. In fact, when roads are maintained, they become one-way. It turns out that it is sometimes impossible to get from one town to another in a legal way – however, we know that all towns are reachable, though illegally!

Fortunately for us, the police tend to be very corrupt and they will allow a lorry driver to break the rules and drive in the wrong direction provided they receive ‘a small gift’. There is one patrol car for every road and they will request 1000 Ruritanian dinars when a driver drives in the wrong direction. However, being greedy, every time a patrol car notices the same driver breaking the rule, they will charge double the amount of money they requested the previous time on that particular road.

Borna is a lorry driver that managed to figure out this bribing pattern. As part of his job, he has to make K stops in some towns all over Ruritania and he has to make these stops in a certain order. There are N towns (enumerated from 1 to N) in Ruritania and Borna’s initial location is the capital city i.e. town 1. He happens to know which ones out of the N - 1 roads in Ruritania are currently unidirectional, but he is unable to compute the least amount of money he needs to prepare for bribing the police. Help Borna by providing him with an answer and you will be richly rewarded.

Input

The first line contains N, the number of towns in Ruritania. The following N - 1 lines contain information regarding individual roads between towns. A road is represented by a tuple of integers (a,b,x), which are separated with a single whitespace character. The numbers a and b represent the cities connected by this particular road, and x is either 0 or 1: 0 means that the road is bidirectional, 1 means that only the a → b direction is legal. The next line contains K, the number of stops Borna has to make. The final line of input contains K positive integers s1, …, sK: the towns Borna has to visit.

  * 1 ≤ N ≤ 105
  * 1 ≤ K ≤ 106
  * 1 ≤ a, b ≤ N for all roads
  * <image> for all roads
  * 1 ≤ si ≤ N for all 1 ≤ i ≤ K

Output

The output should contain a single number: the least amount of thousands of Ruritanian dinars Borna should allocate for bribes, modulo 109 + 7.

Examples

Input

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

Output

4

Note

Borna first takes the route 1 → 5 and has to pay 1000 dinars. After that, he takes the route 5 → 1 → 2 → 3 → 4 and pays nothing this time. However, when he has to return via 4 → 3 → 2 → 1 → 5, he needs to prepare 3000 (1000+2000) dinars. Afterwards, getting to 2 via 5 → 1 → 2 will cost him nothing. Finally, he doesn't even have to leave town 2 to get to 2, so there is no need to prepare any additional bribe money. Hence he has to prepare 4000 dinars in total.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
struct edge {
  int id;
  int tong;
  edge *next;
};
long long ttmp1[100050], ttmp2[100050];
edge edges[100050 << 1];
edge *adj[100050];
int ednum;
inline void addEdge(int a, int b, int c) {
  edge *tmp = &edges[ednum++];
  tmp->id = b;
  tmp->tong = c;
  tmp->next = adj[a];
  adj[a] = tmp;
}
int fa[100050], top[100050], son[100050], siz[100050], id[100050], fid[100050],
    dep[100050];
bool vis[100050];
void dfs1(int me, int deep) {
  int maxsiz = -1;
  vis[me] = 1;
  dep[me] = deep;
  siz[me] = 1;
  for (edge *it = adj[me]; it; it = it->next) {
    if (!vis[it->id]) {
      fa[it->id] = me;
      dfs1(it->id, deep + 1);
      if (maxsiz < siz[it->id]) {
        maxsiz = siz[it->id];
        son[me] = it->id;
      }
      siz[me] += siz[it->id];
    }
  }
}
int num;
void dfs2(int me, int t) {
  vis[me] = 1;
  top[me] = t;
  id[me] = ++num;
  fid[num] = me;
  if (son[me]) {
    dfs2(son[me], t);
  }
  for (edge *it = adj[me]; it; it = it->next) {
    if (!vis[it->id]) {
      dfs2(it->id, it->id);
    }
  }
}
void dfs3(int pos) {
  vis[pos] = 1;
  for (edge *it = adj[pos]; it; it = it->next) {
    if (!vis[it->id]) {
      if (it->tong == 1) {
        ttmp2[it->id] = 1;
      } else if (it->tong == 2) {
        ttmp1[it->id] = 1;
      }
      dfs3(it->id);
    }
  }
}
int solve(int a, int b) {
  while (1) {
    if (top[a] == top[b])
      return dep[a] <= dep[b] ? a : b;
    else if (dep[top[a]] >= dep[top[b]])
      a = fa[top[a]];
    else
      b = fa[top[b]];
  }
}
long long ans;
long long biaoge[1000050];
int jia1[100050], jia2[100050];
struct ss {
  int dep;
  int pos;
  ss(int a, int b) {
    pos = a;
    dep = b;
  }
};
bool operator<(const ss &a, const ss &b) { return a.dep > b.dep; }
multiset<ss> ms;
void dfs4(int pos) {
  vis[pos] = 1;
  ms.insert(ss(pos, dep[pos]));
  for (edge *it = adj[pos]; it; it = it->next) {
    if (!vis[it->id]) {
      dfs4(it->id);
    }
  }
}
int main() {
  long long ttt = 1;
  for (int i = 1; i <= 1000008; i++) {
    biaoge[i] = biaoge[i - 1] + ttt;
    biaoge[i] %= mod;
    ttt <<= 1;
    ttt %= mod;
  }
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int a, b, typ;
    scanf("%d%d%d", &a, &b, &typ);
    if (typ == 0) {
      addEdge(a, b, 0);
      addEdge(b, a, 0);
    } else {
      addEdge(a, b, 1);
      addEdge(b, a, 2);
    }
  }
  dfs1(1, 1);
  memset(vis, 0, sizeof(vis));
  dfs2(1, 1);
  memset(vis, 0, sizeof(vis));
  dfs3(1);
  int bef = 1, now;
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d", &now);
    int gra = solve(bef, now);
    jia2[bef]++;
    jia2[gra]--;
    jia1[now]++;
    jia1[gra]--;
    bef = now;
  }
  memset(vis, 0, sizeof(vis));
  dfs4(1);
  while (!ms.empty()) {
    ss tmp = *ms.begin();
    ms.erase(ms.begin());
    if (ttmp2[tmp.pos]) {
      ans += biaoge[jia2[tmp.pos]];
      ans %= mod;
    }
    if (ttmp1[tmp.pos]) {
      ans += biaoge[jia1[tmp.pos]];
      ans %= mod;
    }
    jia1[fa[tmp.pos]] += jia1[tmp.pos];
    jia2[fa[tmp.pos]] += jia2[tmp.pos];
  }
  printf("%I64d\n", ans);
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Alice and Bob have a tree (undirected acyclic connected graph). There are ai chocolates waiting to be picked up in the i-th vertex of the tree. First, they choose two different vertices as their starting positions (Alice chooses first) and take all the chocolates contained in them.

Then, they alternate their moves, selecting one vertex at a time and collecting all chocolates from this node. To make things more interesting, they decided that one can select a vertex only if he/she selected a vertex adjacent to that one at his/her previous turn and this vertex has not been already chosen by any of them during other move.

If at any moment one of them is not able to select the node that satisfy all the rules, he/she will skip his turns and let the other person pick chocolates as long as he/she can. This goes on until both of them cannot pick chocolates any further.

Due to their greed for chocolates, they want to collect as many chocolates as possible. However, as they are friends they only care about the total number of chocolates they obtain together. What is the maximum total number of chocolates they may pick?

Input

The first line of the input contains the single integer n (2 ≤ n ≤ 100 000) — the number of vertices in the tree.

The second line contains n integers ai (1 ≤ ai ≤ 109), i-th of these numbers stands for the number of chocolates stored at the node i.

Then follow n - 1 lines that describe the tree. Each of them contains two integers ui and vi (1 ≤ ui, vi ≤ n) — indices of vertices connected by the i-th edge.

Output

Print the number of chocolates Alice and Bob can collect together if they behave optimally.

Examples

Input

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

Output

25

Input

2
20 10
1 2

Output

30

Note

In the first sample, Alice may start at the vertex 9 and Bob at vertex 8. Alice will select vertex 1 and Bob has no options now. Alice selects the vertex 7 and they both stop.

In the second sample, both of them will pick either of the nodes alternately.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 500101;
vector<int> e[N];
int v[N];
int a, b, n, i;
long long ans, f[N], g[N], h[N];
void dfs(int x, int fa) {
  int i;
  long long tmp = 0, tmp1 = v[x], tmp2 = v[x];
  f[x] = g[x] = h[x] = v[x];
  long long t1, t2, t3;
  int p1, p2, p3;
  t1 = t2 = t3 = v[x];
  p1 = p2 = p3 = x;
  for (i = 0; i < e[x].size(); i++)
    if (e[x][i] != fa) {
      dfs(e[x][i], x);
      if (tmp + g[e[x][i]] > ans) ans = tmp + g[e[x][i]];
      tmp = max(tmp, g[e[x][i]]);
      g[x] = max(g[x], g[e[x][i]]);
      g[x] = max(g[x], f[x] + f[e[x][i]]);
      f[x] = max(f[x], f[e[x][i]] + v[x]);
      h[x] = max(h[x], h[e[x][i]] + v[x]);
      ans = max(ans, h[e[x][i]] + tmp1);
      ans = max(ans, f[e[x][i]] + tmp2);
      tmp1 = max(tmp1, f[x]);
      tmp2 = max(tmp2, h[x]);
      if (f[e[x][i]] + v[x] > t1) {
        t3 = t2;
        p3 = p2;
        t2 = t1;
        p2 = p1;
        t1 = f[e[x][i]] + v[x];
        p1 = e[x][i];
      } else if (f[e[x][i]] + v[x] > t2) {
        t3 = t2;
        p3 = p2;
        t2 = f[e[x][i]] + v[x];
        p2 = e[x][i];
      } else if (f[e[x][i]] + v[x] > t3) {
        t3 = f[e[x][i]] + v[x];
        p3 = e[x][i];
      }
    }
  ans = max(ans, g[x]);
  for (i = 0; i < e[x].size(); i++)
    if (e[x][i] != fa) {
      if (e[x][i] == p1)
        h[x] = max(h[x], g[e[x][i]] + t2);
      else
        h[x] = max(h[x], g[e[x][i]] + t1);
      if (e[x][i] == p1)
        ans = max(ans, t2 + t3 - v[x] + g[e[x][i]]);
      else if (e[x][i] == p2)
        ans = max(ans, t1 + t3 - v[x] + g[e[x][i]]);
      else
        ans = max(ans, t1 + t2 - v[x] + g[e[x][i]]);
    }
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &v[i]);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    e[a].push_back(b);
    e[b].push_back(a);
  }
  dfs(1, 0);
  printf("%I64d\n", ans);
}

```


### Prompt

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

The Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the campus n ice sculptures were erected. The sculptures are arranged in a circle at equal distances from each other, so they form a regular n-gon. They are numbered in clockwise order with numbers from 1 to n.

The site of the University has already conducted a voting that estimated each sculpture's characteristic of ti — the degree of the sculpture's attractiveness. The values of ti can be positive, negative or zero.

When the university rector came to evaluate the work, he said that this might be not the perfect arrangement. He suggested to melt some of the sculptures so that:

  * the remaining sculptures form a regular polygon (the number of vertices should be between 3 and n),
  * the sum of the ti values of the remaining sculptures is maximized.

Help the Vice Rector to analyze the criticism — find the maximum value of ti sum which can be obtained in this way. It is allowed not to melt any sculptures at all. The sculptures can not be moved.

Input

The first input line contains an integer n (3 ≤ n ≤ 20000) — the initial number of sculptures. The second line contains a sequence of integers t1, t2, ..., tn, ti — the degree of the i-th sculpture's attractiveness ( - 1000 ≤ ti ≤ 1000). The numbers on the line are separated by spaces.

Output

Print the required maximum sum of the sculptures' attractiveness.

Examples

Input

8
1 2 -3 4 -5 5 2 3

Output

14

Input

6
1 -2 3 -4 5 -6

Output

9

Input

6
1 2 3 4 5 6

Output

21

Note

In the first sample it is best to leave every second sculpture, that is, leave sculptures with attractivenesses: 2, 4, 5 и 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int* d = new int[7000 * 7000];
  memset(d, 0, sizeof(int) * 7000 * 7000);
  scanf("%d", &n);
  int max = -99999999;
  int max_j = n / 3;
  for (int i = 0; i < n; i++) {
    int t;
    scanf("%d", &t);
    for (int j = 0; j <= max_j; j++) {
      *(d + (i % (j + 1)) * 7000 + j) += t;
      if (n - i - 1 <= j && *(d + (i % (j + 1)) * 7000 + j) > max) {
        int right = n - i - 1;
        int left = i % (j + 1);
        if (left + right == j && (n / (j + 1)) >= 3)
          max = *(d + (i % (j + 1)) * 7000 + j);
      }
    }
  }
  printf("%d\n", max);
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

As you know, lemmings like jumping. For the next spectacular group jump n lemmings gathered near a high rock with k comfortable ledges on it. The first ledge is situated at the height of h meters, the second one is at the height of 2h meters, and so on (the i-th ledge is at the height of i·h meters). The lemmings are going to jump at sunset, and there's not much time left.

Each lemming is characterized by its climbing speed of vi meters per minute and its weight mi. This means that the i-th lemming can climb to the j-th ledge in <image> minutes.

To make the jump beautiful, heavier lemmings should jump from higher ledges: if a lemming of weight mi jumps from ledge i, and a lemming of weight mj jumps from ledge j (for i < j), then the inequation mi ≤ mj should be fulfilled.

Since there are n lemmings and only k ledges (k ≤ n), the k lemmings that will take part in the jump need to be chosen. The chosen lemmings should be distributed on the ledges from 1 to k, one lemming per ledge. The lemmings are to be arranged in the order of non-decreasing weight with the increasing height of the ledge. In addition, each lemming should have enough time to get to his ledge, that is, the time of his climb should not exceed t minutes. The lemmings climb to their ledges all at the same time and they do not interfere with each other.

Find the way to arrange the lemmings' jump so that time t is minimized.

Input

The first line contains space-separated integers n, k and h (1 ≤ k ≤ n ≤ 105, 1 ≤ h ≤ 104) — the total number of lemmings, the number of ledges and the distance between adjacent ledges.

The second line contains n space-separated integers m1, m2, ..., mn (1 ≤ mi ≤ 109), where mi is the weight of i-th lemming.

The third line contains n space-separated integers v1, v2, ..., vn (1 ≤ vi ≤ 109), where vi is the speed of i-th lemming.

Output

Print k different numbers from 1 to n — the numbers of the lemmings who go to ledges at heights h, 2h, ..., kh, correspondingly, if the jump is organized in an optimal way. If there are multiple ways to select the lemmings, pick any of them.

Examples

Input

5 3 2
1 2 3 2 1
1 2 1 2 10

Output

5 2 4

Input

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

Output

4 3 1

Note

Let's consider the first sample case. The fifth lemming (speed 10) gets to the ledge at height 2 in <image> minutes; the second lemming (speed 2) gets to the ledge at height 4 in 2 minutes; the fourth lemming (speed 2) gets to the ledge at height 6 in 3 minutes. All lemmings manage to occupy their positions in 3 minutes.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int INF = 1000000000;
const long long LINF = 4000000000000000000ll;
void prepare() {}
int n, k, h;
int m[100005], v[100005];
pair<pair<int, int>, int> lem[100005];
int ans[100005];
bool f(double t) {
  int cur = n - 1;
  for (int i = k; i > 0; i--) {
    double h0 = h * i;
    while (cur >= 0) {
      if (h0 / lem[cur].first.second < t + eps) break;
      cur--;
    }
    if (cur == -1) return false;
    ans[i - 1] = lem[cur].second;
    cur--;
  }
  return true;
}
bool solve() {
  scanf("%d%d%d", &n, &k, &h);
  for (int i = 0; i < n; i++) scanf("%d", &lem[i].first.first);
  for (int i = 0; i < n; i++) {
    scanf("%d", &lem[i].first.second);
    lem[i].second = i;
  }
  sort(lem, lem + n);
  double l = 0.0, r = 1e9 + 2.0;
  for (int it = 0; it < 100; it++) {
    double t = (l + r) * 0.5;
    if (f(t))
      r = t;
    else
      l = t;
  }
  f(r);
  for (int i = 0; i < k; i++) printf("%d ", ans[i] + 1);
  printf("\n");
  return false;
}
int main() {
  prepare();
  while (solve())
    ;
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

A long time ago (probably even in the first book), Nicholas Flamel, a great alchemist and the creator of the Philosopher's Stone, taught Harry Potter three useful spells. The first one allows you to convert a grams of sand into b grams of lead, the second one allows you to convert c grams of lead into d grams of gold and third one allows you to convert e grams of gold into f grams of sand. When Harry told his friends about these spells, Ron Weasley was amazed. After all, if they succeed in turning sand into lead, lead into gold, and then turning part of the gold into sand again and so on, then it will be possible to start with a small amount of sand and get huge amounts of gold! Even an infinite amount of gold! Hermione Granger, by contrast, was skeptical about that idea. She argues that according to the law of conservation of matter getting an infinite amount of matter, even using magic, is impossible. On the contrary, the amount of matter may even decrease during transformation, being converted to magical energy. Though Hermione's theory seems convincing, Ron won't believe her. As far as Ron is concerned, Hermione made up her law of conservation of matter to stop Harry and Ron wasting their time with this nonsense, and to make them go and do homework instead. That's why Ron has already collected a certain amount of sand for the experiments. A quarrel between the friends seems unavoidable...

Help Harry to determine which one of his friends is right, and avoid the quarrel after all. To do this you have to figure out whether it is possible to get the amount of gold greater than any preassigned number from some finite amount of sand.

Input

The first line contains 6 integers a, b, c, d, e, f (0 ≤ a, b, c, d, e, f ≤ 1000).

Output

Print "Ron", if it is possible to get an infinitely large amount of gold having a certain finite amount of sand (and not having any gold and lead at all), i.e., Ron is right. Otherwise, print "Hermione".

Examples

Input

100 200 250 150 200 250

Output

Ron

Input

100 50 50 200 200 100

Output

Hermione

Input

100 10 200 20 300 30

Output

Hermione

Input

0 0 0 0 0 0

Output

Hermione

Input

1 1 0 1 1 1

Output

Ron

Input

1 0 1 2 1 2

Output

Hermione

Input

100 1 100 1 0 1

Output

Ron

Note

Consider the first sample. Let's start with the 500 grams of sand. Apply the first spell 5 times and turn the sand into 1000 grams of lead. Then apply the second spell 4 times to get 600 grams of gold. Let’s take 400 grams from the resulting amount of gold turn them back into sand. We get 500 grams of sand and 200 grams of gold. If we apply the same operations to 500 grams of sand again, we can get extra 200 grams of gold every time. Thus, you can get 200, 400, 600 etc. grams of gold, i.e., starting with a finite amount of sand (500 grams), you can get the amount of gold which is greater than any preassigned number.

In the forth sample it is impossible to get sand, or lead, or gold, applying the spells.

In the fifth sample an infinitely large amount of gold can be obtained by using only the second spell, which allows you to receive 1 gram of gold out of nothing. Note that if such a second spell is available, then the first and the third one do not affect the answer at all.

The seventh sample is more interesting. We can also start with a zero amount of sand there. With the aid of the third spell you can get sand out of nothing. We get 10000 grams of sand in this manner. Let's get 100 grams of lead using the first spell 100 times. Then make 1 gram of gold from them. We managed to receive 1 gram of gold, starting with a zero amount of sand! Clearly, in this manner you can get an infinitely large amount of gold.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
double a, b, c, d, e, f;
int check() {
  if (fabs(d) < 1e-6) return (0);
  if (fabs(c) < 1e-6) return (1);
  if (fabs(a) < 1e-6) {
    if (fabs(b) < 1e-6) return (0);
    return (1);
  }
  if (fabs(e) < 1e-6) {
    if (fabs(f) < 1e-6) return (0);
    if (fabs(b) < 1e-6) return (0);
    return (1);
  }
  return (int(b * d * f / a / c / e - 1 > 1e-6));
}
int main() {
  cin >> a >> b >> c >> d >> e >> f;
  if (check())
    cout << "Ron" << endl;
  else
    cout << "Hermione" << endl;
}

```


### Prompt

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

This is an output-only problem. You shouldn't read anything from the input.

In short, your task is to simulate multiplication by using only comparison (x < y) and addition (x + y). There is no input in this problem, you just print a sequence of operations.

Imagine that there is a big array a[0], a[1], ..., a[N-1] of length N. The first two values are initially two non-negative integers A and B (which are unknown to you), the other elements are zeros. Your goal is to get the product A \cdot B in a[2] at the end.

You are allowed operations of two types, with the following format (where 0 \leq i, j, k < N):

* `+ i j k` — applies operation a[k] = a[i] + a[j].
* `< i j k` — applies operation a[k] = a[i] < a[j]. That is, if a[i] < a[j] then a[k] becomes 1, otherwise it becomes 0.

You can use at most Q operations. Elements of a can't exceed V. Indices (i, j, k) don't have to be distinct. It's allowed to modify any element of the array (including the first two). The actual checker simulates the process for multiple pairs (A, B) within a single test. Each time, the checker chooses values A and B, creates the array a = [A, B, 0, 0, \ldots, 0], applies all your operations and ensures that a[2] = A \cdot B.

Constraints

* 0 \leq A, B \leq 10^9
* N = Q = 200\,000
* V = 10^{19} = 10\,000\,000\,000\,000\,000\,000

Input

The Standard Input is empty.

Output

In the first line, print the number of operations. Each operation should then be printed in a single line of format `+ i j k` or `< i j k`.

Example

Input

Output

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[200008];int oz=0;
void out(int t,int x,int y,int z){
	if(t) putchar('+');else putchar('<');
//	if(t) a[z]=a[x]+a[y];else a[z]=(a[x]<a[y]);
oz++;
	printf(" %d %d %d\n",x-1,y-1,z-1);
}
#define n 30

int cmp(int x,int y){
	for(int i=1247;i<=1248;i++) out(0,7777,7777,i);
	out(0,1248,x,1247);
	out(1,y,1247,1247);
	out(0,5,1247,1247);
	return 1247;
}
	int a1=100,b1=400,c1=888;int t=36666;
	void mul(int x,int p){
		while(p--) out(1,x,x,x);
	}
	void solve(int xg){
		out(0,t-1,t-1,t);
		for(int i=n;i>=0;i--) {
			out(1,t-1,t,t+1);
			out(1,t,5+i,t);
			out(0,t,xg,a1+i);
			out(1,t-1,t+1,t);
			mul(a1+i,i);
			out(1,a1+i,t,t);
			out(0,t-1,a1+i,a1+i);
		}
	//	for(int i=0;i<=n;i++) cout<<a[a1+i];cout<<"\n";
	}
signed main(){
//	cin>>a[1]>>a[2];
printf("%d\n",8996);
	out(1,1,2,3);out(0,4,3,5);

	out(1,1,5,1);
	out(1,2,5,2);//to use < as <=
//	cout<<a[1]<<" "<<a[2]<<"\n";
	for(int i=1;i<=n;i++) out(1,4+i,4+i,5+i);
	solve(1);swap(a1,b1);solve(2);

	for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) {
		out(1,cmp(a1+i,b1+j),c1+i+j,c1+i+j);
	}
	out(0,3,3,3);
	for(int i=0;i<=n+n;i++){
		mul(c1+i,i);
		out(1,c1+i,3,3);
	}
//	cout<<oz<<"\n";
//	cout<<a[2]<<"\n";
	return 0;
}
```


### Prompt

Construct a cpp code solution to the problem outlined:

You are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusive OR. Since it can be extremely large, compute the answer modulo 10^9+7.

Constraints

* 1≦N≦10^{18}

Input

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

N

Output

Print the number of the possible pairs of integers u and v, modulo 10^9+7.

Examples

Input

3

Output

5

Input

1422

Output

52277

Input

1000000000000000000

Output

787014179

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

int main(){
  ll n,dp[70][3]={};
  cin>>n;
  dp[62][0]=1;
  ifr(i,62){
    if((n>>i)&1){
      dp[i][0]=dp[i+1][0];
      dp[i][1]=ad(dp[i+1][0],dp[i+1][1]);
      dp[i][2]=ad(2*dp[i+1][1],3*dp[i+1][2]);
    }
    else{
      dp[i][0]=ad(dp[i+1][0],dp[i+1][1]);
      dp[i][1]=dp[i+1][1];
      dp[i][2]=ad(dp[i+1][1],3*dp[i+1][2]);
    }
  }
  cout<<ad(dp[0][0]+dp[0][1]+dp[0][2])<<endl;
}
```


### Prompt

Develop a solution in cpp to the problem described below:

Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an electric shock. He can make guesses which letter is selected, but for each incorrect guess he receives an electric shock too. The show ends when Valentin guesses the selected letter correctly.

Valentin can't keep in mind everything, so he could guess the selected letter much later than it can be uniquely determined and get excessive electric shocks. Excessive electric shocks are those which Valentin got after the moment the selected letter can be uniquely determined. You should find out the number of excessive electric shocks.

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of actions Valentin did.

The next n lines contain descriptions of his actions, each line contains description of one action. Each action can be of one of three types:

  1. Valentin pronounced some word and didn't get an electric shock. This action is described by the string ". w" (without quotes), in which "." is a dot (ASCII-code 46), and w is the word that Valentin said.
  2. Valentin pronounced some word and got an electric shock. This action is described by the string "! w" (without quotes), in which "!" is an exclamation mark (ASCII-code 33), and w is the word that Valentin said.
  3. Valentin made a guess about the selected letter. This action is described by the string "? s" (without quotes), in which "?" is a question mark (ASCII-code 63), and s is the guess — a lowercase English letter.

All words consist only of lowercase English letters. The total length of all words does not exceed 105.

It is guaranteed that last action is a guess about the selected letter. Also, it is guaranteed that Valentin didn't make correct guesses about the selected letter before the last action. Moreover, it's guaranteed that if Valentin got an electric shock after pronouncing some word, then it contains the selected letter; and also if Valentin didn't get an electric shock after pronouncing some word, then it does not contain the selected letter.

Output

Output a single integer — the number of electric shocks that Valentin could have avoided if he had told the selected letter just after it became uniquely determined.

Examples

Input

5
! abc
. ad
. b
! cd
? c

Output

1

Input

8
! hello
! codeforces
? c
. o
? d
? h
. l
? e

Output

2

Input

7
! ababahalamaha
? a
? b
? a
? b
? a
? h

Output

0

Note

In the first test case after the first action it becomes clear that the selected letter is one of the following: a, b, c. After the second action we can note that the selected letter is not a. Valentin tells word "b" and doesn't get a shock. After that it is clear that the selected letter is c, but Valentin pronounces the word cd and gets an excessive electric shock.

In the second test case after the first two electric shocks we understand that the selected letter is e or o. Valentin tries some words consisting of these letters and after the second word it's clear that the selected letter is e, but Valentin makes 3 more actions before he makes a correct hypothesis.

In the third example the selected letter can be uniquely determined only when Valentin guesses it, so he didn't get excessive electric shocks.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long n, q, m, t, k, i, j, x, y, z, p, v, val = 0, minans = LLONG_MAX, a,
                                                b, c, d, flag = 0;
  cin >> n;
  char ch;
  string s;
  set<long long> possible;
  vector<long long> arr(26, 0);
  for (i = 0; i < n; i++) {
    cin >> ch;
    cin >> s;
    if (ch == '.') {
      for (j = 0; j < s.length(); j++) arr[s[j] - 'a'] = -1;
    } else if (ch == '!') {
      if (flag) val++;
      set<long long> temp;
      for (j = 0; j < s.length(); j++) temp.insert(s[j] - 'a');
      for (auto e : temp) {
        if (arr[e] != -1) {
          arr[e]++;
        }
      }
    } else {
      if (flag) val++;
      arr[s[0] - 'a'] = -1;
    }
    long long max1 = LLONG_MIN;
    for (j = 0; j < 26; j++) max1 = max(max1, arr[j]);
    possible.clear();
    for (j = 0; j < 26; j++) {
      if (arr[j] == max1) possible.insert(j);
    }
    if (possible.size() == 1) {
      flag = 1;
    }
  }
  if (val == 0) val++;
  cout << val - 1;
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

A: Information Search

problem

The posting list is a list in which there is a correspondence between the search term and the appearing document ID. For example

* Hokkaido: 1, 2, 4, 9
* Sightseeing: 1, 3, 4, 7

And so on.

From the above posting list, if you search for and, the document with ID 1, 4 will be hit, and if you search for or, ID 1, 2, 3, 4, 7, 9 will be hit.

Here, and search means "listing elements contained in either list", or search means "listing elements contained in at least one of the lists".

Since the posting list is given, output the results of and search and or search respectively.

Input format

n m
a_1 a_2 $ \ ldots $ a_n
b_1 b_2 $ \ ldots $ b_m

All inputs consist of integers.

The first line gives the lengths n and m of the two posting lists to search, separated by spaces.

The second and third lines are given the IDs contained in their respective posting lists, separated by blanks.

Constraint

* 1 \ leq n, m \ leq 2 \ times 10 ^ 5
* a_i <a_j (i <j)
* b_i <b_j (i <j)
* 1 \ leq a_i, b_i \ leq 10 ^ 9

Output format

Let A be the number of hits in the and search, and B be the number of hits in the or search.

Print on the first line in the order A B, separated by blanks.

Output the IDs hit by and search on the following line A in ascending order.

Output the IDs hit by or search on the following B line in ascending order.

Input example 1

4 4
1 2 4 9
1 3 4 7

Output example 1

2 6
1
Four
1
2
3
Four
7
9

Input example 2

4 4
1 3 5 7
2 4 6 8

Output example 2

0 8
1
2
3
Four
Five
6
7
8

Input example 3

3 5
one two Three
1 2 3 4 5

Output example 3

3 5
1
2
3
1
2
3
Four
Five

Example

Input

4 4
1 2 4 9
1 3 4 7

Output

2 6
1
4
1
2
3
4
7
9

### Response

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

int main(){
    int N, M;
    cin >> N >> M;
    map<int, int> mp;
    for(int i=0; i<N+M; i++){
        int a;
        cin >> a;
        mp[a]++;
    }
    vector<int> And, Or;
    for(auto& p : mp){
        if(p.second == 2) And.push_back(p.first);
        Or.push_back(p.first);
    }
    cout << And.size() << " " << Or.size() << endl;
    for(int a : And) cout << a << endl;
    for(int a : Or) cout << a << endl;
}

```


### Prompt

Generate a cpp solution to the following problem:

After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.

Yesterday evening Nastya did not manage to finish reading the book, so she marked the page with number k as the first page which was not read (i.e. she read all pages from the 1-st to the (k-1)-th).

The next day Nastya's friend Igor came and asked her, how many chapters remain to be read by Nastya? Nastya is too busy now, so she asks you to compute the number of chapters she has not completely read yet (i.e. the number of chapters she has not started to read or has finished reading somewhere in the middle).

Input

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of chapters in the book.

There are n lines then. The i-th of these lines contains two integers l_i, r_i separated by space (l_1 = 1, l_i ≤ r_i) — numbers of the first and the last pages of the i-th chapter. It's guaranteed that l_{i+1} = r_i + 1 for all 1 ≤ i ≤ n-1, and also that every chapter contains at most 100 pages.

The (n+2)-th line contains a single integer k (1 ≤ k ≤ r_n) — the index of the marked page.

Output

Print a single integer — the number of chapters which has not been completely read so far.

Examples

Input

3
1 3
4 7
8 11
2

Output

3

Input

3
1 4
5 9
10 12
9

Output

2

Input

1
1 7
4

Output

1

Note

In the first example the book contains 11 pages and 3 chapters — [1;3], [4;7] and [8;11]. Nastya marked the 2-nd page, so she finished in the middle of the 1-st chapter. So, all chapters has not been read so far, so the answer is 3.

The book in the second example contains 12 pages and 3 chapters too, but Nastya finished reading in the middle of the 2-nd chapter, so that the answer is 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 1], b[n + 1];
  for (int k = 1; k <= n; k++) cin >> a[k] >> b[k];
  int m;
  cin >> m;
  int s = 0;
  for (int k = 1; k <= n; k++)
    if ((a[k] <= m && m <= b[k]) || s > 0) s++;
  cout << s << endl;
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Guy-Manuel and Thomas are planning 144 trips around the world.

You are given a simple weighted undirected connected graph with n vertexes and m edges with the following restriction: there isn't any simple cycle (i. e. a cycle which doesn't pass through any vertex more than once) of length greater than 3 which passes through the vertex 1. The cost of a path (not necessarily simple) in this graph is defined as the [XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of weights of all edges in that path with each edge being counted as many times as the path passes through it.

But the trips with cost 0 aren't exciting.

You may choose any subset of edges incident to the vertex 1 and remove them. How many are there such subsets, that, when removed, there is not any nontrivial cycle with the cost equal to 0 which passes through the vertex 1 in the resulting graph? A cycle is called nontrivial if it passes through some edge odd number of times. As the answer can be very big, output it modulo 10^9+7.

Input

The first line contains two integers n and m (1 ≤ n,m ≤ 10^5) — the number of vertexes and edges in the graph. The i-th of the next m lines contains three integers a_i, b_i and w_i (1 ≤ a_i, b_i ≤ n, a_i ≠ b_i, 0 ≤ w_i < 32) — the endpoints of the i-th edge and its weight. It's guaranteed there aren't any multiple edges, the graph is connected and there isn't any simple cycle of length greater than 3 which passes through the vertex 1.

Output

Output the answer modulo 10^9+7.

Examples

Input

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

Output

2

Input

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

Output

1

Input

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

Output

6

Note

The pictures below represent the graphs from examples. <image> In the first example, there aren't any nontrivial cycles with cost 0, so we can either remove or keep the only edge incident to the vertex 1. <image> In the second example, if we don't remove the edge 1-2, then there is a cycle 1-2-4-5-2-1 with cost 0; also if we don't remove the edge 1-3, then there is a cycle 1-3-2-4-5-2-3-1 of cost 0. The only valid subset consists of both edges. <image> In the third example, all subsets are valid except for those two in which both edges 1-3 and 1-4 are kept.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void run(vector<vector<int>> &sets, int **sum);
pair<vector<vector<int>>, int **> precalc();
const int MAXB = 5;
const int MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  auto precalc_vals = precalc();
  run(precalc_vals.first, precalc_vals.second);
}
template <typename type>
type *farray(int n) {
  return (type *)malloc(n * sizeof(type));
}
template <typename type>
type *farray(int n, type val) {
  auto res = farray<type>(n);
  fill(res, res + n, val);
  return res;
}
template <typename type>
type **dim2_farray(int n, int m) {
  auto res = farray<type *>(n);
  for (int i = 0; i < n; i++) {
    res[i] = farray<type>(m);
  }
  return res;
}
template <typename type>
type **dim2_farray(int n, int m, type val) {
  auto res = farray<type *>(n);
  for (int i = 0; i < n; i++) {
    res[i] = farray<type>(m, val);
  }
  return res;
}
template <typename type>
void dim2_free(type *arr, int n) {
  for (int i = 0; i < n; i++) free(arr[i]);
  free(arr);
}
bool gauss(bool **matrix, bool *vec, int n, int m) {
  if (m > n) return false;
  for (int k = 0; k < m; k++) {
    int st = k;
    for (; st < n && matrix[st][k] == 0; st++)
      ;
    if (st == n) return false;
    for (int c = 0; c < m; c++) {
      swap(matrix[st][c], matrix[k][c]);
    }
    swap(vec[st], vec[k]);
    for (int r = st + 1; r < n; r++) {
      if (matrix[r][k] == 0) continue;
      for (int c = k; c < m; c++) {
        matrix[r][c] -= matrix[k][c];
      }
      vec[r] -= vec[k];
    }
  }
  for (int k = m - 1; k >= 0; k--) {
    for (int r = k - 1; r >= 0; r--) {
      if (matrix[r][k] == 0) continue;
      matrix[r][k] -= 1;
      vec[r] -= vec[k];
    }
  }
  for (int k = m; k < n; k++) {
    bool val = 0;
    for (int c = 0; c < m; c++) {
      val += matrix[k][c] * vec[c];
    }
    if (val != vec[k]) return false;
  }
  return true;
}
bool **to_matrix(const vector<int> &a) {
  int len = (int)a.size();
  auto matrix = dim2_farray<bool>(MAXB, len);
  for (int i = 0; i < len; i++) {
    for (int b = 0; b < MAXB; b++) {
      matrix[b][i] = (a[i] & (1 << b)) > 0;
    }
  }
  return matrix;
}
bool indep(const vector<int> &a) {
  int len = (int)a.size();
  auto matrix = to_matrix(a);
  auto vec = farray<bool>(MAXB, 0);
  return gauss(matrix, vec, MAXB, len);
}
bool *bin(int a) {
  auto res = farray<bool>(MAXB);
  for (int i = 0; i < MAXB; i++) {
    res[i] = a & (1 << i);
  }
  return res;
}
bool the_same(const vector<int> &a, const vector<int> &b) {
  if (a.size() != b.size()) return false;
  int len = b.size();
  for (int i = 0; i < len; i++) {
    auto a_matrix = to_matrix(a);
    if (!gauss(a_matrix, bin(b[i]), MAXB, len)) {
      dim2_free(a_matrix, MAXB);
      return false;
    }
    dim2_free(a_matrix, MAXB);
  }
  return true;
}
void precalc_sets(int from, vector<vector<int>> &ans, vector<int> &cur,
                  int k = 0) {
  cur.push_back(0);
  for (int i = from; i < (1 << MAXB); i++) {
    cur.back() = i;
    if (indep(cur)) {
      bool new_one = true;
      for (auto &v : ans) {
        if (the_same(cur, v)) {
          new_one = false;
          break;
        }
      }
      if (new_one) {
        ans.push_back(cur);
        precalc_sets(i + 1, ans, cur, k + 1);
      }
    }
  }
  cur.pop_back();
}
int set_id(vector<int> &basis, vector<vector<int>> &sets) {
  for (int i = 0; i < (int)sets.size(); i++) {
    if (the_same(basis, sets[i])) {
      return i;
    }
  }
  return -1;
}
int **precalc_sums(vector<vector<int>> &sets) {
  int n = (int)sets.size();
  auto res = dim2_farray<int>(n, n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      vector<int> cur = sets[i];
      cur.insert(cur.end(), sets[j].begin(), sets[j].end());
      if (indep(cur)) {
        res[i][j] = set_id(cur, sets);
      } else {
        res[i][j] = -1;
      }
    }
  }
  return res;
}
pair<vector<vector<int>>, int **> precalc() {
  vector<vector<int>> sets(1);
  vector<int> cur;
  precalc_sets(0, sets, cur);
  auto sums = precalc_sums(sets);
  return {sets, sums};
}
struct Graph {
  int *head, *nxt, *eto, *cost, eto_ptr = 0;
  Graph(int n, int m) {
    head = farray<int>(n, -1);
    nxt = farray<int>(m);
    eto = farray<int>(m);
    cost = farray<int>(m);
  }
  void add_edge(int from, int to, int c) {
    eto[eto_ptr++] = to;
    nxt[eto_ptr - 1] = head[from];
    head[from] = eto_ptr - 1;
    cost[eto_ptr - 1] = c;
  }
};
void get_basis(int v, Graph &graph, vector<bool> &used, int *path_xor,
               vector<int> &basis, int p = -1) {
  used[v] = true;
  for (int e = graph.head[v]; e != -1; e = graph.nxt[e]) {
    int u = graph.eto[e];
    if (u == p || u == 1) continue;
    if (!used[u]) {
      path_xor[u] = path_xor[v] ^ graph.cost[e];
      get_basis(u, graph, used, path_xor, basis, v);
    } else if (u < v) {
      basis.push_back(path_xor[v] ^ path_xor[u] ^ graph.cost[e]);
    }
  }
}
void run(vector<vector<int>> &sets, int **sums) {
  int n, m;
  cin >> n >> m;
  Graph graph(n + 1, m * 2);
  for (int i = 0; i < m; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    graph.add_edge(u, v, c);
    graph.add_edge(v, u, c);
  }
  auto near_one = farray<int>(n + 1, -1);
  for (int e = graph.head[1]; e != -1; e = graph.nxt[e]) {
    int u = graph.eto[e];
    near_one[u] = graph.cost[e];
  }
  vector<bool> used(n + 1);
  used[1] = true;
  vector<vector<int>> dims = {{}};
  auto path_xor = farray<int>(n + 1, 0);
  for (int v = 2; v <= n; v++) {
    if (used[v] || near_one[v] == -1) continue;
    int u = -1, c = -1;
    for (int e2 = graph.head[v]; e2 != -1; e2 = graph.nxt[e2]) {
      u = graph.eto[e2];
      c = graph.cost[e2];
      if (near_one[u] != -1) {
        break;
      }
      u = -1;
    }
    vector<int> basis;
    get_basis(v, graph, used, path_xor, basis);
    if (!indep(basis)) continue;
    dims.push_back({set_id(basis, sets)});
    if (u != -1) {
      dims.back().push_back(dims.back().back());
      basis.push_back(near_one[v] ^ near_one[u] ^ c);
      if (indep(basis)) {
        dims.back().push_back(set_id(basis, sets));
      }
    }
  }
  int p = sets.size();
  int k = dims.size();
  auto dp = dim2_farray<int>(k, p, 0);
  dp[0][0] = 1;
  for (int i = 1; i < k; i++) {
    for (int d = 0; d < p; d++) {
      dp[i][d] = dp[i - 1][d];
    }
    for (int d = 0; d < p; d++) {
      for (int a : dims[i]) {
        if (sums[d][a] == -1) continue;
        int new_dim = sums[d][a];
        dp[i][new_dim] = (dp[i][new_dim] + dp[i - 1][d]) % MOD;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < p; i++) {
    ans = (ans + dp[k - 1][i]) % MOD;
  }
  cout << ans << endl;
}

```


### Prompt

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

Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.

In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can replace any pair of consecutive moves RU or UR with a diagonal move (described as character D). After that, he can go on and do some other replacements, until there is no pair of consecutive moves RU or UR left.

Your problem is to print the minimum possible length of the sequence of moves after the replacements.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 100) — the length of the sequence. The second line contains the sequence consisting of n characters U and R.

Output

Print the minimum possible length of the sequence of moves after all replacements are done.

Examples

Input

5
RUURU

Output

3

Input

17
UUURRRRRUUURURUUU

Output

13

Note

In the first test the shortened sequence of moves may be DUD (its length is 3).

In the second test the shortened sequence of moves can be UUDRRRDUDDUUU (its length is 13).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
const int N = 1e5 + 10;
const int mod = 100;
int main() {
  string str;
  int n, ans;
  cin >> n >> str;
  ans = n;
  for (int i = 0; i < n - 1; i++) {
    if (str[i] == 'U' && str[i + 1] == 'R') {
      ans--;
      i++;
    } else if (str[i] == 'R' && str[i + 1] == 'U') {
      i++;
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

```