### Prompt

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

You are given a string of length n. Each character is one of the first p lowercase Latin letters.

You are also given a matrix A with binary values of size p × p. This matrix is symmetric (A_{ij} = A_{ji}). A_{ij} = 1 means that the string can have the i-th and j-th letters of Latin alphabet adjacent.

Let's call the string crisp if all of the adjacent characters in it can be adjacent (have 1 in the corresponding cell of matrix A).

You are allowed to do the following move. Choose any letter, remove all its occurrences and join the remaining parts of the string without changing their order. For example, removing letter 'a' from "abacaba" will yield "bcb".

The string you are given is crisp. The string should remain crisp after every move you make.

You are allowed to do arbitrary number of moves (possible zero). What is the shortest resulting string you can obtain?

Input

The first line contains two integers n and p (1 ≤ n ≤ 10^5, 1 ≤ p ≤ 17) — the length of the initial string and the length of the allowed prefix of Latin alphabet.

The second line contains the initial string. It is guaranteed that it contains only first p lowercase Latin letters and that is it crisp. Some of these p first Latin letters might not be present in the string.

Each of the next p lines contains p integer numbers — the matrix A (0 ≤ A_{ij} ≤ 1, A_{ij} = A_{ji}). A_{ij} = 1 means that the string can have the i-th and j-th letters of Latin alphabet adjacent.

Output

Print a single integer — the length of the shortest string after you make arbitrary number of moves (possible zero).

Examples

Input

7 3
abacaba
0 1 1
1 0 0
1 0 0

Output

7

Input

7 3
abacaba
1 1 1
1 0 0
1 0 0

Output

0

Input

7 4
bacadab
0 1 1 1
1 0 0 0
1 0 0 0
1 0 0 0

Output

5

Input

3 3
cbc
0 0 0
0 0 1
0 1 0

Output

0

Note

In the first example no letter can be removed from the initial string.

In the second example you can remove letters in order: 'b', 'c', 'a'. The strings on the intermediate steps will be: "abacaba" → "aacaa" → "aaaa" → "".

In the third example you can remove letter 'b' and that's it.

