### Prompt

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

Recall that the permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).

A sequence a is a subsegment of a sequence b if a can be obtained from b by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. We will denote the subsegments as [l, r], where l, r are two integers with 1 ≤ l ≤ r ≤ n. This indicates the subsegment where l-1 elements from the beginning and n-r elements from the end are deleted from the sequence.

For a permutation p_1, p_2, …, p_n, we define a framed segment as a subsegment [l,r] where max\\{p_l, p_{l+1}, ..., p_r\} - min\\{p_l, p_{l+1}, ..., p_r\} = r - l. For example, for the permutation (6, 7, 1, 8, 5, 3, 2, 4) some of its framed segments are: [1, 2], [5, 8], [6, 7], [3, 3], [8, 8]. In particular, a subsegment [i,i] is always a framed segments for any i between 1 and n, inclusive.

We define the happiness of a permutation p as the number of pairs (l, r) such that 1 ≤ l ≤ r ≤ n, and [l, r] is a framed segment. For example, the permutation [3, 1, 2] has happiness 5: all segments except [1, 2] are framed segments.

Given integers n and m, Jongwon wants to compute the sum of happiness for all permutations of length n, modulo the prime number m. Note that there exist n! (factorial of n) different permutations of length n.

Input

The only line contains two integers n and m (1 ≤ n ≤ 250 000, 10^8 ≤ m ≤ 10^9, m is prime).

Output

Print r (0 ≤ r < m), the sum of happiness for all permutations of length n, modulo a prime number m.

Examples

Input

1 993244853

Output

1

Input

2 993244853

Output

6

Input

3 993244853

Output

32

Input

2019 993244853

Output

923958830

Input

2020 437122297

Output

265955509

Note

For sample input n=3, let's consider all permutations of length 3:

  * [1, 2, 3], all subsegments are framed segment. Happiness is 6.
  * [1, 3, 2], all subsegments except [1, 2] are framed segment. Happiness is 5.
  * [2, 1, 3], all subsegments except [2, 3] are framed segment. Happiness is 5.
  * [2, 3, 1], all subsegments except [2, 3] are framed segment. Happiness is 5.
  * [3, 1, 2], all subsegments except [1, 2] are framed segment. Happiness is 5.
  * [3, 2, 1], all subsegments are framed segment. Happiness is 6.

Thus, the sum of happiness is 6+5+5+5+5+6 = 32.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long power(long long num, long long g) {
  if (g == 0) return 1;
  if (g % 2 == 1) return (num * power((num * num), g / 2));
  return power((num * num), g / 2);
}
long long mod;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n >> mod;
  long long fact[n + 1];
  fact[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= mod;
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long g = n + 1LL - i;
    g *= g;
    g %= mod;
    g *= fact[i];
    g %= mod;
    g *= fact[n - i];
    g %= mod;
    ans += g;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

In this problem you have to solve a simple classification task: given an image, determine whether it depicts a Fourier doodle.

You are given a set of 50 images with ids 1 through 50. You are also given a text file labels.txt containing the labels for images with ids 1 through 20, which comprise the learning data set.

You have to output the classification results for images with ids 21 through 50 in the same format.

Input

[Download the images and the training labels](http://tc-alchemy.progopedia.com/fourier-doodles.zip)

Each line of the file labels.txt contains a single integer 0 or 1. Line i (1-based) contains the label of the image {i}.png. Label 1 means that the image depicts a Fourier doodle, label 0 - that it does not.

Output

Output 30 lines, one line per image 21 through 50. Line i (1-based) should contain the classification result for the image {i + 20}.png.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  for (int i = 21; i <= 50; ++i)
    cout << ((min(i, 25) + i) % (2 + i % 3) > 0) << '\n';
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

A famous gang of pirates, Sea Dogs, has come back to their hideout from one of their extravagant plunders. They want to split their treasure fairly amongst themselves, that is why You, their trusted financial advisor, devised a game to help them:

All of them take a sit at their round table, some of them with the golden coins they have just stolen. At each iteration of the game if one of them has equal or more than 2 coins, he is eligible to the splitting and he gives one coin to each pirate sitting next to him. If there are more candidates (pirates with equal or more than 2 coins) then You are the one that chooses which one of them will do the splitting in that iteration. The game ends when there are no more candidates eligible to do the splitting.

Pirates can call it a day, only when the game ends. Since they are beings with a finite amount of time at their disposal, they would prefer if the game that they are playing can end after finite iterations, and if so, they call it a good game. On the other hand, if no matter how You do the splitting, the game cannot end in finite iterations, they call it a bad game. Can You help them figure out before they start playing if the game will be good or bad?

Input

The first line of input contains two integer numbers n and k (1 ≤ n ≤ 10^{9}, 0 ≤ k ≤ 2⋅10^5), where n denotes total number of pirates and k is the number of pirates that have any coins.

The next k lines of input contain integers a_i and b_i (1 ≤ a_i ≤ n, 1 ≤ b_i ≤ 10^{9}), where a_i denotes the index of the pirate sitting at the round table (n and 1 are neighbours) and b_i the total number of coins that pirate a_i has at the start of the game.

Output

Print 1 if the game is a good game: There is a way to do the splitting so the game ends after finite number of iterations.

Print -1 if the game is a bad game: No matter how You do the splitting the game does not end in finite number of iterations.

Examples

Input

4 2
1 2
2 2

Output

1

Input

6 2
2 3
4 1

Output

1

Input

3 2
1 1
2 2

Output

-1

Note

In the third example the game has no end, because You always only have only one candidate, after whose splitting you end up in the same position as the starting one.

### Response

```cpp
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
std::mt19937 rnd(
    std::chrono::high_resolution_clock::now().time_since_epoch().count());
const double PI = atan2(0.0, -1.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
void run() {
  int n, k;
  scanf("%d%d", &n, &k);
  ll sum1 = 0, sum2 = 0;
  ll sum = 0;
  sum1 = 1ll * n * (n - 1) / 2;
  while (k--) {
    int pos, val;
    scanf("%d%d", &pos, &val);
    sum += val;
    sum2 += 1ll * (pos - 1) * val;
  }
  if (sum > n) {
    printf("-1\n");
  } else if (sum < n) {
    printf("1\n");
  } else {
    if (sum1 % n != sum2 % n) {
      printf("-1\n");
    } else {
      printf("1\n");
    }
  }
}
int main(void) {
  auto start = std::chrono::high_resolution_clock::now();
  run();
  auto end = std::chrono::high_resolution_clock::now();
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

We have N+M balls, each of which has an integer written on it.
It is known that:

* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.

Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.

Constraints

* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M

Output

Print the answer.

Examples

Input

2 1

Output

1

Input

4 3

Output

9

Input

1 1

Output

0

Input

13 3

Output

81

Input

0 3

Output

3

### Response

```cpp
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int s=a*(a-1)/2+b*(b-1)/2;
	printf("%d",s);
}
```


### Prompt

Construct a CPP code solution to the problem outlined:

AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.

Constraints

* 1 ≤ a,b ≤ 100
* a and b are integers.

Input

Input is given from Standard Input in the following format:

a b

Output

If the concatenation of a and b in this order is a square number, print `Yes`; otherwise, print `No`.

Examples

Input

1 21

Output

Yes

Input

100 100

Output

No

Input

12 10

Output

No

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
string a,b,c;
int n;
int main()
{
	cin>>a>>b;
	c+=a;
	c+=b;
	n=atol(c.c_str());
	for (int i=1;i<=sqrt(n);i++)
	if (i*i==n)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}
```


### Prompt

Generate a Cpp solution to the following problem:

The Little Elephant very much loves sums on intervals.

This time he has a pair of integers l and r (l ≤ r). The Little Elephant has to find the number of such integers x (l ≤ x ≤ r), that the first digit of integer x equals the last one (in decimal notation). For example, such numbers as 101, 477474 or 9 will be included in the answer and 47, 253 or 1020 will not.

Help him and count the number of described numbers x for a given pair l and r.

Input

The single line contains a pair of integers l and r (1 ≤ l ≤ r ≤ 1018) — the boundaries of the interval.

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

Output

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

Examples

Input

2 47

Output

12

Input

47 1024

Output

98

Note

In the first sample the answer includes integers 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long p(long long l) {
  if (l < 10) return l;
  long long f, t, ret;
  t = l % 10;
  f = l;
  while (f >= 10) f /= 10;
  ret = l / 10 + 9;
  if (t < f) ret--;
  return ret;
}
int main() {
  long long l, r;
  cin >> l >> r;
  cout << p(r) - p(l - 1) << endl;
  return 0;
}

```


### Prompt

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

Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every a and b such that 1 ≤ a ≤ b ≤ 6, there is exactly one domino with a dots on one half and b dots on the other half. The set contains exactly 21 dominoes. Here is an exact illustration of his set:

<image>

Also, Anadi has an undirected graph without self-loops and multiple edges. He wants to choose some dominoes and place them on the edges of this graph. He can use at most one domino of each type. Each edge can fit at most one domino. It's not necessary to place a domino on each edge of the graph.

When placing a domino on an edge, he also chooses its direction. In other words, one half of any placed domino must be directed toward one of the endpoints of the edge and the other half must be directed toward the other endpoint. There's a catch: if there are multiple halves of dominoes directed toward the same vertex, each of these halves must contain the same number of dots.

How many dominoes at most can Anadi place on the edges of his graph?

Input

The first line contains two integers n and m (1 ≤ n ≤ 7, 0 ≤ m ≤ (n⋅(n-1))/(2)) — the number of vertices and the number of edges in the graph.

The next m lines contain two integers each. Integers in the i-th line are a_i and b_i (1 ≤ a, b ≤ n, a ≠ b) and denote that there is an edge which connects vertices a_i and b_i.

The graph might be disconnected. It's however guaranteed that the graph doesn't contain any self-loops, and that there is at most one edge between any pair of vertices.

Output

Output one integer which denotes the maximum number of dominoes which Anadi can place on the edges of the graph.

Examples

Input

4 4
1 2
2 3
3 4
4 1

Output

4

Input

7 0

Output

0

Input

3 1
1 3

Output

1

Input

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

Output

16

Note

Here is an illustration of Anadi's graph from the first sample test:

<image>

And here is one of the ways to place a domino on each of its edges:

<image>

Note that each vertex is faced by the halves of dominoes with the same number of dots. For instance, all halves directed toward vertex 1 have three dots.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
pair<int, int> G[21];
int n, m, a, b;
int v[7];
int cal() {
  set<pair<int, int> > s;
  for (int i = 0; i < m; i++) {
    a = v[G[i].first];
    b = v[G[i].second];
    if (a > b) {
      swap(a, b);
    }
    s.insert(pair<int, int>(a, b));
  }
  return s.size();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    G[i] = pair<int, int>(a, b);
  }
  int ans = 0;
  if (n == 7) {
    for (int i = 1; i < 7; i++) {
      for (int j = 0; j < 7; j++) {
        if (j >= i) {
          v[j] = j - 1;
        } else {
          v[j] = j;
        }
      }
      do {
        ans = max(ans, cal());
      } while (next_permutation(v, v + n));
    }
  } else {
    for (int i = 0; i < n; i++) {
      v[i] = i;
    }
    do {
      ans = max(ans, cal());
    } while (next_permutation(v, v + n));
  }
  cout << ans << '\n';
  return 0;
}

```


### Prompt

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

The competitors of Bubble Cup X gathered after the competition and discussed what is the best way to get to know the host country and its cities.

After exploring the map of Serbia for a while, the competitors came up with the following facts: the country has V cities which are indexed with numbers from 1 to V, and there are E bi-directional roads that connect the cites. Each road has a weight (the time needed to cross that road). There are N teams at the Bubble Cup and the competitors came up with the following plan: each of the N teams will start their journey in one of the V cities, and some of the teams share the starting position.

They want to find the shortest time T, such that every team can move in these T minutes, and the number of different cities they end up in is at least K (because they will only get to know the cities they end up in). A team doesn't have to be on the move all the time, if they like it in a particular city, they can stay there and wait for the time to pass.

Please help the competitors to determine the shortest time T so it's possible for them to end up in at least K different cities or print -1 if that is impossible no matter how they move.

Note that there can exist multiple roads between some cities.

Input

The first line contains four integers: V, E, N and K (1 ≤ V ≤ 600, 1 ≤ E ≤ 20000, 1 ≤ N ≤ min(V, 200), 1 ≤ K ≤ N), number of cities, number of roads, number of teams and the smallest number of different cities they need to end up in, respectively.

The second line contains N integers, the cities where the teams start their journey.

Next E lines contain information about the roads in following format: Ai Bi Ti (1 ≤ Ai, Bi ≤ V, 1 ≤ Ti ≤ 10000), which means that there is a road connecting cities Ai and Bi, and you need Ti minutes to cross that road.

Output

Output a single integer that represents the minimal time the teams can move for, such that they end up in at least K different cities or output -1 if there is no solution.

If the solution exists, result will be no greater than 1731311.

Example

Input

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

Output

3

Note

Three teams start from city 5, and two teams start from city 2. If they agree to move for 3 minutes, one possible situation would be the following: Two teams in city 2, one team in city 5, one team in city 3 , and one team in city 1. And we see that there are four different cities the teams end their journey at.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, s, k, x, y, z, S, T, sl, fh, st[1010], cur[1010], dep[1010],
    f[610][610];
int t, head[1010], to[1000010], nxt[1000010], val[1000010];
queue<int> q;
int rd() {
  sl = 0;
  fh = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') sl = sl * 10 + ch - '0', ch = getchar();
  return sl * fh;
}
void add(int u, int v, int w) {
  to[t] = v;
  val[t] = w;
  nxt[t] = head[u];
  head[u] = t++;
}
bool bfs() {
  while (!q.empty()) q.pop();
  memset(dep, 0, sizeof(dep));
  q.push(S);
  dep[S] = 1;
  int u, v;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (int i = head[u]; i != -1; i = nxt[i])
      if (!dep[v = to[i]] && val[i] > 0) {
        dep[v] = dep[u] + 1;
        if (v == T) return 1;
        q.push(v);
      }
  }
  return 0;
}
int dfs(int u, int f) {
  if (f <= 0) return 0;
  if (u == T) return f;
  int v, q = 0, tmp;
  for (int &i = cur[u]; i != -1; i = nxt[i])
    if (dep[v = to[i]] == dep[u] + 1) {
      tmp = dfs(v, min(f, val[i]));
      if (!tmp) continue;
      f -= tmp;
      q += tmp;
      val[i] -= tmp;
      val[i ^ 1] += tmp;
      if (!f) return q;
    }
  return q;
}
bool check(int len) {
  memset(head, -1, sizeof(head));
  t = 0;
  for (int i = 1; i <= s; ++i) add(S, i, 1), add(i, S, 0);
  for (int i = 1; i <= n; ++i) add(s + i, T, 1), add(T, s + i, 0);
  for (int i = 1; i <= s; ++i)
    for (int j = 1; j <= n; ++j)
      if (f[st[i]][j] <= len) add(i, j + s, 1), add(j + s, i, 0);
  int sum, ans = 0;
  while (bfs()) {
    for (int i = 0; i <= s + n + 1; ++i) cur[i] = head[i];
    while (sum = dfs(S, 0x7fffffff)) ans += sum;
  }
  return ans >= k;
}
int main() {
  n = rd();
  m = rd();
  s = rd();
  k = rd();
  memset(f, 127 / 3, sizeof(f));
  for (int i = 1; i <= s; ++i) st[i] = rd();
  for (int i = 1; i <= m; ++i) {
    x = rd();
    y = rd();
    z = rd();
    f[x][y] = f[y][x] = min(f[x][y], z);
  }
  for (int i = 1; i <= n; ++i) f[i][i] = 0;
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      if (i != k)
        for (int j = 1; j <= n; ++j)
          if (i != j && j != k) f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
  int mid, ans = -1, l = 0, r = 1731311;
  S = 0, T = s + n + 1;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (check(mid))
      r = mid - 1, ans = mid;
    else
      l = mid + 1;
  }
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.

