### Prompt

Please create a solution in Cpp to the following problem:

You have a cross-section paper with W x H squares, and each of them is painted either in white or black. You want to re-arrange the squares into a neat checkered pattern, in which black and white squares are arranged alternately both in horizontal and vertical directions (the figure shown below is a checkered patter with W = 5 and H = 5). To achieve this goal, you can perform the following two operations as many times you like in an arbitrary sequence: swapping of two arbitrarily chosen columns, and swapping of two arbitrarily chosen rows.

<image>

Create a program to determine, starting from the given cross-section paper, if you can re-arrange them into a checkered pattern.

Input

The input is given in the following format.

W H
c1,1 c1,2 ... c1,W
c2,1 c2,2 ... c2,W
:
cH,1 cH,2 ... cH,W

The first line provides the number of squares in horizontal direction W (2≤W≤1000) and those in vertical direction H(2≤H≤1000). Each of subsequent H lines provides an array of W integers ci,j corresponding to a square of i-th row and j-th column. The color of the square is white if ci,j is 0, and black if it is 1.

Output

Output "yes" if the goal is achievable and "no" otherwise.

Examples

Input

3 2
1 1 0
0 0 1

Output

yes

Input

2 2
0 0
1 1

Output

no

### Response

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

using ll = long long;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using val = valarray<T>;

using pi = pair<int,int>;

#define rep(a,b) for(int a=0; a<b; ++a)
#define Rep(a,b,c) for(int a=b; a<c; ++a)
#define ran(a,b) for(auto &a:b)
#define all(v) v.begin(),v.end()

int main(){
	int W, H; cin >> W >> H;
	vector<vector<int>> c(H, vector<int>(W)), d(W, vector<int>(H));
	for(int i=0; i<H; ++i) for(int j=0; j<W; ++j) cin >> c[i][j], d[j][i] = c[i][j];

	map<vector<int>,int> S;
	for(int i=0; i<H; ++i) {
		S[c[i]]++;
		if(S.size() > 2) {
			cout << "no" << endl;
			return 0;
		}
	}
	if(S.size() != 2) {
		cout << "no" << endl;
		return 0;
	}
	auto itr = S.begin();
	if(itr->second == H / 2 || (++itr)->second == H / 2) {
	} else {
		cout << "no" << endl;
		return 0;
	}

	S.clear();
	for(int i=0; i<W; ++i) {
		S[d[i]]++;
		if(S.size() > 2) {
			cout << "no" << endl;
			return 0;
		}
	}
	if(S.size() != 2) {
		cout << "no" << endl;
		return 0;
	}
	itr = S.begin();
	if(itr->second == W / 2 || (++itr)->second == W / 2) {
	} else {
		cout << "no" << endl;
		return 0;
	}

	cout << "yes" << endl;
}

```


### Prompt

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

An extension of a complex number is called a quaternion. It is a convenient number that can be used to control the arm of a robot because it is convenient for expressing the rotation of an object. Quaternions are $ using four real numbers $ x $, $ y $, $ z $, $ w $ and special numbers (extended imaginary numbers) $ i $, $ j $, $ k $. It is expressed as x + yi + zj + wk $. The sum of such quaternions is defined as:

$ (x_1 + y_1 i + z_1 j + w_1 k) + (x_2 + y_2 i + z_2 j + w_2 k) = (x_1 + x_2) + (y_1 + y_2) i + (z_1 + z_2) j + (w_1 + w_2) k $

On the other hand, the product between 1, $ i $, $ j $, and $ k $ is given as follows.

<image>

This table represents the product $ AB $ of two special numbers $ A $ and $ B $. For example, the product $ ij $ of $ i $ and $ j $ is $ k $, and the product $ ji $ of $ j $ and $ i $ is $ -k $.

The product of common quaternions is calculated to satisfy this relationship. For example, the product of two quaternions, $ 1 + 2i + 3j + 4k $ and $ 7 + 6i + 7j + 8k $, is calculated as follows:

$ (1 + 2i + 3j + 4k) \ times (7 + 6i + 7j + 8k) = $
$ 7 + 6i + 7j + 8k $
$ + 14i + 12i ^ 2 + 14ij + 16ik $
$ + 21j + 18ji + 21j ^ 2 + 24jk $
$ + 28k + 24ki + 28kj + 32k ^ 2 $

By applying the table above

$ = -58 + 16i + 36j + 32k $

It will be.

Two quaternions ($ x_1 + y_1 i + z_1 j + w_1 k $) and ($) where the four coefficients $ x $, $ y $, $ z $, $ w $ are integers and not all zeros x_2 + y_2 i + z_2 j + w_2 k $), and the product is ($ x_3 + y_3 i + z_3 j + w_3 k $), $ x_3 $, $ y_3 $, $ z_3 $, $ Create a program that outputs w_3 $.

input

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

$ n $
$ data_1 $
$ data_2 $
::
$ data_n $

The first line gives the number of pairs of quaternions to process $ n $ ($ n \ leq 10 $). The following $ n $ line is given the $ i $ th quaternion pair of information $ data_i $ in the following format:

$ x_1 $ $ y_1 $ $ z_1 $ $ w_1 $ $ x_2 $ $ y_2 $ $ z_2 $ $ w_2 $

All coefficients given should be -1000 or more and 1000 or less. The number of datasets does not exceed 50.

output

Prints the product of a given set of quaternions for each dataset.

Example

Input

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

Output

-58 16 36 32
-50 32 28 48

### Response

```cpp
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,a,b,c,d,e,f,g,h;
	while(cin>>n,n){
		rep(i,n){
			cin>>a>>b>>c>>d>>e>>f>>g>>h;
			cout<<(a*e-b*f-c*g-d*h)<<" "<<(a*f+b*e+c*h-d*g)<<" "<<(a*g-b*h+c*e+d*f)<<" "<<(a*h+b*g-c*f+d*e)<<endl;
		}
	}
	return 0;
}
```


### Prompt

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

Polycarpus is sure that his life fits the description: "first there is a white stripe, then a black one, then a white one again". So, Polycarpus is sure that this rule is going to fulfill during the next n days. Polycarpus knows that he is in for w good events and b not-so-good events. At least one event is going to take place during each day. As each day is unequivocally characterizes as a part of a white or a black stripe, then each day is going to have events of the same type only (ether good or not-so-good).

What is the number of distinct ways this scenario can develop over the next n days if Polycarpus is in for a white stripe (a stripe that has good events only, the stripe's length is at least 1 day), the a black stripe (a stripe that has not-so-good events only, the stripe's length is at least 1 day) and a white stripe again (a stripe that has good events only, the stripe's length is at least 1 day). Each of n days will belong to one of the three stripes only.

Note that even the events of the same type are distinct from each other. Even if some events occur on the same day, they go in some order (there are no simultaneous events).

Write a code that prints the number of possible configurations to sort the events into days. See the samples for clarifications on which scenarios should be considered distinct. Print the answer modulo 1000000009 (109 + 9).

Input

The single line of the input contains integers n, w and b (3 ≤ n ≤ 4000, 2 ≤ w ≤ 4000, 1 ≤ b ≤ 4000) — the number of days, the number of good events and the number of not-so-good events. It is guaranteed that w + b ≥ n.

Output

Print the required number of ways modulo 1000000009 (109 + 9).

Examples

Input

3 2 1

Output

2

Input

4 2 2

Output

4

Input

3 2 2

Output

4

Note

We'll represent the good events by numbers starting from 1 and the not-so-good events — by letters starting from 'a'. Vertical lines separate days.

In the first sample the possible ways are: "1|a|2" and "2|a|1". In the second sample the possible ways are: "1|a|b|2", "2|a|b|1", "1|b|a|2" and "2|b|a|1". In the third sample the possible ways are: "1|ab|2", "2|ab|1", "1|ba|2" and "2|ba|1".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long modulo(long long base, long long exponent, long long modulus);
long long choose(long long n, long long k);
long long inverse(long long a, long long m);
void build();
void fileio();
long long ncr(long long n, long long r);
const int nax = 1e6 + 10;
const int LG = log2(nax) + 1;
vector<long long> fact(nax);
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  build();
  long long n, w, b;
  cin >> n >> w >> b;
  long long ans = 0;
  for (long long i = 1; i < w; i++) {
    long long temp = (ncr(w, i) * fact[i]) % 1000000009;
    temp = (temp * fact[w - i]) % 1000000009;
    temp = (temp * fact[b]) % 1000000009;
    temp = (temp * ncr(i - 1 + w - i - 1 + b - 1, n - 3)) % 1000000009;
    ans = (ans + temp) % 1000000009;
  }
  cout << ans << '\n';
  return 0;
}
long long ncr(long long n, long long r) {
  if (r > n || r < 0 || n < 0) return 0;
  long long ans = fact[n];
  long long temp = (fact[n - r] * fact[r]) % 1000000009;
  ans = (ans * inverse(temp, 1000000009)) % 1000000009;
  return ans;
}
void fileio() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void build() {
  fact[0] = 1;
  for (long long i = 1; i < nax; i++) fact[i] = (fact[i - 1] * i) % 1000000009;
}
long long modulo(long long base, long long exponent, long long modulus) {
  if (modulus == 1) return 0;
  long long result = 1;
  base = base % modulus;
  while (exponent > 0) {
    if (exponent % 2 == 1) {
      result = (result * base) % modulus;
    }
    exponent = exponent >> 1;
    base = (base * base) % modulus;
  }
  return result;
}
long long choose(long long n, long long k) {
  if (k == 0) return 1;
  return (n * choose(n - 1, k - 1)) / k;
}
void EE(long long a, long long b, long long &co1, long long &co2) {
  if (a % b == 0) {
    co1 = 0;
    co2 = 1;
    return;
  }
  EE(b, a % b, co1, co2);
  long long temp = co1;
  co1 = co2;
  co2 = temp - co2 * (a / b);
}
long long inverse(long long a, long long m) {
  long long x, y;
  EE(a, m, x, y);
  if (x < 0) x += m;
  return x;
}

```


### Prompt

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

This is an easier version of the problem. In this version n ≤ 1000

The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. All skyscrapers are built along the highway. It is known that the company has already bought n plots along the highway and is preparing to build n skyscrapers, one skyscraper per plot.

Architects must consider several requirements when planning a skyscraper. Firstly, since the land on each plot has different properties, each skyscraper has a limit on the largest number of floors it can have. Secondly, according to the design code of the city, it is unacceptable for a skyscraper to simultaneously have higher skyscrapers both to the left and to the right of it.

Formally, let's number the plots from 1 to n. Then if the skyscraper on the i-th plot has a_i floors, it must hold that a_i is at most m_i (1 ≤ a_i ≤ m_i). Also there mustn't be integers j and k such that j < i < k and a_j > a_i < a_k. Plots j and k are not required to be adjacent to i.

The company wants the total number of floors in the built skyscrapers to be as large as possible. Help it to choose the number of floors for each skyscraper in an optimal way, i.e. in such a way that all requirements are fulfilled, and among all such construction plans choose any plan with the maximum possible total number of floors.

Input

The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of plots.

The second line contains the integers m_1, m_2, …, m_n (1 ≤ m_i ≤ 10^9) — the limit on the number of floors for every possible number of floors for a skyscraper on each plot.

Output

Print n integers a_i — the number of floors in the plan for each skyscraper, such that all requirements are met, and the total number of floors in all skyscrapers is the maximum possible.

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

Examples

Input

5
1 2 3 2 1

Output

1 2 3 2 1

Input

3
10 6 8

Output

10 6 6

Note

In the first example, you can build all skyscrapers with the highest possible height.

