### Prompt

Construct a Cpp code solution to the problem outlined:

problem

During this time of winter in Japan, hot days continue in Australia in the Southern Hemisphere. IOI, who lives in Australia, decided to plan what clothes to wear based on the weather forecast for a certain D day. The maximum temperature on day i (1 ≤ i ≤ D) is predicted to be Ti degrees.

IOI has N kinds of clothes, which are numbered from 1 to N. Clothes j (1 ≤ j ≤ N) are suitable for wearing on days when the maximum temperature is above Aj and below Bj. In addition, each clothes has an integer called "flashiness", and the flashiness of clothes j is Cj.

For each of the D days, IOI chooses to wear one of the clothes suitable for wearing when the maximum temperature follows the weather forecast. You may choose the same clothes as many times as you like, or you may choose clothes that are never chosen in D days.

IOI, who wanted to avoid wearing similar clothes in succession, decided to maximize the total absolute value of the difference in the flashiness of the clothes worn on consecutive days. That is, assuming that the clothes xi are selected on the i-day, we want to maximize the values | Cx1 --Cx2 | + | Cx2 --Cx3 | +… + | CxD-1 --CxD |. Create a program to find this maximum value.

input

The input consists of 1 + D + N lines.

On the first line, two integers D and N (2 ≤ D ≤ 200, 1 ≤ N ≤ 200) are written with a blank as a delimiter. D is the number of days to plan clothes and N is the number of clothes types IOI has.

One integer Ti (0 ≤ Ti ≤ 60) is written in the i-th line (1 ≤ i ≤ D) of the following D lines. This means that the maximum temperature on day i is forecast to be Ti degrees.

In the jth line (1 ≤ j ≤ N) of the following N lines, three integers Aj, Bj, Cj (0 ≤ Aj ≤ Bj ≤ 60, 0 ≤ Cj ≤ 100) are written. These indicate that clothing j is suitable for wearing on days when the maximum temperature is above Aj and below Bj, and the flashiness is Cj.

It is guaranteed that there will be at least one piece of clothing suitable for wearing when the maximum temperature follows the weather forecast for every D day.

output

Output the total absolute value of the difference in the flashiness of clothes worn on consecutive days, that is, the maximum value of the values | Cx1 --Cx2 | + | Cx2 --Cx3 | +… + | CxD-1 --CxD | in one line. ..

Input / output example

Input example 1

3 4
31
27
35
20 25 30
23 29 90
21 35 60
28 33 40

Output example 1

80

In the input / output example 1, the candidates for clothes on the first day are clothes 3 and 4, the candidates for clothes on the second day are clothes 2 and clothes 3, and the candidates for clothes on the third day are only clothes 3. is there. Choose clothes 4 on the first day, clothes 2 on the second day, and clothes 3 on the third day. That is, x1 = 4, x2 = 2, x3 = 3. At this time, the absolute value of the difference in the flashiness of the clothes on the first day and the second day is | 40 --90 | = 50, and the absolute value of the difference in the flashiness of the clothes on the second and third days is | 90-60 | = 30. The total is 80, which is the maximum value.

Input example 2

5 2
26
28
32
29
34
30 35 0
25 30 100

Output example 2

300

In Example 2 of input / output, clothes 2 on the first day, clothes 2 on the second day, clothes 1 on the third day, clothes 2 on the fourth day, and clothes 1 on the fifth day. You have to choose. At this time, the required value is | 100 --100 | + | 100 --0 | + | 0 --100 | + | 100 --0 | = 300.

The question text and the data used for the automatic referee are the question text and the test data for scoring, which are created and published by the Japan Committee for Information Olympics.

Example

Input

3 4
31
27
35
20 25 30
23 29 90
21 35 60
28 33 40

Output

80

### Response

```cpp
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int d, n;
    cin >> d >> n;
    vector <int> t(d), a(n), b(n), c(n);
    rep (i, d) cin >> t[i];
    rep (i, n) cin >> a[i] >> b[i] >> c[i];

    vector <vector <int>> dp(d + 1, vector <int> (101, -1));
    dp[0][0] = 0;
    rep (i, d) rep (j, 101) if (dp[i][j] != -1) rep (k, n) if (a[k] <= t[i] && t[i] <= b[k]) {
        if (i == 0) dp[i + 1][c[k]] = 0;
        else        dp[i + 1][c[k]] = max(dp[i + 1][c[k]], dp[i][j] + abs(j - c[k]));
    }

    int ans = 0;
    rep (i, 101) ans = max(ans, dp[d][i]);
    cout << ans << endl;

    return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.

Constraints

* The length of the input string < 1200

Input

A string is given in a line.

Output

Print the converted string in a line. Note that you do not need to convert any characters other than alphabetical letters.

Example

Input

fAIR, LATER, OCCASIONALLY CLOUDY.

Output

Fair, later, occasionally cloudy.

### Response

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

int main() {
  string s;
  getline(cin,s);
  for(int a = 0; a < s.length(); ++a) {
    if(islower(s[a])) {
      s[a] = toupper(s[a]);
    }else if(isupper(s[a])) {
      s[a] = tolower(s[a]);
    }
  }

  cout << s << endl;

  return 0;
}
```


### Prompt

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

Bizon the Champion isn't just attentive, he also is very hardworking.

Bizon the Champion decided to paint his old fence his favorite color, orange. The fence is represented as n vertical planks, put in a row. Adjacent planks have no gap between them. The planks are numbered from the left to the right starting from one, the i-th plank has the width of 1 meter and the height of ai meters.

Bizon the Champion bought a brush in the shop, the brush's width is 1 meter. He can make vertical and horizontal strokes with the brush. During a stroke the brush's full surface must touch the fence at all the time (see the samples for the better understanding). What minimum number of strokes should Bizon the Champion do to fully paint the fence? Note that you are allowed to paint the same area of the fence multiple times.

Input

The first line contains integer n (1 ≤ n ≤ 5000) — the number of fence planks. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Output

Print a single integer — the minimum number of strokes needed to paint the whole fence.

Examples

Input

5
2 2 1 2 1

Output

3

Input

2
2 2

Output

2

Input

1
5

Output

1

Note

In the first sample you need to paint the fence in three strokes with the brush: the first stroke goes on height 1 horizontally along all the planks. The second stroke goes on height 2 horizontally and paints the first and second planks and the third stroke (it can be horizontal and vertical) finishes painting the fourth plank.

In the second sample you can paint the fence with two strokes, either two horizontal or two vertical strokes.

In the third sample there is only one plank that can be painted using a single vertical stroke.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int *fences;
int paintInterval(int first, int last, int height) {
  if (first >= last) return 0;
  int minHeight = first;
  for (int i = first; i < last; i++)
    if (fences[minHeight] > fences[i]) minHeight = i;
  return min(last - first,
             fences[minHeight] - height +
                 paintInterval(first, minHeight, fences[minHeight]) +
                 paintInterval(minHeight + 1, last, fences[minHeight]));
}
int main() {
  int n;
  cin >> n;
  fences = new int[n];
  for (int i = 0; i < n; i++) cin >> fences[i];
  cout << paintInterval(0, n, 0);
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Arpa is researching the Mexican wave.

There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0.

  * At time 1, the first spectator stands.
  * At time 2, the second spectator stands.
  * ...
  * At time k, the k-th spectator stands.
  * At time k + 1, the (k + 1)-th spectator stands and the first spectator sits.
  * At time k + 2, the (k + 2)-th spectator stands and the second spectator sits.
  * ...
  * At time n, the n-th spectator stands and the (n - k)-th spectator sits.
  * At time n + 1, the (n + 1 - k)-th spectator sits.
  * ...
  * At time n + k, the n-th spectator sits.

Arpa wants to know how many spectators are standing at time t.

Input

The first line contains three integers n, k, t (1 ≤ n ≤ 109, 1 ≤ k ≤ n, 1 ≤ t < n + k).

Output

Print single integer: how many spectators are standing at time t.

Examples

Input

10 5 3

Output

3

Input

10 5 7

Output

5

Input

10 5 12

Output

3

Note

In the following a sitting spectator is represented as -, a standing spectator is represented as ^.

  * At t = 0  ---------- <image> number of standing spectators = 0.
  * At t = 1  ^--------- <image> number of standing spectators = 1.
  * At t = 2  ^^-------- <image> number of standing spectators = 2.
  * At t = 3  ^^^------- <image> number of standing spectators = 3.
  * At t = 4  ^^^^------ <image> number of standing spectators = 4.
  * At t = 5  ^^^^^----- <image> number of standing spectators = 5.
  * At t = 6  -^^^^^---- <image> number of standing spectators = 5.
  * At t = 7  --^^^^^--- <image> number of standing spectators = 5.
  * At t = 8  ---^^^^^-- <image> number of standing spectators = 5.
  * At t = 9  ----^^^^^- <image> number of standing spectators = 5.
  * At t = 10 -----^^^^^ <image> number of standing spectators = 5.
  * At t = 11 ------^^^^ <image> number of standing spectators = 4.
  * At t = 12 -------^^^ <image> number of standing spectators = 3.
  * At t = 13 --------^^ <image> number of standing spectators = 2.
  * At t = 14 ---------^ <image> number of standing spectators = 1.
  * At t = 15 ---------- <image> number of standing spectators = 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, t;
  cin >> n >> k >> t;
  if (t < k) {
    cout << t;
  } else if (t < n) {
    cout << k;
  } else {
    cout << n + k - t;
  }
}

```


### Prompt

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

Takahashi and Aoki will have a battle using their monsters.

The health and strength of Takahashi's monster are A and B, respectively, and those of Aoki's monster are C and D, respectively.

The two monsters will take turns attacking, in the order Takahashi's, Aoki's, Takahashi's, Aoki's, ... Here, an attack decreases the opponent's health by the value equal to the attacker's strength. The monsters keep attacking until the health of one monster becomes 0 or below. The person with the monster whose health becomes 0 or below loses, and the other person wins.

If Takahashi will win, print `Yes`; if he will lose, print `No`.

Constraints

* 1 \leq A,B,C,D \leq 100
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C D

Output

If Takahashi will win, print `Yes`; if he will lose, print `No`.

Examples

Input

10 9 10 10

Output

No

Input

46 4 40 5

Output

Yes

### Response

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

#define ll long long

signed main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int X = (a+d-1)/d;
  int Y = (c+b-1)/b;
  cout << ((X>=Y)? "Yes":"No");
}
```


### Prompt

Generate a CPP solution to the following problem:

You are given two integers n and m (m < n). Consider a convex regular polygon of n vertices. Recall that a regular polygon is a polygon that is equiangular (all angles are equal in measure) and equilateral (all sides have the same length).

<image> Examples of convex regular polygons

Your task is to say if it is possible to build another convex regular polygon with m vertices such that its center coincides with the center of the initial polygon and each of its vertices is some vertex of the initial polygon.

You have to answer t independent test cases.

Input

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

The next t lines describe test cases. Each test case is given as two space-separated integers n and m (3 ≤ m < n ≤ 100) — the number of vertices in the initial polygon and the number of vertices in the polygon you want to build.

Output

For each test case, print the answer — "YES" (without quotes), if it is possible to build another convex regular polygon with m vertices such that its center coincides with the center of the initial polygon and each of its vertices is some vertex of the initial polygon and "NO" otherwise.

Example

Input

2
6 3
7 3

Output

