### Prompt

Please create a solution in cpp to the following problem:

Polycarpus loves convex polygons, especially if all their angles are the same and all their sides are different. Draw for him any such polygon with the given number of vertexes.

Input

The input contains a single integer n (3 ≤ n ≤ 100) — the number of the polygon vertexes.

Output

Print n lines, containing the coordinates of the vertexes of the n-gon "xi yi" in the counter clockwise order. The coordinates of the vertexes shouldn't exceed 106 in their absolute value. The side lengths should fit within limits [1, 1000] (not necessarily integer). Mutual comparing sides and angles of your polygon during the test will go with precision of 10 - 3.

If there is no solution, print "No solution" (without the quotes).

Examples

Input

8

Output

1.000 0.000
7.000 0.000
9.000 2.000
9.000 3.000
5.000 7.000
3.000 7.000
0.000 4.000
0.000 1.000

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int dcmp(double u) {
  if (u > eps) return 1;
  if (u < (-eps)) return -1;
  return 0;
}
struct Point {
  double x;
  double y;
  Point() {}
  Point(double u, double v) {
    x = u;
    y = v;
    return;
  }
  void input() {
    scanf("%lf%lf", &x, &y);
    return;
  }
  void output() { printf("%.9lf %.9lf ", x, y); }
  double len() { return sqrt(x * x + y * y); }
  void tolen(double u) {
    double l = len();
    x /= l;
    x *= u;
    y /= l;
    y *= u;
    return;
  }
  void rotate(double sx, double cx) {
    double x1 = x, y1 = y;
    x = x1 * cx - y1 * sx;
    y = x1 * sx + y1 * cx;
    return;
  }
};
Point er;
Point operator+(Point u, Point v) { return Point(u.x + v.x, u.y + v.y); }
Point operator-(Point u, Point v) { return Point(u.x - v.x, u.y - v.y); }
Point operator*(double u, Point v) { return Point(u * v.x, u * v.y); }
Point operator*(Point v, double u) { return Point(u * v.x, u * v.y); }
double dot(Point u, Point v) { return u.x * v.x + u.y * v.y; }
double det(Point u, Point v) { return u.x * v.y - u.y * v.x; }
struct Line {
  Point d;
  Point dir;
  Line() {}
  Line(Point d1, Point di) {
    d = d1;
    dir = di;
  }
  void makeline(Point d1, Point d2) {
    d = d1;
    dir = d2 - d1;
  }
  void input() {
    Point d1;
    Point d2;
    d1.input();
    d2.input();
    makeline(d1, d2);
  }
};
Point intersect(Line a, Line b) {
  if (dcmp(det(a.dir, b.dir)) == 0) return er;
  double t;
  t = det(b.d, b.dir) - det(a.d, b.dir);
  t /= det(a.dir, b.dir);
  return a.d + t * a.dir;
}
Point ans[200];
double sa, ca;
double al;
double pi;
int n;
int main() {
  scanf("%d", &n);
  if (n <= 4) {
    printf("No solution\n");
    return 0;
  }
  pi = atan(1) * 4;
  al = 2 * pi / (double)n;
  sa = sin(al);
  ca = cos(al);
  double len = 100;
  ans[1] = Point(0, 0);
  Point dir = Point(len, 0);
  for (int i = 2; i <= n; i++) {
    ans[i] = ans[i - 1] + dir;
    len += 0.003;
    dir.tolen(len);
    dir.rotate(sa, ca);
  }
  Line l1, l2;
  l1.d = ans[n];
  l1.dir = dir;
  l2.d = ans[1];
  l2.dir = Point(1, 0);
  Point u = intersect(l1, l2);
  ans[1] = u;
  for (int i = 1; i <= n; i++) printf("%.4lf %.4lf\n", ans[i].x, ans[i].y);
  return 0;
}

```


### Prompt

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

There are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \dots, x_N) and (y_1, y_2, \dots, y_N) are both permuations of (1, 2, \dots, N).

For each k = 1,2,\dots,N, find the answer to the following question:

Rng is in City k. Rng can perform the following move arbitrarily many times:

* move to another city that has a smaller x-coordinate and a smaller y-coordinate, or a larger x-coordinate and a larger y-coordinate, than the city he is currently in.

How many cities (including City k) are reachable from City k?

Constraints

* 1 \leq N \leq 200,000
* (x_1, x_2, \dots, x_N) is a permutation of (1, 2, \dots, N).
* (y_1, y_2, \dots, y_N) is a permutation of (1, 2, \dots, N).
* All values in input are integers.

Input

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 N lines. In i-th line print the answer to the question when k = i.

Examples

Input

4
1 4
2 3
3 1
4 2

Output

1
1
2
2

Input

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

Output

3
3
1
1
2
3
2

### Response

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

#define int long long
#define double long double

const int INF=2147483647;
const int MOD=1000000007;
const int mod=998244353;
const double eps=1e-12;

using namespace std;

struct Pt{
    int x,y,idx;
};

bool cmp(Pt a,Pt b){
    return (a.x<b.x);
}

Pt pt[200001];

int p[200001];
int sz[200001];
int res[200001];

int findp(int v){
    if(v==p[v]){
        return v;
    }
    return p[v]=findp(p[v]);
}

void Union(int v1,int v2){
    int p1=findp(v1);
    int p2=findp(v2);
    if(p1==p2){
        return;
    }
    if(sz[p1]<sz[p2]){
        p[p1]=p2;
        sz[p2]+=sz[p1];
    }
    else{
        p[p2]=p1;
        sz[p1]+=sz[p2];
    }
}

vector<int> mq;

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>pt[i].x>>pt[i].y;
        pt[i].idx=i;
    }
    sort(pt,pt+n,cmp);

    for(int i=0;i<n;i++){
        sz[i]=1;
        p[i]=i;
    }

    for(int i=0;i<n;i++){

        int Min=i;

        while(mq.empty()==0 and pt[*mq.rbegin()].y < pt[i].y ){
            Union(*mq.rbegin(),i);
            if(pt[Min].y > pt[*mq.rbegin()].y){
                Min=*mq.rbegin();
            }
            mq.pop_back();
        }
        mq.push_back(Min);

    }

    for(int i=0;i<n;i++){
        res[ pt[i].idx ]=sz[findp(i)];
    }

    for(int i=0;i<n;i++){
        cout<<res[i]<<endl;
    }

    return 0;
}

```


### Prompt

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

zscoder loves simple strings! A string t is called simple if every pair of adjacent characters are distinct. For example ab, aba, zscoder are simple whereas aa, add are not simple.

zscoder is given a string s. He wants to change a minimum number of characters so that the string s becomes simple. Help him with this task!

Input

The only line contains the string s (1 ≤ |s| ≤ 2·105) — the string given to zscoder. The string s consists of only lowercase English letters.

Output

Print the simple string s' — the string s after the minimal number of changes. If there are multiple solutions, you may output any of them.

Note that the string s' should also consist of only lowercase English letters.

Examples

Input

aab

Output

bab

Input

caaab

Output

cabab

Input

zscoder

Output

zscoder

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
char get(char a, char b = '#') {
  for (char c = 'a'; c <= 'z'; c++)
    if (c != a && c != b) return c;
  assert(false);
}
signed main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int n = ((int)s.size());
  for (int i = 0; i < n;) {
    int j = i;
    while (j < n && s[j] == s[i]) j++;
    j--;
    int len = j - i + 1;
    for (int t = i + 1; t < j; t += 2) s[t] = get(s[i]);
    if (len % 2 == 0) s[j] = get(s[i], (j + 1 < n ? s[j + 1] : '#'));
    i = j + 1;
  }
  cout << s;
  return false;
}

```


### Prompt

Create a solution in Cpp for the following problem:

We have 3N colored balls with IDs from 1 to 3N. A string S of length 3N represents the colors of the balls. The color of Ball i is red if S_i is `R`, green if S_i is `G`, and blue if S_i is `B`. There are N red balls, N green balls, and N blue balls.

Takahashi will distribute these 3N balls to N people so that each person gets one red ball, one blue ball, and one green ball. The people want balls with IDs close to each other, so he will additionally satisfy the following condition:

* Let a_j < b_j < c_j be the IDs of the balls received by the j-th person in ascending order.
* Then, \sum_j (c_j-a_j) should be as small as possible.

Find the number of ways in which Takahashi can distribute the balls. Since the answer can be enormous, compute it modulo 998244353. We consider two ways to distribute the balls different if and only if there is a person who receives different sets of balls.

Constraints

* 1 \leq N \leq 10^5
* |S|=3N
* S consists of `R`, `G`, and `B`, and each of these characters occurs N times in S.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the number of ways in which Takahashi can distribute the balls, modulo 998244353.

Examples

Input

3
RRRGGGBBB

Output

216

Input

5
BBRGRRGRGGRBBGB

Output

960

### Response

```cpp
/*
	i need all of her, what if she doesn't even want any of me
*/
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Os")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define mp make_pair

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=3e5+10, maxm=1e7+10, lg=16, mod=998244353, inf=1e18;

ll n,cr,cg,cb;
string s;

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

	cin>>n>>s;
	ll ans=1; for(int i=1;i<=n;i++) ans*=i, ans%=mod;
	for(int i=0;i<3*n;i++){
		vector<ll> v={cr,cg,cb};
		sort(all(v),greater<ll>());
		ll x;
		if(s[i]=='R') x=cr++;
		if(s[i]=='G') x=cg++;
		if(s[i]=='B') x=cb++;
		if(v[0]==x);
		else if(v[1]==x) ans*=v[1]-v[0], ans%=mod;
		else ans*=v[2]-v[1], ans%=mod;
	}
	cout<<ans;

	return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Polar bears like unique arrays — that is, arrays without repeated elements.

You have got a unique array s with length n containing non-negative integers. Since you are good friends with Alice and Bob, you decide to split the array in two. Precisely, you need to construct two arrays a and b that are also of length n, with the following conditions for all i (1 ≤ i ≤ n):

  * ai, bi are non-negative integers;
  * si = ai + bi .

Ideally, a and b should also be unique arrays. However, life in the Arctic is hard and this is not always possible. Fortunately, Alice and Bob are still happy if their arrays are almost unique. We define an array of length n to be almost unique, if and only if it can be turned into a unique array by removing no more than <image> entries.

For example, the array [1, 2, 1, 3, 2] is almost unique because after removing the first two entries, it becomes [1, 3, 2]. The array [1, 2, 1, 3, 1, 2] is not almost unique because we need to remove at least 3 entries to turn it into a unique array.

So, your task is to split the given unique array s into two almost unique arrays a and b.

Input

The first line of the input contains integer n (1 ≤ n ≤ 105).

The second line contains n distinct integers s1, s2, ... sn (0 ≤ si ≤ 109).

Output

If it is possible to make Alice and Bob happy (if you can split the given array), print "YES" (without quotes) in the first line. In the second line, print the array a. In the third line, print the array b. There may be more than one solution. Any of them will be accepted.

If it is impossible to split s into almost unique arrays a and b, print "NO" (without quotes) in the first line.