Constraints

* 0 < a, b ≤ 2,000,000,000
* LCM(a, b) ≤ 2,000,000,000
* The number of data sets ≤ 50

Input

Input consists of several data sets. Each data set contains a and b separated by a single space in a line. The input terminates with EOF.

Output

For each data set, print GCD and LCM separated by a single space in a line.

Example

Input

8 6
50000000 30000000

Output

2 24
10000000 150000000

### Response

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

long long GCD(long long X, long long Y) {
	if (Y == 0) return X;
	return GCD(Y, X % Y);
}

int main() {
	long long A, B;
	while (cin >> A >> B) {
		cout << GCD(A, B) << " " << A * (B / GCD(A, B)) << endl;
	}
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Snuke has a string x of length N. Initially, every character in x is `0`.

Snuke can do the following two operations any number of times in any order:

* Choose A consecutive characters in x and replace each of them with `0`.
* Choose B consecutive characters in x and replace each of them with `1`.

Find the number of different strings that x can be after Snuke finishes doing operations. This count can be enormous, so compute it modulo (10^9+7).

Constraints

* 1 \leq N \leq 5000
* 1 \leq A,B \leq N
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the number of different strings that x can be after Snuke finishes doing operations, modulo (10^9+7).

Examples

Input

4 2 3

Output

11

Input

10 7 2

Output

533

Input

1000 100 10

Output

828178524

### Response

```cpp
#include <iostream>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int add(int a, int b)
{
	int c=a+b;
	if(c>=mod)c-=mod;
	return c;
}
int dif(int a, int b)
{
	int c=a-b;
	if(c<0)c+=mod;
	return c;
}
int mlt(int a, int b)
{
	long long c=a*1LL*b;
	return c%mod;
}
int bp(int a, int b)
{
	if(b==0)return 1;
	if(b%2==0)
	{
		int val=bp(a, b/2);
		return mlt(val, val);
	}
	if(b%2==1)
	{
		int val=bp(a, b-1);
		return mlt(val, a);
	}
}
int inv(int a)
{
	return bp(a, mod-2);
}
void outp(vector<vector<int>>&v)
{
	for(int i=0; i<v.size(); i++)
	{
		for(int j=0; j<v[i].size(); j++)cout<<v[i][j]<<' ';
		cout<<endl;
	}
	cout<<endl;
}
int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	if (a > b)
	{
		int c = a;
		a = b;
		b = c;
	}
	vector<vector<int>> dpa(n + 1, vector<int>(n + 1)),
			dpb(n + 1, vector<int>(n + 1));
	dpb[0][0]=1;
	for(int i=1; i<=n; i++)
	{
		for(int j=max(0, i-b+1); j<i; j++)
		{
			if(i>=j+a)
			{
				if (i >= a)
				{
					dpa[i][j] = add(dpa[i - 1][j], dpb[i - a][j]);
				}
				else dpa[i][j] = dpa[i - 1][j];
			}
			dpb[i][j] = add(dpa[i - 1][j], dpb[i - 1][j]);
		}
		dpa[i][i]=dpa[i-1][i-1];
		for(int j=i-1; j>=0; j--)dpa[i][i]=add(dpa[i][i], dpb[i-1][j]);
		if(i>=a)
		{
			for (int j = i - a; j >= 0; j--)
			{
				dpa[i][i] = dif(dpa[i][i], dpb[i - a][j]);
			}
		}
	}
	for(int i=1; i<=n; i++)
	{
		for(int j=0; j<=n; j++)
		{
	//		cout<<i<<' '<<j<<' '<<dpa[i][j]<<' '<<dpb[i][j]<<endl;
		}
	}
	int ans=bp(2, n);
	for(int i=0; i<=n; i++)
	{
		ans=dif(ans, dpa[n][i]);
		ans=dif(ans, dpb[n][i]);
	}
	if(a>1)
	{
		cout << ans << endl;
	}
	else cout<<bp(2,n)<<endl;
}
```


### Prompt

Develop a solution in CPP to the problem described below:

ZS the Coder has a large tree. It can be represented as an undirected connected graph of n vertices numbered from 0 to n - 1 and n - 1 edges between them. There is a single nonzero digit written on each edge.

One day, ZS the Coder was bored and decided to investigate some properties of the tree. He chose a positive integer M, which is coprime to 10, i.e. <image>.

ZS consider an ordered pair of distinct vertices (u, v) interesting when if he would follow the shortest path from vertex u to vertex v and write down all the digits he encounters on his path in the same order, he will get a decimal representaion of an integer divisible by M.

Formally, ZS consider an ordered pair of distinct vertices (u, v) interesting if the following states true:

  * Let a1 = u, a2, ..., ak = v be the sequence of vertices on the shortest path from u to v in the order of encountering them;
  * Let di (1 ≤ i < k) be the digit written on the edge between vertices ai and ai + 1;
  * The integer <image> is divisible by M.

Help ZS the Coder find the number of interesting pairs!

Input

The first line of the input contains two integers, n and M (2 ≤ n ≤ 100 000, 1 ≤ M ≤ 109, <image>) — the number of vertices and the number ZS has chosen respectively.

The next n - 1 lines contain three integers each. i-th of them contains ui, vi and wi, denoting an edge between vertices ui and vi with digit wi written on it (0 ≤ ui, vi < n, 1 ≤ wi ≤ 9).

Output

Print a single integer — the number of interesting (by ZS the Coder's consideration) pairs.

Examples

Input

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

Output

7

Input

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

Output

8

Note

In the first sample case, the interesting pairs are (0, 4), (1, 2), (1, 5), (3, 2), (2, 5), (5, 2), (3, 5). The numbers that are formed by these pairs are 14, 21, 217, 91, 7, 7, 917 respectively, which are all multiples of 7. Note that (2, 5) and (5, 2) are considered different.

<image>

In the second sample case, the interesting pairs are (4, 0), (0, 4), (3, 2), (2, 3), (0, 1), (1, 0), (4, 1), (1, 4), and 6 of these pairs give the number 33 while 2 of them give the number 3333, which are all multiples of 11.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
struct Edge {
  int v, d;
};
vector<Edge> edge[N];
map<int, int> cnt;
bool centroid[N];
int sz[N];
int up[N];
int pw[N], ipw[N];
int n, m;
long long ans;
int pow_mod(int x, int n) {
  int ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = (long long)ret * x % m;
    x = (long long)x * x % m;
  }
  return ret;
}
int Phi(int n) {
  int ret = n, m = (int)sqrt(n + 0.5);
  for (int i = 2; i <= m; ++i) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      ret = ret / i * (i - 1);
    }
  }
  if (n > 1) ret = ret / n * (n - 1);
  return ret;
}
void init() {
  int phi = Phi(m);
  pw[0] = ipw[0] = 1;
  for (int i = 1; i <= 100000; ++i) {
    pw[i] = (long long)pw[i - 1] * 10 % m;
    ipw[i] = pow_mod(pw[i], phi - 1);
  }
}
void DFS_size(int u, int fa = -1) {
  sz[u] = 1;
  for (auto it : edge[u])
    if (!(it.v == fa || centroid[it.v])) {
      DFS_size(it.v, u);
      sz[u] += sz[it.v];
    }
}
pair<int, int> DFS_centroid(int u, int fa, int t) {
  pair<int, int> ret = pair<int, int>(INT_MAX, -1);
  int mx = 0, s = 1;
  for (auto it : edge[u])
    if (!(it.v == fa || centroid[it.v])) {
      ret = min(ret, DFS_centroid(it.v, u, t));
      mx = max(mx, sz[it.v]);
      s += sz[it.v];
    }
  mx = max(mx, t - s);
  ret = min(ret, pair<int, int>(mx, u));
  return ret;
}
bool rev;
void DFS_digit_up(int u, int fa, int len) {
  if (!rev && !up[u]) ans++;
  if (cnt.count(up[u])) ans += cnt[up[u]];
  for (auto it : edge[u])
    if (!(it.v == fa || centroid[it.v])) {
      up[it.v] = ((long long)it.d * pw[len] % m + up[u]) % m;
      DFS_digit_up(it.v, u, len + 1);
    }
}
void DFS_digit_down(int u, int fa, int d, int len) {
  if (!rev && !d) ans++;
  int x = (long long)(m - d) * ipw[len] % m;
  cnt[x]++;
  for (auto it : edge[u])
    if (!(it.v == fa || centroid[it.v])) {
      DFS_digit_down(it.v, u, ((long long)d * 10 % m + it.d) % m, len + 1);
    }
}
void DFS(int u) {
  DFS_size(u);
  int s = DFS_centroid(u, -1, sz[u]).second;
  centroid[s] = true;
  for (auto it : edge[s])
    if (!centroid[it.v]) DFS(it.v);
  cnt.clear();
  rev = false;
  for (int v, i = 0; i < edge[s].size(); ++i)
    if (!centroid[v = edge[s][i].v]) {
      up[v] = edge[s][i].d;
      DFS_digit_up(v, s, 1);
      DFS_digit_down(v, s, edge[s][i].d, 1);
    }
  cnt.clear();
  rev = true;
  for (int v, i = (int)edge[s].size() - 1; i >= 0; --i)
    if (!centroid[v = edge[s][i].v]) {
      up[v] = edge[s][i].d;
      DFS_digit_up(v, s, 1);
      DFS_digit_down(v, s, edge[s][i].d, 1);
    }
  centroid[s] = false;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  init();
  for (int i = 1; i < n; ++i) {
    int u, v, d;
    cin >> u >> v >> d;
    d %= m;
    edge[u].push_back(Edge{v, d});
    edge[v].push_back(Edge{u, d});
  }
  DFS(0);
  cout << ans << '\n';
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Nikola owns a large warehouse which is illuminated by N light bulbs, numbered 1 to N. At the exit of the warehouse, there are S light switches, numbered 1 to S. Each switch swaps the on/off state for some light bulbs, so if a light bulb is off, flipping the switch turns it on, and if the light bulb is on, flipping the switch turns it off.

At the end of the day, Nikola wants to turn all the lights off. To achieve this, he will flip some of the light switches at the exit of the warehouse, but since Nikola is lazy, he wants to flip the _minimum_ number of switches required to turn all the lights off. Since Nikola was not able to calculate the minimum number of switches, he asked you to help him. During a period of D days, Nikola noted which light bulbs were off and which were on at the end of each day. He wants you to tell him the minimum number of switches he needed to flip to turn all the lights off for each of the D days or tell him that it's impossible.

Input

First line contains three integers, N, S and D (1 ≤ N ≤ 10^3, 1 ≤ S ≤ 30, 1 ≤ D ≤ 10^3) – representing number of light bulbs, the number of light switches, and the number of days respectively.

The next S lines contain the description of each light switch as follows: The first number in the line, C_i (1 ≤ C_i ≤ N), represents the number of light bulbs for which the on/off state is swapped by light switch i, the next C_i numbers (sorted in increasing order) represent the indices of those light bulbs.

The next D lines contain the description of light bulbs for each day as follows: The first number in the line, T_i (1 ≤ T_i ≤ N), represents the number of light bulbs which are on at the end of day i, the next T_i numbers (sorted in increasing order) represent the indices of those light bulbs.

Output

Print D lines, one for each day. In the i^{th} line, print the minimum number of switches that need to be flipped on day i, or -1 if it's impossible to turn all the lights off.

Example

Input

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

Output

2
2
3
-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
const long long INF = 1e18;
const int MAX = 1005;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand(long long a, long long b) {
  return uniform_int_distribution<long long>(a, b)(rng);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, s, d;
  cin >> n >> s >> d;
  long long hash[n], sw[s];
  for (int i = 0; i < n; i++) hash[i] = rand(1, INF);
  for (int i = 0; i < s; i++) {
    int k;
    cin >> k;
    sw[i] = 0;
    while (k--) {
      int x;
      cin >> x;
      sw[i] ^= hash[x - 1];
    }
  }
  unordered_map<long long, int, custom_hash> left_sz;
  int left = min(s / 2, 10);
  for (int mask = 0; mask < (1 << left); mask++) {
    long long cur = 0;
    for (int bit = 0; bit < left; bit++) {
      if (!((mask >> bit) & 1)) continue;
      cur ^= sw[bit];
    }
    if (!left_sz.count(cur))
      left_sz[cur] = __builtin_popcountll(mask);
    else
      left_sz[cur] = min(left_sz[cur], __builtin_popcountll(mask));
  }
  unordered_map<long long, int, custom_hash> right_sz;
  int right = s - left;
  for (int mask = 0; mask < (1 << right); mask++) {
    long long cur = 0;
    for (int bit = 0; bit < right; bit++) {
      if (!((mask >> bit) & 1)) continue;
      cur ^= sw[bit + left];
    }
    if (!right_sz.count(cur))
      right_sz[cur] = __builtin_popcountll(mask);
    else
      right_sz[cur] = min(right_sz[cur], __builtin_popcountll(mask));
  }
  while (d--) {
    long long cur = 0;
    int sz;
    cin >> sz;
    for (int i = 0; i < sz; i++) {
      int x;
      cin >> x;
      cur ^= hash[x - 1];
    }
    int ans = 100;
    for (auto p : left_sz) {
      long long tmp = cur ^ p.first;
      if (right_sz.count(tmp)) ans = min(ans, p.second + right_sz[tmp]);
      if (left_sz.count(tmp)) {
        if (tmp == p.first)
          ans = 0;
        else
          ans = min(ans, p.second + left_sz[tmp]);
      }
    }
    cout << (ans == 100 ? -1 : ans) << "\n";
  }
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

You are given an array a consisting of n integers, and additionally an integer m. You have to choose some sequence of indices b1, b2, ..., bk (1 ≤ b1 < b2 < ... < bk ≤ n) in such a way that the value of <image> is maximized. Chosen sequence can be empty.

Print the maximum possible value of <image>.

Input

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

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Output

Print the maximum possible value of <image>.

Examples

Input

4 4
5 2 4 1

Output

3

Input

3 20
199 41 299

Output

19

Note

In the first example you can choose a sequence b = {1, 2}, so the sum <image> is equal to 7 (and that's 3 after taking it modulo 4).

In the second example you can choose a sequence b = {3}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, a;
  scanf("%lld %lld", &n, &m);
  vector<long long> a1, a2;
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &a);
    a %= m;
    if (i % 2)
      a2.push_back(a);
    else
      a1.push_back(a);
  }
  long long i, j, sum;
  set<long long> s1, s2;
  n = a1.size();
  for (i = 0; i < (1 << n); i++) {
    sum = 0;
    for (j = n - 1; j >= 0; j--) {
      if (i & (1 << j)) sum += a1[j];
    }
    s1.insert(sum % m);
  }
  n = a2.size();
  for (i = 0; i < (1 << n); i++) {
    sum = 0;
    for (j = n - 1; j >= 0; j--) {
      if (i & (1 << j)) sum += a2[j];
    }
    s2.insert(sum % m);
  }
  set<long long>::iterator it, pt;
  long long ans = 0;
  for (it = s1.begin(); it != s1.end(); it++) {
    sum = *it;
    pt = s2.lower_bound(m - sum);
    pt--;
    ans = max(ans, (sum + *pt) % m);
    pt = s2.end();
    pt--;
    ans = max(ans, (sum + *pt) % m);
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is "Squares". Today we are visiting his studio to see how his masterpieces are given birth.

At the center of his studio, there is a huuuuuge table and beside it are many, many squares of the same size. Pablo Squarson puts one of the squares on the table. Then he places some other squares on the table in sequence. It seems his methodical nature forces him to place each square side by side to the one that he already placed on, with machine-like precision.

Oh! The first piece of artwork is done. Pablo Squarson seems satisfied with it. Look at his happy face.

Oh, what's wrong with Pablo? He is tearing his hair! Oh, I see. He wants to find a box that fits the new piece of work but he has trouble figuring out its size. Let's help him!

Your mission is to write a program that takes instructions that record how Pablo made a piece of his artwork and computes its width and height. It is known that the size of each square is 1. You may assume that Pablo does not put a square on another.

I hear someone murmured "A smaller box will do". No, poor Pablo, shaking his head, is grumbling "My square style does not seem to be understood by illiterates".

<image>

Input

The input consists of a number of datasets. Each dataset represents the way Pablo made a piece of his artwork. The format of a dataset is as follows.

> N
n1 d1
n2 d2
...
nN-1 dN-1

The first line contains the number of squares (= N) used to make the piece of artwork. The number is a positive integer and is smaller than 200.

The remaining (N-1) lines in the dataset are square placement instructions. The line "ni di" indicates placement of the square numbered i (≤ N-1). The rules of numbering squares are as follows. The first square is numbered "zero". Subsequently placed squares are numbered 1, 2, ..., (N-1). Note that the input does not give any placement instruction to the first square, which is numbered zero.

A square placement instruction for the square numbered i, namely "ni di", directs it to be placed next to the one that is numbered ni, towards the direction given by di, which denotes leftward (= 0), downward (= 1), rightward (= 2), and upward (= 3).

For example, pieces of artwork corresponding to the four datasets shown in Sample Input are depicted below. Squares are labeled by their numbers.

<image>

The end of the input is indicated by a line that contains a single zero.

Output

For each dataset, output a line that contains the width and the height of the piece of artwork as decimal numbers, separated by a space. Each line should not contain any other characters.

Sample Input

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

Output for the Sample Input

1 1
3 3
4 4
5 6

Example

Input

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

Output

1 1
3 3
4 4
5 6

### Response

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

int main(void){
	while(1){
		int n;
		cin>>n;
		if(n == 0) break;

		int x[n],y[n];
		x[0] = y[0] = 0;
		int minX=0,minY=0,maxX=0,maxY=0;

		for(int i=1;i<n;i++){
			int a,b;
			cin>>a>>b;

			//ツ債カツ堕、
			if(b == 0){
				x[i] = x[a] - 1;
				y[i] = y[a];
			}
			//ツ可コツ堕、
			else if(b == 1){
				x[i] = x[a];
				y[i] = y[a] - 1;
			}
			//ツ右ツ堕、
			else if(b == 2){
				x[i] = x[a] + 1;
				y[i] = y[a];
			}
			//ツ湘」ツ堕、
			else if(b == 3){
				x[i] = x[a];
				y[i] = y[a] + 1;
			}

			if(minX > x[i]) minX = x[i];
			if(minY > y[i]) minY = y[i];
			if(maxX < x[i]) maxX = x[i];
			if(maxY < y[i]) maxY = y[i];
		}
		cout<<maxX - minX + 1<<" "<<maxY - minY + 1<<endl;
	}

	return 0;
}
```


### Prompt

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

One day Polycarpus got hold of two non-empty strings s and t, consisting of lowercase Latin letters. Polycarpus is quite good with strings, so he immediately wondered, how many different pairs of "x y" are there, such that x is a substring of string s, y is a subsequence of string t, and the content of x and y is the same. Two pairs are considered different, if they contain different substrings of string s or different subsequences of string t. Read the whole statement to understand the definition of different substrings and subsequences.

The length of string s is the number of characters in it. If we denote the length of the string s as |s|, we can write the string as s = s1s2... s|s|.

A substring of s is a non-empty string x = s[a... b] = sasa + 1... sb (1 ≤ a ≤ b ≤ |s|). For example, "code" and "force" are substrings or "codeforces", while "coders" is not. Two substrings s[a... b] and s[c... d] are considered to be different if a ≠ c or b ≠ d. For example, if s="codeforces", s[2...2] and s[6...6] are different, though their content is the same.

A subsequence of s is a non-empty string y = s[p1p2... p|y|] = sp1sp2... sp|y| (1 ≤ p1 < p2 < ... < p|y| ≤ |s|). For example, "coders" is a subsequence of "codeforces". Two subsequences u = s[p1p2... p|u|] and v = s[q1q2... q|v|] are considered different if the sequences p and q are different.

Input

The input consists of two lines. The first of them contains s (1 ≤ |s| ≤ 5000), and the second one contains t (1 ≤ |t| ≤ 5000). Both strings consist of lowercase Latin letters.

Output

Print a single number — the number of different pairs "x y" such that x is a substring of string s, y is a subsequence of string t, and the content of x and y is the same. As the answer can be rather large, print it modulo 1000000007 (109 + 7).

Examples

Input

aa
aa

Output

5

Input

codeforces
forceofcode

Output

60

Note

Let's write down all pairs "x y" that form the answer in the first sample: "s[1...1] t[1]", "s[2...2] t[1]", "s[1...1] t[2]","s[2...2] t[2]", "s[1...2] t[1 2]".

### Response

```cpp
#include <bits/stdc++.h>
int c[5001][5001] = {0};
const int mod = 1000000007;
int main() {
  char s[5000 + 1], t[5000 + 1];
  scanf("%s%s", s, t);
  int sl = strlen(s), tl = strlen(t);
  c[0][0] = (s[0] == t[0]);
  for (int j = 1; j < tl; j++)
    if (s[0] == t[j])
      c[0][j] = c[0][j - 1] + 1;
    else
      c[0][j] = c[0][j - 1];
  for (int i = 1; i < sl; i++) {
    if (s[i] == t[0])
      c[i][0] = 1;
    else
      c[i][0] = 0;
    for (int j = 1; j < tl; j++)
      if (s[i] == t[j])
        c[i][j] = (c[i - 1][j - 1] + c[i][j - 1] + 1) % mod;
      else
        c[i][j] = c[i][j - 1];
  }
  int r = 0;
  for (int i = 0; i < sl; i++) r = (r + c[i][tl - 1]) % mod;
  printf("%d\n", r);
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

There are three airports A, B and C, and flights between each pair of airports in both directions.

A one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours.

Consider a route where we start at one of the airports, fly to another airport and then fly to the other airport.

What is the minimum possible sum of the flight times?

Constraints

* 1 \leq P,Q,R \leq 100
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

P Q R

Output

Print the minimum possible sum of the flight times.

Examples

Input

1 3 4

Output

4

Input

3 2 3

Output

5

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,x;
	cin>>a>>b>>c;
	x=a+b+c;
	cout<<x-max(a,max(b,c));
	return 0;
}
```


### Prompt

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

There is a bookshelf which can fit n books. The i-th position of bookshelf is a_i = 1 if there is a book on this position and a_i = 0 otherwise. It is guaranteed that there is at least one book on the bookshelf.

In one move, you can choose some contiguous segment [l; r] consisting of books (i.e. for each i from l to r the condition a_i = 1 holds) and:

  * Shift it to the right by 1: move the book at index i to i + 1 for all l ≤ i ≤ r. This move can be done only if r+1 ≤ n and there is no book at the position r+1.
  * Shift it to the left by 1: move the book at index i to i-1 for all l ≤ i ≤ r. This move can be done only if l-1 ≥ 1 and there is no book at the position l-1.

Your task is to find the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without any gaps).

For example, for a = [0, 0, 1, 0, 1] there is a gap between books (a_4 = 0 when a_3 = 1 and a_5 = 1), for a = [1, 1, 0] there are no gaps between books and for a = [0, 0,0] there are also no gaps between books.

You have to answer t independent test cases.

Input

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

The first line of the test case contains one integer n (1 ≤ n ≤ 50) — the number of places on a bookshelf. The second line of the test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 1), where a_i is 1 if there is a book at this position and 0 otherwise. It is guaranteed that there is at least one book on the bookshelf.

Output

For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).

Example

Input

5
7
0 0 1 0 1 0 1
3
1 0 0
5
1 1 0 0 1
6
1 0 0 0 0 1
5
1 1 0 1 1

Output

2
0
2
4
1

Note

In the first test case of the example, you can shift the segment [3; 3] to the right and the segment [4; 5] to the right. After all moves, the books form the contiguous segment [5; 7]. So the answer is 2.

In the second test case of the example, you have nothing to do, all the books on the bookshelf form the contiguous segment already.

In the third test case of the example, you can shift the segment [5; 5] to the left and then the segment [4; 4] to the left again. After all moves, the books form the contiguous segment [1; 3]. So the answer is 2.

In the fourth test case of the example, you can shift the segment [1; 1] to the right, the segment [2; 2] to the right, the segment [6; 6] to the left and then the segment [5; 5] to the left. After all moves, the books form the contiguous segment [3; 4]. So the answer is 4.

In the fifth test case of the example, you can shift the segment [1; 2] to the right. After all moves, the books form the contiguous segment [2; 5]. So the answer is 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t, n;
  cin >> t;
  int a[100010];
  while (t--) {
    cin >> n;
    int ans = 0;
    bool one = false;
    int temp;
    for (int j = 0; j < n; j++) {
      cin >> a[j];
    }
    for (int i = 0; i < n; i++) {
      if (a[i] == 1 && one) {
        ans += (i - temp) - 1;
        temp = i;
      }
      if (a[i] == 1) {
        one = true;
        temp = i;
      }
    }
    cout << ans << endl;
  }
}

```


### Prompt

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

One department of some software company has n servers of different specifications. Servers are indexed with consecutive integers from 1 to n. Suppose that the specifications of the j-th server may be expressed with a single integer number c_j of artificial resource units.

In order for production to work, it is needed to deploy two services S_1 and S_2 to process incoming requests using the servers of the department. Processing of incoming requests of service S_i takes x_i resource units.

The described situation happens in an advanced company, that is why each service may be deployed using not only one server, but several servers simultaneously. If service S_i is deployed using k_i servers, then the load is divided equally between these servers and each server requires only x_i / k_i (that may be a fractional number) resource units.

Each server may be left unused at all, or be used for deploying exactly one of the services (but not for two of them simultaneously). The service should not use more resources than the server provides.

Determine if it is possible to deploy both services using the given servers, and if yes, determine which servers should be used for deploying each of the services.

Input

The first line contains three integers n, x_1, x_2 (2 ≤ n ≤ 300 000, 1 ≤ x_1, x_2 ≤ 10^9) — the number of servers that the department may use, and resource units requirements for each of the services.

The second line contains n space-separated integers c_1, c_2, …, c_n (1 ≤ c_i ≤ 10^9) — the number of resource units provided by each of the servers.

Output

If it is impossible to deploy both services using the given servers, print the only word "No" (without the quotes).

Otherwise print the word "Yes" (without the quotes).

In the second line print two integers k_1 and k_2 (1 ≤ k_1, k_2 ≤ n) — the number of servers used for each of the services.

In the third line print k_1 integers, the indices of the servers that will be used for the first service.

In the fourth line print k_2 integers, the indices of the servers that will be used for the second service.

No index may appear twice among the indices you print in the last two lines. If there are several possible answers, it is allowed to print any of them.

Examples

Input

6 8 16
3 5 2 9 8 7

Output

Yes
3 2
1 2 6
5 4

Input

4 20 32
21 11 11 12

Output

Yes
1 3
1
2 3 4

Input

4 11 32
5 5 16 16

Output

No

Input

5 12 20
7 8 4 11 9

Output

No

Note

In the first sample test each of the servers 1, 2 and 6 will will provide 8 / 3 = 2.(6) resource units and each of the servers 5, 4 will provide 16 / 2 = 8 resource units.

In the second sample test the first server will provide 20 resource units and each of the remaining servers will provide 32 / 3 = 10.(6) resource units.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, x1, x2, x;
  cin >> n >> x1 >> x2;
  vector<pair<int, int> > v(n);
  vector<pair<int, int> > ansa;
  vector<pair<int, int> > ansb;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    v[i] = pair<int, int>(x, i + 1);
  }
  bool swapped = false;
  if (x1 > x2) {
    swap(x1, x2);
    swapped = true;
  }
  bool poss = false;
  sort((v).begin(), (v).end());
  for (int i = 0; i < n; ++i) {
    int nec = (x1 - 1) / v[i].first + 1;
    if (nec <= n - i) {
      if (i + nec >= n) {
        if (i + nec < v.size() &&
            (x2 - 1) / v[i + nec].first + 1 <= v.size() - (i + nec)) {
          poss = true;
          for (int j = 0, k = i; j < nec; ++j, ++k) ansa.push_back(v[k]);
          for (int j = 0, k = i + nec; j < (x2 - 1) / v[i + nec].first + 1;
               ++j, ++k)
            ansb.push_back(v[k]);
          break;
        } else
          v.push_back(v[i]);
      } else {
        if ((x2 - 1) / v[i + nec].first + 1 <= n - (i + nec)) {
          poss = true;
          for (int j = 0, k = i; j < nec; ++j, ++k) ansa.push_back(v[k]);
          for (int j = 0, k = i + nec; j < (x2 - 1) / v[i + nec].first + 1;
               ++j, ++k)
            ansb.push_back(v[k]);
          break;
        } else
          v.push_back(v[i]);
      }
    }
  }
  if (poss) {
    cout << "Yes" << '\n';
    if (!swapped) {
      cout << ansa.size() << " " << ansb.size() << '\n';
      for (auto i : ansa) cout << i.second << " ";
      cout << '\n';
      for (auto i : ansb) cout << i.second << " ";
      cout << '\n';
    } else {
      cout << ansb.size() << " " << ansa.size() << '\n';
      for (auto i : ansb) cout << i.second << " ";
      cout << '\n';
      for (auto i : ansa) cout << i.second << " ";
      cout << '\n';
    }
  } else
    cout << "No" << '\n';
  return 0;
}