In the fourth example you can remove letters in order 'c', 'b', but not in the order 'b', 'c' because two letters 'c' can't be adjacent.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmin(T &x, T y) {
  return y <= x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
  return x <= y ? x = y, 1 : 0;
}
const long double eps = 1e-9;
const long double pi = acos(-1);
const int oo = 1 << 30;
const long long loo = 1ll << 60;
const int MAXN = 100005;
const int MAXM = 2000005;
const int MX = 5000;
const int mods = 998244353;
const int SZ = 131;
const int inv2 = (mods + 1) >> 1;
const int INF = 0x3f3f3f3f;
namespace FastIO {
constexpr int SIZE = (1 << 21) + 1;
int num = 0, f;
char ibuf[SIZE], obuf[SIZE], que[65], *iS, *iT, *oS = obuf,
                                                *oT = obuf + SIZE - 1, c;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char c) {
  *oS++ = c;
  if (oS == oT) flush();
}
inline void getc(char &c) {
  for (c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       !isalpha(c) && c != EOF;
       c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    ;
}
inline void reads(char *st) {
  char c;
  int n = 0;
  getc(st[++n]);
  for (c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       isalpha(c);
       c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    st[++n] = c;
  st[++n] = '\0';
}
template <class I>
inline void read(I &x) {
  for (f = 1, c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') f = -1;
  for (x = 0; c >= '0' && c <= '9';
       c = (iS == iT ? (iT = ((iS = ibuf) + fread(ibuf, 1, SIZE, stdin)),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = (x << 3) + (x << 1) + (c & 15);
  x *= f;
}
template <class I>
inline void print(I x) {
  if (x < 0) putc('-'), x = -x;
  if (!x) putc('0');
  while (x) que[++num] = x % 10 + 48, x /= 10;
  while (num) putc(que[num--]);
}
inline void putstr(string st) {
  for (int i = 0; i < (int)st.size(); ++i) putc(st[i]);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_Flusher_;
}  // namespace FastIO
using FastIO ::print;
using FastIO ::putc;
using FastIO ::putstr;
using FastIO ::read;
using FastIO ::reads;
char st[MAXN];
int flag[1 << 17], cnt[17], s[1 << 17], f[1 << 17], g[1 << 17], id[17], wh[17],
    n, m;
void addtag(int x, int y) {
  int M = m - 1;
  for (int i = 0; i < m; ++i) id[i] = i;
  for (int i = y; i < m; ++i) id[i] = id[i + 1];
  if (x != y) {
    --M;
    for (int i = x; i < m - 1; ++i) id[i] = id[i + 1];
  }
  for (int i = 0; i < M; ++i) wh[id[i]] = i;
  for (int i = 0; i < 1 << M; ++i) g[i] = 0;
  for (int i = 1, lst = 0, nw = 0; i <= n; ++i) {
    if (st[i] - 'a' != x && st[i] - 'a' != y) {
      nw |= 1 << wh[st[i] - 'a'];
      continue;
    }
    if (lst && (st[lst] != st[i] || x == y)) g[nw] = 1;
    lst = i, nw = 0;
  }
  for (int i = 0; i < M; ++i)
    for (int j = 0; j < 1 << M; ++j)
      if (!((j >> i) & 1)) g[j ^ (1 << i)] |= g[j];
  for (int i = 0; i < 1 << M; ++i) {
    if (!g[i]) continue;
    int t = 0;
    for (int j = 0; j < M; ++j)
      if ((i >> j) & 1) t |= 1 << id[j];
    flag[t] = 1;
  }
}
int main() {
  read(n), read(m), reads(st);
  for (int i = 1; i <= n; ++i) ++cnt[st[i] - 'a'];
  for (int i = 0; i < m; ++i)
    for (int j = 0, X; j < m; ++j) {
      read(X);
      if (X == 1) continue;
      if (i <= j) addtag(i, j);
    }
  f[0] = 1;
  for (int i = 0; i < 1 << m; ++i) {
    for (int j = 0; j < m; ++j)
      if ((i >> j) & 1) {
        s[i] = s[i ^ (1 << j)] + cnt[j];
      }
    if (flag[i]) {
      f[i] = 0;
      continue;
    }
    for (int j = 0; j < m; ++j)
      if (!((i >> j) & 1)) f[i | (1 << j)] |= f[i];
  }
  int ans = 0;
  for (int i = 0; i < 1 << m; ++i)
    if (f[i]) upmax(ans, s[i]);
  print(n - ans);
  return 0;
}

```


### Prompt

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

Everybody knows of [spaghetti sort](https://en.wikipedia.org/wiki/Spaghetti_sort). You decided to implement an analog sorting algorithm yourself, but as you survey your pantry you realize you're out of spaghetti! The only type of pasta you have is ravioli, but you are not going to let this stop you...

You come up with the following algorithm. For each number in the array ai, build a stack of ai ravioli. The image shows the stack for ai = 4.

<image>

Arrange the stacks in one row in the order in which the corresponding numbers appear in the input array. Find the tallest one (if there are several stacks of maximal height, use the leftmost one). Remove it and add its height to the end of the output array. Shift the stacks in the row so that there is no gap between them. Repeat the procedure until all stacks have been removed.

At first you are very happy with your algorithm, but as you try it on more inputs you realize that it doesn't always produce the right sorted array. Turns out when two stacks of ravioli are next to each other (at any step of the process) and differ in height by two or more, the top ravioli of the taller stack slides down on top of the lower stack.

Given an input array, figure out whether the described algorithm will sort it correctly.

Input

The first line of input contains a single number n (1 ≤ n ≤ 10) — the size of the array.

The second line of input contains n space-separated integers ai (1 ≤ ai ≤ 100) — the elements of the array.

Output

Output "YES" if the array can be sorted using the described procedure and "NO" if it can not.

Examples

Input

3
1 2 3

Output

YES

Input

3
3 1 2

Output

NO

Note

In the second example the array will change even before the tallest stack is chosen for the first time: ravioli from stack of height 3 will slide on the stack of height 1, and the algorithm will output an array {2, 2, 2}.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[15];
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    int max = 0;
    for (int i = 1; i < n - i + 1; i++) {
      if (abs(a[i] - a[i + 1]) >= 2) {
        cout << "NO";
        return false;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (a[i] > a[max]) {
        max = i;
      }
    }
    int tmp = a[max];
    for (int i = max + 1; i <= n; i++) {
      a[i - 1] = a[i];
    }
    a[n] = tmp;
  }
  cout << "YES";
  return 0;
}

```


### Prompt

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

It is a balmy spring afternoon, and Farmer John's n cows are ruminating about link-cut cacti in their stalls. The cows, labeled 1 through n, are arranged so that the i-th cow occupies the i-th stall from the left. However, Elsie, after realizing that she will forever live in the shadows beyond Bessie's limelight, has formed the Mischievous Mess Makers and is plotting to disrupt this beautiful pastoral rhythm. While Farmer John takes his k minute long nap, Elsie and the Mess Makers plan to repeatedly choose two distinct stalls and swap the cows occupying those stalls, making no more than one swap each minute.

Being the meticulous pranksters that they are, the Mischievous Mess Makers would like to know the maximum messiness attainable in the k minutes that they have. We denote as pi the label of the cow in the i-th stall. The messiness of an arrangement of cows is defined as the number of pairs (i, j) such that i < j and pi > pj.

Input

The first line of the input contains two integers n and k (1 ≤ n, k ≤ 100 000) — the number of cows and the length of Farmer John's nap, respectively.

Output

Output a single integer, the maximum messiness that the Mischievous Mess Makers can achieve by performing no more than k swaps.

Examples

Input

5 2

Output

10

Input

1 10

Output

0

Note

In the first sample, the Mischievous Mess Makers can swap the cows in the stalls 1 and 5 during the first minute, then the cows in stalls 2 and 4 during the second minute. This reverses the arrangement of cows, giving us a total messiness of 10.

In the second sample, there is only one cow, so the maximum possible messiness is 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  istream &input = cin;
  ostream &output = cout;
  long long N = 0, K = 0;
  input >> N >> K;
  if (K > N / 2) K = N / 2;
  long long result = 0;
  if (K > 0) {
    result = ((N - 1) + (N - 2 * K)) * K;
  }
  output << result << endl;
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Allen wants to enter a fan zone that occupies a round square and has n entrances.

There already is a queue of a_i people in front of the i-th entrance. Each entrance allows one person from its queue to enter the fan zone in one minute.

Allen uses the following strategy to enter the fan zone:

  * Initially he stands in the end of the queue in front of the first entrance.
  * Each minute, if he is not allowed into the fan zone during the minute (meaning he is not the first in the queue), he leaves the current queue and stands in the end of the queue of the next entrance (or the first entrance if he leaves the last entrance).

Determine the entrance through which Allen will finally enter the fan zone.

Input

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

The second line contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 10^9) — the number of people in queues. These numbers do not include Allen.

Output

Print a single integer — the number of entrance that Allen will use.

Examples

Input

4
2 3 2 0

Output

3

Input

2
10 10

Output

1

Input

6
5 2 6 5 7 4

Output

6

Note

In the first example the number of people (not including Allen) changes as follows: [2, 3, 2, 0] → [1, 2, 1, 0] → [0, 1, 0, 0]. The number in bold is the queue Alles stands in. We see that he will enter the fan zone through the third entrance.

In the second example the number of people (not including Allen) changes as follows: [10, 10] → [9, 9] → [8, 8] → [7, 7] → [6, 6] → \\\ [5, 5] → [4, 4] → [3, 3] → [2, 2] → [1, 1] → [0, 0].

In the third example the number of people (not including Allen) changes as follows: [5, 2, 6, 5, 7, 4] → [4, 1, 5, 4, 6, 3] → [3, 0, 4, 3, 5, 2] → \\\ [2, 0, 3, 2, 4, 1] → [1, 0, 2, 1, 3, 0] → [0, 0, 1, 0, 2, 0].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long a[100005];
int main() {
  int n, m = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    a[i] -= i;
    if (a[i] <= 0) {
      cout << i + 1 << endl;
      m = 1;
      break;
    }
  }
  if (m == 0) {
    long long mmin;
    if (a[0] % n == 0)
      mmin = a[0] / n;
    else
      mmin = a[0] / n + 1;
    for (int i = 0; i < n; i++) {
      if (a[i] % n == 0)
        a[i] = a[i] / n;
      else
        a[i] = a[i] / n + 1;
      mmin = min(mmin, a[i]);
    }
    for (int i = 0; i < n; i++) {
      if (a[i] == mmin) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
  return 0;
}

```


### Prompt

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

Vasya likes everything infinite. Now he is studying the properties of a sequence s, such that its first element is equal to a (s1 = a), and the difference between any two neighbouring elements is equal to c (si - si - 1 = c). In particular, Vasya wonders if his favourite integer b appears in this sequence, that is, there exists a positive integer i, such that si = b. Of course, you are the person he asks for a help.

Input

The first line of the input contain three integers a, b and c ( - 109 ≤ a, b, c ≤ 109) — the first element of the sequence, Vasya's favorite number and the difference between any two neighbouring elements of the sequence, respectively.

Output

If b appears in the sequence s print "YES" (without quotes), otherwise print "NO" (without quotes).

Examples

Input

1 7 3

Output

YES

Input

10 10 0

Output

YES

Input

1 -4 5

Output

NO

Input

0 60 50

Output

NO

Note

In the first sample, the sequence starts from integers 1, 4, 7, so 7 is its element.

In the second sample, the favorite integer of Vasya is equal to the first element of the sequence.

In the third sample all elements of the sequence are greater than Vasya's favorite integer.

In the fourth sample, the sequence starts from 0, 50, 100, and all the following elements are greater than Vasya's favorite integer.

### Response

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

```


### Prompt

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

This contest, AtCoder Beginner Contest, is abbreviated as ABC.

When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC.

What is the abbreviation for the N-th round of ABC? Write a program to output the answer.

Constraints

* 100 ≤ N ≤ 999

Input

Input is given from Standard Input in the following format:

N

Output

Print the abbreviation for the N-th round of ABC.

Examples

Input

100

Output

ABC100

Input

425

Output

ABC425

Input

999

Output

ABC999

### Response

```cpp
#include <iostream>

using namespace std;

int main(){
  	int num;
  	cin >> num;
  	cout <<"ABC" << num;
}
```


### Prompt

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

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

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

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

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

Input

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

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

Note that m is not necessary the prime!

Output

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

Example

Input

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

Output

1
3
5
11
17
23
29
59
89
0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int d, m;
    cin >> d >> m;
    long long ans = 1;
    for (int i = 0; i < 30; i++) {
      if (d < (1 << i)) break;
      ans = ans * (min((1 << (i + 1)) - 1, d) - (1 << i) + 2) % m;
    }
    ans--;
    if (ans < 0) ans += m;
    cout << ans << endl;
  }
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

Ujan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebook with a description of a graph.

It is an undirected weighted graph on n vertices. It is a complete graph: each pair of vertices is connected by an edge. The weight of each edge is either 0 or 1; exactly m edges have weight 1, and all others have weight 0.

Since Ujan doesn't really want to organize his notes, he decided to find the weight of the minimum spanning tree of the graph. (The weight of a spanning tree is the sum of all its edges.) Can you find the answer for Ujan so he stops procrastinating?

Input

The first line of the input contains two integers n and m (1 ≤ n ≤ 10^5, 0 ≤ m ≤ min((n(n-1))/(2),10^5)), the number of vertices and the number of edges of weight 1 in the graph.

The i-th of the next m lines contains two integers a_i and b_i (1 ≤ a_i, b_i ≤ n, a_i ≠ b_i), the endpoints of the i-th edge of weight 1.

It is guaranteed that no edge appears twice in the input.

Output

Output a single integer, the weight of the minimum spanning tree of the graph.

Examples

Input

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

Output

2

Input

3 0

Output

0

Note

The graph from the first sample is shown below. Dashed edges have weight 0, other edges have weight 1. One of the minimum spanning trees is highlighted in orange and has total weight 2.

<image>

In the second sample, all edges have weight 0 so any spanning tree has total weight 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
int N, M;
set<int> to[MAXN + 1];
void solve() {
  int ans = 0;
  set<int> nvis;
  for (int i = 1; i <= N; i++) nvis.insert(i);
  for (int s = 1; s <= N; s++)
    if (nvis.find(s) != nvis.end()) {
      queue<int> q;
      nvis.erase(nvis.find(s));
      q.push(s);
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        set<int> tmp = nvis;
        for (int v : tmp)
          if (to[u].find(v) == to[u].end()) {
            nvis.erase(nvis.find(v));
            q.push(v);
          }
      }
      ans++;
    }
  printf("%d\n", ans - 1);
}
int main(void) {
  while (~scanf("%d%d", &N, &M)) {
    int a, b;
    for (int i = 1; i <= N; i++) to[i].clear();
    for (int i = 0; i < M; i++) {
      scanf("%d%d", &a, &b);
      to[a].insert(b);
      to[b].insert(a);
    }
    solve();
  }
  return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

The Prodiggers are quite a cool band and for this reason, they have been the surprise guest at the ENTER festival for the past 80 years. At the beginning of their careers, they weren’t so successful, so they had to spend time digging channels to earn money; hence the name. Anyway, they like to tour a lot and have surprising amounts of energy to do extremely long tours. However, they hate spending two consecutive days without having a concert, so they would like to avoid it.

A tour is defined by a sequence of concerts and days-off. You need to count in how many ways The Prodiggers can select k different tours of the same length between l and r.

For example if k = 2, l = 1 and r = 2, if we define concert day as {1} and day-off as {0}, here are all possible tours: {0}, {1}, {00}, {01}, {10}, {11}. But tour 00 can not be selected because it has 2 days-off in a row. Now, we need to count in how many ways we can select k = 2 tours of the same length in range [1;2]. Here they are: {0,1}; {01,10}; {01,11}; {10,11}.

Since their schedule is quite busy, they want you to tell them in how many ways can do that, modulo 1 000 000 007 (109 + 7).

Input

The first line of the input contains three integers k, l and r (1 ≤ k ≤ 200, 1 ≤ l ≤ r ≤ 1018).

Output

Output a single number: the number of ways to select k different tours of the same length, modulo 1 000 000 007.

Example

Input

1 1 2

Output

5

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
inline int add(const int& a, const int& b) {
  return a + b >= mod ? a + b - mod : a + b;
}
inline int dec(const int& a, const int& b) {
  return a >= b ? a - b : a - b + mod;
}
inline int mul(const int& a, const int& b) { return (long long)a * b % mod; }
inline void Add(int& a, const int& b) {
  a = a + b >= mod ? a + b - mod : a + b;
}
inline void Dec(int& a, const int& b) { a = a >= b ? a - b : a - b + mod; }
inline void Mul(int& a, const int& b) { a = (long long)a * b % mod; }
inline int ksm(int a, int p) {
  int ret = 1;
  for (; p; p >>= 1, a = mul(a, a))
    if (p & 1) Mul(ret, a);
  return ret;
}
const int N = 205;
struct cp {
  int x, y;
  cp(int x = 0, int y = 0) : x(x), y(y) {}
  friend inline cp operator+(const cp& a, const cp& b) {
    return cp(add(a.x, b.x), add(a.y, b.y));
  }
  friend inline cp operator-(const cp& a, const cp& b) {
    return cp(dec(a.x, b.x), dec(a.y, b.y));
  }
  friend inline cp operator*(const cp& a, const cp& b) {
    return cp(add(mul(a.x, b.x), mul(5, mul(a.y, b.y))),
              add(mul(a.x, b.y), mul(a.y, b.x)));
  }
  friend inline cp operator*(const cp& a, const int& b) {
    return cp(mul(a.x, b), mul(a.y, b));
  }
  friend inline cp operator/(const cp& a, const cp& b) {
    int t = ksm(dec(mul(b.x, b.x), mul(5, mul(b.y, b.y))), mod - 2);
    return cp(mul(t, dec(mul(a.x, b.x), mul(5, mul(a.y, b.y)))),
              mul(t, dec(mul(a.y, b.x), mul(a.x, b.y))));
  }
  friend inline cp operator^(cp a, int p) {
    cp ret = cp(1, 0);
    for (; p; p >>= 1, a = a * a)
      if (p & 1) ret = ret * a;
    return ret;
  }
  friend inline cp operator^(cp a, long long p) {
    cp ret = cp(1, 0);
    for (; p; p >>= 1, a = a * a)
      if (p & 1) ret = ret * a;
    return ret;
  }
} A, B, X, Y, ans;
int C[N][N], s[N][N], k;
long long l, r;
inline void init(const int& up) {
  s[0][0] = 1;
  for (register int i = 0; i <= up; ++i) {
    C[i][0] = C[i][i] = 1;
    for (register int j = 1; j < i; ++j)
      C[i][j] = add(C[i - 1][j - 1], C[i - 1][j]);
  }
  for (register int i = 1; i <= up; ++i)
    for (register int j = 1; j <= i; ++j)
      s[i][j] = add(s[i - 1][j - 1], mul(s[i - 1][j], i - 1));
  A = cp(0, ksm(5, mod - 2)), B = cp(0, mod - ksm(5, mod - 2));
  X = cp((mod + 1) >> 1, (mod + 1) >> 1),
  Y = cp((mod + 1) >> 1, mod - ((mod + 1) >> 1));
}
inline cp S(cp x, int k) {
  if (x.x == 1 && x.y == 0) return x * ((r - l + 1) % mod);
  return (x ^ l) * (((x ^ (r - l + 1)) - cp(1, 0)) / (x - cp(1, 0)));
}
inline cp calc(int k) {
  cp ret;
  for (register int i = 0; i <= k; ++i)
    ret = ret +
          (S((X ^ i) * (Y ^ (k - i)), i) * ((A ^ i) * (B ^ (k - i))) * C[k][i]);
  return ret;
}
int main() {
  cin >> k >> l >> r, l += 2, r += 2;
  init(k);
  cp t;
  register int mt = 1;
  for (register int i = 0; i <= k; ++i)
    t = calc(i) * s[k][i], (k + i)& 1 ? ans = ans - t : ans = ans + t,
    Mul(mt, i ? i : 1);
  cout << mul(ans.x, ksm(mt, mod - 2));
  return 0;
}

```


### Prompt

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

In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.

You are given two strings s1, s2 and another string called virus. Your task is to find the longest common subsequence of s1 and s2, such that it doesn't contain virus as a substring.

Input

The input contains three strings in three separate lines: s1, s2 and virus (1 ≤ |s1|, |s2|, |virus| ≤ 100). Each string consists only of uppercase English letters.

Output

Output the longest common subsequence of s1 and s2 without virus as a substring. If there are multiple answers, any of them will be accepted.

If there is no valid common subsequence, output 0.

Examples

Input

AJKEQSLOBSROFGZ
OVGURWZLWVLUXTH
OZ

Output

ORZ

Input

AA
A
A

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int dp[102][102][102];
int state[102][102][102];
string s1, s2, virus;
int n1, n2, n3;
vector<int> fail;
vector<int> failF() {
  vector<int> T(102, -1);
  for (int i = 1; i <= virus.length(); i++) {
    int pos = T[i - 1];
    while (pos != -1 && virus.at(pos) != virus.at(i - 1)) pos = T[pos];
    T[i] = pos + 1;
  }
  return T;
}
int z = 1;
int dpM(int i1, int i2, int i3) {
  if (dp[i1][i2][i3] != -1) return dp[i1][i2][i3];
  int sol = dpM(i1 + 1, i2, i3);
  state[i1][i2][i3] = -1;
  int temp = dpM(i1, i2 + 1, i3);
  if (temp > sol) {
    sol = temp;
    state[i1][i2][i3] = -2;
  }
  if (s1.at(i1) == s2.at(i2)) {
    int d = i3;
    while (d >= 0 && s1.at(i1) != virus.at(d)) {
      d = fail[d];
      z++;
    }
    d++;
    temp = 1 + dpM(i1 + 1, i2 + 1, d);
    if (temp > sol) {
      sol = temp;
      state[i1][i2][i3] = d;
    }
  }
  return dp[i1][i2][i3] = sol;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> s1 >> s2 >> virus;
  n1 = s1.length();
  n2 = s2.length();
  n3 = virus.length();
  fail = failF();
  memset(dp, 0xff, sizeof(dp));
  for (int i = 0; i <= n1; i++) {
    for (int j = 0; j <= n2; j++) dp[i][j][n3] = -1000000000;
  }
  for (int i = 0; i <= n1; i++) {
    for (int k = 0; k < n3; k++) dp[i][n2][k] = 0;
  }
  for (int j = 0; j <= n2; j++) {
    for (int k = 0; k < n3; k++) dp[n1][j][k] = 0;
  }
  int ans = dpM(0, 0, 0);
  if (ans <= 0)
    cout << 0 << '\n';
  else {
    int i1 = 0, i2 = 0, i3 = 0, c = 0;
    while (c < ans) {
      switch (state[i1][i2][i3]) {
        case -1:
          i1++;
          break;
        case -2:
          i2++;
          break;
        default:
          cout << s1.at(i1);
          i3 = state[i1][i2][i3];
          i1++;
          i2++;
          c++;
      }
    }
  }
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.

The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.

How many different PIN codes can he set this way?

Both the lucky number and the PIN code may begin with a 0.

Constraints

* 4 \leq N \leq 30000
* S is a string of length N consisting of digits.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the number of different PIN codes Takahashi can set.

Examples

Input

4
0224

Output

3

Input

6
123123

Output

17

Input

19
3141592653589793238

Output

329

### Response

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

int main() {
  int N;
  string S;
  cin >> N >> S;

  int ans = 0;

  for (int i = 0; i < 1000; i++) {
    string A = S;
    string B = to_string(i);
    while (B.size() < 3) B = '0' + B;
    for (int i = 0; i < 3; i++) {
      int j = (int)A.find(B.at(i));
      if (j == -1) goto NG;
      A = A.substr(j + 1);
    }
    ans++;
    NG:;
  }

  cout << ans << "\n";
}
```


### Prompt

Please create a solution in Cpp to the following problem:

There are N persons, conveniently numbered 1 through N. They will take 3y3s Challenge for N-1 seconds.

During the challenge, each person must look at each of the N-1 other persons for 1 seconds, in some order.

If any two persons look at each other during the challenge, the challenge ends in failure.

Find the order in which each person looks at each of the N-1 other persons, to be successful in the challenge.

Constraints

* 2 \leq N \leq 100

Input

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

N

Output

If there exists no way to be successful in the challenge, print `-1`.

If there exists a way to be successful in the challenge, print any such way in the following format:

A_{1,1} A_{1,2} ... A_{1, N-1}
A_{2,1} A_{2,2} ... A_{2, N-1}
:
A_{N,1} A_{N,2} ... A_{N, N-1}

where A_{i, j} is the index of the person that the person numbered i looks at during the j-th second.

Judging

The output is considered correct only if all of the following conditions are satisfied:

* 1 \leq A_{i,j} \leq N
* For each i, A_{i,1}, A_{i,2}, ... , A_{i, N-1} are pairwise distinct.
* Let X = A_{i, j}, then A_{X, j} \neq i always holds.

Examples

Input

7

Output

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

Input

2

Output

-1

### Response

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int n;
  cin >> n;
  if (n == 2) {
    cout << -1 << endl;
  } else if (n % 2 == 0) {
    vector<vector<int>> res(n);
    for (int i = 0; i < n; ++i) {
      for (int j = 2; j < n; ++j) {
        if (j == n / 2) continue;
        res[i].emplace_back((i + j) % n + 1);
      }
    }
    for (int i = 0; i < n; ++i) {
      if (i < n / 2) res[i].emplace_back((i + 1) % n + 1);
      else res[i].emplace_back((i + n / 2) % n + 1);
    }
    for (int i = 0; i < n; ++i) {
      if (i >= n / 2) res[i].emplace_back((i + 1) % n + 1);
      else res[i].emplace_back((i + n / 2) % n + 1);
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n - 1; ++j) cout << res[i][j] << (j < n - 2 ? " " : "\n");
    }
  } else {
    for (int i = 0; i < n; ++i) {
      for (int j = 1; j < n; ++j) {
        cout << (i + j) % n + 1 << (j < n - 1 ? " " : "\n");
      }
    }
  }
}

```


### Prompt

Create a solution in cpp for the following problem:

There is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j).

In Cell (i, j), a_{ij} coins are placed.

You can perform the following operation any number of times:

Operation: Choose a cell that was not chosen before and contains one or more coins, then move one of those coins to a vertically or horizontally adjacent cell.

Maximize the number of cells containing an even number of coins.

Constraints

* All values in input are integers.
* 1 \leq H, W \leq 500
* 0 \leq a_{ij} \leq 9

Input

Input is given from Standard Input in the following format:

H W
a_{11} a_{12} ... a_{1W}
a_{21} a_{22} ... a_{2W}
:
a_{H1} a_{H2} ... a_{HW}

Output

Print a sequence of operations that maximizes the number of cells containing an even number of coins, in the following format:

N
y_1 x_1 y_1' x_1'
y_2 x_2 y_2' x_2'
:
y_N x_N y_N' x_N'

That is, in the first line, print an integer N between 0 and H \times W (inclusive), representing the number of operations.

In the (i+1)-th line (1 \leq i \leq N), print four integers y_i, x_i, y_i' and x_i' (1 \leq y_i, y_i' \leq H and 1 \leq x_i, x_i' \leq W), representing the i-th operation. These four integers represents the operation of moving one of the coins placed in Cell (y_i, x_i) to a vertically or horizontally adjacent cell, (y_i', x_i').

Note that if the specified operation violates the specification in the problem statement or the output format is invalid, it will result in Wrong Answer.

Examples

Input

2 3
1 2 3
0 1 1

Output

3
2 2 2 3
1 1 1 2
1 3 1 2

Input

3 2
1 0
2 1
1 0

Output

3
1 1 1 2
1 2 2 2
3 1 3 2

Input

1 5
9 9 9 9 9

Output

2
1 1 1 2
1 3 1 4

### Response

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

int main(){
  int h,w;
  cin >> h >> w;
  int a[h][w];
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> a[i][j];
  int ans=0;
  int sum=h*w;
  int y[sum],x[sum],yy[sum],xx[sum];
  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++){
      if(a[i][j]%2==1){
        y[ans]=i,x[ans]=j,yy[ans]=i,xx[ans]=j+1;
        a[i][j]--; a[i][j+1]++;
        ans++;
      }
    }
  }
  for(int i=0;i<h-1;i++){
    if(a[i][w-1]%2==1){
      y[ans]=i,x[ans]=w-1,yy[ans]=i+1,xx[ans]=w-1;
      a[i][w-1]--; a[i+1][w-1]++;
      ans++;
    }
  }
  cout << ans << endl;
  for(int i=0;i<ans;i++){
    cout << y[i]+1 << ' ' << x[i]+1 << ' ' << yy[i]+1 << ' ' << xx[i]+1 << endl;
  }
}
```


### Prompt

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

A trick of fate caused Hatsumi and Taku to come to know each other. To keep the encounter in memory, they decided to calculate the difference between their ages. But the difference in ages varies depending on the day it is calculated. While trying again and again, they came to notice that the difference of their ages will hit a maximum value even though the months move on forever.

Given the birthdays for the two, make a program to report the maximum difference between their ages. The age increases by one at the moment the birthday begins. If the birthday coincides with the 29th of February in a leap year, the age increases at the moment the 1st of March arrives in non-leap years.

Input

The input is given in the following format.

y_1 m_1 d_1
y_2 m_2 d_2

The first and second lines provide Hatsumi’s and Taku’s birthdays respectively in year y_i (1 ≤ y_i ≤ 3000), month m_i (1 ≤ m_i ≤ 12), and day d_i (1 ≤ d_i ≤ Dmax) format. Where Dmax is given as follows:

* 28 when February in a non-leap year
* 29 when February in a leap-year
* 30 in April, June, September, and November
* 31 otherwise.

It is a leap year if the year represented as a four-digit number is divisible by 4. Note, however, that it is a non-leap year if divisible by 100, and a leap year if divisible by 400.

Output

Output the maximum difference between their ages.

Examples

Input

1999 9 9
2001 11 3

Output

3

Input

2008 2 29
2015 3 1

Output

8

### Response

```cpp
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
 pair< int, pair<int,int> > p1, p2;
 cin >> p1.first >> p1.second.first >> p1.second.second;
 cin >> p2.first >> p2.second.first >> p2.second.second;
 if ( p1 > p2 ) swap( p1, p2 );

 if ( p1.second < p2.second )
 cout << p2.first - p1.first + 1 << endl;
 else cout << p2.first - p1.first << endl;
}

```


### Prompt

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

DZY has a sequence a, consisting of n integers.

We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.

Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change one number to any integer you want) from the subsegment to make the subsegment strictly increasing.

You only need to output the length of the subsegment you find.

Input

The first line contains integer n (1 ≤ n ≤ 105). The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Output

In a single line print the answer to the problem — the maximum length of the required subsegment.

Examples

Input

6
7 2 3 1 5 6

Output

5

Note

You can choose subsegment a2, a3, a4, a5, a6 and change its 3rd element (that is a4) to 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int n, ans = 1;
int a[MAX];
int dp[MAX][2];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  dp[0][0] = dp[0][1] = 1;
  for (int i = 1; i < n; ++i) {
    if (a[i] > a[i - 1])
      dp[i][0] = dp[i - 1][0] + 1;
    else
      dp[i][0] = 1;
    int l = i - dp[i][0];
    if (l <= 0) dp[i][1] = i + 1;
    if (dp[i][0] + 1 < i + 1) dp[i][1] = max(dp[i][1], dp[i][0] + 1);
    if (l > 0 && a[l + 1] > a[l - 1] + 1)
      dp[i][1] = max(dp[i][1], dp[i][0] + 1 + dp[l - 1][0]);
    if (l + 2 <= i && a[l + 2] > a[l] + 1)
      dp[i][1] = max(dp[i][1], dp[i][0] + dp[l][0]);
    if (dp[i][0] == 1) dp[i][1] = max(dp[i][1], dp[i - 1][0] + 1);
    ans = max(ans, dp[i][0]);
    ans = max(ans, dp[i][1]);
  }
  cout << ans;
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

The Little Girl loves problems on games very much. Here's one of them.

Two players have got a string s, consisting of lowercase English letters. They play a game that is described by the following rules:

  * The players move in turns; In one move the player can remove an arbitrary letter from string s.
  * If the player before his turn can reorder the letters in string s so as to get a palindrome, this player wins. A palindrome is a string that reads the same both ways (from left to right, and vice versa). For example, string "abba" is a palindrome and string "abc" isn't.

Determine which player will win, provided that both sides play optimally well — the one who moves first or the one who moves second.

Input

The input contains a single line, containing string s (1 ≤ |s| ≤ 103). String s consists of lowercase English letters.

Output

In a single line print word "First" if the first player wins (provided that both players play optimally well). Otherwise, print word "Second". Print the words without the quotes.

Examples

Input

aba

Output

First

Input

abca

Output

Second

### Response

```cpp
#include <bits/stdc++.h>
char alp[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
int char_to_int(char c) {
  for (int i = 0; i < 26; i++)
    if (c == alp[i]) return i;
}
int main() {
  char *str = (char *)malloc(sizeof(char) * 1001);
  int *trace = (int *)calloc(1001, sizeof(int));
  scanf("%s", str);
  int n = strlen(str), m;
  for (int i = 0; i < n; i++) {
    m = char_to_int(*(str + i));
    *(trace + m) = *(trace + m) + 1;
  }
  int odds = 0;
  for (int i = 0; i < 26; i++) {
    if (*(trace + i) % 2 != 0) odds++;
  }
  if (odds == 0 || odds == 1)
    printf("First");
  else {
    if (odds % 2 != 0) printf("First");
    if (odds % 2 == 0) printf("Second");
  }
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Mr. Scrooge, a very busy man, decided to count the time he wastes on all sorts of useless stuff to evaluate the lost profit. He has already counted the time he wastes sleeping and eating. And now Mr. Scrooge wants to count the time he has wasted signing papers.

Mr. Scrooge's signature can be represented as a polyline A1A2... An. Scrooge signs like that: first it places a pen at the point A1, then draws a segment from point A1 to point A2, then he draws a segment from point A2 to point A3 and so on to point An, where he stops signing and takes the pen off the paper. At that the resulting line can intersect with itself and partially repeat itself but Scrooge pays no attention to it and never changes his signing style. As Scrooge makes the signature, he never takes the pen off the paper and his writing speed is constant — 50 millimeters per second.

Scrooge signed exactly k papers throughout his life and all those signatures look the same.

Find the total time Scrooge wasted signing the papers.

Input

The first line contains two integers n and k (2 ≤ n ≤ 100, 1 ≤ k ≤ 1000). Each of the following n lines contains the coordinates of the polyline's endpoints. The i-th one contains coordinates of the point Ai — integers xi and yi, separated by a space.

All points Ai are different. The absolute value of all coordinates does not exceed 20. The coordinates are measured in millimeters.

Output

Print one real number — the total time Scrooges wastes on signing the papers in seconds. The absolute or relative error should not exceed 10 - 6.

Examples

Input

2 1
0 0
10 0

Output

0.200000000

Input

5 10
3 1
-5 6
-2 -1
3 2
10 0

Output

6.032163204

Input

6 10
5 0
4 0
6 0
3 0
7 0
2 0

Output

3.000000000

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 1e2 + 5, M = 100 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7, base = 131,
          mod2 = 1000136437, mod3 = 998244353;
const double EPS = 1e-9;
int n, k;
complex<double> tmp;
long double ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    complex<double> p(a, b);
    if (i) {
      ans += hypot(p.real() - tmp.real(), p.imag() - tmp.imag());
    }
    tmp = p;
  }
  cout << fixed << setprecision(6) << ans * (k * 1.0 / 50.0);
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and gives it to the second soldier. Then the second one tries to make maximum possible number of rounds. Each round consists of choosing a positive integer x > 1, such that n is divisible by x and replacing n with n / x. When n becomes equal to 1 and there is no more possible valid moves the game is over and the score of the second soldier is equal to the number of rounds he performed.

To make the game more interesting, first soldier chooses n of form a! / b! for some positive integer a and b (a ≥ b). Here by k! we denote the factorial of k that is defined as a product of all positive integers not large than k.

What is the maximum possible score of the second soldier?

Input

First line of input consists of single integer t (1 ≤ t ≤ 1 000 000) denoting number of games soldiers play.

Then follow t lines, each contains pair of integers a and b (1 ≤ b ≤ a ≤ 5 000 000) defining the value of n for a game.

Output

For each game output a maximum score that the second soldier can get.

Examples

Input

2
3 1
6 3

Output

2
5

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long primes[5000009] = {0, 0}, arr[5000009] = {0};
int main() {
  for (long long f = 2; f <= 5000003; f++) {
    if (!primes[f]) {
      for (long long f1 = f; f1 <= 5000003; f1 += f) {
        long long temp = f1;
        while (temp % f == 0) {
          primes[f1]++;
          temp /= f;
        }
      }
    }
  }
  for (int f = 1; f <= 5000003; f++) arr[f] = primes[f] + arr[f - 1];
  long long t, a, b;
  scanf("%I64d", &t);
  while (t--) {
    scanf("%I64d %I64d", &a, &b);
    printf("%I64d\n", arr[a] - arr[b]);
  }
}

```


### Prompt

Create a solution in Cpp for the following problem:

Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.

Note, that during capitalization all the letters except the first one remains unchanged.

Input

A single line contains a non-empty word. This word consists of lowercase and uppercase English letters. The length of the word will not exceed 103.

Output

Output the given word after capitalization.

Examples

Input

ApPLe

Output

ApPLe

Input

konjac

Output

Konjac

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  char *a;
  int n = 10000;
  a = new char[n];
  cin >> a;
  a[0] = toupper(a[0]);
  cout << a;
  return 0;
}

```


### Prompt

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

The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or water. The map is surrounded by the ocean.

Lakes are the maximal regions of water cells, connected by sides, which are not connected with the ocean. Formally, lake is a set of water cells, such that it's possible to get from any cell of the set to any other without leaving the set and moving only to cells adjacent by the side, none of them is located on the border of the rectangle, and it's impossible to add one more water cell to the set such that it will be connected with any other cell.

You task is to fill up with the earth the minimum number of water cells so that there will be exactly k lakes in Berland. Note that the initial number of lakes on the map is not less than k.

Input

The first line of the input contains three integers n, m and k (1 ≤ n, m ≤ 50, 0 ≤ k ≤ 50) — the sizes of the map and the number of lakes which should be left on the map.

The next n lines contain m characters each — the description of the map. Each of the characters is either '.' (it means that the corresponding cell is water) or '*' (it means that the corresponding cell is land).

It is guaranteed that the map contain at least k lakes.

Output

In the first line print the minimum number of cells which should be transformed from water to land.

In the next n lines print m symbols — the map after the changes. The format must strictly follow the format of the map in the input data (there is no need to print the size of the map). If there are several answers, print any of them.

It is guaranteed that the answer exists on the given data.

Examples

Input

5 4 1
****
*..*
****
**.*
..**

Output

1
****
*..*
****
****
..**

Input

3 3 0
***
*.*
***

Output

1
***
***
***

Note

In the first example there are only two lakes — the first consists of the cells (2, 2) and (2, 3), the second consists of the cell (4, 3). It is profitable to cover the second lake because it is smaller. Pay attention that the area of water in the lower left corner is not a lake because this area share a border with the ocean.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, visited[55][55] = {}, kk, ans,
    cnt;
vector<pair<int, pair<int, int>>> del;
bool r = true;
int n, m, k;
char dat[55][55];
int dfs(int a, int b, bool c) {
  if (a == 0 or b == 0 or a == n - 1 or b == m - 1) {
    r = false;
    return 0;
  }
  if (visited[a][b]) return 0;
  visited[a][b] = 1;
  if (dat[a][b] == '*') return 0;
  for (int(i) = 0; (i) < (4); ++(i)) {
    if (dat[a + dx[i]][b + dy[i]] == '.' &&
        visited[a + dx[i]][b + dy[i]] == 0) {
      dfs(a + dx[i], b + dy[i], c);
    }
  }
  if (c) dat[a][b] = '*';
  cnt++;
  if (!r) cnt = 0;
  return r;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (int(i) = 0; (i) < (n); ++(i)) {
    for (int(j) = 0; (j) < (m); ++(j)) {
      cin >> dat[i][j];
    }
  }
  for (int(i) = 0; (i) < (n); ++(i)) {
    for (int(j) = 0; (j) < (m); ++(j)) {
      cnt = 0;
      r = true;
      dfs(i, j, false);
      if (r and cnt > 0) {
        del.push_back(make_pair(cnt, make_pair(i, j)));
        kk++;
      }
    }
  }
  sort(del.begin(), del.end());
  for (int(i) = 0; (i) < (55); ++(i))
    for (int(j) = 0; (j) < (55); ++(j)) visited[i][j] = 0;
  for (int(i) = 0; (i) < (kk - k); ++(i)) {
    int f = del.front().first;
    int sf = del.front().second.first;
    int ss = del.front().second.second;
    del.erase(del.begin());
    ans += f;
    dfs(sf, ss, true);
  }
  cout << ans << endl;
  for (int(i) = 0; (i) < (n); ++(i)) {
    for (int(j) = 0; (j) < (m); ++(j)) {
      cout << dat[i][j];
    }
    cout << endl;
  }
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n square cells (that is, on a 1 × n table).

At the beginning of the game Alice puts k ships on the field without telling their positions to Bob. Each ship looks as a 1 × a rectangle (that is, it occupies a sequence of a consecutive squares of the field). The ships cannot intersect and even touch each other.

After that Bob makes a sequence of "shots". He names cells of the field and Alice either says that the cell is empty ("miss"), or that the cell belongs to some ship ("hit").

But here's the problem! Alice like to cheat. May be that is why she responds to each Bob's move with a "miss".

Help Bob catch Alice cheating — find Bob's first move, such that after it you can be sure that Alice cheated.

Input

The first line of the input contains three integers: n, k and a (1 ≤ n, k, a ≤ 2·105) — the size of the field, the number of the ships and the size of each ship. It is guaranteed that the n, k and a are such that you can put k ships of size a on the field, so that no two ships intersect or touch each other.

The second line contains integer m (1 ≤ m ≤ n) — the number of Bob's moves.

The third line contains m distinct integers x1, x2, ..., xm, where xi is the number of the cell where Bob made the i-th shot. The cells are numbered from left to right from 1 to n.

Output

Print a single integer — the number of such Bob's first move, after which you can be sure that Alice lied. Bob's moves are numbered from 1 to m in the order the were made. If the sought move doesn't exist, then print "-1".

Examples

Input

11 3 3
5
4 8 6 1 11

Output

3

Input

5 1 3
2
1 5

Output

-1

Input

5 1 3
1
3

Output

1

### Response

```cpp
#include <bits/stdc++.h>
const int MOD = 1000000007;
const int MAX = 200005;
int arr[MAX];
using namespace std;
int main() {
  int n, k, a;
  scanf("%d %d %d", &n, &k, &a);
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &arr[i]);
  };
  int ct = (n + 1) / (a + 1);
  set<pair<int, int> > s;
  s.insert(make_pair(n, 1));
  set<pair<int, int> >::iterator it;
  for (int i = 0; i < m; i++) {
    int q = arr[i];
    it = s.lower_bound(make_pair(q, 1));
    pair<int, int> ele = *it;
    if (ele.first == ele.second) {
      if (a == 1) {
        ct--;
      }
      s.erase(ele);
      if (ct < k) {
        cout << i + 1 << endl;
        return 0;
      }
      continue;
    }
    ct -= (ele.first - ele.second + 1 + 1) / (a + 1);
    ct += (q - ele.second + 1) / (a + 1) + (ele.first - q + 1) / (a + 1);
    s.erase(ele);
    if (ct < k) {
      cout << i + 1 << endl;
      return 0;
    }
    s.insert(make_pair(ele.first, q + 1));
    s.insert(make_pair(q - 1, ele.second));
  }
  cout << -1 << endl;
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

