### Prompt

Generate a CPP solution to the following problem:

You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight different pokemons: Vaporeon, Jolteon, Flareon, Espeon, Umbreon, Leafeon, Glaceon, and Sylveon.

You know the length of the word in the crossword, and you already know some letters. Designers of the crossword made sure that the answer is unambiguous, so you can assume that exactly one pokemon out of the 8 that Eevee evolves into fits the length and the letters given. Your task is to find it.

Input

First line contains an integer n (6 ≤ n ≤ 8) – the length of the string.

Next line contains a string consisting of n characters, each of which is either a lower case english letter (indicating a known letter) or a dot character (indicating an empty cell in the crossword).

Output

Print a name of the pokemon that Eevee can evolve into that matches the pattern in the input. Use lower case letters only to print the name (in particular, do not capitalize the first letter).

Examples

Input

7
j......

Output

jolteon

Input

7
...feon

Output

leafeon

Input

7
.l.r.o.

Output

flareon

Note

Here's a set of names in a form you can paste into your solution:

["vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"]

{"vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"}

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
char name[10][10] = {"vaporeon", "jolteon", "flareon", "espeon",
                     "umbreon",  "leafeon", "glaceon", "sylveon"};
int main() {
  int n;
  scanf("%d", &n);
  char ans[10];
  scanf("%s", ans);
  int len = strlen(ans);
  for (int i = 0; i < 8; i++) {
    if (strlen(name[i]) != len)
      continue;
    else {
      int flag = 1;
      for (int j = 0; j < len; j++) {
        if (ans[j] != '.') {
          if (ans[j] != name[i][j]) {
            flag = 0;
            break;
          }
        }
      }
      if (flag == 1) printf("%s\n", name[i]);
    }
  }
  return 0;
}

```


### Prompt

Develop a solution in CPP to the problem described below:

AtCoDeer the deer has N square tiles. The tiles are numbered 1 through N, and the number given to each tile is written on one side of the tile. Also, each corner of each tile is painted in one of the 1000 colors, which are represented by the integers 0 between 999. The top-left, top-right, bottom-right and bottom-left corner of the tile with the number i are painted in color C_{i,0}, C_{i,1}, C_{i,2} and C_{i,3}, respectively, when seen in the direction of the number written on the tile (See Figure 1).

<image>

Figure 1: The correspondence between the colors of a tile and the input

AtCoDeer is constructing a cube using six of these tiles, under the following conditions:

* For each tile, the side with the number must face outward.
* For each vertex of the cube, the three corners of the tiles that forms it must all be painted in the same color.

Help him by finding the number of the different cubes that can be constructed under the conditions. Since each tile has a number written on it, two cubes are considered different if the set of the used tiles are different, or the tiles are used in different directions, even if the formation of the colors are the same. (Each tile can be used in one of the four directions, obtained by 90° rotations.) Two cubes are considered the same only if rotating one in the three dimensional space can obtain an exact copy of the other, including the directions of the tiles.

<image>

Figure 2: The four directions of a tile

Constraints

* 6≦N≦400
* 0≦C_{i,j}≦999 (1≦i≦N , 0≦j≦3)

Input

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

N
C_{1,0} C_{1,1} C_{1,2} C_{1,3}
C_{2,0} C_{2,1} C_{2,2} C_{2,3}
:
C_{N,0} C_{N,1} C_{N,2} C_{N,3}

Output

Print the number of the different cubes that can be constructed under the conditions.

Examples

Input

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

Output

1

Input

8
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1

Output

144

Input

6
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0

Output

122880

### Response

```cpp
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<utility>
#include<cassert>
#include<set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

const int MAXN = 444;
map<vi, int> me;
vi C[MAXN];
ll co[MAXN][MAXN];

vi minV(vi v) {
    vi ret = v;
    for (int i = 0; i < 4; i++) {
        rotate(v.begin(), v.begin()+1, v.end());
        ret = min(ret, v);
    }
    return ret;
}

ll calc(vi a) {
    if (a[0] == a[1] && a[1] == a[2] && a[2] == a[3]) return 4;
    if (a[0] == a[2] && a[1] == a[3]) return 2;
    return 1;
}

ll powI(ll a, int p) {
    if (a == 0) return 0;
    if (p == 0) return 1;
    if (p == 1) return a;
    if (p%2) return a*powI(a, p-1);
    ll tmp = powI(a, p/2);
    return tmp*tmp;
}

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

    // co[i][j] = i*(i-1)*...*(i-j+1)
    for (int i = 0; i < MAXN; i++) {
        co[i][0] = 1;
        for (int j = 0; j < 8; j++) co[i][j+1] = co[i][j]*(i-j);
    }
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        vi v(4, 0);
        for (int j = 0; j < 4; j++) cin >> v[j];
        C[i] = minV(v);
        me[C[i]]++;
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) for (int j = i+1; j < N; j++) {
        me[C[i]]--; me[C[j]]--;
        vi a = C[i], b = C[j];
        swap(b[0], b[2]);
        for (int k = 0; k < 4; k++) {
            map<vi, int> m;
            for (int l = 0; l < 4; l++) {
                vi v;
                v.push_back(a[l]);
                v.push_back(a[(l+3)%4]);
                v.push_back(b[(l+3)%4]);
                v.push_back(b[l]);
                m[minV(v)]++;
            }
            ll t = 1;
            auto it = m.begin();
            while (it != m.end()) {
                t *= co[me[it->first]][it->second];
                t *= powI(calc(it->first), it->second);
                ++it;
            }
            ans += t;
            rotate(b.begin(), b.begin()+1, b.end());
        }
        me[C[i]]++;
        me[C[j]]++;
    }
    ans /= 3;
    cout << ans << endl;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

An English booklet has been created for publicizing Aizu to the world. When you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says "Hoshino" not "Hoshina".

Your task is to write a program which replace all the words "Hoshino" with "Hoshina". You can assume that the number of characters in a text is less than or equal to 1000.

Input

The input consists of several datasets. There will be the number of datasets n in the first line. There will be n lines. A line consisting of english texts will be given for each dataset.

Output

For each dataset, print the converted texts in a line.

Example

Input

3
Hoshino
Hashino
Masayuki Hoshino was the grandson of Ieyasu Tokugawa.

Output

Hoshina
Hashino
Masayuki Hoshina was the grandson of Ieyasu Tokugawa.

### Response

```cpp
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    int n;
    char c;
    string s;

    cin >> n;
    cin.ignore();

    for (int i=0; i<n; i++) {
        getline(cin, s);
        while(s.find("Hoshino") != -1) {
            s.replace(s.find("Hoshino")+6, 1, "a");
        }
        cout << s << endl;
    }

    return 0;
}
```


### Prompt

Please formulate a CPP solution to the following problem:

You've got a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. Your task is to find the sum of lengths of all 12 edges of this parallelepiped.

Input

The first and the single line contains three space-separated integers — the areas of the parallelepiped's faces. The area's values are positive ( > 0) and do not exceed 104. It is guaranteed that there exists at least one parallelepiped that satisfies the problem statement.

Output

Print a single number — the sum of all edges of the parallelepiped.

Examples

Input

1 1 1

Output

12

Input

4 6 6

Output

28

Note

In the first sample the parallelepiped has sizes 1 × 1 × 1, in the second one — 2 × 2 × 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, z, c, d, V;
  scanf("%d %d %d", &x, &y, &z);
  c = sqrt((x * z) / y);
  d = c * c;
  V = (4 * (x + z + d)) / c;
  printf("%d", V);
  return 0;
}

