### Prompt

Create a solution in Cpp for the following problem:

You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (xi, yi). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coordinates (0, 0). Also, let's mark the robot's current position as (x, y). In order to destroy all the bombs, the robot can perform three types of operations:

  1. Operation has format "1 k dir". To perform the operation robot have to move in direction dir k (k ≥ 1) times. There are only 4 directions the robot can move in: "R", "L", "U", "D". During one move the robot can move from the current point to one of following points: (x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1) (corresponding to directions). It is forbidden to move from point (x, y), if at least one point on the path (besides the destination point) contains a bomb.
  2. Operation has format "2". To perform the operation robot have to pick a bomb at point (x, y) and put it in a special container. Thus, the robot can carry the bomb from any point to any other point. The operation cannot be performed if point (x, y) has no bomb. It is forbidden to pick a bomb if the robot already has a bomb in its container.
  3. Operation has format "3". To perform the operation robot have to take a bomb out of the container and destroy it. You are allowed to perform this operation only if the robot is at point (0, 0). It is forbidden to perform the operation if the container has no bomb.

Help the robot and find the shortest possible sequence of operations he can perform to destroy all bombs on the coordinate plane.

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of bombs on the coordinate plane. Next n lines contain two integers each. The i-th line contains numbers (xi, yi) ( - 109 ≤ xi, yi ≤ 109) — the coordinates of the i-th bomb. It is guaranteed that no two bombs are located at the same point and no bomb is at point (0, 0).

Output

In a single line print a single integer k — the minimum number of operations needed to destroy all bombs. On the next lines print the descriptions of these k operations. If there are multiple sequences, you can print any of them. It is guaranteed that there is the solution where k ≤ 106.

Examples

Input

2
1 1
-1 -1

Output

12
1 1 R
1 1 U
2
1 1 L
1 1 D
3
1 1 L
1 1 D
2
1 1 R
1 1 U
3

Input

3
5 0
0 5
1 0

Output

12
1 1 R
2
1 1 L
3
1 5 R
2
1 5 L
3
1 5 U
2
1 5 D
3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = ((long long)1E9 + 7);
template <class C>
void mini(C& aaaa, C bbbb) {
  aaaa = min(aaaa, bbbb);
}
template <class C>
void maxi(C& aaaa, C bbbb) {
  aaaa = max(aaaa, bbbb);
}
const int MX = 100100;
complex<int> p[MX];
bool comp(complex<int> a, complex<int> b) {
  return abs(a.real()) + abs(a.imag()) < abs(b.real()) + abs(b.imag());
}
void go(complex<int> a) {
  if (a.real() > 0) cout << 1 << " " << a.real() << " R" << endl;
  if (a.real() < 0) cout << 1 << " " << -a.real() << " L" << endl;
  if (a.imag() > 0) cout << 1 << " " << a.imag() << " U" << endl;
  if (a.imag() < 0) cout << 1 << " " << -a.imag() << " D" << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    int x, y;
    cin >> x >> y;
    p[i] = complex<int>(x, y);
  }
  sort(p, p + n, comp);
  int res = 0;
  for (int i = 0; i < (n); ++i) {
    res += 6;
    if (p[i].real() == 0) res -= 2;
    if (p[i].imag() == 0) res -= 2;
  }
  cout << res << endl;
  for (int i = 0; i < (n); ++i) {
    go(p[i]);
    cout << 2 << endl;
    go(complex<int>(0, 0) - p[i]);
    cout << 3 << endl;
  }
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, puzzles that are as famous as the Rubik's cube once was.

Its most important components are a button and a line of n similar gears. Each gear has n teeth containing all numbers from 0 to n - 1 in the counter-clockwise order. When you push a button, the first gear rotates clockwise, then the second gear rotates counter-clockwise, the the third gear rotates clockwise an so on.

Besides, each gear has exactly one active tooth. When a gear turns, a new active tooth is the one following after the current active tooth according to the direction of the rotation. For example, if n = 5, and the active tooth is the one containing number 0, then clockwise rotation makes the tooth with number 1 active, or the counter-clockwise rotating makes the tooth number 4 active.

Andrewid remembers that the real puzzle has the following property: you can push the button multiple times in such a way that in the end the numbers on the active teeth of the gears from first to last form sequence 0, 1, 2, ..., n - 1. Write a program that determines whether the given puzzle is real or fake.

Input

The first line contains integer n (1 ≤ n ≤ 1000) — the number of gears.

The second line contains n digits a1, a2, ..., an (0 ≤ ai ≤ n - 1) — the sequence of active teeth: the active tooth of the i-th gear contains number ai.

Output

In a single line print "Yes" (without the quotes), if the given Stolp's gears puzzle is real, and "No" (without the quotes) otherwise.

Examples

Input

3
1 0 0

Output

Yes

Input

5
4 2 1 4 3

Output

Yes

Input

4
0 2 3 1

Output

No

Note