It’s riot time on football stadium Ramacana! Raging fans have entered the field and the police find themselves in a difficult situation. The field can be represented as a square in the coordinate system defined by two diagonal vertices in (0,0) and (105, 105). The sides of that square are also considered to be inside the field, everything else is outside.

In the beginning, there are N fans on the field. For each fan we are given his speed, an integer vi as well as his integer coordinates (xi, yi). A fan with those coordinates might move and after one second he might be at any point (xi + p, yi + q) where 0 ≤ |p| + |q| ≤ vi. p, q are both integers.

Points that go outside of the square that represents the field are excluded and all others have equal probability of being the location of that specific fan after one second.

Andrej, a young and promising police officer, has sent a flying drone to take a photo of the riot from above. The drone’s camera works like this:

  1. It selects three points with integer coordinates such that there is a chance of a fan appearing there after one second. They must not be collinear or the camera won’t work. It is guaranteed that not all of the initial positions of fans will be on the same line.
  2. Camera focuses those points and creates a circle that passes through those three points. A photo is taken after one second (one second after the initial state).
  3. Everything that is on the circle or inside it at the moment of taking the photo (one second after focusing the points) will be on the photo.

Your goal is to select those three points so that the expected number of fans seen on the photo is maximized. If there are more such selections, select those three points that give the circle with largest radius among them. If there are still more suitable selections, any one of them will be accepted. If your answer follows conditions above and radius of circle you return is smaller then the optimal one by 0.01, your output will be considered as correct.