```


### Prompt

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

You are given a graph with n nodes and m directed edges. One lowercase letter is assigned to each node. We define a path's value as the number of the most frequently occurring letter. For example, if letters on a path are "abaca", then the value of that path is 3. Your task is find a path whose value is the largest.

Input

The first line contains two positive integers n, m (1 ≤ n, m ≤ 300 000), denoting that the graph has n nodes and m directed edges.

The second line contains a string s with only lowercase English letters. The i-th character is the letter assigned to the i-th node.

Then m lines follow. Each line contains two integers x, y (1 ≤ x, y ≤ n), describing a directed edge from x to y. Note that x can be equal to y and there can be multiple edges between x and y. Also the graph can be not connected.

Output

Output a single line with a single integer denoting the largest value. If the value can be arbitrarily large, output -1 instead.

Examples

Input

5 4
abaca
1 2
1 3
3 4
4 5

Output

3

Input

6 6
xzyabc
1 2
3 1
2 3
5 4
4 3
6 4

Output

-1

Input

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

Output

4

Note

In the first sample, the path with largest value is 1 → 3 → 4 → 5. The value is 3 because the letter 'a' appears 3 times.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int q, n;
long long int ans, sum;
long long int gcd(long long int a, long long int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long int powe(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = (res * a);
    }
    a = (a * a);
    b /= 2;
  }
  return res;
}
long long int power(long long int a, long long int b, long long int M) {
  a %= M;
  long long int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = (res * a) % M;
    }
    a = (a * a) % M;
    b /= 2;
  }
  return res;
}
long long int extendedEuclid(long long int A, long long int B, long long int &x,
                             long long int &y) {
  if (B == 0) {
    x = 1;
    y = 0;
    return A;
  } else {
    long long int x1, y1;
    long long int gcd = extendedEuclid(B, A % B, x1, y1);
    y = x1 - (A / B) * y1;
    x = y1;
    return gcd;
  }
}
long long int mi(long long int A, long long int M) {
  long long int x, y;
  extendedEuclid(A, M, x, y);
  if (x < 0) {
    x += (long long int)1000000007;
  }
  return x;
}
vector<bool> sieve(1000000, true);
void Sieve() {
  sieve[0] = false;
  sieve[1] = false;
  for (long long int i = 2; i * i <= 1000000; i++) {
    if (sieve[i] == true) {
      for (long long int j = i * i; j < 1000000; j += i) sieve[j] = false;
    }
  }
}
vector<long long int> sieve_spf;
void Sieve_spf() {
  const long long int n = 1e6 + 5;
  sieve_spf.resize(n);
  for (int i = 0; i < n; i++) sieve_spf[i] = i;
  sieve_spf[0] = -1;
  sieve_spf[1] = 1;
  for (int i = 2; i <= n; i += 2) sieve_spf[i] = 2;
  for (int i = 3; i <= n; i += 2)
    if (sieve_spf[i] == i)
      for (int j = i * i; j <= n; j += i)
        if (sieve_spf[j] == j) sieve_spf[j] = i;
}
bool isUpcase(char c) {
  if (c >= 'A' && c <= 'Z')
    return true;
  else
    return false;
}
bool islowcase(char c) {
  if (c >= 'a' && c <= 'z')
    return true;
  else
    return false;
}
void the_happiest_place_on_earth() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
}
bool comp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first > b.first)
    return true;
  else if (a.first == b.first && a.second < b.second)
    return true;
  else
    return false;
}
const int N = 310055;
long long int b[N], a[N], dis[N], p[N];
vector<int> graph[N], graph1[N];
bool vis[N];
int dag;
void gra(long long int m) {
  for (int i = 0; i < m; i++) {
    long long int x, y;
    cin >> x >> y;
    x--, y--;
    graph[x].push_back(y);
  }
}
string second;
long long int color[N], dp[N][30];
void dfs(int node) {
  vis[node] = true;
  color[node] = 1;
  for (auto x : graph[node]) {
    if (color[x] == 1) {
      cout << -1;
      exit(0);
    }
    if (!vis[x]) dfs(x);
    for (int i = 0; i < 26; i++) dp[node][i] = max(dp[node][i], dp[x][i]);
  }
  dp[node][second[node] - 'a']++;
  for (int i = 0; i < 26; i++) ans = max(dp[node][i], ans);
  color[node] = 0;
}
void testcase() {
  long long int m;
  cin >> n >> m >> second;
  gra(m);
  memset(color, 0, sizeof(color));
  for (int i = 0; i < n; i++)
    if (!vis[i]) dfs(i);
  cout << ans;
  return;
}
int main() {
  the_happiest_place_on_earth();
  q = 1;
  while (q--) {
    testcase();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

You are given a permutation p=[p_1, p_2, …, p_n] of integers from 1 to n. Let's call the number m (1 ≤ m ≤ n) beautiful, if there exists two indices l, r (1 ≤ l ≤ r ≤ n), such that the numbers [p_l, p_{l+1}, …, p_r] is a permutation of numbers 1, 2, …, m.

For example, let p = [4, 5, 1, 3, 2, 6]. In this case, the numbers 1, 3, 5, 6 are beautiful and 2, 4 are not. It is because:

  * if l = 3 and r = 3 we will have a permutation [1] for m = 1;
  * if l = 3 and r = 5 we will have a permutation [1, 3, 2] for m = 3;
  * if l = 1 and r = 5 we will have a permutation [4, 5, 1, 3, 2] for m = 5;
  * if l = 1 and r = 6 we will have a permutation [4, 5, 1, 3, 2, 6] for m = 6;
  * it is impossible to take some l and r, such that [p_l, p_{l+1}, …, p_r] is a permutation of numbers 1, 2, …, m for m = 2 and for m = 4.

You are given a permutation p=[p_1, p_2, …, p_n]. For all m (1 ≤ m ≤ n) determine if it is a beautiful number or not.

Input

The first line contains the only integer t (1 ≤ t ≤ 1000) — the number of test cases in the input. The next lines contain the description of test cases.

The first line of a test case contains a number n (1 ≤ n ≤ 2 ⋅ 10^5) — the length of the given permutation p. The next line contains n integers p_1, p_2, …, p_n (1 ≤ p_i ≤ n, all p_i are different) — the given permutation p.

It is guaranteed, that the sum of n from all test cases in the input doesn't exceed 2 ⋅ 10^5.

Output

Print t lines — the answers to test cases in the order they are given in the input.

The answer to a test case is the string of length n, there the i-th character is equal to 1 if i is a beautiful number and is equal to 0 if i is not a beautiful number.

Example

Input

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

Output

101011
11111
1001

Note

The first test case is described in the problem statement.

In the second test case all numbers from 1 to 5 are beautiful:

  * if l = 3 and r = 3 we will have a permutation [1] for m = 1;
  * if l = 3 and r = 4 we will have a permutation [1, 2] for m = 2;
  * if l = 2 and r = 4 we will have a permutation [3, 1, 2] for m = 3;
  * if l = 2 and r = 5 we will have a permutation [3, 1, 2, 4] for m = 4;
  * if l = 1 and r = 5 we will have a permutation [5, 3, 1, 2, 4] for m = 5.

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
const double PI = atan(1.0) * 4;
const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, -1, 0, 1};
const long long INF = (long long)2e18 + 50;
const int maximum = numeric_limits<int>::min();
const int minimum = numeric_limits<int>::max();
const long long mod = 1e9 + 7;
long long power(long long a, long long e) {
  long long res = 1LL;
  while (e > 0) {
    if (e % 2 == 1) res = res * a;
    a = a * a;
    e /= 2;
  }
  return res;
}
bool isBalanced(const string &exp) {
  bool flag = true;
  int count = 0;
  for (int i = 0; i < exp.length(); i++) {
    if (exp[i] == '(') {
      count++;
    } else {
      count--;
    }
    if (count < 0) {
      flag = false;
      break;
    }
  }
  if (count != 0) {
    flag = false;
  }
  return flag;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> pos(n);
    for (int i = 0; i < n; i++) {
      cin >> p[i];
      --p[i];
      pos[p[i]] = i;
    }
    int pos_max = -1, pos_min = n + 1;
    vector<int> res(n);
    for (int i = 0; i < n; i++) {
      pos_max = max(pos_max, pos[i]);
      pos_min = min(pos_min, pos[i]);
      if (pos_max - pos_min == i)
        res[i] = 1;
      else
        res[i] = 0;
    }
    for (auto i : res) {
      cout << i;
    }
    cout << "\n";
  }
  return 0;
}

```


