### Prompt

Construct a Cpp code solution to the problem outlined:

<image>

Input

The input contains two integers row, col (0 ≤ row, col ≤ 63), separated by a single space.

Output

Output "IN" or "OUT".

Examples

Input

0 0

Output

OUT

Input

27 0

Output

IN

Input

0 27

Output

OUT

Input

27 27

Output

IN

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<int> img{
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1,
    0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
    1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0,
    0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0,
    0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
int main() {
  int row, col;
  cin >> row >> col;
  if (img[row * 64 + col]) {
    cout << "IN\n";
  } else {
    cout << "OUT\n";
  }
}

```


### Prompt

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

...Mike the TV greets you again!

Tired of the monotonous furniture? Sick of gray routine? Dreaming about dizzying changes in your humble abode? We have something to offer you!

This domino carpet for only $99.99 will change your life! You can lay it on the floor, hang it on the wall or even on the ceiling! Among other things ...

Having watched the commercial, virus Hexadecimal also wanted to get a Domino Carpet and wanted badly to be photographed in front of it. But of course, a virus will never consent to buying a licensed Carpet! So she ordered a truck of dominoes and decided to make such a Carpet herself.

The original Domino Carpet is a field of squares n × m in size. Each square is half of a domino, and can be rotated either vertically or horizontally, independently from its neighbors. Vertically rotated domino halves look like this:

<image>

And horizontally rotated halves look like this:

<image>

Notice, that some halves looks the same in both rotations, but other halves differ.

Dominoes bought by Hexadecimal are represented by uncuttable chips 1 × 2 in size, which can be laid either vertically or horizontally. If the chip is laid vertically, then both of it's halves should be laid vertically orientated; if the chip is laid horizontally, then both of it's halves should be laid horizontally.

The samples of valid and invalid dominoes laid vertically and horizontally are:

<image>

Virus Hexadecimal assembles her own Domino Carpet so that the following conditions are satisfied:

  * each carpet square is covered by a domino chip, i.e. there are no empty squares;
  * all domino chips lie entirely within the carpet and don't overlap with each other;
  * if there is a horizontal domino chip with its left half in column j then there are no horizontal domino chips with their left halves in columns j - 1 or j + 1.

Before starting to assemble her own Domino Carpet, the virus wants to know the number of ways to achieve the intended purpose modulo 109 + 7.

You can assume that the virus has an infinitely large number of dominoes of each type.

Input

The first line contains two integers n and m, separated by a space — the size of the Domino Carpet (1 ≤ n, m ≤ 250). Next 4n + 1 lines contain 4m + 1 symbols.

Each square of the Domino Carpet, which is a domino half, is described by a 3 × 3 square. Symbol 'O' in this square indicates the presence of a point, symbol '.' — its absence.

Each 3 × 3 square is delineated from adjacent squares by symbols '#' as shown in the examples.

It is guaranteed that every box describes the correct half of a domino.

In all pretests the Domino Carpets have the size of 2 × 2 and 4 × 4.

Output

Print a single number, the number of ways to assemble the Domino Carpet modulo 109 + 7, using only standard dominoes of size 1 × 2.

Examples

Input

3 4
#################
#O..#...#O.O#...#
#.O.#.O.#.O.#...#
#..O#...#O.O#...#
#################
#O.O#OOO#O.O#...#
#.O.#...#...#.O.#
#O.O#OOO#O.O#...#
#################
#O.O#...#O.O#...#
#...#...#...#.O.#
#O.O#...#O.O#...#
#################

Output

3

Input

2 2
#########
#O.O#O.O#
#.O.#...#
#O.O#O.O#
#########
#...#O.O#
#...#...#
#...#O.O#
#########

Output

2

Input

2 2
#########
#..O#O..#
#...#...#
#O..#..O#
#########
#O..#..O#
#...#...#
#..O#O..#
#########

Output

0

Note

A note to the first example: all correct ways to make Domino Carpet are represented below:

<image>

And this way is incorrect:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
char in[1002][1002];
long long dp[251];
int vt[] = {0000, 0020, 0104, 0124, 0505, 0525, 0555};
int hz[] = {0000, 0020, 0401, 0421, 0505, 0525, 0707};
int ct(int i, int j) {
  int u = 0;
  int k = 0;
  for (int a = i * 4 + 1; a < i * 4 + 4; a++) {
    for (int b = j * 4 + 1; b < j * 4 + 4; b++) {
      if (in[a][b] == 'O') {
        u |= (1 << k);
      }
      k++;
    }
  }
  int r = 0;
  for (int k = 0; k < 7; k++) {
    if (u == vt[k]) {
      r |= 1;
    }
    if (u == hz[k]) {
      r |= 2;
    }
  }
  return r;
}
bool check(int i, int j, int p, int q) {
  auto r = ct(i, j);
  auto s = ct(p, q);
  if (j == q) {
    return r & s & 1;
  } else {
    return r & s & 2;
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < 4 * n + 1; i++) {
    scanf("%s", in[i]);
  }
  int v2[251] = {};
  dp[0] = 1;
  for (int j = 0; j < m; j++) {
    if (n % 2 == 0) {
      bool ok = true;
      for (int i = 0; i < n; i += 2) {
        if (!check(i, j, i + 1, j)) {
          ok = false;
          break;
        }
      }
      if (ok) {
        dp[j + 1] += dp[j];
        dp[j + 1] %= M;
        v2[j] = 1;
      }
    }
    if (j == 0) {
      continue;
    }
    long long dp2[251] = {};
    dp2[0] = 1;
    for (int i = 0; i < n; i++) {
      if (check(i, j - 1, i, j)) {
        dp2[i + 1] += dp2[i];
        dp2[i + 1] %= M;
      }
      if (i == 0) {
        continue;
      }
      if (check(i, j - 1, i - 1, j - 1) && check(i, j, i - 1, j)) {
        dp2[i + 1] += dp2[i - 1];
        dp2[i + 1] %= M;
      }
    }
    if (v2[j] && v2[j - 1]) {
      dp2[n] += M - 1;
      dp2[n] %= M;
    }
    dp[j + 1] += dp[j - 1] * dp2[n] % M;
    dp[j + 1] %= M;
  }
  printf("%lld\n", dp[m]);
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

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

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

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

Input

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

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

Output

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

### Response

```cpp
#include <bits/stdc++.h>
signed main() {
  return puts(
             "0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n1\n1\n1\n0\n1\n1\n1"
             "\n1\n1\n0\n1\n0\n1\n1\n1"),
         0;
}

```


### Prompt

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

Now that Heidi knows that she can assign Rebel spaceships to bases (recall the easy subtask), she is asking you: how exactly to do this? Now, given positions of N spaceships and N bases on a plane, your task is to connect spaceships and bases with line segments so that:

  * The segments do not intersect.
  * Such a connection forms a perfect matching.

Input

The first line contains an integer N (1 ≤ n ≤ 10000). For 1 ≤ i ≤ N, the i + 1-th line contains two integers xi and yi (|xi|, |yi| ≤ 10000) denoting the coordinates of the i-th spaceship. The following N lines have the same format, denoting the position of bases. It is guaranteed that no two points coincide and no three points are on the same line.

Output

The output should have N lines. The i-th line should contain an integer pi, the index of the base to which the i-th spaceship is connected. The sequence p1, ..., pN should form a permutation of 1, ..., N.

It is guaranteed that a solution exists. If there are multiple solutions, you can output any one of them.

Example

Input

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

Output

4
1
2
3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f;
const long long MOD = 1000000007;
const int IT_MAX = 1 << 17;
const int MX = 1000005;
pair<int, int> operator-(pair<int, int> a, pair<int, int> b) {
  return pair<int, int>(a.first - b.first, a.second - b.second);
}
long long operator/(pair<int, int> a, pair<int, int> b) {
  return (long long)a.first * b.second - (long long)a.second * b.first;
}
struct point {
  point() {}
  point(pair<int, int> p, int v) : p(p), v(v) {}
  pair<int, int> p;
  int v;
};
int N;
vector<point> V;
int A[30030];
int ans[30030];
void Do(vector<point> &X) {
  if ((int)(X).size() == 0) return;
  if ((int)(X).size() == 2) {
    if (X[0].v > 0)
      ans[X[0].v] = -X[1].v;
    else
      ans[X[1].v] = -X[0].v;
    return;
  }
  int a = rand() % 10000 + 1;
  int b = rand() % 20000 - 10000;
  int fv = 0, m = (int)(X).size();
  for (int i = 1; i < m; i++) {
    long long vi = (long long)(X[i].p.first - X[fv].p.first) * a +
                   (long long)(X[i].p.second - X[fv].p.second) * b;
    if (vi < 0) fv = i;
  }
  swap(X[0], X[fv]);
  for (int i = m - 1; i >= 0; i--) X[i].p = X[i].p - X[0].p;
  sort(X.begin() + 1, X.end(),
       [](point &a, point &b) { return a.p / b.p > 0; });
  int cf = (X[0].v > 0 ? 1 : -1);
  A[0] = cf;
  int tar = m / 2, f = -1;
  for (int i = 1; i < m; i++) {
    int val = 0;
    if (X[i].v > 0)
      val = 1;
    else
      val = -1;
    A[i] = A[i - 1] + val;
    if (A[i] == 0 && val != cf) {
      if (f == -1 || abs(tar - f) > abs(tar - i)) f = i;
    }
  }
  if (X[0].v > 0)
    ans[X[0].v] = -X[f].v;
  else
    ans[X[f].v] = -X[0].v;
  vector<point> NX;
  if (f > tar) {
    for (int i = m - 1; i > f; i--) NX.push_back(X[i]);
    for (int i = 0; i < f - 1; i++) X[i] = X[i + 1];
    while ((int)(X).size() > f - 1) X.pop_back();
    Do(X);
    Do(NX);
  } else {
    for (int i = 1; i < f; i++) NX.push_back(X[i]);
    for (int i = 0; i < m - f - 1; i++) X[i] = X[i + f + 1];
    while ((int)(X).size() > m - f - 1) X.pop_back();
    Do(X);
    Do(NX);
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    V.emplace_back(pair<int, int>(x, y), i);
  }
  for (int i = 1; i <= N; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    V.emplace_back(pair<int, int>(x, y), -i);
  }
  Do(V);
  for (int i = 1; i <= N; i++) printf("%d\n", ans[i]);
  return 0;
}

```


### Prompt

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

You are given a set of n elements indexed from 1 to n. The weight of i-th element is wi. The weight of some subset of a given set is denoted as <image>. The weight of some partition R of a given set into k subsets is <image> (recall that a partition of a given set is a set of its subsets such that every element of the given set belongs to exactly one subset in partition).

Calculate the sum of weights of all partitions of a given set into exactly k non-empty subsets, and print it modulo 109 + 7. Two partitions are considered different iff there exist two elements x and y such that they belong to the same set in one of the partitions, and to different sets in another partition.

Input

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 2·105) — the number of elements and the number of subsets in each partition, respectively.