```


### Prompt

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

Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.

The teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to consecutively connect them by semi-circus in a certain order: first connect the first point with the second one, then connect the second point with the third one, then the third one with the fourth one and so on to the n-th point. Two points with coordinates (x1, 0) and (x2, 0) should be connected by a semi-circle that passes above the abscissa axis with the diameter that coincides with the segment between points. Seryozha needs to find out if the line on the picture intersects itself. For clarifications, see the picture Seryozha showed to Dima (the left picture has self-intersections, the right picture doesn't have any).

<image>

Seryozha is not a small boy, so the coordinates of the points can be rather large. Help Dima cope with the problem.

Input

The first line contains a single integer n (1 ≤ n ≤ 103). The second line contains n distinct integers x1, x2, ..., xn ( - 106 ≤ xi ≤ 106) — the i-th point has coordinates (xi, 0). The points are not necessarily sorted by their x coordinate.

Output

In the single line print "yes" (without the quotes), if the line has self-intersections. Otherwise, print "no" (without the quotes).

Examples

Input

4
0 10 5 15

Output

yes

Input

4
0 15 5 10

Output

no

Note

The first test from the statement is on the picture to the left, the second test is on the picture to the right.

### Response

```cpp
#include <bits/stdc++.h>
struct data {
  int a, b;
};
int main() {
  int n;
  int in[1000 + 100];
  struct data p[1000 + 100];
  while (scanf("%d", &n) != EOF) {
    int i;
    for (i = 0; i < n; i++) scanf("%d", &in[i]);
    for (i = 0; i < n - 1; i++) {
      p[i].a = in[i];
      p[i].b = in[i + 1];
    }
    for (i = 0; i < n - 1; i++) {
      if (p[i].a > p[i].b) {
        p[i].a += p[i].b;
        p[i].b = p[i].a - p[i].b;
        p[i].a = p[i].a - p[i].b;
      }
    }
    int j;
    int flag = 1;
    for (i = 0; i < n - 1; i++) {
      for (j = i + 1; j < n - 1; j++) {
        if (p[i].a < p[j].a && p[i].b > p[j].a && p[i].b < p[j].b) {
          flag = 0;
          break;
        } else if (p[i].a > p[j].a && p[i].a < p[j].b && p[i].b > p[j].b) {
          flag = 0;
          break;
        }
      }
      if (flag == 0) break;
    }
    if (flag == 0)
      printf("yes\n");
    else
      printf("no\n");
  }
  return 0;
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Almost Identical Programs

The programming contest named Concours de Programmation Comtemporaine Interuniversitaire (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program.

Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such close submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions.

Input

The input consists of at most 100 datasets, each in the following format.

s1
s2

Each of s1 and s2 is a string written in a line, with the length between 1 and 200, inclusive. They are the first and the second submitted programs respectively. A program consists of lowercase letters (`a`, `b`, ..., `z`), uppercase letters (`A`, `B`, ..., `Z`), digits (`0`, `1`, ..., `9`), double quotes (`"`), and semicolons (`;`). When double quotes occur in a program, there are always even number of them.

The end of the input is indicated by a line containing one '`.`' (period).

Output

For each dataset, print the judge result in a line.

If the given two programs are identical, print `IDENTICAL`. If two programs differ with only one corresponding string literal, print `CLOSE`. Otherwise, print `DIFFERENT`. A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.

Sample Input

print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.

Output for the Sample Input

IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT

Example

Input

print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.

Output

IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT

### Response

```cpp
#include <iostream>
#include <string>
using namespace std;
int n,m,l;
string s1, s2;
void input() {
	cin >> s1;
	if (s1 == ".")return;
	cin >> s2;
}
void output() {
	cout << endl;
}
void prep() {
	n = s1.length();
	m = s2.length();
	s1 = s1 + "$";
	s2 = s2 + "$";
}
void solve() {
	int i = 0;
	int j = 0;
	int h = 1;
	int cnt = 0;
	while (i+j<m+n-1) {
		h = 1 - h;
		string c1 = "";
		string c2 = "";
		while (i < n) {
			c1=c1+s1[i];
			if (s1[i] == '"')break;
			i++;
		}
		i++;
		while (j < m) {
			c2=c2+s2[j];
			if (s2[j] == '"')break;
			j++;
		}
		j++;
		if (c1!=c2) {
			if (h == 0) {
				cout << "DIFFERENT";
				return;
			}
			cnt++ ;
			if (cnt == 2) {
				cout << "DIFFERENT";
				return;
			}
		}
	}
	if (cnt == 0)cout << "IDENTICAL"; else cout << "CLOSE";
}
int main() {
	while (true) {
		input();
		if (s1 == ".")break;
		prep();
		solve();
		output();
	}
}

```


### Prompt

Please create a solution in Cpp to the following problem:

Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as follows:

<image>

In the above formula, 1 ≤ l < r ≤ n must hold, where n is the size of the Main Uzhlyandian Array a, and |x| means absolute value of x. But the heroes skipped their math lessons in school, so they asked you for help. Help them calculate the maximum value of f among all possible values of l and r for the given array a.

Input

The first line contains single integer n (2 ≤ n ≤ 105) — the size of the array a.

The second line contains n integers a1, a2, ..., an (-109 ≤ ai ≤ 109) — the array elements.

Output

Print the only integer — the maximum value of f.

Examples

Input

5
1 4 2 3 1

Output

3

Input

4
1 5 4 7

Output

6

Note

In the first sample case, the optimal value of f is reached on intervals [1, 2] and [2, 5].

In the second case maximal value of f is reachable only on the whole array.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int a[100005], dp[100005][2], dpsol[100005];
void init() {
  memset(dp, -1, sizeof(dp));
  memset(dpsol, -1, sizeof(dpsol));
  return;
}
void maxm(long long int st, long long int en) {
  for (long long int i = en; i >= st; i--) {
    if (i == en) {
      dp[i][0] = dp[i][1] = 0;
    } else if (i == en - 1) {
      dp[i][0] = dp[i][1] = abs(a[i] - a[i + 1]);
    } else {
      long long int tmp = abs(a[i] - a[i + 1]);
      dp[i][0] = max(tmp, max(tmp - dp[i + 1][0], tmp - dp[i + 1][1]));
      dp[i][1] = min(tmp, min(tmp - dp[i + 1][0], tmp - dp[i + 1][1]));
    }
  }
  return;
}
void sol(long long int st, long long int en) {
  for (long long int i = en; i >= st; i--) {
    if (i == en) {
      dpsol[i] = 0;
    } else if (i == en - 1) {
      dpsol[i] = abs(a[i] - a[i + 1]);
    } else {
      dpsol[i] = max(dpsol[i + 1], max(dp[i][0], dp[i][1]));
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  init();
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  maxm(0, n - 1);
  sol(0, n - 1);
  cout << dpsol[0] << endl;
  return 0;
}

```


### Prompt

Construct a Cpp code solution to the problem outlined:

There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet — the memory manager is among them. According to the developers' plan, in the first release the memory manager will be very simple and rectilinear. It will support three operations:

  * alloc n — to allocate n bytes of the memory and return the allocated block's identifier x;
  * erase x — to erase the block with the identifier x;
  * defragment — to defragment the free memory, bringing all the blocks as close to the beginning of the memory as possible and preserving their respective order;

The memory model in this case is very simple. It is a sequence of m bytes, numbered for convenience from the first to the m-th.

The first operation alloc n takes as the only parameter the size of the memory block that is to be allocated. While processing this operation, a free block of n successive bytes is being allocated in the memory. If the amount of such blocks is more than one, the block closest to the beginning of the memory (i.e. to the first byte) is prefered. All these bytes are marked as not free, and the memory manager returns a 32-bit integer numerical token that is the identifier of this block. If it is impossible to allocate a free block of this size, the function returns NULL.

The second operation erase x takes as its parameter the identifier of some block. This operation frees the system memory, marking the bytes of this block as free for further use. In the case when this identifier does not point to the previously allocated block, which has not been erased yet, the function returns ILLEGAL_ERASE_ARGUMENT.

The last operation defragment does not have any arguments and simply brings the occupied memory sections closer to the beginning of the memory without changing their respective order.

In the current implementation you are to use successive integers, starting with 1, as identifiers. Each successful alloc operation procession should return following number. Unsuccessful alloc operations do not affect numeration.

You are to write the implementation of the memory manager. You should output the returned value for each alloc command. You should also output ILLEGAL_ERASE_ARGUMENT for all the failed erase commands.

Input

The first line of the input data contains two positive integers t and m (1 ≤ t ≤ 100;1 ≤ m ≤ 100), where t — the amount of operations given to the memory manager for processing, and m — the available memory size in bytes. Then there follow t lines where the operations themselves are given. The first operation is alloc n (1 ≤ n ≤ 100), where n is an integer. The second one is erase x, where x is an arbitrary 32-bit integer numerical token. The third operation is defragment.

Output

Output the sequence of lines. Each line should contain either the result of alloc operation procession , or ILLEGAL_ERASE_ARGUMENT as a result of failed erase operation procession. Output lines should go in the same order in which the operations are processed. Successful procession of alloc operation should return integers, starting with 1, as the identifiers of the allocated blocks.

Examples

Input

6 10
alloc 5
alloc 3
erase 1
alloc 6
defragment
alloc 6

Output

1
2
NULL
3

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const long long LIM = 1e18;
const int INF = 0x3f3f3f3f;
const double eps = 1e-4;
const double PI = atan(1.0) * 4;
const int mod = 1e9 + 7;
int t, m, x, tot;
int mem[105], tmp[105];
char s[33];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> t >> m;
  while (t--) {
    cin >> s;
    if (s[0] == 'd') {
      memset(tmp, 0, sizeof(tmp));
      int p = 0;
      for (int i = 1; i <= m; i++)
        if (mem[i]) tmp[++p] = mem[i];
      memcpy(mem, tmp, sizeof(tmp));
    } else if (s[0] == 'a') {
      cin >> x;
      int con = 0, f = 0;
      for (int i = 1; i <= m; i++)
        if (mem[i])
          con = 0;
        else {
          con++;
          if (con == x) {
            ++tot;
            f = 1;
            for (; x; i--, x--) mem[i] = tot;
            break;
          }
        }
      if (f)
        cout << tot << "\n";
      else
        cout << "NULL\n";
    } else {
      cin >> x;
      int f = 0;
      for (int i = 1; i <= m; i++)
        if (mem[i] == x) {
          mem[i] = 0;
          f = 1;
        }
      if (!f || x <= 0) cout << "ILLEGAL_ERASE_ARGUMENT\n";
    }
  }
  return 0;
}

```


### Prompt

Please create a solution in CPP to the following problem:

You are given a set of strings S. Each string consists of lowercase Latin letters.

For each string in this set, you want to calculate the minimum number of seconds required to type this string. To type a string, you have to start with an empty string and transform it into the string you want to type using the following actions:

  * if the current string is t, choose some lowercase Latin letter c and append it to the back of t, so the current string becomes t + c. This action takes 1 second;
  * use autocompletion. When you try to autocomplete the current string t, a list of all strings s ∈ S such that t is a prefix of s is shown to you. This list includes t itself, if t is a string from S, and the strings are ordered lexicographically. You can transform t into the i-th string from this list in i seconds. Note that you may choose any string from this list you want, it is not necessarily the string you are trying to type.

What is the minimum number of seconds that you have to spend to type each string from S?

Note that the strings from S are given in an unusual way.

Input

The first line contains one integer n (1 ≤ n ≤ 10^6).

Then n lines follow, the i-th line contains one integer p_i (0 ≤ p_i < i) and one lowercase Latin character c_i. These lines form some set of strings such that S is its subset as follows: there are n + 1 strings, numbered from 0 to n; the 0-th string is an empty string, and the i-th string (i ≥ 1) is the result of appending the character c_i to the string p_i. It is guaranteed that all these strings are distinct.

The next line contains one integer k (1 ≤ k ≤ n) — the number of strings in S.

The last line contains k integers a_1, a_2, ..., a_k (1 ≤ a_i ≤ n, all a_i are pairwise distinct) denoting the indices of the strings generated by above-mentioned process that form the set S — formally, if we denote the i-th generated string as s_i, then S = {s_{a_1}, s_{a_2}, ..., s_{a_k}}.

Output

Print k integers, the i-th of them should be equal to the minimum number of seconds required to type the string s_{a_i}.

Examples

Input

10
0 i
1 q
2 g
0 k
1 e
5 r
4 m
5 h
3 p
3 e
5
8 9 1 10 6

Output

2 4 1 3 3

Input

8
0 a
1 b
2 a
2 b
4 a
4 b
5 c
6 d
5
2 3 4 7 8

Output

1 2 2 4 4

Note

In the first example, S consists of the following strings: ieh, iqgp, i, iqge, ier.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, dfn[1000100], num, dp[1000100], cnt[1000100], mk[1000100], m, a[1000100];
char s[3], ch[1000100];
vector<int> edge[1000100];
multiset<int> S;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x * f;
}
bool cmp(int i, int j) { return ch[i] < ch[j]; }
void dfs1(int u) {
  dfn[u] = ++num;
  cnt[num] = mk[u];
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i];
    dfs1(v);
  }
}
void dfs(int u, int fa = -1) {
  if (fa != -1) {
    dp[u] = dp[fa] + 1;
  } else {
    dp[u] = 0;
  }
  if (mk[u]) dp[u] = min(dp[u], *S.begin() + cnt[dfn[u]]);
  int tp = dp[u] - cnt[dfn[u] - 1];
  S.insert(tp);
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i];
    dfs(v, u);
  }
  S.erase(S.find(tp));
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    int fa = read();
    scanf("%s", s + 1);
    edge[fa].push_back(i);
    ch[i] = s[1];
  }
  for (int i = 0; i <= n; i++) {
    sort(edge[i].begin(), edge[i].end(), cmp);
  }
  m = read();
  for (int i = 1; i <= m; i++) {
    a[i] = read();
    mk[a[i]] = 1;
  }
  dfs1(0);
  for (int i = 1; i <= n + 1; i++) {
    cnt[i] += cnt[i - 1];
  }
  dfs(0);
  for (int i = 1; i <= m; i++) {
    printf("%d ", dp[a[i]]);
  }
  return 0;
}