### Prompt

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

Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?

The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out the name of the company on a piece of paper in a line (horizontally, from left to right) with large English letters, then put this piece of paper in front of the mirror, then the reflection of the name in the mirror should perfectly match the line written on the piece of paper.

There are many suggestions for the company name, so coming up to the mirror with a piece of paper for each name wouldn't be sensible. The founders of the company decided to automatize this process. They asked you to write a program that can, given a word, determine whether the word is a 'mirror' word or not.

Input

The first line contains a non-empty name that needs to be checked. The name contains at most 105 large English letters. The name will be written with the next sans serif font:

<image>

Output

Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes).

Examples

Input

AHA

Output

YES

Input

Z

Output

NO

Input

XO

Output

NO

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  map<char, int> m;
  m['A'] = 1;
  m['H'] = 1;
  m['I'] = 1;
  m['M'] = 1;
  m['O'] = 1;
  m['T'] = 1;
  m['U'] = 1;
  m['V'] = 1;
  m['W'] = 1;
  m['X'] = 1;
  m['Y'] = 1;
  string s1;
  for (int i = 0; i < s.size(); i++) {
    if (!(m.count(s[i]) > 0)) {
      cout << "NO" << endl;
      return 0;
    } else
      s1.push_back(s[i]);
  }
  string s2 = s1;
  reverse(s2.begin(), s2.end());
  if (s2 == s1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

A bitstring is a string that contains only the characters 0 and 1.

Koyomi Kanou is working hard towards her dream of becoming a writer. To practice, she decided to participate in the Binary Novel Writing Contest. The writing prompt for the contest consists of three bitstrings of length 2n. A valid novel for the contest is a bitstring of length at most 3n that contains at least two of the three given strings as subsequences.

Koyomi has just received the three prompt strings from the contest organizers. Help her write a valid novel for the contest.

A string a is a subsequence of a string b if a can be obtained from b by deletion of several (possibly, zero) characters.

Input

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

The first line of each test case contains a single integer n (1 ≤ n ≤ 10^5).

Each of the following three lines contains a bitstring of length 2n. It is guaranteed that these three strings are pairwise distinct.

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

Output

For each test case, print a single line containing a bitstring of length at most 3n that has at least two of the given bitstrings as subsequences.

It can be proven that under the constraints of the problem, such a bitstring always exists.

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

Example

Input

2
1
00
11
01
3
011001
111010
010001

Output

010
011001010

Note

In the first test case, the bitstrings 00 and 01 are subsequences of the output string: 010 and 010. Note that 11 is not a subsequence of the output string, but this is not required.

In the second test case all three input strings are subsequences of the output string: 011001010, 011001010 and 011001010.

### Response

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

using namespace std;

#define rep(i, j, k) for (LL i = j; i < k; ++i)
typedef long long int LL;

#define F first
#define S second

#define N 312345

string s[3];
int major_char_value[3];
int n;
vector<char> vec[N];

inline void match(int x, int y) {
    char major_char = (major_char_value[x] == 0 ? '0' : '1');
    rep (i, 0, n + 1) vec[i].clear();
    int id = 0;
    rep (i, 0, n + n) {
        if (id < n) {
            if (s[x][i] == major_char) {
                id++;
                continue;
            }
        }
        vec[id].push_back(s[x][i]);
    }
    id = 0;
    rep (i, 0, n + n) {
        if (id < n) {
            if (s[y][i] == major_char) {
                id++;
                continue;
            }
        }
        vec[id].push_back(s[y][i]);
    }
    rep (i, 0, n + 1) {
        rep (j, 0, vec[i].size()) cout << vec[i][j];
        if (i < n) cout << major_char;
    }
    cout << '\n';
}

inline void solve () {
    cin >> n;
    rep (i, 0, 3) {
        cin >> s[i];
        int zc = 0;
        rep (j, 0, n + n) if (s[i][j] == '0') zc++;
        if (zc >= n) {
            major_char_value[i] = 0;
        } else {
            major_char_value[i] = 1;
        }
    }
    if (major_char_value[0] == major_char_value[1]) {
        match(0, 1);
    } else if (major_char_value[0] == major_char_value[2]) {
        match(0, 2);
    } else {
        match(1, 2);
    }
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

The year of 2012 is coming...

According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave heroes have already gathered on the top of a mountain Arreat to protect us mere mortals from the effect of this terrible evil.

The seven great heroes are: amazon Anka, barbarian Chapay, sorceress Cleo, druid Troll, necromancer Dracul, paladin Snowy and a professional hit girl Hexadecimal. Heroes already know how much experience will be given for each of the three megabosses: a for Mephisto, b for Diablo and c for Baal.

Here's the problem: heroes are as much as seven and megabosses are only three! Then our heroes decided to split into three teams, where each team will go to destroy their own megaboss. Each team member will receive a <image> of experience, rounded down, where x will be the amount of experience for the killed megaboss and y — the number of people in the team.

Heroes do not want to hurt each other's feelings, so they want to split into teams so that the difference between the hero who received the maximum number of experience and the hero who received the minimum number of experience were minimal. Since there can be several divisions into teams, then you need to find the one in which the total amount of liking in teams were maximum.

It is known that some heroes like others. But if hero p likes hero q, this does not mean that the hero q likes hero p. No hero likes himself.

The total amount of liking in teams is the amount of ordered pairs (p, q), such that heroes p and q are in the same group, and hero p likes hero q (but it is not important if hero q likes hero p). In case of heroes p and q likes each other and they are in the same group, this pair should be counted twice, as (p, q) and (q, p).

A team can consist even of a single hero, but it is important that every megaboss was destroyed. All heroes must be involved in the campaign against evil. None of the heroes can be in more than one team.

It is guaranteed that every hero is able to destroy any megaboss alone.

Input

The first line contains a single non-negative integer n (0 ≤ n ≤ 42) — amount of liking between the heroes. Next n lines describe liking in the form "p likes q", meaning that the hero p likes the hero q (p ≠  q). Every liking is described in the input exactly once, no hero likes himself.

In the last line are given three integers a, b and c (1 ≤ a, b, c ≤ 2·109), separated by spaces: the experience for Mephisto, the experience for Diablo and experience for Baal.

In all the pretests, except for examples from the statement, the following condition is satisfied: a = b = c.

Output

Print two integers — the minimal difference in the experience between two heroes who will receive the maximum and minimum number of experience points, and the maximal total amount of liking in teams (the number of friendships between heroes that end up in one team).

When calculating the second answer, the team division should satisfy the difference-minimizing contraint. I.e. primary you should minimize the difference in the experience and secondary you should maximize the total amount of liking.

Examples

Input

3
Troll likes Dracul
Dracul likes Anka
Snowy likes Hexadecimal
210 200 180

Output

30 3

Input

2
Anka likes Chapay
Chapay likes Anka
10000 50 50

Output

1950 2

Note

A note to first example: it the first team should be Dracul, Troll and Anka, in the second one Hexadecimal and Snowy, and in the third Cleo и Chapay.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool like[10][10];
int main() {
  map<string, int> mp;
  mp["Anka"] = 1;
  mp["Chapay"] = 2;
  mp["Cleo"] = 3;
  mp["Troll"] = 4;
  mp["Dracul"] = 5;
  mp["Snowy"] = 6;
  mp["Hexadecimal"] = 7;
  int n, i, j, k, l, x, y;
  string str1, str2, str3;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> str1 >> str2 >> str3;
    like[mp[str1]][mp[str3]] = 1;
  }
  int a[5], b[5];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);
  int ans = 1e9;
  for (i = 1; i <= 5; i++)
    for (j = 1; j <= 5; j++) {
      k = 7 - i - j;
      b[0] = i;
      b[1] = j;
      b[2] = k;
      if (k <= 0) continue;
      sort(b, b + 3);
      int mx = 0, mn = 1e9;
      for (l = 0; l < 3; l++) {
        mn = min(mn, a[l] / b[l]);
        mx = max(mx, a[l] / b[l]);
      }
      if (mx - mn < ans) ans = mx - mn;
    }
  int ans2 = 0;
  for (i = 1; i <= 5; i++)
    for (j = 1; j <= 5; j++) {
      k = 7 - i - j;
      b[0] = i;
      b[1] = j;
      b[2] = k;
      sort(b, b + 3);
      if (k <= 0) continue;
      int mn1 = 1e9, mx1 = 0;
      for (l = 0; l < 3; l++) {
        mn1 = min(mn1, a[l] / b[l]);
        mx1 = max(mx1, a[l] / b[l]);
      }
      if (mx1 - mn1 == ans) {
        int arr[10];
        for (l = 0; l < 7; l++) arr[l] = l + 1;
        do {
          int c = 0;
          for (x = 0; x < b[0]; x++) {
            for (y = 0; y < b[0]; y++) {
              if (like[arr[x]][arr[y]] == 1) c++;
            }
          }
          for (x = b[0]; x < b[0] + b[1]; x++) {
            for (y = b[0]; y < b[0] + b[1]; y++) {
              if (like[arr[x]][arr[y]] == 1) c++;
            }
          }
          for (x = b[0] + b[1]; x < b[0] + b[1] + b[2]; x++) {
            for (y = b[0] + b[1]; y < b[0] + b[1] + b[2]; y++) {
              if (like[arr[x]][arr[y]] == 1) c++;
            }
          }
          if (c > ans2) ans2 = c;
        } while (next_permutation(arr, arr + 7));
      }
    }
  cout << ans << " " << ans2 << endl;
  return 0;
}