Examples

Input

6
12 5 8 3 11 9

Output

YES
6 2 6 0 2 4
6 3 2 3 9 5

Note

In the sample, we can remove the first two entries from a and the second entry from b to make them both unique.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n, i, j, ans = 0;
long long a[1000000], b[1000000], c[1000000];
vector<pair<long long, long long> > V;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  long long x;
  for (i = 1; i <= n; i++) cin >> x, V.push_back({x, i}), c[i] = x;
  sort(V.begin(), V.end());
  long long rep = n / 3;
  if (n % 3) rep++;
  vector<long long> P;
  long long l = 0;
  for (i = 0; i < rep and i < n; i++)
    a[V[i].second] = 0, b[V[i].second] = V[i].first, P.push_back(V[i].first);
  for (i = rep; i < 2 * rep and i < n; i++)
    b[V[i].second] = 0, a[V[i].second] = V[i].first;
  long long k = rep - 1;
  for (i = 2 * rep; i < n; i++)
    a[V[i].second] = k, b[V[i].second] = c[V[i].second] - k, k--;
  cout << "YES" << endl;
  for (i = 1; i <= n; i++) cout << a[i] << " ";
  cout << endl;
  for (i = 1; i <= n; i++) cout << b[i] << " ";
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Bike is a smart boy who loves math very much. He invented a number called "Rotatable Number" inspired by 142857.

As you can see, 142857 is a magic number because any of its rotatings can be got by multiplying that number by 1, 2, ..., 6 (numbers from one to number's length). Rotating a number means putting its last several digit into first. For example, by rotating number 12345 you can obtain any numbers: 12345, 51234, 45123, 34512, 23451. It's worth mentioning that leading-zeroes are allowed. So both 4500123 and 0123450 can be obtained by rotating 0012345. You can see why 142857 satisfies the condition. All of the 6 equations are under base 10.

  * 142857·1 = 142857;
  * 142857·2 = 285714;
  * 142857·3 = 428571;
  * 142857·4 = 571428;
  * 142857·5 = 714285;
  * 142857·6 = 857142.

Now, Bike has a problem. He extends "Rotatable Number" under any base b. As is mentioned above, 142857 is a "Rotatable Number" under base 10. Another example is 0011 under base 2. All of the 4 equations are under base 2.

  * 0011·1 = 0011;
  * 0011·10 = 0110;
  * 0011·11 = 1001;
  * 0011·100 = 1100.

So, he wants to find the largest b (1 < b < x) so that there is a positive "Rotatable Number" (leading-zeroes allowed) of length n under base b.

Note that any time you multiply a rotatable number by numbers from 1 to its length you should get a rotating of that number.

Input

The only line contains two space-separated integers n, x (1 ≤ n ≤ 5·106, 2 ≤ x ≤ 109).

Output

Print a single integer — the largest b you found. If no such b exists, print -1 instead.

Examples

Input

6 11

Output

10

Input

5 8

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
const int inf = 0x3f3f3f3f;
int n, x;
bool is_prim(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
long long pow(long long a, long long b, long long mod) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ret;
}
int main() {
  cin >> n >> x;
  if (x == 1 || !is_prim(n + 1))
    ;
  else {
    for (int b = x - 1; b > 1; b--) {
      bool f = 1;
      for (int i = 2; i * i <= n; i++) {
        if (n % i) continue;
        if (pow(b, i, n + 1) == 1) f = 0;
        if (pow(b, n / i, n + 1) == 1) f = 0;
        if (f == 0) break;
      }
      if (f) return printf("%d\n", b), 0;
    }
  }
  puts("-1");
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome.

A palindrome is a string that reads the same backward as forward, for example strings "z", "aaa", "aba", "abccba" are palindromes, but strings "codeforces", "reality", "ab" are not.

Input

The first and single line contains string s (1 ≤ |s| ≤ 15).

Output

Print "YES" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or "NO" (without quotes) otherwise.

Examples

Input

abccaa

Output

YES

Input

abbcca

Output

NO

Input

abcda

Output

YES

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, n, b, c = 0, f;
  string s;
  cin >> s;
  a = s.size();
  n = a / 2;
  b = 0;
  f = a - 1;
  while (n > 0) {
    if (s[b] != s[f]) c++;
    n--;
    f--;
    b++;
  }
  if (c > 1)
    cout << "NO";
  else if (c == 0 && a % 2 == 0)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Dima worked all day and wrote down on a long paper strip his favorite number n consisting of l digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.

To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive integer without leading zeros. After that he will compute the sum of the two integers and write it down on a new strip.

Dima wants the resulting integer to be as small as possible, because it increases the chances that the sum will fit it in the bookshelf. Help Dima decide what is the minimum sum he can obtain.

Input

The first line contains a single integer l (2 ≤ l ≤ 100 000) — the length of the Dima's favorite number.

The second line contains the positive integer n initially written on the strip: the Dima's favorite number.

The integer n consists of exactly l digits and it does not contain leading zeros. Dima guarantees, that there is at least one valid way to split the strip.

Output

Print a single integer — the smallest number Dima can obtain.

Examples

Input

7
1234567

Output

1801

Input

3
101

Output

11

Note

In the first example Dima can split the number 1234567 into integers 1234 and 567. Their sum is 1801.

In the second example Dima can split the number 101 into integers 10 and 1. Their sum is 11. Note that it is impossible to split the strip into "1" and "01" since the numbers can't start with zeros.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = 1LL << 62;
const long long mx = 100005;
const double eps = 1e-10;
long long dx[10] = {1, 0, -1, 0};
long long dy[10] = {0, -1, 0, 1};
long long power(long long a, long long b) {
  if (b == 0) return 1;
  long long x = power(a, b / 2);
  x = x * x;
  if (b % 2) x = x * a;
  return x;
}
long long Set(long long N, long long pos) { return N = N | (1LL << pos); }
long long reset(long long N, long long pos) { return N = N & ~(1LL << pos); }
bool check(long long N, long long pos) { return (bool)(N & (1LL << pos)); }
string str;
long long n;
string add(long long a) {
  string one, two;
  for (long long i = a; i < n; i++) {
    two.push_back(str[i]);
  }
  for (long long i = a - 1; i >= 0; i--) {
    one.push_back(str[i]);
  }
  reverse(two.begin(), two.end());
  long long m = max((long long)(two).size(), (long long)(one).size());
  while ((long long)(two).size() < m) two.push_back('0');
  while ((long long)(one).size() < m) one.push_back('0');
  string res;
  long long b = 0;
  for (long long i = 0; i < m; i++) {
    long long c = (one[i] - '0') + (two[i] - '0') + b;
    res.push_back(c % 10 + '0');
    b = c / 10;
  }
  if (b != 0) res.push_back(b + '0');
  reverse(res.begin(), res.end());
  return res;
}
int main() {
  long long tst, a, b, c, k, m, ans = 0, t = 0;
  scanf("%lld", &n);
  cin >> str;
  string one;
  for (long long i = 1; i <= 100005; i++) {
    one.push_back('9');
  }
  string two = one;
  m = n / 2;
  for (long long i = m; i < n; i++) {
    if (str[i] == '0') continue;
    one = add(i);
    break;
  }
  if (n & 1)
    m++;
  else
    m--;
  for (long long i = m; i > 0; i--) {
    if (str[i] == '0') continue;
    two = add(i);
    break;
  }
  string res;
  if (one == two) {
    res = one;
  } else if ((long long)(one).size() < (long long)(two).size()) {
    res = one;
  } else if ((long long)(two).size() < (long long)(one).size()) {
    res = two;
  } else {
    for (long long i = 0; i < (long long)(one).size(); i++) {
      if (one[i] == two[i]) continue;
      if (one[i] < two[i]) {
        res = one;
        break;
      } else {
        res = two;
        break;
      }
    }
  }
  cout << res << "\n";
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Two famous competing companies ChemForces and TopChemist decided to show their sets of recently discovered chemical elements on an exhibition. However they know that no element should be present in the sets of both companies.

In order to avoid this representatives of both companies decided to make an agreement on the sets the companies should present. The sets should be chosen in the way that maximizes the total income of the companies.

All elements are enumerated with integers. The ChemForces company has discovered n distinct chemical elements with indices a_1, a_2, …, a_n, and will get an income of x_i Berland rubles if the i-th element from this list is in the set of this company.

The TopChemist company discovered m distinct chemical elements with indices b_1, b_2, …, b_m, and it will get an income of y_j Berland rubles for including the j-th element from this list to its set.

In other words, the first company can present any subset of elements from \\{a_1, a_2, …, a_n\} (possibly empty subset), the second company can present any subset of elements from \\{b_1, b_2, …, b_m\} (possibly empty subset). There shouldn't be equal elements in the subsets.

Help the representatives select the sets in such a way that no element is presented in both sets and the total income is the maximum possible.

Input

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

The i-th of the next n lines contains two integers a_i and x_i (1 ≤ a_i ≤ 10^9, 1 ≤ x_i ≤ 10^9) — the index of the i-th element and the income of its usage on the exhibition. It is guaranteed that all a_i are distinct.

The next line contains a single integer m (1 ≤ m ≤ 10^5) — the number of chemicals invented by TopChemist.

The j-th of the next m lines contains two integers b_j and y_j, (1 ≤ b_j ≤ 10^9, 1 ≤ y_j ≤ 10^9) — the index of the j-th element and the income of its usage on the exhibition. It is guaranteed that all b_j are distinct.

Output

Print the maximum total income you can obtain by choosing the sets for both companies in such a way that no element is presented in both sets.

Examples

Input

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

Output

24

Input

1
1000000000 239
3
14 15
92 65
35 89

Output

408

Note

In the first example ChemForces can choose the set (3, 7), while TopChemist can choose (1, 2, 4). This way the total income is (10 + 2) + (4 + 4 + 4) = 24.

In the second example ChemForces can choose the only element 10^9, while TopChemist can choose (14, 92, 35). This way the total income is (239) + (15 + 65 + 89) = 408.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  map<int, int> st;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int a, x;
    scanf("%d%d", &a, &x);
    st[a] = max(st[a], x);
  }
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int a, x;
    scanf("%d%d", &a, &x);
    st[a] = max(st[a], x);
  }
  long long sum = 0;
  for (map<int, int>::iterator it = st.begin(); it != st.end(); ++it)
    sum += it->second;
  printf("%lld\n", sum);
  return 0;
}

