### Prompt

Generate a CPP solution to the following problem:

Little Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A.

You are given three segments on the plane. They form the letter A if the following conditions hold:

  * Two segments have common endpoint (lets call these segments first and second), while the third segment connects two points on the different segments.
  * The angle between the first and the second segments is greater than 0 and do not exceed 90 degrees.
  * The third segment divides each of the first two segments in proportion not less than 1 / 4 (i.e. the ratio of the length of the shortest part to the length of the longest part is not less than 1 / 4).

Input

The first line contains one integer t (1 ≤ t ≤ 10000) — the number of test cases to solve. Each case consists of three lines. Each of these three lines contains four space-separated integers — coordinates of the endpoints of one of the segments. All coordinates do not exceed 108 by absolute value. All segments have positive length.

Output

Output one line for each test case. Print «YES» (without quotes), if the segments form the letter A and «NO» otherwise.

Examples

Input

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

Output

YES
NO
YES

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long LINF = ~(((long long)0x1) << 63) / 2;
template <class T>
bool get_max(T& a, T& b) {
  return b > a ? a = b, 1 : 0;
}
template <class T>
bool get_min(T& a, T& b) {
  return b < a ? a = b, 1 : 0;
}
int sgn(double d) { return d > 1e-10 ? 1 : (d < -1e-10 ? -1 : 0); }
inline double sqr(double x) { return x * x; }
int dbcmp(double x, double y) { return sgn(x - y); }
struct point {
  double x, y;
  point(){};
  point(double _x, double _y) {
    x = _x;
    y = _y;
  }
  void input() { scanf("%lf%lf", &x, &y); }
  void output() { printf("%lf %lf", &x, &y); }
  double norm() const { return sqrt(sqr(x) + sqr(y)); }
  double len() { return sqrt(len2()); }
  double len2() { return x * x + y * y; }
  double dis(const point& p) {
    return sqrt((p.x - x) * (p.x - x) + (p.y - y) * (p.y - y));
  }
  point trunc(double l) {
    if (sgn(len()) == 0) return *this;
    double r = l / len();
    return point(x * r, y * r);
  }
  point rotate_left() const { return point(-y, x); }
  point rotate_left(double ang) const {
    double c = cos(ang), s = sin(ang);
    return point(x * c - y * s, y * c + x * s);
  }
  point rotate_right() const { return point(y, -x); }
  point rotate_right(double ang) const {
    double c = cos(ang), s = sin(ang);
    return point(x * c + y * s, y * c - x * s);
  }
  point rotate(point p, double angle) {
    point v = *this - p;
    double c = cos(angle), s = sin(angle);
    return point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);
  }
  point unify() { return *this / len(); }
  point operator+(const point& p) { return point(x + p.x, y + p.y); }
  point operator-(const point& p) { return point(x - p.x, y - p.y); }
  point operator*(double r) { return point(x * r, y * r); }
  point operator/(double r) { return point(x / r, y / r); }
  point operator=(const point& p) {
    x = p.x;
    y = p.y;
    return *this;
  }
  bool operator==(const point& p) {
    return sgn(x - p.x) == 0 && sgn(y - p.y) == 0;
  }
  bool operator!=(const point& p) { return !(*this == p); }
  bool operator<(const point& p) {
    return sgn(x - p.x) == 0 ? sgn(y - p.y) < 0 : x < p.x;
  }
  bool operator>(const point& p) {
    return sgn(x - p.x) == 0 ? sgn(y - p.y) > 0 : x > p.x;
  }
  double operator*(point b) { return (x * b.y - y * b.x); }
};
struct line {
  point a, b;
  line() {}
  line(point _a, point _b) {
    a = _a;
    b = _b;
  }
  line operator=(const line& l) {
    a = l.a;
    b = l.b;
    return *this;
  }
  line swap() {
    std::swap(a, b);
    return *this;
  }
};
double dot(point p, point q) { return p.x * q.x + p.y * q.y; }
double xmult(point p1, point p2) { return p1.x * p2.y - p1.y * p2.x; }
double len(point p) { return p.x * p.x + p.y * p.y; }
bool is_online(point p, line l) {
  if (xmult(p - l.a, l.b - l.a) == 0) {
    if (p.x >= min(l.a.x, l.b.x) && p.x <= max(l.a.x, l.b.x) &&
        p.y >= min(l.a.y, l.b.y) && p.y <= max(l.a.y, l.b.y))
      return true;
    else
      return false;
  }
  return false;
}
line l1, l2, l3;
bool check(line l1, line l2, line l3) {
  double re = dot(l1.b - l1.a, l2.b - l2.a);
  if (xmult(l1.b - l1.a, l2.b - l2.a) == 0 || re < 0) return false;
  if (is_online(l3.a, l1) && is_online(l3.b, l2)) {
    double len1 = len(l1.a - l3.a);
    double len2 = len(l1.b - l3.a);
    double mmin = min(len1, len2);
    double mmax = max(len1, len2);
    if (16.0 * mmin - mmax >= 0) {
      len1 = len(l2.a - l3.b);
      len2 = len(l2.b - l3.b);
      mmin = min(len1, len2);
      mmax = max(len1, len2);
      if (16 * mmin - mmax >= 0)
        return true;
      else
        return false;
    } else
      return false;
  } else if (is_online(l3.b, l1) && is_online(l3.a, l2)) {
    double len1 = len(l1.a - l3.b);
    double len2 = len(l1.b - l3.b);
    double mmin = min(len1, len2);
    double mmax = max(len1, len2);
    if (16.0 * mmin - mmax >= 0) {
      len1 = len(l2.a - l3.a);
      len2 = len(l2.b - l3.a);
      mmin = min(len1, len2);
      mmax = max(len1, len2);
      if (16 * mmin - mmax >= 0)
        return true;
      else
        return false;
    } else
      return false;
  } else {
    return false;
  }
}
void solve() {
  int ok1 = 0;
  if (l1.a == l2.a) {
    ok1 = check(l1, l2, l3);
  }
  if (l1.a == l2.b) {
    ok1 = ok1 + check(l1, l2.swap(), l3);
    l2.swap();
  }
  if (l1.b == l2.a) {
    ok1 = ok1 + check(l1.swap(), l2, l3);
    l1.swap();
  }
  if (l1.b == l2.b) {
    ok1 = ok1 + check(l1.swap(), l2.swap(), l3);
    l1.swap();
    l2.swap();
  }
  if (l1.a == l3.a) {
    ok1 = ok1 + check(l1, l3, l2);
  }
  if (l1.a == l3.b) {
    ok1 = ok1 + check(l1, l3.swap(), l2);
    l3.swap();
  }
  if (l1.b == l3.a) {
    ok1 = ok1 + check(l1.swap(), l3, l2);
    l1.swap();
  }
  if (l1.b == l3.b) {
    ok1 = ok1 + check(l1.swap(), l3.swap(), l2);
    l1.swap();
    l3.swap();
  }
  if (l2.a == l3.a) {
    ok1 = ok1 + check(l2, l3, l1);
  }
  if (l2.a == l3.b) {
    ok1 = ok1 + check(l2, l3.swap(), l1);
    l3.swap();
  }
  if (l2.b == l3.a) {
    ok1 = ok1 + check(l2.swap(), l3, l1);
    l2.swap();
  }
  if (l2.b == l3.b) {
    ok1 = ok1 + check(l2.swap(), l3.swap(), l1);
    l2.swap();
    l3.swap();
  }
  if (ok1 > 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    cin >> l1.a.x >> l1.a.y >> l1.b.x >> l1.b.y;
    cin >> l2.a.x >> l2.a.y >> l2.b.x >> l2.b.y;
    cin >> l3.a.x >> l3.a.y >> l3.b.x >> l3.b.y;
    solve();
  }
  return 0;
}

```


### Prompt

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

You are given an undirected graph with n vertices. There are no edge-simple cycles with the even length in it. In other words, there are no cycles of even length that pass each edge at most once. Let's enumerate vertices from 1 to n.

You have to answer q queries. Each query is described by a segment of vertices [l; r], and you have to count the number of its subsegments [x; y] (l ≤ x ≤ y ≤ r), such that if we delete all vertices except the segment of vertices [x; y] (including x and y) and edges between them, the resulting graph is bipartite.

Input

The first line contains two integers n and m (1 ≤ n ≤ 3·105, 1 ≤ m ≤ 3·105) — the number of vertices and the number of edges in the graph.

The next m lines describe edges in the graph. The i-th of these lines contains two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi), denoting an edge between vertices ai and bi. It is guaranteed that this graph does not contain edge-simple cycles of even length.

The next line contains a single integer q (1 ≤ q ≤ 3·105) — the number of queries.

The next q lines contain queries. The i-th of these lines contains two integers li and ri (1 ≤ li ≤ ri ≤ n) — the query parameters.

Output

Print q numbers, each in new line: the i-th of them should be the number of subsegments [x; y] (li ≤ x ≤ y ≤ ri), such that the graph that only includes vertices from segment [x; y] and edges between them is bipartite.

Examples

Input

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

Output

5
5
14

Input

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

Output

27
8
19

Note

The first example is shown on the picture below:

<image>

For the first query, all subsegments of [1; 3], except this segment itself, are suitable.

For the first query, all subsegments of [4; 6], except this segment itself, are suitable.

For the third query, all subsegments of [1; 6] are suitable, except [1; 3], [1; 4], [1; 5], [1; 6], [2; 6], [3; 6], [4; 6].

The second example is shown on the picture below:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, q, mx[300005];
long long acu[300005];
vector<vector<int> > adj;
int maxi, mini, p[300005];
void ciclo(int u, int v) {
  if (v == u) return;
  maxi = max(u, maxi);
  mini = min(u, mini);
  ciclo(p[u], v);
}
vector<int> vis;
void dfs(int u) {
  vis[u] = 1;
  for (int v : adj[u]) {
    if (vis[v]) {
      if (vis[v] == 1 && v != p[u]) {
        maxi = mini = v;
        ciclo(u, v);
        mx[mini] = min(mx[mini], maxi - 1);
      }
    } else {
      p[v] = u;
      dfs(v);
    }
  }
  vis[u] = 2;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  adj = vector<vector<int> >(n + 1);
  while (m--) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vis = vector<int>(n + 1);
  fill(mx, mx + n + 1, n);
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      p[i] = i;
      dfs(i);
    }
  }
  for (int i = n - 1; i; i--) mx[i] = min(mx[i], mx[i + 1]);
  acu[0] = 0;
  for (int i = 1; i <= n; i++) acu[i] = acu[i - 1] + mx[i] - i + 1;
  cin >> q;
  while (q--) {
    cin >> a >> b;
    long long x = lower_bound(mx + 1, mx + n + 1, b) - mx;
    if (x < a) {
      x = b - a + 1;
      cout << x * (x + 1) / 2 << '\n';
    } else {
      long long d = b - x + 1;
      cout << d * (d + 1) / 2 + acu[x - 1] - acu[a - 1] << '\n';
    }
  }
  return 0;
}

```


### Prompt

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

Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem.

A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit.