In the second test example, you cannot give the maximum height to all skyscrapers as this violates the design code restriction. The answer [10, 6, 6] is optimal. Note that the answer of [6, 6, 8] also satisfies all restrictions, but is not optimal.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 144, mod = 1e9 + 7, inf = 1e9 + 7, LOG = 18;
long long a[N], b[N];
long long bp(long long x, long long y) {
  x %= mod;
  if (y == 0) return 1;
  if (y & 1) return (x * bp(x, y - 1)) % mod;
  long long z = bp(x, y / 2);
  return (z * z) % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long mx = 0, mi;
  for (int i = 1; i <= n; i++) {
    long long res = a[i];
    b[i] = a[i];
    for (int j = i - 1; j >= 1; j--) {
      b[j] = min(b[j + 1], a[j]);
      res += b[j];
    }
    for (int j = i + 1; j <= n; j++) {
      b[j] = min(b[j - 1], a[j]);
      res += b[j];
    }
    if (res > mx) {
      mx = res;
      mi = i;
    }
  }
  b[mi] = a[mi];
  for (int j = mi - 1; j >= 1; j--) b[j] = min(b[j + 1], a[j]);
  for (int j = mi + 1; j <= n; j++) b[j] = min(b[j - 1], a[j]);
  for (int i = 1; i <= n; i++) cout << b[i] << " ";
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Vasya is interested in arranging dominoes. He is fed up with common dominoes and he uses the dominoes of different heights. He put n dominoes on the table along one axis, going from left to right. Every domino stands perpendicular to that axis so that the axis passes through the center of its base. The i-th domino has the coordinate xi and the height hi. Now Vasya wants to learn for every domino, how many dominoes will fall if he pushes it to the right. Help him do that.

Consider that a domino falls if it is touched strictly above the base. In other words, the fall of the domino with the initial coordinate x and height h leads to the fall of all dominoes on the segment [x + 1, x + h - 1].

<image>

Input

The first line contains integer n (1 ≤ n ≤ 105) which is the number of dominoes. Then follow n lines containing two integers xi and hi ( - 108 ≤ xi ≤ 108, 2 ≤ hi ≤ 108) each, which are the coordinate and height of every domino. No two dominoes stand on one point.

Output

Print n space-separated numbers zi — the number of dominoes that will fall if Vasya pushes the i-th domino to the right (including the domino itself).

Examples

Input

4
16 5
20 5
10 10
18 2

Output

3 1 4 1

Input

4
0 10
1 5
9 10
15 10

Output

4 1 2 1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Domino {
  int coordinate, height, input_index;
};
template <size_t Size>
class Segment_Tree {
 protected:
  array<int, 4 * Size> segment_tree;
  int ceil_log(const int &number) {
    int result = 0;
    for (int power_of_two = 1; power_of_two < number;
         power_of_two <<= 1, ++result)
      ;
    return result;
  }
  int leaf_to_index(const int &leaf) { return (1 << (height - 1)) - 1 + leaf; }
  int parent(const int &index) { return index / 2; }
  int left_child(const int &index) { return index * 2; }
  int right_child(const int &index) { return index * 2 + 1; }

 public:
  int height = ceil_log(Size) + 1;
  Segment_Tree() {
    for (int depth = 1; depth <= height; ++depth)
      for (int index = 1 << (depth - 1); index < 1 << depth; ++index)
        segment_tree[index] = 0;
  }
  void set(const int &leaf, const int &value) {
    segment_tree[leaf_to_index(leaf)] = value;
    for (int index = parent(leaf_to_index(leaf)); index >= 1;
         index = parent(index))
      segment_tree[index] = max(segment_tree[left_child(index)],
                                segment_tree[right_child(index)]);
  }
  int get(const int &start_leaf, const int &end_leaf) {
    int result = -1;
    int start_index, end_index;
    for (start_index = leaf_to_index(start_leaf),
        end_index = leaf_to_index(end_leaf);
         start_index < end_index;
         start_index = parent(start_index), end_index = parent(end_index)) {
      if (left_child(parent(start_index)) != start_index) {
        result = max(result, segment_tree[start_index]);
        ++start_index;
      }
      if (right_child(parent(end_index)) != end_index) {
        result = max(result, segment_tree[end_index]);
        --end_index;
      }
    }
    if (start_index == end_index)
      result = max(result, segment_tree[start_index]);
    return result;
  }
};
const int MAX_N = 1e5;
int n;
array<Domino, MAX_N + 1> dominos;
Segment_Tree<MAX_N> segment_tree;
bool has_next(const int &index) { return index < n; }
bool makes_next_to_fall(const int &index) {
  return dominos[index].coordinate + dominos[index].height - 1 >=
         dominos[index + 1].coordinate;
}
int farest_fallen_domino(const int &range_start, const int &range_end) {
  return segment_tree.get(range_start, range_end);
}
struct proxy {
  const int index;
  proxy(const int &index) : index(index) {}
  void operator=(const int &value) { segment_tree.set(index, value); }
  operator int() { return segment_tree.get(index, index); }
};
proxy farest_fallen_domino(const int &index) { return proxy(index); }
void optimize_IO() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
}
int main() {
  array<int, MAX_N + 1> z;
  optimize_IO();
  cin >> n;
  for (int input_index = 1; input_index <= n; ++input_index) {
    int x, h;
    cin >> x >> h;
    dominos[input_index] = {x, h, input_index};
  }
  sort(dominos.begin() + 1, dominos.begin() + n + 1,
       [](const Domino &comparand, const Domino &comparator) {
         return comparand.coordinate < comparator.coordinate;
       });
  for (int index = n; index >= 1; --index) {
    if (has_next(index) and makes_next_to_fall(index))
      farest_fallen_domino(index) = farest_fallen_domino(
          index + 1,
          distance(dominos.begin() + 1,
                   upper_bound(
                       dominos.begin() + 1, dominos.begin() + n + 1,
                       dominos[index].coordinate + dominos[index].height - 1,
                       [](const int &fallen_coordinate, const Domino &domino) {
                         return fallen_coordinate < domino.coordinate;
                       })));
    else
      farest_fallen_domino(index) = index;
  }
  for (int index = 1; index <= n; ++index)
    z[dominos[index].input_index] = farest_fallen_domino(index) - index + 1;
  for (int input_index = 1; input_index <= n; ++input_index)
    cout << z[input_index] << ' ';
  cout << '\n';
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. Besides, he can take several exams on one day, and in any order.

According to the schedule, a student can take the exam for the i-th subject on the day number ai. However, Valera has made an arrangement with each teacher and the teacher of the i-th subject allowed him to take an exam before the schedule time on day bi (bi < ai). Thus, Valera can take an exam for the i-th subject either on day ai, or on day bi. All the teachers put the record of the exam in the student's record book on the day of the actual exam and write down the date of the mark as number ai.

Valera believes that it would be rather strange if the entries in the record book did not go in the order of non-decreasing date. Therefore Valera asks you to help him. Find the minimum possible value of the day when Valera can take the final exam if he takes exams so that all the records in his record book go in the order of non-decreasing date.

Input

The first line contains a single positive integer n (1 ≤ n ≤ 5000) — the number of exams Valera will take.

Each of the next n lines contains two positive space-separated integers ai and bi (1 ≤ bi < ai ≤ 109) — the date of the exam in the schedule and the early date of passing the i-th exam, correspondingly.

Output

Print a single integer — the minimum possible number of the day when Valera can take the last exam if he takes all the exams so that all the records in his record book go in the order of non-decreasing date.

Examples

Input

3
5 2
3 1
4 2

Output

2

Input

3
6 1
5 2
4 3

Output

6

Note

In the first sample Valera first takes an exam in the second subject on the first day (the teacher writes down the schedule date that is 3). On the next day he takes an exam in the third subject (the teacher writes down the schedule date, 4), then he takes an exam in the first subject (the teacher writes down the mark with date 5). Thus, Valera takes the last exam on the second day and the dates will go in the non-decreasing order: 3, 4, 5.

In the second sample Valera first takes an exam in the third subject on the fourth day. Then he takes an exam in the second subject on the fifth day. After that on the sixth day Valera takes an exam in the first subject.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
pair<int, int> c[5010];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> c[i].first >> c[i].second;
  sort(c + 1, c + n + 1);
  long long kq = 0;
  for (int i = 1; i <= n; i++) {
    if (c[i].second >= kq)
      kq = c[i].second;
    else
      kq = c[i].first;
  }
  cout << kq;
}

```


### Prompt

Generate a Cpp solution to the following problem:

It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be wi, then 0 < w1 ≤ w2 ≤ ... ≤ wk holds.

Polar bears Alice and Bob each have caught some fish, and they are guessing who has the larger sum of weight of the fish he/she's caught. Given the type of the fish they've caught, determine whether it is possible that the fish caught by Alice has a strictly larger total weight than Bob's. In other words, does there exist a sequence of weights wi (not necessary integers), such that the fish caught by Alice has a strictly larger total weight?

Input

The first line contains three integers n, m, k (1 ≤ n, m ≤ 105, 1 ≤ k ≤ 109) — the number of fish caught by Alice and Bob respectively, and the number of fish species.

The second line contains n integers each from 1 to k, the list of fish type caught by Alice. The third line contains m integers each from 1 to k, the list of fish type caught by Bob.

Note that one may have caught more than one fish for a same species.

Output

Output "YES" (without quotes) if it is possible, and "NO" (without quotes) otherwise.

Examples

Input

3 3 3
2 2 2
1 1 3

Output

YES

Input

4 7 9
5 2 7 3
3 5 2 7 3 8 7

Output

NO

Note

In the first sample, if w1 = 1, w2 = 2, w3 = 2.5, then Alice has a total of 2 + 2 + 2 = 6 weight units, while Bob only has 1 + 1 + 2.5 = 4.5.

In the second sample, the fish that Alice caught is a subset of Bob's. Therefore, the total weight of Bob’s fish is always not less than the total weight of Alice’s fish.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
map<int, int> ma;
map<int, int>::iterator it;
int main() {
  int n, m, k, x, num;
  while (~scanf("%d%d%d", &n, &m, &k)) {
    ma.clear();
    for (int i = 1; i <= n; i++) {
      scanf("%d", &x);
      ma[x]++;
    }
    for (int i = 1; i <= m; i++) {
      scanf("%d", &x);
      ma[x]--;
    }
    num = 0;
    for (it = ma.begin(); it != ma.end(); it++) {
      num += it->second;
      if (num < 0) num = 0;
    }
    if (num > 0)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}

```


### Prompt

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

There is a directed graph with N vertices and M edges. The i-th edge (1≤i≤M) points from vertex a_i to vertex b_i, and has a weight c_i. We will play the following single-player game using this graph and a piece.

Initially, the piece is placed at vertex 1, and the score of the player is set to 0. The player can move the piece as follows:

* When the piece is placed at vertex a_i, move the piece along the i-th edge to vertex b_i. After this move, the score of the player is increased by c_i.

The player can end the game only when the piece is placed at vertex N. The given graph guarantees that it is possible to traverse from vertex 1 to vertex N.

When the player acts optimally to maximize the score at the end of the game, what will the score be? If it is possible to increase the score indefinitely, print `inf`.

Constraints

* 2≤N≤1000
* 1≤M≤min(N(N-1),2000)
* 1≤a_i,b_i≤N (1≤i≤M)
* a_i≠b_i (1≤i≤M)
* a_i≠a_j or b_i≠b_j (1≤i<j≤M)
* -10^9≤c_i≤10^9 (1≤i≤M)
* c_i is an integer.
* In the given graph, there exists a path from vertex 1 to vertex N.

Input

Input is given from Standard Input in the following format:

N M
a_1 b_1 c_1
a_2 b_2 c_2
:
a_M b_M c_M

Output

Print the maximum possible score at the end of the game, if it is finite. If it is possible to increase the score indefinitely, print `inf`.

Examples

Input

3 3
1 2 4
2 3 3
1 3 5

Output

7

Input

2 2
1 2 1
2 1 1

Output

inf

Input

6 5
1 2 -1000000000
2 3 -1000000000
3 4 -1000000000
4 5 -1000000000
5 6 -1000000000

Output

-5000000000

### Response

```cpp
#include <iostream>
#include <cstdio>
#define N 1005
#define M 2005
using namespace std;

typedef long long ll;
ll n, m, a[M], b[M], c[M], d[N];
bool v = 1;
int main()
{
	ll i, j, t;
	cin >> n >> m;
	for (i = 0; i < m; i++) scanf("%lld %lld %lld", &a[i], &b[i], &c[i]);
	for (i = 2; i <= n; i++) d[i] = -1e18;
	for (i = 0; i < n - 1 && v; i++) {
		v = 0;
		for (j = 0; j < m; j++) {
			if (d[b[j]] < d[a[j]] + c[j]) v = 1, d[b[j]] = d[a[j]] + c[j];
		}
	}
	if (v) {
		t = d[n];
		for (i = 0; i < m; i++) {
			if (d[b[i]] < d[a[i]] + c[i]) d[b[i]] = d[a[i]] + c[i];
		}
		if (t != d[n]) {cout << "inf"; return 0;}
	}
    cout << d[n];
    return 0;
}
```