```


### Prompt

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

Many countries have such a New Year or Christmas tradition as writing a letter to Santa including a wish list for presents. Vasya is an ordinary programmer boy. Like all ordinary boys, he is going to write the letter to Santa on the New Year Eve (we Russians actually expect Santa for the New Year, not for Christmas).

Vasya has come up with an algorithm he will follow while writing a letter. First he chooses two strings, s1 anf s2, consisting of uppercase English letters. Then the boy makes string sk, using a recurrent equation sn = sn - 2 + sn - 1, operation '+' means a concatenation (that is, the sequential record) of strings in the given order. Then Vasya writes down string sk on a piece of paper, puts it in the envelope and sends in to Santa.

Vasya is absolutely sure that Santa will bring him the best present if the resulting string sk has exactly x occurrences of substring AC (the short-cut reminds him оf accepted problems). Besides, Vasya decided that string s1 should have length n, and string s2 should have length m. Vasya hasn't decided anything else.

At the moment Vasya's got urgent New Year business, so he asks you to choose two strings for him, s1 and s2 in the required manner. Help Vasya.

Input

The first line contains four integers k, x, n, m (3 ≤ k ≤ 50; 0 ≤ x ≤ 109; 1 ≤ n, m ≤ 100).

Output

In the first line print string s1, consisting of n uppercase English letters. In the second line print string s2, consisting of m uppercase English letters. If there are multiple valid strings, print any of them.

If the required pair of strings doesn't exist, print "Happy new year!" without the quotes.

Examples

Input

3 2 2 2

Output

AC
AC

Input

3 3 2 2

Output

Happy new year!

Input

3 0 2 2

Output

AA
AA

Input

4 3 2 1

Output

Happy new year!

Input

4 2 2 1

Output

Happy new year!

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, m, k, x, j, i, a[100], b[100], f[100], res, len1, len2;
long long nm[100], mn[100], mm[100], nn[100], mask;
char get(int x, int y) {
  if (!y) return 'B';
  if (x) return 'C';
  return 'A';
}
string getAns(bool a, bool b, int n, int k, int a1, int b1) {
  int i;
  string ans = "";
  if (n == 1) return ans = get(a, a1);
  if (a == 0 && a1) {
    for (i = 0; i < k; i++) ans += "AC";
    if (k * 2 != n) {
      for (i = 0; i < n - 2 * k; i++) ans += get(b, b1);
    }
    return ans;
  }
  if (b == 1 && b1) {
    for (i = 0; i < k; i++) ans += "AC";
    if (k * 2 != n) {
      for (i = 0; i < n - 2 * k; i++) ans = get(a, a1) + ans;
    }
    return ans;
  }
  for (i = 0; i < k; i++) ans += "AC";
  while (ans.size() + 2 < n) ans += "B";
  return get(a, a1) + ans + get(b, b1);
}
int main() {
  cin >> k >> x >> n >> m;
  a[0] = 0;
  b[0] = 0;
  a[1] = 1;
  b[1] = 1;
  f[0] = 1;
  f[1] = 1;
  for (i = 2; i < k; i++) {
    if (b[i - 2] == 0 && a[i - 1] == 0) nn[i]++;
    if (b[i - 2] == 1 && a[i - 1] == 1) mm[i]++;
    if (b[i - 2] == 0 && a[i - 1] == 1) nm[i]++;
    if (b[i - 2] == 1 && a[i - 1] == 0) mn[i]++;
    f[i] = f[i - 1] + f[i - 2];
    nm[i] += nm[i - 1] + nm[i - 2];
    mn[i] += mn[i - 1] + mn[i - 2];
    mm[i] += mm[i - 1] + mm[i - 2];
    nn[i] += nn[i - 1] + nn[i - 2];
    a[i] = a[i - 2];
    b[i] = b[i - 1];
  }
  k--;
  for (mask = 0; mask < (1 << 8); mask++) {
    if (n == 1 && (bool(mask & 1) ^ bool(mask & 2))) continue;
    if (n == 1 && (bool(mask & 16) ^ bool(mask & 32))) continue;
    if (m == 1 && (bool(mask & 4) ^ bool(mask & 8))) continue;
    if (m == 1 && (bool(mask & 64) ^ bool(mask & 128))) continue;
    if ((mask & 16) && (mask & 32) && !(mask & 1) && (mask & 2))
      len1 = n / 2;
    else {
      if ((!(mask & 1) && (mask & 16)) || ((mask & 2) && (mask & 32)))
        len1 = (n - 1) / 2;
      else
        len1 = (n - 2) / 2;
    }
    if ((mask & 64) && (mask & 128) && !(mask & 4) && (mask & 8))
      len2 = m / 2;
    else {
      if ((!(mask & 4) && (mask & 64)) || ((mask & 8) && (mask & 128)))
        len2 = (m - 1) / 2;
      else
        len2 = (m - 2) / 2;
    }
    for (i = 0; i <= len1; i++) {
      for (j = 0; j <= len2; j++) {
        res = f[k - 2] * i + f[k - 1] * j;
        if ((mask & 16) && (mask & 32))
          res += ((mask & 1) && !(mask & 2)) * nn[k];
        if ((mask & 64) && (mask & 128))
          res += ((mask & 4) && !(mask & 8)) * mm[k];
        if ((mask & 32) && (mask & 64))
          res += (!(mask & 2) && (mask & 4)) * nm[k];
        if ((mask & 16) && (mask & 128))
          res += (!(mask & 8) && (mask & 1)) * mn[k];
        if (res == x) {
          cout << getAns(mask & 1, mask & 2, n, i, mask & 16, mask & 32)
               << endl;
          cout << getAns(mask & 4, mask & 8, m, j, mask & 64, mask & 128);
          return 0;
        }
      }
    }
  }
  cout << "Happy new year!";
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Problem Statement

We have planted $N$ flower seeds, all of which come into different flowers. We want to make all the flowers come out together.

Each plant has a value called vitality, which is initially zero. Watering and spreading fertilizers cause changes on it, and the $i$-th plant will come into flower if its vitality is equal to or greater than $\mathit{th}_i$. Note that $\mathit{th}_i$ may be negative because some flowers require no additional nutrition.

Watering effects on all the plants. Watering the plants with $W$ liters of water changes the vitality of the $i$-th plant by $W \times \mathit{vw}_i$ for all $i$ ($1 \le i \le n$), and costs $W \times \mathit{pw}$ yen, where $W$ need not be an integer. $\mathit{vw}_i$ may be negative because some flowers hate water.

We have $N$ kinds of fertilizers, and the $i$-th fertilizer effects only on the $i$-th plant. Spreading $F_i$ kilograms of the $i$-th fertilizer changes the vitality of the $i$-th plant by $F_i \times \mathit{vf}_i$, and costs $F_i \times \mathit{pf}_i$ yen, where $F_i$ need not be an integer as well. Each fertilizer is specially made for the corresponding plant, therefore $\mathit{vf}_i$ is guaranteed to be positive.

Of course, we also want to minimize the cost. Formally, our purpose is described as "to minimize $W \times \mathit{pw} + \sum_{i=1}^{N}(F_i \times \mathit{pf}_i)$ under $W \times \mathit{vw}_i + F_i \times \mathit{vf}_i \ge \mathit{th}_i$, $W \ge 0$, and $F_i \ge 0$ for all $i$ ($1 \le i \le N$)". Your task is to calculate the minimum cost.

Input

The input consists of multiple datasets. The number of datasets does not exceed $100$, and the data size of the input does not exceed $20\mathrm{MB}$. Each dataset is formatted as follows.

> $N$
> $\mathit{pw}$
> $\mathit{vw}_1$ $\mathit{pf}_1$ $\mathit{vf}_1$ $\mathit{th}_1$
> :
> :
> $\mathit{vw}_N$ $\mathit{pf}_N$ $\mathit{vf}_N$ $\mathit{th}_N$

The first line of a dataset contains a single integer $N$, number of flower seeds. The second line of a dataset contains a single integer $\mathit{pw}$, cost of watering one liter. Each of the following $N$ lines describes a flower. The $i$-th line contains four integers, $\mathit{vw}_i$, $\mathit{pf}_i$, $\mathit{vf}_i$, and $\mathit{th}_i$, separated by a space.

You can assume that $1 \le N \le 10^5$, $1 \le \mathit{pw} \le 100$, $-100 \le \mathit{vw}_i \le 100$, $1 \le \mathit{pf}_i \le 100$, $1 \le \mathit{vf}_i \le 100$, and $-100 \le \mathit{th}_i \le 100$.

The end of the input is indicated by a line containing a zero.

Output

For each dataset, output a line containing the minimum cost to make all the flowers come out. The output must have an absolute or relative error at most $10^{-4}$.

Sample Input

3
10
4 3 4 10
5 4 5 20
6 5 6 30
3
7
-4 3 4 -10
5 4 5 20
6 5 6 30
3
1
-4 3 4 -10
-5 4 5 -20
6 5 6 30
3
10
-4 3 4 -10
-5 4 5 -20
-6 5 6 -30
0

Output for the Sample Input

43.5
36
13.5
0

Example

Input

3
10
4 3 4 10
5 4 5 20
6 5 6 30
3
7
-4 3 4 -10
5 4 5 20
6 5 6 30
3
1
-4 3 4 -10
-5 4 5 -20
6 5 6 30
3
10
-4 3 4 -10
-5 4 5 -20
-6 5 6 -30
0

Output

43.5
36
13.5
0

### Response

```cpp
#include<iostream>
#include<iomanip>
using namespace std;
int N;
double pw;
double vw[1<<17],pf[1<<17],wf[1<<17],th[1<<17];
double calc(double W)
{
	double cost=W*pw;
	for(int i=0;i<N;i++)
	{
		double now=th[i]-W*vw[i];
		if(now>0)cost+=now/wf[i]*pf[i];
	}
	return cost;
}
int main()
{
	while(cin>>N,N)
	{
		cin>>pw;
		for(int i=0;i<N;i++)cin>>vw[i]>>pf[i]>>wf[i]>>th[i];
		double L=0,R=1e9;
		for(int ccc=0;ccc<200;ccc++)
		{
			double M1=(L*2+R)/3;
			double M2=(L+R*2)/3;
			double c1=calc(M1);
			double c2=calc(M2);
			if(c1<c2)R=M2;
			else L=M1;
		}
		cout<<fixed<<setprecision(16)<<calc(L)<<endl;
	}
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Sorting algorithms for sorting data are basic algorithms indispensable in computer science. For example, as shown in the figure below, the operation of "sorting the elements of an array of integer values in ascending order" is alignment.

<image>

Many alignment algorithms have been devised, but one of the basic algorithms is bubble sort. As an example, let's arrange an array of given integer values in ascending order by bubble sort.

<image>

In bubble sort, each calculation step divides the array into "sorted parts" and "unsorted parts". Initially, the entire array will be the unsorted part.

From the beginning of the unsorted part, compare the adjacent elements (green element in the figure) and swap them so that the larger value is to the right. If the two values are equal, they will not be exchanged.

<image>

Repeat this process until the end of the unsorted part (white element in the figure). Finally, add the end to the sorted part (blue element in the figure) to complete one step.

Repeat this step until the unsorted part has a length of 1.

<image>

<image>

<image>

When the length of the unsorted part becomes 1, the sorting process ends.

Now, let's create a program that takes an array of n numbers as input, sorts the numbers in ascending order from the beginning of the array by the above bubble sort procedure, and outputs the number of exchanges of the required array elements. Please give me.

Input

A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:

n
a1
a2
::
an

The first line gives the number n (1 ≤ n ≤ 100), and the following n lines give the i-th number ai (1 ≤ ai ≤ 1000000).

The number of datasets does not exceed 20.

Output

Outputs the number of data element exchanges (integer) for each data set on one line.

Example

Input

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

Output

7
0
3

### Response

```cpp
#include <iostream>
using namespace std;
int n,a[100],ans=0;

void solve() {
  int fin = n-1;
  while(fin != 0) {
    for(int i=0;i<fin;i++) {
      if(a[i] > a[i+1]) {
        swap(a[i],a[i+1]);
        ans++;
      }
    }
    fin--;
  }
  return;
}

int main() {
  while(cin >> n) {
    if(n==0) break;
    for(int i=0;i<n;i++) {
      cin >> a[i];
    }
    solve();
    cout << ans << endl;
    ans = 0;
  }
  return 0;
}
```


### Prompt

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

It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.
There are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses.
Find the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.

Constraints

* 1 ≤ N ≤ 100
* 0 ≤ a_i ≤ 1000
* a_i is an integer.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

Print the minimum distance to be traveled.

Examples

Input

4
2 3 7 9

Output

7

Input

8
3 1 4 1 5 9 2 6

Output

8

### Response

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

int main(){
  int N;
  cin>>N;
  int k=1000,l=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    k=min(k,a);
    l=max(l,a);
  }
  cout<<l-k<<endl;
}
```


### Prompt

Construct a Cpp code solution to the problem outlined:

When preparing a tournament, Codeforces coordinators try treir best to make the first problem as easy as possible. This time the coordinator had chosen some problem and asked n people about their opinions. Each person answered whether this problem is easy or hard.

If at least one of these n people has answered that the problem is hard, the coordinator decides to change the problem. For the given responses, check if the problem is easy enough.

Input

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of people who were asked to give their opinions.

The second line contains n integers, each integer is either 0 or 1. If i-th integer is 0, then i-th person thinks that the problem is easy; if it is 1, then i-th person thinks that the problem is hard.

Output

Print one word: "EASY" if the problem is easy according to all responses, or "HARD" if there is at least one person who thinks the problem is hard.

You may print every letter in any register: "EASY", "easy", "EaSY" and "eAsY" all will be processed correctly.

Examples

Input

3
0 0 1

Output

HARD

Input

1
0

Output

EASY

Note

In the first example the third person says it's a hard problem, so it should be replaced.

In the second example the problem easy for the only person, so it doesn't have to be replaced.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, count = 0;
  cin >> a;
  int arr[a];
  for (int i = 0; i < a; i++) {
    cin >> arr[i];
  }
  for (int j = 0; j < a; j++) {
    if (arr[j] == 1) {
      count++;
    }
  }
  if (count > 0) {
    cout << "HARD";
  } else {
    cout << "EASY";
  }
  return 0;
}

```