```


### Prompt

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

After a successful field test, Heidi is considering deploying a trap along some Corridor, possibly not the first one. She wants to avoid meeting the Daleks inside the Time Vortex, so for abundance of caution she considers placing the traps only along those Corridors that are not going to be used according to the current Daleks' plan – which is to use a minimum spanning tree of Corridors. Heidi knows that all energy requirements for different Corridors are now different, and that the Daleks have a single unique plan which they are intending to use.

Your task is to calculate the number E_{max}(c), which is defined in the same way as in the easy version – i.e., the largest e ≤ 10^9 such that if we changed the energy of corridor c to e, the Daleks might use it – but now for every corridor that Heidi considers.

Input

The first line: number n of destinations, number m of Time Corridors (2 ≤ n ≤ 10^5, n - 1 ≤ m ≤ 10^6). The next m lines: destinations a, b and energy e (1 ≤ a, b ≤ n, a ≠ b, 0 ≤ e ≤ 10^9).

No pair \\{a, b\} will repeat. The graph is guaranteed to be connected. All energy requirements e are distinct.

Output

Output m-(n-1) lines, each containing one integer: E_{max}(c_i) for the i-th Corridor c_i from the input that is not part of the current Daleks' plan (minimum spanning tree).

Example

Input

3 3
1 2 8
2 3 3
3 1 4

Output

4

Note

If m = n-1, then you need not output anything.

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long MOD = 1000000007, LOG = 19;
vector<pair<pair<long long, long long>, pair<long long, long long> > > edges;
long long p[100005], up[100005][LOG], maxi[100005][LOG], in[100005],
    out[100005], idx, ans[1000001];
vector<vector<pair<long long, long long> > > vec;
vector<long long> nt;
long long findSet(long long i) {
  if (p[i] == i) return i;
  return p[i] = findSet(p[i]);
}
bool is_ances(long long a, long long b) {
  return ((in[a] <= in[b]) && (out[a] >= out[b]));
}
void dfs(long long node, long long par, long long w) {
  in[node] = idx++;
  up[node][0] = par, maxi[node][0] = w;
  for (long long i = 1; i < LOG; ++i) up[node][i] = up[up[node][i - 1]][i - 1];
  for (long long i = 1; i < LOG; ++i)
    maxi[node][i] = max(maxi[node][i - 1], maxi[up[node][i - 1]][i - 1]);
  for (auto it : vec[node])
    if (it.second != par) dfs(it.second, node, it.first);
  out[node] = idx++;
}
long long lca(long long a, long long b) {
  if (is_ances(a, b)) return a;
  if (is_ances(b, a)) return b;
  for (long long i = LOG - 1; i >= 0; i--)
    if (!is_ances(up[a][i], b)) a = up[a][i];
  return up[a][0];
}
long long get_max(long long a, long long b) {
  if (a == b) return 0;
  long long ans = 0;
  for (long long i = LOG - 1; i >= 0; i--)
    if (!is_ances(up[a][i], b)) ans = max(ans, maxi[a][i]), a = up[a][i];
  return max(ans, maxi[a][0]);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, a, b, w;
  cin >> n >> m;
  for (long long i = 0; i < n; ++i) p[i] = i;
  edges.resize(m), vec.resize(n);
  for (long long i = 0; i < m; ++i) {
    ans[i] = -1;
    cin >> a >> b >> w;
    a--, b--;
    edges[i] = {pair<long long, long long>(w, i),
                pair<long long, long long>(a, b)};
  }
  sort((edges).begin(), (edges).end());
  for (long long i = 0; i < m; ++i) {
    a = findSet(edges[i].second.first);
    b = findSet(edges[i].second.second);
    if (a == b) {
      nt.push_back(i);
      continue;
    }
    p[a] = b;
    vec[edges[i].second.first].push_back(pair<long long, long long>(
        edges[i].first.first, edges[i].second.second));
    vec[edges[i].second.second].push_back(pair<long long, long long>(
        edges[i].first.first, edges[i].second.first));
  }
  dfs(0, 0, 0);
  for (auto it : nt) {
    a = edges[it].second.first, b = edges[it].second.second;
    long long l = lca(a, b);
    ans[edges[it].first.second] = max(get_max(a, l), get_max(b, l));
  }
  for (long long i = 0; i < m; ++i) {
    if (ans[i] == -1) continue;
    cout << ans[i] << " ";
  }
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Iahub likes trees very much. Recently he discovered an interesting tree named propagating tree. The tree consists of n nodes numbered from 1 to n, each node i having an initial value ai. The root of the tree is node 1.

This tree has a special property: when a value val is added to a value of node i, the value -val is added to values of all the children of node i. Note that when you add value -val to a child of node i, you also add -(-val) to all children of the child of node i and so on. Look an example explanation to understand better how it works.

This tree supports two types of queries:

  * "1 x val" — val is added to the value of node x;
  * "2 x" — print the current value of node x.

In order to help Iahub understand the tree better, you must answer m queries of the preceding type.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 200000). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 1000). Each of the next n–1 lines contains two integers vi and ui (1 ≤ vi, ui ≤ n), meaning that there is an edge between nodes vi and ui.

Each of the next m lines contains a query in the format described above. It is guaranteed that the following constraints hold for all queries: 1 ≤ x ≤ n, 1 ≤ val ≤ 1000.

Output

For each query of type two (print the value of node x) you must print the answer to the query on a separate line. The queries must be answered in the order given in the input.

Examples

Input

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

Output

3
3
0

Note

The values of the nodes are [1, 2, 1, 1, 2] at the beginning.

Then value 3 is added to node 2. It propagates and value -3 is added to it's sons, node 4 and node 5. Then it cannot propagate any more. So the values of the nodes are [1, 5, 1, - 2, - 1].

Then value 2 is added to node 1. It propagates and value -2 is added to it's sons, node 2 and node 3. From node 2 it propagates again, adding value 2 to it's sons, node 4 and node 5. Node 3 has no sons, so it cannot propagate from there. The values of the nodes are [3, 3, - 1, 0, 1].

You can see all the definitions about the tree at the following link: http://en.wikipedia.org/wiki/Tree_(graph_theory)

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> node[210000];
int n, a[210000];
int lid[210000], rid[210000];
bool odd[210000];
int label = 0;
void dfs(int u, int fa, int f = true) {
  lid[u] = rid[u] = ++label;
  odd[u] = f;
  for (int i = 0; i < node[u].size(); i++) {
    if (node[u][i] == fa) continue;
    dfs(node[u][i], u, !f);
    rid[u] = max(rid[u], rid[node[u][i]]);
  }
}
struct Seg {
  int l, r, val, add;
} seg[210000 * 4];
void buildtree(int l, int r, int now = 1) {
  seg[now].l = l;
  seg[now].r = r;
  seg[now].add = seg[now].val = 0;
  if (l == r) return;
  int mid = (l + r) / 2;
  buildtree(l, mid, now * 2);
  buildtree(mid + 1, r, now * 2 + 1);
}
void pushdown(int now) {
  seg[now * 2].add += seg[now].add;
  seg[now * 2 + 1].add += seg[now].add;
  seg[now].add = 0;
}
void update(int l, int r, int val, int now = 1) {
  if (l <= seg[now].l && r >= seg[now].r) {
    seg[now].add += val;
    return;
  }
  pushdown(now);
  int mid = (seg[now].l + seg[now].r) / 2;
  if (l <= mid) update(l, r, val, now * 2);
  if (r > mid) update(l, r, val, now * 2 + 1);
}
int query(int x, int now = 1) {
  if (seg[now].l == seg[now].r) return seg[now].add;
  pushdown(now);
  int mid = (seg[now].l + seg[now].r) / 2;
  if (x <= mid)
    return query(x, now * 2);
  else
    return query(x, now * 2 + 1);
}
int main() {
  int Q;
  scanf("%d%d", &n, &Q);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    node[u].push_back(v);
    node[v].push_back(u);
  }
  dfs(1, 0);
  buildtree(1, n);
  while (Q--) {
    int kind;
    scanf("%d", &kind);
    if (kind == 1) {
      int x, val;
      scanf("%d%d", &x, &val);
      if (odd[x]) val = -val;
      update(lid[x], rid[x], val);
    } else {
      int x;
      scanf("%d", &x);
      int tmp = query(lid[x]);
      if (odd[x]) tmp = -tmp;
      cout << a[x] + tmp << endl;
    }
  }
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the number of unread notifications generated by those applications (maybe Loki put a curse on it so he can't).

q events are about to happen (in chronological order). They are of three types:

  1. Application x generates a notification (this new notification is unread).
  2. Thor reads all notifications generated so far by application x (he may re-read some notifications).
  3. Thor reads the first t notifications generated by phone applications (notifications generated in first t events of the first type). It's guaranteed that there were at least t events of the first type before this event. Please note that he doesn't read first t unread notifications, he just reads the very first t notifications generated on his phone and he may re-read some of them in this operation.

Please help Thor and tell him the number of unread notifications after each event. You may assume that initially there are no notifications in the phone.

Input

The first line of input contains two integers n and q (1 ≤ n, q ≤ 300 000) — the number of applications and the number of events to happen.

The next q lines contain the events. The i-th of these lines starts with an integer typei — type of the i-th event. If typei = 1 or typei = 2 then it is followed by an integer xi. Otherwise it is followed by an integer ti (1 ≤ typei ≤ 3, 1 ≤ xi ≤ n, 1 ≤ ti ≤ q).

Output

Print the number of unread notifications after each event.

Examples

Input

3 4
1 3
1 1
1 2
2 3

Output

1
2
3
2

Input

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

Output

1
2
3
0
1
2

Note

In the first sample:

  1. Application 3 generates a notification (there is 1 unread notification).
  2. Application 1 generates a notification (there are 2 unread notifications).
  3. Application 2 generates a notification (there are 3 unread notifications).
  4. Thor reads the notification generated by application 3, there are 2 unread notifications left.

In the second sample test:

  1. Application 2 generates a notification (there is 1 unread notification).
  2. Application 4 generates a notification (there are 2 unread notifications).
  3. Application 2 generates a notification (there are 3 unread notifications).
  4. Thor reads first three notifications and since there are only three of them so far, there will be no unread notification left.
  5. Application 3 generates a notification (there is 1 unread notification).
  6. Application 3 generates a notification (there are 2 unread notifications).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, qq;
  cin >> n >> qq;
  set<int> app[n + 1];
  int total = 0;
  int t_max = 0;
  queue<pair<int, int>> q;
  for (int i = 0; i < qq; i++) {
    int type;
    cin >> type;
    if (type == 1) {
      int x;
      cin >> x;
      app[x].insert(i);
      total++;
      q.push({i, x});
      cout << total << endl;
    }
    if (type == 2) {
      int x;
      cin >> x;
      total -= app[x].size();
      app[x].clear();
      cout << total << endl;
    }
    if (type == 3) {
      int t;
      cin >> t;
      int temp = t;
      t -= t_max;
      if (t_max < temp) t_max = temp;
      for (int i = 0; i < t; i++) {
        if (q.empty()) break;
        auto u = q.front();
        q.pop();
        int a = u.first;
        int b = u.second;
        if (app[b].find(a) != app[b].end()) {
          total--;
          app[b].erase(a);
        }
      }
      cout << total << endl;
    }
  }
}

```


### Prompt

Create a solution in cpp for the following problem:

N friends of Takahashi has come to a theme park.

To ride the most popular roller coaster in the park, you must be at least K centimeters tall.

The i-th friend is h_i centimeters tall.

How many of the Takahashi's friends can ride the roller coaster?

Constraints