YES
NO

Note

<image> The first test case of the example

It can be shown that the answer for the second test case of the example is "NO".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    if (a % b == 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

The Dogeforces company has k employees. Each employee, except for lower-level employees, has at least 2 subordinates. Lower-level employees have no subordinates. Each employee, except for the head of the company, has exactly one direct supervisor. The head of the company is a direct or indirect supervisor of all employees. It is known that in Dogeforces, each supervisor receives a salary strictly more than all his subordinates.

The full structure of the company is a secret, but you know the number of lower-level employees and for each pair of lower-level employees, the salary of their common supervisor is known (if there are several such supervisors, then the supervisor with the minimum salary). You have to restore the structure of the company.

Input

The first line contains a single integer n (2 ≤ n ≤ 500) — the number of lower-level employees.

This is followed by n lines, where i-th line contains n integers a_{i,1}, a_{i,2}, ..., a_{i,n} (1 ≤ a_{i,j} ≤ 5000) — salary of the common supervisor of employees with numbers i and j. It is guaranteed that a_{i,j} = a_{j,i}. Note that a_{i,i} is equal to the salary of the i-th employee.

Output

In the first line, print a single integer k — the number of employees in the company.

In the second line, print k integers c_1, c_2, ..., c_k, where c_i is the salary of the employee with the number i.

In the third line, print a single integer r — the number of the employee who is the head of the company.

In the following k-1 lines, print two integers v and u (1 ≤ v, u ≤ k) — the number of the employee and his direct supervisor.

Note that the lower-level employees have numbers from 1 to n, and for the rest of the employees, you have to assign numbers from n+1 to k. If there are several correct company structures, you can print any of them.

Example

Input

3
2 5 7
5 1 7
7 7 4

Output

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

Note

One of the possible structures in the first example: <image>

### Response

```cpp
#include <bits/stdc++.h>
#define forr(i,a,b) for(int i=(a);i<(b);i++)
#define forn(i,n) forr(i,0,n)
#define dforn(i,n) for(int i=n-1;i>=0;i--)
#define forall(it,v) for(auto it=v.begin();it!=v.end();it++)
#define sz(c) ((int)c.size())
#define rsz resize
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fst first
#define snd second

#ifdef ANARAP
#define MAXN 13
#else
#define MAXN 502
#endif

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;

int mx[MAXN][MAXN];
bool used[MAXN][MAXN];
struct UnionFind{
	vector<int> f, setSize; //the array f contains the parent of each node
	int cantSets;
	void init(int n)
	{
		f.clear(); setSize.clear();
		cantSets = n;
		f.rsz(n, -1);
		setSize.rsz(n, 1);
	}
	int comp(int x) {return (f[x]==-1? x : f[x]=comp(f[x]));}//O(1)
	bool join(int a, int b) //devuelve true si ya estaban juntos
	{
		a=comp(a), b= comp(b);
		if(a!=b){
			setSize[b] += setSize[a];
			f[a] = b; //el grupo mas grande (b) ahora representa al mas chico (a)
		}
		return a == b;
	}
}uf;

int main()
{
	#ifdef ANARAP
		freopen("input.in", "r", stdin);
		//freopen("output.out", "w", stdout);
		unsigned t0, t1; t0=clock();
	#endif
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n; cin >> n;
	vector<int> ans(n), apunta(n, -1);
	forn(i,n) forn(j,n) cin >> mx[i][j];
	forn(i,n) ans[i] = mx[i][i];
	int row = -1;
	int mini = 5001;
	forn(i,n)forr(j,i+1,n)if(mx[i][j]<mini) {row = i; mini = mx[i][j];}
	int node=n;
	uf.init(n*2+10);
	vector<int> rows;
	forr(j, row+1, n){
		if(mx[row][j] == mini){
			used[row][j] = 1;
			rows.pb(j);
			uf.join(j, node);
			apunta[j] = node;
		}
	}
	forn(i,sz(rows)){
		forr(j, rows[i]+1, n){
			if(mx[rows[i]][j] == mini) used[rows[i]][j]=1;
		}
	}
	apunta[row] = node;
	uf.join(row, node);
	ans.pb(mini);
	apunta.pb(-1);
	while(1){
		node++;
		row = -1;
		mini = 5001;
		rows.clear();
		forn(i,n)forr(j,i+1,n)if(!used[i][j] && mx[i][j]<mini) {row = i; mini = mx[i][j];}
		//~ forn(i,n){
			//~ forn(j,n) cout << used[i][j] << " ";
			//~ cout << '\n';
		//~ }
		//~ cout << row << endl;
		if(row==-1) break;
		ans.pb(mini);
		apunta.pb(-1);
		int auxrow = uf.comp(row);
		forn(i,n)if(uf.comp(i) == auxrow) {rows.pb(i);}
		apunta[auxrow] = node;
		uf.join(auxrow, node);
		vector<int> rows2;
		forn(i, sz(rows)){
			forr(j, rows[i], n){
				if(!used[rows[i]][j] && mx[rows[i]][j] == mini){
					used[rows[i]][j] = 1;
					rows2.pb(j);
					int aux = uf.comp(j);
					if(aux!=node){
						apunta[aux] = node;
						uf.join(aux, node);
					}
				}
			}
		}
		forn(i, sz(rows2)){
			forr(j, rows2[i], n){
				if(!used[rows2[i]][j] && mx[rows2[i]][j] == mini){
					used[rows2[i]][j] = 1;
					int aux = uf.comp(j);
					if(aux!=node){
						apunta[aux] = node;
						uf.join(aux, node);
					}
				}
			}
		}
	}
	cout << node << '\n';
	forn(i,node) cout << ans[i] << " ";
	cout << '\n';
	int root = -1;
	forn(i,node) if(apunta[i] == -1) root = i;
	cout << root+1 << '\n';
	forn(i,node){
		if(apunta[i]!=-1) cout << i+1 << " " << apunta[i]+1 << '\n';

	}

	#ifdef ANARAP
	t1 = clock();double time = (double(t1-t0)/CLOCKS_PER_SEC); cout << "Execution Time: " << time << endl;
	#endif
	return 0;
}

```


### Prompt

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

Dima has a birthday soon! It's a big day! Saryozha's present to Dima is that Seryozha won't be in the room and won't disturb Dima and Inna as they celebrate the birthday. Inna's present to Dima is a stack, a queue and a deck.

Inna wants her present to show Dima how great a programmer he is. For that, she is going to give Dima commands one by one. There are two types of commands:

  1. Add a given number into one of containers. For the queue and the stack, you can add elements only to the end. For the deck, you can add elements to the beginning and to the end.
  2. Extract a number from each of at most three distinct containers. Tell all extracted numbers to Inna and then empty all containers. In the queue container you can extract numbers only from the beginning. In the stack container you can extract numbers only from the end. In the deck number you can extract numbers from the beginning and from the end. You cannot extract numbers from empty containers.

Every time Dima makes a command of the second type, Inna kisses Dima some (possibly zero) number of times. Dima knows Inna perfectly well, he is sure that this number equals the sum of numbers he extracts from containers during this operation.

As we've said before, Dima knows Inna perfectly well and he knows which commands Inna will give to Dima and the order of the commands. Help Dima find the strategy that lets him give as more kisses as possible for his birthday!

Input

The first line contains integer n (1 ≤ n ≤ 105) — the number of Inna's commands. Then n lines follow, describing Inna's commands. Each line consists an integer:

  1. Integer a (1 ≤ a ≤ 105) means that Inna gives Dima a command to add number a into one of containers.
  2. Integer 0 shows that Inna asks Dima to make at most three extractions from different containers.

Output

Each command of the input must correspond to one line of the output — Dima's action.

For the command of the first type (adding) print one word that corresponds to Dima's choice:

  * pushStack — add to the end of the stack;
  * pushQueue — add to the end of the queue;
  * pushFront — add to the beginning of the deck;
  * pushBack — add to the end of the deck.

For a command of the second type first print an integer k (0 ≤ k ≤ 3), that shows the number of extract operations, then print k words separated by space. The words can be:

  * popStack — extract from the end of the stack;
  * popQueue — extract from the beginning of the line;
  * popFront — extract from the beginning from the deck;
  * popBack — extract from the end of the deck.

The printed operations mustn't extract numbers from empty containers. Also, they must extract numbers from distinct containers.

The printed sequence of actions must lead to the maximum number of kisses. If there are multiple sequences of actions leading to the maximum number of kisses, you are allowed to print any of them.

Examples

Input

10
0
1
0
1
2
0
1
2
3
0

Output

0
pushStack
1 popStack
pushStack
pushQueue
2 popStack popQueue
pushStack
pushQueue
pushFront
3 popStack popQueue popFront

Input

4
1
2
3
0

Output

pushStack
pushQueue
pushFront
3 popStack popQueue popFront

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = INT_MAX;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
string op[4] = {"pushStack", "pushQueue", "pushFront", "pushBack"};
string ans[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x, last = 0;
  cin >> n;
  priority_queue<pair<int, int> > queries;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    if (x == 0) {
      int qtd = 0;
      while (!queries.empty()) {
        int val = queries.top().first, id = queries.top().second;
        queries.pop();
        ans[id] = op[min(qtd, 3)];
        qtd++;
      }
      for (int j = last; j < i; ++j) cout << ans[j] << endl;
      cout << min(qtd, 3);
      if (qtd >= 1) cout << " popStack";
      if (qtd >= 2) cout << " popQueue";
      if (qtd >= 3) cout << " popFront";
      cout << endl;
      last = i + 1;
    } else {
      queries.push({x, i});
    }
  }
  for (int i = last; i < n; ++i) cout << op[0] << endl;
}

```


### Prompt

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

We have N integers. The i-th number is A_i.

\\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N.

\\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1.

Determine if \\{A_i\\} is pairwise coprime, setwise coprime, or neither.

Here, GCD(\ldots) denotes greatest common divisor.

Constraints

* 2 \leq N \leq 10^6
* 1 \leq A_i\leq 10^6

Input

Input is given from Standard Input in the following format:

N
A_1 \ldots A_N

Output

If \\{A_i\\} is pairwise coprime, print `pairwise coprime`; if \\{A_i\\} is setwise coprime, print `setwise coprime`; if neither, print `not coprime`.

Examples

Input

3
3 4 5

Output

pairwise coprime

Input

3
6 10 15

Output

setwise coprime

Input

3
6 10 16

Output

not coprime

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
int A[N+1];
int GCD(int a,int b){
	return b==0?a:GCD(b,a%b);
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
#endif
	int n,tmp,gcd=0;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>tmp;
		++A[tmp];
		gcd=GCD(tmp,gcd);
	}

	//pairwise
	for(int i=2;i<=N;++i){
		int flag=0;
		for(int j=i;j<=N;j+=i){
			if(j<=N && A[j]>=1) flag+=A[j];
			if(flag>=2) goto setwise;
		}
	}
	cout<<"pairwise coprime"<<endl;
	return 0;

	setwise:
	if(gcd==1) cout<<"setwise coprime"<<endl;
	else cout<<"not coprime"<<endl;
	return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

One day Jeff got hold of an integer sequence a1, a2, ..., an of length n. The boy immediately decided to analyze the sequence. For that, he needs to find all values of x, for which these conditions hold:

  * x occurs in sequence a.
  * Consider all positions of numbers x in the sequence a (such i, that ai = x). These numbers, sorted in the increasing order, must form an arithmetic progression.

Help Jeff, find all x that meet the problem conditions.

Input

The first line contains integer n (1 ≤ n ≤ 105). The next line contains integers a1, a2, ..., an (1 ≤ ai ≤ 105). The numbers are separated by spaces.

Output

In the first line print integer t — the number of valid x. On each of the next t lines print two integers x and px, where x is current suitable value, px is the common difference between numbers in the progression (if x occurs exactly once in the sequence, px must equal 0). Print the pairs in the order of increasing x.

Examples

Input

1
2

Output

1
2 0

Input

8
1 2 1 3 1 2 1 5

Output

4
1 2
2 4
3 0
5 0

Note

In the first test 2 occurs exactly once in the sequence, ergo p2 = 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int n, ans, num, t, pos[maxn], eq[maxn];
int put[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &t);
    num = max(t, num);
    if (eq[t] == -1) continue;
    if (!pos[t])
      pos[t] = i;
    else if (eq[t] == 0) {
      eq[t] = i - pos[t];
      pos[t] = i;
    } else if (i - pos[t] != eq[t]) {
      eq[t] = -1;
    } else
      pos[t] = i;
  }
  for (int i = 1; i <= num; i++)
    if (pos[i] && eq[i] != -1) {
      put[++ans] = i;
    }
  printf("%d\n", ans);
  for (int i = 1; i <= ans; i++) printf("%d %d\n", put[i], eq[put[i]]);
  return 0;
}

```