The second line contains n integers wi (1 ≤ wi ≤ 109)— weights of elements of the set.

Output

Print one integer — the sum of weights of all partitions of a given set into k non-empty subsets, taken modulo 109 + 7.

Examples

Input

4 2
2 3 2 3

Output

160

Input

5 2
1 2 3 4 5

Output

645

Note

Possible partitions in the first sample:

  1. {{1, 2, 3}, {4}}, W(R) = 3·(w1 + w2 + w3) + 1·w4 = 24;
  2. {{1, 2, 4}, {3}}, W(R) = 26;
  3. {{1, 3, 4}, {2}}, W(R) = 24;
  4. {{1, 2}, {3, 4}}, W(R) = 2·(w1 + w2) + 2·(w3 + w4) = 20;
  5. {{1, 3}, {2, 4}}, W(R) = 20;
  6. {{1, 4}, {2, 3}}, W(R) = 20;
  7. {{1}, {2, 3, 4}}, W(R) = 26;

Possible partitions in the second sample:

  1. {{1, 2, 3, 4}, {5}}, W(R) = 45;
  2. {{1, 2, 3, 5}, {4}}, W(R) = 48;
  3. {{1, 2, 4, 5}, {3}}, W(R) = 51;
  4. {{1, 3, 4, 5}, {2}}, W(R) = 54;
  5. {{2, 3, 4, 5}, {1}}, W(R) = 57;
  6. {{1, 2, 3}, {4, 5}}, W(R) = 36;
  7. {{1, 2, 4}, {3, 5}}, W(R) = 37;
  8. {{1, 2, 5}, {3, 4}}, W(R) = 38;
  9. {{1, 3, 4}, {2, 5}}, W(R) = 38;
  10. {{1, 3, 5}, {2, 4}}, W(R) = 39;
  11. {{1, 4, 5}, {2, 3}}, W(R) = 40;
  12. {{2, 3, 4}, {1, 5}}, W(R) = 39;
  13. {{2, 3, 5}, {1, 4}}, W(R) = 40;
  14. {{2, 4, 5}, {1, 3}}, W(R) = 41;
  15. {{3, 4, 5}, {1, 2}}, W(R) = 42.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool ckmax(T& x, T y) {
  return x < y ? x = y, 1 : 0;
}
template <class T>
bool ckmin(T& x, T y) {
  return x > y ? x = y, 1 : 0;
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = 0;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
const int N = 200005;
inline int qpow(int n, int k) {
  if (k < 0) return 0;
  int res = 1;
  for (; k; k >>= 1, n = 1ll * n * n % 1000000007)
    if (k & 1) res = 1ll * n * res % 1000000007;
  return res;
}
int n, k, sum, fac[N], ifc[N], ans;
int comb(int n, int m) {
  return n < m ? 0
               : 1ll * fac[n] * ifc[m] % 1000000007 * ifc[n - m] % 1000000007;
}
signed main() {
  n = read(), k = read() - 1;
  for (int i = 1, iend = n; i <= iend; ++i) sum = (sum + read()) % 1000000007;
  fac[0] = 1;
  for (int i = 1, iend = k; i <= iend; ++i)
    fac[i] = 1ll * i * fac[i - 1] % 1000000007;
  ifc[k] = qpow(fac[k], 1000000007 - 2);
  for (int i = k - 1, iend = 0; i >= iend; --i)
    ifc[i] = 1ll * ifc[i + 1] * (i + 1) % 1000000007;
  for (int i = 0; i <= k; ++i) {
    int tmp =
        1ll * comb(k, i) *
        (qpow(1 + i, n - 1) + 1ll * (n - 1) * qpow(1 + i, n - 2) % 1000000007) %
        1000000007;
    (k - i)& 1 ? ans = (ans + 1000000007 - tmp) % 1000000007
               : ans = (ans + tmp) % 1000000007;
  }
  ans = 1ll * ans * ifc[k] % 1000000007 * sum % 1000000007;
  cout << ans << '\n';
}

```


### Prompt

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

Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.

We call the man with a number a a 1-ancestor of the man with a number b, if the man with a number a is a direct ancestor of the man with a number b.

We call the man with a number a a k-ancestor (k > 1) of the man with a number b, if the man with a number b has a 1-ancestor, and the man with a number a is a (k - 1)-ancestor of the 1-ancestor of the man with a number b.

In the tree the family ties do not form cycles. In other words there isn't a person who is his own direct or indirect ancestor (that is, who is an x-ancestor of himself, for some x, x > 0).

We call a man with a number a the k-son of the man with a number b, if the man with a number b is a k-ancestor of the man with a number a.

Polycarpus is very much interested in how many sons and which sons each person has. He took a piece of paper and wrote m pairs of numbers vi, ki. Help him to learn for each pair vi, ki the number of distinct names among all names of the ki-sons of the man with number vi.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≤ ri ≤ n), where si is the name of the man with a number i, and ri is either the number of the direct ancestor of the man with a number i or 0, if the man with a number i has no direct ancestor.

The next line contains a single integer m (1 ≤ m ≤ 105) — the number of Polycarpus's records. Next m lines contain space-separated pairs of integers. The i-th line contains integers vi, ki (1 ≤ vi, ki ≤ n).

It is guaranteed that the family relationships do not form cycles. The names of all people are non-empty strings, consisting of no more than 20 lowercase English letters.

Output

Print m whitespace-separated integers — the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.

Examples

Input

6
pasha 0
gerald 1
gerald 1
valera 2
igor 3
olesya 1
5
1 1
1 2
1 3
3 1
6 1

Output

2
2
0
1
0

Input

6
valera 0
valera 1
valera 1
gerald 0
valera 4
kolya 4
7
1 1
1 2
2 1
2 2
4 1
5 1
6 1

Output

1
0
0
0
2
0
0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int maxm = 200005;
const int inf = 1e9 + 7;
int rt[maxn * 40], ls[maxn * 40], rs[maxn * 40], sz[maxn * 40];
int a[maxn], n, q, ct, fa[maxn][25], dep[maxn], L[maxn], R[maxn];
int id[maxn], rid[maxn], ctmp, pos[maxn], d[maxn], val[maxn];
int head[maxn], to[maxm], nex[maxm], cnt;
void add(int u, int v) {
  to[cnt] = v;
  nex[cnt] = head[u];
  head[u] = cnt++;
}
unordered_map<string, int> mp;
void update(int &now, int las, int l, int r, int pos, int v) {
  now = ++ct;
  ls[now] = ls[las];
  rs[now] = rs[las];
  sz[now] = sz[las] + v;
  if (l == r) return;
  int mid = (l + r) / 2;
  if (pos <= mid)
    update(ls[now], ls[las], l, mid, pos, v);
  else
    update(rs[now], rs[las], mid + 1, r, pos, v);
}
int query(int now, int las, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr) {
    return sz[now] - sz[las];
  }
  int mid = (l + r) / 2, ret = 0;
  if (ql <= mid) ret += query(ls[now], ls[las], l, mid, ql, qr);
  if (qr > mid) ret += query(rs[now], rs[las], mid + 1, r, ql, qr);
  return ret;
}
int gain(string s) {
  if (!mp[s]) mp[s] = ++ctmp;
  return mp[s];
}
void bfs() {
  queue<int> Q;
  Q.push(1);
  int tmp = 0;
  while (!Q.empty()) {
    int v = Q.front();
    Q.pop();
    id[v] = ++tmp;
    a[tmp] = val[v];
    rid[tmp] = v;
    for (int i = head[v], x = to[i]; ~i; i = nex[i], x = to[i]) {
      Q.push(x);
    }
  }
}
void dfs(int u, int dep) {
  d[u] = dep;
  L[dep] = min(L[dep], id[u]);
  R[dep] = max(R[dep], id[u]);
  for (int i = head[u]; ~i; i = nex[i]) {
    fa[to[i]][0] = u;
    dfs(to[i], dep + 1);
  }
}
void build() {
  for (int j = 1; (1 << j) <= n; j++)
    for (int i = 1; i <= n; i++) fa[i][j] = fa[fa[i][j - 1]][j - 1];
  for (int i = 1; i <= n; i++) {
    update(rt[i], rt[i - 1], 1, n, i, 1);
    if (pos[a[i]]) {
      int tmp = rt[i];
      update(rt[i], tmp, 1, n, pos[a[i]], -1);
    }
    pos[a[i]] = i;
  }
}
int getfa(int u, int k) {
  for (int i = 21; i >= 0; i--) {
    if ((k & (1 << i)) == (1 << i)) {
      u = fa[u][i];
    }
  }
  return u;
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d", &n);
  for (int i = (int)2; i <= (int)n + 1; i++) {
    string s;
    int ff;
    cin >> s >> ff;
    int ID = gain(s);
    val[i] = ID;
    ff++;
    add(ff, i);
  }
  n++;
  bfs();
  for (int i = (int)1; i <= (int)n; i++) L[i] = inf, R[i] = 0;
  dfs(1, 1);
  build();
  scanf("%d", &q);
  while (q--) {
    int p, k;
    scanf("%d%d", &p, &k);
    p++;
    int aimd = d[p] + k, l, r, aiml = -1, aimr = -1;
    l = L[aimd], r = R[aimd];
    while (l <= r) {
      int mid = (l + r) / 2;
      int faa = getfa(rid[mid], k);
      if (id[faa] >= id[p])
        aiml = mid, r = mid - 1;
      else
        l = mid + 1;
    }
    l = L[aimd], r = R[aimd];
    while (l <= r) {
      int mid = (l + r) / 2;
      int faa = getfa(rid[mid], k);
      if (id[faa] <= id[p])
        aimr = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    if (getfa(rid[aiml], k) != p || aiml < L[aimd] || aiml > R[aimd] ||
        aimr < L[aimd] || aimr > R[aimd]) {
      printf("0\n");
      continue;
    }
    printf("%d\n", query(rt[aimr], 0, 1, n, aiml, aimr));
  }
  return 0;
}

```


### Prompt

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

Little Chris is having a nightmare. Even in dreams all he thinks about is math.

Chris dreams about m binary strings of length n, indexed with numbers from 1 to m. The most horrifying part is that the bits of each string are ordered in either ascending or descending order. For example, Chris could be dreaming about the following 4 strings of length 5:

<image>

The Hamming distance H(a, b) between two strings a and b of length n is the number of positions at which the corresponding symbols are different.

Сhris thinks that each three strings with different indices constitute a single triple. Chris's delusion is that he will wake up only if he counts the number of such string triples a, b, c that the sum H(a, b) + H(b, c) + H(c, a) is maximal among all the string triples constructed from the dreamed strings.

Help Chris wake up from this nightmare!

Input

The first line of input contains two space-separated integers n and m (1 ≤ n ≤ 109; 3 ≤ m ≤ 105), the length and the number of strings. The next m lines contain the description of the strings. The i-th line contains two space-separated integers si and fi (0 ≤ si ≤ 1; 1 ≤ fi ≤ n), the description of the string with index i; that means that the first fi bits of the i-th string are equal to si, and the remaining n - fi bits are equal to 1 - si. There can be multiple equal strings in Chris's dream.

Output

Output a single integer, the number of such string triples among the given that the sum of the Hamming distances between the strings of the triple is maximal.

Examples

Input

5 4
0 3
0 5
1 4
1 5

Output

3

Input

10 4
1 5
0 5
0 5
1 5

Output

4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <int POS, class TUPLE>
void deploy(std::ostream &os, const TUPLE &tuple) {}
template <int POS, class TUPLE, class H, class... Ts>
void deploy(std::ostream &os, const TUPLE &t) {
  os << (POS == 0 ? "" : ", ") << get<POS>(t);
  deploy<POS + 1, TUPLE, Ts...>(os, t);
}
template <class... Ts>
std::ostream &operator<<(std::ostream &os, const std::tuple<Ts...> &t) {
  os << "(";
  deploy<0, std::tuple<Ts...>, Ts...>(os, t);
  os << ")";
  return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, std::vector<T> &v) {
  int remain = v.size();
  os << "{";
  for (auto e : v) os << e << (--remain == 0 ? "" : ", ");
  os << "}";
  return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, std::set<T> &v) {
  int remain = v.size();
  os << "{";
  for (auto e : v) os << e << (--remain == 0 ? "" : ", ");
  os << "}";
  return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, std::queue<T> &q) {
  os << "{";
  for (; !q.empty(); q.pop()) {
    os << q.front() << (q.size() != 1 ? ", " : "");
  }
  os << "}";
  return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, std::priority_queue<T> &q) {
  os << "{";
  for (; !q.empty(); q.pop()) {
    os << q.top() << (q.size() != 1 ? ", " : "");
  }
  os << "}";
  return os;
}
template <class T, class K>
std::ostream &operator<<(std::ostream &os, std::pair<T, K> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <class T, class K>
std::ostream &operator<<(std::ostream &os, std::map<T, K> &mp) {
  int remain = mp.size();
  os << "{";
  for (auto e : mp)
    os << "(" << e.first << " -> " << e.second << ")"
       << (--remain == 0 ? "" : ", ");
  os << "}";
  return os;
}
template <class T, class K>
std::ostream &operator<<(std::ostream &os, std::unordered_map<T, K> &mp) {
  int remain = mp.size();
  os << "{";
  for (auto e : mp)
    os << "(" << e.first << " -> " << e.second << ")"
       << (--remain == 0 ? "" : ", ");
  os << "}";
  return os;
}
const int64_t MAX = 100500;
int64_t type[MAX], L[MAX];
int64_t n, m;
void cutLeftRight() {
  for (int64_t i = 0; i < ((int64_t)(n)); ++i)
    if (type[i] == 0) return;
  int64_t maxi;
  maxi = L[0];
  for (int64_t i = 0; i < ((int64_t)(n)); ++i) maxi = min(maxi, L[i]);
  for (int64_t i = 0; i < ((int64_t)(n)); ++i) L[i] -= maxi;
  m -= maxi;
  maxi = m - L[0];
  for (int64_t i = 0; i < ((int64_t)(n)); ++i) maxi = min(maxi, m - L[i]);
  m -= maxi;
}
void cutMiddle() {
  int64_t maxi0 = 0;
  int64_t mini1 = m;
  for (int64_t i = 0; i < ((int64_t)(n)); ++i) {
    if (type[i] == 0)
      maxi0 = max(maxi0, L[i]);
    else
      mini1 = min(mini1, L[i]);
  }
  if (maxi0 < mini1) {
    for (int64_t i = 0; i < ((int64_t)(n)); ++i)
      if (type[i] == 1) L[i] -= mini1 - maxi0;
    m -= mini1 - maxi0;
  }
}
int64_t choose3(int64_t n) { return n * (n - 1) * (n - 2) / 6; }
void cal(int64_t &total) {
  int64_t cnt = 0;
  for (int64_t i = 0; i < ((int64_t)(n)); ++i)
    if (type[i] == 1) cnt++;
  total -= choose3(cnt);
  vector<tuple<int64_t, int64_t>> v;
  for (int64_t i = 0; i < ((int64_t)(n)); ++i)
    v.push_back(make_tuple(type[i], L[i]));
  sort((v).begin(), (v).end());
  int64_t middle = n;
  for (int64_t t = n - 1; 0 <= t; --t)
    if (get<0>(v[t]) == 1) middle = t;
  int64_t index0 = 0, index1 = middle;
  while (index0 < middle && index1 < n) {
    int64_t mini = min(get<1>(v[index0]), get<1>(v[index1]));
    int64_t rem0 = index0;
    int64_t new0 = 0;
    while (index0 < middle && get<1>(v[index0]) == mini) ++index0, ++new0;
    while (index1 < n && get<1>(v[index1]) == mini) ++index1;
    int64_t rem1 = n - index1;
    total -= rem0 * new0 * rem1;
    total -= new0 * (new0 - 1) / 2 * rem1;
    total -= new0 * rem1 * (rem1 - 1) / 2;
  }
}
int64_t run() {
  for (int64_t step = 0; step < ((int64_t)(2)); ++step) {
    for (int64_t i = 0; i < ((int64_t)(n)); ++i) type[i] = 1 - type[i];
    cutLeftRight();
  }
  for (int64_t step = 0; step < ((int64_t)(2)); ++step) {
    for (int64_t i = 0; i < ((int64_t)(n)); ++i) type[i] = 1 - type[i];
    cutMiddle();
  }
  if (m == 0) return choose3(n);
  for (int64_t i = 0; i < ((int64_t)(n)); ++i)
    if (L[i] == 0) type[i] = 1 - type[i], L[i] = m;
  int64_t total = choose3(n);
  for (int64_t step = 0; step < ((int64_t)(2)); ++step) {
    for (int64_t i = 0; i < ((int64_t)(n)); ++i) type[i] = 1 - type[i];
    cal(total);
  }
  return total;
}
int64_t brute() {
  int64_t maxi = -1, cnt = 0;
  for (int64_t i = 0; i < ((int64_t)(n)); ++i)
    for (int64_t j = 0; j < ((int64_t)(i)); ++j)
      for (int64_t k = 0; k < ((int64_t)(j)); ++k) {
        int64_t t = 0;
        for (int64_t l = 0; l < ((int64_t)(m)); ++l) {
          int64_t a = 0;
          if ((l < L[i]) ^ (type[i] == 0)) ++a;
          if ((l < L[j]) ^ (type[j] == 0)) ++a;
          if ((l < L[k]) ^ (type[k] == 0)) ++a;
          if (a == 1 || a == 2) ++t;
        }
        if (maxi < t) {
          maxi = t;
          cnt = 0;
        }
        if (maxi == t) ++cnt;
      }
  return cnt;
}
int main() {
  bool debug = false;
  if (debug) {
    while (true) {
      n = rand() % 10 + 3;
      m = rand() % 40 + 2;
      for (int64_t i = 0; i < ((int64_t)(n)); ++i)
        type[i] = rand() % 3 == 0 ? 1 : 0;
      for (int64_t i = 0; i < ((int64_t)(n)); ++i) L[i] = rand() % (m + 1);
      int64_t ans0 = brute();
      int64_t ans1 = run();
      {
        std::cout << ("ans0") << "=" << (ans0) << ", " << ("ans1") << "="
                  << (ans1) << std::endl;
      };
      while (ans0 != ans1)
        ;
    }
  }
  cin >> m >> n;
  for (int64_t i = 0; i < ((int64_t)(n)); ++i) cin >> type[i] >> L[i];
  cout << run() << endl;
  ;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Nuske has a grid with N rows and M columns of squares. The rows are numbered 1 through N from top to bottom, and the columns are numbered 1 through M from left to right. Each square in the grid is painted in either blue or white. If S_{i,j} is 1, the square at the i-th row and j-th column is blue; if S_{i,j} is 0, the square is white. For every pair of two blue square a and b, there is at most one path that starts from a, repeatedly proceeds to an adjacent (side by side) blue square and finally reaches b, without traversing the same square more than once.

Phantom Thnook, Nuske's eternal rival, gives Q queries to Nuske. The i-th query consists of four integers x_{i,1}, y_{i,1}, x_{i,2} and y_{i,2} and asks him the following: when the rectangular region of the grid bounded by (and including) the x_{i,1}-th row, x_{i,2}-th row, y_{i,1}-th column and y_{i,2}-th column is cut out, how many connected components consisting of blue squares there are in the region?

Process all the queries.

Constraints

* 1 ≤ N,M ≤ 2000
* 1 ≤ Q ≤ 200000
* S_{i,j} is either 0 or 1.
* S_{i,j} satisfies the condition explained in the statement.
* 1 ≤ x_{i,1} ≤ x_{i,2} ≤ N(1 ≤ i ≤ Q)
* 1 ≤ y_{i,1} ≤ y_{i,2} ≤ M(1 ≤ i ≤ Q)

Input

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

N M Q
S_{1,1}..S_{1,M}
:
S_{N,1}..S_{N,M}
x_{1,1} y_{i,1} x_{i,2} y_{i,2}
:
x_{Q,1} y_{Q,1} x_{Q,2} y_{Q,2}

Output

For each query, print the number of the connected components consisting of blue squares in the region.

Examples

Input

3 4 4
1101
0110
1101
1 1 3 4
1 1 3 1
2 2 3 4
1 2 2 4

Output

3
2
2
2

Input

5 5 6
11010
01110
10101
11101
01010
1 1 5 5
1 2 4 5
2 3 3 4
3 3 3 3
3 1 3 5
1 1 3 4

Output

3
2
1
1
3
2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n,m,q,a1,b1,a2,b2,a[2005][2005],s1[2005][2005],s2[2005][2005],s3[2005][2005];char c[2005];
int gao1(int a1,int b1,int a2,int b2){return s1[a2][b2]-s1[a1-1][b2]-s1[a2][b1-1]+s1[a1-1][b1-1];}
int gao2(int a1,int b1,int a2,int b2){return s2[a2][b2]-s2[a1-1][b2]-s2[a2][b1-1]+s2[a1-1][b1-1];}
int gao3(int a1,int b1,int a2,int b2){return s3[a2][b2]-s3[a1-1][b2]-s3[a2][b1-1]+s3[a1-1][b1-1];}
int main()
{
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++){scanf("%s",c+1);for(int j=1;j<=m;j++) a[i][j]=c[j]-'0';}
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
	{
        s1[i][j]=a[i][j];
        if(a[i][j]&&a[i][j+1]) s2[i][j]=1;
        if(a[i][j]&&a[i+1][j]) s3[i][j]=1;
    }
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
	{
        s1[i][j]+=s1[i-1][j]+s1[i][j-1]-s1[i-1][j-1];
        s2[i][j]+=s2[i-1][j]+s2[i][j-1]-s2[i-1][j-1];
        s3[i][j]+=s3[i-1][j]+s3[i][j-1]-s3[i-1][j-1];
    }
    while(q--) scanf("%d%d%d%d",&a1,&b1,&a2,&b2),printf("%d\n",gao1(a1,b1,a2,b2)-gao2(a1,b1,a2,b2-1)-gao3(a1,b1,a2-1,b2));
}
```


### Prompt

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

Write a program which computes the area of a shape represented by the following three lines:

$y = x^2$
$y = 0$
$x = 600$

It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles in the shape as shown in the following figure:

<image>
$f(x) = x^2$

The approximative area $s$ where the width of the rectangles is $d$ is:

area of rectangle where its width is $d$ and height is $f(d)$ $+$
area of rectangle where its width is $d$ and height is $f(2d)$ $+$
area of rectangle where its width is $d$ and height is $f(3d)$ $+$
...
area of rectangle where its width is $d$ and height is $f(600 - d)$

The more we decrease $d$, the higer-precision value which is close to $72000000$ we could obtain. Your program should read the integer $d$ which is a divisor of $600$, and print the area $s$.

Input

The input consists of several datasets. Each dataset consists of an integer $d$ in a line. The number of datasets is less than or equal to 20.

Output

For each dataset, print the area $s$ in a line.

Example

Input

20
10

Output

68440000
70210000

### Response

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

int main(){
	int d;
	int x;
	int s;

	while(cin >> d){
    s = 0;
		for(int i=d;i<600;i+=d){
			s += d*i*i;
		}
		cout << s << "\n";
	}
	return 0;
}
```


### Prompt

Construct a CPP code solution to the problem outlined:

Calculate the minimum number of characters you need to change in the string s, so that it contains at least k different letters, or print that it is impossible.

String s consists only of lowercase Latin letters, and it is allowed to change characters only to lowercase Latin letters too.

Input

First line of input contains string s, consisting only of lowercase Latin letters (1 ≤ |s| ≤ 1000, |s| denotes the length of s).

Second line of input contains integer k (1 ≤ k ≤ 26).

Output

Print single line with a minimum number of necessary changes, or the word «impossible» (without quotes) if it is impossible.

Examples

Input

yandex
6

Output

0

Input

yahoo
5

Output

1

Input

google
7

Output

impossible

Note

In the first test case string contains 6 different letters, so we don't need to change anything.

In the second test case string contains 4 different letters: {'a', 'h', 'o', 'y'}. To get 5 different letters it is necessary to change one occurrence of 'o' to some letter, which doesn't occur in the string, for example, {'b'}.

In the third test case, it is impossible to make 7 different letters because the length of the string is 6.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int cnt[100005] = {0};
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  };
  string x;
  int k;
  cin >> x;
  cin >> k;
  int zz, dis = 0, del = 0;
  for (int i = 0; i < x.length(); i++) {
    zz = x[i];
    if (dis == k) {
      cout << "0";
      return 0;
    }
    if (cnt[zz] == 0) {
      cnt[zz]++;
      dis++;
    } else {
      cnt[zz]++;
      del++;
    }
  }
  if (del + dis < k)
    cout << "impossible";
  else {
    cout << k - dis;
  }
}

