### Prompt

Generate a Cpp solution to the following problem:

During the last 24 hours Hamed and Malek spent all their time playing "Sharti". Now they are too exhausted to finish the last round. So they asked you for help to determine the winner of this round.

"Sharti" is played on a n × n board with some of cells colored white and others colored black. The rows of the board are numbered from top to bottom using number 1 to n. Also the columns of the board are numbered from left to right using numbers 1 to n. The cell located at the intersection of i-th row and j-th column is denoted by (i, j).

The players alternatively take turns. In each turn the player must choose a square with side-length at most k with its lower-right cell painted white. Then the colors of all the cells in this square are inversed (white cells become black and vice-versa). The player who cannot perform a move in his turn loses.

You know Hamed and Malek are very clever and they would have played their best moves at each turn. Knowing this and the fact that Hamed takes the first turn, given the initial board as described in the input, you must determine which one of them will be the winner.

Input

In this problem the initial board is specified as a set of m rectangles. All cells that lie inside at least one of these rectangles are colored white and the rest are colored black.

In the first line of input three space-spereated integers n, m, k (1 ≤ k ≤ n ≤ 109, 1 ≤ m ≤ 5·104) follow, denoting size of the board, number of rectangles and maximum size of the turn square during the game, respectively.

In i-th line of the next m lines four space-seperated integers ai, bi, ci, di (1 ≤ ai ≤ ci ≤ n, 1 ≤ bi ≤ di ≤ n) are given meaning that i-th rectangle determining the initial board is a rectangle with upper-left cell at (ai, bi) and lower-right cell at (ci, di).

Output

If Hamed wins, print "Hamed", otherwise print "Malek" (without the quotes).

Examples

Input

5 2 1
1 1 3 3
2 2 4 4

Output

Malek

Input

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

Output

Hamed

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 50010;
int n, m, K;
struct rect {
  int a, b, c, d;
} a[maxn], b[maxn];
namespace SEG {
int tot;
struct node {
  int l, r, cnt, ans;
} t[maxn * 50];
void init() {
  for (int i = 1; i <= tot; i++) t[i].l = t[i].r = 0;
  tot = 0;
}
void maintain(int k, int l, int r) {
  if (t[k].cnt)
    t[k].ans = r - l + 1;
  else
    t[k].ans = t[t[k].l].ans + t[t[k].r].ans;
}
void add(int &k, int l, int r, int ql, int qr, int v) {
  if (!k) k = ++tot;
  if (l >= ql && r <= qr) {
    t[k].cnt += v, maintain(k, l, r);
    return;
  }
  if ((l + r >> 1) >= ql) add(t[k].l, l, (l + r >> 1), ql, qr, v);
  if ((l + r >> 1) < qr) add(t[k].r, (l + r >> 1) + 1, r, ql, qr, v);
  maintain(k, l, r);
}
}  // namespace SEG
int main() {
  scanf("%d %d %d", &n, &m, &K);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d %d", &a[i].a, &a[i].b, &a[i].c, &a[i].d);
  }
  auto chk = [&]() {
    vector<tuple<int, int, int, int>> V;
    int ans = 0, rt = 0, n = 0;
    for (int i = 1; i <= m; i++)
      if (b[i].a <= b[i].c && b[i].b <= b[i].d) {
        n = max(n, b[i].d), V.emplace_back(b[i].a, b[i].b, b[i].d, 1);
        V.emplace_back(b[i].c + 1, b[i].b, b[i].d, -1);
      }
    sort(V.begin(), V.end()), SEG::init();
    for (int i = 0, j; i < V.size(); i = j) {
      for (j = i; j < V.size() && get<0>(V[i]) == get<0>(V[j]); j++) {
        SEG::add(rt, 1, n, get<1>(V[j]), get<2>(V[j]), get<3>(V[j]));
      }
      if (j == V.size() || !((get<0>(V[j]) - get<0>(V[i])) & 1)) continue;
      ans ^= SEG::t[1].ans & 1;
    }
    return ans;
  };
  for (int i = 0; 1 << i <= K; i++) {
    copy(a + 1, a + m + 1, b + 1);
    for (int j = 1; j <= m; j++) {
      b[j].a = ((b[j].a - 1) >> i) + 1, b[j].c >>= i;
      b[j].b = ((b[j].b - 1) >> i) + 1, b[j].d >>= i;
    }
    if (chk()) puts("Hamed"), exit(0);
  }
  puts("Malek");
  return 0;
}