* 1 \le N \le 10^5
* 1 \le K \le 500
* 1 \le h_i \le 500
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
h_1 h_2 \ldots h_N

Output

Print the number of people among the Takahashi's friends who can ride the roller coaster.

Examples

Input

4 150
150 140 100 200

Output

2

Input

1 500
499

Output

0

Input

5 1
100 200 300 400 500

Output

5

### Response

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

int main(){
	int n,k,h,counter;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> h;
		if(h >= k)counter++;
	}
	cout << counter;
}

```


### Prompt

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

There are n beacons located at distinct positions on a number line. The i-th beacon has position ai and power level bi. When the i-th beacon is activated, it destroys all beacons to its left (direction of decreasing coordinates) within distance bi inclusive. The beacon itself is not destroyed however. Saitama will activate the beacons one at a time from right to left. If a beacon is destroyed, it cannot be activated.

Saitama wants Genos to add a beacon strictly to the right of all the existing beacons, with any position and any power level, such that the least possible number of beacons are destroyed. Note that Genos's placement of the beacon means it will be the first beacon activated. Help Genos by finding the minimum number of beacons that could be destroyed.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 100 000) — the initial number of beacons.

The i-th of next n lines contains two integers ai and bi (0 ≤ ai ≤ 1 000 000, 1 ≤ bi ≤ 1 000 000) — the position and power level of the i-th beacon respectively. No two beacons will have the same position, so ai ≠ aj if i ≠ j.

Output

Print a single integer — the minimum number of beacons that could be destroyed if exactly one beacon is added.

Examples

Input

4
1 9
3 1
6 1
7 4

Output

1

Input

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

Output

3

Note

For the first sample case, the minimum number of beacons destroyed is 1. One way to achieve this is to place a beacon at position 9 with power level 2.

For the second sample case, the minimum number of beacons destroyed is 3. One way to achieve this is to place a beacon at position 1337 with power level 42.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
const long long inf = 1e15;
const int mod = 1e6;
void faster() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
const long long N = 3e5 + 10;
int n, m;
string s;
pair<long long, long long> p[N];
long long prefix[N];
int main() {
  faster();
  int n;
  cin >> n;
  prefix[0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p, p + n);
  long long mini = p[0].first;
  long long maxi = prefix[0];
  for (int i = 1; i < n; i++) {
    if (p[i].first - p[i].second >= mini) {
      auto q = lower_bound(p, p + i, make_pair(p[i].first - p[i].second, 0ll));
      q--;
      int ind = q - p;
      prefix[i] = prefix[ind] + 1;
    } else
      prefix[i] = 1;
    maxi = max(maxi, prefix[i]);
  }
  cout << n - maxi << endl;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Kuroni isn't good at economics. So he decided to found a new financial pyramid called Antihype. It has the following rules:

  1. You can join the pyramid for free and get 0 coins.
  2. If you are already a member of Antihype, you can invite your friend who is currently not a member of Antihype, and get a number of coins equal to your age (for each friend you invite).

n people have heard about Antihype recently, the i-th person's age is a_i. Some of them are friends, but friendship is a weird thing now: the i-th person is a friend of the j-th person if and only if a_i  AND  a_j = 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND).

Nobody among the n people is a member of Antihype at the moment. They want to cooperate to join and invite each other to Antihype in a way that maximizes their combined gainings. Could you help them?

Input

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

The second line contains n integers a_1, a_2, ..., a_n (0≤ a_i ≤ 2⋅ 10^5) — the ages of the people.

Output

Output exactly one integer — the maximum possible combined gainings of all n people.

Example

Input

3
1 2 3

Output

2

Note

Only the first and second persons are friends. The second can join Antihype and invite the first one, getting 2 for it.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
int dir[8][2] = {-1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -1, 1, 1 - 1, 1, 1};
template <typename S, typename T>
inline bool Min(S &a, const T &b) {
  return a > b ? a = b, true : false;
}
template <typename S, typename T>
inline bool Max(S &a, const T &b) {
  return a < b ? a = b, true : false;
}
template <typename S, typename T>
inline void Adm(S &a, const T &b) {
  a = (a + b) % MOD;
  if (a < 0) a += MOD;
}
template <typename S, typename T>
inline void Mum(S &a, const T &b) {
  a = 1LL * a * b % MOD;
}
template <typename T>
inline bool IsPri(T x) {
  if (x < 2) return false;
  for (T i = 2; i * i <= x; ++i)
    if (x % i == 0) return false;
  return true;
}
template <typename T>
inline T _Gcd(T a, T b) {
  while (b) {
    T t = b;
    b = a % b;
    a = t;
  }
  return a;
}
template <typename T>
inline int _BitCnt(T x) {
  int cnt = 0;
  while (x) ++cnt, x &= x - 1;
  return cnt;
}
template <typename T>
inline T MDis(T x1, T y1, T x2, T y2) {
  return abs(x1 - x2) + abs(y1 - y2);
}
template <typename T>
inline T MDis(T x1, T y1, T z1, T x2, T y2, T z2) {
  return abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2);
}
inline double EDis(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
inline double EDis(double x1, double y1, double z1, double x2, double y2,
                   double z2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) +
              (z1 - z2) * (z1 - z2));
}
inline long long Pow(long long a, long long n) {
  long long t = 1;
  a %= MOD;
  while (n > 0) {
    if (n & 1) t = t * a % MOD;
    a = a * a % MOD, n >>= 1;
  }
  return t % MOD;
}
inline int read() {
  static char buf[1000000], *p1 = buf, *p2 = buf;
  register int x = false;
  register char ch =
      p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
          ? EOF
          : *p1++;
  ;
  register bool sgn = false;
  while (ch != '-' && (ch < '0' || ch > '9'))
    ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
  ;
  if (ch == '-')
    sgn = true,
    ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
  ;
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ 48),
    ch = p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
  ;
  return sgn ? -x : x;
}
const int N = 1 << 18;
long long ans;
struct Dsu {
  int rt[N], w[N];
  void Init() {
    for (int i = 0; i < N; ++i) rt[i] = i;
  }
  int Find(int x) {
    if (rt[x] != x) rt[x] = Find(rt[x]);
    return rt[x];
  }
  void Merge(int x, int y) {
    int fx = Find(x), fy = Find(y);
    if (fx == fy) return;
    ans += 1LL * (x + y) * (w[fx] + w[fy] - 1);
    rt[fx] = fy, w[fy] = 1;
  }
} d;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    ++d.w[x], ans -= x;
  }
  d.Init();
  ++d.w[0];
  for (int sta = N - 1; sta >= 0; --sta)
    for (int ss = sta; ss; ss = (ss - 1) & sta) {
      int s2 = sta ^ ss;
      if (d.w[ss] && d.w[s2]) d.Merge(ss, s2);
    }
  cout << ans << endl;
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Amr loves Geometry. One day he came up with a very interesting problem.

Amr has a circle of radius r and center in point (x, y). He wants the circle center to be in new position (x', y').

In one step Amr can put a pin to the border of the circle in a certain point, then rotate the circle around that pin by any angle and finally remove the pin.

Help Amr to achieve his goal in minimum number of steps.

Input

Input consists of 5 space-separated integers r, x, y, x' y' (1 ≤ r ≤ 105,  - 105 ≤ x, y, x', y' ≤ 105), circle radius, coordinates of original center of the circle and coordinates of destination center of the circle respectively.

Output

Output a single integer — minimum number of steps required to move the center of the circle to the destination point.

Examples

Input

2 0 0 0 4

Output

1

Input

1 1 1 4 4

Output

3

Input

4 5 6 5 6

Output

0

Note

In the first sample test the optimal way is to put a pin at point (0, 2) and rotate the circle by 180 degrees counter-clockwise (or clockwise, no matter).

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long r, x, y, x_, y_, ans;
int main() {
  scanf("%I64d%I64d%I64d%I64d%I64d", &r, &x, &y, &x_, &y_);
  x = abs(x - x_);
  y = abs(y - y_);
  r *= 2;
  ans = ceil(sqrt(x * x + y * y) / r);
  printf("%I64d", ans);
}

```


### Prompt

Develop a solution in CPP to the problem described below:

A prime number is an integer that is greater than 1 and can only be divided by itself or 1. For example, 2 is a prime number because it is divisible only by 2 and 1, but 12 is not a prime number because it is divisible by 2, 3, 4, 6 in addition to 12 and 1.

When you enter the integer n, write a program that outputs the largest prime number less than n and the smallest prime number greater than n.

Input

Given multiple datasets. Each dataset is given n (3 ≤ n ≤ 50,000) on one row.

The number of datasets does not exceed 50.

Output

For each dataset, output the largest prime number less than n and the smallest prime number greater than n on one line, separated by a space.

Example

Input

19
3517

Output

17 23
3511 3527

### Response

```cpp
#include<iostream>
#include<cmath>
#define NUM 100000
using namespace std;
int p[NUM];

int main(){
	int i,j;
	p[0]=0;//ツ素ツ青板テツーツブツδ仰づーツ催ャツづゥ
	p[1]=0;
	for(i=2;i<NUM;i++)p[i]=1;
	for(i=2;i<sqrt(NUM);i++){
		if(p[i]){
			for(j=i*2;j<NUM;j+=i){
				p[j]=0;//ツ倍ツ青板づーツ渉慊つュ
			}
		}
	}
	/*
	for(i=0;i<NUM;i++)
		if(p[i])cout<<i<<",";
		*/
	int a;
	int min,max;
	while(cin>>a){
		for(i=a-1;i>=0;i--){
			if(p[i]){
				min=i;
				break;
			}
		}
		for(j=a+1;j<=NUM;j++){
			if(p[j]){
				max=j;
				break;
			}
		}
		cout<<min<<" "<<max<<endl;
	}

	return 0;
}
```


### Prompt

Create a solution in CPP for the following problem:

You've got an n × m table (n rows and m columns), each cell of the table contains a "0" or a "1".

Your task is to calculate the number of rectangles with the sides that are parallel to the sides of the table and go along the cell borders, such that the number one occurs exactly k times in the rectangle.

Input

The first line contains three space-separated integers n, m and k (1 ≤ n, m ≤ 2500, 0 ≤ k ≤ 6) — the sizes of the table and the required number of numbers one.

Next n lines each contains m characters "0" or "1". The i-th character of the j-th line corresponds to the character that is in the j-th row and the i-th column of the table.

Output

Print a single number — the number of rectangles that contain exactly k numbers one.

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

Examples

Input

3 3 2
101
000
101

Output

8

Input

5 5 1
00000
00000
00100
00000
00000

Output

81

Input

5 5 6
01010
10101
01010
10101
01010

Output

12

Input

3 3 0
001
010
000

Output

15

Input

4 4 0
0000
0101
0000
0000

Output