```


### Prompt

Develop a solution in CPP to the problem described below:

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

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

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

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

Input

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

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

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

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

Output

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

Example

Input

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

Output

YES
YES
YES
NO
NO
YES

Note

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

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

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

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

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

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
inline int read() {
  int x = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return w == 1 ? x : -x;
}
int a[1000005], b[1000005];
int main() {
  int T = read();
  while (T--) {
    int n = read(), f = 0;
    for (int i = 0; i < n; i++) a[i] = read();
    for (int i = 0; i < n; i++) a[i] = (a[i] % n + n) % n;
    for (int i = 0; i < n; i++) b[i] = (i + a[i]) % n;
    sort(b, b + n);
    for (int i = 0; i < n; i++)
      if (i != b[i]) {
        f = 1;
        break;
      }
    if (f == 1)
      puts("NO");
    else
      puts("YES");
  }
  return 0;
}

```


### Prompt

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

In 20XX AD, a school competition was held. The tournament has finally left only the final competition. You are one of the athletes in the competition.

The competition you participate in is to compete for the time it takes to destroy all the blue objects placed in the space. Athletes are allowed to bring in competition guns. In the space, there are multiple blue objects, the same number of red objects, and multiple obstacles. There is a one-to-one correspondence between the blue object and the red object, and the blue object must be destroyed by shooting a bullet at the blue object from the coordinates where the red object is placed. The obstacles placed in the space are spherical and the composition is slightly different, but if it is a normal bullet, the bullet will stop there when it touches the obstacle.