```


### Prompt

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

Andrewid the Android is a galaxy-famous detective. Now he is busy with a top secret case, the details of which are not subject to disclosure.

However, he needs help conducting one of the investigative experiment. There are n pegs put on a plane, they are numbered from 1 to n, the coordinates of the i-th of them are (xi, 0). Then, we tie to the bottom of one of the pegs a weight on a tight rope of length l (thus, its coordinates will be equal to (xi, - l), where i is the number of the used peg). Then the weight is pushed to the right, so that it starts to rotate counterclockwise. At the same time, if the weight during rotation touches some of the other pegs, it then begins to rotate around that peg. Suppose that each peg itself is very thin and does not affect the rope length while weight is rotating around it.

<image>

More formally, if at some moment the segment of the rope contains one or more pegs in addition to the peg around which the weight is rotating, the weight will then rotate around the farthermost one of them on a shorter segment of a rope. In particular, if the segment of the rope touches some peg by its endpoint, it is considered that the weight starts to rotate around that peg on a segment of the rope of length 0.

At some moment the weight will begin to rotate around some peg, without affecting the rest of the pegs. Andrewid interested in determining the number of this peg.

Andrewid prepared m queries containing initial conditions for pushing the weight, help him to determine for each of them, around what peg the weight will eventually rotate.

Input

The first line contains integers n and m (1 ≤ n, m ≤ 2·105) — the number of pegs and queries.

The next line contains n integers x1, x2, ..., xn ( - 109 ≤ xi ≤ 109) — the coordinates of the pegs. It is guaranteed that the coordinates of all the pegs are distinct integers.

Next m lines contain the descriptions of the queries of pushing the weight, each consists of two integers ai (1 ≤ ai ≤ n) and li (1 ≤ li ≤ 109) — the number of the starting peg and the length of the rope.

Output

Print m lines, the i-th line should contain the number of the peg around which the weight will eventually rotate after the i-th push.

Examples

Input

3 2
0 3 5
2 3
1 8

Output

3
2

Input

4 4
1 5 7 15
1 4
2 15
3 16
1 28

Output

2
4
3
1

Note

Picture to the first sample test:

<image>

Picture to the second sample test:

<image>

Note that in the last query weight starts to rotate around the peg 1 attached to a rope segment of length 0.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[200010];
int pos[200010], idx[200010], mp[200010];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i].first), p[i].second = i;
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; i++)
    pos[i] = p[i].first, idx[i] = p[i].second, mp[p[i].second] = i;
  while (m--) {
    bool type = true;
    int x, len;
    scanf("%d%d", &x, &len);
    if (n == 1) {
      printf("1\n");
      continue;
    }
    x = mp[x];
    int id = upper_bound(pos + 1, pos + n + 1, pos[x] + len) - pos - 1;
    len -= pos[id] - pos[x];
    x = id;
    type = false;
    if (len >= pos[n] - pos[1]) {
      int q = len / (pos[n] - pos[1]);
      if (q % 2)
        x = 1, type = true;
      else
        x = n, type = false;
      len -= q * (pos[n] - pos[1]);
    }
    while (len) {
      if (type) {
        id = upper_bound(pos + 1, pos + n + 1, pos[x] + len) - pos - 1;
        if (id == x || pos[id] == pos[x] + len) {
          x = id;
          break;
        }
        if (pos[id] - pos[x] >= len / 2) {
          len -= (pos[id] - pos[x]);
          x = id;
          type = !type;
          continue;
        }
        int tmp = pos[id] - pos[x], q = len / tmp;
        if (q % 2)
          x = id, type = false, len -= q * tmp;
        else
          len -= q * tmp;
      } else {
        id = lower_bound(pos + 1, pos + n + 1, pos[x] - len) - pos;
        if (id == x || pos[id] == pos[x] - len) {
          x = id;
          break;
        }
        if (pos[x] - pos[id] >= len / 2) {
          len -= (pos[x] - pos[id]);
          x = id;
          type = !type;
          continue;
        }
        int tmp = (pos[x] - pos[id]), q = len / tmp;
        if (q % 2)
          x = id, type = true, len -= q * tmp;
        else
          len -= q * tmp;
      }
    }
    printf("%d\n", idx[x]);
  }
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Fafa owns a company that works on huge projects. There are n employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees.

Fafa finds doing this every time is very tiring for him. So, he decided to choose the best l employees in his company as team leaders. Whenever there is a new project, Fafa will divide the tasks among only the team leaders and each team leader will be responsible of some positive number of employees to give them the tasks. To make this process fair for the team leaders, each one of them should be responsible for the same number of employees. Moreover, every employee, who is not a team leader, has to be under the responsibility of exactly one team leader, and no team leader is responsible for another team leader.

Given the number of employees n, find in how many ways Fafa could choose the number of team leaders l in such a way that it is possible to divide employees between them evenly.

Input

The input consists of a single line containing a positive integer n (2 ≤ n ≤ 105) — the number of employees in Fafa's company.

Output

Print a single integer representing the answer to the problem.

Examples

Input

2

Output

1

Input

10

Output

3

Note

In the second sample Fafa has 3 ways:

  * choose only 1 employee as a team leader with 9 employees under his responsibility.
  * choose 2 employees as team leaders with 4 employees under the responsibility of each of them.
  * choose 5 employees as team leaders with 1 employee under the responsibility of each of them.

### Response

```cpp
#include <bits/stdc++.h>
int main() {
  long i, n, d = 0;
  scanf("%ld", &n);
  for (i = 1; i <= n / 2; i++) {
    if (n % i == 0) d++;
  }
  printf("%d", d);
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

You're given a tree consisting of n nodes. Every node u has a weight a_u. You want to choose an integer k (1 ≤ k ≤ n) and then choose k connected components of nodes that don't overlap (i.e every node is in at most 1 component). Let the set of nodes you chose be s. You want to maximize:

$$$\frac{∑_{u ∈ s} a_u}{k}$$$

In other words, you want to maximize the sum of weights of nodes in s divided by the number of connected components you chose. Also, if there are several solutions, you want to maximize k.

Note that adjacent nodes can belong to different components. Refer to the third sample.

Input

The first line contains the integer n (1 ≤ n ≤ 3 ⋅ 10^5), the number of nodes in the tree.

The second line contains n space-separated integers a_1, a_2, ..., a_n (|a_i| ≤ 10^9), the weights of the nodes.

The next n-1 lines, each contains 2 space-separated integers u and v (1 ≤ u,v ≤ n) which means there's an edge between u and v.

Output

Print the answer as a non-reduced fraction represented by 2 space-separated integers. The fraction itself should be maximized and if there are several possible ways, you should maximize the denominator. See the samples for a better understanding.

Examples

Input

3
1 2 3
1 2
1 3

Output

6 1

Input

1
-2

Output

-2 1

Input

3
-1 -1 -1
1 2
2 3

Output

-3 3

Input

3
-1 -2 -1
1 2
1 3

Output

-2 2

Note

A connected component is a set of nodes such that for any node in the set, you can reach all other nodes in the set passing only nodes in the set.

In the first sample, it's optimal to choose the whole tree.

In the second sample, you only have one choice (to choose node 1) because you can't choose 0 components.

In the third sample, notice that we could've, for example, chosen only node 1, or node 1 and node 3, or even the whole tree, and the fraction would've had the same value (-1), but we want to maximize k.

In the fourth sample, we'll just choose nodes 1 and 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y / 2, x = (x * x) % 1000000007;
  }
  return res % 1000000007;
}
long long int child[1000000];
long long int val[1000000];
vector<vector<long long int> > arr(1000000);
long long int cnt = 0;
long long int ma = -1e18;
void dfs(long long int u, long long int par) {
  child[u] = val[u];
  long long int i;
  for (i = 0; i < arr[u].size(); i++) {
    long long int v = arr[u][i];
    if (v != par) {
      dfs(v, u);
      if (child[v] > 0) child[u] += child[v];
    }
  }
}
void dfs1(long long int u, long long int par) {
  long long int i;
  child[u] = val[u];
  for (i = 0; i < arr[u].size(); i++) {
    long long int v = arr[u][i];
    if (v != par) {
      dfs1(v, u);
      if (child[v] > 0) child[u] += child[v];
    }
  }
  if (child[u] == ma) {
    child[u] = 0;
    cnt++;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int i;
  for (i = 1; i <= n; i++) cin >> val[i];
  for (i = 0; i < n - 1; i++) {
    long long int u, v;
    cin >> u >> v;
    arr[u].push_back(v);
    arr[v].push_back(u);
  }
  dfs(1, 0);
  for (i = 1; i <= n; i++) {
    ma = max(ma, child[i]);
  }
  dfs1(1, 0);
  cout << ma * cnt << " " << cnt;
}

```


### Prompt

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

You are given a correct solution of the sudoku puzzle. If you don't know what is the sudoku, you can read about it [here](http://tiny.cc/636xmz).

The picture showing the correct sudoku solution:

<image>

Blocks are bordered with bold black color.

Your task is to change at most 9 elements of this field (i.e. choose some 1 ≤ i, j ≤ 9 and change the number at the position (i, j) to any other number in range [1; 9]) to make it anti-sudoku. The anti-sudoku is the 9 × 9 field, in which:

  * Any number in this field is in range [1; 9];
  * each row contains at least two equal elements;
  * each column contains at least two equal elements;
  * each 3 × 3 block (you can read what is the block in the link above) contains at least two equal elements.

It is guaranteed that the answer exists.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.

Each test case consists of 9 lines, each line consists of 9 characters from 1 to 9 without any whitespaces — the correct solution of the sudoku puzzle.

Output

For each test case, print the answer — the initial field with at most 9 changed elements so that the obtained field is anti-sudoku. If there are several solutions, you can print any. It is guaranteed that the answer exists.

Example

Input

1
154873296
386592714
729641835
863725149
975314628
412968357
631457982
598236471
247189563

Output

154873396
336592714
729645835
863725145
979314628
412958357
631457992
998236471
247789563

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long MOD = (1 ? 100000000000000007 : 233333333333333333);
const int mod = (1 ? 1000000007 : 998244353);
const long long INF = 0x7fffffffffffffff;
const int inf = 0x7fffffff;
const double eps = 1e-9;
const int N = 1e6 + 5;
clock_t start, finish;
void time_in() { start = clock(); }
void time_out() {
  finish = clock();
  double tim = (double)(finish - start) / CLOCKS_PER_SEC;
  printf("Running time is %lf\n", tim);
}
inline long long mul(long long a, long long b) {
  long long s = 0;
  while (b) {
    if (b & 1) s = (s + a) % mod;
    a = (a << 1) % mod;
    b >>= 1;
  }
  return s % mod;
}
inline long long pow_mul(long long a, long long b) {
  long long s = 1;
  while (b) {
    if (b & 1) s = mul(s, a);
    a = mul(a, a);
    b >>= 1;
  }
  return s;
}
inline long long poww(long long a, long long b) {
  long long s = 1;
  while (b) {
    if (b & 1) s = (s * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return s % mod;
}
inline int read() {
  char c = getchar();
  int sgn = 1, ret = 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') sgn = -1, c = getchar();
  while (c >= '0' && c <= '9') ret = ret * 10 + c - 48, c = getchar();
  return ret * sgn;
}
void write(int x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline long long phi(long long x) {
  long long ans = x;
  for (long long i = 2; i * i <= x; i++)
    if (x % i == 0) {
      ans -= ans / i;
      while (x % i == 0) x /= i;
    }
  if (x > 1) ans -= ans / x;
  return ans;
}
int st[5][3] = {-1, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 1};
int t, cas;
int m, n;
string s[11];
int a[11][11];
int b[9][2] = {2, 2, 3, 6, 1, 7, 5, 3, 6, 5, 4, 9, 8, 1, 9, 4, 7, 8};
int main() {
  scanf("%d", &t);
  while (t--) {
    for (int i = 0; i < 9; i++) {
      cin >> s[i];
    }
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        a[i + 1][j + 1] = s[i][j] - '0';
      }
    }
    int cnt = 0;
    for (int i = 0; i < 9; i++) {
      int x = b[i][0], y = b[i][1];
      for (int i = 1; i <= 9; i++) {
        if (a[x][y] != i) {
          a[x][y] = i;
          cnt++;
          break;
        }
      }
    }
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        printf("%d", a[i][j]);
      }
      printf("\n");
    }
  }
}

```


### Prompt

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

You are given an array a[0 … n-1] of length n which consists of non-negative integers. Note that array indices start from zero.

An array is called good if the parity of each index matches the parity of the element at that index. More formally, an array is good if for all i (0 ≤ i ≤ n - 1) the equality i mod 2 = a[i] mod 2 holds, where x mod 2 is the remainder of dividing x by 2.

For example, the arrays [0, 5, 2, 1] and [0, 17, 0, 3] are good, and the array [2, 4, 6, 7] is bad, because for i=1, the parities of i and a[i] are different: i mod 2 = 1 mod 2 = 1, but a[i] mod 2 = 4 mod 2 = 0.

In one move, you can take any two elements of the array and swap them (these elements are not necessarily adjacent).

Find the minimum number of moves in which you can make the array a good, or say that this is not possible.

Input

The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases in the test. Then t test cases follow.

Each test case starts with a line containing an integer n (1 ≤ n ≤ 40) — the length of the array a.

The next line contains n integers a_0, a_1, …, a_{n-1} (0 ≤ a_i ≤ 1000) — the initial array.

Output

For each test case, output a single integer — the minimum number of moves to make the given array a good, or -1 if this is not possible.

Example

Input

4
4
3 2 7 6
3
3 2 6
1
7
7
4 9 2 1 18 3 0

Output

2
1
-1
0

Note

In the first test case, in the first move, you can swap the elements with indices 0 and 1, and in the second move, you can swap the elements with indices 2 and 3.

In the second test case, in the first move, you need to swap the elements with indices 0 and 1.

In the third test case, you cannot make the array good.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n];
    int wantodd = 0;
    int wanteven = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] % 2 == 0 && i % 2 == 1) {
        wanteven++;
      } else if (a[i] % 2 == 1 && i % 2 == 0) {
        wantodd++;
      }
    }
    if (wantodd == wanteven) {
      cout << wanteven << endl;
    } else if (wantodd != wanteven) {
      cout << -1 << endl;
    }
  }
  return 0;
}

```


### Prompt

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

You are asked to watch your nephew who likes to play with toy blocks in a strange way.

He has n boxes and the i-th box has a_i blocks. His game consists of two steps:

  1. he chooses an arbitrary box i;
  2. he tries to move all blocks from the i-th box to other boxes.

If he can make the same number of blocks in each of n - 1 other boxes then he will be happy, otherwise, will be sad. Note that your nephew can only move the blocks from the chosen box to the other boxes; he cannot move blocks from the other boxes.

You don't want to make your nephew sad, so you decided to put several extra blocks into some boxes in such a way that no matter which box i he chooses he won't be sad. What is the minimum number of extra blocks you need to put?

Input

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

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

The second line of each test case contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^9) — the number of blocks in each box.

It's guaranteed that the sum of n over test cases doesn't exceed 10^5.

Output

For each test case, print a single integer — the minimum number of blocks you need to put. It can be proved that the answer always exists, i. e. the number of blocks is finite.

Example

Input

3
3
3 2 2
4
2 2 3 2
3
0 3 0

Output

1
0
3

Note

In the first test case, you can, for example, put one extra block into the first box and make a = [4, 2, 2]. If your nephew chooses the box with 4 blocks, then we will move two blocks to the second box and two blocks to the third box. If he chooses the box with 2 blocks then he will move these two blocks to the other box with 2 blocks.

In the second test case, you don't need to put any extra blocks, since no matter which box your nephew chooses, he can always make other boxes equal.

In the third test case, you should put 3 extra blocks. For example, you can put 2 blocks in the first box and 1 block in the third box. You'll get array a = [2, 3, 1].

### Response

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

#define ll long long
#define mem(a, b) memset(a,b,sizeof(a))
#define sz(a) (int)a.size()
#define INF 0x3f3f3f3f
#define DNF 0x7f
#define DBG printf("this is a input\n")
#define fi first
#define se second
#define pii pair<int,int>
#define mk(a, b) make_pair(a,b)
#define pb push_back
#define LF putchar('\n')
#define SP putchar(' ')
#define p_queue priority_queue
#define CLOSE ios::sync_with_stdio(0); cin.tie(0)

template<typename T>
void read(T &x) {x = 0;char ch = getchar();ll f = 1;while(!isdigit(ch)){if(ch == '-')f *= -1;ch = getchar();}while(isdigit(ch)){x = x * 10 + ch - 48; ch = getchar();}x *= f;}
template<typename T, typename... Args>
void read(T &first, Args& ... args) {read(first);read(args...);}
template<typename T>
void write(T arg) {T x = arg;if(x < 0) {putchar('-'); x =- x;}if(x > 9) {write(x / 10);}putchar(x % 10 + '0');}
template<typename T, typename ... Ts>
void write(T arg, Ts ... args) {write(arg);if(sizeof...(args) != 0) {putchar(' ');write(args ...);}}
using namespace std;

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

const int N = 4e5 + 5;
int T, n, m;
ll a[N], sum;
int main (void)
{
    CLOSE;
    cin >> T;
    while (T --)
    {
        sum = 0;
        cin >> n;
        for (int i = 1 ; i <= n ; i ++)
            cin >> a[i];
        sort (a + 1, a + 1 + n);
        for (int i = 1 ; i <= n ; i ++)
            sum += a[n]-a[i];
        ll ans = 1e18;
        for (int i = 1 ; i <= n ; i ++)
        {
            ll x = sum - (a[n]-a[i]);
            if (a[i] <= x)
                ans = min (ans , x-a[i]);
            else
            {
                ll add = (a[i]-x)%(n-1);
                if (add)
                    ans = min (ans, n-1-add);
                else
                    ans = 0;
            }
        }
        cout << ans << endl;
    }
}
/*
2 2 3
3 3 3
1 2 3 6
5 4 3 0

*/
```


### Prompt

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

Snuke can change a string t of length N into a string t' of length N - 1 under the following rule:

* For each i (1 ≤ i ≤ N - 1), the i-th character of t' must be either the i-th or (i + 1)-th character of t.

There is a string s consisting of lowercase English letters. Snuke's objective is to apply the above operation to s repeatedly so that all the characters in s are the same. Find the minimum necessary number of operations.

Constraints

* 1 ≤ |s| ≤ 100
* s consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

s

Output

Print the minimum necessary number of operations to achieve the objective.