52

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 2555;
int N, M, K, dd[SIZE][SIZE];
char s[SIZE];
int get(int x1, int y1, int x2, int y2) {
  x1--;
  y1--;
  return dd[x2][y2] - dd[x2][y1] - dd[x1][y2] + dd[x1][y1];
}
long long an;
void divide(int x1, int y1, int x2, int y2) {
  if (x1 == x2 && y1 == y2) {
    if (get(x1, y1, x2, y2) == K) an++;
    return;
  }
  int ty = 1;
  if (x2 - x1 > y2 - y1) ty = 0;
  if (ty == 0) {
    int mm = (x1 + x2) >> 1;
    for (int i = y1; i <= y2; i++) {
      int cnt[2][7] = {};
      for (int j = y2; j >= i; j--) {
        for (int k = 0; k <= K; k++)
          while (cnt[0][k] <= mm - x1 && get(mm - cnt[0][k], i, mm, j) <= k)
            cnt[0][k]++;
        for (int k = 0; k <= K; k++)
          while (cnt[1][k] < x2 - mm &&
                 get(mm + 1, i, mm + cnt[1][k] + 1, j) <= k)
            cnt[1][k]++;
        for (int k = 0; k <= K; k++)
          an += (cnt[0][k] - (k ? cnt[0][k - 1] : 0)) *
                (cnt[1][K - k] - (K - k ? cnt[1][K - k - 1] : 0));
      }
    }
    divide(x1, y1, mm, y2);
    divide(mm + 1, y1, x2, y2);
  } else {
    int mm = (y1 + y2) >> 1;
    for (int i = x1; i <= x2; i++) {
      int cnt[2][7] = {};
      for (int j = x2; j >= i; j--) {
        for (int k = 0; k <= K; k++)
          while (cnt[0][k] <= mm - y1 && get(i, mm - cnt[0][k], j, mm) <= k)
            cnt[0][k]++;
        for (int k = 0; k <= K; k++)
          while (cnt[1][k] < y2 - mm &&
                 get(i, mm + 1, j, mm + cnt[1][k] + 1) <= k)
            cnt[1][k]++;
        for (int k = 0; k <= K; k++)
          an += (cnt[0][k] - (k ? cnt[0][k - 1] : 0)) *
                (cnt[1][K - k] - (K - k ? cnt[1][K - k - 1] : 0));
      }
    }
    divide(x1, y1, x2, mm);
    divide(x1, mm + 1, x2, y2);
  }
}
int main() {
  scanf("%d%d%d", &(N), &(M), &(K));
  for (int i = 1; i <= N; i++) {
    scanf("%s", (s + 1));
    for (int j = 1; j <= M; j++)
      dd[i][j] = dd[i][j - 1] + dd[i - 1][j] - dd[i - 1][j - 1] + s[j] - '0';
  }
  divide(1, 1, N, M);
  cout << an << endl;
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

While Vasya finished eating his piece of pizza, the lesson has already started. For being late for the lesson, the teacher suggested Vasya to solve one interesting problem. Vasya has an array a and integer x. He should find the number of different ordered pairs of indexes (i, j) such that ai ≤ aj and there are exactly k integers y such that ai ≤ y ≤ aj and y is divisible by x.

In this problem it is meant that pair (i, j) is equal to (j, i) only if i is equal to j. For example pair (1, 2) is not the same as (2, 1).

Input

The first line contains 3 integers n, x, k (1 ≤ n ≤ 105, 1 ≤ x ≤ 109, 0 ≤ k ≤ 109), where n is the size of the array a and x and k are numbers from the statement.

The second line contains n integers ai (1 ≤ ai ≤ 109) — the elements of the array a.

Output

Print one integer — the answer to the problem.

Examples

Input

4 2 1
1 3 5 7

Output

3

Input

4 2 0
5 3 1 7

Output

4

Input

5 3 1
3 3 3 3 3

Output

25

Note

In first sample there are only three suitable pairs of indexes — (1, 2), (2, 3), (3, 4).

In second sample there are four suitable pairs of indexes(1, 1), (2, 2), (3, 3), (4, 4).

In third sample every pair (i, j) is suitable, so the answer is 5 * 5 = 25.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void printvec(vector<T>& vec) {
  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i] << " ";
  }
  cout << endl;
}
map<long long int, vector<long long int> > mymap;
int main() {
  ios_base::sync_with_stdio(false);
  long long int n, x, k;
  cin >> n >> x >> k;
  vector<long long int> inp;
  long long int tot = 0;
  long long int num = 0;
  for (int i = 0; i < n; i++) {
    long long int a;
    cin >> a;
    inp.push_back(a);
  }
  sort(inp.begin(), inp.end());
  for (int i = 0; i < n; i++) {
    long long int a = inp[i];
    long long int y = a / x;
    mymap[y - k + 1].push_back(a);
  }
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    long long int b = inp[i];
    long long int a = (long long int)(ceil(b / (double)x));
    if (mymap.find(a) == mymap.end()) {
      ans += 0;
    } else {
      vector<long long int>::iterator itlow;
      itlow = lower_bound(mymap[a].begin(), mymap[a].end(), b);
      long long int p = itlow - mymap[a].begin();
      long long int q = mymap[a].size() - 1;
      ans += (q - p + 1);
    }
  }
  cout << ans << "\n";
}

```


### Prompt

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

Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special.

Alyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set of some subsequent elements of the array. The i-th subarray is described with two integers li and ri, and its elements are a[li], a[li + 1], ..., a[ri].

Alyona is going to find mex for each of the chosen subarrays. Among these m mexes the girl is going to find the smallest. She wants this minimum mex to be as large as possible.

You are to find an array a of n elements so that the minimum mex among those chosen by Alyona subarrays is as large as possible.

The mex of a set S is a minimum possible non-negative integer that is not in S.

Input

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

The next m lines contain information about the subarrays chosen by Alyona. The i-th of these lines contains two integers li and ri (1 ≤ li ≤ ri ≤ n), that describe the subarray a[li], a[li + 1], ..., a[ri].

Output

In the first line print single integer — the maximum possible minimum mex.

In the second line print n integers — the array a. All the elements in a should be between 0 and 109.

It is guaranteed that there is an optimal answer in which all the elements in a are between 0 and 109.

If there are multiple solutions, print any of them.

Examples

Input

5 3
1 3
2 5
4 5

Output

2
1 0 2 1 0

Input

4 2
1 4
2 4

Output

3
5 2 0 1

Note

The first example: the mex of the subarray (1, 3) is equal to 3, the mex of the subarray (2, 5) is equal to 3, the mex of the subarray (4, 5) is equal to 2 as well, thus the minumal mex among the subarrays chosen by Alyona is equal to 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, ans, a, b;
  scanf("%d%d", &n, &m);
  ans = n;
  while (m--) {
    scanf("%d%d", &a, &b);
    ans = min(ans, b - a + 1);
  }
  printf("%d\n", ans);
  for (i = n; i >= 1; i--) printf("%d ", i % ans);
  printf("\n");
  return 0;
}

```


### Prompt

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

A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).

Your task is to find out if a given integer is a triangular number.

Input

The first line contains the single number n (1 ≤ n ≤ 500) — the given integer.

Output

If the given integer is a triangular number output YES, otherwise output NO.

Examples

Input

1

Output

YES

Input

2

Output

NO

Input

3

Output

YES

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int sum = 0;
  bool ok = false;
  for (int i = 1; i <= n; i++) {
    sum = i + sum;
    if (n == 1 || n == sum) {
      cout << "YES" << endl;
      break;
    }
    if (sum > n) {
      ok = true;
      break;
    }
  }
  if (ok) cout << "NO" << endl;
  return 0;
}

```


### Prompt

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

Polycarp has recently got himself a new job. He now earns so much that his old wallet can't even store all the money he has.

Berland bills somehow come in lots of different sizes. However, all of them are shaped as rectangles (possibly squares). All wallets are also produced in form of rectangles (possibly squares).

A bill x × y fits into some wallet h × w if either x ≤ h and y ≤ w or y ≤ h and x ≤ w. Bills can overlap with each other in a wallet and an infinite amount of bills can fit into a wallet. That implies that all the bills Polycarp currently have fit into a wallet if every single one of them fits into it independently of the others.

Now you are asked to perform the queries of two types:

  1. +~x~y — Polycarp earns a bill of size x × y;
  2. ?~h~w — Polycarp wants to check if all the bills he has earned to this moment fit into a wallet of size h × w.

It is guaranteed that there is at least one query of type 1 before the first query of type 2 and that there is at least one query of type 2 in the input data.

For each query of type 2 print "YES" if all the bills he has earned to this moment fit into a wallet of given size. Print "NO" otherwise.

Input

The first line contains a single integer n (2 ≤ n ≤ 5 ⋅ 10^5) — the number of queries.

Each of the next n lines contains a query of one of these two types:

  1. +~x~y (1 ≤ x, y ≤ 10^9) — Polycarp earns a bill of size x × y;
  2. ?~h~w (1 ≤ h, w ≤ 10^9) — Polycarp wants to check if all the bills he has earned to this moment fit into a wallet of size h × w.

It is guaranteed that there is at least one query of type 1 before the first query of type 2 and that there is at least one query of type 2 in the input data.

Output

For each query of type 2 print "YES" if all the bills he has earned to this moment fit into a wallet of given size. Print "NO" otherwise.

Example

Input

9
+ 3 2
+ 2 3
? 1 20
? 3 3
? 2 3
+ 1 5
? 10 10
? 1 5
+ 1 1

Output

NO
YES
YES
YES
NO

Note

The queries of type 2 of the example:

  1. Neither bill fits;
  2. Both bills fit (just checking that you got that bills can overlap);
  3. Both bills fit (both bills are actually the same);
  4. All bills fit (too much of free space in a wallet is not a problem);
  5. Only bill 1 × 5 fit (all the others don't, thus it's "NO").

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int Q;
  cin >> Q;
  int mx1 = 0, mx2 = 0;
  while (Q--) {
    char op;
    int a, b;
    cin >> op >> a >> b;
    if (a > b) swap(a, b);
    if (op == '+') {
      mx1 = max(mx1, a);
      mx2 = max(mx2, b);
    } else {
      if (mx1 <= a && mx2 <= b) {
        cout << "YES\n";
      } else {
        cout << "NO\n";
      }
    }
  }
}

```


### Prompt

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

In the Jambo Amusement Garden (JAG), you sell colorful drinks consisting of multiple color layers. This colorful drink can be made by pouring multiple colored liquids of different density from the bottom in order.

You have already prepared several colored liquids with various colors and densities. You will receive a drink request with specified color layers. The colorful drink that you will serve must satisfy the following conditions.

* You cannot use a mixed colored liquid as a layer. Thus, for instance, you cannot create a new liquid with a new color by mixing two or more different colored liquids, nor create a liquid with a density between two or more liquids with the same color by mixing them.
* Only a colored liquid with strictly less density can be an upper layer of a denser colored liquid in a drink. That is, you can put a layer of a colored liquid with density $x$ directly above the layer of a colored liquid with density $y$ if $x < y$ holds.

Your task is to create a program to determine whether a given request can be fulfilled with the prepared colored liquids under the above conditions or not.

Input

The input consists of a single test case in the format below.