### Prompt

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

The weight of a sequence is defined as the number of unordered pairs of indexes (i,j) (here i < j) with same value (a_{i} = a_{j}). For example, the weight of sequence a = [1, 1, 2, 2, 1] is 4. The set of unordered pairs of indexes with same value are (1, 2), (1, 5), (2, 5), and (3, 4).

You are given a sequence a of n integers. Print the sum of the weight of all subsegments of a.

A sequence b is a subsegment of a sequence a if b can be obtained from a by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

Input

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

The first line of each test case contains a single integer n (1 ≤ n ≤ 10^5).

The second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9).

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

Output

For each test case, print a single integer — the sum of the weight of all subsegments of a.

Example

Input

2
4
1 2 1 1
4
1 2 3 4

Output

6
0

Note

  * In test case 1, all possible subsegments of sequence [1, 2, 1, 1] having size more than 1 are:
    1. [1, 2] having 0 valid unordered pairs;
    2. [2, 1] having 0 valid unordered pairs;
    3. [1, 1] having 1 valid unordered pair;
    4. [1, 2, 1] having 1 valid unordered pairs;
    5. [2, 1, 1] having 1 valid unordered pair;
    6. [1, 2, 1, 1] having 3 valid unordered pairs.
Answer is 6.
  * In test case 2, all elements of the sequence are distinct. So, there is no valid unordered pair with the same value for any subarray. Answer is 0.