In the first sample test when you push the button for the first time, the sequence of active teeth will be 2 2 1, when you push it for the second time, you get 0 1 2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 10;
int pos[mx], n;
int main() {
  cin >> n;
  for (int i = int(1); i <= int(n); ++i) cin >> pos[i];
  int nr = (0 - pos[1] + n) % n;
  int chk = 1;
  for (int i = int(2); i <= int(n); ++i) {
    if ((i & 1) == 0) {
      if ((pos[i] - nr + n) % n != i - 1) {
        chk = 0;
        break;
      }
    } else {
      if ((pos[i] + nr) % n != i - 1) {
        chk = 0;
        break;
      }
    }
  }
  if (chk)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

```


### Prompt

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

The Smart Beaver from ABBYY has a long history of cooperating with the "Institute of Cytology and Genetics". Recently, the Institute staff challenged the Beaver with a new problem. The problem is as follows.

There is a collection of n proteins (not necessarily distinct). Each protein is a string consisting of lowercase Latin letters. The problem that the scientists offered to the Beaver is to select a subcollection of size k from the initial collection of proteins so that the representativity of the selected subset of proteins is maximum possible.

The Smart Beaver from ABBYY did some research and came to the conclusion that the representativity of a collection of proteins can be evaluated by a single number, which is simply calculated. Let's suppose we have a collection {a1, ..., ak} consisting of k strings describing proteins. The representativity of this collection is the following value:

<image>

where f(x, y) is the length of the longest common prefix of strings x and y; for example, f("abc", "abd") = 2, and f("ab", "bcd") = 0.

Thus, the representativity of collection of proteins {"abc", "abd", "abe"} equals 6, and the representativity of collection {"aaa", "ba", "ba"} equals 2.

Having discovered that, the Smart Beaver from ABBYY asked the Cup contestants to write a program that selects, from the given collection of proteins, a subcollection of size k which has the largest possible value of representativity. Help him to solve this problem!

Input

The first input line contains two integers n and k (1 ≤ k ≤ n), separated by a single space. The following n lines contain the descriptions of proteins, one per line. Each protein is a non-empty string of no more than 500 characters consisting of only lowercase Latin letters (a...z). Some of the strings may be equal.

The input limitations for getting 20 points are:

  * 1 ≤ n ≤ 20

The input limitations for getting 50 points are:

  * 1 ≤ n ≤ 100

The input limitations for getting 100 points are:

  * 1 ≤ n ≤ 2000

Output

Print a single number denoting the largest possible value of representativity that a subcollection of size k of the given collection of proteins can have.

Examples

Input

3 2
aba
bzd
abq

Output

2

Input

4 3
eee
rrr
ttt
qqq

Output

0

Input

4 3
aaa
abba
abbc
abbd

Output

9

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MX = 2005;
int lcp[MX];
int n;
int cnt = 0;
int dp[2 * MX][MX];
int calc(int L, int R) {
  int cur = cnt++;
  if (L == R) return cur;
  int ii = L;
  for (int i = L + 1; i < R; i++) {
    if (lcp[i] < lcp[ii]) ii = i;
  }
  int a = calc(L, ii), b = calc(ii + 1, R);
  for (int lk = 0; lk <= ii - L + 1; lk++) {
    for (int rk = 0; rk <= R - ii; rk++) {
      int tmp = dp[a][lk] + dp[b][rk] + lcp[ii] * lk * rk;
      dp[cur][lk + rk] = max(dp[cur][lk + rk], tmp);
    }
  }
  return cur;
}
string s[MX];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> s[i];
  sort(s, s + n);
  for (int i = 0; i + 1 < n; i++) {
    while (lcp[i] < (int)s[i].size() && lcp[i] < (int)s[i + 1].size() &&
           s[i][lcp[i]] == s[i + 1][lcp[i]]) {
      lcp[i]++;
    }
  }
  calc(0, n - 1);
  printf("%d\n", dp[0][k]);
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are n inflorescences, numbered from 1 to n. Inflorescence number 1 is situated near base of tree and any other inflorescence with number i (i > 1) is situated at the top of branch, which bottom is pi-th inflorescence and pi < i.

Once tree starts fruiting, there appears exactly one apple in each inflorescence. The same moment as apples appear, they start to roll down along branches to the very base of tree. Each second all apples, except ones in first inflorescence simultaneously roll down one branch closer to tree base, e.g. apple in a-th inflorescence gets to pa-th inflorescence. Apples that end up in first inflorescence are gathered by Arcady in exactly the same moment. Second peculiarity of this tree is that once two apples are in same inflorescence they annihilate. This happens with each pair of apples, e.g. if there are 5 apples in same inflorescence in same time, only one will not be annihilated and if there are 8 apples, all apples will be annihilated. Thus, there can be no more than one apple in each inflorescence in each moment of time.

Help Arcady with counting number of apples he will be able to collect from first inflorescence during one harvest.

Input

First line of input contains single integer number n (2 ≤ n ≤ 100 000) — number of inflorescences.

Second line of input contains sequence of n - 1 integer numbers p2, p3, ..., pn (1 ≤ pi < i), where pi is number of inflorescence into which the apple from i-th inflorescence rolls down.

Output

Single line of output should contain one integer number: amount of apples that Arcady will be able to collect from first inflorescence during one harvest.

Examples

Input

3
1 1

Output

1

Input

5
1 2 2 2

Output

3

Input

18
1 1 1 4 4 3 2 2 2 10 8 9 9 9 10 10 4

Output

4

Note

In first example Arcady will be able to collect only one apple, initially situated in 1st inflorescence. In next second apples from 2nd and 3rd inflorescences will roll down and annihilate, and Arcady won't be able to collect them.

In the second example Arcady will be able to collect 3 apples. First one is one initially situated in first inflorescence. In a second apple from 2nd inflorescence will roll down to 1st (Arcady will collect it) and apples from 3rd, 4th, 5th inflorescences will roll down to 2nd. Two of them will annihilate and one not annihilated will roll down from 2-nd inflorescence to 1st one in the next second and Arcady will collect it.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int n;
vector<int> child[100005];
int ceng[100005];
void dfs(int v, int ii) {
  ceng[ii]++;
  for (int i = 0; i < child[v].size(); i++) {
    dfs(child[v][i], ii + 1);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int tmp;
    scanf("%d", &tmp);
    child[tmp].push_back(i);
  }
  int ans = 0;
  dfs(1, 1);
  for (int i = 1; i <= n; i++) {
    if (ceng[i] % 2 == 0) {
      ceng[i] = 0;
    }
    if (ceng[i]) ceng[i] = 1;
    ans += ceng[i];
  }
  cout << ans << endl;
}

```


### Prompt

Generate a CPP solution to the following problem:

You are given an array a_1, a_2, …, a_n.

You need to perform q queries of the following two types:

  1. "MULTIPLY l r x" — for every i (l ≤ i ≤ r) multiply a_i by x.
  2. "TOTIENT l r" — print \varphi(∏ _{i=l}^{r} a_i) taken modulo 10^9+7, where \varphi denotes Euler's totient function.

The [Euler's totient function](http://gg.gg/euler_totient) of a positive integer n (denoted as \varphi(n)) is the number of integers x (1 ≤ x ≤ n) such that \gcd(n,x) = 1.

Input

The first line contains two integers n and q (1 ≤ n ≤ 4 ⋅ 10^5, 1 ≤ q ≤ 2 ⋅ 10^5) — the number of elements in array a and the number of queries.

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 300) — the elements of array a.

Then q lines follow, describing queries in the format given in the statement.

  1. "MULTIPLY l r x" (1 ≤ l ≤ r ≤ n, 1 ≤ x ≤ 300) — denotes a multiplication query.
  2. "TOTIENT l r" (1 ≤ l ≤ r ≤ n) — denotes a query on the value of Euler's totient function.

It is guaranteed that there is at least one "TOTIENT" query.

Output

For each "TOTIENT" query, print the answer to it.

Example

Input

4 4
5 9 1 2
TOTIENT 3 3
TOTIENT 3 4
MULTIPLY 4 4 3
TOTIENT 4 4

Output

1
1
2

Note

In the first example, \varphi(1) = 1 for the first query, \varphi(2) = 1 for the second query and \varphi(6) = 2 for the third one.

### Response

```cpp
#include <bits/stdc++.h>
inline long long mi(long long a, long long b, long long mo) {
  long long ans = 1ll;
  a %= mo;
  while (b) {
    if (b & 1) ans = ans * a % mo;
    b >>= 1;
    a = a * a % mo;
  }
  return ans;
}
inline long long read() {
  long long t = 0;
  bool neg = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') neg = 1;
    ch = getchar();
  }
  do {
    t = t * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  if (neg) t = -t;
  return t;
}
long long readOpt() {
  char ch = getchar();
  long long ans;
  while (ch < 'A' || ch > 'Z') ch = getchar();
  if (ch == 'T')
    return 2;
  else
    return 1;
}
struct Node {
  long long val;
  long long p;
  long long lazy, lazyP;
  Node() {
    val = 1;
    lazy = 1;
    p = 0;
    lazyP = 0;
  }
} xds[1600007];
long long n, q;
long long a[1600007];
long long f[1001], inv[1001];
long long prime[] = {2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,
                     37,  41,  43,  47,  53,  59,  61,  67,  71,  73,  79,
                     83,  89,  97,  101, 103, 107, 109, 113, 127, 131, 137,
                     139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193,
                     197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257,
                     263, 269, 271, 277, 281, 283, 293};
void pushUp(long long x) {
  xds[x].val = xds[x * 2].val * xds[x * 2 + 1].val % 1000000007;
  xds[x].p = xds[x * 2].p | xds[x * 2 + 1].p;
}
void pushDown(long long x, long long l, long long m, long long r) {
  xds[x * 2].val =
      xds[x * 2].val * mi(xds[x].lazy, m - l + 1, 1000000007) % 1000000007;
  xds[x * 2 + 1].val =
      xds[x * 2 + 1].val * mi(xds[x].lazy, r - m, 1000000007) % 1000000007;
  xds[x * 2].lazy = xds[x * 2].lazy * xds[x].lazy % 1000000007;
  xds[x * 2 + 1].lazy = xds[x * 2 + 1].lazy * xds[x].lazy % 1000000007;
  xds[x * 2].p |= xds[x].lazyP;
  xds[x * 2 + 1].p |= xds[x].lazyP;
  xds[x * 2].lazyP |= xds[x].lazyP;
  xds[x * 2 + 1].lazyP |= xds[x].lazyP;
  xds[x].lazy = 1;
  xds[x].lazyP = 0;
}
void build(long long l, long long r, long long x) {
  if (l == r) {
    xds[x].val = a[l];
    for (long long i = 0; i < 62; ++i)
      if (a[l] % prime[i] == 0) xds[x].p |= (1ll) << i;
    return;
  }
  const long long m = (l + r) >> 1;
  build(l, m, x * 2);
  build(m + 1, r, x * 2 + 1);
  pushUp(x);
}
void update(long long x, long long l, long long r, long long delta,
            long long prime, long long cl, long long cr) {
  if (cl > r || cr < l) return;
  if (l <= cl && cr <= r) {
    xds[x].val = xds[x].val * mi(delta, cr - cl + 1, 1000000007) % 1000000007;
    xds[x].lazy = xds[x].lazy * delta % 1000000007;
    xds[x].p |= prime;
    xds[x].lazyP |= prime;
    return;
  }
  const long long m = (cl + cr) >> 1;
  pushDown(x, cl, m, cr);
  update(x * 2, l, r, delta, prime, cl, m);
  update(x * 2 + 1, l, r, delta, prime, m + 1, cr);
  pushUp(x);
}
Node query(long long x, long long l, long long r, long long cl, long long cr) {
  if (cl > r || cr < l) return Node();
  if (l <= cl && r >= cr) {
    return xds[x];
  }
  const long long m = (cl + cr) >> 1;
  pushDown(x, cl, m, cr);
  Node n;
  Node ll = query(x * 2, l, r, cl, m);
  Node rr = query(x * 2 + 1, l, r, m + 1, cr);
  n.val = ll.val * rr.val % 1000000007;
  n.p = ll.p | rr.p;
  return n;
}
signed main() {
  n = read(), q = read();
  for (long long i = 1; i <= n; ++i) a[i] = read();
  build(1, n, 1);
  inv[1] = 1;
  for (long long i = 2; i <= 300; ++i)
    inv[i] = 1000000007 - (1000000007 / i) * inv[1000000007 % i] % 1000000007;
  for (long long i = 0; i < 62; ++i)
    f[i] = inv[prime[i]] * (prime[i] - 1) % 1000000007;
  for (long long i = 1; i <= q; i += 1) {
    long long opt = readOpt(), x = read(), y = read();
    if (opt == 1) {
      long long k = read();
      long long t = 0;
      for (long long i = 0; i < 62; ++i)
        if (k % prime[i] == 0) t |= (1ll) << i;
      update(1, x, y, k, t, 1, n);
    } else {
      Node ans = query(1, x, y, 1, n);
      long long phi = ans.val;
      for (long long i = 0; i < 62; ++i) {
        if (ans.p >> i & 1) {
          phi = phi * f[i] % 1000000007;
        }
      }
      printf("%lld\n", phi % 1000000007);
    }
  }
  return 0;
}

```


### Prompt

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

There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N.

In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N.

When activated, each type of robot will operate as follows.

* When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.

* When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything.

Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.

Constraints

* 1 \leq N \leq 100
* 1 \leq K \leq 100
* 0 < x_i < K
* All input values are integers.

Inputs

Input is given from Standard Input in the following format:

N
K
x_1 x_2 ... x_N

Outputs

Print the minimum possible total distance covered by robots.

Examples

Input

1
10
2

Output

4

Input

2
9
3 6

Output

12

Input

5
20
11 12 9 17 12

Output

74

### Response

```cpp
#include <iostream>
using namespace std;
int main()
{
  int N,K,s;
  cin>>N;
  cin>>K;
  int x[N];
  s=0;
  for(int i=0;i<N;i++){
    cin>>x[i];
    s+=2*min(x[i],K-x[i]);
  }
  cout<<s<<endl;
  return 0;
}
```


### Prompt

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

Alice lives on a line. Today, she will travel to some place in a mysterious vehicle. Initially, the distance between Alice and her destination is D. When she input a number x to the vehicle, it will travel in the direction of the destination by a distance of x if this move would shorten the distance between the vehicle and the destination, and it will stay at its position otherwise. Note that the vehicle may go past the destination when the distance between the vehicle and the destination is less than x.

Alice made a list of N numbers. The i-th number in this list is d_i. She will insert these numbers to the vehicle one by one.

However, a mischievous witch appeared. She is thinking of rewriting one number in the list so that Alice will not reach the destination after N moves.

She has Q plans to do this, as follows:

* Rewrite only the q_i-th number in the list with some integer so that Alice will not reach the destination.

Write a program to determine whether each plan is feasible.

Constraints

* 1≤ N ≤ 5*10^5
* 1≤ Q ≤ 5*10^5
* 1≤ D ≤ 10^9
* 1≤ d_i ≤ 10^9(1≤i≤N)
* 1≤ q_i ≤ N(1≤i≤Q)
* D and each d_i are integers.

Input

Input is given from Standard Input in the following format:

N D
d_1 d_2 ... d_N
Q
q_1 q_2 ... q_Q

Output

Print Q lines. The i-th line should contain `YES` if the i-th plan is feasible, and `NO` otherwise.

Examples

Input

4 10
3 4 3 3
2
4 3

Output

NO
YES

Input

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

Output

YES
YES
YES
YES
YES

Input

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

Output

NO
NO
YES
NO
NO
YES

### Response

```cpp
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=1e6;
int a[N],f1[N],f2[N];
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	f1[0]=d;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		f1[i]=min(f1[i-1],abs(f1[i-1]-a[i]));
	}
	f2[n+1]=1;
	for (int i=n;i>=1;i--)
	{
		if (a[i]>=2*f2[i+1]) f2[i]=f2[i+1]; else f2[i]=f2[i+1]+a[i];
	}
	int q;
	scanf("%d",&q);
	for (int i=1;i<=q;i++)
	{
		int j;
		scanf("%d",&j);
		if (f1[j-1]<f2[j+1]) printf("%s\n","NO"); else printf("%s\n","YES");
	}
}
```


### Prompt

Construct a Cpp code solution to the problem outlined:

You are given a boolean function of three variables which is defined by its truth table. You need to find an expression of minimum length that equals to this function. The expression may consist of:

  * Operation AND ('&', ASCII code 38)
  * Operation OR ('|', ASCII code 124)
  * Operation NOT ('!', ASCII code 33)
  * Variables x, y and z (ASCII codes 120-122)
  * Parentheses ('(', ASCII code 40, and ')', ASCII code 41)

If more than one expression of minimum length exists, you should find the lexicographically smallest one.

Operations have standard priority. NOT has the highest priority, then AND goes, and OR has the lowest priority. The expression should satisfy the following grammar:

E ::= E '|' T | T

T ::= T '&' F | F

F ::= '!' F | '(' E ')' | 'x' | 'y' | 'z'

Input

The first line contains one integer n — the number of functions in the input (1 ≤ n ≤ 10 000).

The following n lines contain descriptions of functions, the i-th of them contains a string of length 8 that consists of digits 0 and 1 — the truth table of the i-th function. The digit on position j (0 ≤ j < 8) equals to the value of the function in case of <image>, <image> and <image>.

Output

You should output n lines, the i-th line should contain the expression of minimum length which equals to the i-th function. If there is more than one such expression, output the lexicographically smallest of them. Expressions should satisfy the given grammar and shouldn't contain white spaces.

Example

Input

4
00110011
00000111
11110000
00011111

Output

y
(y|z)&x
!x
x|y&z

Note

The truth table for the second function:

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool ls(string s, string t) {
  return t == "" || ((int)s.size()) < ((int)t.size()) ||
         ((int)s.size()) == ((int)t.size()) && s < t;
}
string r[256][2];
bool c;
void doit(string s, int i, int k) {
  if (ls(s, r[i][k])) r[i][k] = s, c = true;
}
int main() {
  r[0xF][0] = r[0xF][1] = "x";
  r[255 ^ 0xF][0] = r[255 ^ 0xF][1] = "!x";
  r[0x33][0] = r[0x33][1] = "y";
  r[255 ^ 0x33][0] = r[255 ^ 0x33][1] = "!y";
  r[0x55][0] = r[0x55][1] = "z";
  r[255 ^ 0x55][0] = r[255 ^ 0x55][1] = "!z";
  c = true;
  while (c) {
    c = false;
    for (int i = 0, ThxDem = 256; i < ThxDem; ++i) {
      for (int k = 0, ThxDem = 2; k < ThxDem; ++k)
        if (((int)r[i][k].size())) {
          string s = "!(" + r[i][k] + ")";
          doit(s, 255 ^ i, 0);
          doit(s, 255 ^ i, 1);
        }
    }
    for (int i = 0, ThxDem = 256; i < ThxDem; ++i)
      for (int j = 0, ThxDem = 256; j < ThxDem; ++j)
        for (int ki = 0, ThxDem = 2; ki < ThxDem; ++ki)
          for (int kj = 0, ThxDem = 2; kj < ThxDem; ++kj)
            if (((int)r[i][ki].size()) && ((int)r[j][kj].size())) {
              string s;
              if (!ki)
                s = r[i][ki];
              else
                s = "(" + r[i][ki] + ")";
              s += "&";
              if (!kj)
                s += r[j][kj];
              else
                s += "(" + r[j][kj] + ")";
              doit(s, i & j, 0);
              s = r[i][ki];
              s += "|";
              s += r[j][kj];
              doit(s, i | j, 1);
            }
  }
  for (int i = 0, ThxDem = 256; i < ThxDem; ++i)
    if (ls(r[i][1], r[i][0])) r[i][0] = r[i][1];
  int n;
  scanf("%d", &n);
  while (n--) {
    char s[16];
    scanf("%s", s);
    int x = 0;
    for (int i = 0, ThxDem = 8; i < ThxDem; ++i) x = 2 * x + s[i] - '0';
    printf("%s\n", r[x][0].c_str());
  }
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n.

You need to permute the array elements so that value

<image> became minimal possible. In particular, it is allowed not to change order of elements at all.

Input

The first line contains two integers n, k (2 ≤ n ≤ 3·105, 1 ≤ k ≤ min(5000, n - 1)).

The second line contains n integers A[1], A[2], ..., A[n] ( - 109 ≤ A[i] ≤ 109), separate by spaces — elements of the array A.

Output

Print the minimum possible value of the sum described in the statement.

Examples

Input

3 2
1 2 4

Output

1

Input

5 2
3 -5 3 -5 3

Output

0

Input

6 3
4 3 4 3 2 5

Output

3

Note

In the first test one of the optimal permutations is 1 4 2.

In the second test the initial order is optimal.

In the third test one of the optimal permutations is 2 3 4 4 3 5.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e17;
const int N = 3e5 + 1;
long long dp[5555][5555], A[N];
int main() {
  int n, k, i, j, t;
  scanf("%d %d", &n, &k);
  t = n / k;
  for (i = 1; i <= n; i++) scanf("%I64d", A + i);
  sort(A + 1, A + 1 + n);
  for (i = 0; i <= k; i++)
    for (j = 0; j <= k; j++) dp[i][j] = INF;
  dp[0][0] = 0;
  for (i = 1; i <= k; i++) {
    for (j = 0; j <= i; j++) {
      dp[i][j] = dp[i - 1][j] + abs(A[t * i + j] - A[t * i + j - t + 1]);
      if (j)
        dp[i][j] = min(dp[i][j],
                       dp[i - 1][j - 1] + abs(A[t * i + j] - A[t * i + j - t]));
    }
  }
  cout << dp[k][n % k];
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

Before the start of the football season in Berland a strange magic ritual is held. The most experienced magicians have to find a magic matrix of the size n × n (n is even number). Gods will never allow to start the championship without it. Matrix should contain integers from 0 to n - 1, main diagonal should contain only zeroes and matrix should be symmetric. Moreover, all numbers in each row should be different. Magicians are very tired of the thinking process, so they ask you to write a program to find such matrix.

Input

The first line contains one integer n (2 ≤ n ≤ 1000), n is even.

Output

Output n lines with n numbers each — the required matrix. Separate numbers with spaces. If there are several solutions, output any.

Examples

Input

2

Output

0 1
1 0

Input

4

Output

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[1005][1005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n - 1; j++) {
      a[i][j] = ((i + j) % (n - 1) == 0 ? n - 1 : (i + j) % (n - 1));
    }
  }
  for (int i = 0; i < n; i++) {
    a[i][n - 1] = a[n - 1][i] = a[i][i];
  }
  for (int i = 0; i < n; i++) {
    a[i][i] = 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      printf("%s%d", (j == 0 ? "" : " "), a[i][j]);
    }
    printf("\n");
  }
  return 0;
}