The bullet used in the competition is a special bullet called Magic Bullet. This bullet can store magical power, and when the bullet touches an obstacle, it automatically consumes the magical power, and the magic that the bullet penetrates is activated. Due to the difference in the composition of obstacles, the amount of magic required to penetrate and the amount of magic power consumed to activate it are different. Therefore, even after the magic for one obstacle is activated, it is necessary to activate another magic in order to penetrate another obstacle. Also, if the bullet touches multiple obstacles at the same time, magic will be activated at the same time. The amount of magical power contained in the bullet decreases with each magic activation.

While the position and size of obstacles and the amount of magical power required to activate the penetrating magic have already been disclosed, the positions of the red and blue objects have not been disclosed. However, the position of the object could be predicted to some extent from the information of the same competition in the past. You want to save as much magical power as you can, because putting magical power into a bullet is very exhausting. Therefore, assuming the position of the red object and the corresponding blue object, the minimum amount of magical power required to be loaded in the bullet at that time, that is, the magical power remaining in the bullet when reaching the blue object is 0. Let's find the amount of magical power that becomes.

Constraints

* 0 ≤ N ≤ 50
* 1 ≤ Q ≤ 50
* -500 ≤ xi, yi, zi ≤ 500
* 1 ≤ ri ≤ 1,000
* 1 ≤ li ≤ 1016
* -500 ≤ sxj, syj, szj ≤ 500
* -500 ≤ dxj, dyj, dzj ≤ 500
* Obstacles are never stuck in other obstacles
* The coordinates of the object are not inside or on the surface of the obstacle
* Under each assumption, the coordinates of the red object and the blue object do not match.

Input

All inputs are integers. Each number is separated by a single space.

N Q
x1 y1 z1 r1 l1
::
xN yN zN rN lN
sx1 sy1 sz1 dx1 dy1 dz1
::
sxQ syQ szQ dxQ dyQ dzQ