### Prompt

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

problem

The JOI building is a combination of regular hexagons with a side of 1 meter as shown in the figure. As Christmas is approaching, JOI decided to decorate the walls of the building with illuminations. However, since it is useless to illuminate the parts that cannot be seen from the outside, we decided to decorate only the walls that can be reached from the outside without passing through the building.

<image>
Figure: Example of JOI building layout

The figure above is an example of the layout of JOI's buildings as seen from above. The numbers in the regular hexagon represent the coordinates. A gray regular hexagon represents a place with a building, and a white regular hexagon represents a place without a building. In this example, the part indicated by the solid red line is the wall surface to be decorated with illumination, and the total length of the wall surface is 64 meters.

Given a map showing the layout of JOI's buildings, create a program to find the total length of the walls to decorate. However, the outside of the map can be freely moved, and it is not possible to pass between adjacent buildings.

input

Two integers W and H (1 ≤ W ≤ 100, 1 ≤ H ≤ 100) are written on the first line of the input file, separated by blanks. The following line H describes the layout of the JOI building. On the first line of i + (1 ≤ i ≤ H), W integers are written separated by blanks, and the jth (1 ≤ j ≤ W) integer is a regular hexagon with coordinates (j, i). It is 1 when there is a building in, and 0 when there is no building. Also, the input data given always has one or more buildings.

The map is described by the following rules.

* The westernmost regular hexagon in the northernmost row of the map is the coordinates (1, 1).
* The eastern adjacent regular hexagon adjacent to the regular hexagon with coordinates (x, y) is the coordinates (x + 1, y).
* When y is odd, the coordinates of the southwestern regular hexagon adjacent to the regular hexagon of coordinates (x, y) are (x, y + 1).
* When y is even, the coordinates of the southeastern regular hexagon adjacent to the regular hexagon of coordinates (x, y) are (x, y + 1).

output

Output the total length of the walls to be decorated with illuminations in one line.

Input / output example

Input example 1

8 4
0 1 0 1 0 1 1 1
0 1 1 0 0 1 0 0
1 0 1 0 1 1 1 1 1
0 1 1 0 1 0 1 0

Output example 1

64

Input / output example 1 corresponds to the example in the problem statement, and the total length of the wall surface decorated with illumination is 64 meters.

Input example 2

8 5
0 1 1 1 0 1 1 1
0 1 0 0 1 1 0 0
1 0 0 1 1 1 1 1 1
0 1 0 1 1 0 1 0
0 1 1 0 1 1 0 0

Output example 2

56

The question text and the data used for the automatic referee are the question text and the test data for scoring, which are created and published by the Japan Committee for Information Olympics.

Example

Input

8 4
0 1 0 1 0 1 1 1
0 1 1 0 0 1 0 0
1 0 1 0 1 1 1 1
0 1 1 0 1 0 1 0

Output

64

### Response

```cpp
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
	int w,h;
class tansa{
public:
	vector<pair<int,int> > childs;
	bool flag;
	bool built;
	int yoko;
	int tate;
	void set(int a,int b,int n);
};
void tansa::set(int a,int b,int n){
	tate = a;
	yoko = b;
	flag = false;
	built = true;
	if(n==0){
	if(tate%2==0){
		if(tate-1>=0){
			childs.push_back(make_pair(tate-1,yoko));
			if(yoko-1>=0)
				childs.push_back(make_pair(tate-1,yoko-1));
		}
		if(tate+1<=h+1){
			childs.push_back(make_pair(tate+1,yoko));
			if(yoko-1>=0)
				childs.push_back(make_pair(tate+1,yoko-1));
		}
		if(yoko-1>=0)
			childs.push_back(make_pair(tate,yoko-1));
		if(yoko+1<=w+1)
			childs.push_back(make_pair(tate,yoko+1));
	}else{
		if(tate-1>=0){
			childs.push_back(make_pair(tate-1,yoko));
			if(yoko+1<=w+1)
				childs.push_back(make_pair(tate-1,yoko+1));
		}
		if(tate+1<=h+1){
			childs.push_back(make_pair(tate+1,yoko));
			if(yoko+1<=w+1)
				childs.push_back(make_pair(tate+1,yoko+1));
		}
		if(yoko-1>=0)
			childs.push_back(make_pair(tate,yoko-1));
		if(yoko+1<=w+1)
			childs.push_back(make_pair(tate,yoko+1));
	}
	built = false;
	}
}
int main(){
	cin>>w>>h;
	tansa d[102][102];
	for(int g=1;g<=h;g++){
	for(int i=1;i<=w;i++){
		int n;
		cin>>n;
		d[g][i].set(g,i,n);
	}}
	for(int i=1;i<w+1;i++){
		d[0][i].set(0,i,0);
		d[h+1][i].set(h+1,i,0);
	}
	for(int g=0;g<h+2;g++){
		d[g][0].set(g,0,0);
		d[g][w+1].set(g,w+1,0);
	}
	int st=0;
	queue<pair<int,int> > q;
	q.push(make_pair(0,0));
	while(!q.empty()){
		pair<int,int> k = q.front();
		q.pop();
		vector<pair<int,int> > t = d[k.first][k.second].childs;
		for(int i=0;i<t.size();i++){
			if(d[t[i].first][t[i].second].built){
				st++;
			}else if(d[t[i].first][t[i].second].flag==false){
				d[t[i].first][t[i].second].flag=true;
				q.push(make_pair(t[i].first,t[i].second));
			}
		}
	}
	cout<<st<<endl;
}
```


### Prompt

Construct a CPP code solution to the problem outlined:

Student Dima from Kremland has a matrix a of size n × m filled with non-negative integers.

He wants to select exactly one integer from each row of the matrix so that the bitwise exclusive OR of the selected integers is strictly greater than zero. Help him!

Formally, he wants to choose an integers sequence c_1, c_2, …, c_n (1 ≤ c_j ≤ m) so that the inequality a_{1, c_1} ⊕ a_{2, c_2} ⊕ … ⊕ a_{n, c_n} > 0 holds, where a_{i, j} is the matrix element from the i-th row and the j-th column.

Here x ⊕ y denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of integers x and y.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 500) — the number of rows and the number of columns in the matrix a.

Each of the next n lines contains m integers: the j-th integer in the i-th line is the j-th element of the i-th row of the matrix a, i.e. a_{i, j} (0 ≤ a_{i, j} ≤ 1023).

Output

If there is no way to choose one integer from each row so that their bitwise exclusive OR is strictly greater than zero, print "NIE".

Otherwise print "TAK" in the first line, in the next line print n integers c_1, c_2, … c_n (1 ≤ c_j ≤ m), so that the inequality a_{1, c_1} ⊕ a_{2, c_2} ⊕ … ⊕ a_{n, c_n} > 0 holds.

If there is more than one possible answer, you may output any.

Examples

Input

3 2
0 0
0 0
0 0

Output

NIE

Input

2 3
7 7 7
7 7 10

Output

TAK
1 3

Note

In the first example, all the numbers in the matrix are 0, so it is impossible to select one number in each row of the table so that their bitwise exclusive OR is strictly greater than zero.

In the second example, the selected numbers are 7 (the first number in the first line) and 10 (the third number in the second line), 7 ⊕ 10 = 13, 13 is more than 0, so the answer is found.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[505][505];
int dp[505][5];
pair<int, int> diff = make_pair(-1, -1);
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int prv = 0;
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
      if (j == 0)
        prv = a[i][j];
      else if (a[i][j] != prv)
        diff = make_pair(i, j);
    }
  }
  int cur = 0;
  for (int i = 0; i < n; i++) {
    cur ^= a[i][0];
  }
  if (cur != 0) {
    printf("TAK\n");
    for (int i = 0; i < n; i++) {
      printf("1 ");
    }
    printf("\n");
  } else {
    if (diff == make_pair(-1, -1)) {
      printf("NIE\n");
    } else {
      printf("TAK\n");
      for (int i = 0; i < n; i++) {
        if (i == diff.first)
          printf("%d ", diff.second + 1);
        else
          printf("1 ");
      }
    }
  }
  return 0;
}