```


### Prompt

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

In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another.

(Cultural note: standing in huge and disorganized queues for hours is a native tradition in Russia, dating back to the Soviet period. Queues can resemble crowds rather than lines. Not to get lost in such a queue, a person should follow a strict survival technique: you approach the queue and ask who the last person is, somebody answers and you join the crowd. Now you're the last person in the queue till somebody else shows up. You keep an eye on the one who was last before you as he is your only chance to get to your destination) I'm sure many people have had the problem when a stranger asks who the last person in the queue is and even dares to hint that he will be the last in the queue and then bolts away to some unknown destination. These are the representatives of the modern world, in which the ratio of lack of time is so great that they do not even watch foreign top-rated TV series. Such people often create problems in queues, because the newcomer does not see the last person in the queue and takes a place after the "virtual" link in this chain, wondering where this legendary figure has left.

The Smart Beaver has been ill and he's made an appointment with a therapist. The doctor told the Beaver the sad news in a nutshell: it is necessary to do an electrocardiogram. The next day the Smart Beaver got up early, put on the famous TV series on download (three hours till the download's complete), clenched his teeth and bravely went to join a queue to the electrocardiogram room, which is notorious for the biggest queues at the clinic.

Having stood for about three hours in the queue, the Smart Beaver realized that many beavers had not seen who was supposed to stand in the queue before them and there was a huge mess. He came up to each beaver in the ECG room queue and asked who should be in front of him in the queue. If the beaver did not know his correct position in the queue, then it might be his turn to go get an ECG, or maybe he should wait for a long, long time...

As you've guessed, the Smart Beaver was in a hurry home, so he gave you all the necessary information for you to help him to determine what his number in the queue can be.

Input

The first line contains two integers n (1 ≤ n ≤ 103) and x (1 ≤ x ≤ n) — the number of beavers that stand in the queue and the Smart Beaver's number, correspondingly. All willing to get to the doctor are numbered from 1 to n.

The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ n) — the number of the beaver followed by the i-th beaver. If ai = 0, then the i-th beaver doesn't know who is should be in front of him. It is guaranteed that values ai are correct. That is there is no cycles in the dependencies. And any beaver is followed by at most one beaver in the queue.

The input limits for scoring 30 points are (subproblem B1):

  * It is guaranteed that the number of zero elements ai doesn't exceed 20.

The input limits for scoring 100 points are (subproblems B1+B2):

  * The number of zero elements ai is arbitrary.

Output

Print all possible positions of the Smart Beaver in the line in the increasing order.

Examples

Input

6 1
2 0 4 0 6 0

Output

2
4
6

Input

6 2
2 3 0 5 6 0

Output

2
5

Input

4 1
0 0 0 0

Output

1
2
3
4

Input

6 2
0 0 1 0 4 5

Output

1
3
4
6

Note

<image> Picture for the fourth test.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int pre[1010];
int a[1010], in[1010];
int dp[1010];
int n, m, my;
int dfs(int x) {
  int cnt = 1;
  int u = x, k = 0;
  if (u == m) k = 1;
  while (pre[u] != u) {
    ++cnt;
    u = pre[u];
    if (u == m) k = 1;
  }
  if (k) {
    int c = 1;
    u = x;
    while (u != m) {
      ++c;
      u = pre[u];
    }
    my = cnt - c + 1;
    return 0;
  } else
    return cnt;
}
int main() {
  int x;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) pre[i] = i, in[i] = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    if (x) pre[i] = x, ++in[x];
  }
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (!in[i]) {
      x = dfs(i);
      if (x) a[cnt++] = x;
    }
  }
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  for (int i = 0; i < cnt; ++i)
    for (int j = n; j - a[i] >= 0; --j)
      if (dp[j - a[i]]) dp[j] = 1;
  for (int i = 0; i <= n; ++i)
    if (dp[i] && i + my <= n) printf("%d\n", i + my);
}

```


### Prompt

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

Attention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We're going to give you the answer, and you need to print a test case that produces the given answer. The original problem is in the following paragraph.

People don't use cash as often as they used to. Having a credit card solves some of the hassles of cash, such as having to receive change when you can't form the exact amount of money needed to purchase an item. Typically cashiers will give you as few coins as possible in change, but they don't have to. For example, if your change is 30 cents, a cashier could give you a 5 cent piece and a 25 cent piece, or they could give you three 10 cent pieces, or ten 1 cent pieces, two 5 cent pieces, and one 10 cent piece. Altogether there are 18 different ways to make 30 cents using only 1 cent pieces, 5 cent pieces, 10 cent pieces, and 25 cent pieces. Two ways are considered different if they contain a different number of at least one type of coin. Given the denominations of the coins and an amount of change to be made, how many different ways are there to make change?