```


### Prompt

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

We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.
Determine if he is correct.

Constraints

* c_{i, j} \ (1 \leq i \leq 3, 1 \leq j \leq 3) is an integer between 0 and 100 (inclusive).

Input

Input is given from Standard Input in the following format:

c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3}

Output

If Takahashi's statement is correct, print `Yes`; otherwise, print `No`.

Examples

Input

1 0 1
2 1 2
1 0 1

Output

Yes

Input

2 2 2
2 1 2
2 2 2

Output

No

Input

0 8 8
0 8 8
0 8 8

Output

Yes

Input

1 8 6
2 9 7
0 7 7

Output

No

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    vector<vector<int>> c(3, vector<int>(3));
    REP(i, 3) REP(j, 3) cin >> c[i][j];
    bool flag = true;
    REP(i, 2) REP(j, 2) {
        if(c[i][j + 1] - c[i][j] != c[i + 1][j + 1] - c[i + 1][j]) flag = false;
    }
    cout << (flag ? "Yes" : "No") << endl;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

Two positive integers a and b have a sum of s and a bitwise XOR of x. How many possible values are there for the ordered pair (a, b)?

Input

The first line of the input contains two integers s and x (2 ≤ s ≤ 1012, 0 ≤ x ≤ 1012), the sum and bitwise xor of the pair of positive integers, respectively.

Output

Print a single integer, the number of solutions to the given conditions. If no solutions exist, print 0.

Examples

Input

9 5

Output

4

Input

3 3

Output

2

Input

5 2

Output

0

Note

In the first sample, we have the following solutions: (2, 7), (3, 6), (6, 3), (7, 2).

In the second sample, the only solutions are (1, 2) and (2, 1).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long f[3000][2];
long long a, b, A[3000], B[3000];
long long dp(int x, int c) {
  if (x > 300) return c == 0;
  if (f[x][c] != -1) return f[x][c];
  long long &ret = f[x][c];
  ret = 0;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      if ((i ^ j) == B[x]) {
        if ((i + j + c) % 2 != A[x]) continue;
        ret += dp(x + 1, (i + j + c) / 2);
      }
  return ret;
}
int main() {
  cin >> a >> b;
  memset(f, -1, sizeof(f));
  int k = (a == b) * 2;
  for (int i = 0; i < 300; i++) {
    A[i] = a % 2;
    a /= 2;
  }
  for (int i = 0; i < 300; i++) {
    B[i] = b % 2;
    b /= 2;
  }
  cout << dp(0, 0) - k;
  return 0;
}

```


### Prompt

Create a solution in Cpp for the following problem:

Yae joins a journey plan, in which parties will be held several times during the itinerary. She wants to participate in all of them and will carry several dresses with her. But the number of dresses she can carry with her may be smaller than that of the party opportunities. In that case, she has to wear some of her dresses more than once.

Fashion-conscious Yae wants to avoid that. At least, she wants to reduce the maximum number of times she has to wear the same dress as far as possible.

Given the number of dresses and frequency of parties, make a program to determine how she can reduce the maximum frequency of wearing the most reused dress.

Input

The input is given in the following format.

$A$ $B$

The input line provides the number of dresses $A$ ($1 \leq A \leq 10^5$) and frequency of parties $B$ ($1 \leq B \leq 10^5$).

Output

Output the frequency she has to wear the most reused dress.

Examples

Input

3 5

Output

2

Input

25 10

Output

1

### Response

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

int main(){
    int a,b,n=0;
    cin>>a>>b;

    if(a>=b)cout<<"1"<<endl;
    else{
        while(1){
            if(a*n>=b)break;
            n++;
        }
        cout<<n<<endl;
    }
    return 0;
}

```


### Prompt

Please formulate a CPP solution to the following problem:

()

Problem Statement

There is a string S. Initially, S is an empty string.
Perform the following processing in order of n.

* Add x_i p_i (=" (" or") ") to the end of S.

After processing, determine if S is a well-balanced string.

"The string is balanced" is defined as follows.

* The empty string is well-balanced.
* For balanced strings a and b, a + b (+ represents a concatenation of strings) is balanced.
* For a balanced string a, "(" + a + ")" is balanced.

Constraints

* 1 ≤ n ≤ 1,000
* 1 ≤ x_i ≤ 10 ^ 6
* p_i is "(" or ")"

Input

Input follows the following format. All given numbers are integers.

n
p_1 x_1
.. ..
p_n x_n

Output

Output "YES" if balanced, otherwise output "NO" on one line.

Examples

Input

3
( 5
) 4
) 1

Output

YES

Input

5
( 2
) 2
( 3
) 1
) 2

Output

YES

Input

2
) 1
( 1

Output

NO

### Response

```cpp
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int n; cin >> n;

	bool flag = true;
	int cnt = 0;
	rep(i, n) {
		char p; int x;
		cin >> p >> x;

		if (p == '(')cnt += x;
		else cnt -= x;

		if (cnt < 0)flag = false;
	}
	if (cnt != 0)flag = false;
	puts(flag ? "YES" : "NO");
}

```


### Prompt

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

Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.

Write a program which computes the amount of the debt in n weeks.

Input

An integer n (0 ≤ n ≤ 100) is given in a line.

Output

Print the amout of the debt in a line.

Example

Input

5

Output

130000

### Response

```cpp
#include<iostream>
using namespace std;
int main() {
double n=100000;
int i,b;
cin>>b;
for(i=0;i<b;i++){
n*=1.05;
n=(int)(n+999)/1000*1000;
}
cout<<(int)n<<endl;
  return 0;
}
```


### Prompt

Develop a solution in cpp to the problem described below:

We have N dice arranged in a line from left to right. The i-th die from the left shows p_i numbers from 1 to p_i with equal probability when thrown.

We will choose K adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.

Constraints

* 1 ≤ K ≤ N ≤ 200000
* 1 ≤ p_i ≤ 1000
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
p_1 ... p_N

Output

Print the maximum possible value of the expected value of the sum of the numbers shown.

Your output will be considered correct when its absolute or relative error from our answer is at most 10^{-6}.

Examples

Input

5 3
1 2 2 4 5

Output

7.000000000000

Input

4 1
6 6 6 6

Output

3.500000000000

Input

10 4
17 13 13 12 15 20 10 13 17 11

Output

32.000000000000

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;cin>>n>>k;
    double p;
    vector<double> ruiseki(n+1,0);
    for(int i=0;i<n;i++){
        cin>>p;
        ruiseki[i+1]=ruiseki[i]+p*(p+1)/(2*p);
    }
    double ans=0;
    for(int i=k;i<n+1;i++){
        ans=max(ans,ruiseki[i]-ruiseki[i-k]);
    }
    printf("%.10f\n",ans);
}

```


### Prompt

Please formulate a CPP solution to the following problem:

There are N integers written on a blackboard. The i-th integer is A_i.

Takahashi will repeatedly perform the following operation on these numbers:

* Select a pair of integers, A_i and A_j, that have the same parity (that is, both are even or both are odd) and erase them.
* Then, write a new integer on the blackboard that is equal to the sum of those integers, A_i+A_j.

Determine whether it is possible to have only one integer on the blackboard.

Constraints

* 2 ≦ N ≦ 10^5
* 1 ≦ A_i ≦ 10^9
* A_i is an integer.

Input

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

N
A_1 A_2 … A_N

Output

If it is possible to have only one integer on the blackboard, print `YES`. Otherwise, print `NO`.

Examples

Input

3
1 2 3

Output

YES

Input

5
1 2 3 4 5

Output

NO

### Response

```cpp
#include<iostream>
using namespace std;
int main()
{
	int n,a,c=0;cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		if(a%2)c++;
	}
	cout<<(c%2?"NO":"YES")<<endl;
}

```


### Prompt

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

There are n cities in Berland. The city numbered 1 is the capital. Some pairs of cities are connected by a one-way road of length 1.

Before the trip, Polycarp for each city found out the value of d_i — the shortest distance from the capital (the 1-st city) to the i-th city.

Polycarp begins his journey in the city with number s and, being in the i-th city, chooses one of the following actions:

  1. Travel from the i-th city to the j-th city if there is a road from the i-th city to the j-th and d_i < d_j;
  2. Travel from the i-th city to the j-th city if there is a road from the i-th city to the j-th and d_i ≥ d_j;
  3. Stop traveling.

Since the government of Berland does not want all people to come to the capital, so Polycarp no more than once can take the second action from the list. in other words, he can perform the second action 0 or 1 time during his journey. Polycarp, on the other hand, wants to be as close to the capital as possible.

<image>

For example, if n = 6 and the cities are connected, as in the picture above, then Polycarp could have made the following travels (not all possible options):

  * 2 → 5 → 1 → 2 → 5;
  * 3 → 6 → 2;
  * 1 → 3 → 6 → 2 → 5.

Polycarp wants for each starting city i to find out how close he can get to the capital. More formally: he wants to find the minimal value of d_j that Polycarp can get from the city i to the city j according to the rules described above.

Input

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

Each test case is preceded by an empty line.

The first line of each test case contains two integers n (2 ≤ n ≤ 2 ⋅ 10^5) and m (1 ≤ m ≤ 2 ⋅ 10^5) — number of cities and roads, respectively.

This is followed by m lines describing the roads. Each road is characterized by two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the numbers of cities connected by a one-way road.

It is guaranteed that the sums of n and m over all test cases do not exceed 2 ⋅ 10^5.

It is guaranteed that for each pair of different cities (u, v) there is at most one road from u to v (but a pair of roads from u to v and from v to u — is valid).

It is guaranteed that there is a path from the capital to all cities.

Output

For each test case, on a separate line output n numbers, the i-th of which is equal to the minimum possible distance from the capital to the city where Polycarp ended his journey.

Example

Input

3

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

2 2
1 2
2 1

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

Output

0 0 1 2 0 1
0 0
0 0 2 1 1 0

### Response