No test will have optimal radius bigger than 1010.

Input

The first line contains the number of fans on the field, N. The next N lines contain three integers: xi ,yi, vi. They are the x-coordinate, y-coordinate and speed of fan i at the beginning of the one second interval considered in the task.

  * 3 ≤ N ≤ 105
  * 0 ≤ xi, yi ≤ 105
  * 0 ≤ vi ≤ 1000
  * All numbers are integers

Output

You need to output the three points that camera needs to select. Print them in three lines, with every line containing the x-coordinate, then y-coordinate, separated by a single space. The order of points does not matter.

Examples

Input

3
1 1 1
1 1 1
1 2 1

Output

2 2
2 1
1 0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const int N = 100000;
int n;
int m;
vector<pair<int, int> > v;
void add(int x, int y) { v.push_back(make_pair(x, y)); }
long long vect(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
  return (long long)(b.first - a.first) * (c.second - b.second) -
         (long long)(b.second - a.second) * (c.first - b.first);
}
long double dist(pair<int, int> a, pair<int, int> b) {
  return sqrt(abs(
      (((long double)a.first - b.first) * ((long double)a.first - b.first)) +
      (((long double)a.second - b.second) *
       ((long double)a.second - b.second))));
}
long double getr(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
  long double A = dist(a, b);
  long double B = dist(a, c);
  long double C = dist(b, c);
  long double p = (A + B + C) / 2;
  long double S = 4 * sqrt(abs(p * (p - A) * (p - B) * (p - C)));
  return A * B * C / S;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y, d;
    scanf("%d%d%d", &x, &y, &d);
    if (x >= d)
      add(x - d, y);
    else {
      int h = d - x;
      if (y + h > N)
        add(0, N);
      else
        add(0, y + h);
      if (y - h < 0)
        add(0, 0);
      else
        add(0, y - h);
    }
    if (x + d <= N)
      add(x + d, y);
    else {
      int h = x + d - N;
      if (y + h > N)
        add(N, N);
      else
        add(N, y + h);
      if (y - h < 0)
        add(N, 0);
      else
        add(N, y - h);
    }
    if (y >= d)
      add(x, y - d);
    else {
      int h = d - y;
      if (x + h > N)
        add(N, 0);
      else
        add(x + h, 0);
      if (x - h < 0)
        add(0, 0);
      else
        add(x - h, 0);
    }
    if (y + d <= N)
      add(x, y + d);
    else {
      int h = y + d - N;
      if (x + h > N)
        add(N, N);
      else
        add(x + h, N);
      if (x - h < 0)
        add(0, N);
      else
        add(x - h, N);
    }
  }
  sort((v).begin(), (v).end());
  v.resize(unique((v).begin(), (v).end()) - v.begin());
  vector<pair<int, int> > q1, q2;
  for (int i = 0; i < ((int)(v).size()); i++) {
    while (((int)(q1).size()) > 1 &&
           vect(q1[((int)(q1).size()) - 2], q1[((int)(q1).size()) - 1], v[i]) >=
               0)
      q1.pop_back();
    while (((int)(q2).size()) > 1 &&
           vect(q2[((int)(q2).size()) - 2], q2[((int)(q2).size()) - 1], v[i]) <=
               0)
      q2.pop_back();
    q1.push_back(v[i]);
    q2.push_back(v[i]);
  }
  q2.pop_back();
  reverse((q2).begin(), (q2).end());
  q2.pop_back();
  for (int i = 0; i < ((int)(q2).size()); i++) q1.push_back(q2[i]);
  pair<long double, int> best(-1e100, 0);
  q1.push_back(q1[0]);
  q1.push_back(q1[1]);
  for (int i = 0; i + 2 < ((int)(q1).size()); i++) {
    long double r = getr(q1[i], q1[i + 1], q1[i + 2]);
    best = max(best, make_pair(r, i));
  }
  printf("%d %d\n", q1[best.second].first, q1[best.second].second);
  printf("%d %d\n", q1[best.second + 1].first, q1[best.second + 1].second);
  printf("%d %d\n", q1[best.second + 2].first, q1[best.second + 2].second);
  return 0;
}