* N is the number of obstacles, and Q is the number of coordinates of the assumed blue and red objects.
* xi, yi, and zi are the x-coordinate, y-coordinate, and z-coordinate that represent the position of the center of the i-th obstacle, respectively.
* ri is the radius of the i-th obstacle.
* li is the amount of magical power consumed by magic to penetrate the i-th obstacle.
* sxj, syj, and szj are the x-coordinate, y-coordinate, and z-coordinate that represent the position of the red object in the jth assumption, respectively.
* dxj, dyj, and dzj are the x-coordinate, y-coordinate, and z-coordinate that represent the position of the blue object in the jth assumption, respectively.

Output

Assuming the position of each pair of red objects and the corresponding blue objects, the amount of magical power to be loaded in the bullet is output on one line, assuming that there are only obstacles, red objects, and one pair of blue objects in space. Let's do it. The bullet is supposed to fly in a straight line from the position of the red object to the position of the blue object, and since the size of the bullet is very small, it is treated as a point.

Examples

Input

5 1
0 10 0 5 2
0 20 0 5 12
0 30 0 5 22
0 40 0 5 32
0 50 0 5 42
0 0 0 0 60 0

Output

110

Input

1 1
10 5 0 5 9
0 0 0 9 12 0

Output

9

Input

5 5
-38 -71 -293 75 1
-158 -38 -405 66 1
-236 -303 157 266 1
316 26 411 190 1
207 -312 -27 196 1
-50 292 -375 -401 389 -389
460 278 409 -329 -303 411
215 -220 -200 309 -474 300
261 -494 -87 -300 123 -463
386 378 486 -443 -64 299

Output

0
2
1
3
0

### Response

```cpp
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
double EPS=1e-9;
double x[60];
double y[60];
double z[60];
double r[60];
long long d[60];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%lf%lf%lf%lf%lld",x+i,y+i,z+i,r+i,d+i);
	}
	for(int i=0;i<b;i++){
		double ax,ay,az,bx,by,bz;
		scanf("%lf%lf%lf%lf%lf%lf",&ax,&ay,&az,&bx,&by,&bz);
		long long ret=0;
		for(int j=0;j<a;j++){
			double left=0;
			double right=1;
			double val=999999999;
			for(int k=0;k<100;k++){
				double m1=left*2/3+right/3;
				double m2=left/3+right*2/3;
				double dx1=x[j]-(m1*ax+(1.0-m1)*bx);
				double dy1=y[j]-(m1*ay+(1.0-m1)*by);
				double dz1=z[j]-(m1*az+(1.0-m1)*bz);
				double dx2=x[j]-(m2*ax+(1.0-m2)*bx);
				double dy2=y[j]-(m2*ay+(1.0-m2)*by);
				double dz2=z[j]-(m2*az+(1.0-m2)*bz);

				double d1=sqrt(dx1*dx1+dy1*dy1+dz1*dz1);
				double d2=sqrt(dx2*dx2+dy2*dy2+dz2*dz2);
				val=min(val,min(d1,d2));
				if(d1<d2){
					right=m2;
				}else left=m1;
			}
			if(val<r[j]+EPS){
				ret+=d[j];
			}
		}
		printf("%lld\n",ret);
	}
}
```


### Prompt

Please formulate a cpp solution to the following problem:

An elementary school student Takahashi has come to a variety store.

He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?

Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.

Constraints

* All input values are integers.
* 1 \leq A, B \leq 500
* 1 \leq C \leq 1000

Input

Input is given from Standard Input in the following format:

A B C

Output

If Takahashi can buy the toy, print `Yes`; if he cannot, print `No`.

Examples

Input

50 100 120

Output

Yes

Input

500 100 1000

Output

No

Input

19 123 143

Output

No

Input

19 123 142

Output

Yes

### Response

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a+b>=c?"Yes":"No") << endl;
  return 0;
}

```


### Prompt

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

The crowdedness of the discotheque would never stop our friends from having fun, but a bit more spaciousness won't hurt, will it?

The discotheque can be seen as an infinite xy-plane, in which there are a total of n dancers. Once someone starts moving around, they will move only inside their own movement range, which is a circular area Ci described by a center (xi, yi) and a radius ri. No two ranges' borders have more than one common point, that is for every pair (i, j) (1 ≤ i < j ≤ n) either ranges Ci and Cj are disjoint, or one of them is a subset of the other. Note that it's possible that two ranges' borders share a single common point, but no two dancers have exactly the same ranges.

Tsukihi, being one of them, defines the spaciousness to be the area covered by an odd number of movement ranges of dancers who are moving. An example is shown below, with shaded regions representing the spaciousness if everyone moves at the same time.

<image>

But no one keeps moving for the whole night after all, so the whole night's time is divided into two halves — before midnight and after midnight. Every dancer moves around in one half, while sitting down with friends in the other. The spaciousness of two halves are calculated separately and their sum should, of course, be as large as possible. The following figure shows an optimal solution to the example above.

<image>

By different plans of who dances in the first half and who does in the other, different sums of spaciousness over two halves are achieved. You are to find the largest achievable value of this sum.

Input

The first line of input contains a positive integer n (1 ≤ n ≤ 1 000) — the number of dancers.

The following n lines each describes a dancer: the i-th line among them contains three space-separated integers xi, yi and ri ( - 106 ≤ xi, yi ≤ 106, 1 ≤ ri ≤ 106), describing a circular movement range centered at (xi, yi) with radius ri.

Output

Output one decimal number — the largest achievable sum of spaciousness over two halves of the night.

The output is considered correct if it has a relative or absolute error of at most 10 - 9. Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if <image>.

Examples

Input

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

Output

138.23007676

Input

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

Output

289.02652413

Note

The first sample corresponds to the illustrations in the legend.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void addmod(int &a, long long b) {
  a = (a + b);
  if (a >= 1000000007) a -= 1000000007;
}
void mulmod(int &a, long long b) { a = (a * b) % 1000000007; }
template <class T>
bool domin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool domax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
int gi() {
  int a;
  scanf("%d", &a);
  return a;
}
long long gll() {
  long long a;
  scanf("%lld", &a);
  return a;
}
struct point {
  long long x, y, r;
  point() {}
  point(long long x, long long y) : x(x), y(y) {}
  double dist(const point &pa, const point &push_back) {
    double num = (push_back.y - pa.y) * x - (push_back.x - pa.x) * y +
                 push_back.x * pa.y - push_back.y * pa.x;
    if (num < 0) num = -num;
    double den = (push_back.y - pa.y) * (push_back.y - pa.y) +
                 (push_back.x - pa.x) * (push_back.x - pa.x);
    den = sqrt(den);
    return num / den;
  }
  long long distsq(const point &o) {
    long long dx = o.x - x, dy = o.y - y;
    return (dx * dx + dy * dy);
  }
  double area() {
    double ans = 3.141592653589;
    ans *= r;
    ans *= r;
    return ans;
  }
};
bool cmp2(const point &a, const point &b) { return a.r < b.r; }
int main() {
  int n = gi();
  vector<point> a(n);
  for (int i = 0; i < n; i++) {
    a[i].x = gi(), a[i].y = gi(), a[i].r = gi();
  }
  sort(a.begin(), a.end(), cmp2);
  vector<bool> vis(n, false);
  vector<int> ne(n, 0);
  vector<vector<bool>> adj(n, vector<bool>(n, false));
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      long long av = a[i].distsq(a[j]);
      if (av <= (a[j].r * a[j].r)) {
        ne[i]++;
        adj[j][i] = true;
      }
    }
  double aa = 0, ab = 0;
  vector<int> q(n + 5, 0);
  int qb = 0, qe = 0;
  for (int i = 0; i < n; i++) {
    int ri = (i - 1);
    qb = qe = 0;
    for (int j = 0; j < n; j++)
      if (!vis[j] && ne[j] == 0) {
        vis[j] = true;
        q[qe++] = j;
      }
    while (qb < qe) {
      int j = q[qb++];
      vis[j] = true;
      if (i > 0) {
        if (ri & 1)
          ab -= a[j].area();
        else
          ab += a[j].area();
      } else {
        aa += a[j].area();
      }
      for (int kk = 0; kk < n; kk++)
        if (adj[j][kk]) {
          ne[kk]--;
        }
    }
  }
  printf("%0.8f\n", aa + ab);
  return 0;
}

```


### Prompt

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

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

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

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

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

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

Input

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

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

Output

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

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

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

Examples

Input

8 3
5 4 2 6 5 1 9 2

Output

20
3 2 3

Input

5 1
1 1 1 1 1

Output

1
5

Input

4 2
1 2000 2000 2

Output

4000
2 2

Note

The first example is described in the problem statement.

In the second example there is only one possible distribution.

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long int n, k;
  cin >> n >> k;
  long long int a[n], f[n];
  vector<long long int> v;
  map<long long int, long long int> m;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    f[i] = a[i];
  }
  long long int x = 0, y = 0;
  sort(a, a + n, greater<long long int>());
  long long int s = 0;
  for (long long int i = 0; i < k; i++) {
    s = s + a[i];
    m[a[i]]++;
    v.push_back(a[i]);
  }
  cout << s << endl;
  long long int z = 0;
  for (long long int i = 0; i < n; i++) {
    x++;
    y = 0;
    if (m[f[i]] > 0) {
      m[f[i]]--;
      if (k != 1) {
        cout << x << " ";
        x = 0;
        y = 1;
      }
      k--;
    }
  }
  cout << x;
}