Examples

Input

serval

Output

3

Input

jackal

Output

2

Input

zzz

Output

0

Input

whbrjpjyhsrywlqjxdbrbaomnw

Output

8

### Response

```cpp
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	char ca[105];
	char cb,cc;
	int i,j,k;
	int a,b,c;
	int s=105;
	cin>>ca;
	for(cb='a';cb<='z';cb++){
		for(a=0,b=0,i=0;i<strlen(ca);i++,b++){
			if(ca[i]==cb){
				if(a<b)a=b;
				b=-1;
			}
		}
		if(a<b)a=b;
		if(a<s)s=a;
	}
	cout<<s<<endl;
	return 0;
}

```


### Prompt

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

After years of hard work scientists invented an absolutely new e-reader display. The new display has a larger resolution, consumes less energy and its production is cheaper. And besides, one can bend it. The only inconvenience is highly unusual management. For that very reason the developers decided to leave the e-readers' software to programmers.

The display is represented by n × n square of pixels, each of which can be either black or white. The display rows are numbered with integers from 1 to n upside down, the columns are numbered with integers from 1 to n from the left to the right. The display can perform commands like "x, y". When a traditional display fulfills such command, it simply inverts a color of (x, y), where x is the row number and y is the column number. But in our new display every pixel that belongs to at least one of the segments (x, x) - (x, y) and (y, y) - (x, y) (both ends of both segments are included) inverts a color.

For example, if initially a display 5 × 5 in size is absolutely white, then the sequence of commands (1, 4), (3, 5), (5, 1), (3, 3) leads to the following changes:

<image>

You are an e-reader software programmer and you should calculate minimal number of commands needed to display the picture. You can regard all display pixels as initially white.

Input

The first line contains number n (1 ≤ n ≤ 2000).

Next n lines contain n characters each: the description of the picture that needs to be shown. "0" represents the white color and "1" represents the black color.

Output

Print one integer z — the least number of commands needed to display the picture.

Examples

Input

5
01110
10010
10001
10011
11110

Output