```cpp
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <random>
#include <cstring>
using namespace std;

//#pragma comment(linker, "/stack:36777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void boostIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
}

bool isPrime(int x) {
	if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
	for (int i = 5; i * i <= x; i += 6) if (x % i == 0 || x % (i + 2) == 0) return 0; return 1;
}

typedef long long int ll;
typedef long double ld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

#define fori(n) for(int i = 0; i < (n); ++i)
#define forj(n) for(int j = 0; j < (n); ++j)
#define fork(n) for(int k = 0; k < (n); ++k)
#define forx(n) for(int x = 0; x < (n); ++x)

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ff first
#define ss second
#define debug(x) cerr << #x << " = " << x << endl;
#define debug_p(x) cerr << #x << " " << x.ff << " " << x.ss << endl;
#define debug_v(x) cerr << #x << " "; for (auto ii : x) cout << i << " "; cout << endl;
#define debug_vp(x) cerr << #x << " "; for (auto ii : x) cout << '[' << ii.ff << " " << ii.ss << ']'; cout << endl;
#define mp make_pair
#define rand kjsdflsdfsdlsjdlkfsdjflsjdfl

#define Return cerr<<endl<<"RUNTIME: "<<1.0*clock()/CLOCKS_PER_SEC << " s" <<endl; return 0;

#define PI 3.14159265

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

template<typename T> inline T getint() {
	T val = 0;
	char c;

	bool neg = false;
	while ((c = getchar()) && !(c >= '0' && c <= '9')) {
		neg |= c == '-';
	}

	do {
		val = (val * 10) + c - '0';
	} while ((c = getchar()) && (c >= '0' && c <= '9'));

	return val * (neg ? -1 : 1);
}

/////////////////////
//#define int long long
int Mod = 1e9 + 7;
#define endl '\n'
/////////////////////

int inf = 2e9 + 7;

void dfs(int node, vector<vector<int>>& adj, vector<int>& Ans, vector<int> &Dist, vector<int> & Seen) {
	if (Seen[node]) return;
	Seen[node] = 1;
	for (auto &x : adj[node]) {
		dfs(x, adj, Ans, Dist, Seen);
		Ans[node] = min(Ans[node], Dist[x]);
		Ans[node] = min(Ans[node], Ans[x]);
	}
}
int32_t main() {
	boostIO();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int T; cin >> T;
	while (T--) {
		int n, m; cin >> n >> m;
		vector<pair<int, int>> A(m);
		vector<vector<int>> adj(n+1);
		vector<vector<int>> ADJ(3 * n);
		fori(m) {
			cin >> A[i].ff >> A[i].ss;
			adj[A[i].ff].push_back(A[i].ss);
		}

		vector<int> Dist(3 * n, inf);

		Dist[1] = 0;
		queue<int> q;
		q.push(1);

		while (q.size() != 0) {
			int node = q.front();
			q.pop();

			for (auto x : adj[node]) {
				if (Dist[x] > Dist[node] + 1) {
					Dist[x] = Dist[node] + 1;
					q.push(x);
				}
			}
		}

		for (int i = 1; i <= n; ++i) {
			Dist[i + n] = Dist[i];
		}

		for (int node = 1; node <= n; ++node) {
			for (auto x : adj[node]) {
				if (Dist[node] < Dist[x]) {
					ADJ[node].push_back(x);
					ADJ[node + n].push_back(x + n);
				}
				else {
					ADJ[node].push_back(x + n);
				}
			}
		}

		vector<int> Ans = Dist;

		Ans[1] = 0;
		vector<int> Seen(3 * n);
		dfs(1, ADJ, Ans, Dist, Seen);

		cerr << "Ans = ";
		for (int i = 1; i <= n; ++i) {
			cout << Ans[i] << " ";
		}
		cout << endl;

	}
}
```


### Prompt

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

You and your grandma are playing with graph automata, which is generalization of cell automata.

A graph automaton is expressed by a graph. The vertices of the graph have a time-dependent value, which can be either 0 or 1. There is no more than one edge between any of two vertices, but self-loops might exist.

The values of vertices change regularly according to the following rule: At time t+1, the value of vertex i will be 1 if and only if there are an odd number of edges from the vertex i to a vertex which has the value 1 at time t; otherwise 0.

Now, your forgetful grandma forgot the past states of the automaton. Your task is to write a program which recovers the past states from the current time and states --- time machines are way too expensive. There may be multiple candidates or no consistent states. For such cases, you must print an appropriate error message.

Input

The input is formatted as follows:

N
a_{11} ... a_{1N}
:
:
a_{N1} ... a_{NN}
v_1
:
:
v_N
T

The first line contains one integer N (2 \leq N \leq 300). N indicates the number of vertices. The following N lines indicate the adjacent matrix of the graph. When (i,j)-element is 1, there is an edge from vertex i to vertex j. Otherwise, there is no edge. The following N lines indicate the value vector of the vertices. The i-th element indicates the value of vertex i at time 0. Each element of the matrix and the vector can be 0 or 1. The last line contains one integer T (1 \leq T \leq 100,000,000). -T is the time your grandma wants to know the status at.

Output

Print the value vector at time -T separated one white space in one line as follows:

v_1 ... v_N

Each value must be separated with one white space. If there is no consistent value vectors, you should print `none` in one line. Or if there are multiple candidates and the solution is not unique (i.e. the solution is not unique), you should print `ambiguous` in one line.

Sample Input 1

2
1 1
0 1
1
1
1

Output for the Sample Input 1

0 1

Sample Input 2

2
0 1
0 0
1
0
1

Output for the Sample Input 2

ambiguous

Sample Input 3

2
0 1
0 0
1
0
2

Output for the Sample Input 3

none

Example

Input

2
1 1
0 1
1
1
1

Output

0 1

### Response

```cpp
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

const int MAX_ROW = 310; // to be set appropriately
const int MAX_COL = 310; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};

ostream& operator << (ostream& s, BitMatrix A) {
    s << endl;
    for (int i = 0; i < A.H; ++i) {
        for (int j = 0; j < A.W; ++j) {
            s << A[i][j] << ", ";
        }
        s << endl;
    }
    return s;
}

inline BitMatrix operator * (BitMatrix A, BitMatrix B) {
    BitMatrix R(A.H, B.W);
    BitMatrix tB(B.W, B.H);
    for (int i = 0; i < tB.H; ++i) for (int j = 0; j < tB.W; ++j) tB[i][j] = B[j][i];
    for (int i = 0; i < R.H; ++i) for (int j = 0; j < R.W; ++j) R[i][j] = ((A[i] & tB[j]).count() & 1);
    return R;
}

inline BitMatrix pow(BitMatrix A, long long n) {
    BitMatrix R(A.H, A.H);
    for (int i = 0; i < A.H; ++i) R[i][i] = 1;
    while (n > 0) {
        if (n & 1) R = R * A;
        A = A * A;
        n >>= 1;
    }
    return R;
}

int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int linear_equation(BitMatrix A, vector<int> b, vector<int> &res) {
    int m = A.H, n = A.W;
    BitMatrix M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = GaussJordan(M, true);

    // check if it has no solution
    for (int row = rank; row < m; ++row) if (M[row][n]) return -1;

    // answer
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return rank;
}

int main() {
    int N; cin >> N;
    BitMatrix A(N, N);
    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j) {
            int a; cin >> a;
            A[i][j] = a;
        }
    vector<int> v(N), res;
    for (int i = 0; i < N; ++i) cin >> v[i];
    long long T; cin >> T;

    BitMatrix P = pow(A, T);
    int rank = linear_equation(P, v, res);
    int jiyudo = N - rank;

    if (rank == -1) puts("none");
    else if (jiyudo > 0) puts("ambiguous");
    else {
        for (int i = 0; i < N; ++i) {
            cout << res[i];
            if (i != N-1) cout << " ";
        }
        cout << endl;
    }
}

```


### Prompt

Construct a CPP code solution to the problem outlined:

Monocarp has got two strings s and t having equal length. Both strings consist of lowercase Latin letters "a" and "b".

Monocarp wants to make these two strings s and t equal to each other. He can do the following operation any number of times: choose an index pos_1 in the string s, choose an index pos_2 in the string t, and swap s_{pos_1} with t_{pos_2}.

You have to determine the minimum number of operations Monocarp has to perform to make s and t equal, and print any optimal sequence of operations — or say that it is impossible to make these strings equal.

Input

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

The second line contains one string s consisting of n characters "a" and "b".

The third line contains one string t consisting of n characters "a" and "b".

Output

If it is impossible to make these strings equal, print -1.

Otherwise, in the first line print k — the minimum number of operations required to make the strings equal. In each of the next k lines print two integers — the index in the string s and the index in the string t that should be used in the corresponding swap operation.

Examples

Input

4
abab
aabb

Output

2
3 3
3 2

Input

1
a
b

Output

-1

Input

8
babbaabb
abababaa

Output

3
2 6
1 3
7 8

Note

In the first example two operations are enough. For example, you can swap the third letter in s with the third letter in t. Then s =  "abbb", t =  "aaab". Then swap the third letter in s and the second letter in t. Then both s and t are equal to "abab".

In the second example it's impossible to make two strings equal.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  string a, b;
  cin >> a >> b;
  int prevA = -1, prevB = -1;
  vector<pair<int, int>> ans;
  for (int i = 0; i < n; i++) {
    if (a[i] != b[i]) {
      if (a[i] == 'a') {
        if (prevA == -1) {
          prevA = i + 1;
        } else {
          ans.push_back({prevA, i + 1});
          prevA = -1;
        }
      } else {
        if (prevB == -1) {
          prevB = i + 1;
        } else {
          ans.push_back({prevB, i + 1});
          prevB = -1;
        }
      }
    }
  }
  if (prevA != -1 and prevB != -1) {
    ans.push_back({prevB, prevB});
    ans.push_back({prevB, prevA});
    prevA = -1, prevB = -1;
  }
  if (prevA != -1 or prevB != -1) {
    cout << -1;
  } else {
    cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i].first << ' ';
      cout << ans[i].second << '\n';
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
    cout << '\n';
  }
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks:

  * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the score. Then he gives the group to the Appleman.
  * Each time Appleman gets a group consisting of a single number, he throws this group out. Each time Appleman gets a group consisting of more than one number, he splits the group into two non-empty groups (he can do it in any way) and gives each of them to Toastman.

After guys complete all the tasks they look at the score value. What is the maximum possible value of score they can get?

Input

The first line contains a single integer n (1 ≤ n ≤ 3·105). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106) — the initial group that is given to Toastman.

Output

Print a single integer — the largest possible score.

Examples

Input

3
3 1 5

Output

26

Input

1
10

Output

10

Note