As we mentioned before, we lost all the test cases for this problem, so we're actually going to give you the number of ways, and want you to produce a test case for which the number of ways is the given number. There could be many ways to achieve this (we guarantee there's always at least one), so you can print any, as long as it meets the constraints described below.

Input

Input will consist of a single integer A (1 ≤ A ≤ 105), the desired number of ways.

Output

In the first line print integers N and M (1 ≤ N ≤ 106, 1 ≤ M ≤ 10), the amount of change to be made, and the number of denominations, respectively.

Then print M integers D1, D2, ..., DM (1 ≤ Di ≤ 106), the denominations of the coins. All denominations must be distinct: for any i ≠ j we must have Di ≠ Dj.

If there are multiple tests, print any of them. You can print denominations in atbitrary order.

Examples

Input

18

Output

30 4
1 5 10 25

Input

3

Output

20 2
5 2

Input

314

Output

183 4
6 5 2 139

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  printf("%d 2\n1 2\n", n * 2 - 1);
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

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

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

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

Input

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

Output

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

Examples

Input

5
3 2 -1 2 11

Output

4

Input

5
2 1 1 1 1

Output

1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  long long res = 0;
  priority_queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (!q.empty() && q.top() > a[i]) {
      res += q.top() - a[i];
      q.pop();
      q.push(a[i]);
    }
    q.push(a[i]);
  }
  printf("%I64d\n", res);
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

Dr .: Peter, I've finally done it.
Peter: What's wrong, Dr. David? Is it a silly invention again?
Dr .: This table, this table.

| Character | Sign
--- | ---
(Blank) | 101
'| 000000
, | 000011
-| 10010001
. | 010001
? | 000001
A | 100101
B | 10011010
| Character | Sign
--- | ---
C | 0101
D | 0001
E | 110
F | 01001
G | 10011011
H | 010000
I | 0111
J | 10011000
| Character | Sign
--- | ---
K | 0110
L | 00100
M | 10011001
N | 10011110
O | 00101
P | 111
Q | 10011111
R | 1000
| Character | Sign
--- | ---
S | 00110
T | 00111
U | 10011100
V | 10011101
W | 000010
X | 10010010
Y | 10010011
Z | 10010000

Peter: What? This table is.
Dr .: Okay, just do what you say. First, write your name on a piece of paper.
Peter: Yes, "PETER POTTER".
Dr .: Then, replace each character with the "code" in this table.
Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying.

111 110 00111 110 1000 101 111 00101 00111 00111 110 1000

became. It looks like a barcode.
Dr .: All right. Then connect all the replaced strings and separate them by 5 characters.
Peter: Yes, if you connect and separate.

11111 00011 11101 00010 11110 01010 01110 01111 10100 0

It turned out to be something like this. But what about the last "0" guy?
Dr .: Add 0 to make it 5 letters.
Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it.

11111 00011 11101 00010 11110 01010 01110 01111 10100 00000

Dr .: Next, use this table.

| Sign | Character
--- | ---
00000 | A
00001 | B
00010 | C
00011 | D
00100 | E
00101 | F
00110 | G
00111 | H
| Sign | Character
--- | ---
01000 | I
01001 | J
01010 | K
01011 | L
01100 | M
01101 | N
01110 | O
01111 | P
| Sign | Character
--- | ---
10000 | Q
10001 | R
10010 | S
10011 | T
10100 | U
10101 | V
10110 | W
10111 | X
| Sign | Character
--- | ---
11000 | Y
11001 | Z
11010 | (blank)
11011 | ..
11100 |,
11101 |-
11110 |'
11111 |?

Peter: How do you use this ... yeah! Now you're going to replace the code with a letter!
Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D".
Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense.
Dr .: Count the number of characters.
Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced.
Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence.

PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS
PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S
THE PECK OF PICKLED PEPPERS PETER PIPER PICKED?

Peter: Gyogyo, the lines are separated, what do you do?
Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character.
Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ...
Dr .: Then why not let the program do it?

So, instead of Peter, create a program that converts the read character string into a code and outputs it.

input

Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters.

The number of datasets does not exceed 200.

output

For each data set, output the converted character string on one line.

Example

Input

PETER POTTER

Output

?D-C'KOPUA

### Response

```cpp
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;

int main(){
	string str;

	map<string,string> encode;
	map<string,string> decode;

	encode[" "] = "101";
	encode["'"] = "000000";
	encode[","] = "000011";
	encode["-"] = "10010001";
	encode["."] = "010001";

	encode["?"] = "000001";
	encode["A"] = "100101";
	encode["B"] = "10011010";
	encode["C"] = "0101";
	encode["D"] = "0001";
	encode["E"] = "110";
	encode["F"] = "01001";
	encode["G"] = "10011011";

	encode["H"] = "010000";
	encode["I"] = "0111";
    encode["J"] = "10011000";
	encode["K"] = "0110";
	encode["L"] = "00100";
	encode["M"] = "10011001";
	encode["N"] = "10011110";

	encode["O"] = "00101";
	encode["P"] = "111";
	encode["Q"] = "10011111";
	encode["R"] = "1000";
	encode["S"] = "00110";
	encode["T"] = "00111";
	encode["U"] = "10011100";

	encode["V"] = "10011101";
	encode["W"] = "000010";
	encode["X"] = "10010010";
	encode["Y"] = "10010011";
	encode["Z"] = "10010000";

	decode["00000"] = "A";
	decode["00001"] = "B";
	decode["00010"] = "C";
	decode["00011"] = "D";
	decode["00100"] = "E";
	decode["00101"] = "F";
	decode["00110"] = "G";

	decode["00111"] = "H";
	decode["01000"] = "I";
	decode["01001"] = "J";
	decode["01010"] = "K";
	decode["01011"] = "L";
	decode["01100"] = "M";
	decode["01101"] = "N";

	decode["01110"] = "O";
	decode["01111"] = "P";
	decode["10000"] = "Q";
	decode["10001"] = "R";
	decode["10010"] = "S";
	decode["10011"] = "T";
	decode["10100"] = "U";

	decode["10101"] = "V";
	decode["10110"] = "W";
	decode["10111"] = "X";
	decode["11000"] = "Y";
	decode["11001"] = "Z";

	decode["11010"] = " ";
	decode["11011"] = ".";
	decode["11100"] = ",";
	decode["11101"] = "-";
	decode["11110"] = "'";
	decode["11111"] = "?";

	while(getline(cin,str)){

		string enc="";
		for(int i=0;i<str.size();i++){
			enc+=encode[str.substr(i,1)];
		}

		enc+="0000";

		string dec="";
		for(int i=0;i+5<=enc.size();i+=5){
			dec+=decode[enc.substr(i,5)];
		}

		cout << dec << endl;
	}

}
```


### Prompt

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

There is a square painted on a piece of paper, the square's side equals n meters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corner of the square. Then John moves along the square's perimeter in the clockwise direction (first upwards, then to the right, then downwards, then to the left and so on). Every time he walks (n + 1) meters, he draws a cross (see picture for clarifications).

John Doe stops only when the lower left corner of the square has two crosses. How many crosses will John draw?

<image> The figure shows the order in which John draws crosses for a square with side 4. The lower left square has two crosses. Overall John paints 17 crosses.

Input

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

The second line contains t space-separated integers ni (1 ≤ ni ≤ 109) — the sides of the square for each test sample.

Output

For each test sample print on a single line the answer to it, that is, the number of crosses John will draw as he will move along the square of the corresponding size. Print the answers to the samples in the order in which the samples are given in the input.

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

Examples

Input

3
4 8 100

Output