4

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2222;
char a[MAXN][MAXN];
int r[MAXN], c[MAXN], d[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%s", a[i]);
  int ans = 0;
  for (int i = 0; i < n; ++i) c[i] = 0;
  for (int i = 0; i < n; ++i) {
    int val = 0;
    for (int j = n - 1; j > i; --j)
      if (a[i][j] - '0' != (val ^ c[j])) {
        ++ans;
        c[j] ^= 1;
        val ^= 1;
      }
    d[i] = val;
  }
  for (int i = 0; i < n; ++i) r[i] = 0;
  for (int j = 0; j < n; ++j) {
    int val = 0;
    for (int i = n - 1; i > j; --i)
      if (a[i][j] - '0' != (val ^ r[i])) {
        ++ans;
        r[i] ^= 1;
        val ^= 1;
      }
    d[j] ^= val;
  }
  for (int i = 0; i < n; ++i)
    if (a[i][i] - '0' != (r[i] ^ c[i] ^ d[i])) ++ans;
  printf("%d\n", ans);
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Blake is a CEO of a large company called "Blake Technologies". He loves his company very much and he thinks that his company should be the best. That is why every candidate needs to pass through the interview that consists of the following problem.

We define function f(x, l, r) as a bitwise OR of integers xl, xl + 1, ..., xr, where xi is the i-th element of the array x. You are given two arrays a and b of length n. You need to determine the maximum value of sum f(a, l, r) + f(b, l, r) among all possible 1 ≤ l ≤ r ≤ n.

<image>

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the length of the arrays.

The second line contains n integers ai (0 ≤ ai ≤ 109).

The third line contains n integers bi (0 ≤ bi ≤ 109).

Output

Print a single integer — the maximum value of sum f(a, l, r) + f(b, l, r) among all possible 1 ≤ l ≤ r ≤ n.

Examples

Input

5
1 2 4 3 2
2 3 3 12 1

Output

22

Input

10
13 2 7 11 8 4 9 8 5 1
5 7 18 9 2 3 0 11 8 6

Output

46

Note

Bitwise OR of two non-negative integers a and b is the number c = a OR b, such that each of its digits in binary notation is 1 if and only if at least one of a or b have 1 in the corresponding position in binary notation.

In the first sample, one of the optimal answers is l = 2 and r = 4, because f(a, 2, 4) + f(b, 2, 4) = (2 OR 4 OR 3) + (3 OR 3 OR 12) = 7 + 15 = 22. Other ways to get maximum value is to choose l = 1 and r = 4, l = 1 and r = 5, l = 2 and r = 4, l = 2 and r = 5, l = 3 and r = 4, or l = 3 and r = 5.

In the second sample, the maximum value is obtained for l = 1 and r = 9.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int tam;
  vector<int> v1, v2;
  scanf("%lld", &tam);
  for (int i = 0, x; i < tam; i++) {
    scanf("%d", &x);
    v1.push_back(x);
  }
  for (int i = 0, x; i < tam; i++) {
    scanf("%d", &x);
    v2.push_back(x);
  }
  int s1 = 0, s2 = 0, maxi = 0;
  for (int i = 0; i < tam; i++) {
    for (int j = i; j <= i; j++) {
      s1 |= v1[j];
      s2 |= v2[j];
      maxi = max(s1 + s2, maxi);
    }
  }
  printf("%d\n", maxi);
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

Danil decided to earn some money, so he had found a part-time job. The interview have went well, so now he is a light switcher.

Danil works in a rooted tree (undirected connected acyclic graph) with n vertices, vertex 1 is the root of the tree. There is a room in each vertex, light can be switched on or off in each room. Danil's duties include switching light in all rooms of the subtree of the vertex. It means that if light is switched on in some room of the subtree, he should switch it off. Otherwise, he should switch it on.

Unfortunately (or fortunately), Danil is very lazy. He knows that his boss is not going to personally check the work. Instead, he will send Danil tasks using Workforces personal messages.

There are two types of tasks:

  1. pow v describes a task to switch lights in the subtree of vertex v.
  2. get v describes a task to count the number of rooms in the subtree of v, in which the light is turned on. Danil should send the answer to his boss using Workforces messages.

A subtree of vertex v is a set of vertices for which the shortest path from them to the root passes through v. In particular, the vertex v is in the subtree of v.

Danil is not going to perform his duties. He asks you to write a program, which answers the boss instead of him.

Input

The first line contains a single integer n (1 ≤ n ≤ 200 000) — the number of vertices in the tree.

The second line contains n - 1 space-separated integers p2, p3, ..., pn (1 ≤ pi < i), where pi is the ancestor of vertex i.

The third line contains n space-separated integers t1, t2, ..., tn (0 ≤ ti ≤ 1), where ti is 1, if the light is turned on in vertex i and 0 otherwise.

The fourth line contains a single integer q (1 ≤ q ≤ 200 000) — the number of tasks.

The next q lines are get v or pow v (1 ≤ v ≤ n) — the tasks described above.

Output

For each task get v print the number of rooms in the subtree of v, in which the light is turned on.

Example

Input

4
1 1 1
1 0 0 1
9
get 1
get 2
get 3
get 4
pow 1
get 1
get 2
get 3
get 4

Output

2
0
0
1
2
1
1
0

Note

<image> The tree before the task pow 1.

<image> The tree after the task pow 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int const N = int(2e5) + 7;
int const mod = int(1e9) + 7;
int p[N];
vector<int> ent, out;
int t[N];
int rt[N];
bool switchS[4 * N];
vector<int> gr[N];
vector<int> seg;
int endS;
int n;
void build(int v = 1, int l = 0, int r = endS) {
  if (l == r) {
    seg[v] = t[rt[l]];
    return;
  }
  int mid = (l + r) >> 1;
  build(v << 1, l, mid);
  build((v << 1) + 1, mid + 1, r);
  seg[v] = seg[v << 1] + seg[(v << 1) + 1];
}
void push(int v, int l, int r) {
  if (switchS[v]) {
    seg[v] = min(n - 1, r) - l + 1 - seg[v];
    if (l < r) {
      switchS[v << 1] ^= true;
      switchS[v << 1 | 1] ^= true;
    }
    switchS[v] = false;
  }
}
void update(int ls, int rs, int v = 1, int l = 0, int r = endS) {
  push(v, l, r);
  if (r < ls || rs < l) {
    return;
  }
  if (ls <= l && r <= rs) {
    switchS[v] = true;
    push(v, l, r);
    return;
  }
  int mid = (l + r) >> 1;
  update(ls, rs, v << 1, l, mid);
  update(ls, rs, (v << 1) + 1, mid + 1, r);
  seg[v] = seg[v << 1] + seg[(v << 1) + 1];
}
int query(int ls, int rs, int v = 1, int l = 0, int r = endS) {
  push(v, l, r);
  if (r < ls || rs < l) {
    return 0;
  }
  if (ls <= l && r <= rs) {
    return seg[v];
  }
  int mid = (l + r) >> 1;
  return query(ls, rs, v << 1, l, mid) +
         query(ls, rs, (v << 1) + 1, mid + 1, r);
}
void dfs(int v, int &tt) {
  ent[v] = tt;
  for (int i = 0; i < gr[v].size(); ++i) {
    ++tt;
    dfs(gr[v][i], tt);
  }
  out[v] = tt;
}
int main() {
  ios_base::sync_with_stdio(false);
  ifstream in("input.txt");
  cin >> n;
  endS = n - 1;
  for (int i = 1; i < n; ++i) {
    cin >> p[i];
    --p[i];
    gr[p[i]].push_back(i);
  }
  int tt = 0;
  seg.resize(4 * n, 0);
  ent.resize(n);
  out.resize(n);
  dfs(0, tt);
  for (int i = 0; i < n; ++i) {
    rt[ent[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    cin >> t[i];
  }
  build();
  int q;
  cin >> q;
  while (q--) {
    string typeQuery;
    cin >> typeQuery;
    int v;
    cin >> v;
    --v;
    if (typeQuery == "pow") {
      update(ent[v], out[v]);
    } else {
      cout << query(ent[v], out[v]) << endl;
    }
  }
  return 0;
}

```


### Prompt

Generate a cpp solution to the following problem:

T students applied into the ZPP class of Summer Irrelevant School. The organizing committee of the school may enroll any number of them, but at least t students must be enrolled. The enrolled students should be divided into two groups in any manner (it is possible that one of the groups will be empty!)

During a shift the students from the ZPP grade are tutored by n teachers. Due to the nature of the educational process, each of the teachers should be assigned to exactly one of two groups (it is possible that no teacher will be assigned to some of the groups!). The i-th teacher is willing to work in a group as long as the group will have at least li and at most ri students (otherwise it would be either too boring or too hard). Besides, some pairs of the teachers don't like each other other and therefore can not work in the same group; in total there are m pairs of conflicting teachers.

You, as the head teacher of Summer Irrelevant School, have got a difficult task: to determine how many students to enroll in each of the groups and in which group each teacher will teach.

Input

The first line contains two space-separated integers, t and T (1 ≤ t ≤ T ≤ 109).

The second line contains two space-separated integers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ 105).

The i-th of the next n lines contain integers li and ri (0 ≤ li ≤ ri ≤ 109).

The next m lines describe the pairs of conflicting teachers. Each of these lines contain two space-separated integers — the indices of teachers in the pair. The teachers are indexed starting from one. It is guaranteed that no teacher has a conflict with himself and no pair of conflicting teachers occurs in the list more than once.

Output

If the distribution is possible, print in the first line a single word 'POSSIBLE' (without the quotes). In the second line print two space-separated integers n1 and n2 — the number of students in the first and second group, correspondingly, the contstraint t ≤ n1 + n2 ≤ T should be met. In the third line print n characters, the i-th of which should be 1 or 2, if the i-th teacher should be assigned to the first or second group, correspondingly. If there are multiple possible distributions of students and teachers in groups, you can print any of them.

If the sought distribution doesn't exist, print a single word 'IMPOSSIBLE' (without the quotes).

Examples

Input

10 20
3 0
3 6
4 9
16 25

Output

POSSIBLE
4 16
112

Input

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

Output

IMPOSSIBLE

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class free>
inline void Min(free&, free);
template <class free>
inline void Max(free&, free);
struct inter {
  int l, r, id, id1;
  inline void operator^=(const inter x) { Max(l, x.l), Min(r, x.r); }
  inline inter operator^(const inter x) { return {max(l, x.l), min(r, x.r)}; }
  inline bool operator<(const inter& x) const { return l < x.l; }
} I[200050], I1[200050][2], I2[200050];
struct point {
  int next, to;
} ar[200050];
multiset<int> S;
bool ans[200050], is[200050];
int head[200050], art, a[200050], at, b1, b2, b3, b4, I2t, t, T, n, m;
inline bool dfs(int, int);
inline void read(int&), link(int, int), deal(inter, inter), deal1(inter, inter),
    deal2(inter, inter), deal3(int, int);
int main() {
  read(t), read(T), read(n), read(m);
  for (int i(1); i <= n; ++i)
    read(I[i].l), read(I[i].r), I1[i][0] = {0, 0x3f3f3f3f, i, 0},
                                I1[i][1] = {0, 0x3f3f3f3f, i, 1};
  for (int i(1), u, v; i <= m; ++i) read(u), read(v), link(u, v);
  memset(a, -1, sizeof(a));
  for (int i(1); i <= n; ++i)
    if (!~a[i] && dfs((++at, i), 0)) return puts("IMPOSSIBLE"), 0;
  for (int i(1), j; i <= at; ++i)
    for (j = 0; j < 2; ++j) {
      if (!b1 || I1[i][j].l > I1[b1][b2].l) b1 = i, b2 = j;
      if (!b3 || I1[i][j].r < I1[b3][b4].r) b3 = i, b4 = j;
    }
  if (b1 ^ b3) {
    ans[b1] = b2, ans[b3] = b4;
    deal(I1[b1][b2] ^ I1[b3][b4], I1[b1][b2 ^ 1] ^ I1[b3][b4 ^ 1]);
    ans[b3] ^= 1;
    deal2(I1[b1][b2] ^ I1[b3][b4 ^ 1], I1[b1][b2 ^ 1] ^ I1[b3][b4]);
  } else {
    if (b2 ^ b4)
      ans[b1] = b2, deal2(I1[b1][b2], I1[b3][b4]);
    else
      ans[b1] = b2, deal(I1[b1][b2], I1[b1][b2 ^ 1]);
  }
  return puts("IMPOSSIBLE"), 0;
}
inline void deal3(int x, int y) {
  printf("POSSIBLE\n%d %d\n", x, y);
  for (int i(1); i <= n; ++i) putchar(ans[I[i].id] ^ a[i] ? 50 : 49);
  exit(0);
}
inline void deal2(inter a, inter b) {
  I2t = 0, S.clear(), memset(is, 0, sizeof(is)), S.insert({0x3f3f3f3f});
  for (int i(1), j; i <= at; ++i)
    if (i ^ b1 && i ^ b3) {
      for (j = 0; j < 2; ++j) I2[++I2t] = I1[i][j];
      if (I1[i][0].r > I1[i][1].r)
        ans[i] = 0, S.insert(I1[i][0].r);
      else
        ans[i] = 1, S.insert({I1[i][1].r});
    }
  if (!I2t) deal1(a, b);
  sort(I2 + 1, I2 + I2t + 1);
  for (int i(I2t), j, k; i; i = j) {
    for (j = i; j && I2[j].l == I2[i].l; --j)
      ;
    bool pd(false);
    for (k = i; k > j; --k)
      if (is[I2[k].id])
        pd = 1, deal1(a, b);
      else {
        inter b1(I1[I2[k].id][I2[k].id1 ^ 1]);
        bool temp(ans[b1.id]);
        pd |= I2[k].l == b1.l;
        S.erase(S.find(max(I2[k].r, b1.r))), ans[b1.id] = b1.id1;
        deal1(a ^ (inter){0, *S.begin()} ^ b1, b ^ I2[k]);
        S.insert(max(I2[k].r, b1.r)), ans[b1.id] = temp;
      }
    if (pd) return;
    for (k = i; k > j; --k)
      if (!is[I2[k].id]) {
        inter b1(I1[I2[k].id][I2[k].id1 ^ 1]);
        S.erase(S.find(max(I2[k].r, b1.r)));
        ans[b1.id] = I2[k].id1, a ^= I2[k], b ^= b1;
        is[b1.id] = 1;
      }
  }
}
inline void deal1(inter a, inter b) {
  if (a.l > a.r || b.l > b.r) return;
  if (t - a.l <= b.l && b.l <= T - a.l) deal3(a.l, b.l);
  if (t - a.l <= b.r && b.r <= T - a.l) deal3(a.l, b.r);
  if (t - a.r <= b.l && b.l <= T - a.r) deal3(a.r, b.l);
  if (t - a.r <= b.r && b.r <= T - a.r) deal3(a.r, b.r);
  int x(a.l), y(t - x);
  if (b.l <= y && y <= b.r) deal3(x, y);
  x = a.r, y = t - x;
  if (b.l <= y && y <= b.r) deal3(x, y);
  y = b.l, x = t - y;
  if (a.l <= x && x <= a.r) deal3(x, y);
  y = b.r, x = t - y;
  if (a.l <= x && x <= a.r) deal3(x, y);
}
inline void deal(inter a, inter b) {
  I2t = 0, S.clear(), memset(is, 0, sizeof(is)), S.insert(0x3f3f3f3f);
  for (int i(1), j; i <= at; ++i)
    if (i ^ b1 && i ^ b3) {
      for (j = 0; j < 2; ++j) I2[++I2t] = I1[i][j];
      if (I1[i][0].r > I1[i][1].r)
        S.insert(I1[i][0].r), ans[i] = 1;
      else
        S.insert(I1[i][1].r), ans[i] = 0;
    }
  if (!I2t) deal1(a, b);
  sort(I2 + 1, I2 + I2t + 1);
  for (int i(I2t), j, k; i; i = j) {
    for (j = i; j && I2[j].l == I2[i].l; --j)
      ;
    bool pd(false);
    for (k = i; k > j; --k)
      if (is[I2[k].id])
        pd = 1, deal1(a, b ^ (inter){0, *S.begin()});
      else {
        bool temp(ans[I2[k].id]);
        inter& b1(I1[I2[k].id][I2[k].id1 ^ 1]);
        pd |= b1.r == I2[k].r;
        ans[I2[k].id] = b1.id1, S.erase(S.find(max(I2[k].r, b1.r)));
        deal1(a, b ^ (inter){0, *S.begin()} ^ I2[k]);
        ans[I2[k].id] = temp, S.insert(max(I2[k].r, b1.r));
      }
    if (pd) return;
    for (k = i; k > j; --k)
      if (!is[I2[k].id]) {
        inter& b1(I1[I2[k].id][I2[k].id1 ^ 1]);
        b ^= b1;
        is[I2[k].id] = 1, S.erase(S.find(max(I2[k].r, b1.r)));
      }
  }
}
template <class free>
inline void Min(free& x, free y) {
  x = x < y ? x : y;
}
template <class free>
inline void Max(free& x, free y) {
  x = x > y ? x : y;
}
inline bool dfs(int x, int c) {
  I1[I[x].id = at][a[x] = c] ^= I[x];
  for (int i(head[x]), i1; i; i = ar[i].next)
    if (!~a[i1 = ar[i].to] && dfs(i1, c ^ 1))
      return true;
    else if (a[i1] == c)
      return true;
  return false;
}
inline void link(int u, int v) {
  ar[++art] = {head[u], v}, head[u] = art;
  ar[++art] = {head[v], u}, head[v] = art;
}
inline void read(int& x) {
  x ^= x;
  register char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
}

```


### Prompt

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

Limak and Radewoosh are going to compete against each other in the upcoming algorithmic contest. They are equally skilled but they won't solve problems in the same order.

There will be n problems. The i-th problem has initial score pi and it takes exactly ti minutes to solve it. Problems are sorted by difficulty — it's guaranteed that pi < pi + 1 and ti < ti + 1.

A constant c is given too, representing the speed of loosing points. Then, submitting the i-th problem at time x (x minutes after the start of the contest) gives max(0, pi - c·x) points.

Limak is going to solve problems in order 1, 2, ..., n (sorted increasingly by pi). Radewoosh is going to solve them in order n, n - 1, ..., 1 (sorted decreasingly by pi). Your task is to predict the outcome — print the name of the winner (person who gets more points at the end) or a word "Tie" in case of a tie.

You may assume that the duration of the competition is greater or equal than the sum of all ti. That means both Limak and Radewoosh will accept all n problems.

Input

The first line contains two integers n and c (1 ≤ n ≤ 50, 1 ≤ c ≤ 1000) — the number of problems and the constant representing the speed of loosing points.

The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ 1000, pi < pi + 1) — initial scores.

The third line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 1000, ti < ti + 1) where ti denotes the number of minutes one needs to solve the i-th problem.

Output

Print "Limak" (without quotes) if Limak will get more points in total. Print "Radewoosh" (without quotes) if Radewoosh will get more points in total. Print "Tie" (without quotes) if Limak and Radewoosh will get the same total number of points.

Examples

Input

3 2
50 85 250
10 15 25

Output

Limak

Input

3 6
50 85 250
10 15 25

Output

Radewoosh

Input

8 1
10 20 30 40 50 60 70 80
8 10 58 63 71 72 75 76

Output

Tie

Note

In the first sample, there are 3 problems. Limak solves them as follows:

  1. Limak spends 10 minutes on the 1-st problem and he gets 50 - c·10 = 50 - 2·10 = 30 points.
  2. Limak spends 15 minutes on the 2-nd problem so he submits it 10 + 15 = 25 minutes after the start of the contest. For the 2-nd problem he gets 85 - 2·25 = 35 points.
  3. He spends 25 minutes on the 3-rd problem so he submits it 10 + 15 + 25 = 50 minutes after the start. For this problem he gets 250 - 2·50 = 150 points.

So, Limak got 30 + 35 + 150 = 215 points.

Radewoosh solves problem in the reversed order:

  1. Radewoosh solves 3-rd problem after 25 minutes so he gets 250 - 2·25 = 200 points.
  2. He spends 15 minutes on the 2-nd problem so he submits it 25 + 15 = 40 minutes after the start. He gets 85 - 2·40 = 5 points for this problem.
  3. He spends 10 minutes on the 1-st problem so he submits it 25 + 15 + 10 = 50 minutes after the start. He gets max(0, 50 - 2·50) = max(0, - 50) = 0 points.

Radewoosh got 200 + 5 + 0 = 205 points in total. Limak has 215 points so Limak wins.

In the second sample, Limak will get 0 points for each problem and Radewoosh will first solve the hardest problem and he will get 250 - 6·25 = 100 points for that. Radewoosh will get 0 points for other two problems but he is the winner anyway.

In the third sample, Limak will get 2 points for the 1-st problem and 2 points for the 2-nd problem. Radewoosh will get 4 points for the 8-th problem. They won't get points for other problems and thus there is a tie because 2 + 2 = 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c, p[55], t[55], x = 0, L = 0, R = 0;
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> t[i];
  }
  for (int i = 0; i < n; i++) {
    x += t[i];
    L += max(0, p[i] - c * x);
  }
  x = 0;
  for (int i = n - 1; i > -1; i--) {
    x += t[i];
    R += max(0, p[i] - c * x);
  }
  if (L > R) {
    cout << "Limak" << endl;
  } else if (L < R) {
    cout << "Radewoosh" << endl;
  } else
    cout << "Tie" << endl;
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