More formally, if a game designer selected cells having coordinates (x1, y1) and (x2, y2), where x1 ≤ x2 and y1 ≤ y2, then all cells having center coordinates (x, y) such that x1 ≤ x ≤ x2 and y1 ≤ y ≤ y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2 - x1 is divisible by 2.

Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map.

Help him implement counting of these units before painting.

<image>

Input

The only line of input contains four integers x1, y1, x2, y2 ( - 109 ≤ x1 ≤ x2 ≤ 109, - 109 ≤ y1 ≤ y2 ≤ 109) — the coordinates of the centers of two cells.

Output

Output one integer — the number of cells to be filled.

Examples

Input

1 1 5 5

Output

13

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  long long int a = ((x2 + 1) - (x1 - 1)) / 2;
  long long int b = ((y2 + 1) - (y1 - 1)) / 2;
  long long int out = a * b + (a - 1) * (b - 1);
  cout << out;
  return 0;
}

```


### Prompt

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

You are given two arrays of integers a_1,…,a_n and b_1,…,b_m.

Your task is to find a non-empty array c_1,…,c_k that is a subsequence of a_1,…,a_n, and also a subsequence of b_1,…,b_m. If there are multiple answers, find one of the smallest possible length. If there are still multiple of the smallest possible length, find any. If there are no such arrays, you should report about it.

A sequence a is a subsequence of a sequence b if a can be obtained from b by deletion of several (possibly, zero) elements. For example, [3,1] is a subsequence of [3,2,1] and [4,3,1], but not a subsequence of [1,3,3,7] and [3,10,4].

Input

The first line contains a single integer t (1≤ t≤ 1000) — the number of test cases. Next 3t lines contain descriptions of test cases.

The first line of each test case contains two integers n and m (1≤ n,m≤ 1000) — the lengths of the two arrays.

The second line of each test case contains n integers a_1,…,a_n (1≤ a_i≤ 1000) — the elements of the first array.

The third line of each test case contains m integers b_1,…,b_m (1≤ b_i≤ 1000) — the elements of the second array.

It is guaranteed that the sum of n and the sum of m across all test cases does not exceed 1000 (∑_{i=1}^t n_i, ∑_{i=1}^t m_i≤ 1000).

Output

For each test case, output "YES" if a solution exists, or "NO" otherwise.

If the answer is "YES", on the next line output an integer k (1≤ k≤ 1000) — the length of the array, followed by k integers c_1,…,c_k (1≤ c_i≤ 1000) — the elements of the array.

If there are multiple solutions with the smallest possible k, output any.

Example

Input

5
4 5
10 8 6 4
1 2 3 4 5
1 1
3
3
1 1
3
2
5 3
1000 2 2 2 3
3 1 5
5 5
1 2 3 4 5
1 2 3 4 5

Output

YES
1 4
YES
1 3
NO
YES
1 3
YES
1 2

Note

In the first test case, [4] is a subsequence of [10, 8, 6, 4] and [1, 2, 3, 4, 5]. This array has length 1, it is the smallest possible length of a subsequence of both a and b.

In the third test case, no non-empty subsequences of both [3] and [2] exist, so the answer is "NO".

### Response

```cpp
#include <bits/stdc++.h>
const long long infl = 1e18;
const int infi = 2e9;
const int mod = 1e9 + 7;
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    long long ans;
    long long a[100000];
    long long b[100000];
    long long count = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
      cin >> b[i];
    }
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        if (a[i] == b[j]) {
          count++;
          ans = a[i];
          break;
        }
      }
    if (count) {
      cout << "YES"
           << "\n";
      cout << 1 << " " << ans << "\n";
    } else {
      cout << "NO"
           << "\n";
    }
  }
}

```


### Prompt

Please create a solution in Cpp to the following problem:

There are literally dozens of snooker competitions held each year, and team Jinotega tries to attend them all (for some reason they prefer name "snookah")! When a competition takes place somewhere far from their hometown, Ivan, Artsem and Konstantin take a flight to the contest and back.

Jinotega's best friends, team Base have found a list of their itinerary receipts with information about departure and arrival airports. Now they wonder, where is Jinotega now: at home or at some competition far away? They know that:

  * this list contains all Jinotega's flights in this year (in arbitrary order),
  * Jinotega has only flown from his hometown to a snooker contest and back,
  * after each competition Jinotega flies back home (though they may attend a competition in one place several times),
  * and finally, at the beginning of the year Jinotega was at home.

Please help them to determine Jinotega's location!

Input

In the first line of input there is a single integer n: the number of Jinotega's flights (1 ≤ n ≤ 100). In the second line there is a string of 3 capital Latin letters: the name of Jinotega's home airport. In the next n lines there is flight information, one flight per line, in form "XXX->YYY", where "XXX" is the name of departure airport "YYY" is the name of arrival airport. Exactly one of these airports is Jinotega's home airport.

It is guaranteed that flights information is consistent with the knowledge of Jinotega's friends, which is described in the main part of the statement.

Output

If Jinotega is now at home, print "home" (without quotes), otherwise print "contest".

Examples

Input

4
SVO
SVO->CDG
LHR->SVO
SVO->LHR
CDG->SVO

Output

home

Input

3
SVO
SVO->HKT
HKT->SVO
SVO->RAP

Output

contest

Note

In the first sample Jinotega might first fly from SVO to CDG and back, and then from SVO to LHR and back, so now they should be at home. In the second sample Jinotega must now be at RAP because a flight from RAP back to SVO is not on the list.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long n;
int main() {
  cin >> n;
  if (n % 2 == 0)
    cout << "home";
  else
    cout << "contest";
}

```


### Prompt

Generate a Cpp solution to the following problem:

You are given four integers: H, W, h and w (1 ≤ h ≤ H, 1 ≤ w ≤ W). Determine whether there exists a matrix such that all of the following conditions are held, and construct one such matrix if the answer is positive:

* The matrix has H rows and W columns.
* Each element of the matrix is an integer between -10^9 and 10^9 (inclusive).
* The sum of all the elements of the matrix is positive.
* The sum of all the elements within every subrectangle with h rows and w columns in the matrix is negative.

Constraints

* 1 ≤ h ≤ H ≤ 500
* 1 ≤ w ≤ W ≤ 500

Input

Input is given from Standard Input in the following format:

H W h w

Output

If there does not exist a matrix that satisfies all of the conditions, print `No`.

Otherwise, print `Yes` in the first line, and print a matrix in the subsequent lines in the following format:

a_{11} ... a_{1W}
:
a_{H1} ... a_{HW}

Here, a_{ij} represents the (i,\ j) element of the matrix.

Examples

Input

3 3 2 2

Output

Yes
1 1 1
1 -4 1
1 1 1

Input

2 4 1 2

Output

No

Input

3 4 2 3

Output

Yes
2 -5 8 7
3 -5 -4 -5
2 1 -1 7

### Response

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int H, W, h, w;
   cin >> H >> W >> h >> w;
   if (H % h == 0 && W % w == 0) {
      cout << "No\n";
      return 0;
   }
   cout << "Yes\n";
   for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
         if (i % h == h - 1 && j % w == w - 1) {
            cout << -1007 * (h * w - 1) - 1 << " ";
         } else {
            cout << 1007 << " ";
         }
      }
      cout << "\n";
   }
}