```


### Prompt

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

Zxr960115 is owner of a large farm. He feeds m cute cats and employs p feeders. There's a straight road across the farm and n hills along the road, numbered from 1 to n from left to right. The distance between hill i and (i - 1) is di meters. The feeders live in hill 1.

One day, the cats went out to play. Cat i went on a trip to hill hi, finished its trip at time ti, and then waited at hill hi for a feeder. The feeders must take all the cats. Each feeder goes straightly from hill 1 to n without waiting at a hill and takes all the waiting cats at each hill away. Feeders walk at a speed of 1 meter per unit time and are strong enough to take as many cats as they want.

For example, suppose we have two hills (d2 = 1) and one cat that finished its trip at time 3 at hill 2 (h1 = 2). Then if the feeder leaves hill 1 at time 2 or at time 3, he can take this cat, but if he leaves hill 1 at time 1 he can't take it. If the feeder leaves hill 1 at time 2, the cat waits him for 0 time units, if the feeder leaves hill 1 at time 3, the cat waits him for 1 time units.

Your task is to schedule the time leaving from hill 1 for each feeder so that the sum of the waiting time of all cats is minimized.

Input

The first line of the input contains three integers n, m, p (2 ≤ n ≤ 105, 1 ≤ m ≤ 105, 1 ≤ p ≤ 100).

The second line contains n - 1 positive integers d2, d3, ..., dn (1 ≤ di < 104).

Each of the next m lines contains two integers hi and ti (1 ≤ hi ≤ n, 0 ≤ ti ≤ 109).

Output

Output an integer, the minimum sum of waiting time of all cats.

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

4 6 2
1 3 5
1 0
2 1
4 9
1 10
2 10
3 12

Output

3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long dp[110][101000];
long long d[100010];
long long sumd[100010];
int n, m, p;
int dis[100010];
int tot = 1;
struct STA {
  struct Sta {
    long long x, y;
    Sta(long long a, long long b) : x(a), y(b) {}
    Sta() {}
  } s[100010];
  int top, now;
  void init() {
    top = -1;
    now = 0;
  }
  void P(long long a, long long b) {
    if (top < 1)
      s[++top] = Sta(a, b);
    else {
      while (1) {
        if (top == 0) {
          s[++top] = Sta(a, b);
          break;
        }
        long long y1 = b - s[top].y;
        long long x1 = a - s[top].x;
        long long y2 = s[top].y - s[top - 1].y;
        long long x2 = s[top].x - s[top - 1].x;
        if (y1 * x2 > y2 * x1) {
          s[++top] = Sta(a, b);
          break;
        } else {
          top--;
        }
      }
    }
  }
} S;
double cal(int x) {
  return double(S.s[x + 1].y - S.s[x].y) / double(S.s[x + 1].x - S.s[x].x);
}
int main() {
  scanf("%d%d%d", &n, &m, &p);
  for (int i = 2; i < n + 1; ++i) {
    scanf("%d", &dis[i]);
    dis[i] = dis[i - 1] + dis[i];
  }
  int h, t;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &h, &t);
    d[tot++] = t - dis[h];
  }
  sort(d + 1, d + tot);
  S.init();
  for (int i = 1; i < tot; ++i) sumd[i] = sumd[i - 1] + d[i];
  for (int i = 1; i < tot; ++i) dp[1][i] = d[i] * i - sumd[i];
  for (int k = 2; k < p + 1; ++k) {
    for (int i = k; i < tot; ++i) {
      S.P(i - 1, dp[k - 1][i - 1] + sumd[i - 1]);
      while (S.now < S.top && cal(S.now) < double(d[i])) {
        S.now++;
      }
      dp[k][i] = S.s[S.now].y - S.s[S.now].x * d[i] + i * d[i] - sumd[i];
    }
    S.init();
  }
  if (p >= tot) {
    puts("0");
    return 0;
  }
  printf("%I64d\n", dp[p][tot - 1]);
  return 0;
}

```


### Prompt

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

In the famous Oh-Suit-United tournament, two teams are playing against each other for the grand prize of precious pepper points.

The first team consists of n players, and the second team consists of m players. Each player has a potential: the potential of the i-th player in the first team is a_i, and the potential of the i-th player in the second team is b_i.

In the tournament, all players will be on the stage in some order. There will be a scoring device, initially assigned to an integer k, which will be used to value the performance of all players.

The scores for all players will be assigned in the order they appear on the stage. Let the potential of the current player be x, and the potential of the previous player be y (y equals x for the first player). Then, x-y is added to the value in the scoring device, Afterwards, if the value in the scoring device becomes negative, the value will be reset to 0. Lastly, the player's score is assigned to the current value on the scoring device. The score of a team is the sum of the scores of all its members.

As an insane fan of the first team, Nezzar desperately wants the biggest win for the first team. He now wonders what is the maximum difference between scores of the first team and the second team.

Formally, let the score of the first team be score_f and the score of the second team be score_s. Nezzar wants to find the maximum value of score_f - score_s over all possible orders of players on the stage.

However, situation often changes and there are q events that will happen. There are three types of events:

  * 1 pos x — change a_{pos} to x;
  * 2 pos x — change b_{pos} to x;
  * 3 x — tournament is held with k = x and Nezzar wants you to compute the maximum value of score_f - score_s.

Can you help Nezzar to answer the queries of the third type?

Input

The first line contains three integers n, m, and q (1 ≤ n,m ≤ 2 ⋅ 10^5, 1 ≤ q ≤ 5 ⋅ 10^5).

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

The third line contains m integers b_1, b_2, …, b_m (0 ≤ b_i ≤ 10^6).

The following q lines contain descriptions of events, described in the statement, each in one of the three possible formats:

  * 1 pos x (1 ≤ pos ≤ n, 0 ≤ x ≤ 10^6);
  * 2 pos x (1 ≤ pos ≤ m, 0 ≤ x ≤ 10^6);
  * 3 x (0 ≤ x ≤ 10^6).

Output

For each query of the third type print the answer to this query.

Examples

Input

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

Output

-4
9

Input

7 8 12
958125 14018 215153 35195 90380 30535 204125
591020 930598 252577 333333 999942 1236 9456 82390
3 123458
2 4 444444
3 123456
1 2 355555
3 123478
3 1111
2 6 340324
3 1111
2 8 999999
2 7 595959
3 222222
3 100

Output

1361307
1361311
1702804
1879305
1821765
1078115
1675180

Note

In the first query of the first test, the tournament is held with k = 5. It would be optimal to arrange players in such way (here their potentials are written):