Koa the Koala and her best friend want to play a game.

The game starts with an array a of length n consisting of non-negative integers. Koa and her best friend move in turns and each have initially a score equal to 0. Koa starts.

Let's describe a move in the game:

  * During his move, a player chooses any element of the array and removes it from this array, xor-ing it with the current score of the player.

More formally: if the current score of the player is x and the chosen element is y, his new score will be x ⊕ y. Here ⊕ denotes [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).

Note that after a move element y is removed from a.

  * The game ends when the array is empty.

At the end of the game the winner is the player with the maximum score. If both players have the same score then it's a draw.

If both players play optimally find out whether Koa will win, lose or draw the game.

Input

Each test contains multiple test cases. The first line contains t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.

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

The second line of each test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 10^9) — elements of a.

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

Output

For each test case print:

  * WIN if Koa will win the game.
  * LOSE if Koa will lose the game.
  * DRAW if the game ends in a draw.

Examples

Input

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

Output

WIN
LOSE
DRAW

Input

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

Output

WIN
WIN
DRAW
WIN

Note

In testcase 1 of the first sample we have:

a = [1, 2, 2]. Here Koa chooses 1, other player has to choose 2, Koa chooses another 2. Score for Koa is 1 ⊕ 2 = 3 and score for other player is 2 so Koa wins.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5001;
int T, N;
void solve() {
  cin >> N;
  vector<int> a(N);
  vector<int> c(30, 0), c2(30, 0);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    int ind = 0;
    for (int j = 0; j < 30; j++) {
      if (a[i] & (1 << j))
        c[j]++;
      else
        c2[j]++;
    }
  }
  for (int j = 29; j >= 0; j--) {
    if (c[j] % 2 == 1) {
      if (c[j] % 4 == 1 || c2[j] % 2 == 1) {
        cout << "WIN\n";
        return;
      } else {
        cout << "LOSE\n";
        return;
      }
    }
  }
  cout << "DRAW\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> T;
  while (T--) {
    solve();
  }
}

```


### Prompt

Please create a solution in Cpp to the following problem:

You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ... \times N), how many Shichi-Go numbers (literally "Seven-Five numbers") are there?

Here, a Shichi-Go number is a positive integer that has exactly 75 divisors.

Constraints

* 1 \leq N \leq 100
* N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of the Shichi-Go numbers that are divisors of N!.

Examples

Input

9

Output

0

Input

10

Output

1

Input

100

Output

543

### Response

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

int n, p = 0;
int dp[120][100];

bool is_prime(int n){
	for(int i = 2; i * i <= n; i++)if(n % i == 0)return false;
	return true;
}

int main(){
	cin >> n;
	dp[0][1] = 1;
	for (int i = 2; i <= n; i++){
		if (is_prime(i) == false)continue;
		int cnt = 0;
		for (int j = 1; j <= n; j++){
			int a = j;
			while (a % i == 0)cnt++, a /= i;
		}
		for (int j = 0; j <= cnt; j++){
			for (int k = 1; k * (j + 1) <= 75; k++){
				dp[i][k * (j + 1)] += dp[p][k];
			}
		}
		p = i;
	}
	cout << dp[p][75] << endl;
}
```


### Prompt

Generate a cpp solution to the following problem:

Berland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.

To solve the puzzle one has to color some cells on the border of the grid black in such a way that:

  * exactly U cells in the top row are black;
  * exactly R cells in the rightmost column are black;
  * exactly D cells in the bottom row are black;
  * exactly L cells in the leftmost column are black.

Note that you can color zero cells black and leave every cell white.

Your task is to check if there exists a solution to the given puzzle.

Input

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

Then the descriptions of t testcases follow.

The only line of each testcase contains 5 integers n, U, R, D, L (2 ≤ n ≤ 100; 0 ≤ U, R, D, L ≤ n).

Output

For each testcase print "YES" if the solution exists and "NO" otherwise.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).

Example

Input

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

Output

YES
YES
NO
YES

Note

Here are possible solutions to testcases 1, 2 and 4:

<image>

### Response

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

inline bool active (int etat, int i)	{
	return  ((etat & (1 << i))!= 0);
}
inline bool est_ok (int nbDeja, int cote, int obj)	{
	if (nbDeja > obj)
		return false;

	int nbBlancsMin = (2-nbDeja);
	int nbBlancsObj = cote-obj;
	if (nbBlancsMin > nbBlancsObj)
		return false;
	return true;
}

int main() 	{
	ios:: sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	int nbTests;
	cin >> nbTests;
	for (int iTest = 0; iTest < nbTests; iTest++)	{
		int cote, haut, droite, bas, gauche;
		cin >> cote >> haut >> droite >> bas >> gauche;

		bool okToutEtat = false;
		for (int etat = 0; etat < pow(2, 4); etat++)	{
			int nbHaut = 0, nbBas = 0, nbGauche = 0, nbDroite = 0;
			if (active(etat, 0))	{
				nbGauche++;
				nbHaut++;
			}
			if (active(etat, 1))	{
				nbHaut++;
				nbDroite++;
			}
			if (active(etat, 2))	{
				nbDroite++;
				nbBas++;
			}
			if (active(etat, 3))	{
				nbBas++;
				nbGauche++;
			}

			bool ok = true;
			if (!est_ok(nbHaut, cote, haut))
				ok = false;
			if (!est_ok(nbBas, cote, bas))
				ok = false;
			if (!est_ok(nbDroite, cote, droite))
				ok = false;
			if (!est_ok(nbGauche, cote, gauche))
				ok = false;

			if (ok)
				okToutEtat = true;
		}
		if (okToutEtat)
			cout << "YES\n";
		else
			cout << "NO\n";
	}
}

```


### Prompt

Please formulate a CPP solution to the following problem:

Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them.

He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2).

Find the minimum total cost to achieve his objective.

Constraints

* 1≦N≦100
* -100≦a_i≦100

Input

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

N
a_1 a_2 ... a_N

Output

Print the minimum total cost to achieve Evi's objective.

Examples

Input

2
4 8

Output

8

Input

3
1 1 3

Output

3

Input

3
4 2 5

Output

5

Input

4
-100 -100 -100 -100

Output

0

### Response

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

int main(){
    int n, i, ave = 0, sum = 0;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++){
        cin >> a[i];
        ave += a[i];
    }
    ave = round((float)ave/n);
    for(i=0; i<n; i++){
        sum += (ave - a[i])*(ave -a[i]);
    }
    cout << sum;
    return 0;
}
```


### Prompt

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

C: Skewering

problem

One day, when Homura was playing with blocks, Tempura came. Homura decided to play with blocks with Tempura.

There is a rectangular parallelepiped of A \ times B \ times C, which is made by stacking A \ times B \ times C blocks of cubic blocks with a side length of 1 without any gaps. Each side of all cubes and rectangular parallelepipeds is parallel to the x-axis, y-axis, or z-axis.

Homura-chan and Tempura-kun alternately repeat the following operations.

* Select a row of blocks of building blocks lined up in a row from a rectangular parallelepiped in any of the vertical, horizontal, and depth directions, and paint all the blocks included in the row in red. However, you cannot select columns that contain blocks that are already painted red.

More precisely

* Select one of the blocks contained in the rectangular parallelepiped and one of the three directions x, y, and z.
* When the selected block is moved in the selected direction by an integer distance, all the blocks that completely overlap are painted in red (think of moving the distance of 0 or a negative integer). However, this operation cannot be performed if there is at least one block that meets the conditions and has already been painted.

Homura-chan is the first player to lose the game if he can't operate it first.

Also, initially all cubes are uncolored.

Determine which one wins when the two act optimally.

Input format

A B C

Constraint

* 1 \ leq A, B, C \ leq 100
* All inputs are integers.

Output format

When the two act optimally, if Homura wins, `Hom` is output, and if Tempura wins,` Tem` is output on one line.

Input example 1

1 1 10

Output example 1

Hom

* The first time Homura can paint all the blocks red.

Input example 2

4 3 5

Output example 2

Hom

Input example 3

6 4 10

Output example 3

Tem

Example

Input

1 1 10

Output

Hom

### Response

```cpp
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<LP> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

void solve() {
	int a, b, c; cin >> a >> b >> c;
	int num = 0;
	if (a % 2)num++;
	if (b % 2)num++;
	if (c % 2)num++;
	if (num<=1) {
		cout << "Tem" << endl;
	}
	else {
		cout << "Hom" << endl;
	}
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
	return 0;
}

```


### Prompt

Create a solution in CPP for the following problem:

Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.

In this problem, we call the greater number of a twin prime "size of the twin prime."

Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n

You may assume that 5 ≤ n ≤ 10000.

Input

The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:

n (integer)

Output

For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.

Example

Input

12
100
200
300
0

Output

5 7
71 73
197 199
281 283

### Response

```cpp
#include<stdio.h>

int main(){
  const int MAX_V = 10000;
  int prime[MAX_V+1];
  int i, k, v, ans, dif;
  for(i = 2; i <= MAX_V; i++){
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++){
    if(prime[i]){
      for(k = 2 * i; k <= MAX_V; k += i){
        prime[k] = 0;
      }
    }
  }
  while(scanf("%d", &v) != EOF){
    if(v == 0) break;
    for(k = v; k >= 2; k--){
      ans = prime[k];
      if(ans == 1){
        dif = prime[k - 2];
        if(dif == 1){
          printf("%d %d\n", k - 2, k);
          break;
        }
      }
    }
  }
  return 0;
}
```


### Prompt

Create a solution in Cpp for the following problem:

Simon has an array a1, a2, ..., an, consisting of n positive integers. Today Simon asked you to find a pair of integers l, r (1 ≤ l ≤ r ≤ n), such that the following conditions hold:

  1. there is integer j (l ≤ j ≤ r), such that all integers al, al + 1, ..., ar are divisible by aj;
  2. value r - l takes the maximum value among all pairs for which condition 1 is true;

Help Simon, find the required pair of numbers (l, r). If there are multiple required pairs find all of them.

Input

The first line contains integer n (1 ≤ n ≤ 3·105).

The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 106).

Output

Print two integers in the first line — the number of required pairs and the maximum value of r - l. On the following line print all l values from optimal pairs in increasing order.

Examples

Input

5
4 6 9 3 6

Output

1 3
2

Input

5
1 3 5 7 9

Output

1 4
1

Input

5
2 3 5 7 11

Output

5 0
1 2 3 4 5

Note

In the first sample the pair of numbers is right, as numbers 6, 9, 3 are divisible by 3.

In the second sample all numbers are divisible by number 1.