Consider the following situation in the first example. Initially Toastman gets group [3, 1, 5] and adds 9 to the score, then he give the group to Appleman. Appleman splits group [3, 1, 5] into two groups: [3, 5] and [1]. Both of them should be given to Toastman. When Toastman receives group [1], he adds 1 to score and gives the group to Appleman (he will throw it out). When Toastman receives group [3, 5], he adds 8 to the score and gives the group to Appleman. Appleman splits [3, 5] in the only possible way: [5] and [3]. Then he gives both groups to Toastman. When Toastman receives [5], he adds 5 to the score and gives the group to Appleman (he will throws it out). When Toastman receives [3], he adds 3 to the score and gives the group to Appleman (he will throws it out). Finally Toastman have added 9 + 1 + 8 + 5 + 3 = 26 to the score. This is the optimal sequence of actions.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int a[300001];
int main() {
  int n;
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    sum += a[i];
  }
  long long ans = sum;
  sort(a, a + n);
  for (int i = 0; i < n - 1; i++) {
    ans += sum;
    sum -= a[i];
  }
  printf("%I64d", ans);
  return 0;
}

```


### Prompt

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

How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?

* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.

Find the count modulo 10^9+7.

Constraints

* 1 \leq n \leq 10^6

Input

Input is given from Standard Input in the following format:

n

Output

Print how many sequences satisfy the conditions, modulo 10^9+7.

Examples

Input

2

Output

4

Input

654321

Output

968545283

### Response

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

const int mo=int(1e9+7);
int n,f[1000010],ans;

void work()
{
	scanf("%d",&n);
	f[0]=1,f[1]=1;
	for (int i=2,s=2; i<=n; i++)
		f[i]=(s+mo-f[i-2])%mo,s=(s+f[i])%mo;
	for (int i=0; i<=n-2; i++)  ans=(ans+(1LL*(n-1)*(n-1)+(i+1))%mo*f[i])%mo;
	ans=(ans+1LL*f[n-1]*(n-1)+f[n])%mo;
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}

```


### Prompt

Please create a solution in cpp to the following problem:

You are given a tree with n nodes. You have to write non-negative integers on its edges so that the following condition would be satisfied:

For every two nodes i, j, look at the path between them and count the sum of numbers on the edges of this path. Write all obtained sums on the blackboard. Then every integer from 1 to ⌊ (2n^2)/(9) ⌋ has to be written on the blackboard at least once.

It is guaranteed that such an arrangement exists.

Input

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

Each of the next n-1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v), meaning that there is an edge between nodes u and v. It is guaranteed that these edges form a tree.

Output

Output n-1 lines, each of form u v x (0 ≤ x ≤ 10^6), which will mean that you wrote number x on the edge between u, v.

Set of edges (u, v) has to coincide with the set of edges of the input graph, but you can output edges in any order. You can also output ends of edges in an order different from the order in input.

Examples

Input

3
2 3
2 1

Output

3 2 1
1 2 2

Input

4
2 4
2 3
2 1

Output

4 2 1
3 2 2
1 2 3

Input

5
1 2
1 3
1 4
2 5

Output

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

Note

In the first example, distance between nodes 1 and 2 is equal to 2, between nodes 2 and 3 to 1, between 1 and 3 to 3.

In the third example, numbers from 1 to 9 (inclusive) will be written on the blackboard, while we need just from 1 to 5 to pass the test.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > ans;
void tree_size(const vector<vector<int> > &g, vector<int> &sz, int u,
               int parent = -1) {
  sz[u] = 1;
  for (int i = 0; i < g[u].size(); i++)
    if (g[u][i] != parent) {
      tree_size(g, sz, g[u][i], u);
      sz[u] += sz[g[u][i]];
    }
}
int tree_centroid(const vector<vector<int> > &g, int u = 0) {
  vector<int> sz(g.size());
  tree_size(g, sz, u);
  for (int i = 0; i < g[u].size(); i++)
    if (sz[g[u][i]] > g.size() / 2) return tree_centroid(g, g[u][i]);
  return u;
}
void dfs(const vector<vector<int> > &g, const vector<int> &sz, int u,
         int parent, const vector<int> &a) {
  for (int i = 0, s = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == parent) continue;
    ans.push_back(make_pair(make_pair(u, v), a[s]));
    vector<int> t;
    for (int j = 1; j < sz[v]; j++) t.push_back(a[s + j] - a[s]);
    dfs(g, sz, v, u, t);
    s += sz[v];
  }
}
int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  vector<vector<int> > g(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    if (u > v) swap(u, v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int c = tree_centroid(g);
  vector<int> sz(n);
  tree_size(g, sz, c);
  vector<pair<int, int> > g1, g2;
  for (int i = 0; i < g[c].size(); i++)
    g2.push_back(make_pair(sz[g[c][i]], g[c][i]));
  sort(g2.begin(), g2.end());
  int sum = 0;
  while (sum * 3 < (n - 1)) {
    sum += g2.back().first;
    g1.push_back(g2.back());
    g2.pop_back();
  }
  vector<int> a(sum), b(n - sum - 1);
  for (int i = 0; i < a.size(); i++) a[i] = i + 1;
  for (int i = 0; i < b.size(); i++) b[i] = (i + 1) * (sum + 1);
  g[c].clear();
  for (int i = 0; i < g1.size(); i++) g[c].push_back(g1[i].second);
  dfs(g, sz, c, -1, a);
  g[c].clear();
  for (int i = 0; i < g2.size(); i++) g[c].push_back(g2[i].second);
  dfs(g, sz, c, -1, b);
  for (int i = 0; i < ans.size(); i++)
    cout << (ans[i].first.first + 1) << ' ' << (ans[i].first.second + 1) << ' '
         << ans[i].second << endl;
  return 0;
}

```


### Prompt

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

This is the easy version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.

You are given a binary table of size n × m. This table consists of symbols 0 and 1.

You can make such operation: select 3 different cells that belong to one 2 × 2 square and change the symbols in these cells (change 0 to 1 and 1 to 0).

Your task is to make all symbols in the table equal to 0. You are allowed to make at most 3nm operations. You don't need to minimize the number of operations.

It can be proved that it is always possible.

Input

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

The first line of the description of each test case contains two integers n, m (2 ≤ n, m ≤ 100).

Each of the next n lines contains a binary string of length m, describing the symbols of the next row of the table.

It is guaranteed that the sum of nm for all test cases does not exceed 20000.

Output

For each test case print the integer k (0 ≤ k ≤ 3nm) — the number of operations.

In the each of the next k lines print 6 integers x_1, y_1, x_2, y_2, x_3, y_3 (1 ≤ x_1, x_2, x_3 ≤ n, 1 ≤ y_1, y_2, y_3 ≤ m) describing the next operation. This operation will be made with three cells (x_1, y_1), (x_2, y_2), (x_3, y_3). These three cells should be different. These three cells should belong into some 2 × 2 square.

Example

Input

5
2 2
10
11
3 3
011
101
110
4 4
1111
0110
0110
1111
5 5
01011
11001
00010
11011
10000
2 3
011
101

Output

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

Note

In the first test case, it is possible to make only one operation with cells (1, 1), (2, 1), (2, 2). After that, all symbols will be equal to 0.

In the second test case:

  * operation with cells (2, 1), (3, 1), (3, 2). After it the table will be:

    011
    001
    000

  * operation with cells (1, 2), (1, 3), (2, 3). After it the table will be:

    000
    000
    000

In the fifth test case:

  * operation with cells (1, 3), (2, 2), (2, 3). After it the table will be:

    010
    110

  * operation with cells (1, 2), (2, 1), (2, 2). After it the table will be:

    000
    000

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long dp[5100][5100];
long long factor[1000001];
long long fact(long long n);
long long power(long long a, long long b, long long f1) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y);
      if (x > f1) x %= f1;
    }
    y = (y * y);
    if (y > f1) y %= f1;
    b /= 2;
  }
  return x;
}
long long fact(long long n, long long f1) { return power(n, f1 - 2, f1); }
long long nCr(long long n, long long r, long long f1) {
  return (factor[n] * ((fact(factor[r], f1) * fact(factor[n - r], f1)) % f1)) %
         f1;
}
template <typename T>
T ma(T x, T y) {
  return (x > y) ? x : y;
}
bool subset(vector<long long> &v, long long n, long long sum) {
  if (sum == 0) return true;
  if (n == 0) return false;
  if (v[n - 1] > sum) {
    return subset(v, n - 1, sum);
  }
  return subset(v, n - 1, sum) || subset(v, n - 1, sum - v[n - 1]);
}
long long ans1 = 0;
long long ans2 = 0;
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.second < b.second);
}
long long prime[100001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t, n, i, j, k;
  long long ans = 0;
  for (i = 1; i <= 100000; i++) prime[i] = 1;
  prime[1] = 0;
  for (i = 2; i * i <= 100000; i++) {
    if (prime[i]) {
      for (j = i * i; j <= 10000; j = j + i) {
        prime[j] = 0;
      }
    }
  }
  for (i = 2; i <= 100000; i++) {
    if (prime[i]) ans++;
  }
  factor[0] = 1;
  for (i = 1; i <= 100001; i++) {
    factor[i] = (factor[i - 1] * i) % 1000000007;
  }
  t = 1;
  cin >> t;
  while (t--) {
    long long m;
    cin >> n >> m;
    char a[n + 1][m + 1];
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) cin >> a[i][j];
    }
    vector<long long> v;
    long long ans = 0;
    for (i = 1; i <= n - 1; i++) {
      for (j = 1; j <= m - 1; j++) {
        if (a[i][j] == '1' && j != m - 1) {
          ans++;
          v.push_back(i);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j + 1);
          a[i][j] = '0';
          if (a[i + 1][j] == '1')
            a[i + 1][j] = '0';
          else if (a[i + 1][j] == '0')
            a[i + 1][j] = '1';
          if (a[i + 1][j + 1] == '1')
            a[i + 1][j + 1] = '0';
          else if (a[i + 1][j + 1] == '0')
            a[i + 1][j + 1] = '1';
        } else if (a[i][j] == '1' && j == m - 1) {
          ans++;
          if (a[i][j + 1] == '1') {
            v.push_back(i);
            v.push_back(j);
            v.push_back(i);
            v.push_back(j + 1);
            v.push_back(i + 1);
            v.push_back(j + 1);
            a[i][j] = '0';
            a[i][j + 1] = '0';
            if (a[i + 1][j + 1] == '1')
              a[i + 1][j + 1] = '0';
            else if (a[i + 1][j + 1] == '0')
              a[i + 1][j + 1] = '1';
          } else {
            v.push_back(i);
            v.push_back(j);
            v.push_back(i + 1);
            v.push_back(j);
            v.push_back(i + 1);
            v.push_back(j + 1);
            a[i][j] = '0';
            if (a[i + 1][j] == '1')
              a[i + 1][j] = '0';
            else if (a[i + 1][j] == '0')
              a[i + 1][j] = '1';
            if (a[i + 1][j + 1] == '1')
              a[i + 1][j + 1] = '0';
            else if (a[i + 1][j + 1] == '0')
              a[i + 1][j + 1] = '1';
          }
        } else if (a[i][j + 1] == '1' && j == m - 1) {
          ans++;
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j + 1);
          a[i][j + 1] = '0';
          if (a[i + 1][j] == '1')
            a[i + 1][j] = '0';
          else if (a[i + 1][j] == '0')
            a[i + 1][j] = '1';
          if (a[i + 1][j + 1] == '1')
            a[i + 1][j + 1] = '0';
          else if (a[i + 1][j + 1] == '0')
            a[i + 1][j + 1] = '1';
        }
      }
    }
    for (i = n - 1; i <= n - 1; i++) {
      for (j = 1; j <= m - 1; j++) {
        if (a[i + 1][j] == '1' && a[i + 1][j + 1] == '1') {
          ans += 2;
          v.push_back(i);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j + 1);
          a[i + 1][j] = '0';
          a[i + 1][j + 1] = '0';
        } else if (a[i + 1][j] == '1' && a[i + 1][j + 1] == '0') {
          ans += 3;
          v.push_back(i);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j + 1);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j + 1);
          a[i + 1][j] = '0';
          a[i + 1][j + 1] = '0';
        } else if (a[i + 1][j] == '0' && a[i + 1][j + 1] == '1') {
          ans += 3;
          v.push_back(i);
          v.push_back(j);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j + 1);
          v.push_back(i);
          v.push_back(j + 1);
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j + 1);
          v.push_back(i);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j);
          v.push_back(i + 1);
          v.push_back(j + 1);
          a[i + 1][j] = '0';
          a[i + 1][j + 1] = '0';
        }
      }
    }
    cout << ans << endl;
    for (i = 0; i < v.size(); i += 6) {
      cout << v[i] << " " << v[i + 1] << " " << v[i + 2] << " " << v[i + 3]
           << " " << v[i + 4] << " " << v[i + 5] << endl;
    }
  }
  return 0;
}

```


### Prompt

Develop a solution in Cpp to the problem described below:

First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.

For example, you should know linguistics very well. You learn a structure of Reberland language as foreign language. In this language words are constructed according to the following rules. First you need to choose the "root" of the word — some string which has more than 4 letters. Then several strings with the length 2 or 3 symbols are appended to this word. The only restriction —  it is not allowed to append the same string twice in a row. All these strings are considered to be suffixes of the word (this time we use word "suffix" to describe a morpheme but not the few last characters of the string as you may used to).

Here is one exercise that you have found in your task list. You are given the word s. Find all distinct strings with the length 2 or 3, which can be suffixes of this word according to the word constructing rules in Reberland language.

Two strings are considered distinct if they have different length or there is a position in which corresponding characters do not match.

Let's look at the example: the word abacabaca is given. This word can be obtained in the following ways: <image>, where the root of the word is overlined, and suffixes are marked by "corners". Thus, the set of possible suffixes for this word is {aca, ba, ca}.

Input

The only line contains a string s (5 ≤ |s| ≤ 104) consisting of lowercase English letters.

Output

On the first line print integer k — a number of distinct possible suffixes. On the next k lines print suffixes.

Print suffixes in lexicographical (alphabetical) order.

Examples

Input

abacabaca

Output

3
aca
ba
ca

Input

abaca

Output

0

Note

The first test was analysed in the problem statement.

In the second example the length of the string equals 5. The length of the root equals 5, so no string can be used as a suffix.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
}
string s;
set<string> st;
int ok[10005][4];
bool rec(int idx, int last) {
  if (idx > s.size()) return 0;
  if (idx == s.size()) return 1;
  int &ret = ok[idx][last];
  if (ret != -1) {
    return ret;
  }
  ret = 0;
  if (last == 0) {
    if (rec(idx + 2, 2)) {
      st.insert(s.substr(idx, 2));
      ret = 1;
    }
    if (rec(idx + 3, 3)) {
      st.insert(s.substr(idx, 3));
      ret = 1;
    }
  } else if (last == 2) {
    if (s.substr(idx - last, 2) != s.substr(idx, 2)) {
      if (rec(idx + 2, 2)) {
        st.insert(s.substr(idx, 2));
        ret = 1;
      }
    }
    if (rec(idx + 3, 3)) {
      st.insert(s.substr(idx, 3));
      ret = 1;
    }
  } else {
    if (s.substr(idx - last, 3) != s.substr(idx, 3)) {
      if (rec(idx + 3, 3)) {
        st.insert(s.substr(idx, 3));
        ret = 1;
      }
    }
    if (rec(idx + 2, 2)) {
      st.insert(s.substr(idx, 2));
      ret = 1;
    }
  }
  return ret;
}
int main() {
  fast();
  memset(ok, -1, sizeof ok);
  cin >> s;
  for (int i = 5; i < s.size(); i++) {
    rec(i, 0);
  }
  cout << st.size() << endl;
  for (auto e : st) {
    cout << e << endl;
  }
  return 0;
}