17
33
401

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<long long> nn;
long long a;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int main() {
  long long num;
  cin >> num;
  while (num--) {
    long long step;
    cin >> a;
    step = a + 1;
    long long line;
    line = (4 * (step - 1));
    nn.push_back(((step * line) / gcd(step, line) / step) + 1);
  }
  for (long long i = 0; i < nn.size(); i++) cout << nn[i] << endl;
  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

One day, BThero decided to play around with arrays and came up with the following problem:

You are given an array a, which consists of n positive integers. The array is numerated 1 through n. You execute the following procedure exactly once:

  * You create a new array b which consists of 2n positive integers, where for each 1 ≤ i ≤ n the condition b_{2i-1}+b_{2i} = a_i holds. For example, for the array a = [6, 8, 2] you can create b = [2, 4, 4, 4, 1, 1].
  * You merge consecutive equal numbers in b. For example, b = [2, 4, 4, 4, 1, 1] becomes b = [2, 4, 1].

Find and print the minimum possible value of |b| (size of b) which can be achieved at the end of the procedure. It can be shown that under the given constraints there is at least one way to construct b.

Input

The first line of the input file contains a single integer T (1 ≤ T ≤ 5 ⋅ 10^5) denoting the number of test cases. The description of T test cases follows.

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

The second line contains n space-separated integers a_1, a_2, ..., a_n (2 ≤ a_i ≤ 10^9).

It is guaranteed that ∑{n} over all test cases does not exceed 5 ⋅ 10^5.

Output

For each test case, print a single line containing one integer — the minimum possible value of |b|.

Example

Input

3
3
6 8 2
1
4
3
5 6 6

Output

3
1
2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f;
template <typename _T>
_T Fabs(_T x) {
  return x < 0 ? -x : x;
}
template <typename _T>
void read(_T &x) {
  _T f = 1;
  x = 0;
  char s = getchar();
  while (s > '9' || s < '0') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while ('0' <= s && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
long long t, n, zero, two, a[500005];
set<pair<long long, long long> > one;
signed main() {
  read(t);
  while (t--) {
    read(n);
    long long shifter = 0, sign = 1;
    two = -1;
    for (long long i = 1; i <= n; i++) read(a[i]);
    for (long long i = 1; i <= n; i++) {
      long long x = a[i];
      if (two ^ -1) {
        zero += 2;
        one.clear();
        sign = 1;
        shifter = 0;
        if (x > two) one.insert(make_pair(x - two, x - two));
      } else if (!one.empty()) {
        if (sign > 0) {
          while (!one.empty() && shifter + one.rbegin()->first >= x)
            one.erase(*one.rbegin());
          if (!one.empty() && shifter + one.rbegin()->second >= x) {
            long long t = one.rbegin()->first;
            one.erase(*one.rbegin());
            one.insert(make_pair(t, x - shifter - 1));
          }
        } else {
          while (!one.empty() && shifter - one.begin()->second >= x)
            one.erase(*one.begin());
          if (!one.empty() && shifter - one.begin()->first >= x) {
            long long t = one.begin()->second;
            one.erase(*one.begin());
            one.insert(make_pair(shifter + 1 - x, t));
          }
        }
        zero++;
        sign *= -1;
        shifter = x - shifter;
      } else {
        shifter = x;
        sign = -1;
        if (i ^ 1) one.insert(make_pair(1, min(a[i - 1], x) - 1));
      }
      two = -1;
      if (x & 1) continue;
      long long c = x / 2, t = sign * (c - shifter);
      bool flag = 0;
      auto it = one.lower_bound(make_pair(t + 1, t + 1));
      if (it != one.begin()) {
        it--;
        if (it->first <= t && t <= it->second) {
          long long t1 = it->first, t2 = it->second;
          one.erase(it);
          if (t1 ^ t) one.insert(make_pair(t1, t - 1));
          if (t2 ^ t) one.insert(make_pair(t + 1, t2));
          two = c;
          flag = 1;
        }
      }
      if (!flag) one.insert(make_pair(t, t));
    }
    if (two != -1)
      printf("%d\n", 2 * n - zero - 2);
    else if (!one.empty())
      printf("%d\n", 2 * n - zero - 1);
    else
      printf("%d\n", 2 * n - zero);
    one.clear();
    zero = two = 0;
  }
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

You are a lover of bacteria. You want to raise some bacteria in a box.

Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly x bacteria in the box at some moment.

What is the minimum number of bacteria you need to put into the box across those days?

Input

The only line containing one integer x (1 ≤ x ≤ 109).

Output

The only line containing one integer: the answer.

Examples

Input

5

Output

2

Input

8

Output

1

Note

For the first sample, we can add one bacterium in the box in the first day morning and at the third morning there will be 4 bacteria in the box. Now we put one more resulting 5 in the box. We added 2 bacteria in the process so the answer is 2.

For the second sample, we can put one in the first morning and in the 4-th morning there will be 8 in the box. So the answer is 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, box = 0;
  cin >> n;
  n = n * 2;
  while (n /= 2) box = box + n % 2;
  cout << box << endl;
  return 0;
}

```


### Prompt

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

Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a1, a2, ..., an.

While Vasya was walking, his little brother Stepan played with Vasya's cubes and changed their order, so now the sequence of numbers written on the cubes became equal to b1, b2, ..., bn.

Stepan said that he swapped only cubes which where on the positions between l and r, inclusive, and did not remove or add any other cubes (i. e. he said that he reordered cubes between positions l and r, inclusive, in some way).

Your task is to determine if it is possible that Stepan said the truth, or it is guaranteed that Stepan deceived his brother.

Input

The first line contains three integers n, l, r (1 ≤ n ≤ 105, 1 ≤ l ≤ r ≤ n) — the number of Vasya's cubes and the positions told by Stepan.

The second line contains the sequence a1, a2, ..., an (1 ≤ ai ≤ n) — the sequence of integers written on cubes in the Vasya's order.

The third line contains the sequence b1, b2, ..., bn (1 ≤ bi ≤ n) — the sequence of integers written on cubes after Stepan rearranged their order.

It is guaranteed that Stepan did not remove or add other cubes, he only rearranged Vasya's cubes.

Output

Print "LIE" (without quotes) if it is guaranteed that Stepan deceived his brother. In the other case, print "TRUTH" (without quotes).

Examples

Input

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

Output

TRUTH

Input

3 1 2
1 2 3
3 1 2

Output

LIE

Input

4 2 4
1 1 1 1
1 1 1 1

Output

TRUTH

Note

In the first example there is a situation when Stepan said the truth. Initially the sequence of integers on the cubes was equal to [3, 4, 2, 3, 1]. Stepan could at first swap cubes on positions 2 and 3 (after that the sequence of integers on cubes became equal to [3, 2, 4, 3, 1]), and then swap cubes in positions 3 and 4 (after that the sequence of integers on cubes became equal to [3, 2, 3, 4, 1]).

In the second example it is not possible that Stepan said truth because he said that he swapped cubes only between positions 1 and 2, but we can see that it is guaranteed that he changed the position of the cube which was on the position 3 at first. So it is guaranteed that Stepan deceived his brother.

In the third example for any values l and r there is a situation when Stepan said the truth.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l, r;
  cin >> n >> l >> r;
  vector<int> a(n + 1);
  vector<int> b(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  sort(a.begin() + l, a.begin() + r + 1);
  sort(b.begin() + l, b.begin() + r + 1);
  bool f = true;
  for (int i = 1; i <= n; i++)
    if (a[i] != b[i]) f = false;
  if (f)
    cout << "TRUTH";
  else
    cout << "LIE";
}

```


### Prompt

Develop a solution in CPP to the problem described below:

At the children's festival, children were dancing in a circle. When music stopped playing, the children were still standing in a circle. Then Lena remembered, that her parents gave her a candy box with exactly k candies "Wilky May". Lena is not a greedy person, so she decided to present all her candies to her friends in the circle. Lena knows, that some of her friends have a sweet tooth and others do not. Sweet tooth takes out of the box two candies, if the box has at least two candies, and otherwise takes one. The rest of Lena's friends always take exactly one candy from the box.

Before starting to give candies, Lena step out of the circle, after that there were exactly n people remaining there. Lena numbered her friends in a clockwise order with positive integers starting with 1 in such a way that index 1 was assigned to her best friend Roma.

Initially, Lena gave the box to the friend with number l, after that each friend (starting from friend number l) took candies from the box and passed the box to the next friend in clockwise order. The process ended with the friend number r taking the last candy (or two, who knows) and the empty box. Please note that it is possible that some of Lena's friends took candy from the box several times, that is, the box could have gone several full circles before becoming empty.

Lena does not know which of her friends have a sweet tooth, but she is interested in the maximum possible number of friends that can have a sweet tooth. If the situation could not happen, and Lena have been proved wrong in her observations, please tell her about this.

Input

The only line contains four integers n, l, r and k (1 ≤ n, k ≤ 10^{11}, 1 ≤ l, r ≤ n) — the number of children in the circle, the number of friend, who was given a box with candies, the number of friend, who has taken last candy and the initial number of candies in the box respectively.

Output

Print exactly one integer — the maximum possible number of sweet tooth among the friends of Lena or "-1" (quotes for clarity), if Lena is wrong.

Examples

Input

4 1 4 12

Output

2

Input

5 3 4 10

Output

3

Input

10 5 5 1

Output

10

Input

5 4 5 6

Output

-1

Note

In the first example, any two friends can be sweet tooths, this way each person will receive the box with candies twice and the last person to take sweets will be the fourth friend.

In the second example, sweet tooths can be any three friends, except for the friend on the third position.

In the third example, only one friend will take candy, but he can still be a sweet tooth, but just not being able to take two candies. All other friends in the circle can be sweet tooths as well, they just will not be able to take a candy even once.

In the fourth example, Lena is wrong and this situation couldn't happen.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
T gi() {
  T x = 0;
  bool f = 0;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') f = 1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f ? -x : x;
}
long long n, l, r, k, len;
namespace cpp1 {
bool check(long long x) {
  long long tmp = k % (x + n), x1 = tmp - len;
  if (x1 < 0) return 0;
  if (x1 < min(x, len)) x1++;
  if (x1 <= min(x, len) && x - x1 <= n - len) return 1;
  return 0;
}
void main() {
  for (int i = n; i >= 0; i--)
    if (check(i)) {
      printf("%d\n", i);
      return;
    }
  puts("-1");
  return;
}
}  // namespace cpp1
namespace cpp2 {
void main() {
  len = (r - l + n) % n + 1;
  long long ans = -1;
  for (long long i = 0; i <= k / n; i++) {
    long long p = (k - 2 * len - (i - 1) * n + 1) / (i + 1);
    long long y = k - i * (n + p) - len;
    if (y < 0) {
      if (i == 0) continue;
      long long dis = (-y - 1) / i + 1;
      y += i * dis;
      p -= dis;
    }
    if (p > n) {
      y += (p - n) * i;
    }
    if (y < 0 || y > p || y > len || len - (y + 1) > n - p) continue;
    long long y2 = y + 1;
    if (y2 <= p && y2 <= len) {
      ans = max(ans, p);
    }
    if (len - y <= n - p) {
      ans = max(ans, p);
    }
  }
  printf("%lld\n", ans);
}
}  // namespace cpp2
int main() {
  n = gi<long long>(), l = gi<long long>(), r = gi<long long>(),
  k = gi<long long>();
  len = (r - l + 1) % n;
  if (len < 0) len += n;
  if (n <= 2e6)
    cpp1 ::main();
  else
    cpp2 ::main();
  return 0;
}

```


### Prompt

Generate a CPP solution to the following problem:

For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.

* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $S$ (0 or 1).
* delete($x$): Delete $x$ from $S$.

Constraints

* $1 \leq q \leq 200,000$
* $0 \leq x \leq 1,000,000,000$

Input

The input is given in the following format.

$q$
$query_1$
$query_2$
:
$query_q$

Each query $query_i$ is given by

0 $x$

or

1 $x$

or

2 $x$

where the first digits 0, 1 and 2 represent insert, find and delete operations respectively.

Output

For each insert operation, print the number of elements in $S$.
For each find operation, print the number of specified elements in $S$.

Example

Input

8
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 2

Output

1
2
3
1
0
1
3

### Response

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;
typedef pair<int, int> P;

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  set<int> a;
  int q;
  cin >> q;
  vector<int> ans;
  rep(i,q) {
    int command; cin >> command;
    if (command == 0) {
      int x; cin >> x;
      a.insert(x);
      ans.push_back(a.size());
    } else if (command == 1) {
      int x; cin >> x;
      ans.push_back(a.find(x) != a.end());
    } else if (command == 2) {
      int x; cin >> x;
      a.erase(x);
    }
  }

  for (auto a : ans) cout << a << endl;

  return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.

Your task is to choose at most ⌊n/2⌋ vertices in this graph so each unchosen vertex is adjacent (in other words, connected by an edge) to at least one of chosen vertices.

It is guaranteed that the answer exists. If there are multiple answers, you can print any.

You will be given multiple independent queries to answer.

Input

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

Then t queries follow.

The first line of each query contains two integers n and m (2 ≤ n ≤ 2 ⋅ 10^5, n - 1 ≤ m ≤ min(2 ⋅ 10^5, (n(n-1))/(2))) — the number of vertices and the number of edges, respectively.

The following m lines denote edges: edge i is represented by a pair of integers v_i, u_i (1 ≤ v_i, u_i ≤ n, u_i ≠ v_i), which are the indices of vertices connected by the edge.

There are no self-loops or multiple edges in the given graph, i. e. for each pair (v_i, u_i) there are no other pairs (v_i, u_i) or (u_i, v_i) in the list of edges, and for each pair (v_i, u_i) the condition v_i ≠ u_i is satisfied. It is guaranteed that the given graph is connected.

It is guaranteed that ∑ m ≤ 2 ⋅ 10^5 over all queries.

Output

For each query print two lines.

In the first line print k (1 ≤ ⌊n/2⌋) — the number of chosen vertices.

In the second line print k distinct integers c_1, c_2, ..., c_k in any order, where c_i is the index of the i-th chosen vertex.

It is guaranteed that the answer exists. If there are multiple answers, you can print any.

Example

Input

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

Output

2
1 3
3
4 3 6

Note

In the first query any vertex or any pair of vertices will suffice.

<image>

Note that you don't have to minimize the number of chosen vertices. In the second query two vertices can be enough (vertices 2 and 4) but three is also ok.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MN = 2e5 + 2, MOD = 1e9 + 7, LOG = 15;
int depth[MN];
vector<int> adj[MN];
void dfs(int cur) {
  for (int i : adj[cur])
    if (!depth[i]) {
      depth[i] = depth[cur] + 1;
      dfs(i);
    }
}
void solve() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) depth[i] = 0, adj[i].clear();
  while (m--) {
    int a, b;
    scanf("%d %d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  depth[1] = 1;
  dfs(1);
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (depth[i] & 1) ++cnt;
  if (cnt <= n / 2) {
    printf("%d\n", cnt);
    for (int i = 1; i <= n; i++)
      if (depth[i] & 1) printf("%d ", i);
    printf("\n");
  } else {
    printf("%d\n", n - cnt);
    for (int i = 1; i <= n; i++)
      if (!(depth[i] & 1)) printf("%d ", i);
    printf("\n");
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}

```


### Prompt

Generate a Cpp solution to the following problem:

We have a string S consisting of lowercase English letters.

If the length of S is at most K, print S without change.

If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result.

Constraints

* K is an integer between 1 and 100 (inclusive).
* S is a string consisting of lowercase English letters.
* The length of S is between 1 and 100 (inclusive).

Input

Input is given from Standard Input in the following format:

K
S

Output

Print a string as stated in Problem Statement.

Examples

Input

7
nikoandsolstice

Output

nikoand...

Input

40
ferelibenterhominesidquodvoluntcredunt

Output

ferelibenterhominesidquodvoluntcredunt

### Response

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

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

if(S.size()>K){
    cout<<S.substr(0,K)<<"..."<<endl;
}else{
    cout<<S<<endl;
}
}
```


### Prompt

Construct a cpp code solution to the problem outlined:

Programmers working on a large project have just received a task to write exactly m lines of code. There are n programmers working on a project, the i-th of them makes exactly ai bugs in every line of code that he writes.

Let's call a sequence of non-negative integers v1, v2, ..., vn a plan, if v1 + v2 + ... + vn = m. The programmers follow the plan like that: in the beginning the first programmer writes the first v1 lines of the given task, then the second programmer writes v2 more lines of the given task, and so on. In the end, the last programmer writes the remaining lines of the code. Let's call a plan good, if all the written lines of the task contain at most b bugs in total.

Your task is to determine how many distinct good plans are there. As the number of plans can be large, print the remainder of this number modulo given positive integer mod.

Input

The first line contains four integers n, m, b, mod (1 ≤ n, m ≤ 500, 0 ≤ b ≤ 500; 1 ≤ mod ≤ 109 + 7) — the number of programmers, the number of lines of code in the task, the maximum total number of bugs respectively and the modulo you should use when printing the answer.

The next line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 500) — the number of bugs per line for each programmer.

Output

Print a single integer — the answer to the problem modulo mod.

Examples

Input

3 3 3 100
1 1 1

Output

10

Input

3 6 5 1000000007
1 2 3

Output

0

Input

3 5 6 11
1 2 1

Output

0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long dp[501][501];
  long b, a[500], n, m, mod, ans = 0;
  scanf("%ld %ld %ld %ld", &n, &m, &b, &mod);
  for (int i = 0; i <= 500; i++) {
    for (int j = 0; j <= 500; j++) {
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
    for (int ld = 0; ld < m; ld++) {
      for (int bugs = 0; bugs + a[i] <= b; bugs++) {
        dp[ld + 1][bugs + a[i]] =
            (dp[ld + 1][bugs + a[i]] + dp[ld][bugs]) % mod;
      }
    }
  }
  for (int i = 0; i <= b; i++) {
    ans = (ans + dp[m][i]) % mod;
  }
  cout << ans << endl;
  return 0;
}

```


### Prompt

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

In 1862, the lord of Aizu was ordered to serve as a guardian of Kyoto. The Kyoto Shugoshoku is an important role to protect Kyoto at the end of the Edo period when security has deteriorated. You have to patrol the city by sharing it with the shogunate and other clan. However, when it came time to decide the sharing route, the following order was received from a stubborn old man who is famous among his vassals.

<image>

It was a big deal. Even the lord cannot ignore the statement of this vassal. Depending on the selection of the sharing route, it will be "the samurai's face is not noticeable".

So, please make a program to judge whether the above three conditions are met by inputting the information of the start point, the goal point, and the intersection, and give it to the lord.

The start point is represented by 1, the goal point is represented by 2, and other intersections are represented by integers of 3 or more. A road is represented by a set of intersection numbers that the roads connect to. The number of intersections shall be 100 or less, and there shall be one or more routes from all intersections to the start point and goal point.

input

Given multiple datasets. Each dataset is given in the following format:

a1 b1
a2 b2
:
:
0 0

The two integers in each row indicate that there is a road connecting intersection ai and intersection bi. When both ai and bi are 0, it indicates the end of inputting intersection information.

The number of datasets does not exceed 50.

output

For each data set, if the samurai's face stands out (if the three conditions are met), OK, otherwise (if the three conditions are not met), output NG on one line.

Example

Input

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

Output

OK
NG

### Response

```cpp
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

int main() {
  int c[101] =  { 0 };
  int a, b;
  while (cin >> a >> b) {
    if (a + b == 0) {
      int t = 0;
      for (int i = 3; i < 101; i++) {
        t += c[i] % 2;
      }
      if (t == 0 && c[1] % 2 && c[2] % 2) {
        cout << "OK" << endl;
      } else {
        cout << "NG" << endl;
      }

      memset(c, 0, sizeof(c));

    } else {
      c[a]++;
      c[b]++;
    }

  }

  return 0;
}
```


### Prompt

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

problem

You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of who and who are your friends. Based on this list, create a program that asks for the number of students you will invite to your Christmas party.

input

The input consists of multiple datasets. Each dataset is given in the following format.

The first line of the dataset contains the number of students in the school n (2 ≤ n ≤ 500), and the second line contains the length of the list m (1 ≤ m ≤ 10000). The input consists of 2 + m lines in total. Line 2 + i (1 ≤ i ≤ m) contains two integers ai and bi (1 ≤ ai <bi ≤ n) separated by blanks, and the students with numbers ai and bi are friends. Represents that. From the 3rd line to the 2 + m line, the lines representing the same friendship do not appear twice.

When both n and m are 0, it indicates the end of input. The number of data sets does not exceed 5.

output

For each dataset, print the number of students you invite to the Christmas party on one line.

Examples

Input

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

Output

3
0

Input

None

Output

None

### Response

```cpp
#include <iostream>
#include <cstring>
using namespace std;
int table[501][501],f[500];
int main(){
	int n,m,a,b,c,d,e,i,j,k;
	bool flag;
	while(cin >> n && n){
		c = 0;
		flag = true;
		cin >> m;
		memset(table,0,sizeof(table));
		memset(f,0,sizeof(f));
		for(i = 0;i < m;i++){
			cin >> a >> b;
			table[b][a] = 1;
			table[a][b] = 1;
		}
		for(i = 1;i <= n;i++){
			if(table[1][i] == 1){
				f[c] = i;
				c++;
			}
		}
		if(c > 0){
			d = c;
			for(i = 0;i < d;i++){
				for(j = 2;j <= n;j++){
					if(table[f[i]][j] == 1){
						for(k = 0;k < c;k++){
							if(j == f[k]){
								flag = false;
							}
						}
						if(flag){
							f[c] = j;
							c++;
						}
						flag = true;
					}
				}
			}
		}
		cout << c << endl;
	}

}
```


### Prompt

Please create a solution in CPP 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;
vector<int> g[200005];
map<int, int> h;
int comp[200005], cnt[200005], xr[200005];
void dfs(int v, int cmp) {
  comp[v] = cmp;
  cnt[cmp] = (cnt[cmp] & xr[v]);
  for (auto u : g[v]) {
    if (comp[u] == -1) dfs(u, cmp);
  }
}
int main() {
  int n, a, b, p[200005], i, j;
  cin >> n >> a >> b;
  for (i = 1; i <= n; i++) {
    cin >> p[i];
    h[p[i]] = i;
  }
  memset(xr, 0, sizeof xr);
  for (i = 1; i <= n; i++) {
    if (h.count(a - p[i])) {
      g[h[p[i]]].push_back(h[a - p[i]]);
      g[h[a - p[i]]].push_back(h[p[i]]);
      xr[i] |= 1;
    }
    if (h.count(b - p[i])) {
      g[h[p[i]]].push_back(h[b - p[i]]);
      g[h[b - p[i]]].push_back(h[p[i]]);
      xr[i] |= 2;
    }
  }
  memset(comp, -1, sizeof comp);
  int c = 0;
  for (i = 1; i <= n; i++) {
    if (comp[i] == -1) {
      cnt[c] = 3;
      dfs(i, c);
      if (cnt[c] == 0) break;
      c++;
    }
  }
  if (i <= n)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (i = 1; i <= n; i++) {
      cout << (cnt[comp[i]] == 2) << ' ';
    }
  }
  return 0;
}

```


### Prompt

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

A tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them.

Limak is a little polar bear. He lives in a tree that consists of n vertices, numbered 1 through n.

Limak recently learned how to jump. He can jump from a vertex to any vertex within distance at most k.

For a pair of vertices (s, t) we define f(s, t) as the minimum number of jumps Limak needs to get from s to t. Your task is to find the sum of f(s, t) over all pairs of vertices (s, t) such that s < t.

Input

The first line of the input contains two integers n and k (2 ≤ n ≤ 200 000, 1 ≤ k ≤ 5) — the number of vertices in the tree and the maximum allowed jump distance respectively.

The next n - 1 lines describe edges in the tree. The i-th of those lines contains two integers ai and bi (1 ≤ ai, bi ≤ n) — the indices on vertices connected with i-th edge.

It's guaranteed that the given edges form a tree.

Output

Print one integer, denoting the sum of f(s, t) over all pairs of vertices (s, t) such that s < t.

Examples

Input

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

Output

20

Input

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

Output

114

Input

3 5
2 1
3 1

Output

3

Note

In the first sample, the given tree has 6 vertices and it's displayed on the drawing below. Limak can jump to any vertex within distance at most 2. For example, from the vertex 5 he can jump to any of vertices: 1, 2 and 4 (well, he can also jump to the vertex 5 itself).

<image>

There are <image> pairs of vertices (s, t) such that s < t. For 5 of those pairs Limak would need two jumps: (1, 6), (3, 4), (3, 5), (3, 6), (5, 6). For other 10 pairs one jump is enough. So, the answer is 5·2 + 10·1 = 20.

In the third sample, Limak can jump between every two vertices directly. There are 3 pairs of vertices (s < t), so the answer is 3·1 = 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
struct Edge {
  int u, v, next;
} e[MAXN * 2];
int head[MAXN], tot;
void init() {
  memset(head, -1, sizeof(head));
  tot = 0;
}
void add_edge(int u, int v) {
  e[tot].u = u, e[tot].v = v, e[tot].next = head[u];
  head[u] = tot++;
}
int n, k;
long long int dp[MAXN][6], size[MAXN];
long long int ans = 0, tmp = 0;
void dfs(int u, int fa) {
  size[u] = 1;
  for (int i = head[u]; i != -1; i = e[i].next) {
    int v = e[i].v;
    if (v == fa) continue;
    dfs(v, u);
    ans += size[v] * (n - size[v]);
    size[u] += size[v];
    for (int j = 0; j < k; j++) {
      for (int l = 0; l < k; l++) {
        long long int ta = dp[u][j];
        long long int tb = dp[v][l];
        if (l == 0) tb++;
        tmp += ((k - (j + l + 1) % k) % k) * ta * tb;
      }
    }
    for (int j = 0; j < k; j++) dp[u][j] += dp[v][(j - 1 + k) % k];
    dp[u][1]++;
  }
  for (int i = 1; i < k; i++) tmp += (k - i) * dp[u][i];
  return;
}
int main() {
  scanf("%d%d", &n, &k);
  init();
  int u, v;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    add_edge(u, v);
    add_edge(v, u);
  }
  memset(size, 0, sizeof(size));
  dfs(1, 1);
  if (k == 1) {
    printf("%I64d\n", ans);
    return 0;
  }
  printf("%I64d\n", (ans + tmp) / k);
  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Consider a square grid with h rows and w columns with some dominoes on it. Each domino covers exactly two cells of the grid that share a common side. Every cell is covered by at most one domino.

Let's call a placement of dominoes on the grid perfectly balanced if no row and no column contains a pair of cells covered by two different dominoes. In other words, every row and column may contain no covered cells, one covered cell, or two covered cells that belong to the same domino.

You are given a perfectly balanced placement of dominoes on a grid. Find the number of ways to place zero or more extra dominoes on this grid to keep the placement perfectly balanced. Output this number modulo 998 244 353.

Input

The first line contains three integers h, w, and n (1 ≤ h, w ≤ 3600; 0 ≤ n ≤ 2400), denoting the dimensions of the grid and the number of already placed dominoes. The rows are numbered from 1 to h, and the columns are numbered from 1 to w.

Each of the next n lines contains four integers r_{i, 1}, c_{i, 1}, r_{i, 2}, c_{i, 2} (1 ≤ r_{i, 1} ≤ r_{i, 2} ≤ h; 1 ≤ c_{i, 1} ≤ c_{i, 2} ≤ w), denoting the row id and the column id of the cells covered by the i-th domino. Cells (r_{i, 1}, c_{i, 1}) and (r_{i, 2}, c_{i, 2}) are distinct and share a common side.

The given domino placement is perfectly balanced.

Output

Output the number of ways to place zero or more extra dominoes on the grid to keep the placement perfectly balanced, modulo 998 244 353.

Examples

Input

5 7 2
3 1 3 2
4 4 4 5

Output

8

Input

5 4 2
1 2 2 2
4 3 4 4

Output

1

Input

23 42 0

Output

102848351

Note

In the first example, the initial grid looks like this:

<image>

Here are 8 ways to place zero or more extra dominoes to keep the placement perfectly balanced:

<image>

In the second example, the initial grid looks like this:

<image>

No extra dominoes can be placed here.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r) { return l + rng() % (r - l + 1); }
const int N = 4010, M = 998244353;
int H[N], G[N];
int r[N], c[N];
int f[N][N], g[N][N];
void add(int &a, int b) {
  a += b;
  if (a >= M) a -= M;
}
int mul(int a, int b) { return (long long)a * b % M; }
int pw(int a, int i) {
  int b = 1;
  for (; i; i >>= 1, a = mul(a, a))
    if (i & 1) b = mul(b, a);
  return b;
}
int P(int n, int k) {
  if (n < k) return 0;
  return mul(G[n], H[n - k]);
}
int main() {
  for (int i = 0, _c = 4000; i <= _c; ++i) G[i] = i ? mul(G[i - 1], i) : 1;
  for (int i = 4000, _c = 0; i >= _c; --i)
    H[i] = i < 4000 ? mul(H[i + 1], i + 1) : pw(G[i], M - 2);
  int m = ({
    int x = 0;
    int c = getchar(), n = 0;
    for (; !isdigit(c); c = getchar()) n = (c == '-');
    for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
    n ? -x : x;
  }),
      n = ({
        int x = 0;
        int c = getchar(), n = 0;
        for (; !isdigit(c); c = getchar()) n = (c == '-');
        for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
        n ? -x : x;
      }),
      k = ({
        int x = 0;
        int c = getchar(), n = 0;
        for (; !isdigit(c); c = getchar()) n = (c == '-');
        for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
        n ? -x : x;
      });
  for (int i = 1, _c = k; i <= _c; ++i) {
    int x = ({
      int x = 0;
      int c = getchar(), n = 0;
      for (; !isdigit(c); c = getchar()) n = (c == '-');
      for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
      n ? -x : x;
    }),
        y = ({
          int x = 0;
          int c = getchar(), n = 0;
          for (; !isdigit(c); c = getchar()) n = (c == '-');
          for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
          n ? -x : x;
        }),
        u = ({
          int x = 0;
          int c = getchar(), n = 0;
          for (; !isdigit(c); c = getchar()) n = (c == '-');
          for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
          n ? -x : x;
        }),
        v = ({
          int x = 0;
          int c = getchar(), n = 0;
          for (; !isdigit(c); c = getchar()) n = (c == '-');
          for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
          n ? -x : x;
        });
    for (int j = min(x, u), _c = max(x, u); j <= _c; ++j) r[j] = 1;
    for (int j = min(y, v), _c = max(y, v); j <= _c; ++j) c[j] = 1;
  }
  int R = 0, C = 0;
  for (int i = 1, _c = m; i <= _c; ++i) R += !r[i];
  for (int i = 1, _c = n; i <= _c; ++i) C += !c[i];
  f[0][0] = g[0][0] = 1;
  for (int i = 1, _c = m; i <= _c; ++i) {
    for (int j = 0, _c = m; j <= _c; ++j) {
      add(f[i][j], f[i - 1][j]);
      if (i > 1 && j && r[i] + r[i - 1] == 0) add(f[i][j], f[i - 2][j - 1]);
    }
  }
  for (int i = 1, _c = n; i <= _c; ++i) {
    for (int j = 0, _c = n; j <= _c; ++j) {
      add(g[i][j], g[i - 1][j]);
      if (i > 1 && j && c[i] + c[i - 1] == 0) add(g[i][j], g[i - 2][j - 1]);
    }
  }
  int ret = 0;
  for (int i = 0, _c = R; i <= _c; ++i) {
    for (int j = 0, _c = C; j <= _c; ++j) {
      add(ret,
          mul(mul(f[m][i], P(C - j * 2, i)), mul(g[n][j], P(R - i * 2, j))));
    }
  }
  cout << ret;
}

```


### Prompt

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

You have a simple and connected undirected graph consisting of n nodes and m edges.

Consider any way to pair some subset of these n nodes such that no node is present in more than one pair.

This pairing is valid if for every pair of pairs, the induced subgraph containing all 4 nodes, two from each pair, has at most 2 edges (out of the 6 possible edges). More formally, for any two pairs, (a,b) and (c,d), the induced subgraph with nodes \\{a,b,c,d\} should have at most 2 edges.

Please note that the subgraph induced by a set of nodes contains nodes only from this set and edges which have both of its end points in this set.

Now, do one of the following:

  * Find a simple path consisting of at least ⌈ n/2 ⌉ nodes. Here, a path is called simple if it does not visit any node multiple times.
  * Find a valid pairing in which at least ⌈ n/2 ⌉ nodes are paired.

It can be shown that it is possible to find at least one of the two in every graph satisfying constraints from the statement.

Input

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

The first line of each test case contains 2 integers n, m (2 ≤ n ≤ 5⋅ 10^5, 1 ≤ m ≤ 10^6), denoting the number of nodes and edges, respectively.

The next m lines each contain 2 integers u and v (1 ≤ u, v ≤ n, u ≠ v), denoting that there is an undirected edge between nodes u and v in the given graph.

It is guaranteed that the given graph is connected, and simple — it does not contain multiple edges between the same pair of nodes, nor does it have any self-loops.

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

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

Output

For each test case, the output format is as follows.

If you have found a pairing, in the first line output "PAIRING" (without quotes).

  * Then, output k (⌈ n/2 ⌉ ≤ 2⋅ k ≤ n), the number of pairs in your pairing.
  * Then, in each of the next k lines, output 2 integers a and b — denoting that a and b are paired with each other. Note that the graph does not have to have an edge between a and b!
  * This pairing has to be valid, and every node has to be a part of at most 1 pair.

Otherwise, in the first line output "PATH" (without quotes).

  * Then, output k (⌈ n/2 ⌉ ≤ k ≤ n), the number of nodes in your path.
  * Then, in the second line, output k integers, v_1, v_2, …, v_k, in the order in which they appear on the path. Formally, v_i and v_{i+1} should have an edge between them for every i (1 ≤ i < k).
  * This path has to be simple, meaning no node should appear more than once.

Example

Input

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

Output

PATH
4
1 5 3 6
PAIRING
2
1 6
2 4
PAIRING
3
1 8
2 5
4 10
PAIRING
4
1 7
2 9
3 11
4 5

Note

The path outputted in the first case is the following.

<image>

The pairing outputted in the second case is the following.

<image>

Here is an invalid pairing for the same graph — the subgraph \{1,3,4,5\} has 3 edges.

<image>

Here is the pairing outputted in the third case.

<image>

It's valid because —

  * The subgraph \{1,8,2,5\} has edges (1,2) and (1,5).
  * The subgraph \{1,8,4,10\} has edges (1,4) and (4,10).
  * The subgraph \{4,10,2,5\} has edges (2,4) and (4,10).

Here is the pairing outputted in the fourth case.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m;
struct Node {
  vector<int> adjs;
  int depth = -1;
  int prev = 0;
} nodes[500005];
int mdepth = 0, mdepth_idx = -1;
void dfs(int idx) {
  for (int v : nodes[idx].adjs) {
    if (nodes[v].depth != -1) continue;
    nodes[v].depth = nodes[idx].depth + 1;
    if (mdepth < nodes[v].depth) {
      mdepth = nodes[v].depth;
      mdepth_idx = v;
    }
    nodes[v].prev = idx;
    dfs(v);
  }
}
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    nodes[i].adjs.clear();
    nodes[i].depth = -1;
    nodes[i].prev = 0;
  }
  mdepth = 0;
  mdepth_idx = -1;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    nodes[u].adjs.push_back(v);
    nodes[v].adjs.push_back(u);
  }
  nodes[1].depth = 0;
  dfs(1);
  if (mdepth >= (n + 1) / 2) {
    int cur = mdepth_idx;
    vector<int> path;
    while (cur) {
      path.push_back(cur);
      cur = nodes[cur].prev;
    }
    cout << "PATH" << '\n';
    cout << path.size() << '\n';
    for (int v : path) {
      cout << v << " ";
    }
    cout << '\n';
  } else {
    cout << "PAIRING" << '\n';
    vector<vector<int>> lev(mdepth + 1);
    for (int i = 1; i <= n; ++i) {
      lev[nodes[i].depth].push_back(i);
    }
    vector<pair<int, int>> pairs;
    for (int i = 1; i < lev.size(); ++i) {
      for (int j = 0; j + 1 < lev[i].size(); j += 2) {
        pairs.emplace_back(lev[i][j], lev[i][j + 1]);
      }
    }
    cout << pairs.size() << '\n';
    for (int i = 0; i < pairs.size(); ++i) {
      cout << pairs[i].first << " " << pairs[i].second << '\n';
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) solve();
}