```


### Prompt

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

Stepan has a very big positive integer.

Let's consider all cyclic shifts of Stepan's integer (if we look at his integer like at a string) which are also integers (i.e. they do not have leading zeros). Let's call such shifts as good shifts. For example, for the integer 10203 the good shifts are the integer itself 10203 and integers 20310 and 31020.

Stepan wants to know the minimum remainder of the division by the given number m among all good shifts. Your task is to determine the minimum remainder of the division by m.

Input

The first line contains the integer which Stepan has. The length of Stepan's integer is between 2 and 200 000 digits, inclusive. It is guaranteed that Stepan's integer does not contain leading zeros.

The second line contains the integer m (2 ≤ m ≤ 108) — the number by which Stepan divides good shifts of his integer.

Output

Print the minimum remainder which Stepan can get if he divides all good shifts of his integer by the given number m.

Examples

Input

521
3

Output

2

Input

1001
5

Output

0

Input

5678901234567890123456789
10000

Output

123

Note

In the first example all good shifts of the integer 521 (good shifts are equal to 521, 215 and 152) has same remainder 2 when dividing by 3.

In the second example there are only two good shifts: the Stepan's integer itself and the shift by one position to the right. The integer itself is 1001 and the remainder after dividing it by 5 equals 1. The shift by one position to the right equals to 1100 and the remainder after dividing it by 5 equals 0, which is the minimum possible remainder.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = .2e6 + 5;
long long pw[N], hs[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  s = '_' + s;
  int m;
  cin >> m;
  pw[0] = 1;
  for (int i = 1; i <= n; i++) {
    hs[i] = (hs[i - 1] * 10 + (s[i] - '0')) % m;
    pw[i] = (pw[i - 1] * 10) % m;
  }
  long long ans = m;
  for (int i = 1; i <= n; i++) {
    if (s[i] == '0') continue;
    long long val1 = hs[i - 1];
    long long val2 = (hs[n] - hs[i - 1] * pw[n - i + 1]) % m;
    if (val2 < 0) val2 += m;
    long long cnt = (val2 * pw[i - 1] + val1) % m;
    ans = min(ans, cnt);
  }
  cout << ans << "\n";
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and just count the quantity of beautiful numbers in given ranges.

Input

The first line of the input contains the number of cases t (1 ≤ t ≤ 10). Each of the next t lines contains two natural numbers li and ri (1 ≤ li ≤ ri ≤ 9 ·1018).

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d).

Output

Output should contain t numbers — answers to the queries, one number per line — quantities of beautiful numbers in given intervals (from li to ri, inclusively).

Examples

Input

1
1 9

Output

9

Input

1
12 15

Output

2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long d[25][50][2550];
int a[50];
int hh[2550];
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long dfs(int len, int pl, int px, bool l) {
  if (len == -1) return px % pl == 0;
  if (!l && d[len][hh[pl]][px] != -1) return d[len][hh[pl]][px];
  int n = l ? a[len] : 9;
  long long sum = 0;
  for (int i = 0; i <= n; i++) {
    int nowpx = (px * 10 + i) % 2520;
    int nowpl = pl;
    if (i) nowpl = lcm(pl, i);
    sum += dfs(len - 1, nowpl, nowpx, l && i == n);
  }
  if (!l) d[len][hh[pl]][px] = sum;
  return sum;
}
long long CC(long long x) {
  int n = 0;
  while (x) {
    a[n++] = x % 10;
    x /= 10;
  }
  return dfs(n - 1, 1, 0, 1);
}
int main() {
  int u = 0;
  for (int i = 1; i <= 2520; i++) {
    if (2520 % i == 0) hh[i] = ++u;
  }
  int T;
  while (~scanf("%d", &T)) {
    memset(d, -1, sizeof(d));
    while (T--) {
      long long a, b;
      scanf("%I64d%I64d", &a, &b);
      printf("%I64d\n", CC(b) - CC(a - 1));
    }
  }
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:

  * a12 + a22 + ... + an2 ≥ x
  * a1 + a2 + ... + an ≤ y

Input

The first line contains three space-separated integers n, x and y (1 ≤ n ≤ 105, 1 ≤ x ≤ 1012, 1 ≤ y ≤ 106).

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

Output

Print n positive integers that satisfy the conditions, one integer per line. If such numbers do not exist, print a single number "-1". If there are several solutions, print any of them.

Examples

Input

5 15 15

Output

4
4
1
1
2

Input

2 3 2

Output

-1

Input

1 99 11

Output

11

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, x, y;
  cin >> n >> x >> y;
  if (y < n || (n - 1) + (y - n + 1) * (y - n + 1) < x) {
    cout << -1;
  } else {
    for (int i = 1; i < n; i++) cout << 1 << endl;
    cout << y - n + 1;
  }
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Let's call an array a of size n coprime iff gcd(a1, a2, ..., an) = 1, where gcd is the greatest common divisor of the arguments.

You are given two numbers n and k. For each i (1 ≤ i ≤ k) you have to determine the number of coprime arrays a of size n such that for every j (1 ≤ j ≤ n) 1 ≤ aj ≤ i. Since the answers can be very large, you have to calculate them modulo 109 + 7.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 2·106) — the size of the desired arrays and the maximum upper bound on elements, respectively.

Output

Since printing 2·106 numbers may take a lot of time, you have to output the answer in such a way:

Let bi be the number of coprime arrays with elements in range [1, i], taken modulo 109 + 7. You have to print <image>, taken modulo 109 + 7. Here <image> denotes bitwise xor operation (^ in C++ or Java, xor in Pascal).

Examples

Input

3 4

Output

82

Input

2000000 8

Output

339310063

Note

Explanation of the example:

Since the number of coprime arrays is large, we will list the arrays that are non-coprime, but contain only elements in range [1, i]:

For i = 1, the only array is coprime. b1 = 1.

For i = 2, array [2, 2, 2] is not coprime. b2 = 7.

For i = 3, arrays [2, 2, 2] and [3, 3, 3] are not coprime. b3 = 25.

For i = 4, arrays [2, 2, 2], [3, 3, 3], [2, 2, 4], [2, 4, 2], [2, 4, 4], [4, 2, 2], [4, 2, 4], [4, 4, 2] and [4, 4, 4] are not coprime. b4 = 55.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << "(" << p.first << "," << p.second << ")";
  return o;
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}
const ll mod = 1e9 + 7;
ll mod_pow(ll x, ll n) {
  ll ret = 1;
  while (n) {
    if (n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
const int N = 2000002;
ll pw[N];
bool p[N];
int mu[N];
ll f[N];
vector<int> upd[N];
int main() {
  int n, k;
  cin >> n >> k;
  fill(p, p + N, true);
  fill(mu, mu + N, 1);
  p[0] = p[1] = false;
  for (int i = 2; i < N; ++i)
    if (p[i]) {
      mu[i] = -1;
      for (int j = 2 * i; j < N; j += i) {
        p[j] = false;
        mu[j] = -mu[j];
      }
      if ((ll)i * i < N) {
        for (int j = i * i; j < N; j += i * i) mu[j] = false;
      }
    }
  for (int(i) = 0; (i) < (int)(N); ++(i)) pw[i] = mod_pow(i, n);
  for (int i = 1; i <= k; ++i)
    if (mu[i] != 0) {
      for (int j = i; j <= k; j += i) upd[j].push_back(i);
    }
  ll ans = 0;
  ll now = 0;
  for (int i = 1; i <= k; ++i) {
    for (int j : upd[i]) {
      now -= f[j];
      now += mod;
      f[j] = mu[j] * pw[i / j];
      now += f[j];
      now += mod;
      now %= mod;
    }
    ans += now ^ i;
    ans %= mod;
  }
  cout << ans << "\n";
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Arkady is playing Battleship. The rules of this game aren't really important.

There is a field of n × n cells. There should be exactly one k-decker on the field, i. e. a ship that is k cells long oriented either horizontally or vertically. However, Arkady doesn't know where it is located. For each cell Arkady knows if it is definitely empty or can contain a part of the ship.

Consider all possible locations of the ship. Find such a cell that belongs to the maximum possible number of different locations of the ship.

Input

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 100) — the size of the field and the size of the ship.

The next n lines contain the field. Each line contains n characters, each of which is either '#' (denotes a definitely empty cell) or '.' (denotes a cell that can belong to the ship).

Output

Output two integers — the row and the column of a cell that belongs to the maximum possible number of different locations of the ship.

If there are multiple answers, output any of them. In particular, if no ship can be placed on the field, you can output any cell.

Examples

Input

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

Output

3 2

Input

10 4
#....##...
.#...#....
..#..#..#.
...#.#....
.#..##.#..
.....#...#
...#.##...
.#...#.#..
.....#..#.
...#.#...#

Output

6 1

Input

19 6
##..............###
#......#####.....##
.....#########.....
....###########....
...#############...
..###############..
.#################.
.#################.
.#################.
.#################.
#####....##....####
####............###
####............###
#####...####...####
.#####..####..#####
...###........###..
....###########....
.........##........
#.................#

Output

1 8

Note

The picture below shows the three possible locations of the ship that contain the cell (3, 2) in the first sample.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct data {
  int i, j, val;
};
int main() {
  data mx = {0, 0, 0};
  int n, k, last, i, j, a, b, c, x, y;
  scanf("%d %d", &n, &k);
  char ara[n][n];
  int ans[n][n];
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      ans[i][j] = 0;
    }
  }
  for (i = 0; i < n; i++) {
    scanf("%s", ara[i]);
  }
  for (i = 0; i < n; i++) {
    last = -1;
    for (j = 0; j < n; j++) {
      if (ara[i][j] == '#') {
        for (a = last + 1; j - a >= k; a++) {
          for (b = a, c = 0; c < k; c++, b++) {
            ans[i][b]++;
          }
        }
        last = j;
      }
    }
    for (a = last + 1; n - a >= k; a++) {
      for (b = a, c = 0; c < k; c++, b++) {
        ans[i][b]++;
      }
    }
  }
  for (i = 0; i < n; i++) {
    last = -1;
    for (j = 0; j < n; j++) {
      if (ara[j][i] == '#') {
        for (a = last + 1; j - a >= k; a++) {
          for (b = a, c = 0; c < k; c++, b++) {
            ans[b][i]++;
          }
        }
        last = j;
      }
    }
    for (a = last + 1; n - a >= k; a++) {
      for (b = a, c = 0; c < k; c++, b++) {
        ans[b][i]++;
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (ans[i][j] > mx.val) {
        mx = {i, j, ans[i][j]};
      }
    }
  }
  printf("%d %d\n", mx.i + 1, mx.j + 1);
  return 0;
}

```


### Prompt

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

We'll call a sequence of integers a good k-d sequence if we can add to it at most k numbers in such a way that after the sorting the sequence will be an arithmetic progression with difference d.

You got hold of some sequence a, consisting of n integers. Your task is to find its longest contiguous subsegment, such that it is a good k-d sequence.

Input

The first line contains three space-separated integers n, k, d (1 ≤ n ≤ 2·105; 0 ≤ k ≤ 2·105; 0 ≤ d ≤ 109). The second line contains n space-separated integers: a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — the actual sequence.

Output

Print two space-separated integers l, r (1 ≤ l ≤ r ≤ n) show that sequence al, al + 1, ..., ar is the longest subsegment that is a good k-d sequence.

If there are multiple optimal answers, print the one with the minimum value of l.

Examples

Input

6 1 2
4 3 2 8 6 2

Output

3 5

Note

In the first test sample the answer is the subsegment consisting of numbers 2, 8, 6 — after adding number 4 and sorting it becomes sequence 2, 4, 6, 8 — the arithmetic progression with difference 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 2e5;
int n, k, d, a[N];
struct Tree {
  int l, r, v, lazy;
  Tree *left, *right;
};
int mc;
Tree memory[400000], *root;
map<int, int> hash;
Tree *Build(int l, int r) {
  Tree *ret = &memory[mc++];
  ret->l = l, ret->r = r;
  if (l == r)
    ret->v = l;
  else {
    ret->left = Build(l, (l + r) / 2);
    ret->right = Build((l + r) / 2 + 1, r);
    ret->v = min(ret->left->v, ret->right->v);
  }
  return ret;
}
void PushDown(Tree *t) {
  t->v += t->lazy;
  if (t->l < t->r) {
    t->left->lazy += t->lazy;
    t->right->lazy += t->lazy;
  }
  t->lazy = 0;
}
void Modify(Tree *t, int l, int r, int v) {
  PushDown(t);
  if (t->l == l && t->r == r)
    t->lazy += v;
  else {
    if (r <= t->left->r)
      Modify(t->left, l, r, v);
    else if (l >= t->right->l)
      Modify(t->right, l, r, v);
    else
      Modify(t->left, l, t->left->r, v), Modify(t->right, t->right->l, r, v);
    t->v = min(t->left->v + t->left->lazy, t->right->v + t->right->lazy);
  }
}
int Query(Tree *t, int l, int r, int v) {
  PushDown(t);
  if (t->l == t->r) return t->v <= v ? l : -1;
  if (t->left->v + t->left->lazy <= v && l <= t->left->r) {
    int tmp = Query(t->left, l, min(r, t->left->r), v);
    if (tmp != -1) return tmp;
  }
  if (t->right->v + t->right->lazy <= v && r >= t->right->l)
    return Query(t->right, max(l, t->right->l), r, v);
  return -1;
}
int ansl, ansr;
inline void Submit(int l, int r) {
  if (r - l > ansr - ansl || (r - l == ansr - ansl && l < ansl))
    ansl = l, ansr = r;
}
int pre[N];
void Solve(int l, int r) {
  map<int, int> hash;
  for (int i = l; i <= r; i++) a[i] /= d;
  for (int i = l; i <= r; i++) {
    map<int, int>::iterator iter = hash.find(a[i]);
    if (iter == hash.end())
      hash.insert(make_pair(a[i], i));
    else
      pre[i] = iter->second + 1, iter->second = i;
  }
  stack<pair<int, int> > maxi, mini;
  int p = l;
  for (int i = l; i <= r; i++) {
    p = max(p, pre[i]);
    while (!mini.empty() && a[i] <= mini.top().first) {
      pair<int, int> tmp = mini.top();
      mini.pop();
      if (mini.empty() && p > tmp.second) continue;
      Modify(root, mini.empty() ? p : mini.top().second + 1, tmp.second,
             tmp.first - a[i]);
    }
    while (!maxi.empty() && a[i] >= maxi.top().first) {
      pair<int, int> tmp = maxi.top();
      maxi.pop();
      if (maxi.empty() && p > tmp.second) continue;
      Modify(root, maxi.empty() ? p : maxi.top().second + 1, tmp.second,
             a[i] - tmp.first);
    }
    mini.push(make_pair(a[i], i));
    maxi.push(make_pair(a[i], i));
    int tmp = Query(root, p, i, i + k);
    if (tmp != -1) Submit(tmp, i);
  }
}
int main() {
  scanf("%d%d%d", &n, &k, &d);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    a[i] += 1000000000;
  }
  if (d == 0)
    for (int i = 0; i < n;) {
      int r = i + 1;
      while (r < n && a[i] == a[r]) r++;
      Submit(i, r - 1);
      i = r;
    }
  else {
    root = Build(0, n - 1);
    for (int i = 0; i < n;) {
      int r = i + 1;
      while (r < n && a[i] % d == a[r] % d) r++;
      Solve(i, r - 1);
      i = r;
    }
  }
  cout << ansl + 1 << ' ' << ansr + 1 << endl;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Ignoring the air resistance, velocity of a freely falling object $v$ after $t$ seconds and its drop $y$ in $t$ seconds are represented by the following formulas:

$ v = 9.8 t $
$ y = 4.9 t^2 $

A person is trying to drop down a glass ball and check whether it will crack. Your task is to write a program to help this experiment.

You are given the minimum velocity to crack the ball. Your program should print the lowest possible floor of a building to crack the ball. The height of the $N$ floor of the building is defined by $5 \times N - 5$.

Input

The input consists of multiple datasets. Each dataset, a line, consists of the minimum velocity v (0 < v < 200) to crack the ball. The value is given by a decimal fraction, with at most 4 digits after the decimal point. The input ends with EOF. The number of datasets is less than or equal to 50.

Output

For each dataset, print the lowest possible floor where the ball cracks.

Example

Input

25.4
25.4

Output

8
8

### Response

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

int main() {
  double v;
  while (cin >> v) {
    cout << floor(v*v/98 + 2) << endl;
  }
  return 0;
}
```


### Prompt

Construct a CPP code solution to the problem outlined:

Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct.

Fortunately the child knows how to solve such complicated test. The child will follow the algorithm:

  * If there is some choice whose description at least twice shorter than all other descriptions, or at least twice longer than all other descriptions, then the child thinks the choice is great.
  * If there is exactly one great choice then the child chooses it. Otherwise the child chooses C (the child think it is the luckiest choice).

You are given a multiple-choice questions, can you predict child's choose?

Input

The first line starts with "A." (without quotes), then followed the description of choice A. The next three lines contains the descriptions of the other choices in the same format. They are given in order: B, C, D. Please note, that the description goes after prefix "X.", so the prefix mustn't be counted in description's length.

Each description is non-empty and consists of at most 100 characters. Each character can be either uppercase English letter or lowercase English letter, or "_".

Output

Print a single line with the child's choice: "A", "B", "C" or "D" (without quotes).

Examples

Input

A.VFleaKing_is_the_author_of_this_problem
B.Picks_is_the_author_of_this_problem
C.Picking_is_the_author_of_this_problem
D.Ftiasch_is_cute

Output

D

Input

A.ab
B.abcde
C.ab
D.abc

Output

C

Input

A.c
B.cc
C.c
D.c

Output

B

Note

In the first sample, the first choice has length 39, the second one has length 35, the third one has length 37, and the last one has length 15. The choice D (length 15) is twice shorter than all other choices', so it is great choice. There is no other great choices so the child will choose D.

In the second sample, no choice is great, so the child will choose the luckiest choice C.

In the third sample, the choice B (length 2) is twice longer than all other choices', so it is great choice. There is no other great choices so the child will choose B.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  vector<string> A(4);
  for (int i = 0; i < 4; i++) {
    cin >> A[i];
    A[i] = A[i].substr(2);
  }
  vector<int> B;
  for (int i = 0; i < 4; i++) {
    bool flag1 = true, flag2 = true;
    for (int j = 0; j < 4; j++) {
      if (i == j) continue;
      if (A[i].size() < A[j].size() * 2) flag1 = false;
    }
    for (int j = 0; j < 4; j++) {
      if (i == j) continue;
      if (A[i].size() * 2 > A[j].size()) flag2 = false;
    }
    if (flag1 || flag2) B.push_back(i);
  }
  if (B.size() == 1)
    cout << (char)('A' + B[0]) << endl;
  else
    cout << "C\n";
  return 0;
}

```


### Prompt

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

Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle.

Ivar has n warriors, he places them on a straight line in front of the main gate, in a way that the i-th warrior stands right after (i-1)-th warrior. The first warrior leads the attack.

Each attacker can take up to a_i arrows before he falls to the ground, where a_i is the i-th warrior's strength.

Lagertha orders her warriors to shoot k_i arrows during the i-th minute, the arrows one by one hit the first still standing warrior. After all Ivar's warriors fall and all the currently flying arrows fly by, Thor smashes his hammer and all Ivar's warriors get their previous strengths back and stand up to fight again. In other words, if all warriors die in minute t, they will all be standing to fight at the end of minute t.

The battle will last for q minutes, after each minute you should tell Ivar what is the number of his standing warriors.

Input

The first line contains two integers n and q (1 ≤ n, q ≤ 200 000) — the number of warriors and the number of minutes in the battle.

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 10^9) that represent the warriors' strengths.

The third line contains q integers k_1, k_2, …, k_q (1 ≤ k_i ≤ 10^{14}), the i-th of them represents Lagertha's order at the i-th minute: k_i arrows will attack the warriors.

Output

Output q lines, the i-th of them is the number of standing warriors after the i-th minute.

Examples

Input

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

Output

3
5
4
4
3

Input

4 4
1 2 3 4
9 1 10 6

Output

1
4
4
1

Note

In the first example:

  * after the 1-st minute, the 1-st and 2-nd warriors die.
  * after the 2-nd minute all warriors die (and all arrows left over are wasted), then they will be revived thus answer is 5 — all warriors are alive.
  * after the 3-rd minute, the 1-st warrior dies.
  * after the 4-th minute, the 2-nd warrior takes a hit and his strength decreases by 1.
  * after the 5-th minute, the 2-nd warrior dies.

### Response

```cpp
#include <bits/stdc++.h>
int Set(int N, int pos) { return N = N | (1 << pos); }
int reset(int N, int pos) { return N = N & ~(1 << pos); }
bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
using namespace std;
const long long maxx = 2e5 + 10;
long long arr[maxx + 5], krr[maxx + 5], sum[maxx + 5];
vector<long long> v;
vector<long long>::iterator upper;
int main() {
  long long n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    arr[i] = x;
    sum[i] = x;
    if (i != 0) {
      sum[i] += sum[i - 1];
    }
    v.push_back(sum[i]);
  }
  for (int i = 0; i < q; i++) {
    long long x;
    cin >> x;
    krr[i] = x;
  }
  long long arrow = 0;
  for (int i = 0; i < q; i++) {
    arrow += krr[i];
    upper = upper_bound(v.begin(), v.end(), arrow);
    int dead = (upper - v.begin());
    if (dead == n) {
      arrow = 0;
      dead = 0;
    }
    cout << n - dead << endl;
  }
  return 0;
}

```


### Prompt

Please formulate a CPP solution to 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;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  char c = getchar();
  int tot = 1;
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    tot = -1;
    c = getchar();
  }
  int sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * tot;
}
inline void wr(long long x) {
  if (x < 0) {
    putchar('-');
    wr(-x);
    return;
  }
  if (x >= 10) wr(x / 10);
  putchar(x % 10 + '0');
}
inline void wrn(long long x) {
  wr(x);
  putchar('\n');
}
inline void wri(int x) {
  wr(x);
  putchar(' ');
}
inline void wrn(int x, int y) {
  wri(x);
  wrn(y);
}
inline void wrn(int a, int b, int c) {
  wri(a);
  wrn(b, c);
}
int n, m, K;
long long ans;
int s[3055][3055], up[8], down[8];
inline int sum(int x1, int x2, int y1, int y2) {
  return s[x2][y2] - s[x2][y1] - s[x1][y2] + s[x1][y1];
}
void work(int x1, int x2, int y1, int y2, bool dir) {
  if (x1 == x2 || y1 == y2) return;
  if ((x1 + 1 == x2) && (y1 + 1 == y2)) {
    ans += sum(x1, x2, y1, y2) == K;
    return;
  }
  if (dir) {
    int mid = ((x1 + x2) >> 1);
    work(x1, mid, y1, y2, !dir);
    work(mid, x2, y1, y2, !dir);
    for (int i = y1; i < y2; i++) {
      up[0] = down[0] = mid;
      for (int k = 1; k <= K + 1; k++) up[k] = x1, down[k] = x2;
      for (int j = i + 1; j <= y2; j++) {
        for (int k = 1; k <= K + 1; k++)
          while (sum(up[k], mid, i, j) >= k) up[k]++;
        for (int k = 1; k <= K + 1; k++)
          while (sum(mid, down[k], i, j) >= k) down[k]--;
        for (int k = 0; k <= K; k++)
          ans += (up[k] - up[k + 1]) * (down[K - k + 1] - down[K - k]);
      }
    }
  } else {
    int mid = ((y1 + y2) >> 1);
    work(x1, x2, y1, mid, !dir);
    work(x1, x2, mid, y2, !dir);
    for (int i = x1; i < x2; i++) {
      up[0] = down[0] = mid;
      for (int k = 1; k <= K + 1; k++) up[k] = y1, down[k] = y2;
      for (int j = i + 1; j <= x2; j++) {
        for (int k = 1; k <= K + 1; k++)
          while (sum(i, j, up[k], mid) >= k) up[k]++;
        for (int k = 1; k <= K + 1; k++)
          while (sum(i, j, mid, down[k]) >= k) down[k]--;
        for (int k = 0; k <= K; k++)
          ans += (up[k] - up[k + 1]) * (down[K - k + 1] - down[K - k]);
      }
    }
  }
}
char str[3055];
int main() {
  n = read();
  m = read();
  K = read();
  for (int i = (1); i <= (n); i++) {
    scanf("%s", str + 1);
    for (int j = (1); j <= (m); j++)
      s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + str[j] - '0';
  }
  work(0, n, 0, m, 0);
  wrn(ans);
  return 0;
}