In the third sample all numbers are prime, so conditions 1 and 2 are true only for pairs of numbers (1, 1), (2, 2), (3, 3), (4, 4), (5, 5).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int st_min[300001][20], st_gcd[300001][20];
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
bool f(long long int n, long long int M, long long int log_2[]) {
  for (auto i = 0; i < n - M; i++) {
    long long int j = log_2[M + 1];
    if (min(st_min[i][j], st_min[i + M - (1 << j) + 1][j]) ==
        gcd(st_gcd[i][j], st_gcd[i + M - (1 << j) + 1][j]))
      return true;
  }
  return false;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int a[n];
  for (auto i = 0; i < n; i++) cin >> a[i];
  for (auto i = 0; i < n; i++) {
    st_min[i][0] = a[i];
    st_gcd[i][0] = a[i];
  }
  for (auto j = 1; j < 20; j++)
    for (auto i = 0; i < n; i++) {
      st_min[i][j] = st_min[i][j - 1];
      st_gcd[i][j] = st_gcd[i][j - 1];
      if (i + (1 << (j - 1)) < n) {
        st_min[i][j] = min(st_min[i][j], st_min[i + (1 << (j - 1))][j - 1]);
        st_gcd[i][j] = gcd(st_gcd[i][j], st_gcd[i + (1 << (j - 1))][j - 1]);
      }
    }
  long long int log_2[n + 1];
  log_2[1] = 0;
  for (auto i = 2; i < n + 1; i++) log_2[i] = log_2[i / 2] + 1;
  long long int L = 0, R = n - 1, M, chk = -1;
  while (L <= R) {
    M = (L + R) >> 1;
    if (f(n, M, log_2)) {
      chk = M;
      L = M + 1;
    } else
      R = M - 1;
  }
  vector<long long int> v;
  for (auto i = 0; i < n - chk; i++) {
    long long int j = log_2[chk + 1];
    if (min(st_min[i][j], st_min[i + chk - (1 << j) + 1][j]) ==
        gcd(st_gcd[i][j], st_gcd[i + chk - (1 << j) + 1][j]))
      v.push_back(i + 1);
  }
  cout << (long long int)(v).size() << " " << chk << "\n";
  for (auto i = 0; i < (long long int)(v).size(); i++) cout << v[i] << " ";
  cout << "\n";
  return 0;
}

```


### Prompt

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

The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for the company and the goods it produces) or its components: the name, the logo, the slogan. They decided to start with the name.

For this purpose the corporation has consecutively hired m designers. Once a company hires the i-th designer, he immediately contributes to the creation of a new corporation name as follows: he takes the newest version of the name and replaces all the letters xi by yi, and all the letters yi by xi. This results in the new version. It is possible that some of these letters do no occur in the string. It may also happen that xi coincides with yi. The version of the name received after the work of the last designer becomes the new name of the corporation.

Manager Arkady has recently got a job in this company, but is already soaked in the spirit of teamwork and is very worried about the success of the rebranding. Naturally, he can't wait to find out what is the new name the Corporation will receive.

Satisfy Arkady's curiosity and tell him the final version of the name.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 200 000) — the length of the initial name and the number of designers hired, respectively.

The second line consists of n lowercase English letters and represents the original name of the corporation.

Next m lines contain the descriptions of the designers' actions: the i-th of them contains two space-separated lowercase English letters xi and yi.

Output

Print the new name of the corporation.

Examples

Input

6 1
police
p m

Output

molice

Input

11 6
abacabadaba
a b
b c
a d
e g
f a
b b

Output

cdcbcdcfcdc

Note

In the second sample the name of the corporation consecutively changes as follows:

<image>

<image>

<image>

<image>

<image>

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200020;
int cnt;
char str[MAXN];
int a[30], b[30];
int main() {
  int n, m;
  scanf("%d%d", &m, &n);
  scanf("%s", &str);
  getchar();
  char ch1, ch2;
  for (int i = 0; i < 26; i++) {
    a[i] = i;
    b[i] = i;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%c %c", &ch1, &ch2);
    getchar();
    int x = b[ch1 - 'a'];
    int y = b[ch2 - 'a'];
    int tmp = a[x];
    a[x] = a[y];
    a[y] = tmp;
    b[a[x]] = x;
    b[a[y]] = y;
  }
  for (int i = 0; i < m; i++) {
    printf("%c", a[str[i] - 'a'] + 'a');
  }
  printf("\n");
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

One day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neighbors in the circle, or there is number c, such that a and с are immediate neighbors, and b and c are immediate neighbors. As you can easily deduce, in the end Vasya drew 2·n arcs.

For example, if the numbers are written in the circle in the order 1, 2, 3, 4, 5 (in the clockwise direction), then the arcs will join pairs of integers (1, 2), (2, 3), (3, 4), (4, 5), (5, 1), (1, 3), (2, 4), (3, 5), (4, 1) and (5, 2).

Much time has passed ever since, the numbers we wiped off the blackboard long ago, but recently Vasya has found a piece of paper with 2·n written pairs of integers that were joined with the arcs on the board. Vasya asks you to find the order of numbers in the circle by these pairs.

Input

The first line of the input contains a single integer n (5 ≤ n ≤ 105) that shows, how many numbers were written on the board. Next 2·n lines contain pairs of integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi) — the numbers that were connected by the arcs.

It is guaranteed that no pair of integers, connected by a arc, occurs in the input more than once. The pairs of numbers and the numbers in the pairs are given in the arbitrary order.

Output

If Vasya made a mistake somewhere and there isn't any way to place numbers from 1 to n on the circle according to the statement, then print a single number "-1" (without the quotes). Otherwise, print any suitable sequence of n distinct integers from 1 to n.

If there are multiple solutions, you are allowed to print any of them. Specifically, it doesn't matter which number you write first to describe the sequence of the order. It also doesn't matter whether you write out the numbers in the clockwise or counter-clockwise direction.

Examples

Input

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

Output

1 2 3 4 5

Input

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

Output

1 2 4 5 3 6

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > E;
vector<int> nodes;
bitset<100001> bs;
int n;
bool connected(int a, int b) {
  bool ans = false;
  for (int i = 0; i < 4; ++i) {
    if (E[a][i] == b) {
      ans = true;
      break;
    }
  }
  return ans;
}
bool dfs(int a, int b, int k, int lim) {
  if (k == lim) {
    return b == 1;
  }
  nodes[k - 1] = a, nodes[k] = b;
  bs[b] = true;
  for (int i = 0; i < 4; ++i) {
    int m = E[b][i];
    if (bs[m]) continue;
    if (connected(a, m) && dfs(b, m, k + 1, lim)) return true;
  }
  bs[b] = false;
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, a, b;
  cin >> n;
  E.resize(n + 1);
  nodes.resize(n + 1);
  for (int i = 0; i < (2 * n); ++i) {
    cin >> a >> b;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  for (int i = 1; i <= n; ++i) {
    if (E[i].size() != 4) {
      cout << -1 << '\n';
      return 0;
    }
  }
  for (int i = 0; i < 4; ++i) {
    if (dfs(1, E[1][i], 1, n)) {
      for (int j = 0; j < n; ++j) cout << nodes[j] << " ";
      cout << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
}

```


### Prompt

Generate a Cpp solution to the following problem:

Little X has n distinct integers: p1, p2, ..., pn. He wants to divide all of them into two sets A and B. The following two conditions must be satisfied:

  * If number x belongs to set A, then number a - x must also belong to set A.
  * If number x belongs to set B, then number b - x must also belong to set B.

Help Little X divide the numbers into two sets or determine that it's impossible.

Input

The first line contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The next line contains n space-separated distinct integers p1, p2, ..., pn (1 ≤ pi ≤ 109).

Output

If there is a way to divide the numbers into two sets, then print "YES" in the first line. Then print n integers: b1, b2, ..., bn (bi equals either 0, or 1), describing the division. If bi equals to 0, then pi belongs to set A, otherwise it belongs to set B.

If it's impossible, print "NO" (without the quotes).

Examples

Input

4 5 9
2 3 4 5

Output

YES
0 0 1 1

Input

3 3 4
1 2 4

Output

NO

Note

It's OK if all the numbers are in the same set, and the other one is empty.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5 + 10;
;
map<int, int> m;
int num[maxn], n, a, b, pr[maxn], rank[maxn];
bool ans[maxn];
int find(int a) { return (a == pr[a] ? a : pr[a] = find(pr[a])); }
void uni(int a, int b) {
  a = find(a);
  b = find(b);
  pr[a] = b;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < maxn; i++) {
    pr[i] = i;
  }
  cin >> n >> a >> b;
  for (int i = 2; i < n + 2; i++) {
    cin >> num[i];
    m[num[i]] = i;
  }
  for (int i = 2; i < n + 2; i++) {
    if (m[a - num[i]]) uni(m[num[i]], m[a - num[i]]);
    if (m[b - num[i]]) uni(m[num[i]], m[b - num[i]]);
  }
  if (a == b) {
    for (int i = 2; i < n + 2; i++) {
      if (!m[a - num[i]]) {
        cout << "NO";
        return 0;
      }
    }
    cout << "YES\n";
    for (int i = 0; i < n; i++) cout << "0 ";
    return 0;
  }
  for (int i = 2; i < n + 2; i++) {
    if ((find(i) == 0 && !m[a - num[i]]) || (find(i) == 1 && !m[b - num[i]]) ||
        (!m[a - num[i]] && !m[b - num[i]])) {
      cout << "NO";
      return 0;
    }
    bool f = m[a - num[i]], f2 = m[b - num[i]];
    if (f && f2) continue;
    if (f) {
      pr[find(i)] = 0;
    } else {
      pr[find(i)] = 1;
    }
  }
  cout << "YES\n";
  for (int i = 2; i < n + 2; i++) cout << find(i) << " ";
}

```


### Prompt

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

You are given sequence a1, a2, ..., an and m queries lj, rj (1 ≤ lj ≤ rj ≤ n). For each query you need to print the minimum distance between such pair of elements ax and ay (x ≠ y), that:

  * both indexes of the elements lie within range [lj, rj], that is, lj ≤ x, y ≤ rj;
  * the values of the elements are equal, that is ax = ay.

The text above understands distance as |x - y|.

Input

The first line of the input contains a pair of integers n, m (1 ≤ n, m ≤ 5·105) — the length of the sequence and the number of queries, correspondingly.

The second line contains the sequence of integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109).

Next m lines contain the queries, one per line. Each query is given by a pair of numbers lj, rj (1 ≤ lj ≤ rj ≤ n) — the indexes of the query range limits.

Output

Print m integers — the answers to each query. If there is no valid match for some query, please print -1 as an answer to this query.

Examples

Input

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

Output

1
-1
2

Input

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

Output

2
2
3
-1
2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int Num;
char CH[20];
const int inf = 0x3f3f3f3f;
inline long long read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void P(int x) {
  Num = 0;
  if (!x) {
    putchar('0');
    puts("");
    return;
  }
  while (x > 0) CH[++Num] = x % 10, x /= 10;
  while (Num) putchar(CH[Num--] + 48);
  puts("");
}
struct node {
  int l, r, v;
} a[500001 * 4];
struct ques {
  int l, r, an, v;
} qu[500001];
void build(int x, int l, int r) {
  a[x].l = l, a[x].r = r;
  a[x].v = 500001;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
}
void pushup(int x) { a[x].v = min(a[x << 1].v, a[x << 1 | 1].v); }
void update(int x, int pos, int val) {
  if (a[x].l == a[x].r) {
    a[x].v = val;
    return;
  }
  int mid = (a[x].l + a[x].r) >> 1;
  if (pos <= mid)
    update(x << 1, pos, val);
  else
    update(x << 1 | 1, pos, val);
  pushup(x);
}
int mi;
void query(int x, int l, int r) {
  if (l <= a[x].r && r >= a[x].r) {
    mi = min(mi, a[x].v);
    return;
  }
  int mid = (a[x].l + a[x].r) >> 1;
  if (l <= mid) query(x << 1, l, r);
  if (r > mid) query(x << 1 | 1, l, r);
}
map<int, int> mp;
int d[500001];
bool cmp(ques a, ques b) { return a.l > b.l; }
int ans[500001];
int main() {
  int n = read(), m = read();
  build(1, 1, n);
  for (int i = 1; i <= n; i++) d[i] = read();
  for (int i = 1; i <= m; i++) {
    qu[i].l = read(), qu[i].r = read();
    qu[i].v = i;
  }
  sort(qu + 1, qu + 1 + m, cmp);
  int t = 1;
  for (int i = n; i; i--) {
    if (mp[d[i]]) {
      update(1, mp[d[i]], mp[d[i]] - i);
    }
    mp[d[i]] = i;
    while (qu[t].l == i) {
      mi = 500001;
      query(1, qu[t].l, qu[t].r);
      if (mi == 500001) mi = -1;
      ans[qu[t].v] = mi;
      t++;
    }
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
}

```