```


### Prompt

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

In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short.
The name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.

Given a string S of length N and an integer k (k \geq 3), he defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy the following conditions:

* 0 \leq a < b < c \leq N - 1
* S[a] = `D`
* S[b] = `M`
* S[c] = `C`
* c-a < k

Here S[a] is the a-th character of the string S. Indexing is zero-based, that is, 0 \leq a \leq N - 1 holds.

For a string S and Q integers k_0, k_1, ..., k_{Q-1}, calculate the k_i-DMC number of S for each i (0 \leq i \leq Q-1).

Constraints

* 3 \leq N \leq 10^6
* S consists of uppercase English letters
* 1 \leq Q \leq 75
* 3 \leq k_i \leq N
* All numbers given in input are integers

Input

Input is given from Standard Input in the following format:

N
S
Q
k_{0} k_{1} ... k_{Q-1}

Output

Print Q lines. The i-th line should contain the k_i-DMC number of the string S.

Examples

Input

18
DWANGOMEDIACLUSTER
1
18

Output

1

Input

18
DDDDDDMMMMMCCCCCCC
1
18

Output

210

Input

54
DIALUPWIDEAREANETWORKGAMINGOPERATIONCORPORATIONLIMITED
3
20 30 40

Output

0
1
2

Input

30
DMCDMCDMCDMCDMCDMCDMCDMCDMCDMC
4
5 10 15 20

Output

10
52
110
140

### Response

```cpp
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(void) {
	long long n, q;
	string s;
	cin >> n >> s >> q;
	vector<long long> v(q), m(n), c(n), mc(n);
	REP(i, q) cin >> v[i];
	m[0] = s[0] == 'M' ? 1 : 0;
	c[0] = s[0] == 'C' ? 1 : 0;
	mc[0] = 0;
	FOR(i, 1, n) {
		m[i] = s[i] == 'M' ? m[i - 1] + 1 : m[i - 1];
		c[i] = s[i] == 'C' ? c[i - 1] + 1 : c[i - 1];
		mc[i] = s[i] == 'C' ? mc[i - 1] + m[i - 1] : mc[i - 1];
	}
	for(long long k: v){
		long long res = 0;
		REP(i, n) {
			if (s[i] == 'D') {
				int j = min(i + k - 1, n - 1);
				res += mc[j] - mc[i];
				res -= m[i] * (c[j] - c[i]);
			}
		}
		cout << res << endl;
	}
	return 0;
}
```


### Prompt

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

Many countries have such a New Year or Christmas tradition as writing a letter to Santa including a wish list for presents. Vasya is an ordinary programmer boy. Like all ordinary boys, he is going to write the letter to Santa on the New Year Eve (we Russians actually expect Santa for the New Year, not for Christmas).

Vasya has come up with an algorithm he will follow while writing a letter. First he chooses two strings, s1 anf s2, consisting of uppercase English letters. Then the boy makes string sk, using a recurrent equation sn = sn - 2 + sn - 1, operation '+' means a concatenation (that is, the sequential record) of strings in the given order. Then Vasya writes down string sk on a piece of paper, puts it in the envelope and sends in to Santa.

Vasya is absolutely sure that Santa will bring him the best present if the resulting string sk has exactly x occurrences of substring AC (the short-cut reminds him оf accepted problems). Besides, Vasya decided that string s1 should have length n, and string s2 should have length m. Vasya hasn't decided anything else.

At the moment Vasya's got urgent New Year business, so he asks you to choose two strings for him, s1 and s2 in the required manner. Help Vasya.

Input

The first line contains four integers k, x, n, m (3 ≤ k ≤ 50; 0 ≤ x ≤ 109; 1 ≤ n, m ≤ 100).

Output

In the first line print string s1, consisting of n uppercase English letters. In the second line print string s2, consisting of m uppercase English letters. If there are multiple valid strings, print any of them.

If the required pair of strings doesn't exist, print "Happy new year!" without the quotes.

Examples

Input

3 2 2 2

Output

AC
AC

Input

3 3 2 2

Output

Happy new year!

Input

3 0 2 2

Output

AA
AA

Input

4 3 2 1

Output

Happy new year!

Input

4 2 2 1

Output

Happy new year!

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000 + 5;
const int MOD = 1000 * 1000 * 1000 + 7;
const long double EPS = 1e-9;
int k, n, m;
long long x;
vector<long long> a, b, c;
string ansA, ansB;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> k >> x >> n >> m;
  ansA.resize(n, 'X');
  ansB.resize(m, 'X');
  a.resize(k);
  b.resize(k);
  c.resize(k);
  for (int i = 0; 2 * i <= n; ++i)
    for (int ix = 0; ix < 2; ++ix)
      for (int iy = 0; iy < 2; ++iy)
        for (int j = 0; 2 * j <= m; ++j)
          for (int jx = 0; jx < 2; ++jx)
            for (int jy = 0; jy < 2; ++jy) {
              if ((2 * i == n && (ix || iy)) || (2 * j == m && (jx || jy)))
                continue;
              if ((2 * i + 1 == n && (ix && iy)) ||
                  (2 * j + 1 == m && (jx && jy)))
                continue;
              a[0] = i, a[1] = j;
              b[0] = ix, b[1] = jx;
              c[0] = iy, c[1] = jy;
              bool overflow = false;
              for (int t = 2; t < k && !overflow; ++t) {
                a[t] = a[t - 2] + a[t - 1] + (b[t - 2] && c[t - 1]);
                b[t] = b[t - 1];
                c[t] = c[t - 2];
                if (a[t] > x) overflow = true;
              }
              if (overflow) continue;
              if (a[k - 1] == x) {
                int iu = 0;
                if (ix) ansA[n - 1] = 'A';
                if (iy) ansA[iu++] = 'C';
                for (int t = 0; t < i; ++t) ansA[iu++] = 'A', ansA[iu++] = 'C';
                int ju = 0;
                if (jx) ansB[m - 1] = 'A';
                if (jy) ansB[ju++] = 'C';
                for (int t = 0; t < j; ++t) ansB[ju++] = 'A', ansB[ju++] = 'C';
                cout << ansA << "\n" << ansB << "\n";
                return 0;
              }
            }
  cout << "Happy new year!"
       << "\n";
  return 0;
}

```