```


### Prompt

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

This is a hard version of the problem. The actual problems are different, but the easy version is almost a subtask of the hard version. Note that the constraints and the output format are different.

You are given a string s consisting of n lowercase Latin letters.

You have to color all its characters the minimum number of colors (each character to exactly one color, the same letters can be colored the same or different colors, i.e. you can choose exactly one color for each index in s).

After coloring, you can swap any two neighboring characters of the string that are colored different colors. You can perform such an operation arbitrary (possibly, zero) number of times.

The goal is to make the string sorted, i.e. all characters should be in alphabetical order.

Your task is to find the minimum number of colors which you have to color the given string in so that after coloring it can become sorted by some sequence of swaps. Note that you have to restore only coloring, not the sequence of swaps.

Input

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

The second line of the input contains the string s consisting of exactly n lowercase Latin letters.

Output

In the first line print one integer res (1 ≤ res ≤ n) — the minimum number of colors in which you have to color the given string so that after coloring it can become sorted by some sequence of swaps.

In the second line print any possible coloring that can be used to sort the string using some sequence of swaps described in the problem statement. The coloring is the array c of length n, where 1 ≤ c_i ≤ res and c_i means the color of the i-th character.

Examples

Input

9
abacbecfd

Output

2
1 1 2 1 2 1 2 1 2

Input

8
aaabbcbb

Output

2
1 2 1 2 1 2 1 1

Input

7
abcdedc

Output

3
1 1 1 1 1 2 3

Input

5
abcde

Output

1
1 1 1 1 1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long M = (long long)1e9 + 1, t = 0;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long digits(long long n) { return floor(log10(n)) + 1; }
bool ispoweroftwo(long long x) { return x && (!(x & (x - 1))); }
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  string s;
  cin >> n >> s;
  vector<long long> maxc(26);
  vector<long long> v(n, 1);
  long long ans = -1;
  for (long long i = 0; i < n; i++) {
    for (char c = s[i] + 1; c <= 'z'; c++) {
      v[i] = max(v[i], maxc[c - 'a'] + 1);
    }
    maxc[s[i] - 'a'] = max(v[i], maxc[s[i] - 'a']);
    ans = max(ans, maxc[s[i] - 'a']);
  }
  cout << ans << endl;
  for (long long x : v) cout << x << " ";
  cout << endl;
}

```


### Prompt

Please create a solution in CPP to the following problem:

Heidi is a statistician to the core, and she likes to study the evolution of marmot populations in each of V (1 ≤ V ≤ 100) villages! So it comes that every spring, when Heidi sees the first snowdrops sprout in the meadows around her barn, she impatiently dons her snowshoes and sets out to the Alps, to welcome her friends the marmots to a new season of thrilling adventures.

Arriving in a village, Heidi asks each and every marmot she comes across for the number of inhabitants of that village. This year, the marmots decide to play an April Fools' joke on Heidi. Instead of consistently providing the exact number of inhabitants P (10 ≤ P ≤ 1000) of the village, they respond with a random non-negative integer k, drawn from one of two types of probability distributions:

  * Poisson (d'avril) distribution: the probability of getting an answer k is <image> for k = 0, 1, 2, 3, ...,
  * Uniform distribution: the probability of getting an answer k is <image> for k = 0, 1, 2, ..., 2P.

Heidi collects exactly 250 answers per village. Every village follows either the Poisson or the uniform distribution. Heidi cannot tell marmots apart, so she may query some marmots several times, and each time the marmot will answer with a new number drawn from the village's distribution.

Can you help Heidi to find out whether a village follows a Poisson or a uniform distribution?

Input

The first line of input will contain the number of villages V (1 ≤ V ≤ 100). The following V lines each describe one village. The description of each village consists of 250 space-separated integers k, drawn from one of the above distributions.

Output

Output one line per village, in the same order as provided in the input. The village's line shall state poisson if the village's distribution is of the Poisson type, and uniform if the answer came from a uniform distribution.

Example

Input

2
92 100 99 109 93 105 103 106 101 99 ... (input is truncated)
28 180 147 53 84 80 180 85 8 16 ... (input is truncated)

Output

poisson
uniform

Note

The full example input is visually represented below, along with the probability distribution function it was drawn from (the y-axis is labeled by its values multiplied by 250).

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long V;
  cin >> V;
  while (V--) {
    double a[250];
    for (long long i = 0; i < 250; i++) cin >> a[i];
    double exp = 0;
    for (long long i = 0; i < 250; i++) exp += a[i];
    exp /= 250;
    double var = 0;
    for (long long i = 0; i < 250; i++) var += (a[i] - exp) * (a[i] - exp);
    var /= 250;
    double k = exp / var;
    double err = 0.40;
    if (1.0 - err <= k && k <= 1.0 + err)
      cout << "poisson" << endl;
    else
      cout << "uniform" << endl;
  }
  return 0;
}

```


### Prompt

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

We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:

* For any two vertices painted in the same color, the distance between them is an even number.

Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.

Constraints

* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq u_i < v_i \leq N
* 1 \leq w_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N
u_1 v_1 w_1
u_2 v_2 w_2
.
.
.
u_{N - 1} v_{N - 1} w_{N - 1}

Output

Print a coloring of the vertices that satisfies the condition, in N lines. The i-th line should contain `0` if Vertex i is painted white and `1` if it is painted black.

If there are multiple colorings that satisfy the condition, any of them will be accepted.

Examples

Input

3
1 2 2
2 3 1

Output

0
0
1

Input

5
2 5 2
2 3 10
1 3 8
3 4 2

Output

1
0
1
0
1

### Response

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

bool seen[110000];
int vec[110000];
map<pair<int,int>,int> ma;

void dfs(const vector<vector<int>> &G,int v){
  seen[v]=true;
  for(auto next_v:G[v]){
    if(seen[next_v])continue;
    vec[next_v]=vec[v]+ma[{v,next_v}];
    dfs(G,next_v);
  }
}

int main(){
  int n;
  cin>>n;
  vector<vector<int>> g(n);
  for(int i=0;i<n-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    c%=2;
    g[a].push_back(b);
    g[b].push_back(a);
    ma[{a,b}]=c;
    ma[{b,a}]=c;
  }
  vec[0]=0;
  dfs(g,0);
  for(int i=0;i<n;i++){
    cout<<vec[i]%2<<endl;
  }
}
```


### Prompt

Please create a solution in Cpp to the following problem:

As a result of Pinky and Brain's mysterious experiments in the Large Hadron Collider some portals or black holes opened to the parallel dimension. And the World Evil has crept to the veil between their world and ours. Brain quickly evaluated the situation and he understood that the more evil tentacles creep out and become free, the higher is the possibility that Brain will rule the world.

The collider's constriction is a rectangular grid rolled into a cylinder and consisting of n rows and m columns such as is shown in the picture below:

<image>

In this example n = 4, m = 5. Dotted lines are corridores that close each column to a ring, i. e. connect the n-th and the 1-th rows of the grid.

In the leftmost column of the grid the portals are situated and the tentacles of the World Evil are ready to creep out from there. In the rightmost column the exit doors are located. The tentacles can only get out through those doors. The segments joining the nodes of the grid are corridors.

Brain would be glad to let all the tentacles out but he faces a problem: the infinite number of tentacles can creep out of the portals, every tentacle possesses infinite length and some width and the volume of the corridors are, unfortunately, quite limited. Brain could approximately evaluate the maximal number of tentacles that will be able to crawl through every corridor.

Now help the mice to determine the maximal number of tentacles of the World Evil that will crawl out of the Large Hadron Collider.

Input

The first line of the input file contains two integers n and m (2 ≤ n ≤ 5, 2 ≤ m ≤ 105). They are the sizes of the Large Hadron Collider grid. The next m - 1 lines contain n numbers each. They are the horizontal corridors' capacities. The next m lines contain n numbers each. They are the vertical corridors' capacities. Corridors are described from left to right and from top to bottom. Every n-th vertical corridor connects nodes of the n-th and 1-th rows. A corridor's capacity is a non-negative integer that does not exceed 109.

Output

Print a single number, the number of the World Evil tentacles Pinky and Brain will command.

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

Examples

Input

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

Output

7

Input

2 2
9 2
2 3
6 1

Output

11

### Response