```


### Prompt

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

You are given n positive integers a1, a2, ..., an.

For every ai you need to find a positive integer ki such that the decimal notation of 2ki contains the decimal notation of ai as a substring among its last min(100, length(2ki)) digits. Here length(m) is the length of the decimal notation of m.

Note that you don't have to minimize ki. The decimal notations in this problem do not contain leading zeros.

Input

The first line contains a single integer n (1 ≤ n ≤ 2 000) — the number of integers ai.

Each of the next n lines contains a positive integer ai (1 ≤ ai < 1011).

Output

Print n lines. The i-th of them should contain a positive integer ki such that the last min(100, length(2ki)) digits of 2ki contain the decimal notation of ai as a substring. Integers ki must satisfy 1 ≤ ki ≤ 1050.

It can be shown that the answer always exists under the given constraints. If there are multiple answers, print any of them.

Examples

Input

2
8
2

Output

3
1

Input

2
3
4857

Output

5
20

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void gmin(T &x, const T &y) {
  x = x > y ? y : x;
}
template <class T>
inline void gmax(T &x, const T &y) {
  x = x < y ? y : x;
}
template <class T>
inline bool Gmin(T &x, const T &y) {
  return x > y ? x = y, 1 : 0;
}
template <class T>
inline bool Gmax(T &x, const T &y) {
  return x < y ? x = y, 1 : 0;
}
const int BufferSize = 1 << 16;
char buffer[BufferSize], *Bufferhead, *Buffertail;
bool Terminal;
inline char Getchar() {
  if (Bufferhead == Buffertail) {
    int l = fread(buffer, 1, BufferSize, stdin);
    if (!l) {
      Terminal = 1;
      return 0;
    }
    Buffertail = (Bufferhead = buffer) + l;
  }
  return *Bufferhead++;
}
template <class T>
inline bool read(T &x) {
  x = 0;
  char c = Getchar(), rev = 0;
  while (c < '0' || c > '9') {
    rev |= c == '-';
    c = Getchar();
    if (Terminal) return 0;
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = Getchar();
  if (c == '.') {
    c = Getchar();
    double t = 0.1;
    while (c >= '0' && c <= '9')
      x = x + (c - '0') * t, c = Getchar(), t = t / 10;
  }
  x = rev ? -x : x;
  return 1;
}
template <class T1, class T2>
inline bool read(T1 &x, T2 &y) {
  return read(x) & read(y);
}
template <class T1, class T2, class T3>
inline bool read(T1 &x, T2 &y, T3 &z) {
  return read(x) & read(y) & read(z);
}
template <class T1, class T2, class T3, class T4>
inline bool read(T1 &x, T2 &y, T3 &z, T4 &w) {
  return read(x) & read(y) & read(z) & read(w);
}
inline bool reads(char *x) {
  char c = Getchar();
  while (c < 33 || c > 126) {
    c = Getchar();
    if (Terminal) return 0;
  }
  while (c >= 33 && c <= 126) (*x++) = c, c = Getchar();
  *x = 0;
  return 1;
}
template <class T>
inline void print(T x, const char c = '\n') {
  if (!x) {
    putchar('0');
    putchar(c);
    return;
  }
  if (x < 0) putchar('-'), x = -x;
  int m = 0, a[20];
  while (x) a[m++] = x % 10, x /= 10;
  while (m--) putchar(a[m] + '0');
  putchar(c);
}
const int inf = 0x3f3f3f3f;
const int N = 200005, M = 100005, mod = 1e9 + 7;
template <class T, class S>
inline void ch(T &x, const S y) {
  x = (x + y) % mod;
}
inline long long mul(long long x, long long y, long long mod) {
  long long t = x * y - (long long)((long double)x * y / mod + 0.1) * mod;
  return t < 0 ? t + mod : t;
}
inline long long exp(long long x, long long y, long long mod) {
  long long ans = 1;
  while (y) {
    if (y & 1) ans = mul(ans, x, mod);
    x = mul(x, x, mod);
    y >>= 1;
  }
  return ans;
}
inline int getlen(long long a) {
  int ans = 0;
  while (a) a /= 10, ans++;
  return ans;
}
inline long long calc(int g, int p, int a, long long x) {
  long long mod = p, phi = p - 1, d = 0;
  for (int i = 0, pw = 1; i < p; i++) {
    if (pw == x % p) {
      d = i;
      break;
    }
    pw = (long long)pw * g % p;
  }
  for (int i = 2; i <= a; i++) {
    mod *= p;
    for (;; d += phi)
      if (exp(g, d, mod) == x % mod) break;
    phi *= p;
  }
  return d;
}
int Main(int argv) {
  long long a;
  read(a);
  int n;
  n = getlen(a);
  for (int m = 0;; m++) {
    long long b = (-a) & ((1ll << n + m) - 1);
    cerr << "m"
         << "=" << m << endl;
    if (m && b % 5 == 0) b += (1ll << n + m);
    if (!m && a % 5 == 0) goto power;
    if (getlen(b) <= m) {
      print(calc(2, 5, n + m, (a + b) >> n + m) + n + m);
      return 0;
    }
  power:
    a *= 10;
  }
  return 0;
}
void clear() {}
int main() {
  int T;
  scanf("%d", &T);
  for (int i = 1; i <= T; i++) Main(i), clear();
  return 0;
}

```


### Prompt

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

Lee is going to fashionably decorate his house for a party, using some regular convex polygons...

Lee thinks a regular n-sided (convex) polygon is beautiful if and only if he can rotate it in such a way that at least one of its edges is parallel to the OX-axis and at least one of its edges is parallel to the OY-axis at the same time.

Recall that a regular n-sided polygon is a convex polygon with n vertices such that all the edges and angles are equal.

Now he is shopping: the market has t regular polygons. For each of them print YES if it is beautiful and NO otherwise.

Input

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

Each of the next t lines contains a single integer n_i (3 ≤ n_i ≤ 10^9): it means that the i-th polygon is a regular n_i-sided polygon.

Output

For each polygon, print YES if it's beautiful or NO otherwise (case insensitive).

Example

Input

4
3
4
12
1000000000

Output

NO
YES
YES
YES

Note

In the example, there are 4 polygons in the market. It's easy to see that an equilateral triangle (a regular 3-sided polygon) is not beautiful, a square (a regular 4-sided polygon) is beautiful and a regular 12-sided polygon (is shown below) is beautiful as well.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t, ans;
  long long int i, j, n;
  cin >> t;
  while (t--) {
    string ans = "NO";
    cin >> n;
    if (n % 4 == 0) {
      ans = "YES";
    }
    cout << ans << endl;
  }
}

```


### Prompt

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

The ancient Berlanders believed that the longer the name, the more important its bearer is. Thus, Berland kings were famous for their long names. But long names are somewhat inconvenient, so the Berlanders started to abbreviate the names of their kings. They called every king by the first letters of its name. Thus, the king, whose name was Victorious Vasily Pupkin, was always called by the berlanders VVP.

In Berland over its long history many dynasties of kings replaced each other, but they were all united by common traditions. Thus, according to one Berland traditions, to maintain stability in the country, the first name of the heir should be the same as the last name his predecessor (hence, the first letter of the abbreviated name of the heir coincides with the last letter of the abbreviated name of the predecessor). Berlanders appreciate stability, so this tradition has never been broken. Also Berlanders like perfection, so another tradition requires that the first name of the first king in the dynasty coincides with the last name of the last king in this dynasty (hence, the first letter of the abbreviated name of the first king coincides with the last letter of the abbreviated name of the last king). This tradition, of course, has also been always observed.

The name of a dynasty is formed by very simple rules: we take all the short names of the kings in the order in which they ruled, and write them in one line. Thus, a dynasty of kings "ab" and "ba" is called "abba", and the dynasty, which had only the king "abca", is called "abca".

Vasya, a historian, has recently found a list of abbreviated names of all Berland kings and their relatives. Help Vasya to find the maximally long name of the dynasty that could have existed in Berland.

Note that in his list all the names are ordered by the time, that is, if name A is earlier in the list than B, then if A and B were kings, then king A ruled before king B.

Input

The first line contains integer n (1 ≤ n ≤ 5·105) — the number of names in Vasya's list. Next n lines contain n abbreviated names, one per line. An abbreviated name is a non-empty sequence of lowercase Latin letters. Its length does not exceed 10 characters.

Output

Print a single number — length of the sought dynasty's name in letters.

If Vasya's list is wrong and no dynasty can be found there, print a single number 0.

Examples

Input

3
abc
ca
cba

Output

6

Input

4
vvp
vvp
dam
vvp

Output

0

Input

3
ab
c
def

Output

1

Note

In the first sample two dynasties can exist: the one called "abcca" (with the first and second kings) and the one called "abccba" (with the first and third kings).

In the second sample there aren't acceptable dynasties.

The only dynasty in the third sample consists of one king, his name is "c".

### Response

```cpp
#include <bits/stdc++.h>
const int G = 'z' - 'a' + 1;
int g[G][G];
char name[16];
int n;
int main() {
  memset(g, 0, sizeof(g));
  scanf(" %d", &n);
  for (int i = 0; i < n; ++i) {
    scanf(" %s", name);
    int len = strlen(name);
    int a = name[0] - 'a', b = name[len - 1] - 'a';
    for (int j = 0; j < 'z' - 'a' + 1; ++j)
      if (g[j][a] && g[j][b] < g[j][a] + len) g[j][b] = g[j][a] + len;
    g[a][b] = std::max(g[a][b], len);
  }
  int ans = 0;
  for (int i = 0; i < 'z' - 'a' + 1; ++i) ans = std::max(ans, g[i][i]);
  printf("%d\n", ans);
  return 0;
}

```


### Prompt

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

Arthur has bought a beautiful big table into his new flat. When he came home, Arthur noticed that the new table is unstable.

In total the table Arthur bought has n legs, the length of the i-th leg is li.

Arthur decided to make the table stable and remove some legs. For each of them Arthur determined number di — the amount of energy that he spends to remove the i-th leg.

A table with k legs is assumed to be stable if there are more than half legs of the maximum length. For example, to make a table with 5 legs stable, you need to make sure it has at least three (out of these five) legs of the maximum length. Also, a table with one leg is always stable and a table with two legs is stable if and only if they have the same lengths.

Your task is to help Arthur and count the minimum number of energy units Arthur should spend on making the table stable.

Input

The first line of the input contains integer n (1 ≤ n ≤ 105) — the initial number of legs in the table Arthur bought.

The second line of the input contains a sequence of n integers li (1 ≤ li ≤ 105), where li is equal to the length of the i-th leg of the table.

The third line of the input contains a sequence of n integers di (1 ≤ di ≤ 200), where di is the number of energy units that Arthur spends on removing the i-th leg off the table.

Output

Print a single integer — the minimum number of energy units that Arthur needs to spend in order to make the table stable.

Examples

Input

2
1 5
3 2

Output

2

Input

3
2 4 4
1 1 1

Output

0

Input

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

Output

8

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int M = 100005;
multiset<int> st;
multiset<int>::iterator it;
int n, x[M], y[M], len[M], sum[M];
pair<int, int> in[M];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &in[i].first);
  for (int i = 1; i <= n; i++) scanf("%d", &in[i].second);
  sort(in + 1, in + n + 1);
  for (int i = 1; i <= n; i++) {
    x[i] = in[i].first, y[i] = in[i].second;
    sum[i] += (sum[i - 1] + in[i].second);
  }
  for (int i = n; i > 0; i--) {
    if (x[i] == x[i + 1])
      len[i] = len[i + 1] + 1;
    else
      len[i] = 1;
  }
  int ans = 1 << 30;
  for (int i = 1; i <= n; i++) {
    if (x[i] != x[i - 1]) {
      int lim = len[i] - 1;
      int tmp = sum[n] - sum[i + len[i] - 1] + sum[i - 1];
      for (it = st.begin(); lim && it != st.end(); it++, lim--) {
        tmp += (*it);
      }
      ans = min(ans, tmp);
    }
    st.insert(-y[i]);
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

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

In Omkar's last class of math, he learned about the least common multiple, or LCM. LCM(a, b) is the smallest positive integer x which is divisible by both a and b.

Omkar, having a laudably curious mind, immediately thought of a problem involving the LCM operation: given an integer n, find positive integers a and b such that a + b = n and LCM(a, b) is the minimum value possible.

Can you help Omkar solve his ludicrously challenging math problem?

Input

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

Each test case consists of a single integer n (2 ≤ n ≤ 10^{9}).

Output

For each test case, output two positive integers a and b, such that a + b = n and LCM(a, b) is the minimum possible.

Example

Input

3
4
6
9

Output

2 2
3 3
3 6

Note

For the first test case, the numbers we can choose are 1, 3 or 2, 2. LCM(1, 3) = 3 and LCM(2, 2) = 2, so we output 2 \ 2.

For the second test case, the numbers we can choose are 1, 5, 2, 4, or 3, 3. LCM(1, 5) = 5, LCM(2, 4) = 4, and LCM(3, 3) = 3, so we output 3 \ 3.

For the third test case, LCM(3, 6) = 6. It can be shown that there are no other pairs of numbers which sum to 9 that have a lower LCM.

### Response

```cpp
#include <bits/stdc++.h>
int t, n, r1, r2, vec[10000], size = 0;
char prime[int(1e5)];
void sang() {
  prime[0] = prime[1] = 1;
  for (int i = 2; i < 1e5; i += 1) {
    if (!prime[i]) {
      vec[size++] = i;
      for (int j = i + i; j < 1e5; j += i) {
        prime[j] = 1;
      }
    }
  }
}
int main() {
  scanf("%i", &t);
  sang();
  while (t--) {
    scanf("%i", &n);
    r1 = 1;
    r2 = n - 1;
    for (int i = 0; i < size && vec[i] * vec[i] <= n; i += 1) {
      if (n % vec[i] == 0) {
        r1 = n / vec[i];
        r2 = n - r1;
        break;
      }
    }
    printf("%i %i\n", r1, r2);
  }
}