### Prompt

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

Innopolis University scientists continue to investigate the periodic table. There are n·m known elements and they form a periodic table: a rectangle with n rows and m columns. Each element can be described by its coordinates (r, c) (1 ≤ r ≤ n, 1 ≤ c ≤ m) in the table.

Recently scientists discovered that for every four different elements in this table that form a rectangle with sides parallel to the sides of the table, if they have samples of three of the four elements, they can produce a sample of the fourth element using nuclear fusion. So if we have elements in positions (r1, c1), (r1, c2), (r2, c1), where r1 ≠ r2 and c1 ≠ c2, then we can produce element (r2, c2).

<image>

Samples used in fusion are not wasted and can be used again in future fusions. Newly crafted elements also can be used in future fusions.

Innopolis University scientists already have samples of q elements. They want to obtain samples of all n·m elements. To achieve that, they will purchase some samples from other laboratories and then produce all remaining elements using an arbitrary number of nuclear fusions in some order. Help them to find the minimal number of elements they need to purchase.

Input

The first line contains three integers n, m, q (1 ≤ n, m ≤ 200 000; 0 ≤ q ≤ min(n·m, 200 000)), the chemical table dimensions and the number of elements scientists already have.

The following q lines contain two integers ri, ci (1 ≤ ri ≤ n, 1 ≤ ci ≤ m), each describes an element that scientists already have. All elements in the input are different.

Output

Print the minimal number of elements to be purchased.

Examples

Input

2 2 3
1 2
2 2
2 1

Output

0

Input

1 5 3
1 3
1 1
1 5

Output

2

Input

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

Output

1

Note

For each example you have a picture which illustrates it.

The first picture for each example describes the initial set of element samples available. Black crosses represent elements available in the lab initially.

The second picture describes how remaining samples can be obtained. Red dashed circles denote elements that should be purchased from other labs (the optimal solution should minimize the number of red circles). Blue dashed circles are elements that can be produced with nuclear fusion. They are numbered in order in which they can be produced.

Test 1

We can use nuclear fusion and get the element from three other samples, so we don't need to purchase anything.

<image>

Test 2

We cannot use any nuclear fusion at all as there is only one row, so we have to purchase all missing elements.

<image>

Test 3

There are several possible solutions. One of them is illustrated below.

Note that after purchasing one element marked as red it's still not possible to immidiately produce the middle element in the bottom row (marked as 4). So we produce the element in the left-top corner first (marked as 1), and then use it in future fusions.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int MAXN = 600010;
const int INF = 2147483600;
int fa[MAXN + 1];
int N, M, Q;
inline int find(int x) { return x == fa[x] ? x : (fa[x] = find(fa[x])); }
inline void merge(int u, int v) {
  int x = find(u), y = find(v);
  if (x == y) return;
  fa[y] = x;
}
int main() {
  N = read(), M = read(), Q = read();
  int cnt = 0;
  for (int i = 1; i <= N + M; i++) fa[i] = i;
  for (int i = 1; i <= Q; i++) {
    int u = read(), v = read();
    merge(u, v + N);
  }
  for (int i = 1; i <= N + M; i++)
    if (fa[i] == i) ++cnt;
  printf("%d\n", cnt - 1);
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Don't put up with what you're sick of! The Smart Beaver decided to escape from the campus of Beaver Science Academy (BSA). BSA is a b × b square on a plane. Each point x, y (0 ≤ x, y ≤ b) belongs to BSA. To make the path quick and funny, the Beaver constructed a Beaveractor, an effective and comfortable types of transport.

The campus obeys traffic rules: there are n arrows, parallel to the coordinate axes. The arrows do not intersect and do not touch each other. When the Beaveractor reaches some arrow, it turns in the arrow's direction and moves on until it either reaches the next arrow or gets outside the campus. The Beaveractor covers exactly one unit of space per one unit of time. You can assume that there are no obstacles to the Beaveractor.

The BSA scientists want to transport the brand new Beaveractor to the "Academic Tractor" research institute and send the Smart Beaver to do his postgraduate studies and sharpen pencils. They have q plans, representing the Beaveractor's initial position (xi, yi), the initial motion vector wi and the time ti that have passed after the escape started.

Your task is for each of the q plans to determine the Smart Beaver's position after the given time.

Input

The first line contains two integers: the number of traffic rules n and the size of the campus b, 0 ≤ n, 1 ≤ b. Next n lines contain the rules. Each line of the rules contains four space-separated integers x0, y0, x1, y1 — the beginning and the end of the arrow. It is guaranteed that all arrows are parallel to the coordinate axes and have no common points. All arrows are located inside the campus, that is, 0 ≤ x0, y0, x1, y1 ≤ b holds.

Next line contains integer q — the number of plans the scientists have, 1 ≤ q ≤ 105. The i-th plan is represented by two integers, xi, yi are the Beaveractor's coordinates at the initial time, 0 ≤ xi, yi ≤ b, character wi, that takes value U, D, L, R and sets the initial direction up, down, to the left or to the right correspondingly (the Y axis is directed upwards), and ti — the time passed after the escape started, 0 ≤ ti ≤ 1015.

  * to get 30 points you need to solve the problem with constraints n, b ≤ 30 (subproblem D1);
  * to get 60 points you need to solve the problem with constraints n, b ≤ 1000 (subproblems D1+D2);
  * to get 100 points you need to solve the problem with constraints n, b ≤ 105 (subproblems D1+D2+D3).

Output

Print q lines. Each line should contain two integers — the Beaveractor's coordinates at the final moment of time for each plan. If the Smart Beaver manages to leave the campus in time ti, print the coordinates of the last point in the campus he visited.

Examples

Input

3 3
0 0 0 1
0 2 2 2
3 3 2 3
12
0 0 L 0
0 0 L 1
0 0 L 2
0 0 L 3
0 0 L 4
0 0 L 5
0 0 L 6
2 0 U 2
2 0 U 3
3 0 U 5
1 3 D 2
1 3 R 2

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int dx[5] = {0, 1, 0, -1, 0};
int dy[5] = {0, 0, 1, 0, -1};
int n, b, q;
int a[N + 5][N + 5];
int nx[N * N * 5 + 55][2];
int ans[111111];
long long t[111111];
int hash1(int x, int y, int d) {
  if (a[x][y]) d = a[x][y];
  return d * N * N + x * N + y;
}
int main() {
  int i, j, k, x1, y1, x2, y2, d, h;
  char ch[5];
  scanf("%d%d", &n, &b);
  for (i = 1; i <= n; i = i + 1) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 == x2) {
      if (y1 > y2)
        d = 4;
      else
        d = 2;
    } else {
      if (x1 > x2)
        d = 3;
      else
        d = 1;
    }
    while (x1 != x2 || y1 != y2) {
      a[x1][y1] = d;
      x1 += dx[d];
      y1 += dy[d];
    }
    a[x2][y2] = d;
  }
  for (i = 0; i <= b; i = i + 1)
    for (j = 0; j <= b; j = j + 1)
      for (k = 1; k <= 4; k = k + 1) {
        if (a[i][j] && a[i][j] != k) continue;
        h = hash1(i, j, k);
        x1 = i + dx[k];
        y1 = j + dy[k];
        if (x1 < 0 || x1 > b || y1 < 0 || y1 > b)
          nx[h][0] = h;
        else
          nx[h][0] = hash1(x1, y1, k);
      }
  scanf("%d", &q);
  for (i = 1; i <= q; i = i + 1) {
    scanf("%d%d%s%lld", &x1, &x2, &ch, t + i);
    if (ch[0] == 'R') d = 1;
    if (ch[0] == 'U') d = 2;
    if (ch[0] == 'L') d = 3;
    if (ch[0] == 'D') d = 4;
    ans[i] = hash1(x1, x2, d);
  }
  for (i = 0; i <= 60; i = i + 1) {
    h = i & 1;
    for (j = 1; j <= q; j = j + 1)
      if (t[j] & ((long long)1 << i)) ans[j] = nx[ans[j]][h];
    for (j = 1; j < N * N * 5; j = j + 1) nx[j][h ^ 1] = nx[nx[j][h]][h];
  }
  for (i = 1; i <= q; i = i + 1) {
    y1 = ans[i] % N;
    ans[i] /= N;
    x1 = ans[i] % N;
    cout << x1 << ' ' << y1 << endl;
  }
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

You are given N points (x_i,y_i) located on a two-dimensional plane. Consider a subset S of the N points that forms a convex polygon. Here, we say a set of points S forms a convex polygon when there exists a convex polygon with a positive area that has the same set of vertices as S. All the interior angles of the polygon must be strictly less than 180°.

cddb0c267926c2add885ca153c47ad8a.png

For example, in the figure above, {A,C,E} and {B,D,E} form convex polygons; {A,C,D,E}, {A,B,C,E}, {A,B,C}, {D,E} and {} do not.

For a given set S, let n be the number of the points among the N points that are inside the convex hull of S (including the boundary and vertices). Then, we will define the score of S as 2^{n-|S|}.

Compute the scores of all possible sets S that form convex polygons, and find the sum of all those scores.

However, since the sum can be extremely large, print the sum modulo 998244353.

Constraints

* 1≤N≤200
* 0≤x_i,y_i<10^4 (1≤i≤N)
* If i≠j, x_i≠x_j or y_i≠y_j.
* x_i and y_i are integers.

Input

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

N
x_1 y_1
x_2 y_2
:
x_N y_N

Output

Print the sum of all the scores modulo 998244353.

Examples

Input

4
0 0
0 1
1 0
1 1

Output

5

Input

5
0 0
0 1
0 2
0 3
1 1

Output

11

Input

1
3141 2718

Output

0

### Response

```cpp
#include<bits/stdc++.h>
#define Mo 998244353
#define N 500
typedef long long LL;
using namespace std;
int x[N], y[N], b[N], num[N], n;

void prepare() {
    b[0] = 1;
    for(int i = 1; i <= n; i++) b[i] = ((LL)b[i - 1] * 2) % Mo;
    for(int i = 1; i <= n; i++) b[i] = (b[i] - 1 - i - i * (i - 1) / 2) % Mo;
}

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
    prepare();
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++) {
            if (i == j) continue;
            int cnt = 2;
            for(int k = 1; k <= n; k++) {
                if (k == i || k == j) continue;
                if ((LL)(x[k] - x[i]) * (y[k] - y[j]) == (LL)(x[k] - x[j]) * (y[k] - y[i])) cnt++;
            }
            num[cnt]++;
        }
    for(int i = 3; i <= n; i++) num[i] = num[i] / i / (i - 1);
    LL ans = b[n];
    for(int i = 3; i <= n; i++) ans = (ans - (LL)num[i] * b[i] % Mo) % Mo;
    cout << (ans % Mo + Mo) % Mo << endl;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression:

(1n + 2n + 3n + 4n) mod 5

for given value of n. Fedya managed to complete the task. Can you? Note that given number n can be extremely large (e.g. it can exceed any integer type of your programming language).

Input

The single line contains a single integer n (0 ≤ n ≤ 10105). The number doesn't contain any leading zeroes.

Output

Print the value of the expression without leading zeros.

Examples

Input

4

Output

4

Input

124356983594583453458888889

Output

0

Note

Operation x mod y means taking remainder after division x by y.

Note to the first sample:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = (int)s.length();
  int m4 = 0;
  for (int i = 0; i < n; i++) {
    m4 = m4 * 10 + (s[i] - '0');
    m4 %= 4;
  }
  if (m4 == 0) {
    cout << 4 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

```


### Prompt

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

When Valera was playing football on a stadium, it suddenly began to rain. Valera hid in the corridor under the grandstand not to get wet. However, the desire to play was so great that he decided to train his hitting the ball right in this corridor. Valera went back far enough, put the ball and hit it. The ball bounced off the walls, the ceiling and the floor corridor and finally hit the exit door. As the ball was wet, it left a spot on the door. Now Valera wants to know the coordinates for this spot.