```cpp
#include <bits/stdc++.h>
const long long T00B1G = 9223372036854775807LL;
const int maskl = 5;
template <class TEl>
using TTable = std::vector<std::vector<TEl>>;
template <class TEl>
void spacecreator(long long first, long long second, TTable<TEl>& vec) {
  vec.resize(first);
  for (auto& sub : vec) {
    sub.resize(second);
  }
}
template <class T>
void makemask(long nn, T& mask) {
  auto ulim = 1 << nn;
  for (auto st = 0; st < ulim; st++) {
    for (auto pos = 0; pos < nn; pos++) {
      mask[st][pos] = (st >> pos) & 1;
    }
  }
}
int main() {
  long long mm;
  long nn;
  TTable<long long> dp;
  TTable<long long> left, down;
  TTable<bool> mask;
  std::ios::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cin >> nn >> mm;
  spacecreator(mm + 5, 2 << nn, dp);
  spacecreator(maskl, mm + 5, left);
  spacecreator(maskl, mm + 5, down);
  spacecreator((2 << nn), maskl, mask);
  for (auto col = 1; col < mm; ++col) {
    for (auto row = 0; row < nn; ++row) {
      std::cin >> left[row][col];
    }
  }
  for (auto col = 0; col < mm; ++col) {
    for (auto row = 0; row < nn; ++row) {
      std::cin >> down[row][col];
    }
  }
  makemask(nn, mask);
  long long row_i, col_i;
  auto ulim = 1 << nn;
  for (auto col = 1; col < mm; ++col) {
    for (auto st = 0; st < ulim; ++st) {
      row_i = 0;
      dp[col][st] = T00B1G;
      auto& mcache = mask[st];
      for (auto row = 0; row < nn; ++row) {
        auto next = (row + 1) % nn;
        if (mcache[row] ^ mcache[next]) {
          row_i += down[row][col];
        }
      }
      for (auto prev = 0; prev < ulim; ++prev) {
        col_i = 0;
        for (auto row = 0; row < nn; ++row) {
          if (mcache[row] ^ mask[prev][row]) {
            col_i += left[row][col];
          }
        }
        dp[col][st] = std::min(dp[col][st], dp[col - 1][prev] + col_i + row_i);
        if (col == 1) {
          break;
        }
      }
    }
  }
  std::cout << dp[mm - 1][ulim - 1];
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya and his friend Vasya play an interesting game. Petya randomly chooses an integer p from the interval [pl, pr] and Vasya chooses an integer v from the interval [vl, vr] (also randomly). Both players choose their integers equiprobably. Find the probability that the interval [min(v, p), max(v, p)] contains exactly k lucky numbers.

Input

The single line contains five integers pl, pr, vl, vr and k (1 ≤ pl ≤ pr ≤ 109, 1 ≤ vl ≤ vr ≤ 109, 1 ≤ k ≤ 1000).

Output

On the single line print the result with an absolute error of no more than 10 - 9.

Examples

Input

1 10 1 10 2

Output

0.320000000000

Input

5 6 8 10 1

Output

1.000000000000

Note

Consider that [a, b] denotes an interval of integers; this interval includes the boundaries. That is, <image>

In first case there are 32 suitable pairs: (1, 7), (1, 8), (1, 9), (1, 10), (2, 7), (2, 8), (2, 9), (2, 10), (3, 7), (3, 8), (3, 9), (3, 10), (4, 7), (4, 8), (4, 9), (4, 10), (7, 1), (7, 2), (7, 3), (7, 4), (8, 1), (8, 2), (8, 3), (8, 4), (9, 1), (9, 2), (9, 3), (9, 4), (10, 1), (10, 2), (10, 3), (10, 4). Total number of possible pairs is 10·10 = 100, so answer is 32 / 100.

In second case Petya always get number less than Vasya and the only lucky 7 is between this numbers, so there will be always 1 lucky number.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long p[1505], tot, p1, p2, v1, v2, k;
;
void dfs(long long x) {
  if (x > 1e9) return;
  p[tot++] = x;
  dfs(x * 10 + 4);
  dfs(x * 10 + 7);
}
int main() {
  scanf("%I64d%I64d%I64d%I64d%I64d", &p1, &p2, &v1, &v2, &k);
  tot = 0;
  dfs(0);
  sort(p, p + tot);
  p[tot] = 999999999;
  p[tot + 1] = 999999999;
  long long ans = 0;
  for (long long i = 1; i < tot; i++) {
    if (i + k - 1 > tot) break;
    long long x = p[i], y = p[i + k - 1];
    if (y > v2 && y > p2) break;
    long long l = 0, r = 0;
    l = max(l, min(p[k + i] - 1, v2) - max(v1, y) + 1);
    r = max(r, min(x, p2) - max(p1, p[i - 1] + 1) + 1);
    ans += l * r;
    l = r = 0;
    l = max(l, min(p[k + i] - 1, p2) - max(p1, y) + 1);
    r = max(r, min(x, v2) - max(v1, p[i - 1] + 1) + 1);
    ans += l * r;
    if (k == 1) {
      l = r = 0;
      l = max(l, min(p2, p[i]) - max(p1, p[i]) + 1);
      r = max(r, min(v2, p[i]) - max(v1, p[i]) + 1);
      ans -= l * r;
    }
  }
  double s = ans * 1.0 / ((p2 - p1 + 1) * (v2 - v1 + 1));
  printf("%.9lf\n", s);
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Due to atheistic Soviet past, Christmas wasn't officially celebrated in Russia for most of the twentieth century. As a result, the Russian traditions for Christmas and New Year mixed into one event celebrated on the New Year but including the tree, a Santa-like 'Grandfather Frost', presents and huge family reunions and dinner parties all over the country. Bying a Tree at the New Year and installing it in the house is a tradition. Usually the whole family decorates the tree on the New Year Eve. We hope that Codeforces is a big and loving family, so in this problem we are going to decorate a tree as well.

So, our decoration consists of n pieces, each piece is a piece of colored paper, its border is a closed polyline of a special shape. The pieces go one by one as is shown on the picture. The i-th piece is a polyline that goes through points: (0, 0), (0, y0), (1, y1), (2, y2), ..., (k, yk), (k, 0). The width of each piece equals k.

<image> The figure to the left shows the decoration, the figure to the right shows the individual pieces it consists of.

The piece number 1 (shown red on the figure) is the outer piece (we see it completely), piece number 2 (shown yellow) follows it (we don't see it completely as it is partially closed by the first piece) and so on. The programmers are quite curious guys, so the moment we hung a decoration on the New Year tree we started to wonder: what area of each piece can people see?

Input

The first line contains two integers, n and k (1 ≤ n, k ≤ 300). Each of the following n lines contains k + 1 integers — the description of the polyline. If the i-th line contains ontegers yi, 0, yi, 1, ..., yi, k, that means that the polyline of the i-th piece goes through points (0, 0), (0, yi, 0), (1, yi, 1), (2, yi, 2), ..., (k, yi, k), (k, 0) (1 ≤ yi, j ≤ 1000).

Output

Print n real numbers — for each polyline, the area of its visible part.

The answer will be considered correct if its relative or absolute error do not exceed 10 - 4.

Examples

Input

2 2
2 1 2
1 2 1

Output

3.000000000000
0.500000000000

Input

1 1
1 1

Output

1.000000000000

Input

4 1
2 7
7 2
5 5
6 4

Output

4.500000000000
1.250000000000
0.050000000000
0.016666666667

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
const int INF = (int)1e9 + 1;
const long double EPS = 1e-9;
void precalc() {}
struct Point {
  long double x, y;
  Point() {}
  Point(long double _x, long double _y) : x(_x), y(_y) {}
  inline Point operator-(const Point &p) const {
    return Point(x - p.x, y - p.y);
  }
};
const int maxn = 300 + 10;
Point qs[maxn][maxn];
int n, k;
bool read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= k; ++j) {
      double y;
      scanf("%lf", &y);
      qs[i][j] = Point(j, y);
    }
  }
  return 1;
}
Point ps[maxn * maxn * 2], nps[maxn * maxn * 2];
long double get(const long double &x1, const long double &y1,
                const long double &x2, const long double &y2,
                const long double &x) {
  assert(x2 - x1 > EPS);
  return y1 + (y2 - y1) * (x - x1) / (x2 - x1);
}
int sign(const long double &x) { return x < -EPS ? -1 : x > EPS; }
void addSequence(int &n, Point *ps, int m, Point *qs, long double &S) {
  assert(n >= 1 && m >= 1);
  long double x = 0, y1 = ps[0].y, y2 = qs[0].y;
  int nn = 1;
  nps[0] = Point(0, max(y1, y2));
  for (int i = 1, j = 1; i < n || j < m;) {
    assert(i < n && j < m);
    long double nx = min(ps[i].x, qs[j].x);
    long double ny1 = get(x, y1, ps[i].x, ps[i].y, nx);
    long double ny2 = get(x, y2, qs[j].x, qs[j].y, nx);
    if (sign(y1 - y2) * sign(ny1 - ny2) == -1) {
      long double cx = (y1 - y2) / (y1 - y2 + ny2 - ny1) * (nx - x) + x;
      nps[nn++] = Point(cx, y1 + (cx - x) / (nx - x) * (ny1 - y1));
    }
    nps[nn++] = Point(nx, max(ny1, ny2));
    x = nx;
    y1 = ny1, y2 = ny2;
    if (ps[i].x <= nx + EPS) {
      ++i;
    }
    if (qs[j].x <= nx + EPS) {
      ++j;
    }
  }
  n = nn;
  S = 0;
  for (int i = 1; i < n; ++i) {
    S += (nps[i].x - nps[i - 1].x) * (nps[i].y + nps[i - 1].y) / 2;
  }
  for (int i = 0; i < n; ++i) {
    ps[i] = nps[i];
  }
}
void solve() {
  int cnt = 2;
  ps[0] = Point(0, 0);
  ps[1] = Point(k, 0);
  long double S = 0;
  for (int i = 0; i < n; ++i) {
    long double lastS = S;
    addSequence(cnt, ps, k + 1, qs[i], S);
    printf("%.18f\n", (double)(S - lastS));
  }
}
int main() {
  srand(rdtsc());
  precalc();
  while (1) {
    if (!read()) {
      break;
    }
    solve();
  }
  return 0;
}

```


### Prompt

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

You are given an array a_1, a_2, ..., a_n and an integer k.

You are asked to divide this array into k non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. Let f(i) be the index of subarray the i-th element belongs to. Subarrays are numbered from left to right and from 1 to k.

Let the cost of division be equal to ∑_{i=1}^{n} (a_i ⋅ f(i)). For example, if a = [1, -2, -3, 4, -5, 6, -7] and we divide it into 3 subbarays in the following way: [1, -2, -3], [4, -5], [6, -7], then the cost of division is equal to 1 ⋅ 1 - 2 ⋅ 1 - 3 ⋅ 1 + 4 ⋅ 2 - 5 ⋅ 2 + 6 ⋅ 3 - 7 ⋅ 3 = -9.

Calculate the maximum cost you can obtain by dividing the array a into k non-empty consecutive subarrays.

Input

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 3 ⋅ 10^5).

The second line contains n integers a_1, a_2, ..., a_n ( |a_i| ≤ 10^6).

Output

Print the maximum cost you can obtain by dividing the array a into k nonempty consecutive subarrays.

Examples

Input

5 2
-1 -2 5 -4 8

Output

15

Input

7 6
-3 0 -1 -2 -2 -4 -1

Output

-45

Input

4 1
3 -1 6 0

Output

8

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long const INF = 1e18;
long long s[300100], a[300100];
int n, k;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  s[n + 1] = 0;
  for (int i = n; i >= 1; i--) s[i] = s[i + 1] + a[i];
  s[0] = s[1];
  sort(s + 2, s + n + 1);
  long long res = 0;
  for (int i = n; i >= n - k + 2; i--) res = res + s[i];
  res += s[1];
  cout << res << endl;
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3.