### Prompt

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

There are n + 1 cities, numbered from 0 to n. n roads connect these cities, the i-th road connects cities i - 1 and i (i ∈ [1, n]).

Each road has a direction. The directions are given by a string of n characters such that each character is either L or R. If the i-th character is L, it means that the i-th road initially goes from the city i to the city i - 1; otherwise it goes from the city i - 1 to the city i.

A traveler would like to visit as many cities of this country as possible. Initially, they will choose some city to start their journey from. Each day, the traveler must go from the city where they currently are to a neighboring city using one of the roads, and they can go along a road only if it is directed in the same direction they are going; i. e., if a road is directed from city i to the city i + 1, it is possible to travel from i to i + 1, but not from i + 1 to i. After the traveler moves to a neighboring city, all roads change their directions to the opposite ones. If the traveler cannot go from their current city to a neighboring city, their journey ends; it is also possible to end the journey whenever the traveler wants to.

The goal of the traveler is to visit as many different cities as possible (they can visit a city multiple times, but only the first visit is counted). For each city i, calculate the maximum number of different cities the traveler can visit during exactly one journey if they start in the city i.

Input

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

Each test case consists of two lines. The first line contains one integer n (1 ≤ n ≤ 3 ⋅ 10^5). The second line contains the string s consisting of exactly n characters, each character is either L or R.

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