```


### Prompt

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

Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself, decides he wants to shuffle the guests around because he thinks this will create a vacancy (a room without a guest).

For any integer k and positive integer n, let kmod n denote the remainder when k is divided by n. More formally, r=kmod n is the smallest non-negative integer such that k-r is divisible by n. It always holds that 0≤ kmod n≤ n-1. For example, 100mod 12=4 and (-1337)mod 3=1.

Then the shuffling works as follows. There is an array of n integers a_0,a_1,…,a_{n-1}. Then for each integer k, the guest in room k is moved to room number k+a_{kmod n}.

After this shuffling process, determine if there is still exactly one guest assigned to each room. That is, there are no vacancies or rooms with multiple guests.

Input

Each test consists of multiple test cases. The first line contains a single integer t (1≤ t≤ 10^4) — the number of test cases. Next 2t lines contain descriptions of test cases.

The first line of each test case contains a single integer n (1≤ n≤ 2⋅ 10^5) — the length of the array.

The second line of each test case contains n integers a_0,a_1,…,a_{n-1} (-10^9≤ a_i≤ 10^9).

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

Output

For each test case, output a single line containing "YES" if there is exactly one guest assigned to each room after the shuffling process, or "NO" otherwise. You can print each letter in any case (upper or lower).

Example

Input

6
1
14
2
1 -1
4
5 5 5 1
3
3 2 1
2
0 1
5
-239 -2 -100 -3 -11

Output

YES
YES
YES
NO
NO
YES

Note

In the first test case, every guest is shifted by 14 rooms, so the assignment is still unique.

In the second test case, even guests move to the right by 1 room, and odd guests move to the left by 1 room. We can show that the assignment is still unique.

In the third test case, every fourth guest moves to the right by 1 room, and the other guests move to the right by 5 rooms. We can show that the assignment is still unique.

In the fourth test case, guests 0 and 1 are both assigned to room 3.

In the fifth test case, guests 1 and 2 are both assigned to room 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using llu = unsigned long long;
int mod(int a, int b) {
  int ret = a % b;
  if (ret < 0) return ret + b;
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> g(n);
    for (int k = 0; k < n; k++) {
      cin >> a[k];
      int r = mod(k + a[k], n);
      g[k]--;
      g[r]++;
    }
    bool good = true;
    for (int i : g) {
      if (i != 0) {
        good = false;
        break;
      }
    }
    if (good)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

The Hedgehog recently remembered one of his favorite childhood activities, — solving puzzles, and got into it with new vigor. He would sit day in, day out with his friend buried into thousands of tiny pieces of the picture, looking for the required items one by one.

Soon the Hedgehog came up with a brilliant idea: instead of buying ready-made puzzles, one can take his own large piece of paper with some picture and cut it into many small rectangular pieces, then mix them and solve the resulting puzzle, trying to piece together the picture. The resulting task is even more challenging than the classic puzzle: now all the fragments have the same rectangular shape, and one can assemble the puzzle only relying on the picture drawn on the pieces.

All puzzle pieces turn out to be of the same size X × Y, because the picture is cut first by horizontal cuts with the pitch of X, then with vertical cuts with the pitch of Y. If we denote the initial size of the picture as A × B, then A must be divisible by X and B must be divisible by Y (X and Y are integer numbers).

However, not every such cutting of the picture will result in a good puzzle. The Hedgehog finds a puzzle good if no two pieces in it are the same (It is allowed to rotate the pieces when comparing them, but it is forbidden to turn them over).

Your task is to count for a given picture the number of good puzzles that you can make from it, and also to find the puzzle with the minimal piece size.

Input

The first line contains two numbers A and B which are the sizes of the picture. They are positive integers not exceeding 20.

Then follow A lines containing B symbols each, describing the actual picture. The lines only contain uppercase English letters.

Output

In the first line print the number of possible good puzzles (in other words, the number of pairs (X, Y) such that the puzzle with the corresponding element sizes will be good). This number should always be positive, because the whole picture is a good puzzle itself.

In the second line print two numbers — the sizes X and Y of the smallest possible element among all good puzzles. The comparison is made firstly by the area XY of one element and secondly — by the length X.

Examples

Input

2 4
ABDC
ABDC

Output

3
2 1

Input

2 6
ABCCBA
ABCCBA

Output

1
2 6

Note

The picture in the first sample test has the following good puzzles: (2, 1), (2, 2), (2, 4).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline int __builtin_popcount(T n) {
  return (n == 0) ? 0 : (1 + __builtin_popcount(n & (n - 1)));
}
struct Ans {
  int x, y;
  bool operator<(const Ans& a) const {
    if (x * y == a.x * a.y) {
      return x < a.x;
    }
    return x * y < a.x * a.y;
  }
  Ans(int xx, int yy) {
    x = xx;
    y = yy;
  }
};
bool isOk(vector<vector<string> > vvs) {
  int N = vvs.size();
  for (int i = 0; i < (int)(N); i++) {
    vector<string> vs = vvs[i];
    int H = vs.size();
    int W = vs[0].size();
    vector<string> s0(H, ""), s1(H, ""), s2(W, ""), s3(W, "");
    for (int h = 0; h < (int)(H); h++) {
      string t0 = "", t1 = "";
      for (int w = 0; w < (int)(W); w++) {
        t0 += vs[h][w];
        t1 += vs[H - 1 - h][W - 1 - w];
      }
      s0[h] = t0;
      s1[h] = t1;
    }
    for (int w = 0; w < (int)(W); w++) {
      string t2 = "", t3 = "";
      for (int h = 0; h < (int)(H); h++) {
        t2 += vs[H - 1 - h][w];
        t3 += vs[h][W - 1 - w];
      }
      s2[w] = t2;
      s3[w] = t3;
    }
    for (int j = 0; j < (int)(N); j++) {
      if (i == j) continue;
      vector<string> vj = vvs[j];
      if (H == vj.size() && W == vj[0].size()) {
        bool isSame = true;
        for (int h = 0; h < (int)(H); h++)
          for (int w = 0; w < (int)(W); w++) {
            if (vj[h][w] != s0[h][w]) {
              isSame = false;
              h = H;
              break;
            }
          }
        if (isSame) return false;
        isSame = true;
        for (int h = 0; h < (int)(H); h++)
          for (int w = 0; w < (int)(W); w++) {
            if (vj[h][w] != s1[h][w]) {
              isSame = false;
              h = H;
              break;
            }
          }
        if (isSame) return false;
      }
      if (H == vj[0].size() && W == vj.size()) {
        bool isSame = true;
        for (int h = 0; h < (int)(H); h++)
          for (int w = 0; w < (int)(W); w++) {
            if (vj[w][h] != s2[w][h]) {
              isSame = false;
              h = H;
              break;
            }
          }
        if (isSame) return false;
        isSame = true;
        for (int h = 0; h < (int)(H); h++)
          for (int w = 0; w < (int)(W); w++) {
            if (vj[w][h] != s3[w][h]) {
              isSame = false;
              h = H;
              break;
            }
          }
        if (isSame) return false;
      }
    }
  }
  return true;
}
int main() {
  int A, B;
  cin >> A >> B;
  int resNum = 0;
  Ans res = Ans(100, 100);
  vector<string> pic(A, "");
  for (int i = 0; i < (int)(A); i++) cin >> pic[i];
  for (int a = A; a > 0; a--)
    if (A % a == 0) {
      for (int b = B; b > 0; b--)
        if (B % b == 0) {
          bool isGood = true;
          vector<vector<string> > tmp;
          tmp.clear();
          for (int y = 0; y < A; y += a) {
            for (int x = 0; x < B; x += b) {
              vector<string> piece;
              for (int yy = y; yy < y + a; yy++) {
                piece.push_back(pic[yy].substr(x, b));
              }
              tmp.push_back(piece);
            }
          }
          if (isOk(tmp)) {
            resNum++;
            res = min(res, Ans(a, b));
          }
        }
    }
  cout << resNum << endl;
  cout << res.x << " " << res.y << endl;
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

A chessboard n × m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all such squares are repainted simultaneously). This process continues ad infinitum. You have to figure out how many squares we repainted exactly x times.

The upper left square of the board has to be assumed to be always black. Two squares are called corner-adjacent, if they have exactly one common point.

Input

The first line contains integers n and m (1 ≤ n, m ≤ 5000). The second line contains integer x (1 ≤ x ≤ 109).

Output

Print how many squares will be painted exactly x times.

Examples

Input

3 3
1

Output

4

Input

3 3
2

Output

1

Input

1 1
1

Output

1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int con = 1;
  while (x != con && n > 2 && m > 2) {
    n -= 2;
    m -= 2;
    con++;
  }
  if (x != con) {
    cout << 0 << endl;
  } else {
    if (m > 1 && n > 1) {
      int r = m + n + m + n - 4;
      cout << r / 2 << endl;
    } else {
      if (m == 1) {
        cout << (n + 1) / 2 << endl;
      } else {
        cout << (m + 1) / 2 << endl;
      }
    }
  }
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

The Berland capital is shaken with three bold crimes committed by the Pihsters, a notorious criminal gang.

The Berland capital's map is represented by an n × m rectangular table. Each cell of the table on the map represents some districts of the capital.

The capital's main detective Polycarpus took a map and marked there the districts where the first three robberies had been committed as asterisks. Deduction tells Polycarpus that the fourth robbery will be committed in such district, that all four robbed districts will form the vertices of some rectangle, parallel to the sides of the map.

Polycarpus is good at deduction but he's hopeless at math. So he asked you to find the district where the fourth robbery will be committed.

Input

The first line contains two space-separated integers n and m (2 ≤ n, m ≤ 100) — the number of rows and columns in the table, correspondingly.

Each of the next n lines contains m characters — the description of the capital's map. Each character can either be a "." (dot), or an "*" (asterisk). A character equals "*" if the corresponding district has been robbed. Otherwise, it equals ".".

It is guaranteed that the map has exactly three characters "*" and we can always find the fourth district that meets the problem requirements.

Output

Print two integers — the number of the row and the number of the column of the city district that is the fourth one to be robbed. The rows are numbered starting from one from top to bottom and the columns are numbered starting from one from left to right.

Examples

Input

3 2
.*
..
**

Output

1 1

Input

3 3
*.*
*..
...

Output

2 3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  vector<pair<int, int>> v;
  string s[200];
  for (int i = 0; i < x; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      if (s[i][j] == '*') {
        v.push_back(make_pair(i, j));
      }
    }
  }
  int y1, y2, x1, x2;
  y1 = v[0].first;
  if (v[0].first == v[1].first) {
    y2 = v[2].first;
  } else {
    y2 = v[1].first;
  }
  x1 = v[0].second;
  x2 = v[1].second == v[0].second ? v[2].second : v[1].second;
  int y3 = (y1 + y2) * 2 - (v[0].first + v[1].first + v[2].first);
  int x3 = (x1 + x2) * 2 - (v[0].second + v[1].second + v[2].second);
  cout << y3 + 1 << " " << x3 + 1;
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

Only T milliseconds left before the start of well-known online programming contest Codehorses Round 2017.

Polycarp needs to download B++ compiler to take part in the contest. The size of the file is f bytes.

Polycarp's internet tariff allows to download data at the rate of one byte per t0 milliseconds. This tariff is already prepaid, and its use does not incur any expense for Polycarp. In addition, the Internet service provider offers two additional packages:

  * download a1 bytes at the rate of one byte per t1 milliseconds, paying p1 burles for the package;
  * download a2 bytes at the rate of one byte per t2 milliseconds, paying p2 burles for the package.

Polycarp can buy any package many times. When buying a package, its price (p1 or p2) is prepaid before usage. Once a package is bought it replaces the regular tariff until package data limit is completely used. After a package is consumed Polycarp can immediately buy a new package or switch to the regular tariff without loosing any time. While a package is in use Polycarp can't buy another package or switch back to the regular internet tariff.

Find the minimum amount of money Polycarp has to spend to download an f bytes file no more than in T milliseconds.

Note that because of technical reasons Polycarp can download only integer number of bytes using regular tariff and both packages. I.e. in each of three downloading modes the number of downloaded bytes will be integer. It means that Polycarp can't download a byte partially using the regular tariff or/and both packages.

Input

The first line contains three integer numbers f, T and t0 (1 ≤ f, T, t0 ≤ 107) — size of the file to download (in bytes), maximal time to download the file (in milliseconds) and number of milliseconds to download one byte using the regular internet tariff.

The second line contains a description of the first additional package. The line contains three integer numbers a1, t1 and p1 (1 ≤ a1, t1, p1 ≤ 107), where a1 is maximal sizes of downloaded data (in bytes), t1 is time to download one byte (in milliseconds), p1 is price of the package (in burles).

The third line contains a description of the second additional package. The line contains three integer numbers a2, t2 and p2 (1 ≤ a2, t2, p2 ≤ 107), where a2 is maximal sizes of downloaded data (in bytes), t2 is time to download one byte (in milliseconds), p2 is price of the package (in burles).

Polycarp can buy any package many times. Once package is bought it replaces the regular tariff until package data limit is completely used. While a package is in use Polycarp can't buy another package or switch back to the regular internet tariff.

Output

Print the minimum amount of money that Polycarp needs to pay to download B++ compiler no more than in T milliseconds. If there is no solution, print the only integer -1.

Examples

Input

120 964 20
26 8 8
13 10 4

Output

40

Input

10 200 20
1 1 1
2 2 3

Output

0

Input

8 81 11
4 10 16
3 10 12

Output

28

Input

8 79 11
4 10 16
3 10 12

Output

-1

Note

In the first example Polycarp has to buy the first additional package 5 times and do not buy the second additional package. He downloads 120 bytes (of total 26·5 = 130 bytes) in 120·8 = 960 milliseconds (960 ≤ 964). He spends 8·5 = 40 burles on it.

In the second example Polycarp has enough time to download 10 bytes. It takes 10·20 = 200 milliseconds which equals to upper constraint on download time.

In the third example Polycarp has to buy one first additional package and one second additional package.

In the fourth example Polycarp has no way to download the file on time.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18;
long long f, T, t0;
long long a1, t1, p1, a2, t2, p2;
int main() {
  cin >> f >> T >> t0;
  cin >> a1 >> t1 >> p1;
  cin >> a2 >> t2 >> p2;
  long long res = INF;
  for (int swapped = 0; swapped < 2; swapped++) {
    if (swapped) {
      swap(a1, a2);
      swap(t1, t2);
      swap(p1, p2);
    }
    for (long long c1 = 0; c1 * a1 <= f + a1; c1++) {
      long long rem_f = max(0LL, f - c1 * a1);
      if (t1 * min(a1 * c1, f) + min(t2, t0) * rem_f > T) continue;
      if (t2 >= t0) {
        res = min(res, c1 * p1);
      } else {
        res = min(res, c1 * p1 + (rem_f + a2 - 1) / a2 * p2);
        long long over_t = max(0LL, rem_f * t0 + t1 * (f - rem_f) - T);
        long long mn_c2 = (over_t + a2 * (t0 - t2) - 1) / ((t0 - t2) * a2);
        if (mn_c2 * a2 <= rem_f) {
          res = min(res, c1 * p1 + mn_c2 * p2);
        }
      }
    }
  }
  cout << (res == INF ? -1 : res) << '\n';
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Sereja adores trees. Today he came up with a revolutionary new type of binary root trees.

His new tree consists of n levels, each vertex is indexed by two integers: the number of the level and the number of the vertex on the current level. The tree root is at level 1, its index is (1, 1). Here is a pseudo code of tree construction.

    //the global data are integer arrays cnt[], left[][], right[][]

    cnt[1] = 1;
    fill arrays left[][], right[][] with values -1;
    for(level = 1; level < n; level = level + 1){
        cnt[level + 1] = 0;
        for(position = 1; position <= cnt[level]; position = position + 1){
            if(the value of position is a power of two){ // that is, 1, 2, 4, 8...
                left[level][position] = cnt[level + 1] + 1;
                right[level][position] = cnt[level + 1] + 2;
                cnt[level + 1] = cnt[level + 1] + 2;
            }else{
                right[level][position] = cnt[level + 1] + 1;
                cnt[level + 1] = cnt[level + 1] + 1;
            }
        }
    }

After the pseudo code is run, cell cnt[level] contains the number of vertices on level level. Cell left[level][position] contains the number of the vertex on the level level + 1, which is the left child of the vertex with index (level, position), or it contains -1, if the vertex doesn't have a left child. Similarly, cell right[level][position] is responsible for the right child. You can see how the tree with n = 4 looks like in the notes.

Serja loves to make things complicated, so he first made a tree and then added an empty set A(level, position) for each vertex. Then Sereja executes m operations. Each operation is of one of the two following types:

  * The format of the operation is "1 t l r x". For all vertices level, position (level = t; l ≤ position ≤ r) add value x to set A(level, position).
  * The format of the operation is "2 t v". For vertex level, position (level = t, position = v), find the union of all sets of vertices that are in the subtree of vertex (level, position). Print the size of the union of these sets.

Help Sereja execute the operations. In this problem a set contains only distinct values like std::set in C++.

Input

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

Next m lines contain the descriptions of the operations. The operation of the first type is given by five integers: 1 t l r x (1 ≤ t ≤ n; 1 ≤ l ≤ r ≤ cnt[t]; 1 ≤ x ≤ 106). The operation of the second type is given by three integers: 2 t v (1 ≤ t ≤ n; 1 ≤ v ≤ cnt[t]).

Output

For each operation of the second type, print the answer on a single line.

Examples

Input

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

Output

2
0
1

Note

You can find the definitions that are used while working with root trees by this link: http://en.wikipedia.org/wiki/Tree_(graph_theory)

You can see an example of a constructed tree at n = 4 below.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct _ {
  _() { ios_base::sync_with_stdio(0); }
} _;
template <class T>
void PV(T a, T b) {
  while (a != b) cout << *a++, cout << (a != b ? " " : "\n");
}
template <class T>
inline bool chmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
inline bool chmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
string tostring(T first, int len = 0) {
  stringstream ss;
  ss << first;
  string r = ss.str();
  if (r.length() < len) r = string(len - r.length(), '0') + r;
  return r;
}
template <class T>
void convert(string first, T &r) {
  stringstream ss(first);
  ss >> r;
}
template <class A, class B>
ostream &operator<<(ostream &o, pair<A, B> t) {
  o << "(" << t.first << ", " << t.second << ")";
  return o;
}
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 7001;
int n, m;
vector<pair<pair<int, int>, int> > level[N];
int c[1000010];
void init() {
  c[1] = 1;
  for (int i = 2; i < 1000010; i++) {
    if ((i - 1) & (i - 2))
      c[i] = c[i - 1] + 1;
    else
      c[i] = c[i - 1] + 2;
  }
}
int main() {
  cin >> n >> m;
  init();
  while (m--) {
    int op;
    cin >> op;
    if (op == 1) {
      int lev, l, r, first;
      cin >> lev >> l >> r >> first;
      level[lev].push_back(make_pair(make_pair(l, r), first));
    } else {
      int lev, pos;
      cin >> lev >> pos;
      vector<int> v;
      int l = pos, r = pos;
      for (int j = lev; j <= n; j++) {
        for (auto i : level[j]) {
          int left = i.first.first;
          int right = i.first.second;
          if (left > r || right < l) continue;
          v.push_back(i.second);
        }
        l = c[l];
        r = c[r + 1] - 1;
      }
      sort((v).begin(), (v).end()),
          v.resize(unique((v).begin(), (v).end()) - v.begin());
      cout << v.size() << endl;
    }
  }
  return 0;
}

```