$N$
$C_1$ $D_1$
$\vdots$
$C_N$ $D_N$
$M$
$O_1$
$\vdots$
$O_M$

The first line consists of an integer $N$ ($1 \leq N \leq 10^5$), which represents the number of the prepared colored liquids. The following $N$ lines consists of $C_i$ and $D_i$ ($1 \leq i \leq N$). $C_i$ is a string consisting of lowercase alphabets and denotes the color of the $i$-th prepared colored liquid. The length of $C_i$ is between $1$ and $20$ inclusive. $D_i$ is an integer and represents the density of the $i$-th prepared colored liquid. The value of $D_i$ is between $1$ and $10^5$ inclusive. The ($N+2$)-nd line consists of an integer $M$ ($1 \leq M \leq 10^5$), which represents the number of color layers of a drink request. The following $M$ lines consists of $O_i$ ($1 \leq i \leq M$). $O_i$ is a string consisting of lowercase alphabets and denotes the color of the $i$-th layer from the top of the drink request. The length of $O_i$ is between $1$ and $20$ inclusive.

Output

If the requested colorful drink can be served by using some of the prepared colored liquids, print 'Yes'. Otherwise, print 'No'.

Examples

Input

2
white 20
black 10
2
black
white

Output

Yes

Input

2
white 10
black 10
2
black
white

Output

No

Input

2
white 20
black 10
2
black
orange

Output

No

Input

3
white 10
red 20
white 30
3
white
red
white

Output

Yes

Input

4
red 3444
red 3018
red 3098
red 3319
4
red
red
red
red

Output

Yes

### Response

```cpp
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<set<string>> v(100010);
    for (int i = 0; i < n; ++i) {
        string c; int d;
        cin >> c >> d;
        v[d-1].insert(c);
    }
    int cur = 0;
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        string s;
        cin >> s;
        while(cur < 100005 && !v[cur].count(s)) cur++;
        if(cur == 100005) {
            puts("No");
            return 0;
        }
        cur++;
    }
    puts("Yes");
    return 0;
}

```


### Prompt

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

Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.

To compress the string, you have to represent s as a concatenation of several non-empty strings: s = t_{1} t_{2} … t_{k}. The i-th of these strings should be encoded with one of the two ways:

  * if |t_{i}| = 1, meaning that the current string consists of a single character, you can encode it paying a coins;
  * if t_{i} is a substring of t_{1} t_{2} … t_{i - 1}, then you can encode it paying b coins.

A string x is a substring of a string y if x can be obtained from y by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.

So your task is to calculate the minimum possible number of coins you need to spend in order to compress the given string s.

Input

The first line contains three positive integers, separated by spaces: n, a and b (1 ≤ n, a, b ≤ 5000) — the length of the string, the cost to compress a one-character string and the cost to compress a string that appeared before.

The second line contains a single string s, consisting of n lowercase English letters.

Output

Output a single integer — the smallest possible number of coins you need to spend to compress s.

Examples

Input

3 3 1
aba

Output

7

Input

4 1 1
abcd

Output

4

Input

4 10 1
aaaa

Output

12

Note

In the first sample case, you can set t_{1} = 'a', t_{2} = 'b', t_{3} = 'a' and pay 3 + 3 + 1 = 7 coins, since t_{3} is a substring of t_{1}t_{2}.

In the second sample, you just need to compress every character by itself.

In the third sample, you set t_{1} = t_{2} = 'a', t_{3} = 'aa' and pay 10 + 1 + 1 = 12 coins, since t_{2} is a substring of t_{1} and t_{3} is a substring of t_{1} t_{2}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, m;
int ok[N];
int dp[5005][5005];
int main() {
  ios::sync_with_stdio(false);
  int n, a, b;
  cin >> n >> a >> b;
  string str;
  cin >> str;
  str = " " + str;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (str[i] == str[j]) dp[i][j] = dp[i - 1][j - 1] + 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    ok[i] = ok[i - 1] + a;
    int mxx = 0;
    for (int j = 1; j < i; j++) {
      mxx = max(mxx, dp[i][j]);
      if (mxx >= (i - j)) ok[i] = min(ok[i], ok[j] + b);
    }
  }
  cout << ok[n];
  return 0;
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly greater he throws it away and continues with the next one.

The juicer has a special section to collect waste. It overflows if Kolya squeezes oranges of the total size strictly greater than d. When it happens Kolya empties the waste section (even if there are no more oranges) and continues to squeeze the juice. How many times will he have to empty the waste section?

Input

The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 1 000 000) — sizes of the oranges listed in the order Kolya is going to try to put them in the juicer.

Output

Print one integer — the number of times Kolya will have to empty the waste section.

Examples

Input

2 7 10
5 6

Output

1

Input

1 5 10
7

Output

0

Input

3 10 10
5 7 7

Output

1

Input

1 1 1
1

Output

0

Note

In the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.

In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, b, d, size = 0, c = 0;
  cin >> n >> b >> d;
  for (int i = 0; i < n; i++) {
    long long int val;
    cin >> val;
    if (val <= b) {
      size = size + val;
    }
    if (size > d) {
      c++;
      size = 0;
    }
  }
  cout << c;
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

Snuke has an integer sequence A of length N.

He will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E. The positions of the cuts can be freely chosen.

Let P,Q,R,S be the sums of the elements in B,C,D,E, respectively. Snuke is happier when the absolute difference of the maximum and the minimum among P,Q,R,S is smaller. Find the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.

Constraints

* 4 \leq N \leq 2 \times 10^5
* 1 \leq A_i \leq 10^9
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Find the minimum possible absolute difference of the maximum and the minimum among P,Q,R,S.

Examples

Input

5
3 2 4 1 2

Output

2

Input

10
10 71 84 33 6 47 23 25 52 64

Output

36

Input

7
1 2 3 1000000000 4 5 6

Output

999999994

### Response

```cpp
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a, lt=1, md, rt=3, ans=1e18, s[200005];
ll f(ll p, ll q, ll r, ll s) {
	ll mx = max(max(p,q), max(r,s));
	ll mn = min(min(p,q), min(r,s));
	return mx-mn;
}

int main() {
	cin>>n;
	for (ll i=1; i<=n; i++) scanf("%lld", &a), s[i] = s[i-1] + a;
	for (md=2; md<=n-2; md++) {
		while (abs(s[md] - 2*s[lt+1]) < abs(s[md] - 2*s[lt])) lt++;
		while (abs(s[n] - 2*s[rt+1] + s[md]) < abs(s[n] - 2*s[rt] + s[md])) rt++;
		ans = min(ans, f(s[lt], s[md]-s[lt], s[rt]-s[md], s[n]-s[rt]));
	}
	cout<<ans;
	return 0;
}
```


### Prompt

Please formulate a Cpp solution to the following problem:

Sereja has m non-empty sets of integers A1, A2, ..., Am. What a lucky coincidence! The given sets are a partition of the set of all integers from 1 to n. In other words, for any integer v (1 ≤ v ≤ n) there is exactly one set At such that <image>. Also Sereja has integer d.

Sereja decided to choose some sets from the sets he has. Let's suppose that i1, i2, ..., ik (1 ≤ i1 < i2 < ... < ik ≤ m) are indexes of the chosen sets. Then let's define an array of integers b, sorted in ascending order, as a union of the chosen sets, that is, <image>. We'll represent the element with number j in this array (in ascending order) as bj. Sereja considers his choice of sets correct, if the following conditions are met:

b1 ≤ d; bi + 1 - bi ≤ d (1 ≤ i < |b|); n - d + 1 ≤ b|b|.

Sereja wants to know what is the minimum number of sets (k) that he can choose so that his choice will be correct. Help him with that.

Input

The first line contains integers n, m, d (1 ≤ d ≤ n ≤ 105, 1 ≤ m ≤ 20). The next m lines contain sets. The first number in the i-th line is si (1 ≤ si ≤ n). This number denotes the size of the i-th set. Then the line contains si distinct integers from 1 to n — set Ai.

It is guaranteed that the sets form partition of all integers from 1 to n.

Output

In a single line print the answer to the problem — the minimum value k at the right choice.

Examples

Input

3 2 2
1 2
2 1 3

Output

1

Input

5 1 1
5 4 5 3 2 1

Output

1

Input

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

Output