### Response

```cpp
//#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
using namespace std;
const int N = 500010,M = 80010;
typedef long long ll;
int n,m;
int a[N],h[N];
vector<int> re[N];int t = 0;
int find(int x)
{
	return lower_bound(h+1,h+1+t,x)-h;
}

void slove()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		re[i].clear();
		h[i] = a[i];
	}
	sort(h+1,h+1+n);
	t = unique(h+1,h+1+n)-h-1;
	for(int i=1;i<=n;i++) a[i] = find(a[i]);;
	//for(int i=1;i<=n;i++) cout<<a[i]<<" ";
	ll da = 0;
	for(int i=1;i<=n;i++) re[a[i]].push_back(i);

	//system("pause");
	for(int i=1;i<=t;i++)
	{
		ll res = 0;
		for(auto x:re[i])
		{
			da+=(n-x+1)*res;
			res+=x;
		}
	}
	cout<<da<<"\n";
}
int main()
{
    int T;cin>>T;
    while(T--)
    {
    	slove();
	}
    return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Being tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller than the other.

He noticed that the two rabbits were hopping towards each other. The positions of the two rabbits can be represented as integer coordinates on a horizontal line. The taller rabbit is currently on position x, and the shorter rabbit is currently on position y (x < y). Every second, each rabbit hops to another position. The taller rabbit hops to the positive direction by a, and the shorter rabbit hops to the negative direction by b.

<image>

For example, let's say x=0, y=10, a=2, and b=3. At the 1-st second, each rabbit will be at position 2 and 7. At the 2-nd second, both rabbits will be at position 4.

Gildong is now wondering: Will the two rabbits be at the same position at the same moment? If so, how long will it take? Let's find a moment in time (in seconds) after which the rabbits will be at the same point.

Input

Each test contains one or more test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000).

Each test case contains exactly one line. The line consists of four integers x, y, a, b (0 ≤ x < y ≤ 10^9, 1 ≤ a,b ≤ 10^9) — the current position of the taller rabbit, the current position of the shorter rabbit, the hopping distance of the taller rabbit, and the hopping distance of the shorter rabbit, respectively.

Output

For each test case, print the single integer: number of seconds the two rabbits will take to be at the same position.

If the two rabbits will never be at the same position simultaneously, print -1.

Example

Input

5
0 10 2 3
0 10 3 3
900000000 1000000000 1 9999999
1 2 1 1
1 3 1 1

Output

2
-1
10
-1
1

Note

The first case is explained in the description.

In the second case, each rabbit will be at position 3 and 7 respectively at the 1-st second. But in the 2-nd second they will be at 6 and 4 respectively, and we can see that they will never be at the same position since the distance between the two rabbits will only increase afterward.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
long long t, x, y, a, b;
int main(void) {
  scanf("%d", &t);
  while (t--) {
    scanf("%lld%lld%lld%lld", &x, &y, &a, &b);
    if ((y - x) % (a + b) == 0) {
      printf("%lld\n", (y - x) / (a + b));
    } else
      puts("-1");
  }
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Little girl Margarita is a big fan of competitive programming. She especially loves problems about arrays and queries on them.

Recently, she was presented with an array a of the size of 10^9 elements that is filled as follows:

  * a_1 = -1
  * a_2 = 2
  * a_3 = -3
  * a_4 = 4
  * a_5 = -5
  * And so on ...

That is, the value of the i-th element of the array a is calculated using the formula a_i = i ⋅ (-1)^i.

She immediately came up with q queries on this array. Each query is described with two numbers: l and r. The answer to a query is the sum of all the elements of the array at positions from l to r inclusive.

Margarita really wants to know the answer to each of the requests. She doesn't want to count all this manually, but unfortunately, she couldn't write the program that solves the problem either. She has turned to you — the best programmer.

Help her find the answers!

Input

The first line contains a single integer q (1 ≤ q ≤ 10^3) — the number of the queries.

Each of the next q lines contains two integers l and r (1 ≤ l ≤ r ≤ 10^9) — the descriptions of the queries.

Output

Print q lines, each containing one number — the answer to the query.

Example

Input

5
1 3
2 5
5 5
4 4
2 3

Output

-2
-2
-5
4
-1

Note

In the first query, you need to find the sum of the elements of the array from position 1 to position 3. The sum is equal to a_1 + a_2 + a_3 = -1 + 2 -3 = -2.

In the second query, you need to find the sum of the elements of the array from position 2 to position 5. The sum is equal to a_2 + a_3 + a_4 + a_5 = 2 -3 + 4 - 5 = -2.

In the third query, you need to find the sum of the elements of the array from position 5 to position 5. The sum is equal to a_5 = -5.

In the fourth query, you need to find the sum of the elements of the array from position 4 to position 4. The sum is equal to a_4 = 4.

In the fifth query, you need to find the sum of the elements of the array from position 2 to position 3. The sum is equal to a_2 + a_3 = 2 - 3 = -1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int i, z, y, n, x[10000][2];
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x[i][0] >> x[i][1];
    x[i][0]--;
  }
  for (i = 0; i < n; i++) {
    if (x[i][1] % 2 == 0)
      z = x[i][1] / 2;
    else
      z = (x[i][1] / 2 + 1) * -1;
    if (x[i][0] == 0)
      y = 0;
    else if (x[i][0] % 2 == 0)
      y = x[i][0] / 2;
    else
      y = (x[i][0] / 2 + 1) * -1;
    cout << z - y << endl;
  }
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Your task is to write a program of a simple dictionary which implements the following instructions:

* insert str: insert a string str in to the dictionary
* find str: if the distionary contains str, then print 'yes', otherwise print 'no'

Notes

Template in C

Constraints

* A string consists of 'A', 'C', 'G', or 'T'
* 1 ≤ length of a string ≤ 12
* n ≤ 1000000

Input

In the first line n, the number of instructions is given. In the following n lines, n instructions are given in the above mentioned format.

Output

Print yes or no for each find instruction in a line.

Examples

Input

5
insert A
insert T
insert C
find G
find A

Output

no
yes

Input

13
insert AAA
insert AAC
insert AGA
insert AGG
insert TTT
find AAA
find CCC
find CCC
insert CCC
find CCC
insert T
find TTT
find T

Output

yes
no
no
yes
yes
yes

### Response

```cpp
#include <iostream>
#include <set>