```


### Prompt

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

The only difference between easy and hard versions is constraints.

Nauuo is a girl who loves random picture websites.

One day she made a random picture website by herself which includes n pictures.

When Nauuo visits the website, she sees exactly one picture. The website does not display each picture with equal probability. The i-th picture has a non-negative weight w_i, and the probability of the i-th picture being displayed is \frac{w_i}{∑_{j=1}^nw_j}. That is to say, the probability of a picture to be displayed is proportional to its weight.

However, Nauuo discovered that some pictures she does not like were displayed too often.

To solve this problem, she came up with a great idea: when she saw a picture she likes, she would add 1 to its weight; otherwise, she would subtract 1 from its weight.

Nauuo will visit the website m times. She wants to know the expected weight of each picture after all the m visits modulo 998244353. Can you help her?

The expected weight of the i-th picture can be denoted by \frac {q_i} {p_i} where \gcd(p_i,q_i)=1, you need to print an integer r_i satisfying 0≤ r_i<998244353 and r_i⋅ p_i≡ q_i\pmod{998244353}. It can be proved that such r_i exists and is unique.

Input

The first line contains two integers n and m (1≤ n≤ 50, 1≤ m≤ 50) — the number of pictures and the number of visits to the website.

The second line contains n integers a_1,a_2,…,a_n (a_i is either 0 or 1) — if a_i=0 , Nauuo does not like the i-th picture; otherwise Nauuo likes the i-th picture. It is guaranteed that there is at least one picture which Nauuo likes.

The third line contains n integers w_1,w_2,…,w_n (1≤ w_i≤50) — the initial weights of the pictures.

Output

The output contains n integers r_1,r_2,…,r_n — the expected weights modulo 998244353.

Examples

Input

2 1
0 1
2 1

Output

332748119
332748119

Input

1 2
1
1

Output

3

Input

3 3
0 1 1
4 3 5

Output

160955686
185138929
974061117

Note

In the first example, if the only visit shows the first picture with a probability of \frac 2 3, the final weights are (1,1); if the only visit shows the second picture with a probability of \frac1 3, the final weights are (2,2).

So, both expected weights are \frac2 3⋅ 1+\frac 1 3⋅ 2=\frac4 3 .

Because 332748119⋅ 3≡ 4\pmod{998244353}, you need to print 332748119 instead of \frac4 3 or 1.3333333333.

In the second example, there is only one picture which Nauuo likes, so every time Nauuo visits the website, w_1 will be increased by 1.

So, the expected weight is 1+2=3.

Nauuo is very naughty so she didn't give you any hint of the third example.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vint = vector<int>;
constexpr int MOD = 998244353LL;
ll ppow(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1) {
      ans = (ans * a) % MOD;
    }
    b /= 2;
    a = (a * a) % MOD;
  }
  return ans;
}
vector<ll> mods;
ll modinv(ll k) { return mods[k]; }
class solver {
 private:
  int n, m;
  vector<int> likes;
  vector<int> weights;
  ll all_sum;
  ll all_likes;
  ll all_unlikes;
  vector<vector<vector<ll>>> cc[2][2];
  ll dp(int like, int likes_delta, int unlikes_delta, int cur, int ost) {
    if (likes_delta > 50 || unlikes_delta > 50 || cur > 100) {
      return 0;
    }
    if (ost == 0) {
      return cur;
    }
    ll &ans = cc[ost % 2][like][likes_delta][unlikes_delta][cur];
    if (ans != -1) {
      return ans;
    }
    ans = 0;
    ll all_count = all_sum + likes_delta - unlikes_delta;
    if (all_count < 0) {
      return 0;
    }
    ll choose_cur_ver = cur;
    ll unlike_count = all_unlikes - unlikes_delta - (like == 0 ? cur : 0);
    ans += dp(like, likes_delta, unlikes_delta + 1, cur, ost - 1) *
           ((unlike_count * modinv(all_count)) % MOD);
    ll like_count = all_likes + likes_delta - (like == 1 ? cur : 0);
    ans += dp(like, likes_delta + 1, unlikes_delta, cur, ost - 1) *
           ((like_count * modinv(all_count)) % MOD);
    if (like) {
      ans += dp(like, likes_delta + 1, unlikes_delta, cur + 1, ost - 1) *
             ((cur * modinv(all_count)) % MOD);
    } else if (!like && cur > 0) {
      ans += dp(like, likes_delta, unlikes_delta + 1, cur - 1, ost - 1) *
             ((cur * modinv(all_count)) % MOD);
    }
    ans %= MOD;
    return ans;
  }

 public:
  void solve(int n) {
    this->n = n;
    cin >> m;
    likes.resize(n);
    weights.resize(n);
    for (auto &it : likes) {
      cin >> it;
    }
    for (auto &it : weights) {
      cin >> it;
    }
    all_sum = 0;
    all_likes = 0;
    all_unlikes = 0;
    for (int i = 0; i < n; i++) {
      all_sum += weights[i];
      if (likes[i]) {
        all_likes += weights[i];
      } else {
        all_unlikes += weights[i];
      }
    }
    for (int a = 0; a < 2; a++) {
      for (int b = 0; b < 2; b++) {
        cc[a][b].resize(51);
        for (int z = 0; z < 51; z++) {
          cc[a][b][z].resize(51);
          for (int s = 0; s < 51; s++) {
            cc[a][b][z][s].resize(101, -1);
          }
        }
      }
    }
    for (int ost = 0; ost < m; ost++) {
      for (int b = 0; b < 2; b++) {
        for (int z = 0; z < 51; z++) {
          for (int s = 0; s < 51; s++) {
            fill(cc[ost % 2][b][z][s].begin(), cc[ost % 2][b][z][s].end(), -1);
          }
        }
      }
      for (int b = 0; b < 2; b++) {
        for (int ld = 0; ld <= 50; ld++) {
          for (int ud = 0; ud <= 50; ud++) {
            for (int cur = 0; cur <= 100; cur++) {
              dp(b, ld, ud, cur, ost);
            }
          }
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (int b = 0; b < 2; b++) {
        for (int z = 0; z < 51; z++) {
          for (int s = 0; s < 51; s++) {
            fill(cc[m % 2][b][z][s].begin(), cc[m % 2][b][z][s].end(), -1);
          }
        }
      }
      cout << dp(likes[i], 0, 0, weights[i], m) << endl;
    }
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  mods.resize(300000);
  for (int i = 0; i < mods.size(); i++) {
    mods[i] = ppow(i, MOD - 2);
  }
  int n;
  while (cin >> n) {
    solver s;
    s.solve(n);
  }
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

We have three boxes A, B, and C, each of which contains an integer.
Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.
We will now do the operations below in order. Find the content of each box afterward.

* Swap the contents of the boxes A and B
* Swap the contents of the boxes A and C

Constraints

* 1 \leq X,Y,Z \leq 100
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

X Y Z

Output

Print the integers contained in the boxes A, B, and C, in this order, with space in between.

Examples

Input

1 2 3

Output

3 1 2

Input

100 100 100

Output

100 100 100

Input

41 59 31

Output

31 41 59

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int x,y,z; cin>>x>>y>>z;
  printf("%d %d %d",z,x,y);
  return 0;
}
```


### Prompt

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

You are given a permutation of n numbers p1, p2, ..., pn. We perform k operations of the following type: choose uniformly at random two indices l and r (l ≤ r) and reverse the order of the elements pl, pl + 1, ..., pr. Your task is to find the expected value of the number of inversions in the resulting permutation.

Input

The first line of input contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 109). The next line contains n integers p1, p2, ..., pn — the given permutation. All pi are different and in range from 1 to n.

The problem consists of three subproblems. The subproblems have different constraints on the input. You will get some score for the correct submission of the subproblem. The description of the subproblems follows.

  * In subproblem G1 (3 points), the constraints 1 ≤ n ≤ 6, 1 ≤ k ≤ 4 will hold.
  * In subproblem G2 (5 points), the constraints 1 ≤ n ≤ 30, 1 ≤ k ≤ 200 will hold.
  * In subproblem G3 (16 points), the constraints 1 ≤ n ≤ 100, 1 ≤ k ≤ 109 will hold.

Output

Output the answer with absolute or relative error no more than 1e - 9.

Examples

Input

3 1
1 2 3

Output

0.833333333333333

Input

3 4
1 3 2

Output

1.458333333333334

Note