### Prompt

Create a solution in cpp for the following problem:

A substring of some string is called the most frequent, if the number of its occurrences is not less than number of occurrences of any other substring.

You are given a set of strings. A string (not necessarily from this set) is called good if all elements of the set are the most frequent substrings of this string. Restore the non-empty good string with minimum length. If several such strings exist, restore lexicographically minimum string. If there are no good strings, print "NO" (without quotes).

A substring of a string is a contiguous subsequence of letters in the string. For example, "ab", "c", "abc" are substrings of string "abc", while "ac" is not a substring of that string.

The number of occurrences of a substring in a string is the number of starting positions in the string where the substring occurs. These occurrences could overlap.

String a is lexicographically smaller than string b, if a is a prefix of b, or a has a smaller letter at the first position where a and b differ.

Input

The first line contains integer n (1 ≤ n ≤ 105) — the number of strings in the set.

Each of the next n lines contains a non-empty string consisting of lowercase English letters. It is guaranteed that the strings are distinct.

The total length of the strings doesn't exceed 105.

Output

Print the non-empty good string with minimum length. If several good strings exist, print lexicographically minimum among them. Print "NO" (without quotes) if there are no good strings.

Examples

Input

4
mail
ai
lru
cf

Output

cfmailru

Input

3
kek
preceq
cheburek

Output

NO

Note

One can show that in the first sample only two good strings with minimum length exist: "cfmailru" and "mailrucf". The first string is lexicographically minimum.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
char *s[maxn], *p, buf[maxn * 2];
char t[maxn];
int alp[30][30], d[30], is[30], vis[30];
int ct;
bool dfs(int u) {
  t[ct++] = u + 'a';
  vis[u] = 1;
  int cnt = 0, p = -1;
  for (int i = 0; i < 26; i++) {
    if (alp[u][i]) cnt++, p = i;
  }
  if (cnt > 1) return false;
  if (cnt == 0) {
    t[ct] = 0;
    return true;
  }
  if (vis[p]) return 0;
  return dfs(p);
}
int main(void) {
  int n;
  scanf("%d", &n);
  p = buf;
  for (int i = 1; i <= n; i++) {
    scanf("%s", p);
    s[i] = p;
    p += strlen(p) + 1;
  }
  for (int i = 1; i <= n; i++) {
    is[s[i][0] - 'a'] = 1;
    for (int j = 1; s[i][j]; j++) {
      alp[s[i][j - 1] - 'a'][s[i][j] - 'a'] = 1;
      d[s[i][j] - 'a']++;
      is[s[i][0] - 'a'] = 1;
    }
  }
  int flag = 0, yes = 0;
  for (int i = 0; i < 26; i++)
    if (is[i] == 1) {
      if (d[i] == 0) {
        yes = 1;
        if (dfs(i) == false) {
          flag = 1;
          break;
        }
      }
    }
  for (int i = 0; i < 26; i++)
    if (is[i] && vis[i] == 0) {
      flag = 1;
    }
  if (flag || yes == 0) {
    printf("NO\n");
    return 0;
  }
  printf("%s\n", t);
  return 0;
}

```


### Prompt

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

You are now examining a unique method to sort a sequence of numbers in increasing order. The method only allows swapping of two numbers that have a common prime factor. For example, a sequence [6, 4, 2, 3, 7] can be sorted using the following steps.
Step 0: 6 4 2 3 7 (given sequence)
Step 1: 2 4 6 3 7 (elements 6 and 2 swapped)
Step 2: 2 6 4 3 7 (elements 4 and 6 swapped)
Step 3: 2 3 4 6 7 (elements 6 and 3 swapped)

Depending on the nature of the sequence, however, this approach may fail to complete the sorting. You have given a name "Coprime sort" to this approach and are now examining if a given sequence is coprime-sortable.

Make a program to determine if a given sequence can be sorted in increasing order by iterating an arbitrary number of swapping operations of two elements that have a common prime number.

Input

The input is given in the following format.

$N$
$a_1$ $a_2$ $...$ $a_N$

The first line provides the number of elements included in the sequence $N$ ($2 \leq N \leq 10^5$). The second line provides an array of integers $a_i$ ($2 \leq a_i \leq 10^5$) that constitute the sequence.

Output

Output "1" if the sequence is coprime-sortable in increasing order, or "0" otherwise.

Examples

Input

5
6 4 2 3 7

Output

1

Input

7
2 9 6 5 6 7 3

Output

0

### Response

```cpp
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define MP(a, b) make_pair(a, b)

//Union-Find木
struct UnionFind{
private:
    vector<int> parent;
public:
    UnionFind(int N) : parent(N){ //初期化する O(N)
        for(int i=0; i<N; i++) parent[i] = i;
    }
    int root(int a){ //親を返す O(log N)
        if(parent[a] == a) return a;
        return parent[a] = root(parent[a]);
    }
    void unite(int a, int b){ //木を併合する O(log N)
        int rootA = root(a);
        int rootB = root(b);
        if(rootA != rootB) parent[rootA] = rootB;
    }
    bool same(int a, int b){ //属する木が同じかを返す O(log N)
        return root(a) == root(b);
    }
};