Let's describe the event more formally. The ball will be considered a point in space. The door of the corridor will be considered a rectangle located on plane xOz, such that the lower left corner of the door is located at point (0, 0, 0), and the upper right corner is located at point (a, 0, b) . The corridor will be considered as a rectangular parallelepiped, infinite in the direction of increasing coordinates of y. In this corridor the floor will be considered as plane xOy, and the ceiling as plane, parallel to xOy and passing through point (a, 0, b). We will also assume that one of the walls is plane yOz, and the other wall is plane, parallel to yOz and passing through point (a, 0, b).

We'll say that the ball hit the door when its coordinate y was equal to 0. Thus the coordinates of the spot are point (x0, 0, z0), where 0 ≤ x0 ≤ a, 0 ≤ z0 ≤ b. To hit the ball, Valera steps away from the door at distance m and puts the ball in the center of the corridor at point <image>. After the hit the ball flies at speed (vx, vy, vz). This means that if the ball has coordinates (x, y, z), then after one second it will have coordinates (x + vx, y + vy, z + vz).

See image in notes for clarification.

When the ball collides with the ceiling, the floor or a wall of the corridor, it bounces off in accordance with the laws of reflection (the angle of incidence equals the angle of reflection). In the problem we consider the ideal physical model, so we can assume that there is no air resistance, friction force, or any loss of energy.

Input

The first line contains three space-separated integers a, b, m (1 ≤ a, b, m ≤ 100). The first two integers specify point (a, 0, b), through which the ceiling and one of the corridor walls pass. The third integer is the distance at which Valera went away from the door.

The second line has three space-separated integers vx, vy, vz (|vx|, |vy|, |vz| ≤ 100, vy < 0, vz ≥ 0) — the speed of the ball after the hit.

It is guaranteed that the ball hits the door.

Output

Print two real numbers x0, z0 — the x and z coordinates of point (x0, 0, z0), at which the ball hits the exit door. The answer will be considered correct, if its absolute or relative error does not exceed 10  - 6.

Examples

Input

7 2 11
3 -11 2

Output

6.5000000000 2.0000000000

Input

7 2 11
4 -3 3

Output

4.1666666667 1.0000000000

Note

<image>

### Response

```cpp
#include <bits/stdc++.h>
const int maxi = 2000000000;
const int maxq = 1000000000;
const double eps = 1e-10;
const double pi = 3.1415926535897932;
const double inf = 1e+18;
const int mo = 1000000007;
using namespace std;
double a, b, m, vx, vy, vz;
int main() {
  cin >> a >> b >> m;
  cin >> vx >> vy >> vz;
  double xs = a / 2.;
  double ys = m;
  double zs = 0;
  double tx = ys / fabs(vy);
  double tz = tx;
  bool flag = false;
  if (fabs(vx * tx) > a / 2.) {
    if (vx < 0)
      xs = 0;
    else
      xs = a;
    tx = tx - ((a / 2.) / fabs(vx));
    flag = true;
  } else
    xs = xs + vx * tx, tx = 0;
  vx = fabs(vx);
  int tiz = int((vz * tz) / b);
  int tix = int((vx * tx) / a);
  if (vx > eps) tx = tx - (tix * a) / vx;
  if (vz > eps) tz = tz - (tiz * b) / vz;
  if (((tiz)&1))
    zs = b - tz * vz;
  else
    zs = tz * vz;
  if (flag) {
    if (fabs(xs) < eps) {
      if (((tix)&1))
        xs = a - tx * vx;
      else
        xs = tx * vx;
    } else {
      if (((tix)&1) == 0)
        xs = a - tx * vx;
      else
        xs = tx * vx;
    }
  }
  printf("%.9lf %.9lf\n", xs, zs);
  return 0;
}

```


### Prompt

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

There are n stone quarries in Petrograd.

Each quarry owns mi dumpers (1 ≤ i ≤ n). It is known that the first dumper of the i-th quarry has xi stones in it, the second dumper has xi + 1 stones in it, the third has xi + 2, and the mi-th dumper (the last for the i-th quarry) has xi + mi - 1 stones in it.

Two oligarchs play a well-known game Nim. Players take turns removing stones from dumpers. On each turn, a player can select any dumper and remove any non-zero amount of stones from it. The player who cannot take a stone loses.

Your task is to find out which oligarch will win, provided that both of them play optimally. The oligarchs asked you not to reveal their names. So, let's call the one who takes the first stone «tolik» and the other one «bolik».

Input

The first line of the input contains one integer number n (1 ≤ n ≤ 105) — the amount of quarries. Then there follow n lines, each of them contains two space-separated integers xi and mi (1 ≤ xi, mi ≤ 1016) — the amount of stones in the first dumper of the i-th quarry and the number of dumpers at the i-th quarry.

Output

Output «tolik» if the oligarch who takes a stone first wins, and «bolik» otherwise.

Examples

Input

2
2 1
3 2

Output

tolik

Input

4
1 1
1 1
1 1
1 1

Output

bolik

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long range(long long L) {
  switch (L & 3) {
    case 0:
      return L;
    case 1:
      return 1;
    case 2:
      return L + 1;
    case 3:
      return 0;
  }
}
int main() {
  for (int N; cin >> N;) {
    long long sum = 0;
    for (int i = 0; i < (int)(N); ++i) {
      long long m, x;
      cin >> x >> m;
      long long b = range(x - 1);
      long long a = range(x + m - 1);
      sum ^= b;
      sum ^= a;
    }
    if (sum == 0)
      cout << "bolik" << endl;
    else
      cout << "tolik" << endl;
  }
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

You're given an array a of n integers, such that a_1 + a_2 + ⋅⋅⋅ + a_n = 0.

In one operation, you can choose two different indices i and j (1 ≤ i, j ≤ n), decrement a_i by one and increment a_j by one. If i < j this operation is free, otherwise it costs one coin.

How many coins do you have to spend in order to make all elements equal to 0?

Input

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

The first line of each test case contains an integer n (1 ≤ n ≤ 10^5) — the number of elements.

The next line contains n integers a_1, …, a_n (-10^9 ≤ a_i ≤ 10^9). It is given that ∑_{i=1}^n a_i = 0.

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

Output

For each test case, print the minimum number of coins we have to spend in order to make all elements equal to 0.

Example

Input

7
4
-3 5 -3 1
2
1 -1
4
-3 2 -3 4
4
-1 1 1 -1
7
-5 7 -6 -4 17 -13 4
6
-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000
1
0

Output

3
0
4
1
8
3000000000
0

Note

Possible strategy for the first test case:

  * Do (i=2, j=3) three times (free), a = [-3, 2, 0, 1].
  * Do (i=2, j=1) two times (pay two coins), a = [-1, 0, 0, 1].
  * Do (i=4, j=1) one time (pay one coin), a = [0, 0, 0, 0].

### Response

```cpp
#include <bits/stdc++.h>
const long long M = 1e9 + 7;
const long long N = 2e5 + 5;
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long z = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > 0) {
      z += a[i];
    } else {
      long long p = min(z, -1 * a[i]);
      a[i] += p;
      z -= p;
      ans -= a[i];
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) solve();
}

```


### Prompt

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

You are recording a result of a secret experiment, which consists of a large set of N-dimensional vectors. Since the result may become very large, you are thinking of compressing it. Fortunately you already have a good compression method for vectors with small absolute values, all you have to do is to preprocess the vectors and make them small.

You can record the set of vectors in any order you like. Let's assume you process them in the order v_1, v_2,..., v_M. Each vector v_i is recorded either as is, or as a difference vector. When it is recorded as a difference, you can arbitrarily pick up an already chosen vector v_j (j<i) and a real value r. Then the actual vector value recorded is (v_i - r v_j). The values of r and j do not affect the compression ratio so much, so you don't have to care about them.

Given a set of vectors, your task is to write a program that calculates the minimum sum of the squared length of the recorded vectors.

Input

The input is like the following style.

N M
v_{1,1} v_{1,2} ... v_{1,N}
...
v_{M,1} v_{M,2} ... v_{M,N}

The first line contains two integers N and M (1 \leq N, M \leq 100), where N is the dimension of each vector, and M is the number of the vectors. Each of the following M lines contains N floating point values v_{i,j} (-1.0 \leq v_{i,j} \leq 1.0) which represents the j-th element value of the i-th vector.

Output

Output the minimum sum of the squared length of the recorded vectors. The output should not contain an absolute error greater than 10^{-6}.

Examples

Input

2 3
1.0 1.0
-1.0 0.0
0.5 0.5

Output

1.0

Input

1 1
1.0

Output

1.0

Input

4 3
1.0 1.0 0.0 0.0
-1.0 0.0 -1.0 0.0
0.5 0.5 0.5 0.5

Output

3.0

### Response

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

typedef double ldouble;
typedef vector<ldouble> Point;
ldouble INF=1e9;

struct UnionFind{
  vector<int> par,rank;
  void init(int n){
    par.clear();
    rank.clear();
    par.resize(n);
    rank.resize(n);
    for(int i=0;i<n;i++){
      par[i]=i;
      rank[i]=1;
    }
  }

  int find(int x){
    if(x==par[x])return x;
    return par[x]=find(par[x]);
  }

  bool same(int x,int y){
    return ( find(x)==find(y) );
  }

  void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(rank[x]<rank[y])swap(x,y);
    par[y]=x;
    rank[x]+=rank[y];
  }
};

struct edge{
  int from;
  int to;
  ldouble cost;
  int id;
  edge(int from,int to,ldouble cost,int id) :from(from), to(to),cost(cost),id(id) {}
  bool operator < (const edge e)const{
    return cost > e.cost;
  }
};

typedef priority_queue< edge > prque;
typedef prque* Prque;

typedef vector<edge> Node;
typedef vector<Node> Graph;

Prque Merge(vector< Prque > &Q, vector<edge> &ev,int A,int C){
  if( Q[C]->size() < Q[A]->size() ){

    while( !Q[C]->empty() ){
      edge e=Q[C]->top();
      e.cost-=ev[C].cost;
      e.cost+=ev[A].cost;
      //      cout<<e.from<<' '<<e.to<<' '<<e.cost<<' '<<ev[A].cost<<' '<<ev[C].cost<<endl;
      Q[A]->push(e);
      Q[C]->pop();
    }
    ev[C].cost=ev[A].cost;
    return Q[A];
  }else{
    while( !Q[A]->empty() ){
      edge e=Q[A]->top();
      e.cost-=ev[A].cost;
      e.cost+=ev[C].cost;
      //      cout<<e.from<<' '<<e.to<<' '<<e.cost<<endl;
      Q[C]->push(e);
      Q[A]->pop();
    }
    return Q[C];
  }
}

ldouble solve(Graph &G,vector<edge> &edges,int root){

  int n=G.size();
  ldouble res=0;

  vector<int> used(n,0);
  vector< edge > ev(n, (edge){0,0,0,-1} );
  vector< prque > pool(n);
  vector< Prque > Q(n);
  for(int i=0;i<n;i++)Q[i]=&pool[i];

  UnionFind uf;
  uf.init(n);

  for(int i=0;i<(int)edges.size();i++){
    edge e=edges[i];
    Q[ e.to ]->push( e );
  }

  used[root]=2;
  for(int Pos=0;Pos<n;Pos++){
    if(used[Pos]==2)continue;
    int pos=Pos;
    vector<int> path;

    while( used[pos] != 2 ){
      pos=uf.find(pos);

      used[pos]=1;
      path.push_back(pos);
      if( Q[pos]->empty() ){
        return INF;
      }

      edge e=Q[pos]->top();

      Q[pos]->pop();
      e.cost-=ev[pos].cost;
      if( uf.same(e.from,pos) ) continue;
      ldouble tmpcost=ev[pos].cost;
      /*
      cout<<" pos="<<pos;
      cout<<" e.from="<<e.from;
      cout<<" e.to="<<e.to;
      cout<<" e.cost="<<e.cost;
      cout<<" tmpcost="<<tmpcost<<endl;
      cout<<endl;
      */
      res+=e.cost;
      e.cost+=tmpcost;
      ev[pos]=e;
      if( used[ uf.find(e.from) ] == 2 )break;
      if( used[ uf.find(e.from) ] == 0 ){
        pos=e.from;
        continue;
      }
      int pre=uf.find(e.from);
      for(int i=0;i<100;i++){
        if(!uf.same(pre,pos)){
          int A=uf.find(pre), B=uf.find(pos);
          uf.unite(A,B);
          int C=uf.find(A);
          /*
          cout<<" !!A="<<A;
          cout<<" !!B="<<B;
          cout<<" !!C="<<C<<endl;
          */
          Prque tmp=NULL;
          if(B==C)tmp=Merge(Q,ev,A,C);
          else if(A==C)tmp=Merge(Q,ev,B,C);
          else assert(0);

          Q[C]=tmp;
        }
        pre=uf.find(ev[pre].from);
      }
    }// while_pos

    for(int i=0;i<(int)path.size();i++)used[ path[i] ]=2;
  }// Pos
  return res;
}