Consider the first sample test. We will randomly pick an interval of the permutation (1, 2, 3) (which has no inversions) and reverse the order of its elements. With probability <image>, the interval will consist of a single element and the permutation will not be altered. With probability <image> we will inverse the first two elements' order and obtain the permutation (2, 1, 3) which has one inversion. With the same probability we might pick the interval consisting of the last two elements which will lead to the permutation (1, 3, 2) with one inversion. Finally, with probability <image> the randomly picked interval will contain all elements, leading to the permutation (3, 2, 1) with 3 inversions. Hence, the expected number of inversions is equal to <image>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void smn(T &a, const T &b) {
  if (b < a) a = b;
}
template <class T>
inline void smx(T &a, const T &b) {
  if (b > a) a = b;
}
const double eps = 1e-8;
const int MN = 100 + 100;
int n, k;
double dp[MN][MN][MN];
bool mark[MN][MN][MN];
double all;
int perm[MN];
int fix(int now, int s, int e) {
  if (e < now || s > now) return now;
  return (e - (now - s));
}
double fnd(int s, int e, int t) {
  if (t == 0) return (s > e) ? 1 : 0;
  if (mark[s][e][t]) return dp[s][e][t];
  mark[s][e][t] = 1;
  double &res = dp[s][e][t];
  res = 0;
  for (int i = 0; i < n; i++)
    for (int j = i; j < n; j++) {
      res += 1 / all * fnd(fix(s, i, j), fix(e, i, j), t - 1);
    }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  all = n * (n + 1) / 2;
  for (int i = 0; i < n; i++) cin >> perm[i];
  double res = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (perm[i] < perm[j])
        res += fnd(i, j, k);
      else
        res += (1 - fnd(i, j, k));
  cout << fixed << setprecision(11) << res << '\n';
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!

A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system.

There are n booking requests received by now. Each request is characterized by two numbers: ci and pi — the size of the group of visitors who will come via this request and the total sum of money they will spend in the restaurant, correspondingly.

We know that for each request, all ci people want to sit at the same table and are going to spend the whole evening in the restaurant, from the opening moment at 18:00 to the closing moment.

Unfortunately, there only are k tables in the restaurant. For each table, we know ri — the maximum number of people who can sit at it. A table can have only people from the same group sitting at it. If you cannot find a large enough table for the whole group, then all visitors leave and naturally, pay nothing.

Your task is: given the tables and the requests, decide which requests to accept and which requests to decline so that the money paid by the happy and full visitors was maximum.

Input

The first line of the input contains integer n (1 ≤ n ≤ 1000) — the number of requests from visitors. Then n lines follow. Each line contains two integers: ci, pi (1 ≤ ci, pi ≤ 1000) — the size of the group of visitors who will come by the i-th request and the total sum of money they will pay when they visit the restaurant, correspondingly.

The next line contains integer k (1 ≤ k ≤ 1000) — the number of tables in the restaurant. The last line contains k space-separated integers: r1, r2, ..., rk (1 ≤ ri ≤ 1000) — the maximum number of people that can sit at each table.

Output

In the first line print two integers: m, s — the number of accepted requests and the total money you get from these requests, correspondingly.

Then print m lines — each line must contain two space-separated integers: the number of the accepted request and the number of the table to seat people who come via this request. The requests and the tables are consecutively numbered starting from 1 in the order in which they are given in the input.

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

Examples

Input

3
10 50
2 100
5 30
3
4 6 9

Output

2 130
2 1
3 2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
inline void INP() {}
bool check(string &s) {
  int i = 0, j = s.length() - 1;
  while (i <= j) {
    if (s[i] != s[j]) return false;
    i++;
    j--;
  }
  return true;
}
int binary(vector<pair<int, int>> &tables, int num) {
  int i = 0, j = tables.size() - 1;
  int ans = tables.size();
  while (i <= j) {
    int mid = (i + j) / 2;
    int value = tables[mid].first;
    if (value < num) {
      i = mid + 1;
    } else {
      ans = mid;
      j = mid - 1;
    }
  }
  return ans;
}
void solve() {
  int n;
  cin >> n;
  vector<pair<int, pair<int, int>>> v;
  for (int i = 0; i < (n); ++i) {
    int c, p;
    cin >> c >> p;
    v.push_back(make_pair(p, make_pair(c, i)));
  }
  sort(v.begin(), v.end(), greater<pair<int, pair<int, int>>>());
  int k;
  cin >> k;
  vector<pair<int, int>> tables(k);
  for (int i = 0; i < (k); ++i) {
    int a;
    cin >> a;
    tables[i] = make_pair(a, (int)i);
  }
  sort(tables.begin(), tables.end());
  int index[k];
  for (int i = 0; i < (k); ++i) index[i] = -1;
  for (int i = 0; i < (v.size()); ++i) {
    int idx = v[i].second.second;
    int size = v[i].second.first;
    int pos = binary(tables, size);
    if (pos != tables.size()) {
      if (index[tables[pos].second] == -1) {
        index[tables[pos].second] = i;
      } else {
        while (pos < tables.size() && index[tables[pos].second] != -1) {
          pos++;
        }
        if (pos != tables.size()) {
          if (index[tables[pos].second] == -1) {
            index[tables[pos].second] = i;
          }
        }
      }
    }
  }
  int count = 0;
  int money = 0;
  for (int i = 0; i < (k); ++i) {
    if (index[i] != -1) {
      count++;
      money += v[index[i]].first;
    }
  }
  cout << count << " ";
  cout << money << '\n';
  for (int i = 0; i < (k); ++i) {
    if (index[i] != -1) {
      cout << v[index[i]].second.second + 1 << " ";
      cout << i + 1 << '\n';
    }
  }
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Little Petya likes to play very much. And most of all he likes to play the following game:

He is given a sequence of N integer numbers. At each step it is allowed to increase the value of any number by 1 or to decrease it by 1. The goal of the game is to make the sequence non-decreasing with the smallest number of steps. Petya is not good at math, so he asks for your help.

The sequence a is called non-decreasing if a1 ≤ a2 ≤ ... ≤ aN holds, where N is the length of the sequence.

Input

The first line of the input contains single integer N (1 ≤ N ≤ 5000) — the length of the initial sequence. The following N lines contain one integer each — elements of the sequence. These numbers do not exceed 109 by absolute value.

Output

Output one integer — minimum number of steps required to achieve the goal.

Examples

Input

5
3 2 -1 2 11

Output

4

Input

5
2 1 1 1 1

Output

1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct IO {
  char buf[(1 << 20)], *p1, *p2;
  char pbuf[(1 << 20)], *pp;
  IO() : p1(buf), p2(buf), pp(pbuf) {}
  inline char gc() {
    return getchar();
    if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, (1 << 20), stdin);
    return p1 == p2 ? ' ' : *p1++;
  }
  inline bool blank(char ch) {
    return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
  }
  template <class T>
  inline void read(T &x) {
    register double tmp = 1;
    register bool sign = 0;
    x = 0;
    register char ch = gc();
    for (; !(ch >= '0' && ch <= '9'); ch = gc())
      if (ch == '-') sign = 1;
    for (; (ch >= '0' && ch <= '9'); ch = gc()) x = x * 10 + (ch - '0');
    if (ch == '.')
      for (ch = gc(); (ch >= '0' && ch <= '9'); ch = gc())
        tmp /= 10.0, x += tmp * (ch - '0');
    if (sign) x = -x;
  }
  inline void read(char *s) {
    register char ch = gc();
    for (; blank(ch); ch = gc())
      ;
    for (; !blank(ch); ch = gc()) *s++ = ch;
    *s = 0;
  }
  inline void read(char &c) {
    for (c = gc(); blank(c); c = gc())
      ;
  }
  template <class t>
  inline void write(t x) {
    if (x < 0)
      putchar('-'), write(-x);
    else {
      if (x > 9) write(x / 10);
      putchar('0' + x % 10);
    }
  }
} io;
const long long mod = 1e9 + 7;
const long long mo = 998244353;
const long long N = 5005;
long long n, m, a[N], b[N], f[2][N], g[2][N], ans;
signed main() {
  io.read(n);
  for (long long i = (1); i <= (n); i++) io.read(b[i]), a[i] = b[i];
  sort(b + 1, b + n + 1);
  for (long long i = (1); i <= (n); i++) f[0][i] = 0, g[0][i] = 0;
  for (long long i = (1); i <= (n); i++) {
    memset(f[i & 1], 88, sizeof(f[i & 1]));
    memset(g[i & 1], 88, sizeof(g[i & 1]));
    for (long long j = (1); j <= (n); j++)
      f[i & 1][j] = min(f[i & 1][j], g[(i - 1) & 1][j] + abs(a[i] - b[j]));
    for (long long j = (1); j <= (n); j++)
      g[i & 1][j] = min(g[i & 1][j - 1], f[i & 1][j]);
  }
  ans = 1e14;
  for (long long i = (1); i <= (n); i++) ans = min(ans, f[n & 1][i]);
  printf("%lld\n", ans);
  return 0;
}

```


### Prompt

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

Polycarp wants to cook a soup. To do it, he needs to buy exactly n liters of water.

There are only two types of water bottles in the nearby shop — 1-liter bottles and 2-liter bottles. There are infinitely many bottles of these two types in the shop.

The bottle of the first type costs a burles and the bottle of the second type costs b burles correspondingly.

Polycarp wants to spend as few money as possible. Your task is to find the minimum amount of money (in burles) Polycarp needs to buy exactly n liters of water in the nearby shop if the bottle of the first type costs a burles and the bottle of the second type costs b burles.

You also have to answer q independent queries.

Input

The first line of the input contains one integer q (1 ≤ q ≤ 500) — the number of queries.

The next q lines contain queries. The i-th query is given as three space-separated integers n_i, a_i and b_i (1 ≤ n_i ≤ 10^{12}, 1 ≤ a_i, b_i ≤ 1000) — how many liters Polycarp needs in the i-th query, the cost (in burles) of the bottle of the first type in the i-th query and the cost (in burles) of the bottle of the second type in the i-th query, respectively.

Output

Print q integers. The i-th integer should be equal to the minimum amount of money (in burles) Polycarp needs to buy exactly n_i liters of water in the nearby shop if the bottle of the first type costs a_i burles and the bottle of the second type costs b_i burles.

Example

Input

4
10 1 3
7 3 2
1 1000 1
1000000000000 42 88

Output

10
9
1000
42000000000000

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, a, b;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> n >> a >> b;
    if ((double)(a) < (double)(b / 2.0)) {
      cout << n * a << endl;
    } else {
      if (n % 2 == 0) {
        cout << n / 2 * b << endl;
      } else {
        cout << ((n - 1) / 2 * b) + a << endl;
      }
    }
  }
  return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Extended Euclid Algorithm

Given positive integers a and b, find the integer solution (x, y) to ax + by = gcd(a, b), where gcd(a, b) is the greatest common divisor of a and b.

Constraints

* 1 ≤ a, b ≤ 109

Input

a b

Two positive integers a and b are given separated by a space in a line.

Output

Print two integers x and y separated by a space. If there are several pairs of such x and y, print that pair for which |x| + |y| is the minimal (primarily) and x ≤ y (secondarily).

Examples

Input

4 12

Output

1 0

Input

3 8

Output

3 -1

### Response

```cpp
#include <iostream>

using namespace std;

template<typename T>
T extgcd(T a, T b, T& x, T& y){
    T g = a; x = 1; y = 0;
    if(b){
        g = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    return g;
}

int main(){
    int a, b, x, y;
    cin >> a >> b;
    extgcd(a, b, x, y);
    cout << x << ' ' << y << '\n';
    return 0;
}
```


### Prompt

Construct a Cpp code solution to the problem outlined:

We have a grid with H rows and W columns of squares. Snuke is painting these squares in colors 1, 2, ..., N. Here, the following conditions should be satisfied:

* For each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W.
* For each i (1 ≤ i ≤ N), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color i by repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.

Find a way to paint the squares so that the conditions are satisfied. It can be shown that a solution always exists.

Constraints

* 1 ≤ H, W ≤ 100
* 1 ≤ N ≤ H W
* a_i ≥ 1
* a_1 + a_2 + ... + a_N = H W

Input

Input is given from Standard Input in the following format:

H W
N
a_1 a_2 ... a_N

Output

Print one way to paint the squares that satisfies the conditions. Output in the following format:

c_{1 1} ... c_{1 W}
:
c_{H 1} ... c_{H W}

Here, c_{i j} is the color of the square at the i-th row from the top and j-th column from the left.

Examples

Input

2 2
3
2 1 1

Output

1 1
2 3

Input

3 5
5
1 2 3 4 5

Output

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

Input

1 1
1
1

Output

1

### Response

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

int	main() {
	int H, W;
	cin >>H >>W;
	int N;
	cin >>N;
	int a;
	vector<int> A(0);
	for (int i=0; i<N; i++) {
		cin >>a;
		for (int j=0; j<a; j++)
			A.push_back(i+1);
	}
	vector<vector<int>> C(H, vector<int>(W, 0));
	for (int i=0; i<H*W; i++) {
		int h=i/W;
		int w=i%W;
		if (0!=h%2)
			w=W-w-1;
		C.at(h).at(w)=A.at(i);
	}
	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++)
			cout <<C.at(i).at(j) <<' ';
		cout <<endl;
	}
	return 0;
};

```


### Prompt

Construct a cpp code solution to the problem outlined:

The only difference between easy and hard versions is the maximum value of n.

You are given a positive integer number n. You really love good numbers so you want to find the smallest good number greater than or equal to n.

The positive integer is called good if it can be represented as a sum of distinct powers of 3 (i.e. no duplicates of powers of 3 are allowed).

For example:

  * 30 is a good number: 30 = 3^3 + 3^1,
  * 1 is a good number: 1 = 3^0,
  * 12 is a good number: 12 = 3^2 + 3^1,
  * but 2 is not a good number: you can't represent it as a sum of distinct powers of 3 (2 = 3^0 + 3^0),
  * 19 is not a good number: you can't represent it as a sum of distinct powers of 3 (for example, the representations 19 = 3^2 + 3^2 + 3^0 = 3^2 + 3^1 + 3^1 + 3^1 + 3^0 are invalid),
  * 20 is also not a good number: you can't represent it as a sum of distinct powers of 3 (for example, the representation 20 = 3^2 + 3^2 + 3^0 + 3^0 is invalid).

Note, that there exist other representations of 19 and 20 as sums of powers of 3 but none of them consists of distinct powers of 3.

For the given positive integer n find such smallest m (n ≤ m) that m is a good number.

You have to answer q independent queries.

Input

The first line of the input contains one integer q (1 ≤ q ≤ 500) — the number of queries. Then q queries follow.

The only line of the query contains one integer n (1 ≤ n ≤ 10^{18}).

Output

For each query, print such smallest integer m (where n ≤ m) that m is a good number.

Example

Input

8
1
2
6
13
14
3620
10000
1000000000000000000

Output

1
3
9
13
27
6561
19683
1350851717672992089

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long N = 201;
int n, ka, q;
string TToT(long long a) {
  string p;
  while (a >= 3) {
    p += to_string(a % 3);
    a /= 3;
  }
  p += to_string(a % 3);
  string m;
  for (int i = p.size() - 1; i < 64; i++) m += '0';
  for (int i = p.size() - 1; i >= 0; i--) {
    m += p[i];
  }
  return m;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> q;
  while (q--) {
    long long p, answ = 0;
    cin >> p;
    string m = TToT(p);
    for (int i = m.size() - 1; i >= 1; i--) {
      if (m[i] > 49) {
        if (m[i - 1] > 48)
          m[i - 1] = char(m[i - 1] + 1);
        else {
          m[i - 1] = '1';
          for (int j = i; j < m.size(); j++) m[j] = 0;
        }
        m[i] = '0';
      }
    }
    for (int i = m.size() - 1; i >= 0; i--) {
      if (m[i] == '1') {
        answ += pow(3, m.size() - i - 1);
      }
    }
    cout << answ << "\n";
  }
}

```


### Prompt

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

Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of remarkable properties. Help Rikhail to convince the scientific community in this!

Let us remind you that a number is called prime if it is integer larger than one, and is not divisible by any positive integer other than itself and one.

Rikhail calls a number a palindromic if it is integer, positive, and its decimal representation without leading zeros is a palindrome, i.e. reads the same from left to right and right to left.

One problem with prime numbers is that there are too many of them. Let's introduce the following notation: π(n) — the number of primes no larger than n, rub(n) — the number of palindromic numbers no larger than n. Rikhail wants to prove that there are a lot more primes than palindromic ones.

He asked you to solve the following problem: for a given value of the coefficient A find the maximum n, such that π(n) ≤ A·rub(n).

Input

The input consists of two positive integers p, q, the numerator and denominator of the fraction that is the value of A (<image>, <image>).

Output

If such maximum number exists, then print it. Otherwise, print "Palindromic tree is better than splay tree" (without the quotes).

Examples

Input

1 1

Output

40

Input

1 42

Output

1

Input

6 4

Output

172

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool prime[10000000];
void seive() {
  for (int i = 3; i <= 10000000; i += 2) prime[i] = true;
  prime[2] = true;
  prime[1] = false;
  int k = sqrt(10000000);
  for (int i = 3; i <= k; i += 2) {
    if (prime[i] == true)
      for (int j = i * i; j <= 10000000; j += (2 * i)) prime[j] = false;
  }
}
bool ispalin(int n) {
  int temp = n;
  int m = 0;
  while (n > 0) {
    m = m * 10 + n % 10;
    n /= 10;
  }
  if (temp == m)
    return true;
  else
    return false;
}
int main() {
  seive();
  long long p, q, tot_prime = 0, tot_palin = 0, last;
  cin >> p >> q;
  for (int i = 1; i <= 10000000; i++) {
    if (prime[i]) tot_prime++;
    if (ispalin(i)) tot_palin++;
    if (q * tot_prime <= p * tot_palin) {
      last = i;
    }
  }
  cout << last << endl;
  return 0;
}

```


### Prompt

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

Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.

Then Andrey got bored from looking at the same number and he started to swap digits first in one, then in the other number, then again in the first number and so on (arbitrary number of changes could be made in each number). At some point it turned out that if we sum the resulting numbers, then the number of zeroes with which the sum will end would be maximum among the possible variants of digit permutations in those numbers.

Given number n, can you find the two digit permutations that have this property?

Input

The first line contains a positive integer n — the original number. The number of digits in this number does not exceed 105. The number is written without any leading zeroes.

Output

Print two permutations of digits of number n, such that the sum of these numbers ends with the maximum number of zeroes. The permutations can have leading zeroes (if they are present, they all should be printed). The permutations do not have to be different. If there are several answers, print any of them.

Examples

Input

198

Output

981
819

Input

500

Output

500
500

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <class T>
void out(vector<T> A, int n = -1) {
  if (n == -1) n = ((int)A.size());
  if (n > ((int)A.size())) n = ((int)A.size());
  cout << "{";
  for (int i = 0; i < n; i++) cout << A[i] << " ";
  cout << "}" << endl;
}
template <class T>
void out(T A[], int n) {
  cout << "{";
  for (int i = 0; i < n; i++) cout << A[i] << " ";
  cout << "}" << endl;
}
string tostring(int v) {
  ostringstream sout;
  sout << v;
  return sout.str();
}
string tostring(long long v) {
  ostringstream sout;
  sout << v;
  return sout.str();
}
int low(int i) { return i & -i; }
int countbit(int i) { return (i == 0) ? 0 : (1 + countbit(i - low(i))); }
int toint(string s) {
  istringstream sin(s);
  int t;
  sin >> t;
  return t;
}
long long toint64(string s) {
  istringstream sin(s);
  long long t;
  sin >> t;
  return t;
}
const double pi = acos(-1.);
const double eps = 1e-11;
string s;
int a[200005], b[200005], f[200005], g[200005];
int main() {
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) a[(int)(s[i] - '0')]++, b[(int)(s[i] - '0')]++;
  int max = -1, last = 0, haha = 0;
  for (int k = 0; k <= a[0]; k++) {
    a[0] -= k;
    b[0] -= k;
    for (int i = 1; i < 10; i++)
      if (a[i] > 0 && b[10 - i] > 0) {
        a[i]--;
        b[10 - i]--;
        int t = k;
        for (int j = 0; j <= 9; j++) t += min(a[j], b[9 - j]);
        if (t > max) {
          max = t;
          last = i;
          haha = k;
        }
        a[i]++;
        b[10 - i]++;
      }
    a[0] += k;
    b[0] += k;
  }
  if (last == 0) {
    for (int i = 9; i >= 0; i--)
      while (a[i]) printf("%d", i), a[i]--;
    printf("\n");
    for (int i = 9; i >= 0; i--)
      while (b[i]) printf("%d", i), b[i]--;
    printf("\n");
  } else {
    int tot = 0;
    while (a[0]) {
      if (tot == haha) break;
      tot++, f[tot] = 0, g[tot] = 0, a[0]--, b[0]--;
    }
    tot++;
    f[tot] = last;
    g[tot] = 10 - last;
    a[last]--;
    b[10 - last]--;
    for (int j = 0; j <= 9; j++) {
      while (min(a[j], b[9 - j]) > 0) {
        tot++;
        f[tot] = j;
        g[tot] = 9 - j;
        a[j]--;
        b[9 - j]--;
      }
    }
    int t1 = tot, t2 = tot;
    for (int j = 0; j <= 9; j++) {
      while (a[j]) t1++, f[t1] = j, a[j]--;
      while (b[j]) t2++, g[t2] = j, b[j]--;
    }
    for (int i = n; i > 0; i--) printf("%d", f[i]);
    printf("\n");
    for (int i = n; i > 0; i--) printf("%d", g[i]);
    printf("\n");
  }
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

problem

President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each square is painted in one of white, blue, and red.

Chairman K is trying to repaint some of the squares on this flag to make it the Russian flag. However, the Russian flag in this problem is as follows.

* Several lines (one or more lines) from the top are all painted in white.
* The next few lines (one or more lines) are all painted in blue.
* All the cells in the other lines (one or more lines) are painted in red.

Find the minimum number of squares that President K needs to repaint to turn the old flag into a Russian flag.

input

The input consists of 1 + N lines.

On the first line, two integers N and M (3 ≤ N ≤ 50, 3 ≤ M ≤ 50) are written separated by a blank. This means that the flags are separated by N rows and M columns.

The following N lines each contain a string of M characters, which represents the color information painted in the squares of the old flag. The jth character (1 ≤ i ≤ N, 1 ≤ j ≤ M) on the i-th line of the N-line represents the color of the cell on the i-th line and j-th column of the old flag. It is either B'or'R'. 'W' stands for white,'B' stands for blue, and'R' stands for red.

output

Output in one line the minimum number of squares that President K needs to repaint to turn the old flag into a Russian flag.

Input / output example

Input example 1

4 5
WRWRW
BWRWB
WRWRW
RWBWR

Output example 1

11

Input example 2

6 14
WWWWWWWWWWWWWW
WBBBWWRRWWBBBW
WWBWWRRRRWWBWW
BWBWWRRRRWWBWW
WBBWWWRRWWBBBW
WWWWWWWWWWWWWW

Output example 2

44

In I / O example 1, the old flag is colored as shown in the figure below.

fig01

In the figure below, repaint the 11 squares with an'X'.

fig02

This makes it possible to make the Russian flag as shown in the figure below.

fig03

Since it is not possible to make a Russian flag by repainting less than 11 squares, 11 is output.

In I / O example 2, the old flag is colored as shown in the figure below.

fig04

Creative Commons License

Information Olympics Japan Committee work "15th Japan Information Olympics JOI 2015/2016 Qualifying Competition Tasks"

Example

Input

4 5
WRWRW
BWRWB
WRWRW
RWBWR

Output

11

### Response

```cpp
#include <iostream>
using namespace std;
int main(void){
    int N, M;
    cin >> N >> M;

    int count, min_count=N*M;
    char flag[N][M];
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            cin >> flag[i][j];
        }
    }

    for(int w=1; w<=N-2; w++){
        for(int b=1; b<=N-w-1; b++){
            count=0;
            for(int i=0; i<w; i++){
                for(int j=0; j<M; j++){
                    if(flag[i][j] != 'W'){
                        count++;
                    }
                }
            }
            for(int i=w; i<w+b; i++){
                for(int j=0; j<M; j++){
                    if(flag[i][j] != 'B'){
                        count++;
                    }
                }
            }
            for(int i=w+b; i<N; i++){
                for(int j=0; j<M; j++){
                    if(flag[i][j] != 'R'){
                        count++;
                    }
                }
            }
            if(min_count>count){
                min_count=count;
            }
        }
    }
    cout << min_count << endl;

}

```


### Prompt

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

There are n points on the plane, (x_1,y_1), (x_2,y_2), …, (x_n,y_n).

You need to place an isosceles triangle with two sides on the coordinate axis to cover all points (a point is covered if it lies inside the triangle or on the side of the triangle). Calculate the minimum length of the shorter side of the triangle.

Input

First line contains one integer n (1 ≤ n ≤ 10^5).

Each of the next n lines contains two integers x_i and y_i (1 ≤ x_i,y_i ≤ 10^9).

Output

Print the minimum length of the shorter side of the triangle. It can be proved that it's always an integer.

Examples

Input

3
1 1
1 2
2 1

Output

3

Input

4
1 1
1 2
2 1
2 2

Output

4

Note

Illustration for the first example: <image>

Illustration for the second example: <image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("-O2")
const int LIM = 5e5 + 5, MOD = 1e9 + 7;
int t, n, m, k, x, y;
bool compare(pair<int, int> p1, pair<int, int> p2) {
  return p1.second < p2.second;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (x + y > ans) ans = x + y;
  }
  cout << ans;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction.

More specifically, in one move, he can go from coordinate x to x + D or x - D.

He wants to make K moves so that the absolute value of the coordinate of the destination will be the smallest possible.

Find the minimum possible absolute value of the coordinate of the destination.

Constraints

* -10^{15} \leq X \leq 10^{15}
* 1 \leq K \leq 10^{15}
* 1 \leq D \leq 10^{15}
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

X K D

Output

Print the minimum possible absolute value of the coordinate of the destination.

Examples

Input

6 2 4

Output

2

Input

7 4 3

Output

1

Input

10 1 2

Output

8

Input

1000000000000000 1000000000000000 1000000000000000

Output

1000000000000000

### Response

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

long long x, k, d, one = 1;

int main() {
  cin >> x >> k >> d;
  if (x < 0) one *= -1, x *= -1;
  long long now = min(x / d, k);
  x -= d * now;
  k -= now;
  k %= 2;
  if (k & 1) x -= d;
  cout << abs(x) << endl;
  return 0;
}
```


### Prompt

Generate a cpp solution to the following problem:

This is an interactive problem

Ginny is taking an exam on game theory. The professor is tired of hearing the same answers over and over again, so he offered Ginny to play a game instead of a standard exam.

As known from the course, a combinatorial game on a graph with multiple starting positions is a game with a directed graph and multiple starting vertices holding a token each. Two players take turns moving one of the tokens along the graph edges on each turn. The player who can't make a move loses the game. If both players can play an infinitely long game without losing, a draw is called.

For the exam, the professor drew an acyclic directed graph and chose one of its vertices. Ginny needs to guess the vertex the professor chose. To do so, Ginny can choose a multiset of vertices S several times and ask the professor: "If I put one token in each vertex of the given graph for each occurrence of the vertex in the multiset S, and then one more in the selected vertex, what would be the result of the combinatorial game?".

Having given the task, the professor left the room to give Ginny some time to prepare for the game. Ginny thinks that she's being tricked because the problem is impossible to solve. Therefore, while the professor is away, she wants to add or remove several edges from the graph. Even though the original graph was acyclic, edges could be added to the graph to make cycles appear.

Interaction

In this task, interaction consists of several phases.

In the first phase, the interactor gives as an input to your program three integers N (1 ≤ N ≤ 1000), M (0 ≤ M ≤ 100 000), T (1 ≤ T ≤ 2000): the number of vertices and edges in the initial graph, and the number of times Ginny has to guess the chosen vertex. The next M lines contain pairs of vertices a_i b_i (1 ≤ a_i, b_i ≤ N): beginning and end of corresponding graph edges. The graph is guaranteed to be acyclic and all of its edges to be distinct.

The solution should print an integer K (0 ≤ K ≤ 4242): the number of edges to change in the graph. The next K lines should contain either "+ a_i b_i" or "- a_i b_i": the beginning and the end of an edge that Ginny has to add or remove accordingly. You are allowed to add preexisting edges to the graph. Operations are performed in the order of appearance, so Ginny is allowed to remove an edge added by the solution. You can only remove an existing edge. The operations can create cycles in the graph.

The next T phases are dedicated to guessing the chosen vertices. In each phase, the solution can make at most 20 queries and then print the answer. To query a multiset S, the solution should print "? |S|~S_1~S_2~...~S_{|S|}". The total size of all multisets in a single phase should not exceed 20. The interactor will reply with one of the following words:

  * "Win", if the winner of a combinatorial game with tokens in multiset S and the selected vertex is the first player.
  * "Lose", if the winner of a combinatorial game with tokens in multiset S and the selected vertex is the second player.
  * "Draw", if a combinatorial game with tokens in multiset S and selected vertex ends in a draw.
  * "Slow", if the solution made a 21-st request, or the total size of all multisets in a single phase exceeded 20. In this case, the solution should terminate and receive Wrong Answer verdict.

As soon as the selected vertex is guessed, that solution should print "! v". If the chosen vertex is guessed correctly, the interactor will print Correct and the solution should either move on to the next phase of guessing or finish its execution if it's the last phase. Otherwise, the interactor will print Wrong, which means that the solution should terminate and will receive the Wrong Answer verdict.

The interactor can change the chosen vertex based on graph changes and solution actions, but at every given moment of time, at least one vertex that corresponds to all given interactor answers will exist.

Hack format

Hacks have the following extra limitations:

  * T = 1
  * you need to specify a single vertex, chosen by the interactor.

Hack test format. The first line of input contains three integers N~M~1. The next M lines on input contain edge description in the same format as in the input. The next line contains a single integer v: the number of the chosen vertex. The hack will be successful even if the solution guesses the vertex right, but the vertex will not be the single one to match all performed queries.

Example

Input

3 2 3
1 2
2 3

Lose

Correct

Win

Correct

Draw

Correct

Output

6
+ 2 2
- 1 2
+ 2 3
- 2 2
+ 3 1
+ 2 2
? 0

! 1

? 1 2

! 3

? 5 1 3 1 3 1

! 2

Note

In the sample test, the empty lines represent waiting for the input by the other side of the interaction. The real interactor will not print empty lines, and the solution should not print them either.

<image>

The image above illustrates the sample test. Added edges are coloured in red, and the removed edges are drawn with a dotted line. Three guessing phases denote different ways of getting the answer.

  * If the solution will query just the chosen vertex, the interactor will return the result of the game in that vertex. The first player loses only if the chosen vertex has the number 1.
  * If we add a single vertex 2 to the chosen vertex, then if the chosen vertex is either 1 or 2, the game should end in a draw. If vertex number 3 is chosen, then the first player wins.
  * If we place three tokens in vertex 1 and two tokens in vertex 3, then the game will end in a draw only if vertex 2 is chosen. If the professor chose vertex 3, the first player will win, if the professor chose vertex 1, then the second player will win.

In the first test, the interactor will behave as if the chosen vertices are the same as those in the example above. However, if you will try to guess the answer before it limits the options to one single vertex, the solution will get "Wrong Answer", even if you print the same answers. That's because the interactor is allowed to change the chosen vertex if it's consistent with the previous query answers.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
const long long mod = 998244353;
const long long Inf = 1e18;
int inv[1 << 20], cnt, f[N], val[N], mini, id[N];
vector<int> g[N];
bool vis[N];
void dfs(int u) {
  vis[u] = 1;
  for (auto v : g[u]) {
    if (!vis[v]) dfs(v);
    val[u] += val[v] * f[v];
  }
  if (cnt < mini) {
    val[u] = 1 << cnt;
    f[u] = 1;
  }
  id[cnt] = u;
  ++cnt;
}
void add(int u, int v, int c) {
  if (c)
    printf("+ %d %d\n", u, v);
  else
    printf("- %d %d\n", u, v);
}
void check(int u, int i) {
  if (val[u] & (1 << i))
    printf("- %d %d\n", u, id[i]);
  else
    printf("+ %d %d\n", u, id[i]);
}
int main() {
  int n, m, T;
  scanf("%d%d%d", &n, &m, &T);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
  }
  mini = min(n, 20);
  for (int i = (1); i < (n + 1); ++i) {
    if (!vis[i]) dfs(i);
  }
  printf("%d\n", (mini - 1) * mini / 2 + 4 * (n - mini));
  for (int i = (0); i < (n); ++i) {
    if (i < mini) {
      for (int j = (0); j < (i); ++j) add(id[i], id[j], 1);
    } else {
      add(id[i], id[i], 1);
      int u = id[i];
      int ok = 0;
      for (int j = (0); j < (mini); ++j) {
        for (int k = (j + 1); k < (mini); ++k) {
          for (int l = (k + 1); l < (mini); ++l) {
            int mask = val[u] ^ (1 << j) ^ (1 << k) ^ (1 << l);
            if (!ok && !inv[mask]) {
              ok = 1;
              inv[mask] = u;
              check(u, j);
              check(u, k);
              check(u, l);
            }
          }
        }
      }
    }
  }
  char s[10];
  while (T--) {
    int ans = 0, ok = 0;
    for (int i = (0); i < (mini); ++i) {
      printf("? 1 %d\n", id[i]);
      fflush(stdout);
      scanf("%s", s);
      if (s[0] == 'W') ans |= 1 << i;
      if (s[0] == 'L') ok = id[i];
    }
    ans = inv[ans];
    if (ok) ans = ok;
    printf("! %d\n", ans);
    fflush(stdout);
    scanf("%s", s);
  }
}

```


### Prompt

Create a solution in Cpp for the following problem:

Example

Input

anagram
grandmother

Output

4

### Response

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int BASE = 4200;
const int MOD = 1e9 + 9;
const int MOD2 = 1e9 + 7;
int pot[26], pot2[26];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    pot[0] = pot2[0] = 1;
    fori(i, 1, 26) {
        pot[i] = (1LL * pot[i - 1] * BASE) % MOD;
        pot2[i] = (1LL * pot2[i - 1] * BASE) % MOD2;
    }
    string a, b;
    cin >> a >> b;
    vector<ii> all;
    fori(i, 0, a.size()) {
        int h = 0, h2 = 0;
        fori(j, i, a.size()) {
            h = (h + pot[a[j] - 'a']) % MOD;
            h2 = (h2 + pot2[a[j] - 'a']) % MOD2;
            all.emplace_back(h, h2);
        }
    }
    sort(all.begin(), all.end());
    all.erase(unique(all.begin(), all.end()), all.end());
    int ans = 0;
    fori(i, 0, b.size()) {
        int h = 0, h2 = 0;
        fori(j, i, b.size()) {
            h = (h + pot[b[j] - 'a']) % MOD;
            h2 = (h2 + pot2[b[j] - 'a']) % MOD2;
            auto it = lower_bound(all.begin(), all.end(), ii(h, h2));
            if(it != all.end() && *it == ii(h, h2)) {
                ans = max(ans, j - i + 1);
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.

Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced. So the word corrector works in such a way: as long as there are two consecutive vowels in the word, it deletes the first vowel in a word such that there is another vowel right before it. If there are no two consecutive vowels in the word, it is considered to be correct.

You are given a word s. Can you predict what will it become after correction?

In this problem letters a, e, i, o, u and y are considered to be vowels.

Input

The first line contains one integer n (1 ≤ n ≤ 100) — the number of letters in word s before the correction.

The second line contains a string s consisting of exactly n lowercase Latin letters — the word before the correction.

Output

Output the word s after the correction.

Examples

Input

5
weird

Output

werd

Input

4
word

Output

word

Input

5
aaeaa

Output

a

Note

Explanations of the examples:

  1. There is only one replace: weird <image> werd;
  2. No replace needed since there are no two consecutive vowels;
  3. aaeaa <image> aeaa <image> aaa <image> aa <image> a.

### Response

```cpp
#include <bits/stdc++.h>
bool isvowel(char c) {
  return c == 'e' || c == 'y' || c == 'u' || c == 'i' || c == 'o' || c == 'a';
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  std::cerr.tie(0);
  int n, k;
  std::cin >> n;
  std::string st;
  std::cin >> st;
  bool prev = false;
  for (size_t it = 0; it < st.size(); ++it) {
    if (!prev || prev && !isvowel(st[it])) {
      std::cout << st[it];
    }
    prev = isvowel(st[it]);
  }
}

```