int main(){
    iostream::sync_with_stdio(false);

    int N;
    cin >> N;
    int a[100000];
    vector<pair<int,int> > b;
    for(int i=0; i<N; i++){
        cin >> a[i];
        b.push_back(MP(a[i], i));
    }
    sort(b.begin(), b.end());

    UnionFind uf(N);

    //素因数分解
    map<int,int> so;
    for(int i=0; i<N; i++){
        for(int j=2; j<=sqrt(a[i])+1; j++){
            if(a[i] % j == 0){
                a[i] /= j;
                auto itr = so.find(j);
                if(itr == so.end()) so[j] = i;
                else uf.unite(i,itr->second);
                j--;
            }
        }
        if(a[i] != 1){
            auto itr = so.find(a[i]);
            if(itr == so.end()) so[a[i]] = i;
            else uf.unite(i,itr->second);
        }
    }

    //判定
    for(int i=0; i<N; i++){
        if(!uf.same(i, b[i].second)){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << 1 << endl;

    return 0;
}

```


### Prompt

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

Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform n operations. Each operation is one of the following:

  1. Add the integer xi to the first ai elements of the sequence.
  2. Append an integer ki to the end of the sequence. (And hence the size of the sequence increases by 1)
  3. Remove the last element of the sequence. So, the size of the sequence decreases by one. Note, that this operation can only be done if there are at least two elements in the sequence.

After each operation, the cows would like to know the average of all the numbers in the sequence. Help them!

Input

The first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of operations. The next n lines describe the operations. Each line will start with an integer ti (1 ≤ ti ≤ 3), denoting the type of the operation (see above). If ti = 1, it will be followed by two integers ai, xi (|xi| ≤ 103; 1 ≤ ai). If ti = 2, it will be followed by a single integer ki (|ki| ≤ 103). If ti = 3, it will not be followed by anything.

It is guaranteed that all operations are correct (don't touch nonexistent elements) and that there will always be at least one element in the sequence.

Output

Output n lines each containing the average of the numbers in the sequence after the corresponding operation.

The answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6.

Examples

Input

5
2 1
3
2 3
2 1
3

Output

0.500000
0.000000
1.500000
1.333333
1.500000

Input

6
2 1
1 2 20
2 2
1 2 -3
3
3

Output

0.500000
20.500000
14.333333
12.333333
17.500000
17.000000

Note

In the second sample, the sequence becomes <image>

### Response

```cpp
#include <bits/stdc++.h>
const int inf = 0xfffffff;
const long long INF = 1ll << 61;
using namespace std;
int add[200000 + 5];
int now[200000 + 5];
int len;
double sum;
void init() {
  len = 1;
  sum = 0.00;
  memset(add, 0, sizeof(add));
  memset(now, 0, sizeof(now));
}
void input(int &n) { scanf("%d", &n); }
void cal(int &n) {
  int t;
  while (n--) {
    scanf("%d", &t);
    if (t == 1) {
      int x, a;
      scanf("%d %d", &a, &x);
      sum += a * x;
      add[a] += x;
      double ans = sum * 1.0 / len * 1.0;
      printf("%lf\n", ans);
    } else if (t == 2) {
      int x;
      scanf("%d", &x);
      now[++len] = x;
      sum += x;
      double ans = sum * 1.0 / len * 1.0;
      printf("%lf\n", ans);
    } else {
      if (len < 2) continue;
      sum -= now[len];
      sum -= add[len];
      if (add[len]) add[len - 1] += add[len];
      add[len] = 0;
      now[len] = 0;
      --len;
      double ans = sum * 1.0 / len * 1.0;
      printf("%lf\n", ans);
    }
  }
}
void output() {}
int main() {
  int n;
  init();
  input(n);
  cal(n);
  output();
  return 0;
}

```


### Prompt

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

There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step.

You're given the initial arrangement of the psychos in the line. Calculate how many steps are needed to the moment of time such, that nobody kills his neighbor after that moment. Look notes to understand the statement more precise.

Input

The first line of input contains integer n denoting the number of psychos, (1 ≤ n ≤ 105). In the second line there will be a list of n space separated distinct integers each in range 1 to n, inclusive — ids of the psychos in the line from left to right.

Output

Print the number of steps, so that the line remains the same afterward.

Examples

Input

10
10 9 7 8 6 5 3 4 2 1

Output

2

Input

6
1 2 3 4 5 6

Output

0

Note

In the first sample line of the psychos transforms as follows: [10 9 7 8 6 5 3 4 2 1]  →  [10 8 4] →  [10]. So, there are two steps.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
int a[100001], n, num, siz = 0, sq;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> kill(n, 1);
  stack<int> s;
  s.push(0);
  kill[0] = 1000000000;
  for (int i = 1; i < n; i++) {
    while (!s.empty() && a[i] > a[s.top()]) {
      kill[i] = max(kill[s.top()] + 1, kill[i]);
      s.pop();
    }
    s.push(i);
  }
  num = 0;
  for (int i = 0; i < n; i++)
    if (kill[i] < 1000000000) num = max(num, kill[i]);
  cout << num;
}

```


### Prompt

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

XXI Berland Annual Fair is coming really soon! Traditionally fair consists of n booths, arranged in a circle. The booths are numbered 1 through n clockwise with n being adjacent to 1. The i-th booths sells some candies for the price of a_i burles per item. Each booth has an unlimited supply of candies.

Polycarp has decided to spend at most T burles at the fair. However, he has some plan in mind for his path across the booths:

  * at first, he visits booth number 1;
  * if he has enough burles to buy exactly one candy from the current booth, then he buys it immediately;
  * then he proceeds to the next booth in the clockwise order (regardless of if he bought a candy or not).

Polycarp's money is finite, thus the process will end once he can no longer buy candy at any booth.

Calculate the number of candies Polycarp will buy.

Input

The first line contains two integers n and T (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ T ≤ 10^{18}) — the number of booths at the fair and the initial amount of burles Polycarp has.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the price of the single candy at booth number i.

Output

Print a single integer — the total number of candies Polycarp will buy.

Examples

Input

3 38
5 2 5

Output

10

Input

5 21
2 4 100 2 6

Output

6

Note

Let's consider the first example. Here are Polycarp's moves until he runs out of money:

  1. Booth 1, buys candy for 5, T = 33;
  2. Booth 2, buys candy for 2, T = 31;
  3. Booth 3, buys candy for 5, T = 26;
  4. Booth 1, buys candy for 5, T = 21;
  5. Booth 2, buys candy for 2, T = 19;
  6. Booth 3, buys candy for 5, T = 14;
  7. Booth 1, buys candy for 5, T = 9;
  8. Booth 2, buys candy for 2, T = 7;
  9. Booth 3, buys candy for 5, T = 2;
  10. Booth 1, buys no candy, not enough money;
  11. Booth 2, buys candy for 2, T = 0.

No candy can be bought later. The total number of candies bought is 10.

In the second example he has 1 burle left at the end of his path, no candy can be bought with this amount.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  unsigned long long T;
  cin >> n >> T;
  vector<unsigned long long> v(n + 100);
  for (int i = 0; i < n; i++) cin >> v[i];
  unsigned long long res = 0;
  while (true) {
    int i = 0;
    unsigned long long temp = T, sum = 0, cnt = 0;
    while (i < n && temp > 0) {
      if (v[i] <= temp) {
        temp -= v[i];
        sum += v[i];
        cnt++;
      }
      i++;
    }
    if (cnt == 0) break;
    res += (T / sum) * cnt;
    T = T % sum;
  }
  cout << res << endl;
  return 0;
}

```


### Prompt

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

Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.

Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≤ x, y. There is a tree in such a point, and it has x + y bananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation <image>. Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point.

Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely.

Okabe is sure that the answer does not exceed 1018. You can trust him.

Input

The first line of input contains two space-separated integers m and b (1 ≤ m ≤ 1000, 1 ≤ b ≤ 10000).

Output

Print the maximum number of bananas Okabe can get from the trees he cuts.

Examples

Input

1 5

Output

30

Input

2 3

Output

25

Note

<image>

The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long m, b, maxx = 0;
  cin >> m >> b;
  for (int y = 0; y < b; ++y)
    maxx = max(maxx, (m * (b - y) + 1) * (m * (b - y) + y) * (y + 1) / 2);
  cout << maxx;
}

```


### Prompt

Generate a CPP solution to the following problem:

Having learned (not without some help from the Codeforces participants) to play the card game from the previous round optimally, Shrek and Donkey (as you may remember, they too live now in the Kingdom of Far Far Away) have decided to quit the boring card games and play with toy soldiers.

The rules of the game are as follows: there is a battlefield, its size equals n × m squares, some squares contain the toy soldiers (the green ones belong to Shrek and the red ones belong to Donkey). Besides, each of the n lines of the area contains not more than two soldiers. During a move a players should select not less than 1 and not more than k soldiers belonging to him and make them either attack or retreat.

An attack is moving all of the selected soldiers along the lines on which they stand in the direction of an enemy soldier, if he is in this line. If this line doesn't have an enemy soldier, then the selected soldier on this line can move in any direction during the player's move. Each selected soldier has to move at least by one cell. Different soldiers can move by a different number of cells. During the attack the soldiers are not allowed to cross the cells where other soldiers stand (or stood immediately before the attack). It is also not allowed to go beyond the battlefield or finish the attack in the cells, where other soldiers stand (or stood immediately before attack).

A retreat is moving all of the selected soldiers along the lines on which they stand in the direction from an enemy soldier, if he is in this line. The other rules repeat the rules of the attack.

For example, let's suppose that the original battlefield had the form (here symbols "G" mark Shrek's green soldiers and symbols "R" mark Donkey's red ones):

    -G-R-
    -R-G-

Let's suppose that k = 2 and Shrek moves first. If he decides to attack, then after his move the battlefield can look like that:

    --GR-     --GR-     -G-R-
    -RG--     -R-G-     -RG--

If in the previous example Shrek decides to retreat, then after his move the battlefield can look like that:

    G--R-     G--R-     -G-R-
    -R--G     -R-G-     -R--G

On the other hand, the followings fields cannot result from Shrek's correct move:

    G--R-     ---RG     --GR-
    -RG--     -R-G-     GR---

Shrek starts the game. To make a move means to attack or to retreat by the rules. A player who cannot make a move loses and his opponent is the winner. Determine the winner of the given toy soldier game if Shrek and Donkey continue to be under the yellow pills from the last rounds' problem. Thus, they always play optimally (that is, they try to win if it is possible, or finish the game in a draw, by ensuring that it lasts forever, if they cannot win).

Input

The first line contains space-separated integers n, m and k (1 ≤ n, m, k ≤ 100). Then n lines contain m characters each. These characters belong to the set {"-", "G", "R"}, denoting, respectively, a battlefield's free cell, a cell occupied by Shrek's soldiers and a cell occupied by Donkey's soldiers.

It is guaranteed that each line contains no more than two soldiers.

Output

Print "First" (without the quotes) if Shrek wins in the given Toy Soldier game. If Donkey wins, print "Second" (without the quotes). If the game continues forever, print "Draw" (also without the quotes).

Examples

Input

2 3 1
R-G
RG-

Output

First

Input

3 3 2
G-R
R-G
G-R

Output

Second

Input

2 3 1
-R-
-G-

Output

Draw

Input

2 5 2
-G-R-
-R-G-

Output

First

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
char str[105][105];
int n, m, k;
int gwin, rwin;
vector<int> num;
int dp[105];
void get() {
  gwin = -1;
  rwin = -1;
  for (int i = 1; i <= n; i++) {
    int R = -1;
    int G = -1;
    int has = 0;
    for (int j = 0; j < m; j++) {
      if (str[i][j] == 'G')
        G = j;
      else if (str[i][j] == 'R')
        R = j;
      else if (str[i][j] == '-')
        has = 1;
    }
    if (G != -1 && R == -1 && has) gwin = 1;
    if (R != -1 && G == -1 && has) rwin = 1;
    if (R != -1 && G != -1 && abs(G - R) != 1) num.push_back(abs(R - G) - 1);
  }
}
void Compute() {
  if (rwin == 1 && gwin == -1) {
    printf("Second\n");
  } else if (rwin == -1 && gwin == 1) {
    printf("First\n");
  } else if (rwin == 1 && gwin == 1)
    printf("Draw\n");
  else {
    bool flag = true;
    for (int bit = 0; bit <= 8; bit++) {
      int sum = 0;
      for (size_t i = 0; i < num.size(); i++) {
        int v = num[i];
        sum = sum + ((v >> bit) & 1);
      }
      if (sum % (k + 1)) {
        flag = false;
        break;
      }
    }
    if (!flag)
      printf("First\n");
    else
      printf("Second\n");
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%s", str[i]);
  }
  get();
  Compute();
  return 0;
}

```


### Prompt

Create a solution in cpp for the following problem:

Let s be some string consisting of symbols "0" or "1". Let's call a string t a substring of string s, if there exists such number 1 ≤ l ≤ |s| - |t| + 1 that t = s_l s_{l+1} … s_{l + |t| - 1}. Let's call a substring t of string s unique, if there exist only one such l.

For example, let s = "1010111". A string t = "010" is an unique substring of s, because l = 2 is the only one suitable number. But, for example t = "10" isn't a unique substring of s, because l = 1 and l = 3 are suitable. And for example t ="00" at all isn't a substring of s, because there is no suitable l.

Today Vasya solved the following problem at the informatics lesson: given a string consisting of symbols "0" and "1", the task is to find the length of its minimal unique substring. He has written a solution to this problem and wants to test it. He is asking you to help him.

You are given 2 positive integers n and k, such that (n mod 2) = (k mod 2), where (x mod 2) is operation of taking remainder of x by dividing on 2. Find any string s consisting of n symbols "0" or "1", such that the length of its minimal unique substring is equal to k.

Input

The first line contains two integers n and k, separated by spaces (1 ≤ k ≤ n ≤ 100 000, (k mod 2) = (n mod 2)).

Output

Print a string s of length n, consisting of symbols "0" and "1". Minimal length of the unique substring of s should be equal to k. You can find any suitable string. It is guaranteed, that there exists at least one such string.

Examples

Input

4 4

Output

1111

Input

5 3

Output

01010

Input

7 3

Output

1011011

Note

In the first test, it's easy to see, that the only unique substring of string s = "1111" is all string s, which has length 4.

In the second test a string s = "01010" has minimal unique substring t ="101", which has length 3.

In the third test a string s = "1011011" has minimal unique substring t ="110", which has length 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3c3c3c3c;
const long long LINF = 1ll * INF * INF * 2;
const int N = 1000001;
int n, m;
int x[N];
int ans[N];
int main(void) {
  scanf("%d%d", &n, &m);
  if (m == 1) {
    printf("0");
    for (int i = 1; i < n; i++) printf("1");
    return 0;
  }
  int T = (n - m) / 2 + 1;
  for (int i = 0; i < T - 1; i++) x[i] = 1;
  x[T] = 0;
  for (int i = 0; i < n; i++) printf("%d", x[i % T]);
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Dreamoon likes to play with sets, integers and <image>. <image> is defined as the largest positive integer that divides both a and b.

Let S be a set of exactly four distinct integers greater than 0. Define S to be of rank k if and only if for all pairs of distinct elements si, sj from S, <image>.

Given k and n, Dreamoon wants to make up n sets of rank k using integers from 1 to m such that no integer is used in two different sets (of course you can leave some integers without use). Calculate the minimum m that makes it possible and print one possible solution.

Input

The single line of the input contains two space separated integers n, k (1 ≤ n ≤ 10 000, 1 ≤ k ≤ 100).

Output

On the first line print a single integer — the minimal possible m.

On each of the next n lines print four space separated integers representing the i-th set.

Neither the order of the sets nor the order of integers within a set is important. If there are multiple possible solutions with minimal m, print any one of them.

Examples

Input

1 1

Output

5
1 2 3 5

Input

2 2

Output

22
2 4 6 22
14 18 10 16

Note

For the first example it's easy to see that set {1, 2, 3, 4} isn't a valid set of rank 1 since <image>.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = (1e9) + 7;
int n, k;
long long dp[10010][4];
int main() {
  scanf("%d%d", &n, &k);
  dp[0][0] = 1;
  dp[0][1] = 2;
  dp[0][2] = 3;
  dp[0][3] = 5;
  long long ans;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 4; ++j) dp[i][j] = dp[i - 1][j] + 6;
  }
  ans = dp[n - 1][3] * k;
  printf("%I64d\n", ans);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 4; j++) {
      if (j) printf(" ");
      printf("%I64d", dp[i][j] * k);
    }
    printf("\n");
  }
  return 0;
}

```