```


### Prompt

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

Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on n - 2 intermediate planets. Formally: we number all the planets from 1 to n. 1 is Earth, n is Mars. Natasha will make exactly n flights: 1 → 2 → … n → 1.

Flight from x to y consists of two phases: take-off from planet x and landing to planet y. This way, the overall itinerary of the trip will be: the 1-st planet → take-off from the 1-st planet → landing to the 2-nd planet → 2-nd planet → take-off from the 2-nd planet → … → landing to the n-th planet → the n-th planet → take-off from the n-th planet → landing to the 1-st planet → the 1-st planet.

The mass of the rocket together with all the useful cargo (but without fuel) is m tons. However, Natasha does not know how much fuel to load into the rocket. Unfortunately, fuel can only be loaded on Earth, so if the rocket runs out of fuel on some other planet, Natasha will not be able to return home. Fuel is needed to take-off from each planet and to land to each planet. It is known that 1 ton of fuel can lift off a_i tons of rocket from the i-th planet or to land b_i tons of rocket onto the i-th planet.

For example, if the weight of rocket is 9 tons, weight of fuel is 3 tons and take-off coefficient is 8 (a_i = 8), then 1.5 tons of fuel will be burnt (since 1.5 ⋅ 8 = 9 + 3). The new weight of fuel after take-off will be 1.5 tons.

Please note, that it is allowed to burn non-integral amount of fuel during take-off or landing, and the amount of initial fuel can be non-integral as well.

Help Natasha to calculate the minimum mass of fuel to load into the rocket. Note, that the rocket must spend fuel to carry both useful cargo and the fuel itself. However, it doesn't need to carry the fuel which has already been burnt. Assume, that the rocket takes off and lands instantly.

Input

The first line contains a single integer n (2 ≤ n ≤ 1000) — number of planets.

The second line contains the only integer m (1 ≤ m ≤ 1000) — weight of the payload.

The third line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 1000), where a_i is the number of tons, which can be lifted off by one ton of fuel.

The fourth line contains n integers b_1, b_2, …, b_n (1 ≤ b_i ≤ 1000), where b_i is the number of tons, which can be landed by one ton of fuel.

It is guaranteed, that if Natasha can make a flight, then it takes no more than 10^9 tons of fuel.

Output

If Natasha can fly to Mars through (n - 2) planets and return to Earth, print the minimum mass of fuel (in tons) that Natasha should take. Otherwise, print a single number -1.

It is guaranteed, that if Natasha can make a flight, then it takes no more than 10^9 tons of fuel.

The answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}. Formally, let your answer be p, and the jury's answer be q. Your answer is considered correct if \frac{|p - q|}{max{(1, |q|)}} ≤ 10^{-6}.

Examples

Input

2
12
11 8
7 5

Output

10.0000000000

Input

3
1
1 4 1
2 5 3

Output

-1

Input

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

Output

85.4800000000

Note

Let's consider the first example.

Initially, the mass of a rocket with fuel is 22 tons.

  * At take-off from Earth one ton of fuel can lift off 11 tons of cargo, so to lift off 22 tons you need to burn 2 tons of fuel. Remaining weight of the rocket with fuel is 20 tons.
  * During landing on Mars, one ton of fuel can land 5 tons of cargo, so for landing 20 tons you will need to burn 4 tons of fuel. There will be 16 tons of the rocket with fuel remaining.
  * While taking off from Mars, one ton of fuel can raise 8 tons of cargo, so to lift off 16 tons you will need to burn 2 tons of fuel. There will be 14 tons of rocket with fuel after that.
  * During landing on Earth, one ton of fuel can land 7 tons of cargo, so for landing 14 tons you will need to burn 2 tons of fuel. Remaining weight is 12 tons, that is, a rocket without any fuel.

In the second case, the rocket will not be able even to take off from Earth.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
double fuelLeft(vector<int>& ais, vector<int>& bis, int weight, double fuel) {
  double totweight = weight + fuel;
  for (int i = 0; i < ais.size(); i++) {
    double fuel = totweight / (double)ais[i];
    totweight -= fuel;
    if (i < ais.size() - 1) {
      fuel = totweight / (double)bis[i + 1];
      totweight -= fuel;
    } else {
      fuel = totweight / (double)bis[0];
      totweight -= fuel;
    }
  }
  return totweight - weight;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ais(n);
  vector<int> bis(n);
  bool can = 1;
  for (int i = 0; i < n; i++) {
    cin >> ais[i];
    if (ais[i] == 1) can = 0;
  }
  for (int i = 0; i < n; i++) {
    cin >> bis[i];
    if (bis[i] == 1) can = 0;
  }
  if (can) {
    double r = 1000000002;
    double l = 0;
    double med = l + (r - l) / 2;
    while (l < r - 0.00000001) {
      double toC = fuelLeft(ais, bis, m, med);
      if (toC < -0.00000001) {
        l = med + 0.000000001;
        med = l + (r - l) / 2;
      } else if (toC > 0.000000001) {
        r = med - 0.00000001;
        med = l + (r - l) / 2;
      } else {
        l = r;
      }
    }
    cout << setprecision(7);
    cout << fixed;
    cout << med << "\n";
  } else
    cout << -1 << "\n";
  return 0;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

Zart PMP is qualified for ICPC World Finals in Harbin, China. After team excursion to Sun Island Park for snow sculpture art exposition, PMP should get back to buses before they leave. But the park is really big and he does not know how to find them.

The park has n intersections numbered 1 through n. There are m bidirectional roads that connect some pairs of these intersections. At k intersections, ICPC volunteers are helping the teams and showing them the way to their destinations. Locations of volunteers are fixed and distinct.

When PMP asks a volunteer the way to bus station, he/she can tell him the whole path. But the park is fully covered with ice and snow and everywhere looks almost the same. So PMP can only memorize at most q intersections after each question (excluding the intersection they are currently standing). He always tells volunteers about his weak memory and if there is no direct path of length (in number of roads) at most q that leads to bus station, the volunteer will guide PMP to another volunteer (who is at most q intersections away, of course). ICPC volunteers know the area very well and always tell PMP the best way. So if there exists a way to bus stations, PMP will definitely find it.

PMP's initial location is intersection s and the buses are at intersection t. There will always be a volunteer at intersection s. Your job is to find out the minimum q which guarantees that PMP can find the buses.

Input

The first line contains three space-separated integers n, m, k (2 ≤ n ≤ 105, 0 ≤ m ≤ 2·105, 1 ≤ k ≤ n) — the number of intersections, roads and volunteers, respectively. Next line contains k distinct space-separated integers between 1 and n inclusive — the numbers of cities where volunteers are located.

Next m lines describe the roads. The i-th of these lines contains two space-separated integers ui, vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — two intersections that i-th road connects. There will be at most one road between any two intersections.

Last line of input contains two space-separated integers s, t (1 ≤ s, t ≤ n, s ≠ t) — the initial location of PMP and the location of the buses. It might not always be possible to reach t from s.

It is guaranteed that there is always a volunteer at intersection s.

Output

Print on the only line the answer to the problem — the minimum value of q which guarantees that PMP can find the buses. If PMP cannot reach the buses at all, output -1 instead.

Examples

Input

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

Output

3

Input

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

Output

3

Note

The first sample is illustrated below. Blue intersections are where volunteers are located. If PMP goes in the path of dashed line, it can reach the buses with q = 3:

<image>

In the second sample, PMP uses intersection 6 as an intermediate intersection, thus the answer is 3.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxx = 600010;
const double pi = acos(-1.0);
const double eps = 1e-15;
struct node {
  int num, val;
  bool operator<(const node &X) const { return val < X.val; }
};
vector<int> g[maxx];
priority_queue<node> q;
int t, n, m, u, v, s, k;
int ans = 0, total = 0, sum = 0, cnt = 0;
int a[maxx], bj[maxx], vis[maxx], dis[maxx];
bool f(int xx) {
  while (!q.empty()) q.pop();
  for (int i = 1; i <= n; i++) dis[i] = -1;
  q.push(node{s, xx}), dis[s] = xx;
  while (!q.empty()) {
    int x = q.top().num;
    int val = q.top().val;
    q.pop();
    if (val == 0) continue;
    for (int i = 0; i < g[x].size(); i++) {
      int to = g[x][i];
      int w = val - 1;
      if (to == t) return true;
      if (bj[to]) w = xx;
      if (w > dis[to]) {
        dis[to] = w;
        q.push(node{to, w});
      }
    }
  }
  return false;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d", &t);
    bj[t] = 1;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v), g[v].push_back(u);
  }
  scanf("%d%d", &s, &t);
  int l = 1, r = n;
  ans = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (f(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%d", ans);
  return 0;
}

```