### Prompt

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

It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.

Marmot brought Mole n ordered piles of worms such that i-th pile contains ai worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to a1, worms in second pile are labeled with numbers a1 + 1 to a1 + a2 and so on. See the example for a better understanding.

Mole can't eat all the worms (Marmot brought a lot) and, as we all know, Mole is blind, so Marmot tells him the labels of the best juicy worms. Marmot will only give Mole a worm if Mole says correctly in which pile this worm is contained.

Poor Mole asks for your help. For all juicy worms said by Marmot, tell Mole the correct answers.

Input

The first line contains a single integer n (1 ≤ n ≤ 105), the number of piles.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 103, a1 + a2 + ... + an ≤ 106), where ai is the number of worms in the i-th pile.

The third line contains single integer m (1 ≤ m ≤ 105), the number of juicy worms said by Marmot.

The fourth line contains m integers q1, q2, ..., qm (1 ≤ qi ≤ a1 + a2 + ... + an), the labels of the juicy worms.

Output

Print m lines to the standard output. The i-th line should contain an integer, representing the number of the pile where the worm labeled with the number qi is.

Examples

Input

5
2 7 3 4 9
3
1 25 11

Output

1
5
3

Note

For the sample input:

  * The worms with labels from [1, 2] are in the first pile.
  * The worms with labels from [3, 9] are in the second pile.
  * The worms with labels from [10, 12] are in the third pile.
  * The worms with labels from [13, 16] are in the fourth pile.
  * The worms with labels from [17, 25] are in the fifth pile.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, arr[1000009], j = 1, m;
  memset(arr, 0, sizeof arr);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    for (int k = 0; k < a; k++) {
      arr[j++] = i;
    }
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    cout << arr[a] << endl;
  }
  return 0;
}