Output

For each test case, print n + 1 integers. The i-th integer should be equal to the maximum number of different cities the traveler can visit during one journey if this journey starts in the i-th city.

Example

Input

2
6
LRRRLL
3
LRL

Output

1 3 2 3 1 3 2
1 4 1 4

### Response

```cpp
/// HDM
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
#define ld long double
#define time cout << "\nTime: " << clock()/(double) 1000 << "s "
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define inp freopen(duckman".inp", "r", stdin);
#define out freopen(duckman".out", "w", stdout);
const ll oo = 4557430888798830399;

#define duckman "Journey"

const ll nmax = 3e5 + 5, mod = 1000000007;
using namespace std;

ll n, L[nmax], R[nmax];
string s;
void Solve() {
    cin >> n;
    cin >> s;
    s = ' ' + s + ' ';
    ++n;
    for (ll i = 0; i <= n + 1; ++i) {
        L[i] = R[i] = 0;
    }
    for (ll i = 2; i <= n; ++i) {
        if (s[i - 1] != s[i - 2]) {
            L[i] = L[i - 1] + 1;
        }
        else {
            L[i] = 1;
        }
    }
    for (ll i = n - 1; i >= 1; --i) {
        if (s[i] != s[i + 1]) {
            R[i] = R[i + 1] + 1;
        }
        else {
            R[i] = 1;
        }
    }
    for (ll i = 1; i <= n; ++i) {
        ll ans = 1;
        if (s[i - 1] == 'L') {
            ans += L[i];
        }
        if (s[i] == 'R') {
            ans += R[i];
        }
        cout << ans << " ";
    }
    cout << endl;
}

int main() {
    fast;

    ll t;
    cin >> t;
    for (ll i = 1; i <= t; ++i) {
        Solve();
    }

}
/*

*/

```