\underline{7}, 3, 5, 4, 6, \underline{1}, \underline{2} (underlined numbers are potentials of players that are from the first team).

The individual scores of players, numbered in the order of their appearance, are:

  * max(5 + (7 - 7), 0) = 5 for the \underline{1}-st player;
  * max(5 + (3 - 7), 0) = 1 for the 2-nd player;
  * max(1 + (5 - 3), 0) = 3 for the 3-rd player;
  * max(3 + (4 - 5), 0) = 2 for the 4-th player;
  * max(2 + (6 - 4), 0) = 4 for the 5-th player;
  * max(4 + (1 - 6), 0) = 0 for the \underline{6}-th player;
  * max(0 + (2 - 1), 0) = 1 for the \underline{7}-th player.

So, score_f = 5 + 0 + 1 = 6 and score_s = 1 + 3 + 2 + 4 = 10. The score difference is 6 - 10 = -4. It can be proven, that it is the maximum possible score difference.

### Response

```cpp
//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 1100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
struct bit {
	ll d[maxn + 105];
	int lb(int a) {
		return a & -a;
	}
	void ins(int pl, int x) {
		pl++;
		while (pl < maxn)
			d[pl] += x,
			pl += lb(pl);
	}
	ll q(int pl) {
		pl++;
		ll ans = 0;
		while (pl) {
			ans += d[pl];
			pl -= lb(pl);
		}
		return ans;
	}
	ll q(int l, int r) {
		chkmax(l, 0);
		chkmin(r, maxn + 10);
		return q(r) - q(l - 1);
	}
}s[2];

ll calc(int a) {
	ll ans = s[1].q(a, maxn + 50) - 1ll * a * s[0].q(a, maxn + 50);
	return ans;
}
ll sum[2];
int e[2][maxn];
ll sz[2];
multiset<int> tot;
multiset<int> us[2];
#define iter multiset<int>::iterator
int main() {
	int q;
	cin >> sz[0] >> sz[1] >> q;
	for (int i = 0; i < 2; i++)
		for (int j = 1; j <= sz[i]; j++) {
			scanf("%d", &e[i][j]),
			sum[i] += e[i][j],
			us[i].insert(e[i][j]),
			tot.insert(e[i][j]);
		}
	for (int j = 1; j <= sz[1]; j++)
		s[0].ins(e[1][j], 1),
		s[1].ins(e[1][j], e[1][j]);
	while (q--) {
		int t, u;
		scanf("%d%d", &t, &u);
		t--;
		if (t <= 1) {
			int to;
			scanf("%d", &to);
			tot.erase(tot.find(e[t][u]));
			us[t].erase(us[t].find(e[t][u]));

			sum[t] -= e[t][u];

			if (t == 1)
				s[0].ins(e[t][u], -1),
				s[1].ins(e[t][u], -e[t][u]);

			e[t][u] = to;

			tot.insert(e[t][u]);
			us[t].insert(e[t][u]);
			sum[t] += e[t][u];

			if (t == 1)
				s[0].ins(e[t][u], 1),
				s[1].ins(e[t][u], e[t][u]);

		}
		else {
			// 第一种 ： <= min + k
			int mn = *tot.begin();
			int k = u;

			ll ans = -6e18;
			chkmax(ans, sum[0] - 1ll * sz[0] * (mn - k) - (sum[1] - 1ll * sz[1] * (mn - k)));

			iter cur = tot.lower_bound(mn + k + 1);
			if (cur != tot.begin()) {
				cur--;
				int cr = *cur;
				assert(cr <= mn + k);
				chkmax(ans, (sum[0] - 1ll * sz[0] * (cr - k)) - (sum[1] - 1ll * sz[1] * (cr - k)));
			}

			int mx = *(--us[0].end());
			ll dsum = sum[0] - 1ll * sz[0] * mn;

			int um = *(--us[1].end());

			if (mx > mn + k) {
				chkmax(ans, -calc(mx - k) + dsum - (mx - mn) + k);

				iter h = us[0].lower_bound(um + k);
				if (h != us[0].end()) {
					mx = *h;
					if (mx > mn + k)
						chkmax(ans, -calc(mx - k) + dsum - (mx - mn) + k);
				}

				if (h != us[0].begin()) {
					h--;
					mx = *h;
					if (mx > mn + k)
						chkmax(ans, -calc(mx - k) + dsum - (mx - mn) + k);
				}
			}

			mx = um;
			if (mx > mn + k)
				chkmax(ans, -calc(mx - k) + dsum);

			printf("%lld\n", ans);
		}
	}
	return 0;
}
```


### Prompt

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

Vasya and Petya have invented a new game. Vasya takes a stripe consisting of 1 × n square and paints the squares black and white. After that Petya can start moves — during a move he may choose any two neighboring squares of one color and repaint these two squares any way he wants, perhaps in different colors. Petya can only repaint the squares in white and black colors. Petya’s aim is to repaint the stripe so that no two neighboring squares were of one color. Help Petya, using the given initial coloring, find the minimum number of moves Petya needs to win.

Input

The first line contains number n (1 ≤ n ≤ 1000) which represents the stripe’s length. The second line contains exactly n symbols — the line’s initial coloring. 0 corresponds to a white square, 1 corresponds to a black one.

Output

If Petya cannot win with such an initial coloring, print -1. Otherwise print the minimum number of moves Petya needs to win.

Examples

Input

6
111010

Output

1

Input

5
10001

Output

1

Input

7
1100010

Output

2

Input

5
00100

Output

2

Note

In the first sample Petya can take squares 1 and 2. He repaints square 1 to black and square 2 to white.

In the second sample Petya can take squares 2 and 3. He repaints square 2 to white and square 3 to black.

### Response