### Prompt

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

The Little Elephant has array a, consisting of n positive integers, indexed from 1 to n. Let's denote the number with index i as ai.

The Little Elephant wants to count, how many pairs of integers l and r are there, such that 1 ≤ l < r ≤ n and sequence b = a1a2... alarar + 1... an has no more than k inversions.

An inversion in sequence b is a pair of elements of the sequence b, that change their relative order after a stable sorting of the sequence. In other words, an inversion is a pair of integers i and j, such that 1 ≤ i < j ≤ |b| and bi > bj, where |b| is the length of sequence b, and bj is its j-th element.

Help the Little Elephant and count the number of the described pairs.

Input

The first line contains two integers n and k (2 ≤ n ≤ 105, 0 ≤ k ≤ 1018) — the size of array a and the maximum allowed number of inversions respectively. The next line contains n positive integers, separated by single spaces, a1, a2, ..., an (1 ≤ ai ≤ 109) — elements of array a.

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

Output

In a single line print a single number — the answer to the problem.

Examples

Input

3 1
1 3 2

Output

3

Input

5 2
1 3 2 1 7

Output

6

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
struct cntSet {
 public:
  void erase(int);
  void insert(int);
  int getLower(int);
  int getHigher(int);

 private:
  int fen[N];
  int getSum(int);
  void add(int, int);
};
int n, a[N], db[N], dbs;
cntSet _right, _left;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    db[i] = a[i];
  }
  sort(db, db + n);
  dbs = unique(db, db + n) - db;
  for (int i = 0; i < n; i++) a[i] = lower_bound(db, db + dbs, a[i]) - db;
  long long curInv = 0;
  for (int i = n - 1; i > 0; i--) {
    curInv += _right.getLower(a[i]);
    _right.insert(a[i]);
  }
  long long ans = 0;
  curInv += _right.getLower(a[0]);
  if (curInv <= k) ans += n - 1;
  curInv -= _right.getLower(a[0]);
  int r = 1;
  for (int l = 0; l < n; l++) {
    bool flag = true;
    while ((flag && curInv > k) || r == l)
      if (r < n) {
        _right.erase(a[r]);
        curInv -= _left.getHigher(a[r]) + _right.getLower(a[r]);
        r++;
      } else
        flag = false;
    if (!flag) break;
    if (l > 0) ans += n - r;
    _left.insert(a[l]);
    curInv += _left.getHigher(a[l]) + _right.getLower(a[l]);
  }
  cout << ans << endl;
}
void cntSet::insert(int v) { add(v, +1); }
void cntSet::erase(int v) { add(v, -1); }
int cntSet::getLower(int v) { return getSum(v); }
int cntSet::getHigher(int v) { return getSum(dbs) - getSum(v + 1); }
void cntSet::add(int i, int val) {
  for (i++; i <= dbs; i += i & -i) fen[i] += val;
}
int cntSet::getSum(int r) {
  int res = 0;
  for (; r; r ^= r & -r) res += fen[r];
  return res;
}

```


### Prompt

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

A new airplane SuperPuperJet has an infinite number of rows, numbered with positive integers starting with 1 from cockpit to tail. There are six seats in each row, denoted with letters from 'a' to 'f'. Seats 'a', 'b' and 'c' are located to the left of an aisle (if one looks in the direction of the cockpit), while seats 'd', 'e' and 'f' are located to the right. Seats 'a' and 'f' are located near the windows, while seats 'c' and 'd' are located near the aisle.

<image>

It's lunch time and two flight attendants have just started to serve food. They move from the first rows to the tail, always maintaining a distance of two rows from each other because of the food trolley. Thus, at the beginning the first attendant serves row 1 while the second attendant serves row 3. When both rows are done they move one row forward: the first attendant serves row 2 while the second attendant serves row 4. Then they move three rows forward and the first attendant serves row 5 while the second attendant serves row 7. Then they move one row forward again and so on.

Flight attendants work with the same speed: it takes exactly 1 second to serve one passenger and 1 second to move one row forward. Each attendant first serves the passengers on the seats to the right of the aisle and then serves passengers on the seats to the left of the aisle (if one looks in the direction of the cockpit). Moreover, they always serve passengers in order from the window to the aisle. Thus, the first passenger to receive food in each row is located in seat 'f', and the last one — in seat 'c'. Assume that all seats are occupied.

Vasya has seat s in row n and wants to know how many seconds will pass before he gets his lunch.

Input

The only line of input contains a description of Vasya's seat in the format ns, where n (1 ≤ n ≤ 1018) is the index of the row and s is the seat in this row, denoted as letter from 'a' to 'f'. The index of the row and the seat are not separated by a space.

Output

Print one integer — the number of seconds Vasya has to wait until he gets his lunch.

Examples

Input

1f

Output

1

Input

2d

Output

10

Input

4a

Output

11

Input

5e

Output

18

Note

In the first sample, the first flight attendant serves Vasya first, so Vasya gets his lunch after 1 second.

In the second sample, the flight attendants will spend 6 seconds to serve everyone in the rows 1 and 3, then they will move one row forward in 1 second. As they first serve seats located to the right of the aisle in order from window to aisle, Vasya has to wait 3 more seconds. The total is 6 + 1 + 3 = 10.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  unsigned long long n;
  cin >> n;
  char f;
  cin >> f;
  unsigned long long h;
  if (f == 'f') h = 1;
  if (f == 'e') h = 2;
  if (f == 'd') h = 3;
  if (f == 'a') h = 4;
  if (f == 'b') h = 5;
  if (f == 'c') h = 6;
  cout << ((n - 1) / 4) * 16 + h + ((n + 1) % 2) * 7;
  return 0;
}

```


### Prompt

Please formulate a Cpp solution to the following problem:

You are given two strings s and t. The string s consists of lowercase Latin letters and at most one wildcard character '*', the string t consists only of lowercase Latin letters. The length of the string s equals n, the length of the string t equals m.

The wildcard character '*' in the string s (if any) can be replaced with an arbitrary sequence (possibly empty) of lowercase Latin letters. No other character of s can be replaced with anything. If it is possible to replace a wildcard character '*' in s to obtain a string t, then the string t matches the pattern s.

For example, if s="aba*aba" then the following strings match it "abaaba", "abacaba" and "abazzzaba", but the following strings do not match: "ababa", "abcaaba", "codeforces", "aba1aba", "aba?aba".

If the given string t matches the given string s, print "YES", otherwise print "NO".

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 2 ⋅ 10^5) — the length of the string s and the length of the string t, respectively.

The second line contains string s of length n, which consists of lowercase Latin letters and at most one wildcard character '*'.

The third line contains string t of length m, which consists only of lowercase Latin letters.

Output

Print "YES" (without quotes), if you can obtain the string t from the string s. Otherwise print "NO" (without quotes).

Examples

Input

6 10
code*s
codeforces

Output

YES

Input

6 5
vk*cup
vkcup

Output

YES

Input

1 1
v
k

Output

NO

Input

9 6
gfgf*gfgf
gfgfgf

Output

NO

Note

In the first example a wildcard character '*' can be replaced with a string "force". So the string s after this replacement is "codeforces" and the answer is "YES".

In the second example a wildcard character '*' can be replaced with an empty string. So the string s after this replacement is "vkcup" and the answer is "YES".

There is no wildcard character '*' in the third example and the strings "v" and "k" are different so the answer is "NO".