3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int M(22), N(100010);
int n, m, d, ans;
int st[M][N];
bool no[1 << M];
int getSt(int l, int r) {
  int t = (int)(log10(r - l + 1) / log10(2));
  return st[t][l] | st[t][r - (1 << t) + 1];
}
int bitCnt(int x) { return x ? bitCnt(x / 2) + x % 2 : 0; }
int main() {
  cin >> n >> m >> d;
  for (int i = 0; i < m; ++i) {
    int t, x;
    for (cin >> t; t; --t) {
      cin >> x;
      st[0][x] = 1 << i;
    }
  }
  for (int i = 1; i != M; ++i)
    for (int j = 1; j + (1 << i) - 1 <= n; ++j)
      st[i][j] = st[i - 1][j] | st[i - 1][j + (1 << (i - 1))];
  for (int i = 1; i + d - 1 <= n; ++i) no[getSt(i, i + d - 1)] = 1;
  int ans = m;
  for (int i = 0; i != (1 << m); ++i) {
    for (int j = 0; j != m; ++j)
      if (i & (1 << j)) no[i] |= no[i - (1 << j)];
    if (!no[i]) ans = min(ans, bitCnt(((1 << m) - 1) ^ i));
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

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

Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue (Leonard) buys a can, drinks it and gets to the end of the queue as two Leonards, and so on. This process continues ad infinitum.

For example, Penny drinks the third can of cola and the queue will look like this: Rajesh, Howard, Sheldon, Sheldon, Leonard, Leonard, Penny, Penny.

Write a program that will print the name of a man who will drink the n-th can.

Note that in the very beginning the queue looks like that: Sheldon, Leonard, Penny, Rajesh, Howard. The first person is Sheldon.

Input

The input data consist of a single integer n (1 ≤ n ≤ 109).

It is guaranteed that the pretests check the spelling of all the five names, that is, that they contain all the five possible answers.

Output

Print the single line — the name of the person who drinks the n-th can of cola. The cans are numbered starting from 1. Please note that you should spell the names like this: "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" (without the quotes). In that order precisely the friends are in the queue initially.

Examples

Input

1

Output

Sheldon

Input

6

Output

Sheldon

Input

1802

Output

Penny

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, prevN = 0, currN = 5, nums = 0;
  double who = 0.0;
  cin >> n;
  while (currN < n) {
    nums++;
    prevN = currN;
    currN += 5 * int(pow(2.0, nums));
  }
  who = (n - prevN) / pow(2.0, nums);
  if (who <= 1.0) {
    cout << "Sheldon";
  } else if (who <= 2.0) {
    cout << "Leonard";
  } else if (who <= 3.0) {
    cout << "Penny";
  } else if (who <= 4.0) {
    cout << "Rajesh";
  } else {
    cout << "Howard";
  }
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.

The calendar is so beautiful that she wants to know what is the next year after y when the calendar will be exactly the same. Help Taylor to find that year.

Note that leap years has 366 days. The year is leap if it is divisible by 400 or it is divisible by 4, but not by 100 (<https://en.wikipedia.org/wiki/Leap_year>).

Input

The only line contains integer y (1000 ≤ y < 100'000) — the year of the calendar.

Output

Print the only integer y' — the next year after y when the calendar will be the same. Note that you should find the first year after y with the same calendar.

Examples

Input

2016

Output

2044

Input

2000

Output

2028

Input

50501

Output

50507

Note

Today is Monday, the 13th of June, 2016.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool isLeap(int y) {
  if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0))
    return true;
  else
    return false;
}
int add(int y) {
  if (isLeap(y))
    return 366 % 7;
  else
    return 365 % 7;
}
int main() {
  int y, Add = 0, y_aux;
  scanf("%d", &y);
  y_aux = y;
  do {
    y_aux++;
    Add += add(y_aux);
  } while (Add % 7 != 0 || (isLeap(y_aux) != isLeap(y)));
  printf("%d\n", y_aux);
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Olya loves energy drinks. She loves them so much that her room is full of empty cans from energy drinks.

Formally, her room can be represented as a field of n × m cells, each cell of which is empty or littered with cans.

Olya drank a lot of energy drink, so now she can run k meters per second. Each second she chooses one of the four directions (up, down, left or right) and runs from 1 to k meters in this direction. Of course, she can only run through empty cells.

Now Olya needs to get from cell (x1, y1) to cell (x2, y2). How many seconds will it take her if she moves optimally?

It's guaranteed that cells (x1, y1) and (x2, y2) are empty. These cells can coincide.

Input

The first line contains three integers n, m and k (1 ≤ n, m, k ≤ 1000) — the sizes of the room and Olya's speed.

Then n lines follow containing m characters each, the i-th of them contains on j-th position "#", if the cell (i, j) is littered with cans, and "." otherwise.

The last line contains four integers x1, y1, x2, y2 (1 ≤ x1, x2 ≤ n, 1 ≤ y1, y2 ≤ m) — the coordinates of the first and the last cells.

Output

Print a single integer — the minimum time it will take Olya to get from (x1, y1) to (x2, y2).

If it's impossible to get from (x1, y1) to (x2, y2), print -1.

Examples

Input

3 4 4
....
###.
....
1 1 3 1

Output

3

Input

3 4 1
....
###.
....
1 1 3 1

Output

8

Input

2 2 1
.#
#.
1 1 2 2

Output

-1

Note

In the first sample Olya should run 3 meters to the right in the first second, 2 meters down in the second second and 3 meters to the left in the third second.

In second sample Olya should run to the right for 3 seconds, then down for 2 seconds and then to the left for 3 seconds.

Olya does not recommend drinking energy drinks and generally believes that this is bad.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int han[4] = {0, 0, 1, -1}, lie[4] = {1, -1, 0, 0};
int n, m, number[1010][1010], k;
int step[1010][1010];
int stx, sty, lenx, leny;
void bfs() {
  queue<pair<int, int> > str;
  str.push(make_pair(stx, sty));
  memset(step, -1, sizeof(step));
  step[stx][sty] = 0;
  while (str.size()) {
    pair<int, int> now = str.front();
    str.pop();
    for (int a = 0; a < 4; a++) {
      for (int b = 1; b <= k; b++) {
        int han1 = now.first + han[a] * b;
        int lie1 = now.second + lie[a] * b;
        if (han1 <= 0 || lie1 <= 0 || han1 > n || lie1 > m) break;
        if (number[han1][lie1] == 1) break;
        if ((step[han1][lie1] != -1) &&
            (step[han1][lie1] < step[now.first][now.second] + 1))
          break;
        if (step[han1][lie1] == -1) {
          step[han1][lie1] = step[now.first][now.second] + 1;
          if (han1 == lenx && lie1 == leny) {
            cout << step[han1][lie1] << endl;
            return;
          }
          str.push(make_pair(han1, lie1));
        }
      }
    }
  }
  cout << "-1" << endl;
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m >> k;
  char c;
  for (int a = 1; a <= n; a++)
    for (int b = 1; b <= m; b++) {
      cin >> c;
      if (c == '.')
        number[a][b] = 0;
      else
        number[a][b] = 1;
    }
  cin >> stx >> sty >> lenx >> leny;
  if (stx == lenx && sty == leny) {
    cout << "0" << endl;
    return 0;
  }
  bfs();
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

For given n points in metric space, find the distance of the closest points.

Constraints

* 2 ≤ n ≤ 100,000
* -100 ≤ x, y ≤ 100

Input

n
x0 y0
x1 y1
:
xn-1 yn-1

The first integer n is the number of points.

In the following n lines, the coordinate of the i-th point is given by two real numbers xi and yi. Each value is a real number with at most 6 digits after the decimal point.

Output

Print the distance in a line. The output values should be in a decimal fraction with an error less than 0.000001.

Examples

Input

2
0.0 0.0
1.0 0.0

Output

1.000000

Input

3
0.0 0.0
2.0 0.0
1.0 1.0

Output

1.41421356237

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

/* 基本要素 */
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> VP;
const double PI = acos(-1);
const double EPS = 1e-9; // 許容誤差^2
const double INF = 1e9;
#define X real()
#define Y imag()
#define LE(n,m) ((n) - (m) < EPS)
#define GE(n,m) (EPS > (m) - (n))
#define EQ(n,m) (abs((n)-(m)) < EPS)

bool compX(const Point a, const Point b) {
  return (a.X!=b.X ? a.X<b.X : a.Y<b.Y);
}

bool compY(const Point a, const Point b) {
  return (a.Y!=b.Y ? a.Y<b.Y : a.X<b.X);
}

double closestPair(VP& a,int l,int r) {
  if(r-l<=1) return INF;
  int m = (l+r)/2;
  double x = a[m].X;
  double d = min(closestPair(a,l,m),closestPair(a,m,r));
  inplace_merge(a.begin()+l, a.begin()+m, a.begin()+r, compY);
  VP b;
  for(int i=l;i<r;i++){
    if(abs(a[i].X - x)>=d)continue;
    for(int j=b.size()-1;j>=0;j--){
      if((a[i]-b[j]).Y>=d)break;
      d = min(d,abs(a[i]-b[j]));
    }
    b.push_back(a[i]);
  }
  return d;
}

double closestPair(VP ps){
  sort(ps.begin(),ps.end(),compX);
  return closestPair(ps,0,ps.size());
}

int main(){
    int n;
    cin >>n;

    VP p(n);
    rep(i,n){
        double x,y;
        cin >>x >>y;
        p[i] = Point(x,y);
    }

    printf("%.10f\n", closestPair(p));
    return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

As a German University in Cairo (GUC) student and a basketball player, Herr Wafa was delighted once he heard the news. GUC is finally participating in the Annual Basketball Competition (ABC).

A team is to be formed of n players, all of which are GUC students. However, the team might have players belonging to different departments. There are m departments in GUC, numbered from 1 to m. Herr Wafa's department has number h. For each department i, Herr Wafa knows number si — how many students who play basketball belong to this department.

Herr Wafa was also able to guarantee a spot on the team, using his special powers. But since he hates floating-point numbers, he needs your help at finding the probability that he will have at least one teammate belonging to his department.

Note that every possible team containing Herr Wafa is equally probable. Consider all the students different from each other.

Input

The first line contains three integers n, m and h (1 ≤ n ≤ 100, 1 ≤ m ≤ 1000, 1 ≤ h ≤ m) — the number of players on the team, the number of departments in GUC and Herr Wafa's department, correspondingly.

The second line contains a single-space-separated list of m integers si (1 ≤ si ≤ 100), denoting the number of students in the i-th department. Note that sh includes Herr Wafa.

Output

Print the probability that Herr Wafa will have at least one teammate from his department. If there is not enough basketball players in GUC to participate in ABC, print -1. The answer will be accepted if it has absolute or relative error not exceeding 10 - 6.

Examples

Input

3 2 1
2 1

Output

1

Input

3 2 1
1 1

Output

-1

Input

3 2 1
2 2

Output

0.666667

Note

In the first example all 3 players (2 from department 1 and 1 from department 2) must be chosen for the team. Both players from Wafa's departments will be chosen, so he's guaranteed to have a teammate from his department.

In the second example, there are not enough players.

In the third example, there are three possibilities to compose the team containing Herr Wafa. In two of them the other player from Herr Wafa's department is part of the team.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double E = exp(1);
template <class T1>
void deb(T1 e) {
  cout << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
template <typename T>
inline T sqr(T n) {
  return n * n;
}
inline double hypot(double x, double y) { return sqrt(sqr(x) + sqr(y)); }
template <typename T>
inline T pmod(T n, T m) {
  return ((n % m) + m) % m;
}
template <typename T>
T power(T n, int p) {
  return (p == 0) ? (T)(1) : (sqr(power(n, p >> 1)) * ((p & 1) * (n - 1) + 1));
}
template <typename T>
T bigmod(T n, int p, T m) {
  return (p == 0)
             ? (T)(1)
             : ((sqr(bigmod(n, p >> 1, m)) % m) * ((p & 1) * (n - 1) % m + 1)) %
                   m;
}
double comb[105][105];
int h, ara[1005];
int p, m;
double NcR(int n, int r) {
  if (r < 0) return 0;
  double ret = 1.0;
  int up = n;
  int down = 1;
  for (int i = 1; i <= r; i++) {
    ret *= up;
    ret /= down;
    down++;
    up--;
  }
  return ret;
}
int main() {
  while (scanf("%d %d %d", &p, &m, &h) == 3) {
    int sum = 0;
    for (int i = 1; i <= m; ++i) {
      scanf("%d", &ara[i]);
      if (i != h) sum += ara[i];
    }
    p--;
    ara[h]--;
    if (sum + ara[h] < p) {
      printf("-1\n");
      continue;
    }
    double A = 0.0;
    double B = NcR(sum, p);
    for (int i = 1; i <= ara[h]; i++) {
      A += (NcR(ara[h], i) * NcR(sum, p - i));
    }
    printf("%.10lf\n", A / (A + B));
  }
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long as possible but he doesn't remember exactly the heights of all trees in the forest. He is sure that he remembers correct heights of all trees except, possibly, one of them.

It is known that the forest consists of n trees staying in a row numbered from left to right with integers from 1 to n. According to Vasya, the height of the i-th tree is equal to hi. The zip-line of length k should hang over k (1 ≤ k ≤ n) trees i1, i2, ..., ik (i1 < i2 < ... < ik) such that their heights form an increasing sequence, that is hi1 < hi2 < ... < hik.

Petya had been in this forest together with Vasya, and he now has q assumptions about the mistake in Vasya's sequence h. His i-th assumption consists of two integers ai and bi indicating that, according to Petya, the height of the tree numbered ai is actually equal to bi. Note that Petya's assumptions are independent from each other.

Your task is to find the maximum length of a zip-line that can be built over the trees under each of the q assumptions.

In this problem the length of a zip line is considered equal to the number of trees that form this zip-line.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 400 000) — the number of the trees in the forest and the number of Petya's assumptions, respectively.

The following line contains n integers hi (1 ≤ hi ≤ 109) — the heights of trees according to Vasya.

Each of the following m lines contains two integers ai and bi (1 ≤ ai ≤ n, 1 ≤ bi ≤ 109).

Output

For each of the Petya's assumptions output one integer, indicating the maximum length of a zip-line that can be built under this assumption.

Examples

Input

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

Output

4
3
3
4

Input

4 2
1 3 2 6
3 5
2 4

Output

4
3

Note

Consider the first sample. The first assumption actually coincides with the height remembered by Vasya. In the second assumption the heights of the trees are (4, 2, 3, 4), in the third one they are (1, 2, 3, 3) and in the fourth one they are (1, 2, 3, 5).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
const long double eps = 1e-11;
const long double pi = acos(-1);
const int oo = 1 << 30;
const long long loo = 1ll << 62;
const int mods = 998244353;
const int MAXN = 400005;
const int INF = 0x3f3f3f3f;
inline int read() {
  int f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
int a[MAXN], g[MAXN], L[MAXN], R[MAXN], rtl[MAXN], rtr[MAXN], wh[MAXN],
    cnt[MAXN];
struct Segment_Tree {
  int ls[MAXN * 20], rs[MAXN * 20], mn[MAXN * 20], nodenum = 0;
  int update(int x, int l, int r, int y, int z) {
    int p = ++nodenum;
    ls[p] = ls[x], rs[p] = rs[x], mn[p] = INF;
    if (l == r) {
      mn[p] = z;
      return p;
    }
    int mid = (l + r) >> 1;
    if (y <= mid)
      ls[p] = update(ls[x], l, mid, y, z);
    else
      rs[p] = update(rs[x], mid + 1, r, y, z);
    if (ls[p]) upmin(mn[p], mn[ls[p]]);
    if (rs[p]) upmin(mn[p], mn[rs[p]]);
    return p;
  }
  int query(int x, int l, int r, int y) {
    if (l == r) return l;
    int mid = (l + r) >> 1;
    if (rs[x] && mn[rs[x]] < y) return query(rs[x], mid + 1, r, y);
    if (ls[x] && mn[ls[x]] < y) return query(ls[x], l, mid, y);
    return 0;
  }
} segl, segr;
signed main() {
  int n = read(), m = read(), ans = 0;
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) g[i] = INF;
  for (int i = 1; i <= n; i++)
    L[i] = lower_bound(g, g + n, a[i]) - g, upmin(g[L[i]], a[i]),
    upmax(ans, L[i]);
  for (int i = 1; i <= n; i++) g[i] = 0;
  g[0] = -INF;
  for (int i = n; i >= 1; i--)
    R[i] = lower_bound(g, g + n, -a[i]) - g, upmin(g[R[i]], -a[i]);
  for (int i = 1; i <= n; i++)
    if (L[i] + R[i] - 1 == ans) wh[i] = L[i], cnt[L[i]]++;
  for (int i = 1; i <= n; i++)
    rtl[i] = segl.update(rtl[i - 1], 1, n, L[i], a[i]);
  for (int i = n; i >= 1; i--)
    rtr[i] = segr.update(rtr[i + 1], 1, n, R[i], -a[i]);
  while (m--) {
    int x = read(), y = read(), t = 0;
    if (x > 1) t += segl.query(rtl[x - 1], 1, n, y);
    if (x < n) t += segr.query(rtr[x + 1], 1, n, -y);
    printf("%d\n", max(t + 1, (wh[x] > 0 && cnt[L[x]] == 1) ? ans - 1 : ans));
  }
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Author has gone out of the stories about Vasiliy, so here is just a formal task description.

You are given q queries and a multiset A, initially containing only integer 0. There are three types of queries:

  1. "+ x" — add integer x to multiset A.
  2. "- x" — erase one occurrence of integer x from multiset A. It's guaranteed that at least one x is present in the multiset A before this query.
  3. "? x" — you are given integer x and need to compute the value <image>, i.e. the maximum value of bitwise exclusive OR (also know as XOR) of integer x and some integer y from the multiset A.

Multiset is a set, where equal elements are allowed.

Input

The first line of the input contains a single integer q (1 ≤ q ≤ 200 000) — the number of queries Vasiliy has to perform.

Each of the following q lines of the input contains one of three characters '+', '-' or '?' and an integer xi (1 ≤ xi ≤ 109). It's guaranteed that there is at least one query of the third type.

Note, that the integer 0 will always be present in the set A.

Output

For each query of the type '?' print one integer — the maximum value of bitwise exclusive OR (XOR) of integer xi and some integer from the multiset A.

Example

Input

10
+ 8
+ 9
+ 11
+ 6
+ 1
? 3
- 8
? 3
? 8
? 11

Output

11
10
14
13

Note

After first five operations multiset A contains integers 0, 8, 9, 11, 6 and 1.

The answer for the sixth query is integer <image> — maximum among integers <image>, <image>, <image>, <image> and <image>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 2e18;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); }
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
void debug() { cout << "DEBUG" << endl; }
int exp(int a, int b) {
  int result = 1;
  while (b > 0) {
    if (b & 1) result = result * a;
    b >>= 1;
    a = a * a;
  }
  return result;
}
int exp(int a, int b, int m) {
  int result = 1;
  while (b > 0) {
    if (b & 1) result = result * a % m;
    b >>= 1;
    a = a * a % m;
  }
  return result % m;
}
struct trie {
  struct node {
    vector<int> children;
    bool end;
    node() {
      children.assign(2, -1);
      end = false;
    }
  };
  vector<node> root;
  trie() {
    node x;
    root.push_back(x);
  }
  void insert(int x) {
    int v = 0;
    for (int i = 30; i >= 0; i--) {
      int bit = x >> i & 1;
      if (root[v].children[bit] == -1) {
        root[v].children[bit] = root.size();
        root.push_back(node());
      }
      v = root[v].children[bit];
    }
    root[v].end = true;
  }
  int calc(int x) {
    int v = 0;
    int ans = 0;
    for (int i = 30; i >= 0; i--) {
      int bit = !(x >> i & 1);
      if (root[v].children[bit] == -1) {
        bit = !bit;
        v = root[v].children[bit];
      } else {
        ans += 1 << i;
        v = root[v].children[bit];
      }
    }
    return ans;
  }
  int cnt(node &x) {
    int ans = 0;
    for (int &i : x.children) {
      ans += (i != -1);
    }
    return ans;
  }
  bool del(int x, int index = 30, int v = 0) {
    if (index == -1) {
      if (!root[v].end) return false;
      root[v].end = false;
      return cnt(root[v]) == 0;
    }
    int bit = x >> index & 1;
    if (root[v].children[bit] == -1) return false;
    bool ans = del(x, index - 1, root[v].children[bit]);
    if (ans) {
      root[v].children[bit] = -1;
      return cnt(root[v]) == 0;
    }
    return false;
  }
  void consertar() {
    while (cnt(root.back()) == 0 and !root.back().end) {
      root.pop_back();
    }
  }
};
trie tr;
void solve() {
  tr.insert(0ll);
  int q;
  cin >> q;
  map<int, int> m;
  m[0] = 1;
  while (q--) {
    char c;
    cin >> c;
    int x;
    cin >> x;
    if (c == '+') {
      if (m[x] == 0) tr.insert(x);
      m[x]++;
    } else if (c == '-') {
      m[x]--;
      if (m[x] == 0) tr.del(x);
    } else {
      cout << tr.calc(x) << endl;
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
}

```


### Prompt

Please formulate a CPP solution to the following problem:

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

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

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

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

Input

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

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

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

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

Output

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

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

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

Example

Input

2
1
00
11
01
3
011001
111010
010001

Output

010
011001010

Note

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

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

### Response

```cpp
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#include <bits/stdc++.h>

using namespace std;

#define endl "\n"
#define int long long

const int N = 1e3 + 5;
int n;
string s[3];

int count(string s, char ch){
    int tot = 0;
    for(int i = 0;i < s.size();++i){
        tot += s[i] == ch;
    }
    return tot;
}

string givecommon(string a, string b){
    int zeros = 0, ones = 0;
    zeros = min(count(a, '0'), count(b, '0'));
    ones = min(count(a, '1'), count(b, '1'));

    string s1 = "";

    if(zeros >= n){
        for(int i = 0;i < zeros;++i) s1 += '0';
    }
    else if(ones >= n){
        for(int i = 0;i < ones;++i) s1 += '1';
    }
    else s1 = "";

    return s1;
}

void solve(){
    cin >> n >> s[0] >> s[1] >> s[2];

    for(int i = 0;i < 3;++i){
        string s1 = givecommon(s[i], s[(i + 1) % 3]);
        if(s1.size() >= n){
            string ans = "";
            int ind1 = 0, ind2 = 0;
            for(int j = 0;j < s1.size();++j){
                while(ind1 < 2 * n and s[i][ind1] != s1[j]){
                    ans += s[i][ind1];
                    ind1++;
                }
                while(ind2 < 2 * n and s[(i + 1) % 3][ind2] != s1[j]){
                    ans += s[(i + 1) % 3][ind2];
                    ind2++;
                }
                ans += s1[j];
                ind1++;
                ind2++;
            }
            while(ind1 < 2 * n){
                ans += s[i][ind1];
                ind1++;
            }
            while(ind2 < 2 * n){
                ans += s[(i + 1) % 3][ind2];
                ind2++;
            }
            cout << ans << endl;
            return;
        }
    }

}

signed main(){
    ios :: sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t = 1;
    cin >> t;
    while(t--){
        solve();

    }

}
```


### Prompt

Generate a CPP solution to the following problem:

Nauuo is a girl who loves writing comments.

One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.

It's known that there were x persons who would upvote, y persons who would downvote, and there were also another z persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the x+y+z people would vote exactly one time.

There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".

Because of the z unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the z persons vote, that the results are different in the two situations.

Tell Nauuo the result or report that the result is uncertain.

Input

The only line contains three integers x, y, z (0≤ x,y,z≤100), corresponding to the number of persons who would upvote, downvote or unknown.

Output

If there is only one possible result, print the result : "+", "-" or "0".

Otherwise, print "?" to report that the result is uncertain.

Examples

Input

3 7 0

Output

-

Input

2 0 1

Output

+

Input

1 1 0

Output

0

Input

0 0 1

Output

?

Note

In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".

In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".

In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".

In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, z;
  cin >> x >> y >> z;
  if (x == y) {
    if (z > 0)
      cout << "?" << endl;
    else
      cout << 0 << endl;
  } else if (x > y) {
    int s = y + z;
    if (s >= x)
      cout << "?" << endl;
    else
      cout << "+" << endl;
  } else {
    int s = x + z;
    if (s >= y)
      cout << "?" << endl;
    else
      cout << "-" << endl;
  }
  return 0;
}

```