Point add(Point a,Point b){
  Point res(a.size());
  for(int i=0;i<(int)a.size();i++)
    res[i]=a[i]+b[i];
  return res;
}

Point sub(Point a,Point b){
  Point res(a.size());
  for(int i=0;i<(int)a.size();i++)
    res[i]=a[i]-b[i];
  return res;
}

ldouble dot(Point a,Point b){
  ldouble res=0;
  for(int i=0;i<(int)a.size();i++)
    res+=a[i]*b[i];
  return res;
}

ldouble norm(Point p){
  return  dot(p,p);
}

ldouble abs(Point p){
  return  sqrt( norm(p) );
}

double Sqrt(double x){
  if(x<0)return 0;
  return sqrt(x);
}

double project(Point a,Point b){
  ldouble t=dot(a,b);

  //  cout<<a[0]<<' '<<a[1]<<endl;
  //  cout<<b[0]<<' '<<b[1]<<endl;
  //  cout<< dot(a,b) <<endl;
  return   abs( norm(b) - (t*t/norm(a)) );
}

int main(){
  int n,m;
  vector< Point > t;

  cin>>m>>n;
  for(int i=0;i<n;i++){
    Point a(m);
    for(int j=0;j<m;j++){
      cin>>a[j];
    }

    if(norm(a) < 0.00000001){
      continue;
    }
    t.push_back(a);
  }
  n=t.size();
  Graph G;
  G.resize(n+1);
  int cc=0;
  for(int i=0;i<n;i++){
    G[n].push_back( edge(n,i,norm(t[i]) , cc++) );
    for(int j=0;j<n;j++){
      if(i==j)continue;
      ldouble cost=project(t[i],t[j]);
      G[i].push_back( edge(i,j,cost,cc++) );
    }
  }

  vector<edge> edges;
  for(int i=0;i<=n;i++)
    for(int j=0;j<(int)G[i].size();j++)
      edges.push_back(G[i][j]);

  printf("%.10f\n",(double) solve(G,edges,n) );

  return 0;
}
```


### Prompt

Create a solution in cpp for the following problem:

User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible.

Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., bn, if and only if there exists an integer k (1 ≤ k ≤ n) where a1 = b1, a2 = b2, ..., ak - 1 = bk - 1 and ak < bk all holds.

As known, permutation p is so sensitive that it could be only modified by swapping two distinct elements. But swapping two elements is harder than you think. Given an n × n binary matrix A, user ainta can swap the values of pi and pj (1 ≤ i, j ≤ n, i ≠ j) if and only if Ai, j = 1.

Given the permutation p and the matrix A, user ainta wants to know the prettiest permutation that he can obtain.

Input

The first line contains an integer n (1 ≤ n ≤ 300) — the size of the permutation p.

The second line contains n space-separated integers p1, p2, ..., pn — the permutation p that user ainta has. Each integer between 1 and n occurs exactly once in the given permutation.

Next n lines describe the matrix A. The i-th line contains n characters '0' or '1' and describes the i-th row of A. The j-th character of the i-th line Ai, j is the element on the intersection of the i-th row and the j-th column of A. It is guaranteed that, for all integers i, j where 1 ≤ i < j ≤ n, Ai, j = Aj, i holds. Also, for all integers i where 1 ≤ i ≤ n, Ai, i = 0 holds.

Output

In the first and only line, print n space-separated integers, describing the prettiest permutation that can be obtained.

Examples

Input

7
5 2 4 3 6 7 1
0001001
0000000
0000010
1000001
0000000
0010000
1001000

Output

1 2 4 3 6 7 5

Input

5
4 2 1 5 3
00100
00011
10010
01101
01010

Output

1 2 3 4 5

Note

In the first sample, the swap needed to obtain the prettiest permutation is: (p1, p7).

In the second sample, the swaps needed to obtain the prettiest permutation is (p1, p3), (p4, p5), (p3, p4).

<image>

A permutation p is a sequence of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceed n. The i-th element of the permutation p is denoted as pi. The size of the permutation p is denoted as n.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T gcd(T a, T b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
template <typename T>
inline T lcm(T a, T b) {
  return (a * b) / gcd(a, b);
}
using namespace std;
int n, vec[305], visited[305];
char ar[305][305];
vector<set<int> > ans(305);
void dfs(int node, int color) {
  visited[node] = color;
  ans[color].insert(vec[node]);
  for (int i = 1; i <= n; i++) {
    if (ar[node][i] == '1' && !visited[i]) {
      dfs(i, color);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> vec[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) cin >> ar[i][j];
  int c = 0;
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      dfs(i, ++c);
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << *ans[visited[i]].begin() << " ";
    ans[visited[i]].erase(ans[visited[i]].begin());
  }
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Hands that shed innocent blood!

There are n guilty people in a line, the i-th of them holds a claw with length Li. The bell rings and every person kills some of people in front of him. All people kill others at the same time. Namely, the i-th person kills the j-th person if and only if j < i and j ≥ i - Li.

You are given lengths of the claws. You need to find the total number of alive people after the bell rings.

Input

The first line contains one integer n (1 ≤ n ≤ 106) — the number of guilty people.

Second line contains n space-separated integers L1, L2, ..., Ln (0 ≤ Li ≤ 109), where Li is the length of the i-th person's claw.

Output

Print one integer — the total number of alive people after the bell rings.

Examples

Input

4
0 1 0 10

Output

1

Input

2
0 0

Output

2

Input

10
1 1 3 0 0 0 2 1 0 3

Output

3

Note

In first sample the last person kills everyone in front of him.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int INF = 1e9;
int f[1000005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> l(n, 0);
  for (int i = 1; i <= n; i++) {
    cin >> l[i];
  }
  for (int i = 1; i <= n; i++) {
    f[max(0, i - l[i])]++;
    f[i]--;
  }
  int cur = f[0], res = 0;
  for (int i = 1; i <= n; i++) {
    cur += f[i];
    if (cur == 0) res++;
  }
  cout << min(n, res) << endl;
}

```


### Prompt

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

You have a bag of size n. Also you have m boxes. The size of i-th box is a_i, where each a_i is an integer non-negative power of two.

You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.

For example, if n = 10 and a = [1, 1, 32] then you have to divide the box of size 32 into two parts of size 16, and then divide the box of size 16. So you can fill the bag with boxes of size 1, 1 and 8.

Calculate the minimum number of divisions required to fill the bag of size n.

Input

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

The first line of each test case contains two integers n and m (1 ≤ n ≤ 10^{18}, 1 ≤ m ≤ 10^5) — the size of bag and the number of boxes, respectively.

The second line of each test case contains m integers a_1, a_2, ... , a_m (1 ≤ a_i ≤ 10^9) — the sizes of boxes. It is guaranteed that each a_i is a power of two.

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

Output

For each test case print one integer — the minimum number of divisions required to fill the bag of size n (or -1, if it is impossible).

Example

Input

3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8

Output

2
-1
0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int T, n, m, a, buc[63], con, sum, e;
bool z;
void pot(long int p) {
  if (p > 60) {
    z = true;
    return;
  }
  if (buc[p] == 0) {
    con++;
    pot(p + 1);
    buc[p]++;
    return;
  }
  buc[p]--;
  return;
}
int main() {
  cin >> T;
  for (int t = 0; t < T; t++) {
    cin >> n >> m;
    con = 0;
    z = false;
    for (int i = 0; i < m; i++) {
      cin >> a;
      e = -1;
      while (a != 0) {
        a /= 2;
        e++;
      }
      buc[e]++;
    }
    for (int i = 0; i <= 60; i++) {
      if ((n & (1ULL << i)) != 0) {
        n -= (1ULL << i);
        pot(i);
      }
      buc[i + 1] += buc[i] / 2;
      buc[i] = 0;
    }
    if (!z)
      cout << con << "\n";
    else
      cout << "-1"
           << "\n";
  }
}

```


### Prompt

Please create a solution in cpp to the following problem:

There are N towns in the State of Atcoder, connected by M bidirectional roads.

The i-th road connects Town A_i and B_i and has a length of C_i.

Joisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order).

She will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road.

If she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?

Constraints

* 2≤N≤200
* 1≤M≤N×(N-1)/2
* 2≤R≤min(8,N) (min(8,N) is the smaller of 8 and N.)
* r_i≠r_j (i≠j)
* 1≤A_i,B_i≤N, A_i≠B_i
* (A_i,B_i)≠(A_j,B_j),(A_i,B_i)≠(B_j,A_j) (i≠j)
* 1≤C_i≤100000
* Every town can be reached from every town by road.
* All input values are integers.

Input

Input is given from Standard Input in the following format:

N M R
r_1 ... r_R
A_1 B_1 C_1
:
A_M B_M C_M

Output

Print the distance traveled by road if Joisino visits the towns in the order that minimizes it.

Examples

Input

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

Output

2

Input

3 3 2
1 3
2 3 2
1 3 6
1 2 2

Output

4

Input

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

Output

3

### Response

```cpp
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
#define all(v) v.begin(), v.end()