In the fourth example there is no such replacement of a wildcard character '*' that you can obtain the string t so the answer is "NO".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
char a[2 * maxn], b[2 * maxn];
int main() {
  int n, m, ll = 0, c = 0;
  scanf("%d%d", &n, &m);
  getchar();
  for (int i = 1; i <= n; i++) {
    scanf("%c", &a[i]);
    if (a[i] == '*') {
      c = i;
      ll = 1;
    }
  }
  getchar();
  for (int i = 1; i <= m; i++) {
    scanf("%c", &b[i]);
  }
  if (ll == 0) {
    if (n == m) {
      int lk = 0;
      for (int i = 1; i <= n; i++) {
        if (a[i] != b[i]) {
          lk = 1;
          break;
        }
      }
      if (lk == 1) {
        printf("NO\n");
        return 0;
      } else {
        printf("YES\n");
        return 0;
      }
    }
    printf("NO\n");
    return 0;
  }
  if (n > m + 1) {
    printf("NO\n");
    return 0;
  }
  int l = 1;
  for (int i = 1; i < c; i++) {
    if (a[i] != b[i]) {
      l = 0;
      break;
    }
  }
  int num = n, numm = m, lll = 1;
  while (a[num] != '*') {
    if (a[num] != b[numm]) {
      lll = 0;
      break;
    }
    num--;
    numm--;
  }
  if (l == 1 && lll == 1)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}

```


### Prompt

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

Many students live in a dormitory. A dormitory is a whole new world of funny amusements and possibilities but it does have its drawbacks.

There is only one shower and there are multiple students who wish to have a shower in the morning. That's why every morning there is a line of five people in front of the dormitory shower door. As soon as the shower opens, the first person from the line enters the shower. After a while the first person leaves the shower and the next person enters the shower. The process continues until everybody in the line has a shower.

Having a shower takes some time, so the students in the line talk as they wait. At each moment of time the students talk in pairs: the (2i - 1)-th man in the line (for the current moment) talks with the (2i)-th one.

Let's look at this process in more detail. Let's number the people from 1 to 5. Let's assume that the line initially looks as 23154 (person number 2 stands at the beginning of the line). Then, before the shower opens, 2 talks with 3, 1 talks with 5, 4 doesn't talk with anyone. Then 2 enters the shower. While 2 has a shower, 3 and 1 talk, 5 and 4 talk too. Then, 3 enters the shower. While 3 has a shower, 1 and 5 talk, 4 doesn't talk to anyone. Then 1 enters the shower and while he is there, 5 and 4 talk. Then 5 enters the shower, and then 4 enters the shower.

We know that if students i and j talk, then the i-th student's happiness increases by gij and the j-th student's happiness increases by gji. Your task is to find such initial order of students in the line that the total happiness of all students will be maximum in the end. Please note that some pair of students may have a talk several times. In the example above students 1 and 5 talk while they wait for the shower to open and while 3 has a shower.

Input

The input consists of five lines, each line contains five space-separated integers: the j-th number in the i-th line shows gij (0 ≤ gij ≤ 105). It is guaranteed that gii = 0 for all i.

Assume that the students are numbered from 1 to 5.

Output

Print a single integer — the maximum possible total happiness of the students.

Examples

Input

0 0 0 0 9
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
7 0 0 0 0

Output

32

Input

0 43 21 18 2
3 0 21 11 65
5 2 0 1 4
54 62 12 0 99
87 64 81 33 0

Output

620

Note

In the first sample, the optimal arrangement of the line is 23154. In this case, the total happiness equals:

(g23 + g32 + g15 + g51) + (g13 + g31 + g54 + g45) + (g15 + g51) + (g54 + g45) = 32.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[6][6];
  for (int i = 1; i <= 5; i++)
    for (int j = 1; j <= 5; j++) cin >> arr[i][j];
  int p[6];
  for (int i = 1; i <= 5; i++) p[i] = i;
  int maxe = -1;
  int res;
  do {
    res = 0;
    for (int i = 1; i <= 5; i++) {
      for (int j = i; j < 5; j += 2) {
        int x = p[j], y = p[j + 1];
        res += (arr[x][y] + arr[y][x]);
      }
    }
    maxe = max(res, maxe);
  } while (next_permutation(p + 1, p + 6));
  cout << maxe;
}

```


### Prompt

Please formulate a cpp solution to the following problem:

New AtCoder City has an infinite grid of streets, as follows:

* At the center of the city stands a clock tower. Let (0, 0) be the coordinates of this point.
* A straight street, which we will call East-West Main Street, runs east-west and passes the clock tower. It corresponds to the x-axis in the two-dimensional coordinate plane.
* There are also other infinitely many streets parallel to East-West Main Street, with a distance of 1 between them. They correspond to the lines \ldots, y = -2, y = -1, y = 1, y = 2, \ldots in the two-dimensional coordinate plane.
* A straight street, which we will call North-South Main Street, runs north-south and passes the clock tower. It corresponds to the y-axis in the two-dimensional coordinate plane.
* There are also other infinitely many streets parallel to North-South Main Street, with a distance of 1 between them. They correspond to the lines \ldots, x = -2, x = -1, x = 1, x = 2, \ldots in the two-dimensional coordinate plane.

There are N residential areas in New AtCoder City. The i-th area is located at the intersection with the coordinates (X_i, Y_i) and has a population of P_i. Each citizen in the city lives in one of these areas.

The city currently has only two railroads, stretching infinitely, one along East-West Main Street and the other along North-South Main Street.
M-kun, the mayor, thinks that they are not enough for the commuters, so he decides to choose K streets and build a railroad stretching infinitely along each of those streets.

Let the walking distance of each citizen be the distance from his/her residential area to the nearest railroad.
M-kun wants to build railroads so that the sum of the walking distances of all citizens, S, is minimized.

For each K = 0, 1, 2, \dots, N, what is the minimum possible value of S after building railroads?

Constraints

* 1 \leq N \leq 15
* -10 \ 000 \leq X_i \leq 10 \ 000
* -10 \ 000 \leq Y_i \leq 10 \ 000
* 1 \leq P_i \leq 1 \ 000 \ 000
* The locations of the N residential areas, (X_i, Y_i), are all distinct.
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
X_1 Y_1 P_1
X_2 Y_2 P_2
:  :  :
X_N Y_N P_N

Output

Print the answer in N+1 lines.
The i-th line (i = 1, \ldots, N+1) should contain the minimum possible value of S after building railroads for the case K = i-1.

Examples

Input

3
1 2 300
3 3 600
1 4 800

Output

2900
900
0
0

Input

5
3 5 400
5 3 700
5 5 1000
5 7 700
7 5 400

Output

13800
1600
0
0
0
0

Input

6
2 5 1000
5 2 1100
5 5 1700
-2 -5 900
-5 -2 600
-5 -5 2200

Output

26700
13900
3200
1200
0
0
0

Input

8
2 2 286017
3 1 262355
2 -2 213815
1 -3 224435
-2 -2 136860
-3 -1 239338
-2 2 217647
-1 3 141903

Output

2576709
1569381
868031
605676
366338
141903
0
0
0

### 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;
typedef pair<int, P> PP;

#define MAX 1000000020
#define INF 1e18

int main(int, char**)
{
  int n;
  cin >> n;
  vector<ll> x(n), y(n), p(n);
  rep(i,n) cin >> x[i] >> y[i] >> p[i];

  vector< vector<ll> > costx(n, vector<ll>(1<<n));
  vector< vector<ll> > costy(n, vector<ll>(1<<n));
  rep(i,n) {
    rep(j,1<<n) {
      costx[i][j] = abs(x[i])*p[i];
      costy[i][j] = abs(y[i])*p[i];
      rep(k,n) {
        if (j&1<<k) {
          costx[i][j] = min(costx[i][j], abs(x[i] - x[k])*p[i]);
          costy[i][j] = min(costy[i][j], abs(y[i] - y[k])*p[i]);
        }
      }
    }
  }

  vector<ll> ans(n+1,INF);
  rep(i,pow(3,n)) {
    int xx = 0, yy = 0;
    int tmp = i;
    int k = 0;
    int cnt = 0;
    while (tmp > 0) {
      if (tmp%3==1) xx |= 1<<cnt;
      if (tmp%3==2) yy |= 1<<cnt;
      if (tmp%3!=0) k++;
      cnt++;
      tmp /= 3;
    }
    ll dis = 0;
    rep(j,n) {
      dis += min(costx[j][xx],costy[j][yy]);
    }
    ans[k] = min(ans[k],dis);
  }
  rep(i,n+1) cout << ans[i] << endl;

  return 0;
}

```


### Prompt

Develop a solution in cpp to the problem described below:

You are given a complete directed graph K_n with n vertices: each pair of vertices u ≠ v in K_n have both directed edges (u, v) and (v, u); there are no self-loops.

You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices).

We can write such cycle as a list of n(n - 1) + 1 vertices v_1, v_2, v_3, ..., v_{n(n - 1) - 1}, v_{n(n - 1)}, v_{n(n - 1) + 1} = v_1 — a visiting order, where each (v_i, v_{i + 1}) occurs exactly once.

Find the lexicographically smallest such cycle. It's not hard to prove that the cycle always exists.

Since the answer can be too large print its [l, r] segment, in other words, v_l, v_{l + 1}, ..., v_r.

Input

The first line contains the single integer T (1 ≤ T ≤ 100) — the number of test cases.

Next T lines contain test cases — one per line. The first and only line of each test case contains three integers n, l and r (2 ≤ n ≤ 10^5, 1 ≤ l ≤ r ≤ n(n - 1) + 1, r - l + 1 ≤ 10^5) — the number of vertices in K_n, and segment of the cycle to print.

It's guaranteed that the total sum of n doesn't exceed 10^5 and the total sum of r - l + 1 doesn't exceed 10^5.

Output

For each test case print the segment v_l, v_{l + 1}, ..., v_r of the lexicographically smallest cycle that visits every edge exactly once.

Example

Input

3
2 1 3
3 3 6
99995 9998900031 9998900031

Output

1 2 1
1 3 2 3
1

Note

In the second test case, the lexicographically minimum cycle looks like: 1, 2, 1, 3, 2, 3, 1.

In the third test case, it's quite obvious that the cycle should start and end in vertex 1.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long q, n, l, r, sum[100005];
signed main() {
  cin >> q;
  while (q--) {
    cin >> n >> l >> r;
    long long s = n * (n - 1), p = 0;
    if (l == s + 1) {
      puts("1");
      continue;
    }
    sum[0] = 0;
    for (long long i = 1; i < n; i++) sum[i] = sum[i - 1] + 2 * (n - i);
    for (p = 1; p < n; p++)
      if (sum[p] >= l) break;
    if (r < s + 1)
      for (long long i = l; i <= r; i++) {
        if (i % 2 == 1)
          cout << p << ' ';
        else
          cout << p + (i - sum[p - 1]) / 2 << ' ';
        if (i == sum[p]) p++;
      }
    else {
      for (long long i = l; i < r; i++) {
        if (i % 2 == 1)
          cout << p << ' ';
        else
          cout << p + (i - sum[p - 1]) / 2 << ' ';
        if (i == sum[p]) p++;
      }
      cout << 1;
    }
    puts("");
  }
  return 0;
}

```