```


### Prompt

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

Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in the orchestra. Count the number of possible pictures that Paul can take.

Two pictures are considered to be different if the coordinates of corresponding rectangles are different.

Input

The first line of input contains four space-separated integers r, c, n, k (1 ≤ r, c, n ≤ 10, 1 ≤ k ≤ n) — the number of rows and columns of the string section, the total number of violas, and the minimum number of violas Paul would like in his photograph, respectively.

The next n lines each contain two integers xi and yi (1 ≤ xi ≤ r, 1 ≤ yi ≤ c): the position of the i-th viola. It is guaranteed that no location appears more than once in the input.

Output

Print a single integer — the number of photographs Paul can take which include at least k violas.

Examples

Input

2 2 1 1
1 2

Output

4

Input

3 2 3 3
1 1
3 1
2 2

Output

1

Input

3 2 3 2
1 1
3 1
2 2

Output

4

Note

We will use '*' to denote violinists and '#' to denote violists.

In the first sample, the orchestra looks as follows

    *#
    **

Paul can take a photograph of just the viola, the 1 × 2 column containing the viola, the 2 × 1 row containing the viola, or the entire string section, for 4 pictures total.

In the second sample, the orchestra looks as follows

    #*
    *#
    #*

Paul must take a photograph of the entire section.

In the third sample, the orchestra looks the same as in the second sample.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[11][11];
int main() {
  int r, c, n, K;
  cin >> r >> c >> n >> K;
  for (int i = 0; i < n; i++) {
    int x, y;
    ;
    cin >> x >> y;
    a[x - 1][y - 1] = 1;
  }
  int cnt = 0;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      int cur = 0;
      for (int k = i; k < r; k++) {
        for (int l = j; l < c; l++) {
          int cur = 0;
          for (int m = i; m <= k; m++) {
            for (int p = j; p <= l; p++) {
              if (a[m][p] == 1) {
                cur++;
              }
            }
          }
          if (cur >= K) {
            cnt++;
          }
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

```


### Prompt

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

Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:

You are given two integers d, m, find the number of arrays a, satisfying the following constraints:

  * The length of a is n, n ≥ 1
  * 1 ≤ a_1 < a_2 < ... < a_n ≤ d
  * Define an array b of length n as follows: b_1 = a_1, ∀ i > 1, b_i = b_{i - 1} ⊕ a_i, where ⊕ is the bitwise exclusive-or (xor). After constructing an array b, the constraint b_1 < b_2 < ... < b_{n - 1} < b_n should hold.

Since the number of possible arrays may be too large, you need to find the answer modulo m.

Input

The first line contains an integer t (1 ≤ t ≤ 100) denoting the number of test cases in the input.

Each of the next t lines contains two integers d, m (1 ≤ d, m ≤ 10^9).

Note that m is not necessary the prime!

Output

For each test case, print the number of arrays a, satisfying all given constrains, modulo m.

Example

Input

10
1 1000000000
2 999999999
3 99999998
4 9999997
5 999996
6 99995
7 9994
8 993
9 92
10 1

Output

1
3
5
11
17
23
29
59
89
0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void file(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
template <typename Tp>
void read(Tp &x) {
  long long fh = 1;
  char c = getchar();
  x = 0;
  while (c > '9' || c < '0') {
    if (c == '-') {
      fh = -1;
    }
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c & 15);
    c = getchar();
  }
  x *= fh;
}
long long n, m;
long long ans[50], sm = 0;
map<long long, long long> LG;
signed main() {
  for (long long i = 0; i <= 31; i++) LG[1ll << i] = i;
  long long T;
  read(T);
  while (T--) {
    sm = 0;
    memset(ans, 0, sizeof(ans));
    read(n);
    read(m);
    if (n == 1) {
      printf("%I64d\n", 1 % m);
      continue;
    }
    long long N;
    for (N = 1; (N << 1) <= n; N <<= 1)
      ;
    ans[LG[N]] = 1;
    ans[LG[N] - 1] = n - N + 2;
    for (long long i = LG[N] - 2; i >= 0; i--) {
      ans[i] = ans[i + 1] * ((1ll << (i + 1)) + 1) % m;
    }
    for (long long i = 0; i <= LG[N] - 1; i++) {
      sm = (sm + ans[i] * (1ll << (i)) % m) % m;
    }
    sm = (sm + n - N + 1) % m;
    printf("%I64d\n", sm);
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}

```


### Prompt

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

Polycarp is practicing his problem solving skill. He has a list of n problems with difficulties a_1, a_2, ..., a_n, respectively. His plan is to practice for exactly k days. Each day he has to solve at least one problem from his list. Polycarp solves the problems in the order they are given in his list, he cannot skip any problem from his list. He has to solve all n problems in exactly k days.

Thus, each day Polycarp solves a contiguous sequence of (consecutive) problems from the start of the list. He can't skip problems or solve them multiple times. As a result, in k days he will solve all the n problems.

The profit of the j-th day of Polycarp's practice is the maximum among all the difficulties of problems Polycarp solves during the j-th day (i.e. if he solves problems with indices from l to r during a day, then the profit of the day is max_{l ≤ i ≤ r}a_i). The total profit of his practice is the sum of the profits over all k days of his practice.

You want to help Polycarp to get the maximum possible total profit over all valid ways to solve problems. Your task is to distribute all n problems between k days satisfying the conditions above in such a way, that the total profit is maximum.

For example, if n = 8, k = 3 and a = [5, 4, 2, 6, 5, 1, 9, 2], one of the possible distributions with maximum total profit is: [5, 4, 2], [6, 5], [1, 9, 2]. Here the total profit equals 5 + 6 + 9 = 20.

Input

The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 2000) — the number of problems and the number of days, respectively.

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 2000) — difficulties of problems in Polycarp's list, in the order they are placed in the list (i.e. in the order Polycarp will solve them).

Output

In the first line of the output print the maximum possible total profit.

In the second line print exactly k positive integers t_1, t_2, ..., t_k (t_1 + t_2 + ... + t_k must equal n), where t_j means the number of problems Polycarp will solve during the j-th day in order to achieve the maximum possible total profit of his practice.

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

Examples

Input

8 3
5 4 2 6 5 1 9 2

Output

20
3 2 3

Input

5 1
1 1 1 1 1

Output

1
5

Input

4 2
1 2000 2000 2

Output

4000
2 2

Note

The first example is described in the problem statement.

In the second example there is only one possible distribution.

In the third example the best answer is to distribute problems in the following way: [1, 2000], [2000, 2]. The total profit of this distribution is 2000 + 2000 = 4000.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
struct node {
  int num, x;
} a[maxn];
int n, k;
int b[maxn];
bool compare(node a, node b) { return a.x > b.x; }
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].x);
    a[i].num = i;
  }
  int ans = 0;
  sort(a + 1, a + n + 1, compare);
  for (int i = 1; i <= k; i++) {
    b[i] = a[i].num;
    ans += a[i].x;
  }
  sort(b + 1, b + k + 1);
  printf("%d\n", ans);
  if (k != 1) printf("%d ", b[1]);
  for (int i = 2; i < k; i++) printf("%d ", b[i] - b[i - 1]);
  if (k != 1)
    printf("%d", n - b[k - 1]);
  else
    printf("%d", n);
  return 0;
}

```


### Prompt

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

Given is a string S. Let T be the concatenation of K copies of S. We can repeatedly perform the following operation: choose a character in T and replace it with a different character. Find the minimum number of operations required to satisfy the following condition: any two adjacent characters in T are different.

Constraints

* 1 \leq |S| \leq 100
* S consists of lowercase English letters.
* 1 \leq K \leq 10^9
* K is an integer.

Input

Input is given from Standard Input in the following format:

S
K

Output

Print the minimum number of operations required.

Examples

Input

issii
2

Output

4

Input

qq
81

Output

81

Input

cooooooooonteeeeeeeeeest
999993333

Output

8999939997

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	ll k;
	cin>>k;
	ll m1,m2;
	m1=m2=0;
	string t='A'+s;
	string u=s[s.size()-1]+s;
	for(ll i=1;i<=t.size();i++){
		if(t[i]==t[i-1]){
			t[i]='A';
			m1++;
		}
	}
	for(ll i=1;i<=u.size();i++){
		if(u[i]==u[i-1]){
			u[i]='A';
			m2++;
		}
	}
	if(t[1]!=t[t.size()-1]){
		cout<<k*m1;
	}
	else{
		if(u[1]!=u[u.size()-1]){
			cout << m1+(k-1)*m2;
		}
		else{
			cout << k/2*(m1+m2)+k%2*m1;
		}
	}
	// your code goes here
	return 0;
}
```


### Prompt

Construct a CPP code solution to the problem outlined:

There are many anime that are about "love triangles": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to n. Every pair of two characters can either mutually love each other or mutually hate each other (there is no neutral state).

You hate love triangles (A-B are in love and B-C are in love, but A-C hate each other), and you also hate it when nobody is in love. So, considering any three characters, you will be happy if exactly one pair is in love (A and B love each other, and C hates both A and B), or if all three pairs are in love (A loves B, B loves C, C loves A).

You are given a list of m known relationships in the anime. You know for sure that certain pairs love each other, and certain pairs hate each other. You're wondering how many ways you can fill in the remaining relationships so you are happy with every triangle. Two ways are considered different if two characters are in love in one way but hate each other in the other. Print this count modulo 1 000 000 007.

Input

The first line of input will contain two integers n, m (3 ≤ n ≤ 100 000, 0 ≤ m ≤ 100 000).

The next m lines will contain the description of the known relationships. The i-th line will contain three integers ai, bi, ci. If ci is 1, then ai and bi are in love, otherwise, they hate each other (1 ≤ ai, bi ≤ n, ai ≠ bi, <image>).

Each pair of people will be described no more than once.

Output

Print a single integer equal to the number of ways to fill in the remaining pairs so that you are happy with every triangle modulo 1 000 000 007.

Examples

Input

3 0

Output

4

Input

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

Output

1

Input

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

Output

0

Note

In the first sample, the four ways are to:

  * Make everyone love each other
  * Make 1 and 2 love each other, and 3 hate 1 and 2 (symmetrically, we get 3 ways from this).

In the second sample, the only possible solution is to make 1 and 3 love each other and 2 and 4 hate each other.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;
int n, m, x, y, type, h[N];
vector<pair<int, int> > v[N];
queue<int> q;
int main() {
  cin >> n >> m;
  for (auto i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &type);
    v[x].push_back(pair<int, int>(type ^ 1, y));
    v[y].push_back(pair<int, int>(type ^ 1, x));
  }
  int ans = 1;
  memset(h, -1, sizeof(h));
  for (auto i = 1; i <= n; i++)
    if (h[i] == -1) {
      h[i] = 0;
      q.push(i);
      while (!q.empty()) {
        int x = q.front();
        q.pop();
        for (auto j : v[x]) {
          int y = j.second, ns = h[x] ^ j.first;
          if (h[y] == -1) {
            h[y] = ns;
            q.push(y);
          } else if (h[y] != ns) {
            printf("0");
            return 0;
          }
        }
      }
      if (i != 1) ans = ans * 2 % MOD;
    }
  cout << ans;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Miki is a high school student. She has a part time job, so she cannot take enough sleep on weekdays. She wants to take good sleep on holidays, but she doesn't know the best length of sleeping time for her. She is now trying to figure that out with the following algorithm:

1. Begin with the numbers K, R and L.
2. She tries to sleep for H=(R+L)/2 hours.
3. If she feels the time is longer than or equal to the optimal length, then update L with H. Otherwise, update R with H.
4. After repeating step 2 and 3 for K nights, she decides her optimal sleeping time to be T' = (R+L)/2.

If her feeling is always correct, the steps described above should give her a very accurate optimal sleeping time. But unfortunately, she makes mistake in step 3 with the probability P.

Assume you know the optimal sleeping time T for Miki. You have to calculate the probability PP that the absolute difference of T' and T is smaller or equal to E. It is guaranteed that the answer remains unaffected by the change of E in 10^{-10}.

Input

The input follows the format shown below

K R L
P
E
T

Where the integers 0 \leq K \leq 30, 0 \leq R \leq L \leq 12 are the parameters for the algorithm described above. The decimal numbers on the following three lines of the input gives the parameters for the estimation. You can assume 0 \leq P \leq 1, 0 \leq E \leq 12, 0 \leq T \leq 12.

Output

Output PP in one line. The output should not contain an error greater than 10^{-5}.

Examples

Input

3 0 2
0.10000000000
0.50000000000
1.00000000000

Output

0.900000

Input

3 0 2
0.10000000000
0.37499999977
1.00000000000

Output

0.810000

Input

3 0 2
0.10000000000
0.00000100000
0.37500000000

Output

0.729000

Input

3 0 2
0.20000000000
0.00000100000
0.37500000000

Output

0.512000

### Response

```cpp
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