int main(){
  ll N,M,R,ans=1000000000;
  cin >> N >> M >> R;
  vector<ll> r(R);
  rep(i,R){
    cin >> r.at(i);
    r.at(i)--;
  }
  sort(all(r));
  vector<vector<ll>> d(N,vector<ll>(N,100000000));
  rep(i,N) d.at(i).at(i)=0;
  rep(i,M){
    ll a,b,c;
    cin >> a >> b >> c;
    d.at(a-1).at(b-1)=c;
    d.at(b-1).at(a-1)=c;
  }
  rep(k,N)rep(i,N)rep(j,N){
    d.at(i).at(j)=min(d.at(i).at(j),d.at(i).at(k)+d.at(k).at(j));
  }
  do{
    ll t=0;
    rep(i,R-1){
      t+=d.at(r.at(i)).at(r.at(i+1));
    }
    ans=min(ans,t);
  } while (next_permutation(all(r)));
  cout << ans << endl;

}
```


### Prompt

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

Cucumber boy is fan of Kyubeat, a famous music game.

Kyubeat has 16 panels for playing arranged in 4 × 4 table. When a panel lights up, he has to press that panel.

Each panel has a timing to press (the preffered time when a player should press it), and Cucumber boy is able to press at most k panels in a time with his one hand. Cucumber boy is trying to press all panels in perfect timing, that is he wants to press each panel exactly in its preffered time. If he cannot press the panels with his two hands in perfect timing, his challenge to press all the panels in perfect timing will fail.

You are given one scene of Kyubeat's panel from the music Cucumber boy is trying. Tell him is he able to press all the panels in perfect timing.

Input

The first line contains a single integer k (1 ≤ k ≤ 5) — the number of panels Cucumber boy can press with his one hand.

Next 4 lines contain 4 characters each (digits from 1 to 9, or period) — table of panels. If a digit i was written on the panel, it means the boy has to press that panel in time i. If period was written on the panel, he doesn't have to press that panel.

Output

Output "YES" (without quotes), if he is able to press all the panels in perfect timing. If not, output "NO" (without quotes).

Examples

Input

1
.135
1247
3468
5789

Output

YES

Input

5
..1.
1111
..1.
..1.

Output

YES

Input

1
....
12.1
.2..
.2..

Output

NO

Note

In the third sample boy cannot press all panels in perfect timing. He can press all the panels in timing in time 1, but he cannot press the panels in time 2 in timing with his two hands.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[10] = {0};
  int k;
  cin >> k;
  k *= 2;
  char s;
  for (int i = 0; i < 16 && cin >> s; i++)
    if (s != '.') arr[s - '0']++;
  for (int i = 0; i < 10; i++)
    if (arr[i] > k) {
      cout << "NO";
      return 0;
    }
  cout << "YES";
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Tokitsukaze and CSL are playing a little game of stones.

In the beginning, there are n piles of stones, the i-th pile of which has a_i stones. The two players take turns making moves. Tokitsukaze moves first. On each turn the player chooses a nonempty pile and removes exactly one stone from the pile. A player loses if all of the piles are empty before his turn, or if after removing the stone, two piles (possibly empty) contain the same number of stones. Supposing that both players play optimally, who will win the game?

Consider an example: n=3 and sizes of piles are a_1=2, a_2=3, a_3=0. It is impossible to choose the empty pile, so Tokitsukaze has two choices: the first and the second piles. If she chooses the first pile then the state will be [1, 3, 0] and it is a good move. But if she chooses the second pile then the state will be [2, 2, 0] and she immediately loses. So the only good move for her is to choose the first pile.

Supposing that both players always take their best moves and never make mistakes, who will win the game?

Note that even if there are two piles with the same number of stones at the beginning, Tokitsukaze may still be able to make a valid first move. It is only necessary that there are no two piles with the same number of stones after she moves.

Input

The first line contains a single integer n (1 ≤ n ≤ 10^5) — the number of piles.

The second line contains n integers a_1, a_2, …, a_n (0 ≤ a_1, a_2, …, a_n ≤ 10^9), which mean the i-th pile has a_i stones.

Output

Print "sjfnb" (without quotes) if Tokitsukaze will win, or "cslnb" (without quotes) if CSL will win. Note the output characters are case-sensitive.

Examples

Input

1
0

Output

cslnb

Input

2
1 0

Output

cslnb

Input

2
2 2

Output

sjfnb

Input

3
2 3 1

Output

sjfnb

Note

In the first example, Tokitsukaze cannot take any stone, so CSL will win.

In the second example, Tokitsukaze can only take a stone from the first pile, and then, even though they have no stone, these two piles will have the same number of stones, which implies CSL will win.

In the third example, Tokitsukaze will win. Here is one of the optimal ways:

  * Firstly, Tokitsukaze can choose the first pile and take a stone from that pile.
  * Then, CSL can only choose the first pile, because if he chooses the second pile, he will lose immediately.
  * Finally, Tokitsukaze can choose the second pile, and then CSL will have no choice but to lose.

In the fourth example, they only have one good choice at any time, so Tokitsukaze can make the game lasting as long as possible and finally win.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
char buf[(1 << 22)], *p1 = buf, *p2 = buf;
inline int read() {
  char c =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 22, stdin), p1 == p2)
           ? EOF
           : *p1++);
  int x = 0, f = 1;
  while (c<'0' | c> '9') {
    if (c == '-') f = -1;
    c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 22, stdin), p1 == p2)
             ? EOF
             : *p1++);
  }
  while (c >= '0' && c <= '9')
    x = x * 10 + c - '0',
    c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 22, stdin), p1 == p2)
             ? EOF
             : *p1++);
  return x * f;
}
const int maxn = 1e5 + 10;
int a[maxn], n;
map<int, int> mp;
map<int, bool> vis;
int main() {
  long long sum = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    mp[a[i]]++;
  }
  sort(a, a + n);
  int tot = 0;
  for (int i = 0; i < n; i++) {
    sum += (a[i] - i);
    if (!vis[a[i]] && mp[a[i]] > 1) {
      vis[a[i]] = true;
      tot++;
    }
    if (mp[a[i]] > 2) {
      sum = 0;
      break;
    }
    if (mp[a[i] + 1] > 1) {
      sum = 0;
      break;
    }
  }
  if (tot > 1 || mp[0] > 1) sum = 0;
  printf(sum % 2 == 0 ? "cslnb\n" : "sjfnb\n");
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

The Cybermen solved that first test much quicker than the Daleks. Luckily for us, the Daleks were angry (shocking!) and they destroyed some of the Cybermen.

After the fighting stopped, Heidi gave them another task to waste their time on.

There are n points on a plane. Given a radius r, find the maximum number of points that can be covered by an L^1-ball with radius r.

An L^1-ball with radius r and center (x_0, y_0) in a 2D-plane is defined as the set of points (x, y) such that the Manhattan distance between (x_0, y_0) and (x, y) is at most r.

Manhattan distance between (x_0, y_0) and (x, y) is defined as |x - x_0| + |y - y_0|.

Input

The first line contains two integers n, r (1 ≤ n ≤ 300 000, 1 ≤ r ≤ 10^6), the number of points and the radius of the ball, respectively.

Each of the next n lines contains integers x_i, y_i (-10^6 ≤ x_i, y_i ≤ 10^6), describing the coordinates of the i-th point.

It is guaranteed, that all points are distinct.

Output

Print one integer — the maximum number points that an L^1-ball with radius r can cover.

Examples

Input

5 1
1 1
1 -1
-1 1
-1 -1
2 0

Output

3

Input

5 2
1 1
1 -1
-1 1
-1 -1
2 0

Output

5

Note

In the first example, a ball centered at (1, 0) covers the points (1, 1), (1, -1), (2, 0).

In the second example, a ball centered at (0, 0) covers all the points.

Note that x_0 and y_0 need not be integer.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e5 + 25;
const long long inf = (long long)1e12;
const int MOD = (int)1e9 + 7;
struct Point {
  int x, y;
  bool operator<(const Point& b) const { return x != b.x ? x < b.x : y < b.y; }
};
Point pt[N];
int mp[N];
int seg[N << 2], lzy[N << 2];
inline void init(int n) {
  memset(seg, 0, 4 * n * sizeof(int));
  memset(lzy, 0, 4 * n * sizeof(int));
}
inline void pushDown(int rt) {
  if (lzy[rt]) {
    seg[rt << 1] += lzy[rt];
    seg[rt << 1 | 1] += lzy[rt];
    lzy[rt << 1] += lzy[rt];
    lzy[rt << 1 | 1] += lzy[rt];
    lzy[rt] = 0;
  }
}
inline void pushUp(int rt) { seg[rt] = max(seg[rt << 1], seg[rt << 1 | 1]); }
inline void update(int ql, int qr, int val, int l, int r, int rt) {
  if (ql <= l && r <= qr) {
    seg[rt] += val;
    lzy[rt] += val;
    return;
  }
  pushDown(rt);
  int m = (l + r) >> 1;
  if (ql <= m) {
    update(ql, qr, val, l, m, rt << 1);
  }
  if (m < qr) {
    update(ql, qr, val, m + 1, r, rt << 1 | 1);
  }
  pushUp(rt);
}
int main() {
  int n, r;
  while (~scanf("%d%d", &n, &r)) {
    init(n + 5);
    for (int i = 1; i <= n; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      pt[i].x = x + y;
      mp[i] = pt[i].y = x - y;
    }
    int ans = 0;
    sort(pt + 1, pt + 1 + n);
    sort(mp + 1, mp + 1 + n);
    int tot = unique(mp + 1, mp + n + 1) - mp - 1;
    int l = 1;
    for (int i = 1; i <= n; i++) {
      while (pt[i].x - pt[l].x > 2 * r) {
        int rp = upper_bound(mp + 1, mp + 1 + tot, pt[l].y + 2 * r) - mp - 1;
        int lp = lower_bound(mp + 1, mp + 1 + tot, pt[l].y) - mp;
        update(lp, rp, -1, 1, tot, 1);
        l++;
      }
      int rp = upper_bound(mp + 1, mp + 1 + tot, pt[i].y + 2 * r) - mp - 1;
      int lp = lower_bound(mp + 1, mp + 1 + tot, pt[i].y) - mp;
      update(lp, rp, 1, 1, tot, 1);
      ans = max(ans, seg[1]);
    }
    printf("%d\n", ans);
  }
}

```


### Prompt

Create a solution in CPP for the following problem:

We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.

We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).

Constraints

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

Input

Input is given from Standard Input in the following format:

N K

Output

Print the number of possible values of the sum, modulo (10^9+7).

Examples

Input

3 2

Output

10

Input

200000 200001

Output

1

Input

141421 35623

Output

220280457

### Response

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

int main(){
  long long n,k;
  cin >> n >> k;
  long long ans=0;
  while(k<=n+1){
    ans=(ans+(k*(n-k+1)+1))%1000000007;
    k++;
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drink equals pi percent.

One day Vasya decided to make himself an orange cocktail. He took equal proportions of each of the n drinks and mixed them. Then he wondered, how much orange juice the cocktail has.

Find the volume fraction of orange juice in the final drink.

Input

The first input line contains a single integer n (1 ≤ n ≤ 100) — the number of orange-containing drinks in Vasya's fridge. The second line contains n integers pi (0 ≤ pi ≤ 100) — the volume fraction of orange juice in the i-th drink, in percent. The numbers are separated by a space.

Output

Print the volume fraction in percent of orange juice in Vasya's cocktail. The answer will be considered correct if the absolute or relative error does not exceed 10  - 4.

Examples

Input

3
50 50 100

Output

66.666666666667

Input

4
0 25 50 75

Output

37.500000000000

Note

Note to the first sample: let's assume that Vasya takes x milliliters of each drink from the fridge. Then the volume of pure juice in the cocktail will equal <image> milliliters. The total cocktail's volume equals 3·x milliliters, so the volume fraction of the juice in the cocktail equals <image>, that is, 66.(6) percent.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n;
  double sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> k;
    sum += k / 100.0;
  }
  printf("%.12f\n", sum / n * 100);
  return 0;
}