A cycle of length 3 is an unordered group of three distinct graph vertices a, b and c, such that each pair of them is connected by a graph edge.

John has been painting for long, but he has not been a success. Help him find such graph. Note that the number of vertices there shouldn't exceed 100, or else John will have problems painting it.

Input

A single line contains an integer k (1 ≤ k ≤ 105) — the number of cycles of length 3 in the required graph.

Output

In the first line print integer n (3 ≤ n ≤ 100) — the number of vertices in the found graph. In each of next n lines print n characters "0" and "1": the i-th character of the j-th line should equal "0", if vertices i and j do not have an edge between them, otherwise it should equal "1". Note that as the required graph is undirected, the i-th character of the j-th line must equal the j-th character of the i-th line. The graph shouldn't contain self-loops, so the i-th character of the i-th line must equal "0" for all i.

Examples

Input

1

Output

3
011
101
110

Input

10

Output

5
01111
10111
11011
11101
11110

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e2 + 7;
int G[MAX_N][MAX_N];
void link(int a, int b) { G[a][b] = G[b][a] = true; }
void check(int des, int n) {
  int ret = 0;
  for (int i = (1); i < (n + 1); i++)
    for (int j = (1); j < (n + 1); j++)
      for (int k = (1); k < (n + 1); k++)
        if (G[i][j] && G[i][k] && G[j][k]) ret++;
  ret /= 6;
  cout << "ret"
       << " => " << ret << endl;
  cout << "des"
       << " => " << des << endl;
  puts(ret == des ? "AC" : "WA");
}
int C2[MAX_N];
int main() {
  for (int i = (2); i < (MAX_N); i++) C2[i] = i * (i - 1) / 2;
  link(1, 2);
  int n;
  cin >> n;
  int _n = n;
  int base = 2;
  for (; n >= C2[base]; base++) {
    n -= C2[base];
    for (int i = (1); i < (base + 1); i++) link(i, base + 1);
  }
  for (; n;) {
    int pos = lower_bound(C2, C2 + MAX_N, n + 1) - C2;
    pos--;
    n -= C2[pos];
    ++base;
    for (int i = (1); i < (pos + 1); i++) link(base, i);
  }
  printf("%d\n", base);
  for (int i = (1); i < (base + 1); i++) {
    for (int j = (1); j < (base + 1); j++) printf("%d", G[i][j]);
    printf("\n");
  }
}

```


### Prompt

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

The Bitlandians are quite weird people. They have very peculiar customs.

As is customary, Uncle J. wants to have n eggs painted for Bitruz (an ancient Bitland festival). He has asked G. and A. to do the work.

The kids are excited because just as is customary, they're going to be paid for the job!

Overall uncle J. has got n eggs. G. named his price for painting each egg. Similarly, A. named his price for painting each egg. It turns out that for each egg the sum of the money both A. and G. want for the painting equals 1000.

Uncle J. wants to distribute the eggs between the children so as to give each egg to exactly one child. Also, Uncle J. wants the total money paid to A. to be different from the total money paid to G. by no more than 500.

Help Uncle J. Find the required distribution of eggs or otherwise say that distributing the eggs in the required manner is impossible.

Input

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

Next n lines contain two integers ai and gi each (0 ≤ ai, gi ≤ 1000; ai + gi = 1000): ai is the price said by A. for the i-th egg and gi is the price said by G. for the i-th egg.

Output

If it is impossible to assign the painting, print "-1" (without quotes).

Otherwise print a string, consisting of n letters "G" and "A". The i-th letter of this string should represent the child who will get the i-th egg in the required distribution. Letter "A" represents A. and letter "G" represents G. If we denote the money Uncle J. must pay A. for the painting as Sa, and the money Uncle J. must pay G. for the painting as Sg, then this inequality must hold: |Sa - Sg| ≤ 500.

If there are several solutions, you are allowed to print any of them.

Examples

Input

2
1 999
999 1

Output

AG

Input

3
400 600
400 600
400 600

Output

AGA

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void c_p_c() {}
void solve() {
  long long n, k = 0;
  cin >> n;
  long long i = 0;
  char res[1000005];
  while (n--) {
    long long x, y;
    cin >> x >> y;
    if (x + k <= 500) {
      k += x;
      res[i++] = 'A';
    } else {
      k -= y;
      res[i++] = 'G';
    }
  }
  cout << res << endl;
}
int32_t main() {
  c_p_c();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken by somebody, it couldn't be taken by anybody else.

You are to determine the minimum time needed for all n people to get to the office with keys. Assume that people move a unit distance per 1 second. If two people reach a key at the same time, only one of them can take the key. A person can pass through a point with a key without taking it.

Input

The first line contains three integers n, k and p (1 ≤ n ≤ 1 000, n ≤ k ≤ 2 000, 1 ≤ p ≤ 109) — the number of people, the number of keys and the office location.

The second line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ 109) — positions in which people are located initially. The positions are given in arbitrary order.

The third line contains k distinct integers b1, b2, ..., bk (1 ≤ bj ≤ 109) — positions of the keys. The positions are given in arbitrary order.

Note that there can't be more than one person or more than one key in the same point. A person and a key can be located in the same point.

Output

Print the minimum time (in seconds) needed for all n to reach the office with keys.

Examples

Input

2 4 50
20 100
60 10 40 80

Output

50

Input

1 2 10
11
15 7

Output

7

Note

In the first example the person located at point 20 should take the key located at point 40 and go with it to the office located at point 50. He spends 30 seconds. The person located at point 100 can take the key located at point 80 and go to the office with it. He spends 50 seconds. Thus, after 50 seconds everybody is in office with keys.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e3 + 10;
const double eps = 1e-6;
int dp[MAX][MAX];
int main() {
  int n, m, aim, i, j, a[MAX], b[MAX];
  cin >> n >> m >> aim;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= m; i++) cin >> b[i];
  sort(a + 1, a + n + 1);
  sort(b + 1, b + m + 1);
  memset(dp, 0, sizeof(dp));
  for (i = 1; i <= n; i++)
    for (j = i; j <= m; j++) {
      if (i == j)
        dp[i][j] = max(dp[i - 1][j - 1], abs(a[i] - b[j]) + abs(b[j] - aim));
      else
        dp[i][j] = min(dp[i][j - 1], max(dp[i - 1][j - 1],
                                         abs(a[i] - b[j]) + abs(b[j] - aim)));
    }
  cout << dp[n][m] << endl;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Snuke has N hats. The i-th hat has an integer a_i written on it.

There are N camels standing in a circle. Snuke will put one of his hats on each of these camels.

If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No`.

* The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself.

What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non-negative integers x_1, x_2, \ldots, x_n is defined as follows: - When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 \oplus 5 = 6.

Constraints

* All values in input are integers.
* 3 \leq N \leq 10^{5}
* 0 \leq a_i \leq 10^{9}

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 \ldots a_{N}

Output

Print the answer.

Examples

Input

3
1 2 3

Output

Yes

Input

4
1 2 4 8

Output

No

### Response

```cpp
#include <iostream>
using namespace std;
int main() {
	int N, a, x = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		x ^= a;
	}
	cout << (x ? "No" : "Yes") << endl;
}
```


### Prompt

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

Consider a linear function f(x) = Ax + B. Let's define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x)) for n > 0. For the given integer values A, B, n and x find the value of g(n)(x) modulo 109 + 7.

Input

The only line contains four integers A, B, n and x (1 ≤ A, B, x ≤ 109, 1 ≤ n ≤ 1018) — the parameters from the problem statement.

Note that the given value n can be too large, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.

Output

Print the only integer s — the value g(n)(x) modulo 109 + 7.

Examples

Input

3 4 1 1

Output

7

Input

3 4 2 1

Output

25

Input

3 4 3 1

Output

79

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int n = 2;
long long a, b, p, x;
vector<vector<long long> > operator*(const vector<vector<long long> > &a,
                                     const vector<vector<long long> > &b) {
  vector<vector<long long> > m(n, vector<long long>(n));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++) {
        m[i][j] += (a[i][k] * b[k][j]) % MOD;
        m[i][j] %= MOD;
      }
  return m;
}
vector<vector<long long> > id() {
  vector<vector<long long> > m(n, vector<long long>(n));
  for (int i = 0; i < n; i++) m[i][i] = 1;
  return m;
}
long long expo(vector<vector<long long> > ele, long long e) {
  vector<vector<long long> > ans = id();
  while (e) {
    if (e & 1) ans = ans * ele;
    ele = ele * ele;
    e >>= 1;
  }
  long long resp = (ans[0][0] * x) % MOD;
  resp += (ans[1][0] * b) % MOD;
  resp %= MOD;
  return resp;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> a >> b >> p >> x;
  vector<vector<long long> > m(n, vector<long long>(n, 1LL));
  m[0][0] = a;
  m[0][1] = 0;
  cout << expo(m, p) << endl;
  return 0;
}

```


### Prompt

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

There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`.

Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.

Constraints

* 1 \leq N \leq 2\times 10^5
* S is a string of length N consisting of `.` and `#`.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the minimum number of stones that needs to be recolored.

Examples

Input

3
#.#

Output

1

Input

3
.#

Output

1

Input

5
.##.

Output

2

Input

9
.........

Output

0

### Response

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

int main()
{
	int n;
	string s;
	cin >> n >> s;
	vector<int> l(n + 1), r(n + 1);
	for(int i = 0; i < n; i++){
		if(s[i] == '#') l[i + 1]++;
		if(s[n - i - 1] == '.') r[n - i - 1]++;
		l[i + 1] += l[i];
		r[n - i - 1] += r[n - i];
	}
	int ans = 1001001001;
	for(int i = 0; i < n; i++){
		ans = min(ans, l[i] + r[i + 1]);
	}
	cout << ans << endl;
	return 0;
}
```