int main() {
	int n;
	std::cin >> n;
	std::string command, str;
	std::set<std::string> dic;
	for (int i = 0; i < n; i++) {
		std::cin >> command >> str;
		if (command == "insert") {
			dic.insert(str);
		} else if (command == "find") {
			if (dic.count(str) == 0) {
				std::cout << "no\n";
			} else {
				std::cout << "yes\n";
			}
		}
	}
	return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Vasya has a sequence a consisting of n integers a_1, a_2, ..., a_n. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (... 00000000110_2) into 3 (... 00000000011_2), 12 (... 000000001100_2), 1026 (... 10000000010_2) and many others. Vasya can use this operation any (possibly zero) number of times on any number from the sequence.

Vasya names a sequence as good one, if, using operation mentioned above, he can obtain the sequence with [bitwise exclusive or](https://en.wikipedia.org/wiki/Exclusive_or) of all elements equal to 0.

For the given sequence a_1, a_2, …, a_n Vasya'd like to calculate number of integer pairs (l, r) such that 1 ≤ l ≤ r ≤ n and sequence a_l, a_{l + 1}, ..., a_r is good.

Input

The first line contains a single integer n (1 ≤ n ≤ 3 ⋅ 10^5) — length of the sequence.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^{18}) — the sequence a.

Output

Print one integer — the number of pairs (l, r) such that 1 ≤ l ≤ r ≤ n and the sequence a_l, a_{l + 1}, ..., a_r is good.

Examples

Input

3
6 7 14

Output

2

Input

4
1 2 1 16

Output

4

Note

In the first example pairs (2, 3) and (1, 3) are valid. Pair (2, 3) is valid since a_2 = 7 → 11, a_3 = 14 → 11 and 11 ⊕ 11 = 0, where ⊕ — bitwise exclusive or. Pair (1, 3) is valid since a_1 = 6 → 3, a_2 = 7 → 13, a_3 = 14 → 14 and 3 ⊕ 13 ⊕ 14 = 0.

In the second example pairs (1, 2), (2, 3), (3, 4) and (1, 4) are valid.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
template <typename T>
void chkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
void chkmin(T &x, T y) {
  x = min(x, y);
}
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
template <typename T>
void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  puts("");
}
int a[MAXN], s[MAXN][2], sum[MAXN], nxt[MAXN];
int main() {
  int n;
  read(n);
  for (int i = 1; i <= n; i++) {
    long long tmp;
    read(tmp);
    while (tmp) {
      a[i] += tmp & 1;
      tmp >>= 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i];
    s[i][1] = s[i - 1][1];
    s[i][0] = s[i - 1][0];
    if (sum[i] % 2 == 1)
      s[i][1]++;
    else
      s[i][0]++;
  }
  int las = n + 1;
  for (int i = n; i >= 0; i--) {
    nxt[i] = las;
    if (a[i] != 0) las = i;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = sum[i - 1] % 2;
    int las = i, Max = a[i], sum = a[i];
    for (int j = 1; j <= 128; j++) {
      int id = nxt[las];
      if (sum / 2 >= Max) {
        ans = ans + s[id - 1][tmp] - s[las - 1][tmp];
      }
      Max = max(a[id], Max);
      sum = sum + a[id];
      las = id;
      if (las > n) break;
    }
    ans = ans + s[n][tmp] - s[las - 1][tmp];
  }
  writeln(ans);
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

Even if the world is full of counterfeits, I still regard it as wonderful.

Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this.

The phoenix has a rather long lifespan, and reincarnates itself once every a! years. Here a! denotes the factorial of integer a, that is, a! = 1 × 2 × ... × a. Specifically, 0! = 1.

Koyomi doesn't care much about this, but before he gets into another mess with oddities, he is interested in the number of times the phoenix will reincarnate in a timespan of b! years, that is, <image>. Note that when b ≥ a this value is always integer.

As the answer can be quite large, it would be enough for Koyomi just to know the last digit of the answer in decimal representation. And you're here to provide Koyomi with this knowledge.

Input

The first and only line of input contains two space-separated integers a and b (0 ≤ a ≤ b ≤ 1018).

Output

Output one line containing a single decimal digit — the last digit of the value that interests Koyomi.

Examples

Input

2 4

Output

2

Input

0 10

Output

0

Input

107 109

Output

2

Note

In the first example, the last digit of <image> is 2;

In the second example, the last digit of <image> is 0;

In the third example, the last digit of <image> is 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b;
  scanf("%lld %lld", &a, &b);
  long long int diff = b - a + 1;
  if (diff < 10) {
    long long int ans = 1;
    for (long long int i = b; i >= a + 1; i--) ans = (ans * i) % 10;
    printf("%lld\n", ans);
  } else
    printf("0\n");
  return 0;
}

```