double k, l, r, p, e, t;
double rec(int k, double l, double r){
	if(l >= t - e && r <= t + e) return 1.0;
	if(r < t - e || l > t + e) return 0.0;
	if(k == 0) return abs(t - (l + r) / 2) <= e ? 1.0 : 0.0;

	double m = (l + r) / 2, res = 0;
	if(m < t){
		res += rec(k - 1, m, r) * (1 - p);
		res += rec(k - 1, l, m) * p;
	}
	else{
		res += rec(k - 1, l, m) * (1 - p);
		res += rec(k - 1, m, r) * p;
	}
	return res;
}
int main(){
	cin >> k >> l >> r;
	cin >> p >> e >> t;
	double ans = rec(k, l, r);
	printf("%.9f\n", ans);
	return 0;
}
```


### Prompt

Construct a CPP code solution to the problem outlined:

Michael has just bought a new electric car for moving across city. Michael does not like to overwork, so each day he drives to only one of two his jobs.

Michael's day starts from charging his electric car for getting to the work and back. He spends 1000 burles on charge if he goes to the first job, and 2000 burles if he goes to the second job.

On a charging station he uses there is a loyalty program that involves bonus cards. Bonus card may have some non-negative amount of bonus burles. Each time customer is going to buy something for the price of x burles, he is allowed to pay an amount of y (0 ≤ y ≤ x) burles that does not exceed the bonus card balance with bonus burles. In this case he pays x - y burles with cash, and the balance on the bonus card is decreased by y bonus burles.

If customer pays whole price with cash (i.e., y = 0) then 10% of price is returned back to the bonus card. This means that bonus card balance increases by <image> bonus burles. Initially the bonus card balance is equal to 0 bonus burles.

Michael has planned next n days and he knows how much does the charge cost on each of those days. Help Michael determine the minimum amount of burles in cash he has to spend with optimal use of bonus card. Assume that Michael is able to cover any part of the price with cash in any day. It is not necessary to spend all bonus burles at the end of the given period.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 300 000), the number of days Michael has planned.

Next line contains n integers a1, a2, ..., an (ai = 1000 or ai = 2000) with ai denoting the charging cost at the day i.

Output

Output the minimum amount of burles Michael has to spend.

Examples

Input

3
1000 2000 1000

Output

3700

Input

6
2000 2000 2000 2000 2000 1000

Output

10000

Note

In the first sample case the most optimal way for Michael is to pay for the first two days spending 3000 burles and get 300 bonus burles as return. After that he is able to pay only 700 burles for the third days, covering the rest of the price with bonus burles.

In the second sample case the most optimal way for Michael is to pay the whole price for the first five days, getting 1000 bonus burles as return and being able to use them on the last day without paying anything in cash.

### Response

```cpp
#include <bits/stdc++.h>
const int N = 3e5 + 10;
using namespace std;
int n, A[N];
int dp[2][35];
int main() {
  memset(dp, 0x3f, sizeof(dp));
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &A[i]);
    A[i] /= 100;
  }
  int s = 0, t = 1;
  dp[0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    int a = A[i] / 10;
    for (int j = 0; j <= 31; ++j)
      if (dp[s][j] < dp[0][32]) {
        if (j + a <= 31) dp[t][j + a] = min(dp[t][j + a], dp[s][j] + A[i]);
        int b = min(j, A[i]);
        if (b) dp[t][j - b] = min(dp[t][j - b], dp[s][j] + A[i] - b);
        dp[s][j] = dp[0][32];
      }
    swap(s, t);
  }
  int ans = dp[0][32];
  for (int i = 0; i < 20; ++i) ans = min(ans, dp[s][i]);
  printf("%d00\n", ans);
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

A and B are preparing themselves for programming contests.

The University where A and B study is a set of rooms connected by corridors. Overall, the University has n rooms connected by n - 1 corridors so that you can get from any room to any other one by moving along the corridors. The rooms are numbered from 1 to n.

Every day А and B write contests in some rooms of their university, and after each contest they gather together in the same room and discuss problems. A and B want the distance from the rooms where problems are discussed to the rooms where contests are written to be equal. The distance between two rooms is the number of edges on the shortest path between them.

As they write contests in new rooms every day, they asked you to help them find the number of possible rooms to discuss problems for each of the following m days.

Input

The first line contains integer n (1 ≤ n ≤ 105) — the number of rooms in the University.

The next n - 1 lines describe the corridors. The i-th of these lines (1 ≤ i ≤ n - 1) contains two integers ai and bi (1 ≤ ai, bi ≤ n), showing that the i-th corridor connects rooms ai and bi.

The next line contains integer m (1 ≤ m ≤ 105) — the number of queries.

Next m lines describe the queries. The j-th of these lines (1 ≤ j ≤ m) contains two integers xj and yj (1 ≤ xj, yj ≤ n) that means that on the j-th day A will write the contest in the room xj, B will write in the room yj.

Output

In the i-th (1 ≤ i ≤ m) line print the number of rooms that are equidistant from the rooms where A and B write contest on the i-th day.

Examples

Input

4
1 2
1 3
2 4
1
2 3

Output

1

Input

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

Output

0
2

Note

in the first sample there is only one room at the same distance from rooms number 2 and 3 — room number 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n;
int T;
int pa[N];
int tin[N];
int tout[N];
int kp[N][20];
int d[N];
int sz[N];
vector<int> g[N];
void dfs(int x) {
  tin[x] = T++;
  sz[x] = 1;
  for (int i = 0; i < g[x].size(); ++i) {
    int y = g[x][i];
    if (y != pa[x]) {
      d[y] = d[x] + 1;
      pa[y] = x;
      dfs(y);
      sz[x] += sz[y];
    }
  }
  tout[x] = T++;
}
bool anc(int x, int y) { return tin[x] <= tin[y] && tout[x] >= tout[y]; }
int lca(int x, int y) {
  if (anc(x, y)) {
    return x;
  }
  for (int i = 19; i >= 0; --i) {
    if (!anc(kp[x][i], y)) {
      x = kp[x][i];
    }
  }
  return pa[x];
}
int get_kth(int x, int k) {
  for (int i = 19; i >= 0; --i) {
    if (k >= (1 << i)) {
      k -= (1 << i);
      x = kp[x][i];
    }
  }
  return x;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x;
    --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  T = 0;
  d[0] = 0;
  pa[0] = 0;
  dfs(0);
  for (int i = 0; i < n; ++i) {
    kp[i][0] = pa[i];
  }
  for (int j = 1; j < 20; ++j) {
    for (int i = 0; i < n; ++i) {
      kp[i][j] = kp[kp[i][j - 1]][j - 1];
    }
  }
  int qq;
  scanf("%d", &qq);
  while (qq--) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x;
    --y;
    if (x == y) {
      printf("%d\n", n);
    } else {
      int z = lca(x, y);
      int dist = d[x] + d[y] - 2 * d[z];
      int ans = 0;
      if (dist % 2 == 0) {
        int middle = dist / 2;
        if (d[x] > d[y]) {
          ans += sz[get_kth(x, middle)];
          ans -= sz[get_kth(x, middle - 1)];
        } else if (d[y] > d[x]) {
          ans += sz[get_kth(y, middle)];
          ans -= sz[get_kth(y, middle - 1)];
        } else {
          ans += n;
          ans -= sz[get_kth(x, middle - 1)];
          ans -= sz[get_kth(y, middle - 1)];
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}

```


### Prompt

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

The Bitlandians are quite weird people. They have their own problems and their own solutions. They have their own thoughts and their own beliefs, they have their own values and their own merits. They have their own dishes and their own sausages!

In Bitland a sausage is an array of integers! A sausage's deliciousness is equal to the bitwise excluding OR (the xor operation) of all integers in that sausage.

One day, when Mr. Bitkoch (the local cook) was going to close his BitRestaurant, BitHaval and BitAryo, the most famous citizens of Bitland, entered the restaurant and each ordered a sausage.

But Mr. Bitkoch had only one sausage left. So he decided to cut a prefix (several, may be zero, first array elements) of the sausage and give it to BitHaval and a postfix (several, may be zero, last array elements) of the sausage and give it to BitAryo. Note that one or both pieces of the sausage can be empty. Of course, the cut pieces mustn't intersect (no array element can occur in both pieces).

The pleasure of BitHaval and BitAryo is equal to the bitwise XOR of their sausages' deliciousness. An empty sausage's deliciousness equals zero.

Find a way to cut a piece of sausage for BitHaval and BitAryo that maximizes the pleasure of these worthy citizens.

Input

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

The next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 1012) — Mr. Bitkoch's sausage.

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

Output

Print a single integer — the maximum pleasure BitHaval and BitAryo can get from the dinner.

Examples

Input

2
1 2

Output

3

Input

3
1 2 3

Output

3

Input

2
1000 1000

Output

1000

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Trie {
  Trie *nx[2];
  int cnt;
  Trie() {
    nx[0] = nx[1] = nullptr;
    cnt = 0;
  }
};
Trie *root;
void ins(long long x) {
  Trie *now = root;
  for (int bit = 45; bit >= 0; --bit) {
    int p = (x >> bit) & 1LL;
    if (now->nx[p] == nullptr) now->nx[p] = new Trie();
    now = now->nx[p];
    now->cnt++;
  }
}
long long query(long long x) {
  Trie *now = root;
  long long ret = 0LL;
  for (int bit = 45; bit >= 0; --bit) {
    int p = (x >> bit) & 1LL;
    p ^= 1;
    if (now->nx[p] != nullptr && now->nx[p]->cnt > 0) {
      ret += 1LL << bit;
      now = now->nx[p];
    } else {
      now = now->nx[p ^ 1];
    }
    if (now == nullptr || now->cnt == 0) break;
  }
  return ret;
}
const int MXSZ = 1e5;
int n;
long long a[MXSZ + 5];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  root = new Trie();
  cin >> n;
  long long curr = 0LL;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    curr ^= a[i];
    ins(curr);
  }
  long long mx = 0LL;
  mx = max(mx, query(0));
  curr = 0LL;
  for (int i = n; i >= 1; --i) {
    curr ^= a[i];
    mx = max(mx, query(curr));
  }
  cout << mx << '\n';
  return 0;
}

```