```


### Prompt

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

Suppose you are given two strings a and b. You can apply the following operation any number of times: choose any contiguous substring of a or b, and sort the characters in it in non-descending order. Let f(a, b) the minimum number of operations you have to apply in order to make them equal (or f(a, b) = 1337 if it is impossible to make a and b equal using these operations).

For example:

  * f(ab, ab) = 0;
  * f(ba, ab) = 1 (in one operation, we can sort the whole first string);
  * f(ebcda, ecdba) = 1 (in one operation, we can sort the substring of the second string starting from the 2-nd character and ending with the 4-th character);
  * f(a, b) = 1337.

You are given n strings s_1, s_2, ..., s_k having equal length. Calculate ∑ _{i = 1}^{n} ∑_{j = i + 1}^{n} f(s_i, s_j).

Input

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

Then n lines follow, each line contains one of the strings s_i, consisting of lowercase Latin letters. |s_1| = |s_2| = … = |s_n|, and n ⋅ |s_1| ≤ 2 ⋅ 10^5. All these strings are pairwise distinct.

Output

Print one integer: ∑ _{i = 1}^{n} ∑_{j = i + 1}^{n} f(s_i, s_j).

Examples

Input

4
zzz
bac
abc
acb

Output

4015

Input

2
a
b

Output

1337

### Response

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

#define int long long
#define double long double
//#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
double PI=3.14159265359;
int inf=1000000000000000007;
int mod=1000000007;
int mod1=998244353;

const bool multi=0;

string s[200007];
string s1[200007];
int it=1,n,m;
int fen[400007];
int trie[200007][27];
int pre[200007],post[200007],c=0;
int last[27];

void dfs(int v)
{
    pre[v]=++c;
    for(int j=0;j<26;j++) if(trie[v][j]>0) dfs(trie[v][j]);
    post[v]=c;
}

inline void ins(int x,int val) {while(x<=it)  {  fen[x]+=val;  x+=(x&-x);  } }

inline int que(int x) {int res=0;  while(x>0)  {  res+=fen[x];  x-=(x&-x);  } return res; }

vector<int> gdzie[200007];
vector<int> mx[200007];
int pairs;

void solve(vector<int> id,int j)
{
    if(sz(id)<=1||j>=m) return ;
    for(auto x:id) ins(pre[gdzie[x][0]],1);
    vector<int>vec[26];
    for(auto x:id) vec[s[x][j]-'a'].pb(x);
    for(int i=0;i<26;i++)
    {
        for(auto x:vec[i]) ins(pre[gdzie[x][0]],-1);
        for(auto x:vec[i]) pairs+=que(post[gdzie[x][mx[x][j]]])-que(pre[gdzie[x][mx[x][j]]]-1);
        for(auto x:vec[i]) ins(pre[gdzie[x][0]],1);
    }
    for(auto x:id) ins(pre[gdzie[x][0]],-1);
    for(int i=0;i<26;i++) solve(vec[i],j+1);
}

map<string,int>mapa;

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt;
    if(multi)
        cin>>tt;
    else tt=1;
    while(tt--)
    {
        cin>>n;
        for(int i=1;i<=n;i++) cin>>s[i];
        m=sz(s[1]);
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<=m+1;j++)
            {
                gdzie[i].pb(0);
                mx[i].pb(0);
            }
            int p=1;
            gdzie[i][m]=1;
            for(int j=m-1;j>=0;j--)
            {
                if(trie[p][s[i][j]-'a']==0) trie[p][s[i][j]-'a']=++it;
                p=trie[p][s[i][j]-'a'];
                gdzie[i][j]=p;
            }
        }
        dfs(1);
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<26;j++) last[j]=m;
            mx[i][m]=m;
            for(int j=m-1;j>=0;j--)
            {
                int xd=mod;
                last[s[i][j]-'a']=j;
                for(int l=s[i][j]-'a'-1;l>=0;l--) xd=min(xd,last[l]);
                mx[i][j]=min(xd,mx[i][j+1]);
            }
        }
        vector<int>act;
        for(int i=1;i<=n;i++)
        {
            s1[i]=s[i];
            sort(s1[i].begin(),s1[i].end());
        }
        vector<pair<string,int>>vec;
        for(int i=1;i<=n;i++) vec.pb({s1[i],i});
        sort(vec.begin(),vec.end());
        act.pb(vec[0].nd);
        int ans=0,bad=0,good=0;
        for(int i=1;i<=n;i++)
        {
            good+=mapa[s[i]];
            mapa[s[i]]++;
        }
        for(int i=1;i<n;i++)
        {
            if(vec[i].st!=vec[i-1].st)
            {
                pairs=0;
                solve(act,0);
                ans+=pairs;
                ans+=2*(sz(act)*(sz(act)-1)/2-pairs);
                bad+=sz(act)*(n-sz(act));
                act.clear();
            }
            act.pb(vec[i].nd);
        }
        pairs=0;
        solve(act,0);
        ans+=pairs;
        ans+=2*(sz(act)*(sz(act)-1)/2-pairs);
        bad+=sz(act)*(n-sz(act));
        ans+=bad/2*1337;
        ans-=good*2;
        cout<<ans<<endl;
    }

    return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some words. To make it still possible to read, he will try to modify each word as little as possible.

Limak has a string s that consists of uppercase English letters. In one move he can swap two adjacent letters of the string. For example, he can transform a string "ABBC" into "BABC" or "ABCB" in one move.

Limak wants to obtain a string without a substring "VK" (i.e. there should be no letter 'V' immediately followed by letter 'K'). It can be easily proved that it's possible for any initial string s.

What is the minimum possible number of moves Limak can do?

Input

The first line of the input contains an integer n (1 ≤ n ≤ 75) — the length of the string.

The second line contains a string s, consisting of uppercase English letters. The length of the string is equal to n.

Output

Print one integer, denoting the minimum possible number of moves Limak can do, in order to obtain a string without a substring "VK".

Examples

Input

4
VKVK

Output

3

Input

5
BVVKV

Output

2

Input

7
VVKEVKK

Output

3

Input

20
VKVKVVVKVOVKVQKKKVVK

Output

8

Input

5
LIMAK

Output

0

Note

In the first sample, the initial string is "VKVK". The minimum possible number of moves is 3. One optimal sequence of moves is:

  1. Swap two last letters. The string becomes "VKKV".
  2. Swap first two letters. The string becomes "KVKV".
  3. Swap the second and the third letter. The string becomes "KKVV". Indeed, this string doesn't have a substring "VK".

In the second sample, there are two optimal sequences of moves. One is "BVVKV" → "VBVKV" → "VVBKV". The other is "BVVKV" → "BVKVV" → "BKVVV".

In the fifth sample, no swaps are necessary.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 80, INF = 0x3f3f3f3f;
char str[MAXN];
vector<int> vs, ks, xs;
int dp[MAXN][MAXN][MAXN][2];
int remain(vector<int> &vec, int start, int lim) {
  int res = 0;
  for (unsigned i = start; i < vec.size() && vec[i] < lim; i++) res++;
  return res;
}
void update(int &dst, int v, int k, int x, int canK, int val) {
  int d = remain(vs, v, val) + remain(ks, k, val) + remain(xs, x, val);
  dst = min(dst, dp[v][k][x][canK] + d);
}
int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);
  int n;
  cin >> n >> str;
  for (int i = 0; i < n; i++) {
    if (str[i] == 'V')
      vs.push_back(i);
    else if (str[i] == 'K')
      ks.push_back(i);
    else
      xs.push_back(i);
  }
  memset(dp, INF, sizeof(dp));
  dp[0][0][0][1] = 0;
  for (unsigned v = 0; v <= vs.size(); v++) {
    for (unsigned k = 0; k <= ks.size(); k++) {
      for (unsigned x = 0; x <= xs.size(); x++) {
        for (unsigned canK = 0; canK <= 1; canK++) {
          if (v < vs.size()) update(dp[v + 1][k][x][0], v, k, x, canK, vs[v]);
          if (canK && k < ks.size()) {
            update(dp[v][k + 1][x][1], v, k, x, canK, ks[k]);
          }
          if (x < xs.size()) update(dp[v][k][x + 1][1], v, k, x, canK, xs[x]);
        }
      }
    }
  }
  int *ans = dp[vs.size()][ks.size()][xs.size()];
  cout << min(ans[0], ans[1]) << '\n';
}

```


### Prompt

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

Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as possible. New app suggested n available Beru-taxi nearby. The i-th taxi is located at point (xi, yi) and moves with a speed vi.

Consider that each of n drivers will move directly to Vasiliy and with a maximum possible speed. Compute the minimum time when Vasiliy will get in any of Beru-taxi cars.

Input

The first line of the input contains two integers a and b ( - 100 ≤ a, b ≤ 100) — coordinates of Vasiliy's home.

The second line contains a single integer n (1 ≤ n ≤ 1000) — the number of available Beru-taxi cars nearby.

The i-th of the following n lines contains three integers xi, yi and vi ( - 100 ≤ xi, yi ≤ 100, 1 ≤ vi ≤ 100) — the coordinates of the i-th car and its speed.

It's allowed that several cars are located at the same point. Also, cars may be located at exactly the same point where Vasiliy lives.

Output

Print a single real value — the minimum time Vasiliy needs to get in any of the Beru-taxi cars. You answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if <image>.

Examples

Input

0 0
2
2 0 1
0 2 2

Output

1.00000000000000000000

Input

1 3
3
3 3 2
-2 3 6
-2 7 10

Output

0.50000000000000000000

Note

In the first sample, first taxi will get to Vasiliy in time 2, and second will do this in time 1, therefore 1 is the answer.

In the second sample, cars 2 and 3 will arrive simultaneously.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  long double q[100000][3];
  long double a, b, t, d, min, di;
  cin >> a >> b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> q[i][j];
    }
  }
  di = sqrt((q[0][0] - a) * (q[0][0] - a) + (q[0][1] - b) * (q[0][1] - b));
  min = di / q[0][2];
  for (int i = 0; i < n; i++) {
    d = sqrt((q[i][0] - a) * (q[i][0] - a) + (q[i][1] - b) * (q[i][1] - b));
    t = d / q[i][2];
    if (t < min || i == 0) min = t;
  }
  cout << std::setprecision(14) << min;
}

```


### Prompt

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

Blackjack is a type of card game played in casinos, where the game is played using cards with numbers from 1 to 13. The score of each card is decided as follows.

* 1 is 1 point or 11 points
* From 2 to 9, the score is as written.
* 10 points from 10 to 13

There are several participants in this game, including parents, each with several sets of cards. This set of cards is called a hand. The hand score is the total of the card scores. The calculation shall be performed as follows.

* If the total score of the cards is greater than 21, the score of the hand is set to 0.
* As the score of the card, 1 may be calculated as 1 point or 11 points, but the one with the maximum hand score shall be selected.

Create a program that uses the information of the cards dealt as input and outputs the score of the hand.

Input

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

c1 c2 ... cn

The integer ci (1 ≤ ci ≤ 13) written on the i-th card is given to each line, separated by blanks. The number of cards n does not exceed 100.

The number of datasets does not exceed 200.

Output

The score of the hand is output to one line for each data set.

Example

Input

1
7 7 7
7 7 8
12 1
10 1 1
0

Output

11
21
0
21
12

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int ans,f,num;
string s;

int getNum(int x){
  int res=0;
  for(int i=x;s[i]!=' '&&i!=s.size();i++){
    res=res*10+s[i]-'0';
  }
  return res;
}

int main(){
  int d[14]={0,1,2,3,4,5,6,7,8,9,10,10,10,10};
  while(1){
    getline(cin,s);
    if(s=="0")break;
    ans=0,f=0;
    for(int i=0;i<s.size();i++){
      num=getNum(i);
      while(s[i]!=' '&&i!=s.size())i++;
      ans+=d[num];
      if(num==1)f=1;
    }
    if(f&&ans+10<=21)cout<<ans+10<<endl;
    else if(ans<=21)cout<<ans<<endl;
    else cout<<0<<endl;
  }
  return 0;
}
```


### Prompt

Create a solution in CPP for the following problem:

You are a given a list of integers a_1, a_2, …, a_n and s of its segments [l_j; r_j] (where 1 ≤ l_j ≤ r_j ≤ n).

You need to select exactly m segments in such a way that the k-th order statistic of the multiset of a_i, where i is contained in at least one segment, is the smallest possible. If it's impossible to select a set of m segments in such a way that the multiset contains at least k elements, print -1.

The k-th order statistic of a multiset is the value of the k-th element after sorting the multiset in non-descending order.

Input

The first line contains four integers n, s, m and k (1 ≤ m ≤ s ≤ 1500, 1 ≤ k ≤ n ≤ 1500) — the size of the list, the number of segments, the number of segments to choose and the statistic number.

The second line contains n integers a_i (1 ≤ a_i ≤ 10^9) — the values of the numbers in the list.

Each of the next s lines contains two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n) — the endpoints of the segments.

It is possible that some segments coincide.

Output

Print exactly one integer — the smallest possible k-th order statistic, or -1 if it's impossible to choose segments in a way that the multiset contains at least k elements.

Examples

Input

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

Output

2

Input

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

Output

1

Input

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

Output

-1

Note

In the first example, one possible solution is to choose the first and the third segment. Together they will cover three elements of the list (all, except for the third one). This way the 2-nd order statistic for the covered elements is 2.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1500 + 10;
const int INF = 0x3f3f3f3f;
int n, s, m, k;
int a[N], b[N], f[N][N], mn[N];
struct dat {
  int l, r;
  bool operator<(const dat& rhs) const { return l < rhs.l; }
} q[N];
bool flag[N];
int mx[N];
void update(int x, int v) {
  for (; x <= n; x += x & -x) mx[x] = max(mx[x], v);
}
int query(int x) {
  int res = 0;
  for (; x; x -= x & -x) res = max(res, mx[x]);
  return res;
}
bool check(int mid) {
  for (int i = 1; i <= n; i++)
    if (a[i] <= mid)
      b[i] = 1;
    else
      b[i] = 0;
  int Max = 0;
  for (int i = 1; i <= n; i++) b[i] += b[i - 1];
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= m; i++) {
    memset(mx, 0, sizeof(mx));
    for (int j = 1; j <= s; j++) {
      f[i][j] = f[i - 1][j];
      int t = mn[q[j].l];
      f[i][j] = max(f[i][j], f[i - 1][t] + b[q[j].r] - b[q[t].r]);
      f[i][j] = max(f[i][j], query(q[j].l - 1) + b[q[j].r] - b[q[j].l - 1]);
      update(q[j].r, f[i - 1][j]);
      Max = max(Max, f[i][j]);
    }
  }
  return Max >= k;
}
int main() {
  cin >> n >> s >> m >> k;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= s; i++) scanf("%d%d", &q[i].l, &q[i].r);
  for (int i = 1; i <= s; i++)
    for (int j = 1; j <= s; j++)
      if (i != j && !flag[j] && q[j].l <= q[i].l && q[i].r <= q[j].r) {
        flag[i] = 1;
        break;
      }
  int tp = 0;
  for (int i = 1; i <= s; i++)
    if (!flag[i]) q[++tp].l = q[i].l, q[tp].r = q[i].r;
  s = tp;
  sort(q + 1, q + s + 1);
  for (int i = 1; i <= s; i++)
    for (int j = q[i].l; j <= q[i].r; j++)
      if (!mn[j] || q[mn[j]].l > q[i].l) mn[j] = i;
  int L = -INF, R = INF;
  while (L < R) {
    int mid = L + R >> 1;
    if (check(mid))
      R = mid;
    else
      L = mid + 1;
  }
  if (check(L))
    cout << L;
  else
    cout << -1;
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