```cpp
#include <bits/stdc++.h>
int arr[1024];
int narr;
int func(int x) {
  int i, count = 0;
  for (i = 0; i < narr; i++) {
    ("ele = %d : %d\n", i, arr[i]);
    if ((i % 2) == 0) {
      if (arr[i] != x) {
        count++;
      }
    } else {
      if (arr[i] != (!x)) {
        ("%d : %d : ( !x not matched = %d ) \n", i, arr[i], !x);
        count++;
      }
    }
  }
  return count;
}
int main() {
  int t, i;
  int v1, v2;
  scanf("%d\n", &narr);
  for (i = 0; i < narr; i++) {
    t = getchar();
    arr[i] = t - '0';
  }
  v1 = func(1);
  v2 = func(0);
  ("1 at even pos = %d\n", func(1));
  ("1 at odd  pos = %d\n", func(0));
  printf("%d\n", (v1 > v2) ? v2 : v1);
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

You already know that Valery's favorite sport is biathlon. Due to your help, he learned to shoot without missing, and his skills are unmatched at the shooting range. But now a smaller task is to be performed, he should learn to complete the path fastest.

The track's map is represented by a rectangle n × m in size divided into squares. Each square is marked with a lowercase Latin letter (which means the type of the plot), with the exception of the starting square (it is marked with a capital Latin letters S) and the terminating square (it is marked with a capital Latin letter T). The time of movement from one square to another is equal to 1 minute. The time of movement within the cell can be neglected. We can move from the cell only to side-adjacent ones, but it is forbidden to go beyond the map edges. Also the following restriction is imposed on the path: it is not allowed to visit more than k different types of squares (squares of one type can be visited an infinite number of times). Squares marked with S and T have no type, so they are not counted. But S must be visited exactly once — at the very beginning, and T must be visited exactly once — at the very end.

Your task is to find the path from the square S to the square T that takes minimum time. Among all shortest paths you should choose the lexicographically minimal one. When comparing paths you should lexicographically represent them as a sequence of characters, that is, of plot types.

Input

The first input line contains three integers n, m and k (1 ≤ n, m ≤ 50, n·m ≥ 2, 1 ≤ k ≤ 4). Then n lines contain the map. Each line has the length of exactly m characters and consists of lowercase Latin letters and characters S and T. It is guaranteed that the map contains exactly one character S and exactly one character T.

Pretest 12 is one of the maximal tests for this problem.

Output

If there is a path that satisfies the condition, print it as a sequence of letters — the plot types. Otherwise, print "-1" (without quotes). You shouldn't print the character S in the beginning and T in the end.

Note that this sequence may be empty. This case is present in pretests. You can just print nothing or print one "End of line"-character. Both will be accepted.

Examples

Input

5 3 2
Sba
ccc
aac
ccc
abT

Output

bcccc

Input

3 4 1
Sxyy
yxxx
yyyT

Output

xxxx

Input

1 3 3
TyS

Output

y

Input

1 4 1
SxyT

Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline int GetBit(int mask, int num) { return (mask >> num) & 1; }
inline int GetAmountOfBits(int mask) {
  int ans = 0;
  while (mask > 0) {
    ans += (mask & 1);
    mask >>= 1;
  }
  return ans;
}
const int kAlphabetSize = 26;
const int kDx[4] = {-1, 0, 0, 1};
const int kDy[4] = {0, -1, 1, 0};
int n, m, k;
vector<vector<char> > field;
int si, sj;
int fi, fj;
bool ans_found;
int ans_len;
string ans_path;
vector<vector<bool> > used;
vector<vector<bool> > inused;
vector<vector<int> > dist;
vector<int> char_posses_i[kAlphabetSize];
vector<int> char_posses_j[kAlphabetSize];
void ClearUsed(int mask, vector<vector<bool> >& used) {
  for (int c = 0; c < kAlphabetSize; ++c) {
    if (!GetBit(mask, c)) {
      continue;
    }
    for (int i = 0; i < (int)char_posses_i[c].size(); ++i) {
      used[char_posses_i[c][i]][char_posses_j[c][i]] = false;
    }
  }
  used[si][sj] = false;
  used[fi][fj] = false;
}
void UpdateAns(int mask) {
  if (dist[fi][fj] == 1) {
    ans_found = true;
    ans_len = 1;
    ans_path = "";
    return;
  }
  string cur_path;
  cur_path.reserve(dist[fi][fj] - 1);
  deque<int> qi;
  deque<int> qj;
  qi.push_back(fi);
  qj.push_back(fj);
  inused[fi][fj] = true;
  while (!qi.empty()) {
    int ci = qi.front();
    qi.pop_front();
    int cj = qj.front();
    qj.pop_front();
    for (int step_index = 0; step_index < 4; ++step_index) {
      int ni = ci + kDx[step_index];
      int nj = cj + kDy[step_index];
      if (ni >= 0 && ni < n && nj >= 0 && nj < m && !inused[ni][nj] &&
          used[ni][nj] && dist[ni][nj] + 1 == dist[ci][cj]) {
        inused[ni][nj] = true;
        qi.push_back(ni);
        qj.push_back(nj);
      }
    }
  }
  qi.push_back(si);
  qj.push_back(sj);
  used[si][sj] = false;
  while (!qi.empty()) {
    char min_char = field[qi[0]][qj[0]];
    for (int i = 1; i < (int)qi.size(); ++i) {
      min_char = min(min_char, field[qi[i]][qj[i]]);
    }
    if (min_char != 'S' && min_char != 'T') {
      cur_path.push_back(min_char);
    }
    int sz = qi.size();
    for (int itr = 0; itr < (int)sz; ++itr) {
      int ci = qi.front();
      qi.pop_front();
      int cj = qj.front();
      qj.pop_front();
      if (field[ci][cj] != min_char) {
        continue;
      }
      for (int step_index = 0; step_index < 4; ++step_index) {
        int ni = ci + kDx[step_index];
        int nj = cj + kDy[step_index];
        if (ni >= 0 && ni < n && nj >= 0 && nj < m && inused[ni][nj] &&
            used[ni][nj] && dist[ni][nj] == dist[ci][cj] + 1) {
          used[ni][nj] = false;
          qi.push_back(ni);
          qj.push_back(nj);
        }
      }
    }
  }
  ClearUsed(mask, inused);
  if (!ans_found || dist[fi][fj] < ans_len || cur_path < ans_path) {
    ans_found = true;
    ans_len = dist[fi][fj];
    ans_path = cur_path;
  }
}
void Solve(int mask) {
  queue<int> qi;
  queue<int> qj;
  used[si][sj] = true;
  dist[si][sj] = 0;
  qi.push(si);
  qj.push(sj);
  while (!qi.empty()) {
    int ci = qi.front();
    qi.pop();
    int cj = qj.front();
    qj.pop();
    for (int step_index = 0; step_index < 4; ++step_index) {
      int ni = ci + kDx[step_index];
      int nj = cj + kDy[step_index];
      if (ni >= 0 && ni < n && nj >= 0 && nj < m &&
          (field[ni][nj] == 'T' || field[ni][nj] == 'S' ||
           GetBit(mask, field[ni][nj] - 'a')) &&
          !used[ni][nj]) {
        used[ni][nj] = true;
        dist[ni][nj] = dist[ci][cj] + 1;
        qi.push(ni);
        qj.push(nj);
      }
    }
  }
  if (used[fi][fj]) {
    if (!ans_found || dist[fi][fj] <= ans_len) {
      UpdateAns(mask);
    }
  }
  ClearUsed(mask, used);
}
void Dfs(int c, int mask, int num) {
  if (c == kAlphabetSize) {
    Solve(mask);
    return;
  }
  if (num + 1 <= k) {
    Dfs(c + 1, mask + (1 << c), num + 1);
  }
  Dfs(c + 1, mask, num);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m >> k;
  field.resize(n, vector<char>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> field[i][j];
      if (field[i][j] == 'S') {
        si = i;
        sj = j;
      }
      if (field[i][j] == 'T') {
        fi = i;
        fj = j;
      }
    }
  }
  used.assign(n, vector<bool>(m, false));
  inused.assign(n, vector<bool>(m, false));
  dist.resize(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (field[i][j] >= 'a' && field[i][j] <= 'z') {
        char_posses_i[field[i][j] - 'a'].push_back(i);
        char_posses_j[field[i][j] - 'a'].push_back(j);
      }
    }
  }
  ans_found = false;
  Dfs(0, 0, 0);
  if (!ans_found) {
    cout << -1 << endl;
  } else {
    cout << ans_path << endl;
  }
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

There is a light source on the plane. This source is so small that it can be represented as point. The light source is moving from point (a, s_y) to the (b, s_y) (s_y < 0) with speed equal to 1 unit per second. The trajectory of this light source is a straight segment connecting these two points.

There is also a fence on OX axis represented as n segments (l_i, r_i) (so the actual coordinates of endpoints of each segment are (l_i, 0) and (r_i, 0)). The point (x, y) is in the shade if segment connecting (x,y) and the current position of the light source intersects or touches with any segment of the fence.

<image>

You are given q points. For each point calculate total time of this point being in the shade, while the light source is moving from (a, s_y) to the (b, s_y).

Input

First line contains three space separated integers s_y, a and b (-10^9 ≤ s_y < 0, 1 ≤ a < b ≤ 10^9) — corresponding coordinates of the light source.

Second line contains single integer n (1 ≤ n ≤ 2 ⋅ 10^5) — number of segments in the fence.

Next n lines contain two integers per line: l_i and r_i (1 ≤ l_i < r_i ≤ 10^9, r_{i - 1} < l_i) — segments in the fence in increasing order. Segments don't intersect or touch each other.

Next line contains single integer q (1 ≤ q ≤ 2 ⋅ 10^5) — number of points to check.

Next q lines contain two integers per line: x_i and y_i (1 ≤ x_i, y_i ≤ 10^9) — points to process.

Output

Print q lines. The i-th line should contain one real number — total time of the i-th point being in the shade, while the light source is moving from (a, s_y) to the (b, s_y). The answer is considered as correct if its absolute of relative error doesn't exceed 10^{-6}.

Example

Input

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

Output

5.000000000000000
3.000000000000000
0.000000000000000
1.500000000000000
2.000000000000000

Note

  * The 1-st point is always in the shade;
  * the 2-nd point is in the shade while light source is moving from (3, -3) to (6, -3);
  * the 3-rd point is in the shade while light source is at point (6, -3).
  * the 4-th point is in the shade while light source is moving from (1, -3) to (2.5, -3) and at point (6, -3);
  * the 5-th point is in the shade while light source is moving from (1, -3) to (2.5, -3) and from (5.5, -3) to (6, -3);

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long double sy, a, b;
int n;
long double l[200005], r[200005];
long double acc[200005];
long double x, y;
void solve() {
  long double L = (a * y + x * sy) / (y + sy);
  long double R = (b * y + x * sy) / (y + sy);
  int lc = 0;
  int rc = n;
  int lb, rb;
  while (rc - lc > 1) {
    int mid = (lc + rc) >> 1;
    if (r[mid] >= L) {
      rc = mid;
    } else {
      lc = mid;
    }
  }
  lb = rc;
  lc = 1;
  rc = n + 1;
  while (rc - lc > 1) {
    int mid = (lc + rc) >> 1;
    if (l[mid] <= R) {
      lc = mid;
    } else {
      rc = mid;
    }
  }
  rb = lc;
  long double ans;
  if (lb == rb) {
    long double LL = l[lb] + (l[lb] - x) / y * sy;
    long double RR = r[lb] + (r[lb] - x) / y * sy;
    if (RR < a || LL > b)
      ans = 0;
    else
      ans = min(RR, b) - max(LL, a);
  } else {
    ans = (acc[rb] - acc[lb - 1]) / y * (y + sy);
    long double LL = l[lb] + (l[lb] - x) / y * sy;
    long double RR = r[rb] + (r[rb] - x) / y * sy;
    if (LL < a) {
      ans -= a - LL;
    }
    if (RR > b) {
      ans -= RR - b;
    }
  }
  printf("%.13LF\n", ans);
}
int main() {
  cin >> sy >> a >> b;
  sy = -sy;
  cin >> n;
  acc[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%LF%LF", &l[i], &r[i]);
    acc[i] = acc[i - 1] + r[i] - l[i];
  }
  int Q;
  scanf("%d", &Q);
  ;
  while (Q--) {
    scanf("%LF%LF", &x, &y);
    solve();
  }
}

```


### Prompt

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

problem

There are $ N $ propositions, named $ 1, 2, \ cdots, N $, respectively. Also, $ M $ information about the propositions is given. The $ i $ th information is "$ a_i $$". Given in the form "b_i $", which means that $ a_i $ is $ b_i $. ("If" is a logical conditional and the transition law holds.) $ For each proposition $ i $ Output all propositions that have the same value as i $ in ascending order. However, proposition $ i $ and proposition $ i $ are always the same value. Proposition $ X $ and proposition $ Y $ have the same value as "$ if $ X $". It means "Y $" and "$ X $ if $ Y $".

output

On the $ i $ line, output all propositions that have the same value as the proposition $ i $, separated by blanks in ascending order. Also, output a line break at the end of each line.

Example

Input

5 2
1 2
2 1

Output

1 2
1 2
3
4
5

### Response

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

namespace SCC{
    void visit(const vector<vector<int>>&G,vector<int>&vs,vector<int>&used,int v){
        used[v]=true;
        for(auto u:G[v]){
            if(!used[u])visit(G,vs,used,u);
        }
        vs.push_back(v);
    }

    void visit2(const vector<vector<int>>&T,vector<int>&used,vector<int>&comp,vector<int>&vec,int k,int v){
        comp[v]=k;
        used[v]=true;
        vec.push_back(v);

        for(auto u:T[v]){
            if(!used[u])visit2(T,used,comp,vec,k,u);
        }
    }
    void decompose(const vector<vector<int>>&G,vector<vector<int>>&H,vector<int>&comp){
        vector<vector<int>>T(G.size());
        for(int i=0;i<G.size();i++){
            for(auto v:G[i]){
                T[v].push_back(i);
            }
        }
        comp.resize(G.size());

        vector<int>vs(G.size());
        vector<int>used(G.size());
        for(int i=0;i<G.size();i++){
            if(!used[i])visit(G,vs,used,i);
        }
        reverse(vs.begin(),vs.end());
        fill(used.begin(),used.end(),0);

        int K=0;
        vector<vector<int>>S;
        for(auto v:vs){
            if(!used[v]){
                S.push_back(vector<int>());
                visit2(T,used,comp,S.back(),K++,v);
            }
        }

        H.resize(K);
        fill(used.begin(),used.end(),0);
        for(int i=0;i<K;i++){
            for(auto v:S[i]){
                for(auto u:G[v]){
                    if(used[comp[u]]||comp[v]==comp[u])continue;
                    used[comp[u]]=true;
                    H[comp[v]].push_back(comp[u]);
                }
            }
            for(auto v:H[i])used[v]=false;
        }

    }
}

signed main(){
	int N,M;
	cin>>N>>M;
	vector<vint>G(N);
	rep(i,M){
		int a,b;cin>>a>>b;a--;b--;
		G[a].pb(b);
	}

	vector<vint>H;
	vint comp;
	SCC::decompose(G,H,comp);

	rep(i,N){
		bool f=false;
		rep(j,N){
			if(comp[i]!=comp[j])continue;
			if(f)cout<<" ";
			f=true;
			cout<<j+1;
		}
		cout<<endl;
	}
	return 0;
}

```


### Prompt

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

Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements:

  * each cut should be straight (horizontal or vertical);
  * each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate square with cut);
  * each cut should go inside the whole chocolate bar, and all cuts must be distinct.

The picture below shows a possible way to cut a 5 × 6 chocolate for 5 times.

<image>

Imagine Jzzhu have made k cuts and the big chocolate is splitted into several pieces. Consider the smallest (by area) piece of the chocolate, Jzzhu wants this piece to be as large as possible. What is the maximum possible area of smallest piece he can get with exactly k cuts? The area of a chocolate piece is the number of unit squares in it.

Input

A single line contains three integers n, m, k (1 ≤ n, m ≤ 109; 1 ≤ k ≤ 2·109).

Output

Output a single integer representing the answer. If it is impossible to cut the big chocolate k times, print -1.

Examples

Input

3 4 1

Output

6

Input

6 4 2

Output

8

Input

2 3 4

Output

-1

Note

In the first sample, Jzzhu can cut the chocolate following the picture below:

<image>

In the second sample the optimal division looks like this:

<image>

In the third sample, it's impossible to cut a 2 × 3 chocolate 4 times.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, k, a;
  scanf("%I64d%I64d%I64d", &n, &m, &k);
  if (n + m - 2 < k)
    printf("-1");
  else {
    if (n > m) {
      a = n;
      n = m;
      m = a;
    }
    if (n >= k + 1) {
      printf("%I64d", max((m / (k + 1)) * n, (n / (k + 1)) * m));
    } else {
      if (m >= k + 1)
        printf("%I64d", (m / (k + 1)) * n);
      else
        printf("%I64d", n / (k - m + 2));
    }
  }
}

```


### Prompt

Generate a CPP solution to the following problem:

On a chessboard with a width of n and a height of n, rows are numbered from bottom to top from 1 to n, columns are numbered from left to right from 1 to n. Therefore, for each cell of the chessboard, you can assign the coordinates (r,c), where r is the number of the row, and c is the number of the column.

The white king has been sitting in a cell with (1,1) coordinates for a thousand years, while the black king has been sitting in a cell with (n,n) coordinates. They would have sat like that further, but suddenly a beautiful coin fell on the cell with coordinates (x,y)...

Each of the monarchs wanted to get it, so they decided to arrange a race according to slightly changed chess rules:

As in chess, the white king makes the first move, the black king makes the second one, the white king makes the third one, and so on. However, in this problem, kings can stand in adjacent cells or even in the same cell at the same time.

The player who reaches the coin first will win, that is to say, the player who reaches the cell with the coordinates (x,y) first will win.

Let's recall that the king is such a chess piece that can move one cell in all directions, that is, if the king is in the (a,b) cell, then in one move he can move from (a,b) to the cells (a + 1,b), (a - 1,b), (a,b + 1), (a,b - 1), (a + 1,b - 1), (a + 1,b + 1), (a - 1,b - 1), or (a - 1,b + 1). Going outside of the field is prohibited.

Determine the color of the king, who will reach the cell with the coordinates (x,y) first, if the white king moves first.

Input

The first line contains a single integer n (2 ≤ n ≤ 10^{18}) — the length of the side of the chess field.

The second line contains two integers x and y (1 ≤ x,y ≤ n) — coordinates of the cell, where the coin fell.

Output

In a single line print the answer "White" (without quotes), if the white king will win, or "Black" (without quotes), if the black king will win.

You can print each letter in any case (upper or lower).

Examples

Input

4
2 3

Output

White

Input

5
3 5

Output

Black

Input

2
2 2

Output

Black

Note

An example of the race from the first sample where both the white king and the black king move optimally:

  1. The white king moves from the cell (1,1) into the cell (2,2).
  2. The black king moves form the cell (4,4) into the cell (3,3).
  3. The white king moves from the cell (2,2) into the cell (2,3). This is cell containing the coin, so the white king wins.

<image>

An example of the race from the second sample where both the white king and the black king move optimally:

  1. The white king moves from the cell (1,1) into the cell (2,2).
  2. The black king moves form the cell (5,5) into the cell (4,4).
  3. The white king moves from the cell (2,2) into the cell (3,3).
  4. The black king moves from the cell (4,4) into the cell (3,5). This is the cell, where the coin fell, so the black king wins.

<image>

In the third example, the coin fell in the starting cell of the black king, so the black king immediately wins.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a, b;
  cin >> a >> b;
  long long x = abs(1 - a);
  long long xx = abs(n - b);
  if (x == xx)
    cout << "White" << endl;
  else if (x < xx)
    cout << "White" << endl;
  else
    cout << "Black" << endl;
  return 0;
}

```


### Prompt

Construct a cpp code solution to the problem outlined:

Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:

* add(s, t, x): add x to as, as+1, ..., at.
* get(i): output the value of ai.

Note that the initial values of ai (i = 1, 2, . . . , n) are 0.

Constraints

* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 100000
* 1 ≤ s ≤ t ≤ n
* 1 ≤ i ≤ n
* 0 ≤ x ≤ 1000

Input

n q
query1
query2
:
queryq

In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:

0 s t x

or

1 t

The first digit represents the type of the query. '0' denotes add(s, t, x) and '1' denotes get(i).

Output

For each get operation, print the value.

Examples

Input

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

Output

3
5

Input

4 3
1 2
0 1 4 1
1 2

Output

0
1

### Response

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

template <class T = long long>
struct BIT_Range_Add_Point_Get {
	// 区間更新・点取得
	//階差数列のBITを作って端から足す方針 vec[i] = data[i-1]-data[i-2];
	vector<T> vec;
	int n;
	BIT_Range_Add_Point_Get(int sz) : vec(sz + 1, 0), n(sz) {}
	//元の値に足す 更新は不可
	void add(int lef, int rig, T val, int index = 0) {
		if(!index) {
			lef++;
			rig++;
		}
		for(int x = lef; x <= n; x += x & -x) vec[x] += val;
		for(int x = rig; x <= n; x += x & -x) vec[x] -= val;
	}
	//端からの合計値 = 値計算
	T get(int a, int index = 0) {
		a += 1 - index;
		T ret = 0;
		for(int x = a; x > 0; x -= x & -x) ret += vec[x];
		return ret;
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	BIT_Range_Add_Point_Get<int> b(n);
	for(int i = 0; i < q; i++) {
		int com;
		cin >> com;
		if(com) {
			int idx;
			cin >> idx;
			cout << b.get(idx - 1) << endl;
		} else {
			int s, t, x;
			cin >> s >> t >> x;
			b.add(s - 1, t, x);
		}
	}
}

```


### Prompt

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

Note that the difference between easy and hard versions is that in hard version unavailable cells can become available again and in easy version can't. You can make hacks only if all versions are solved.

Ildar and Ivan are tired of chess, but they really like the chessboard, so they invented a new game. The field is a chessboard 2n × 2m: it has 2n rows, 2m columns, and the cell in row i and column j is colored white if i+j is even, and is colored black otherwise.

The game proceeds as follows: Ildar marks some of the white cells of the chessboard as unavailable, and asks Ivan to place n × m kings on the remaining white cells in such way, so that there are no kings attacking each other. A king can attack another king if they are located in the adjacent cells, sharing an edge or a corner.

Ildar would like to explore different combinations of cells. Initially all cells are marked as available, and then he has q queries. In each query he either marks a cell as unavailable, or marks the previously unavailable cell as available. After each query he would like to know whether it is possible to place the kings on the available cells in a desired way. Please help him!

Input

The first line of input contains three integers n, m, q (1 ≤ n, m, q ≤ 200 000) — the size of the board and the number of queries.

q lines follow, each of them contains a description of a query: two integers i and j, denoting a white cell on the board (1 ≤ i ≤ 2n, 1 ≤ j ≤ 2m, i + j is even). If the cell (i, j) was available before the query, then it becomes unavailable. Otherwise, if the cell was unavailable, it becomes available.

Output

Output q lines, i-th line should contain answer for a board after i queries of Ildar. This line should contain "YES" if it is possible to place the kings on the available cells in the desired way, or "NO" otherwise.

Examples

Input

1 3 3
1 1
1 5
2 4

Output

YES
YES
NO

Input

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

Output

YES
YES
NO
NO
YES
YES
NO
YES
YES
NO

Note

In the first example case after the second query only cells (1, 1) and (1, 5) are unavailable. Then Ivan can place three kings on cells (2, 2), (2, 4) and (2, 6).

After the third query three cells (1, 1), (1, 5) and (2, 4) are unavailable, so there remain only 3 available cells: (2, 2), (1, 3) and (2, 6). Ivan can not put 3 kings on those cells, because kings on cells (2, 2) and (1, 3) attack each other, since these cells share a corner.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 2000000000;
set<int> a[400005];
set<int> b[400005];
struct Interval {
  int flag, minn, maxx;
};
Interval arbint[1600005];
int n;
Interval create(int value1, int value2) {
  return Interval{
      ((value1 != 0 ? value1 : INF) > (value2 != 0 ? value2 : 0)),
      value1 != 0 ? value1 : INF,
      value2 != 0 ? value2 : 0,
  };
}
Interval join(const Interval &left, const Interval &right) {
  return Interval{
      (left.minn > right.maxx) & (left.flag == 1) & (right.flag == 1),
      min(left.minn, right.minn),
      max(left.maxx, right.maxx),
  };
}
void update(int nod, int st, int dr, int index) {
  if (st == dr) {
    if (a[st].size() == 0) {
      if (b[st].size() == 0)
        arbint[nod] = create(0, 0);
      else
        arbint[nod] = create(0, *(b[st].rbegin()));
    } else {
      if (b[st].size() == 0)
        arbint[nod] = create(*a[st].begin(), 0);
      else
        arbint[nod] = create(*a[st].begin(), *(b[st].rbegin()));
    }
  } else {
    int mij = (st + dr) / 2;
    if (index <= mij)
      update(2 * nod, st, mij, index);
    else
      update(2 * nod + 1, mij + 1, dr, index);
    arbint[nod] = join(arbint[2 * nod], arbint[2 * nod + 1]);
  }
}
void update(int index) { update(1, 1, n, index); }
Interval query(int nod, int st, int dr, int left, int right) {
  if (st == left && dr == right)
    return arbint[nod];
  else {
    int mij = (st + dr) / 2;
    if (right <= mij)
      return query(2 * nod, st, mij, left, right);
    else {
      if (mij < left)
        return query(2 * nod + 1, mij + 1, dr, left, right);
      else
        return join(query(2 * nod, st, mij, left, mij),
                    query(2 * nod + 1, mij + 1, dr, mij + 1, right));
    }
  }
}
Interval query(int left, int right) { return query(1, 1, n, left, right); }
int main() {
  int m, q, i, x, y;
  scanf("%d%d%d", &n, &m, &q);
  n *= 2;
  for (i = 1; i <= 4 * n; i++) {
    arbint[i].minn = INF;
    arbint[i].flag = 1;
  }
  for (i = 1; i <= q; i++) {
    scanf("%d%d", &x, &y);
    set<int>::iterator it;
    if (x % 2 == 1 && y % 2 == 1) {
      it = a[x].find(y);
      if (it != a[x].end()) {
        a[x].erase(it);
        update(x);
      } else {
        a[x].insert(y);
        update(x);
      }
    } else {
      it = b[x - 1].find(y);
      if (it != b[x - 1].end()) {
        b[x - 1].erase(it);
        update(x - 1);
      } else {
        b[x - 1].insert(y);
        update(x - 1);
      }
    }
    if (arbint[1].flag == 1)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the same forward and backward. For example, "noon", "testset" and "a" are all palindromes, while "test" and "kitayuta" are not.) You can choose any n lowercase English letters, and insert each of them to any position of s, possibly to the beginning or the end of s. You have to insert exactly n letters even if it is possible to turn s into a palindrome by inserting less than n letters.

Find the number of the palindromes that can be obtained in this way, modulo 10007.

Input

The first line contains a string s (1 ≤ |s| ≤ 200). Each character in s is a lowercase English letter.

The second line contains an integer n (1 ≤ n ≤ 109).

Output

Print the number of the palindromes that can be obtained, modulo 10007.

Examples

Input

revive
1

Output

1

Input

add
2

Output

28

Note

For the first sample, you can obtain the palindrome "reviver" by inserting 'r' to the end of "revive".

For the second sample, the following 28 palindromes can be obtained: "adada", "adbda", ..., "adzda", "dadad" and "ddadd".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool solve(string a) {
  int f = 0;
  if (a.size() % 2) {
    for (int i = 0; i < a.size() / 2; i++) {
      if (a[i] != a[a.size() - 1 - i]) f = 1;
    }
    if (f)
      return 0;
    else
      return 1;
  } else {
    for (int i = 0; i < a.size() / 2; i++) {
      if (a[i] != a[a.size() - 1 - i]) f = 1;
    }
    if (f)
      return 0;
    else
      return 1;
  }
}
set<char> st1, st2;
int main() {
  string s1;
  while (cin >> s1) {
    if (solve(s1)) {
      if (s1.size() % 2) {
        for (int i = 0; i <= s1.size() / 2; i++) {
          cout << s1[i];
        }
        for (int i = s1.size() / 2; i < s1.size(); i++) {
          cout << s1[i];
        }
        cout << endl;
      } else {
        for (int i = 0; i <= s1.size() / 2; i++) {
          cout << s1[i];
        }
        for (int i = s1.size() / 2; i < s1.size(); i++) {
          cout << s1[i];
        }
        cout << endl;
      }
    } else {
      int f = 0;
      string s;
      for (int i = 0; i <= s1.size(); i++) {
        for (int j = 0; j < 26; j++) {
          s.clear();
          char b = 'a' + j;
          for (int k = 0; k < i; k++) s += s1[k];
          s += b;
          for (int k = i; k < s1.size(); k++) s += s1[k];
          if (solve(s)) {
            cout << s << endl;
            return 0;
          }
        }
      }
      cout << "NA" << endl;
    }
  }
}

```