C： AA グラフ (AA Graph)

Problem

Given a graph as an ASCII Art (AA), please print the length of shortest paths from the vertex s to the vertex t. The AA of the graph satisfies the following constraints.

A vertex is represented by an uppercase alphabet and symbols `o` in 8 neighbors as follows.

ooo
oAo
ooo

Horizontal edges and vertical edges are represented by symbols `-` and `|`, respectively. Lengths of all edges are 1, that is, it do not depends on the number of continuous symbols `-` or `|`. All edges do not cross each other, and all vertices do not overlap and touch each other.

For each vertex, outgoing edges are at most 1 for each directions top, bottom, left, and right. Each edge is connected to a symbol `o` that is adjacent to an uppercase alphabet in 4 neighbors as follows.

..|..
.ooo.
-oAo-
.ooo.
..|..

Therefore, for example, following inputs are not given.

..........
.ooo..ooo.
.oAo..oBo.
.ooo--ooo.
..........

(Edges do not satisfies the constraint about their position.)

oooooo
oAooBo
oooooo

(Two vertices are adjacent each other.)

Input Format

H W s t
a_1
$\vdots$
a_H

* In line 1, two integers H and W, and two characters s and t are given. H and W is the width and height of the AA, respectively. s and t is the start and end vertices, respectively. They are given in separating by en spaces.
* In line 1 + i where 1 \leq i \leq H, the string representing line i of the AA is given.

Constraints

* 3 \leq H, W \leq 50
* s and t are selected by uppercase alphabets from `A` to `Z`, and s \neq t.
* a_i (1 \leq i \leq H) consists of uppercase alphabets and symbols `o`, `-`, `|`, and `.`.
* Each uppercase alphabet occurs at most once in the AA.
* It is guaranteed that there are two vertices representing s and t.
* The AA represents a connected graph.

Output Format

Print the length of the shortest paths from s to t in one line.

Example 1

14 16 A L
ooo.....ooo.....
oAo-----oHo.....
ooo.....ooo..ooo
.|.......|...oLo
ooo..ooo.|...ooo
oKo--oYo.|....|.
ooo..ooo.|....|.
.|....|.ooo...|.
.|....|.oGo...|.
.|....|.ooo...|.
.|....|.......|.
ooo..ooo.....ooo
oFo--oXo-----oEo
ooo..ooo.....ooo

Output 1

5

Exapmple 2

21 17 F L
.................
.....ooo.....ooo.
.....oAo-----oBo.
.....ooo.....ooo.
......|.......|..
.ooo..|..ooo..|..
.oCo..|..oDo.ooo.
.ooo.ooo.ooo.oEo.
..|..oFo..|..ooo.
..|..ooo..|...|..
..|...|...|...|..
..|...|...|...|..
..|...|...|...|..
.ooo.ooo.ooo..|..
.oGo-oHo-oIo..|..
.ooo.ooo.ooo..|..
..|...........|..
.ooo...ooo...ooo.
.oJo---oKo---oLo.
.ooo...ooo...ooo.
.................

Output 2

4

Example

Input

Output

### Response

```cpp
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;

int h, w; char s, t;
string art[50];
vector<int> et[26];

P toPos(char a) {
	int i, j;
	rep(i, h) rep(j, w) if (art[i][j] == a) return P(i, j);
	return P(-1, -1);
}

bool isConnect(char a, char b) {
	P posA = toPos(a); int yA = posA.first; int xA = posA.second;
	P posB = toPos(b); int yB = posB.first; int xB = posB.second;
	int i;

	if (yA == -1 || yB == -1) return false;
	if (yA == yB) {
		int y = yA;
		if (xA > xB) swap(xA, xB);
		if (art[y][xA + 1] != 'o') return false;
		if (art[y][xB - 1] != 'o') return false;
		for (i = xA + 2; i <= xB - 2; i++) {
			if (art[y][i] != '-') return false;
		}
		return true;
	}
	if (xA == xB) {
		int x = xA;
		if (yA > yB) swap(yA, yB);
		if (art[yA + 1][x] != 'o') return false;
		if (art[yB - 1][x] != 'o') return false;
		for (i = yA + 2; i <= yB - 2; i++) {
			if (art[i][x] != '|') return false;
		}
		return true;
	}
	return false;
}

int main() {
	int i, j, k;

	cin >> h >> w >> s >> t;
	for (i = 0; i < h; i++) cin >> art[i];

	for (i = 0; i < 26; i++) {
		for (j = i + 1; j < 26; j++) {
			if (isConnect('A' + i, 'A' + j)) {
				et[i].push_back(j);
				et[j].push_back(i);
			}
		}
	}

	int dist[26][26], INF = 114514;
	rep(i, 26) rep(j, 26) dist[i][j] = INF;
	rep(i, 26) dist[i][i] = 0;
	rep(i, 26) rep(j, et[i].size()) dist[i][et[i][j]] = 1;
	rep(k, 26) rep(i, 26) rep(j, 26) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	cout << dist[s - 'A'][t - 'A'] << endl;
	return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

You have a plate and you want to add some gilding to it. The plate is a rectangle that we split into w× h cells. There should be k gilded rings, the first one should go along the edge of the plate, the second one — 2 cells away from the edge and so on. Each ring has a width of 1 cell. Formally, the i-th of these rings should consist of all bordering cells on the inner rectangle of size (w - 4(i - 1))×(h - 4(i - 1)).

<image> The picture corresponds to the third example.

Your task is to compute the number of cells to be gilded.

Input

The only line contains three integers w, h and k (3 ≤ w, h ≤ 100, 1 ≤ k ≤ \left⌊ (min(n, m) + 1)/(4)\right⌋, where ⌊ x ⌋ denotes the number x rounded down) — the number of rows, columns and the number of rings, respectively.

Output

Print a single positive integer — the number of cells to be gilded.

Examples

Input

3 3 1

Output

8

Input

7 9 1

Output

28

Input

7 9 2

Output

40

Note

The first example is shown on the picture below.

<image>

The second example is shown on the picture below.

<image>

The third example is shown in the problem description.

### Response

```cpp
#include <bits/stdc++.h>
int gold(int m, int n, int k) {
  int f, i = 1, tot, total = 0;
  f = (((m + n) * 2) - 4);
  total = f;
  if (k > 1) {
    while (i <= (k - 1)) {
      m = m - 4;
      n = n - 4;
      tot = (((m + n) * 2) - 4);
      total = tot + total;
      i++;
    }
  }
  return total;
}
int main(int argc, char **argv) {
  int g, h, t, k;
  scanf("%d", &g);
  scanf("%d", &h);
  scanf("%d", &k);
  t = gold(g, h, k);
  printf("%d", t);
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

One day Petya got a birthday present from his mom: a book called "The Legends and Myths of Graph Theory". From this book Petya learned about a hydra graph.

A non-oriented graph is a hydra, if it has a structure, shown on the figure below. Namely, there are two nodes u and v connected by an edge, they are the hydra's chest and stomach, correspondingly. The chest is connected with h nodes, which are the hydra's heads. The stomach is connected with t nodes, which are the hydra's tails. Note that the hydra is a tree, consisting of h + t + 2 nodes.

<image>

Also, Petya's got a non-directed graph G, consisting of n nodes and m edges. Petya got this graph as a last year birthday present from his mom. Graph G contains no self-loops or multiple edges.

Now Petya wants to find a hydra in graph G. Or else, to make sure that the graph doesn't have a hydra.

Input

The first line contains four integers n, m, h, t (1 ≤ n, m ≤ 105, 1 ≤ h, t ≤ 100) — the number of nodes and edges in graph G, and the number of a hydra's heads and tails.

Next m lines contain the description of the edges of graph G. The i-th of these lines contains two integers ai and bi (1 ≤ ai, bi ≤ n, a ≠ b) — the numbers of the nodes, connected by the i-th edge.

It is guaranteed that graph G contains no self-loops and multiple edges. Consider the nodes of graph G numbered with integers from 1 to n.

Output

If graph G has no hydra, print "NO" (without the quotes).

Otherwise, in the first line print "YES" (without the quotes). In the second line print two integers — the numbers of nodes u and v. In the third line print h numbers — the numbers of the nodes that are the heads. In the fourth line print t numbers — the numbers of the nodes that are the tails. All printed numbers should be distinct.

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

Examples

Input

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

Output

YES
4 1
5 6
9 3 2

Input

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

Output

NO

Note

The first sample is depicted on the picture below:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > vv;
int n, m, h, t;
vector<pair<int, int> > edges;
vector<int> add;
int count(int v1, int v2) {
  int ans = 0;
  vector<int> all;
  int id1 = 0, id2 = 0;
  while (id1 < vv[v1].size() || id2 < vv[v2].size()) {
    if (id1 == vv[v1].size()) {
      all.push_back(vv[v2][id2]);
      id2++;
      continue;
    }
    if (id2 == vv[v2].size()) {
      all.push_back(vv[v1][id1]);
      id1++;
      continue;
    }
    if (vv[v1][id1] < vv[v2][id2]) {
      all.push_back(vv[v1][id1]);
      id1++;
    } else {
      all.push_back(vv[v2][id2]);
      id2++;
    }
  }
  add.clear();
  for (int i = 1; i < all.size(); i++) {
    if (all[i] == all[i - 1]) {
      ans++;
      add.push_back(all[i]);
    }
  }
  return ans;
}
bool used[100002];
int main() {
  cin >> n >> m >> h >> t;
  vv.resize(n + 1);
  for (int i = 0; i < m; i++) {
    int from, to;
    cin >> from >> to;
    vv[from].push_back(to);
    vv[to].push_back(from);
    edges.push_back(make_pair(from, to));
    edges.push_back(make_pair(to, from));
  }
  for (int i = 0; i <= n; i++) {
    sort(vv[i].begin(), vv[i].end());
  }
  for (int i = 0; i < edges.size(); i++) {
    int u = edges[i].first;
    int v = edges[i].second;
    if ((int)vv[u].size() - 1 < h || (int)vv[v].size() - 1 < t) continue;
    int cnt_all = count(u, v);
    int cnt1 = vv[u].size() - 1 - cnt_all;
    int cnt2 = vv[v].size() - 1 - cnt_all;
    int need = max(0, h - cnt1);
    cnt_all -= need;
    cnt1 += need;
    need = max(0, t - cnt2);
    cnt_all -= need;
    cnt2 += need;
    if (cnt_all >= 0 && cnt1 >= h && cnt2 >= t) {
      cout << "YES\n";
      cout << u << ' ' << v << '\n';
      int cnt = 0;
      used[u] = true;
      used[v] = true;
      for (int j = 0; j < add.size(); j++) used[add[j]] = true;
      for (int j = 0; j < vv[u].size() && cnt < h; j++) {
        if (!used[vv[u][j]]) {
          cout << vv[u][j] << ' ';
          cnt++;
          used[vv[u][j]] = true;
        }
      }
      int from = 0;
      while (cnt < h) {
        cout << add[from] << ' ';
        cnt++;
        from++;
      }
      cout << '\n';
      cnt = 0;
      for (int j = 0; j < vv[v].size() && cnt < t; j++) {
        if (!used[vv[v][j]]) {
          cout << vv[v][j] << ' ';
          cnt++;
        }
      }
      while (cnt < t) {
        cout << add[from] << ' ';
        cnt++;
        from++;
      }
      cout << '\n';
      return 0;
    }
  }
  cout << "NO\n";
  return 0;
}

```