1078_B. The Unbearable Lightness of Weights

You have a set of n weights. You know that their masses are a_1, a_2, ..., a_n grams, but you don't know which of them has which mass. You can't distinguish the weights.

However, your friend does know the mass of each weight. You can ask your friend to give you exactly k weights with the total mass m (both parameters k and m are chosen by you), and your friend will point to any valid subset of weights, if it is possible.

You are allowed to make this query only once. Find the maximum possible number of weights you can reveal after this query.

Input

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

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 100) — the masses of the weights.

Output

Print the maximum number of weights you can learn the masses for after making a single query.

Examples

Input

4
1 4 2 2

Output

2

Input

6
1 2 4 4 4 9

Output

2

Note

In the first example we can ask for a subset of two weights with total mass being equal to 4, and the only option is to get \{2, 2\}.

Another way to obtain the same result is to ask for a subset of two weights with the total mass of 5 and get \{1, 4\}. It is easy to see that the two remaining weights have mass of 2 grams each.

In the second example we can ask for a subset of two weights with total mass being 8, and the only answer is \{4, 4\}. We can prove it is not possible to learn masses for three weights in one query, but we won't put the proof here.

```python
from collections import defaultdict

def calcBinomials(N):
    global binom
    N += 1
    binom = [[0]*N for _ in range(N)]
    for n in range(N):
        binom[n][0] = binom[n][n] = 1
        for k in range(1, n):
            binom[n][k] = binom[n-1][k] + binom[n-1][k-1]

n = int(input())
a = list(map(int, input().split()))
S, res = sum(a), 0
dp = [defaultdict(lambda: 0) for _ in range(S+1)]
dp[0][0] = 1

cnt = {_:a.count(_) for _ in a}
for x in a:
    for i in range(len(dp)-1-x, -1, -1):
        for k, v in dp[i].items():
            dp[i+x][k+1] += v

calcBinomials(n)
for x, c in cnt.items():
    for i in range(1, c+1):
        if dp[x*i][i] == binom[c][i] or dp[S - x*i][n-i] == binom[c][c-i]:
            res = max(res, i)
if len(cnt) <= 2: res = n
print(res)

```


1099_B. Squares and Segments

Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw n squares in the snow with a side length of 1. For simplicity, we assume that Sofia lives on a plane and can draw only segments of length 1, parallel to the coordinate axes, with vertices at integer points.

In order to draw a segment, Sofia proceeds as follows. If she wants to draw a vertical segment with the coordinates of the ends (x, y) and (x, y+1). Then Sofia looks if there is already a drawn segment with the coordinates of the ends (x', y) and (x', y+1) for some x'. If such a segment exists, then Sofia quickly draws a new segment, using the old one as a guideline. If there is no such segment, then Sofia has to take a ruler and measure a new segment for a long time. Same thing happens when Sofia wants to draw a horizontal segment, but only now she checks for the existence of a segment with the same coordinates x, x+1 and the differing coordinate y.

For example, if Sofia needs to draw one square, she will have to draw two segments using a ruler:

<image>

After that, she can draw the remaining two segments, using the first two as a guide:

<image>

If Sofia needs to draw two squares, she will have to draw three segments using a ruler:

<image>

After that, she can draw the remaining four segments, using the first three as a guide:

<image>

Sofia is in a hurry, so she wants to minimize the number of segments that she will have to draw with a ruler without a guide. Help her find this minimum number.

Input

The only line of input contains a single integer n (1 ≤ n ≤ 10^{9}), the number of squares that Sofia wants to draw.

Output

Print single integer, the minimum number of segments that Sofia will have to draw with a ruler without a guide in order to draw n squares in the manner described above.

Examples

Input

1

Output

2

Input

2

Output

3

Input

4

Output

4

```python
# cook your dish here
t=int(input())
l=int(t**(0.5))
if l==(t**(0.5)):
    print(2*l)
else:
    if abs((l**2)-t) < ((l+1)**2)-t:
        print(2*l+1)
    else:
        print(2*(l+1))
```


111_A. Petya and Inequiations

Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:

  * a12 + a22 + ... + an2 ≥ x
  * a1 + a2 + ... + an ≤ y

Input

The first line contains three space-separated integers n, x and y (1 ≤ n ≤ 105, 1 ≤ x ≤ 1012, 1 ≤ y ≤ 106).

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

Output

Print n positive integers that satisfy the conditions, one integer per line. If such numbers do not exist, print a single number "-1". If there are several solutions, print any of them.

Examples

Input

5 15 15

Output

4
4
1
1
2

Input

2 3 2

Output

-1

Input

1 99 11

Output

11

```python
from math import sqrt, ceil
n, x, y = map(int, input().split())
t = 1 if x < n else ceil(sqrt(x - n + 1))
if t + n - 1 > y: print(-1)
else: print(str(t), '\n1' * (n - 1))
```


1167_F. Scalar Queries

You are given an array a_1, a_2, ..., a_n. All a_i are pairwise distinct.

Let's define function f(l, r) as follows:

  * let's define array b_1, b_2, ..., b_{r - l + 1}, where b_i = a_{l - 1 + i};
  * sort array b in increasing order;
  * result of the function f(l, r) is ∑_{i = 1}^{r - l + 1}{b_i ⋅ i}.

Calculate \left(∑_{1 ≤ l ≤ r ≤ n}{f(l, r)}\right) mod (10^9+7), i.e. total sum of f for all subsegments of a modulo 10^9+7.

Input

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

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9, a_i ≠ a_j for i ≠ j) — array a.

Output

Print one integer — the total sum of f for all subsegments of a modulo 10^9+7

Examples

Input

4
5 2 4 7

Output

167

Input

3
123456789 214365879 987654321

Output

582491518

Note

Description of the first example:

  * f(1, 1) = 5 ⋅ 1 = 5;
  * f(1, 2) = 2 ⋅ 1 + 5 ⋅ 2 = 12;
  * f(1, 3) = 2 ⋅ 1 + 4 ⋅ 2 + 5 ⋅ 3 = 25;
  * f(1, 4) = 2 ⋅ 1 + 4 ⋅ 2 + 5 ⋅ 3 + 7 ⋅ 4 = 53;
  * f(2, 2) = 2 ⋅ 1 = 2;
  * f(2, 3) = 2 ⋅ 1 + 4 ⋅ 2 = 10;
  * f(2, 4) = 2 ⋅ 1 + 4 ⋅ 2 + 7 ⋅ 3 = 31;
  * f(3, 3) = 4 ⋅ 1 = 4;
  * f(3, 4) = 4 ⋅ 1 + 7 ⋅ 2 = 18;
  * f(4, 4) = 7 ⋅ 1 = 7;

```python
import sys

MOD = (int)(1e9+7)

def add(a, b):
	a += b
	if a >= MOD: a -= MOD
	return a

def mul(a, b):
	return (a * b) % MOD

class fenwickTree:
	def __init__(self, max_val):
		self.max_val = max_val + 5
		self.tree = [0] * self.max_val

	def update(self, idx, value):
		idx += 1
		while idx < self.max_val:
			self.tree[idx] = add(self.tree[idx], value)
			idx += (idx & (-idx))

	def read(self, idx):
		idx += 1
		res = 0
		while idx > 0:
			res = add(res, self.tree[idx])
			idx -= (idx & (-idx))
		return res

inp = [int(x) for x in sys.stdin.read().split()]

n = inp[0]
a = []
for i in range(1, n + 1):
	a.append(inp[i])

sorted_array = sorted(a)
dict = {}
for i in range(n):
	dict[sorted_array[i]] = i

factor = [0] * n
for i in range(0, n):
	factor[i] = mul(i + 1, n - i)

left_tree = fenwickTree(n)
for i in range(0, n):
	element_idx = dict[a[i]]
	factor[i] = add(factor[i], mul(n - i, left_tree.read(element_idx)))
	left_tree.update(element_idx, i + 1)

right_tree = fenwickTree(n)
for i in range(n - 1, -1, -1):
	element_idx = dict[a[i]]
	factor[i] = add(factor[i], mul(i + 1, right_tree.read(element_idx)))
	right_tree.update(element_idx, n - i)

ans = 0
for i in range(n):
	ans = add(ans, mul(a[i], factor[i]))
print(ans)

```


1186_A. Vus the Cossack and a Contest

Vus the [Cossack](https://en.wikipedia.org/wiki/Cossacks) holds a programming competition, in which n people participate. He decided to award them all with pens and notebooks. It is known that Vus has exactly m pens and k notebooks.

Determine whether the Cossack can reward all participants, giving each of them at least one pen and at least one notebook.

Input

The first line contains three integers n, m, and k (1 ≤ n, m, k ≤ 100) — the number of participants, the number of pens, and the number of notebooks respectively.

Output

Print "Yes" if it possible to reward all the participants. Otherwise, print "No".

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

Examples

Input

5 8 6

Output

Yes

Input

3 9 3

Output

Yes

Input

8 5 20

Output

No

Note

In the first example, there are 5 participants. The Cossack has 8 pens and 6 notebooks. Therefore, he has enough pens and notebooks.

In the second example, there are 3 participants. The Cossack has 9 pens and 3 notebooks. He has more than enough pens but only the minimum needed number of notebooks.

In the third example, there are 8 participants but only 5 pens. Since the Cossack does not have enough pens, the answer is "No".

```python
def solve(n, m, k):
    if min(m,k) >= n:
        return "Yes"
    else:
        return "No"

def main():
    n, m, k = list(map(int, input().split()))
    print(solve(n, m, k))

if __name__ == '__main__':
    main()
```


1205_A. Almost Equal

You are given integer n. You have to arrange numbers from 1 to 2n, using each of them exactly once, on the circle, so that the following condition would be satisfied:

For every n consecutive numbers on the circle write their sum on the blackboard. Then any two of written on the blackboard 2n numbers differ not more than by 1.

For example, choose n = 3. On the left you can see an example of a valid arrangement: 1 + 4 + 5 = 10, 4 + 5 + 2 = 11, 5 + 2 + 3 = 10, 2 + 3 + 6 = 11, 3 + 6 + 1 = 10, 6 + 1 + 4 = 11, any two numbers differ by at most 1. On the right you can see an invalid arrangement: for example, 5 + 1 + 6 = 12, and 3 + 2 + 4 = 9, 9 and 12 differ more than by 1.

<image>

Input

The first and the only line contain one integer n (1 ≤ n ≤ 10^5).

Output

If there is no solution, output "NO" in the first line.

If there is a solution, output "YES" in the first line. In the second line output 2n numbers — numbers from 1 to 2n in the order they will stay in the circle. Each number should appear only once. If there are several solutions, you can output any of them.

Examples

Input

3

Output

YES
1 4 5 2 3 6

Input

4

Output

NO

Note

Example from the statement is shown for the first example.

It can be proved that there is no solution in the second example.

```python
n = int(input())
if n%2 == 0:
    print("NO")
    exit(0)

arr = []
for i in range(1, n+1):
    if i%2 == 1:
        arr.append(2*i-1)
    else:
        arr.append(2*i)

for i in range(n):
    if arr[i] % 2 == 1:
        arr.append(arr[i]+1)
    else:
        arr.append(arr[i]-1)

print("YES")
print(*arr)
```


1221_E. Game With String

Alice and Bob play a game. Initially they have a string s_1, s_2, ..., s_n, consisting of only characters . and X. They take alternating turns, and Alice is moving first. During each turn, the player has to select a contiguous substring consisting only of characters . and replaces each of them with X. Alice must select a substing of length a, and Bob must select a substring of length b. It is guaranteed that a > b.

For example, if s = ...X.. and a = 3, b = 2, then after Alice's move string can turn only into XXXX... And if it's Bob's turn and the string s = ...X.., then after Bob's move the string can turn into XX.X.., .XXX.. or ...XXX.

Whoever is unable to make a move, loses. You have to determine who wins if they both play optimally.

You have to answer q independent queries.

Input

The first line contains one integer q (1 ≤ q ≤ 3 ⋅ 10^5) — the number of queries.

The first line of each query contains two integers a and b (1 ≤ b < a ≤ 3 ⋅ 10^5).

The second line of each query contains the string s (1 ≤ |s| ≤ 3 ⋅ 10^5), consisting of only characters . and X.

It is guaranteed that sum of all |s| over all queries not exceed 3 ⋅ 10^5.

Output

For each test case print YES if Alice can win and NO otherwise.

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

Example

Input

3
3 2
XX......XX...X
4 2
X...X.X..X
5 3
.......X..X

Output

YES
NO
YES

Note

In the first query Alice can select substring s_3 ... s_5. After that s turns into XXXXX...XX...X. After that, no matter what move Bob makes, Alice can make the move (this will be her second move), but Bob can't make his second move.

In the second query Alice can not win because she cannot even make one move.

In the third query Alice can choose substring s_2 ... s_6. After that s turns into .XXXXX.X..X, and Bob can't make a move after that.

```python
q = int(input())
for i in range(q):
    a, b = [int(item) for item in input().split()]
    s = input().rstrip() + "#"
    cnt = 0
    bob_world = 0
    alice_world = 0
    length = 0
    bob_winning = False
    for ch in s:
        if ch == ".":
            cnt += 1
        else:
            if cnt < b:
                pass
            elif b <= cnt < a:
                bob_winning = True
                break
            elif a <= cnt < b * 2:
                alice_world += 1
            elif cnt >= b * 2:
                length = cnt
                bob_world += 1
                if bob_world >= 2:
                    bob_winning = True
                    break
            cnt = 0
    if bob_winning:
        print("No")
    else:
        if length == 0:
            if alice_world % 2 == 1:
                print("Yes")
            else:
                print("No")
            continue
        possibility = set()
        for i in range(length - a + 1):
            l = i; r = length - a - i
            if b <= l < a or b <= r < a:
                continue
            if l >= b * 2 or r >= b * 2:
                continue
            val = 0
            if a <= l < b * 2:
                val += 1
            if a <= r < b * 2:
                val += 1
            possibility.add(val + 1)
        alice_win = False
        for item in possibility:
            if (alice_world + item) % 2 == 1:
                alice_win = True
        if alice_win:
            print("Yes")
        else:
            print("No")
```


1248_B. Grow The Tree

Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to grow a tree from them.

The tree looks like a polyline on the plane, consisting of all sticks. The polyline starts at the point (0, 0). While constructing the polyline, Alexey will attach sticks to it one by one in arbitrary order. Each stick must be either vertical or horizontal (that is, parallel to OX or OY axis). It is not allowed for two consecutive sticks to be aligned simultaneously horizontally or simultaneously vertically. See the images below for clarification.

Alexey wants to make a polyline in such a way that its end is as far as possible from (0, 0). Please help him to grow the tree this way.

Note that the polyline defining the form of the tree may have self-intersections and self-touches, but it can be proved that the optimal answer does not contain any self-intersections or self-touches.

Input

The first line contains an integer n (1 ≤ n ≤ 100 000) — the number of sticks Alexey got as a present.

The second line contains n integers a_1, …, a_n (1 ≤ a_i ≤ 10 000) — the lengths of the sticks.

Output

Print one integer — the square of the largest possible distance from (0, 0) to the tree end.

Examples

Input

3
1 2 3

Output

26

Input

4
1 1 2 2

Output

20

Note

The following pictures show optimal trees for example tests. The squared distance in the first example equals 5 ⋅ 5 + 1 ⋅ 1 = 26, and in the second example 4 ⋅ 4 + 2 ⋅ 2 = 20.

<image> <image>

```python
a=int(input());b=sorted(list(map(int,input().split())),reverse=True);from math import ceil as c;print(sum(b[:c(len(b)/2)])**2+sum(b[c(len(b)/2):])**2)

```


1288_A. Deadline

Adilbek was assigned to a special project. For Adilbek it means that he has n days to run a special program and provide its results. But there is a problem: the program needs to run for d days to calculate the results.

Fortunately, Adilbek can optimize the program. If he spends x (x is a non-negative integer) days optimizing the program, he will make the program run in \left⌈ (d)/(x + 1) \right⌉ days (\left⌈ a \right⌉ is the ceiling function: \left⌈ 2.4 \right⌉ = 3, \left⌈ 2 \right⌉ = 2). The program cannot be run and optimized simultaneously, so the total number of days he will spend is equal to x + \left⌈ (d)/(x + 1) \right⌉.

Will Adilbek be able to provide the generated results in no more than n days?

Input

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

The next T lines contain test cases – one per line. Each line contains two integers n and d (1 ≤ n ≤ 10^9, 1 ≤ d ≤ 10^9) — the number of days before the deadline and the number of days the program runs.

Output

Print T answers — one per test case. For each test case print YES (case insensitive) if Adilbek can fit in n days or NO (case insensitive) otherwise.

Example

Input

3
1 1
4 5
5 11

Output

YES
YES
NO

Note

In the first test case, Adilbek decides not to optimize the program at all, since d ≤ n.

In the second test case, Adilbek can spend 1 day optimizing the program and it will run \left⌈ 5/2 \right⌉ = 3 days. In total, he will spend 4 days and will fit in the limit.

In the third test case, it's impossible to fit in the limit. For example, if Adilbek will optimize the program 2 days, it'll still work \left⌈ (11)/(2+1) \right⌉ = 4 days.

```python
import math
for _ in range(int(input())):
    n,d = map(int,input().split())

    if ((1-n)**2) - (4*(d-n)) >= 0:
        print('YES')
    else:
        print('NO')

```


1331_D. Again?

Input

The only line of the input contains a 7-digit hexadecimal number. The first "digit" of the number is letter A, the rest of the "digits" are decimal digits 0-9.

Output

Output a single integer.

Examples

Input

A278832

Output

0

Input

A089956

Output

0

Input

A089957

Output

1

Input

A144045

Output

1

```python
value = input()

print(int(value, 16)%2)
```


1351_B. Square?

Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a square. In other words, check if it is possible to make a square using two given rectangles.

Input

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

Each test case is given in two lines.

The first line contains two integers a_1 and b_1 (1 ≤ a_1, b_1 ≤ 100) — the dimensions of the first one obtained after cutting rectangle. The sizes are given in random order (that is, it is not known which of the numbers is the width, and which of the numbers is the length).

The second line contains two integers a_2 and b_2 (1 ≤ a_2, b_2 ≤ 100) — the dimensions of the second obtained after cutting rectangle. The sizes are given in random order (that is, it is not known which of the numbers is the width, and which of the numbers is the length).

Output

Print t answers, each of which is a string "YES" (in the case of a positive answer) or "NO" (in the case of a negative answer). The letters in words can be printed in any case (upper or lower).

Example

Input

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

Output

Yes
Yes
No

```python
for t in range(int(input())):
   a, b = map(int, input().split())
   c, d = map(int, input().split())
   a, b = min(a, b), max(a, b)
   c, d = min(c, d), max(c, d)
   if a + c == b == d:
      print("YES")
   else:
      print("NO")

```


1371_D. Grid-00100

A mad scientist Dr.Jubal has made a competitive programming task. Try to solve it!

You are given integers n,k. Construct a grid A with size n × n consisting of integers 0 and 1. The very important condition should be satisfied: the sum of all elements in the grid is exactly k. In other words, the number of 1 in the grid is equal to k.

Let's define:

  * A_{i,j} as the integer in the i-th row and the j-th column.
  * R_i = A_{i,1}+A_{i,2}+...+A_{i,n} (for all 1 ≤ i ≤ n).
  * C_j = A_{1,j}+A_{2,j}+...+A_{n,j} (for all 1 ≤ j ≤ n).
  * In other words, R_i are row sums and C_j are column sums of the grid A.
  * For the grid A let's define the value f(A) = (max(R)-min(R))^2 + (max(C)-min(C))^2 (here for an integer sequence X we define max(X) as the maximum value in X and min(X) as the minimum value in X).

Find any grid A, which satisfies the following condition. Among such grids find any, for which the value f(A) is the minimum possible. Among such tables, you can find any.

Input

The input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. Next t lines contain descriptions of test cases.

For each test case the only line contains two integers n, k (1 ≤ n ≤ 300, 0 ≤ k ≤ n^2).

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

Output

For each test case, firstly print the minimum possible value of f(A) among all tables, for which the condition is satisfied.

After that, print n lines contain n characters each. The j-th character in the i-th line should be equal to A_{i,j}.

If there are multiple answers you can print any.

Example

Input

4
2 2
3 8
1 0
4 16

Output

0
10
01
2
111
111
101
0
0
0
1111
1111
1111
1111

Note

In the first test case, the sum of all elements in the grid is equal to 2, so the condition is satisfied. R_1 = 1, R_2 = 1 and C_1 = 1, C_2 = 1. Then, f(A) = (1-1)^2 + (1-1)^2 = 0, which is the minimum possible value of f(A).

In the second test case, the sum of all elements in the grid is equal to 8, so the condition is satisfied. R_1 = 3, R_2 = 3, R_3 = 2 and C_1 = 3, C_2 = 2, C_3 = 3. Then, f(A) = (3-2)^2 + (3-2)^2 = 2. It can be proven, that it is the minimum possible value of f(A).

```python
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
#######################################
t=int(input())
for i in range(t):
    n,k=map(int,input().split())
    a=k//n
    b=k%n
    l=[[0 for j in range(n)] for p in range(n)]
    x=0
    c=n-b
    if k!=0:
        for j in range(n):
            if c>0:
                for p in range(x,x+a):
                    l[j][p%n]=1
                c-=1
            else:
                for p in range(x,x+a+1):
                    l[j][p%n]=1
            x+=1
            x%=n
        if k%n:
            ans=2
        else:
            ans=0
    else:
        ans=0
    print(ans)
    for j in l:
        print(*j,sep='')

```


1394_A. Boboniu Chats with Du

Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.

In Boboniu's chat group, there's a person called Du Yi who likes to make fun of Boboniu every day.

Du will chat in the group for n days. On the i-th day:

  * If Du can speak, he'll make fun of Boboniu with fun factor a_i. But after that, he may be muzzled depending on Boboniu's mood.
  * Otherwise, Du won't do anything.

Boboniu's mood is a constant m. On the i-th day:

  * If Du can speak and a_i>m, then Boboniu will be angry and muzzle him for d days, which means that Du won't be able to speak on the i+1, i+2, ⋅⋅⋅, min(i+d,n)-th days.
  * Otherwise, Boboniu won't do anything.

The total fun factor is the sum of the fun factors on the days when Du can speak.

Du asked you to find the maximum total fun factor among all possible permutations of a.

Input

The first line contains three integers n, d and m (1≤ d≤ n≤ 10^5,0≤ m≤ 10^9).

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

Output

Print one integer: the maximum total fun factor among all permutations of a.

Examples

Input

5 2 11
8 10 15 23 5

Output

48

Input

20 2 16
20 5 8 2 18 16 2 16 16 1 5 16 2 13 6 16 4 17 21 7

Output

195

Note

In the first example, you can set a'=[15, 5, 8, 10, 23]. Then Du's chatting record will be:

  1. Make fun of Boboniu with fun factor 15.
  2. Be muzzled.
  3. Be muzzled.
  4. Make fun of Boboniu with fun factor 10.
  5. Make fun of Boboniu with fun factor 23.

Thus the total fun factor is 48.

```python
#! /usr/bin/python3

n, d, m = [int(inp) for inp in input().split()]
aArr = sorted([int(inp) for inp in input().split()], reverse = True)

i = sum([j > m for j in aArr])

aU = aArr[:i]
aL = aArr[i:]

aUS = aU
for i in range(1, len(aU)):
	aUS[i] += aUS[i - 1]
aUS = [0] + aUS

aLS = aL
for i in range(1, len(aL)):
	aLS[i] += aLS[i - 1]
aLS = [0] + aLS

fromU = min(1 + (n - 1)//(d + 1), len(aU))

maxFun = aUS[0] + aLS[-1]

for j in range(1, fromU + 1):
	newFun = aUS[j] + aLS[min(max(0, n - 1 - (j - 1)*(d + 1)), len(aL))]
	if newFun > maxFun:
		maxFun = newFun

print(maxFun)
```


1436_E. Complicated Computations

In this problem MEX of a certain array is the smallest positive integer not contained in this array.

Everyone knows this definition, including Lesha. But Lesha loves MEX, so he comes up with a new problem involving MEX every day, including today.

You are given an array a of length n. Lesha considers all the non-empty subarrays of the initial array and computes MEX for each of them. Then Lesha computes MEX of the obtained numbers.

An array b is a subarray of an array a, if b can be obtained from a by deletion of several (possible none or all) elements from the beginning and several (possibly none or all) elements from the end. In particular, an array is a subarray of itself.

Lesha understands that the problem is very interesting this time, but he doesn't know how to solve it. Help him and find the MEX of MEXes of all the subarrays!

Input

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

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

Output

Print a single integer — the MEX of MEXes of all subarrays.

Examples

Input

3
1 3 2

Output

3

Input

5
1 4 3 1 2

Output

6

```python
class SegmentTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        self.range = [(-1,n)] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
            self.range[self.num + i] = (i,i)
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])
            self.range[i] = (self.range[2 * i][0],self.range[2 * i + 1][1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

    def bisect_l(self,l,r,x):
        l += self.num
        r += self.num
        Lmin = -1
        Rmin = -1
        while l<r:
            if l & 1:
                if self.tree[l] <= x and Lmin==-1:
                    Lmin = l
                l += 1
            if r & 1:
                if self.tree[r-1] <=x:
                    Rmin = r-1
            l >>= 1
            r >>= 1

        if Lmin != -1:
            pos = Lmin
            while pos<self.num:
                if self.tree[2 * pos] <=x:
                    pos = 2 * pos
                else:
                    pos = 2 * pos +1
            return pos-self.num
        elif Rmin != -1:
            pos = Rmin
            while pos<self.num:
                if self.tree[2 * pos] <=x:
                    pos = 2 * pos
                else:
                    pos = 2 * pos +1
            return pos-self.num
        else:
            return -1

n = int(input())
p = list(map(int,input().split()))

pos = [[] for i in range(n+2)]
for i in range(n):
    pos[p[i]].append(i)

query = [[] for i in range(n)]

for i in range(1,n+2):
    for j in range(len(pos[i])-1):
        L = pos[i][j] + 1
        R = pos[i][j+1] - 1
        if L<=R:
            query[R].append((L,i))
    if pos[i]:
        if pos[i][0]!=0:
            query[pos[i][0]-1].append((0,i))
        if pos[i][-1]!=n-1:
            query[n-1].append((pos[i][-1]+1,i))
    else:
        query[n-1].append((0,i))

#print(query)

flag = [False for i in range(n+3)]

init = [-1]*(n+2)
init[0] = n
lastappeared = SegmentTree(init,min,-1)
for i in range(n):
    lastappeared.update(p[i],i)
    for l,val in query[i]:
        check = lastappeared.bisect_l(0,n+2,l-1)
        #print(l,i,val,check)
        #pp = [lastappeared.tree[j+lastappeared.num] for j in range(n)]

        if check>=val or check==-1:
            flag[val] = True

for i in range(1,n+3):
    if not flag[i]:
        print(i)
        break
```


1461_C. Random Events

Ron is a happy owner of a permutation a of length n.

A permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).

<image>

Ron's permutation is subjected to m experiments of the following type: (r_i, p_i). This means that elements in range [1, r_i] (in other words, the prefix of length r_i) have to be sorted in ascending order with the probability of p_i. All experiments are performed in the same order in which they are specified in the input data.

As an example, let's take a look at a permutation [4, 2, 1, 5, 3] and an experiment (3, 0.6). After such an experiment with the probability of 60\% the permutation will assume the form [1, 2, 4, 5, 3] and with a 40\% probability it will remain unchanged.

You have to determine the probability of the permutation becoming completely sorted in ascending order after m experiments.

Input

Each test contains one or more test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100).

The first line of each test case contains two integers n and m (1 ≤ n, m ≤ 10^5) — the length of the permutation and the number of experiments, respectively.

The second line of each test case contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n) — contents of the permutation.

The following m lines of each test case each contain an integer r_i and a real number p_i (1 ≤ r_i ≤ n, 0 ≤ p_i ≤ 1) — the length of the prefix and the probability of it being sorted. All probabilities are given with at most 6 decimal places.

It is guaranteed that the sum of n and the sum of m does not exceed 10^5 (∑ n, ∑ m ≤ 10^5).

Output

For each test case, print a single number — the probability that after all experiments the permutation becomes sorted in ascending order. Your answer will be considered correct if its absolute or relative error does not exceed 10^{-6}.

Formally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if \frac{|a - b|}{max{(1, |b|)}} ≤ 10^{-6}.

Example

Input

4
4 3
4 3 2 1
1 0.3
3 1
4 0.6
5 3
4 2 1 3 5
3 0.8
4 0.6
5 0.3
6 5
1 3 2 4 5 6
4 0.9
5 0.3
2 0.4
6 0.7
3 0.5
4 2
1 2 3 4
2 0.5
4 0.1

Output

0.600000
0.720000
0.989500
1.000000

Note

Explanation of the first test case: It can be demonstrated that whether the final permutation is sorted or not depends solely on sorting being performed in the (4, 0.6) experiment.

```python
# by the authority of GOD     author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase

def main():
    for _ in range(int(input())):
        n,m = map(int,input().split())
        a = list(map(int,input().split()))
        j = n-1
        while j != -1 and a[j] == j+1:
            j -= 1
        if j == -1:
            for _ in range(m):
                x = input()
            print(1)
            continue
        ans = 0
        fac = 1
        for _ in range(m):
            r,p = map(float,input().split())
            r = int(r)
            if r >= j+1:
                ans += fac*p
                fac *= (1-p)
        print(ans)

#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()
```


1486_D. Max Median

You are a given an array a of length n. Find a subarray a[l..r] with length at least k with the largest median.

A median in an array of length n is an element which occupies position number ⌊ (n + 1)/(2) ⌋ after we sort the elements in non-decreasing order. For example: median([1, 2, 3, 4]) = 2, median([3, 2, 1]) = 2, median([2, 1, 2, 1]) = 1.

Subarray a[l..r] is a contiguous part of the array a, i. e. the array a_l,a_{l+1},…,a_r for some 1 ≤ l ≤ r ≤ n, its length is r - l + 1.

Input

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

The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ n).

Output

Output one integer m — the maximum median you can get.

Examples

Input

5 3
1 2 3 2 1

Output

2

Input

4 2
1 2 3 4

Output

3

Note

In the first example all the possible subarrays are [1..3], [1..4], [1..5], [2..4], [2..5] and [3..5] and the median for all of them is 2, so the maximum possible median is 2 too.

In the second example median([3..4]) = 3.

```python
import collections

def solveTestCase():
	n, k = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	r = n + 1
	l = 1
	while r - l > 1:
		m = (r+l)//2
		b = [1 if i >= m else -1 for i in a]
		for i in range(1, len(b)):
			b[i] += b[i - 1]
		ans = False
		if b[k-1] > 0:
			ans = True

		mm = 0
		for i in range(k, n):
			mm = min(mm, b[i-k])
			if b[i] - mm  > 0:
				ans = True
				break

		if ans:
			l = m
		else:
			r = m

	print(l)

if __name__ == "__main__":
	t = 1
	while t > 0:
		t -= 1
		solveTestCase()

```


1510_D. Digits

Diana loves playing with numbers. She's got n cards with positive integer numbers a_i written on them. She spends her free time multiplying the numbers on the cards. She picks a non-empty subset of the cards and multiplies all the numbers a_i written on them.

Diana is happy when the product of the numbers ends with her favorite digit d. Now she is curious what cards she should pick so that the product of the numbers on them is the largest possible and the last decimal digit of the product is d. Please, help her.

Input

The first line contains the integers n and d (1≤ n≤ 10^5, 0≤ d≤ 9). The second line contains n integers a_i (1≤ a_i≤ 1000).

Output

On the first line, print the number of chosen cards k (1≤ k≤ n). On the next line, print the numbers written on the chosen cards in any order.

If it is impossible to choose a subset of cards with the product that ends with the digit d, print the single line with -1.

Examples

Input

6 4
4 11 8 2 1 13

Output

5
1 2 4 11 13

Input

3 1
2 4 6

Output

-1

Input

5 7
1 3 1 5 3

Output

-1

Input

6 3
8 9 4 17 11 5

Output

3
9 11 17

Input

5 6
2 2 2 2 2

Output

4
2 2 2 2

Note

In the first example, 1 × 2 × 4 × 11 × 13 = 1144, which is the largest product that ends with the digit 4. The same set of cards without the number 1 is also a valid answer, as well as a set of 8, 11, and 13 with or without 1 that also has the product of 1144.

In the second example, all the numbers on the cards are even and their product cannot end with an odd digit 1.

In the third example, the only possible products are 1, 3, 5, 9, 15, and 45, none of which end with the digit 7.

In the fourth example, 9 × 11 × 17 = 1683, which ends with the digit 3.

In the fifth example, 2 × 2 × 2 × 2 = 16, which ends with the digit 6.

```python
import math;n, d = map(int, input().split());a = [int(_) for _ in input().split()];dp = [[-1e10] * 10 for _ in range(n + 1)]
come = [[(0, 0, 0) for i in range(10)] for j in range(n + 1)];dp[0][1] = 0
for i in range(n):
    for j in range(10):
        val = dp[i][j] + math.log(a[i])
        if dp[i + 1][(j * a[i]) % 10] <= val:            dp[i + 1][(j * a[i]) % 10] = val;            come[i + 1][(j * a[i]) % 10] = (i, j, 1)
        val = dp[i][j]
        if dp[i + 1][j] <= val:            dp[i + 1][j] = val;          come[i + 1][j] = (i, j, 0)
now = n;prod = 1;dig = d;soln = []
while now > 0:
    if come[now][dig][2] == 1:        soln.append(a[now - 1])
    now, dig = come[now][dig][:2]
for i in soln: prod = (prod * i) % 10
if prod == d and len(soln) > 0:    print(len(soln));  print(' '.join(map(str, soln)))
else:    print(-1)
```


1536_F. Omkar and Akmar

Omkar and Akmar are playing a game on a circular board with n (2 ≤ n ≤ 10^6) cells. The cells are numbered from 1 to n so that for each i (1 ≤ i ≤ n-1) cell i is adjacent to cell i+1 and cell 1 is adjacent to cell n. Initially, each cell is empty.

Omkar and Akmar take turns placing either an A or a B on the board, with Akmar going first. The letter must be placed on an empty cell. In addition, the letter cannot be placed adjacent to a cell containing the same letter.

A player loses when it is their turn and there are no more valid moves.

Output the number of possible distinct games where both players play optimally modulo 10^9+7. Note that we only consider games where some player has lost and there are no more valid moves.

Two games are considered distinct if the number of turns is different or for some turn, the letter or cell number that the letter is placed on were different.

A move is considered optimal if the move maximizes the player's chance of winning, assuming the other player plays optimally as well. More formally, if the player who has to move has a winning strategy, they have to make a move after which they will still have a winning strategy. If they do not, they can make any move.

Input

The only line will contain an integer n (2 ≤ n ≤ 10^6) — the number of cells on the board.

Output

Output a single integer — the number of possible distinct games where both players play optimally modulo 10^9+7.

Examples

Input

2

Output

4

Input

69420

Output

629909355

Input

42069

Output

675837193

Note

For the first sample case, the first player has 4 possible moves. No matter what the first player plays, the second player only has 1 possible move, so there are 4 possible games.

```python
import sys
input = sys.stdin.readline

n = int(input())
mod = 10 ** 9 + 7
F = [0] * (n + 1)
F[0] = 1
for i in range(1, n + 1):
    F[i] = i * F[i - 1] % mod
iF = [0] * (n + 1)
iF[-1] = pow(F[-1], mod - 2, mod)
for i in range(n - 1, -1, -1):
    iF[i] = iF[i + 1] * (i + 1) % mod

def C(n, k):
    if k > n: return 0
    return F[n] * iF[n - k] * iF[k] % mod

ans = 0
for x in range((n + 1) // 2, n + 1):
    if x % 2: continue
    if x < n: cur = (C(x, n - x) + C(x - 1, n - x - 1)) % mod
    else: cur = 1
    cur = (cur * 2 * F[x]) % mod
    ans = (ans + cur) % mod
print(ans)
```


185_A. Plant

Dwarfs have planted a very interesting plant, which is a triangle directed "upwards". This plant has an amusing feature. After one year a triangle plant directed "upwards" divides into four triangle plants: three of them will point "upwards" and one will point "downwards". After another year, each triangle plant divides into four triangle plants: three of them will be directed in the same direction as the parent plant, and one of them will be directed in the opposite direction. Then each year the process repeats. The figure below illustrates this process.

<image>

Help the dwarfs find out how many triangle plants that point "upwards" will be in n years.

Input

The first line contains a single integer n (0 ≤ n ≤ 1018) — the number of full years when the plant grew.

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

Print a single integer — the remainder of dividing the number of plants that will point "upwards" in n years by 1000000007 (109 + 7).

Examples

Input

1

Output

3

Input

2

Output

10

Note

The first test sample corresponds to the second triangle on the figure in the statement. The second test sample corresponds to the third one.

```python
n=int(input())

e=10**9+7

print(1if n==0else(pow(2,n-1,e)+pow(2,n*2-1,e))%e)

# Made By Mostafa_Khaled
```


231_B. Magic, Wizardry and Wonders

Vasya the Great Magician and Conjurer loves all kinds of miracles and wizardry. In one wave of a magic wand he can turn an object into something else. But, as you all know, there is no better magic in the Universe than the magic of numbers. That's why Vasya adores math and spends a lot of time turning some numbers into some other ones.

This morning he has n cards with integers lined up in front of him. Each integer is not less than 1, but not greater than l. When Vasya waves his magic wand, two rightmost cards vanish from the line and a new card magically appears in their place. It contains the difference between the left and the right numbers on the two vanished cards. Vasya was very interested to know what would happen next, and so he waved with his magic wand on and on, until the table had a single card left.

Suppose that Vasya originally had the following cards: 4, 1, 1, 3 (listed from left to right). Then after the first wave the line would be: 4, 1, -2, and after the second one: 4, 3, and after the third one the table would have a single card with number 1.

Please note that in spite of the fact that initially all the numbers on the cards were not less than 1 and not greater than l, the numbers on the appearing cards can be anything, no restrictions are imposed on them.

It is now evening. Vasya is very tired and wants to return everything back, but does not remember which cards he had in the morning. He only remembers that there were n cards, they contained integers from 1 to l, and after all magical actions he was left with a single card containing number d.

Help Vasya to recover the initial set of cards with numbers.

Input

The single line contains three space-separated integers: n (2 ≤ n ≤ 100) — the initial number of cards on the table, d (|d| ≤ 104) — the number on the card that was left on the table after all the magical actions, and l (1 ≤ l ≤ 100) — the limits for the initial integers.

Output

If Vasya is mistaken, that is, if there doesn't exist a set that meets the requirements given in the statement, then print a single number -1, otherwise print the sought set containing n integers from 1 to l. Separate the integers by spaces. Print the integers in the order, in which they were written on the cards from left to right. If there are several suitable sets of numbers, you can print any of them.

Examples

Input

3 3 2

Output

2 1 2

Input

5 -4 3

Output

-1

Input

5 -4 4

Output

2 4 1 4 1

```python
n, d, L = map(int, input().split())
sp = []
for _ in range(n - 1):
    if d <= 0:
        sp.append(1)
        d = 1 - d
    else:
        sp.append(L)
        d = L - d
if 1 <= d <= L:
    sp.append(d)
    print(*sp)
else:
    print(-1)

```


257_A. Sockets

Vasya has got many devices that work on electricity. He's got n supply-line filters to plug the devices, the i-th supply-line filter has ai sockets.

Overall Vasya has got m devices and k electrical sockets in his flat, he can plug the devices or supply-line filters directly. Of course, he can plug the supply-line filter to any other supply-line filter. The device (or the supply-line filter) is considered plugged to electricity if it is either plugged to one of k electrical sockets, or if it is plugged to some supply-line filter that is in turn plugged to electricity.

What minimum number of supply-line filters from the given set will Vasya need to plug all the devices he has to electricity? Note that all devices and supply-line filters take one socket for plugging and that he can use one socket to plug either one device or one supply-line filter.

Input

The first line contains three integers n, m, k (1 ≤ n, m, k ≤ 50) — the number of supply-line filters, the number of devices and the number of sockets that he can plug to directly, correspondingly. The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 50) — number ai stands for the number of sockets on the i-th supply-line filter.

Output

Print a single number — the minimum number of supply-line filters that is needed to plug all the devices to electricity. If it is impossible to plug all the devices even using all the supply-line filters, print -1.

Examples

Input

3 5 3
3 1 2

Output

1

Input

4 7 2
3 3 2 4

Output

2

Input

5 5 1
1 3 1 2 1

Output

-1

Note

In the first test case he can plug the first supply-line filter directly to electricity. After he plug it, he get 5 (3 on the supply-line filter and 2 remaining sockets for direct plugging) available sockets to plug. Thus, one filter is enough to plug 5 devices.

One of the optimal ways in the second test sample is to plug the second supply-line filter directly and plug the fourth supply-line filter to one of the sockets in the second supply-line filter. Thus, he gets exactly 7 sockets, available to plug: one to plug to the electricity directly, 2 on the second supply-line filter, 4 on the fourth supply-line filter. There's no way he can plug 7 devices if he use one supply-line filter.

```python
n,m,k=map(int,input().split(" "))
li=list(map(int,input().split(" ",n)[:n]))
li.sort(reverse=True)
fl=0
a,s=0,0
if m<=k:
    print(0)
else:
    while fl==0 and a<n:
        s+=li[a]
        a+=1
        if a!=1:
            s-=1
        if s+k-1>=m and a!=0:
            fl=1
            break
    if fl!=1:
        print(-1)
    else:
        print(a)

```


280_A. Rectangle Puzzle

You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of the side that is parallel to the Ox axis, equals w, the length of the side that is parallel to the Oy axis, equals h. The second rectangle can be obtained by rotating the first rectangle relative to the origin of coordinates by angle α.

<image>

Your task is to find the area of the region which belongs to both given rectangles. This region is shaded in the picture.

Input

The first line contains three integers w, h, α (1 ≤ w, h ≤ 106; 0 ≤ α ≤ 180). Angle α is given in degrees.

Output

In a single line print a real number — the area of the region which belongs to both given rectangles.

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

Examples

Input

1 1 45

Output

0.828427125

Input

6 4 30

Output

19.668384925

Note

The second sample has been drawn on the picture above.

```python
from math import radians, cos, sin, atan2

def rotate(point, alpha):
    x = point[0]
    y = point[1]
    return (x * cos(alpha) - y * sin(alpha), x * sin(alpha) + y * cos(alpha))

def crs(a, b):
    return a[0] * b[1] - a[1] * b[0]

def m(end, start):
    return (end[0] - start[0], end[1] - start[1])

def area(poly):
    ret = 0
    n = len(poly)

    for i in range(n):
        j = (i + 1) % n
        ret += crs(poly[i], poly[j])

    return abs(ret) / 2.0

def intersect(a, b, c, d):
    r = crs(m(c, d), m(a, d)) * crs(m(c, d), m(b, d)) <= 0
    r &= crs(m(b, a), m(c, a)) * crs(m(b, a), m(d, a)) <= 0
    if not r:
        return None

    x1 = a[0]
    y1 = a[1]

    x2 = c[0]
    y2 = c[1]

    dx1 = b[0] - a[0]
    dx2 = d[0] - c[0]

    dy1 = b[1] - a[1]
    dy2 = d[1] - c[1]

    if dx2 * dy1 == dx1 * dy2:
        return None

    t = ((x1 - x2) * dy2 + (y2 - y1) * dx2) / (dx2 * dy1 - dx1 * dy2)
    return (x1 + t * dx1, y1 + t * dy1)

w, h, alpha = map(int, input().split())

if alpha == 0 or alpha == 180:
    print(w * h)
else:
    alpha = radians(alpha)
    pnt = []

    pnt.append((w / 2, h / 2))
    pnt.append((-w / 2, h / 2))
    pnt.append((-w / 2, -h / 2))
    pnt.append((w / 2, -h / 2))

    pnt2 = []
    for p in pnt:
        pnt2.append(rotate(p, alpha))

    pnt2.append(pnt2[0])
    pnt.append(pnt[0])

    points_total = []

    for st in range(4):
        for en in range(4):
            t = intersect(pnt[st], pnt[st + 1], pnt2[en], pnt2[en + 1])

            if t != None:
                points_total.append(t)

    points_total = sorted(points_total, key=lambda x: atan2(x[1], x[0]))

    print(area(points_total))

```


32_A. Reconnaissance

According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are of the same height. Bob wants to know, how many ways exist to form a reconnaissance unit of two soldiers from his detachment.

Ways (1, 2) and (2, 1) should be regarded as different.

Input

The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.

Output

Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.

Examples

Input

5 10
10 20 50 60 65

Output

6

Input

5 1
55 30 29 31 55

Output

6

```python
n, d = [int(i) for i in input().split()]
S = sorted([int(i) for i in input().split()])
k = 0
for i in range(n):
    for j in range(i+1, n):
        if(S[j]-S[i]<=d):
            k += 1
        else:
            break
print(k*2)
```


397_B. On Corruption and Numbers

Alexey, a merry Berland entrant, got sick of the gray reality and he zealously wants to go to university. There are a lot of universities nowadays, so Alexey is getting lost in the diversity — he has not yet decided what profession he wants to get. At school, he had bad grades in all subjects, and it's only thanks to wealthy parents that he was able to obtain the graduation certificate.

The situation is complicated by the fact that each high education institution has the determined amount of voluntary donations, paid by the new students for admission — ni berubleys. He cannot pay more than ni, because then the difference between the paid amount and ni can be regarded as a bribe!

Each rector is wearing the distinctive uniform of his university. Therefore, the uniform's pockets cannot contain coins of denomination more than ri. The rector also does not carry coins of denomination less than li in his pocket — because if everyone pays him with so small coins, they gather a lot of weight and the pocket tears. Therefore, a donation can be paid only by coins of denomination x berubleys, where li ≤ x ≤ ri (Berland uses coins of any positive integer denomination). Alexey can use the coins of different denominations and he can use the coins of the same denomination any number of times. When Alexey was first confronted with such orders, he was puzzled because it turned out that not all universities can accept him! Alexey is very afraid of going into the army (even though he had long wanted to get the green uniform, but his dad says that the army bullies will beat his son and he cannot pay to ensure the boy's safety). So, Alexey wants to know for sure which universities he can enter so that he could quickly choose his alma mater.

Thanks to the parents, Alexey is not limited in money and we can assume that he has an unlimited number of coins of each type.

In other words, you are given t requests, each of them contains numbers ni, li, ri. For each query you need to answer, whether it is possible to gather the sum of exactly ni berubleys using only coins with an integer denomination from li to ri berubleys. You can use coins of different denominations. Coins of each denomination can be used any number of times.

Input

The first line contains the number of universities t, (1 ≤ t ≤ 1000) Each of the next t lines contain three space-separated integers: ni, li, ri (1 ≤ ni, li, ri ≤ 109; li ≤ ri).

Output

For each query print on a single line: either "Yes", if Alexey can enter the university, or "No" otherwise.

Examples

Input

2
5 2 3
6 4 5

Output

Yes
No

Note

You can pay the donation to the first university with two coins: one of denomination 2 and one of denomination 3 berubleys. The donation to the second university cannot be paid.

```python
t = int(input())
for _ in range(t):
  n, l, r = map(int, input().split())
  print("No" if n // l * r < n else "Yes")
```


41_C. Email address

Sometimes one has to spell email addresses over the phone. Then one usually pronounces a dot as dot, an at sign as at. As a result, we get something like vasyaatgmaildotcom. Your task is to transform it into a proper email address (vasya@gmail.com).

It is known that a proper email address contains only such symbols as . @ and lower-case Latin letters, doesn't start with and doesn't end with a dot. Also, a proper email address doesn't start with and doesn't end with an at sign. Moreover, an email address contains exactly one such symbol as @, yet may contain any number (possible, zero) of dots.

You have to carry out a series of replacements so that the length of the result was as short as possible and it was a proper email address. If the lengths are equal, you should print the lexicographically minimal result.

Overall, two variants of replacement are possible: dot can be replaced by a dot, at can be replaced by an at.

Input

The first line contains the email address description. It is guaranteed that that is a proper email address with all the dots replaced by dot an the at signs replaced by at. The line is not empty and its length does not exceed 100 symbols.

Output

Print the shortest email address, from which the given line could be made by the described above replacements. If there are several solutions to that problem, print the lexicographically minimal one (the lexicographical comparison of the lines are implemented with an operator < in modern programming languages).

In the ASCII table the symbols go in this order: . @ ab...z

Examples

Input

vasyaatgmaildotcom

Output

vasya@gmail.com

Input

dotdotdotatdotdotat

Output

dot..@..at

Input

aatt

Output

a@t


446_A. DZY Loves Sequences

DZY has a sequence a, consisting of n integers.

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

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

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

Input

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

Output

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

Examples

Input

6
7 2 3 1 5 6

Output

5

Note

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

```python
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def msi(): return map(str,input().split())
def li(): return list(mi())

n=ii()
a=li()
pre,suf = [1]*n,[1]*n

for i in range(1,n):
    if a[i]>a[i-1]:
        pre[i]+=pre[i-1]

for i in range(n-2,-1,-1):
    if a[i]<a[i+1]:
        suf[i]+=suf[i+1]

ans=max(pre)
if ans<n:
    ans+=1

for i in range(1,n-1):
    if a[i+1]>a[i-1]+1:
        ans=max(ans,pre[i-1]+suf[i+1]+1)

print(ans)
```


468_B. Two Sets

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

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

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

Input

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

Output

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

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

Examples

Input

4 5 9
2 3 4 5

Output

YES
0 0 1 1

Input

3 3 4
1 2 4

Output

NO

Note

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

```python
import sys
import queue
sys.setrecursionlimit(100000)

# global constant
INF = int(1e7+1)
MAX = 100005

# For testing
#sys.stdin = open("INP.txt", 'r')
#sys.stdout = open("OUT.txt", 'w')

# global variables
parents = []
ranks = []
size = []
n = 0

# classes

class Pair:
    def __init__(self, a, b):
        self.first = a
        self.second = b

# functions
def init():
    global parents, ranks, size
    parents = [i for i in range(n+2)]
    ranks = [0 for i in range(n+2)]
    size = [1 for i in range(n+2)]

def findSet(u):
    if(parents[u] != u):
        parents[u] = findSet(parents[u])
    return parents[u]

def unionSet(u, v):
    up = findSet(u)
    vp = findSet(v)
    if up == vp:
        return
    if ranks[up] < ranks[vp]:
        parents[up] = vp
    elif ranks[vp] < ranks[up]:
        parents[vp] = up
    else:
        ranks[vp] += 1
        parents[up] = vp

# main function
def main():
    global n
    n, a, b = map(int, input().split())
    init()
    M = {}
    l = list(map(int, input().split()))
    Max = -1
    l.insert(0, -1)
    l.append(-1)
    for i in range(1, n+1):
        M[l[i]] = i
        parents[i] = i
        Max = max(Max, l[i])
    if Max >= a and Max >= b:
        print("NO")
        return

    for i in range(1, n+1):
        # print(l[i], a-l[i], b-l[i], (a-l[i] in M), (b-l[i]) in M)
        if (a-l[i]) in M:
            unionSet(M[a - l[i]], i)
        else:
            unionSet(i, n+1)
        if(b-l[i]) in M:
            unionSet(M[b-l[i]], i)
        else:
            unionSet(i, 0)
    A = findSet(0)
    B = findSet(n+1)
    """ for parent in parents:
        print(parent, end = ' ')
    print()
    print(A, B) """
    if(A == B):
        print("NO")
        return
    print("YES")
    for i in range(1, n+1):
        # print(l[i], findSet(l[i]))
        if (findSet(i) == A):
            print("%d" % (0), end=' ')
        else:
            print("%d" % (1), end=' ')

main()

```


490_B. Queue

During the lunch break all n Berland State University students lined up in the food court. However, it turned out that the food court, too, has a lunch break and it temporarily stopped working.

Standing in a queue that isn't being served is so boring! So, each of the students wrote down the number of the student ID of the student that stands in line directly in front of him, and the student that stands in line directly behind him. If no one stands before or after a student (that is, he is the first one or the last one), then he writes down number 0 instead (in Berland State University student IDs are numerated from 1).

After that, all the students went about their business. When they returned, they found out that restoring the queue is not such an easy task.

Help the students to restore the state of the queue by the numbers of the student ID's of their neighbors in the queue.

Input

The first line contains integer n (2 ≤ n ≤ 2·105) — the number of students in the queue.

Then n lines follow, i-th line contains the pair of integers ai, bi (0 ≤ ai, bi ≤ 106), where ai is the ID number of a person in front of a student and bi is the ID number of a person behind a student. The lines are given in the arbitrary order. Value 0 is given instead of a neighbor's ID number if the neighbor doesn't exist.

The ID numbers of all students are distinct. It is guaranteed that the records correspond too the queue where all the students stand in some order.

Output

Print a sequence of n integers x1, x2, ..., xn — the sequence of ID numbers of all the students in the order they go in the queue from the first student to the last one.

Examples

Input

4
92 31
0 7
31 0
7 141

Output

92 7 31 141

Note

The picture illustrates the queue for the first sample.

<image>

```python
import math
from collections import deque

class Empty(Exception):
    pass
class _DoublyLinkedBase:
  """A base class providing a doubly linked list representation."""

  #-------------------------- nested _Node class --------------------------
  # nested _Node class
  class _Node:
    """Lightweight, nonpublic class for storing a doubly linked node."""
    __slots__ = '_element', '_prev', '_next'            # streamline memory

    def __init__(self, element, prev, next):            # initialize node's fields
      self._element = element                           # user's element
      self._prev = prev                                 # previous node reference
      self._next = next                                 # next node reference

  #-------------------------- list constructor --------------------------

  def __init__(self):
    """Create an empty list."""
    self._header = self._Node(None, None, None)
    self._trailer = self._Node(None, None, None)
    self._header._next = self._trailer                  # trailer is after header
    self._trailer._prev = self._header                  # header is before trailer
    self._size = 0                                      # number of elements

  #-------------------------- public accessors --------------------------

  def __len__(self):
    """Return the number of elements in the list."""
    return self._size

  def is_empty(self):
    """Return True if list is empty."""
    return self._size == 0

  #-------------------------- nonpublic utilities --------------------------

  def _insert_between(self, e, predecessor, successor):
    """Add element e between two existing nodes and return new node."""
    newest = self._Node(e, predecessor, successor)      # linked to neighbors
    predecessor._next = newest
    successor._prev = newest
    self._size += 1
    return newest

  def _delete_node(self, node):
    """Delete nonsentinel node from the list and return its element."""
    predecessor = node._prev
    successor = node._next
    predecessor._next = successor
    successor._prev = predecessor
    self._size -= 1
    element = node._element                             # record deleted element
    node._prev = node._next = node._element = None      # deprecate node
    return element                                      # return deleted element
class LinkedDeque(_DoublyLinkedBase):         # note the use of inheritance
  """Double-ended queue implementation based on a doubly linked list."""

  def first(self):
    """Return (but do not remove) the element at the front of the deque.

    Raise Empty exception if the deque is empty.
    """
    if self.is_empty():
      raise Empty("Deque is empty")
    return self._header._next._element        # real item just after header

  def last(self):
    """Return (but do not remove) the element at the back of the deque.

    Raise Empty exception if the deque is empty.
    """
    if self.is_empty():
      raise Empty("Deque is empty")
    return self._trailer._prev._element       # real item just before trailer

  def insert_first(self, e):
    """Add an element to the front of the deque."""
    self._insert_between(e, self._header, self._header._next)   # after header

  def insert_last(self, e):
    """Add an element to the back of the deque."""
    self._insert_between(e, self._trailer._prev, self._trailer) # before trailer

  def delete_first(self):
    """Remove and return the element from the front of the deque.

    Raise Empty exception if the deque is empty.
    """
    if self.is_empty():
      raise Empty("Deque is empty")
    return self._delete_node(self._header._next)   # use inherited method

  def delete_last(self):
    """Remove and return the element from the back of the deque.

    Raise Empty exception if the deque is empty.
    """
    if self.is_empty():
      raise Empty("Deque is empty")
    return self._delete_node(self._trailer._prev)  # use inherited method
class PositionalList(_DoublyLinkedBase):
  """A sequential container of elements allowing positional access."""

  #-------------------------- nested Position class --------------------------
  class Position:
    """An abstraction representing the location of a single element.

    Note that two position instaces may represent the same inherent
    location in the list.  Therefore, users should always rely on
    syntax 'p == q' rather than 'p is q' when testing equivalence of
    positions.
    """

    def __init__(self, container, node):
      """Constructor should not be invoked by user."""
      self._container = container
      self._node = node

    def element(self):
      """Return the element stored at this Position."""
      return self._node._element

    def __eq__(self, other):
      """Return True if other is a Position representing the same location."""
      return type(other) is type(self) and other._node is self._node

    def __ne__(self, other):
      """Return True if other does not represent the same location."""
      return not (self == other)               # opposite of __eq__

  #------------------------------- utility methods -------------------------------
  def _validate(self, p):
    """Return position's node, or raise appropriate error if invalid."""
    if not isinstance(p, self.Position):
      raise TypeError('p must be proper Position type')
    if p._container is not self:
      raise ValueError('p does not belong to this container')
    if p._node._next is None:                  # convention for deprecated nodes
      raise ValueError('p is no longer valid')
    return p._node

  def _make_position(self, node):
    """Return Position instance for given node (or None if sentinel)."""
    if node is self._header or node is self._trailer:
      return None                              # boundary violation
    else:
      return self.Position(self, node)         # legitimate position

  #------------------------------- accessors -------------------------------
  def first(self):
    """Return the first Position in the list (or None if list is empty)."""
    return self._make_position(self._header._next)

  def last(self):
    """Return the last Position in the list (or None if list is empty)."""
    return self._make_position(self._trailer._prev)

  def before(self, p):
    """Return the Position just before Position p (or None if p is first)."""
    node = self._validate(p)
    return self._make_position(node._prev)

  def after(self, p):
    """Return the Position just after Position p (or None if p is last)."""
    node = self._validate(p)
    return self._make_position(node._next)

  def __iter__(self):
    """Generate a forward iteration of the elements of the list."""
    cursor = self.first()
    while cursor is not None:
      yield cursor.element()
      cursor = self.after(cursor)

  #------------------------------- mutators -------------------------------
  # override inherited version to return Position, rather than Node
  def _insert_between(self, e, predecessor, successor):
    """Add element between existing nodes and return new Position."""
    node = super()._insert_between(e, predecessor, successor)
    return self._make_position(node)

  def add_first(self, e):
    """Insert element e at the front of the list and return new Position."""
    return self._insert_between(e, self._header, self._header._next)

  def add_last(self, e):
    """Insert element e at the back of the list and return new Position."""
    return self._insert_between(e, self._trailer._prev, self._trailer)

  def add_before(self, p, e):
    """Insert element e into list before Position p and return new Position."""
    original = self._validate(p)
    return self._insert_between(e, original._prev, original)

  def add_after(self, p, e):
    """Insert element e into list after Position p and return new Position."""
    original = self._validate(p)
    return self._insert_between(e, original, original._next)

  def delete(self, p):
    """Remove and return the element at Position p."""
    original = self._validate(p)
    return self._delete_node(original)  # inherited method returns element

  def replace(self, p, e):
    """Replace the element at Position p with e.

    Return the element formerly at Position p.
    """
    original = self._validate(p)
    old_value = original._element       # temporarily store old element
    original._element = e               # replace with new element
    return old_value                    # return the old element value

L1=LinkedDeque()
L2=LinkedDeque()
dic={}
dic2={}
n=int(input())
for i in range(n):
    a,b=(int(i) for i in input().split())
    dic[a]=b
    dic2[b]=a

forw=0
while (forw in dic) :
    L1.insert_last(dic[forw])
    t=dic[forw]
    dic.pop(forw)
    forw=t
if L1.last()==0 :
    L1.delete_last()
if n%2==0 :
    backw=0
    while (backw in dic2) :
        L2.insert_first(dic2[backw])
        t=dic2[backw]
        dic2.pop(backw)
        backw=t
else:
    tk,tv=0,0
    for (k, v) in dic.items():
        tk=k
        tv=v
    forw=tk
    while (forw in dic) :
        L2.insert_last(dic[forw])
        t=dic[forw]
        dic.pop(forw)
        forw=t
    backw=tv
    while (backw in dic2) :
        L2.insert_first(dic2[backw])
        t=dic2[backw]
        dic2.pop(backw)
        backw=t
outList=[]
while L1.is_empty()==False :
    outList.append(str(L2.first()))
    outList.append(str(L1.first()))
    L1.delete_first()
    L2.delete_first()
if L2.is_empty()==False :
    outList.append(str(L2.first()))
    pass
print(" ".join(outList))
```


514_B. Han Solo and Lazer Gun

There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.

Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x0, y0). In one shot it can can destroy all the stormtroopers, situated on some line that crosses point (x0, y0).

Your task is to determine what minimum number of shots Han Solo needs to defeat all the stormtroopers.

The gun is the newest invention, it shoots very quickly and even after a very large number of shots the stormtroopers don't have enough time to realize what's happening and change their location.

Input

The first line contains three integers n, x0 и y0 (1 ≤ n ≤ 1000,  - 104 ≤ x0, y0 ≤ 104) — the number of stormtroopers on the battle field and the coordinates of your gun.

Next n lines contain two integers each xi, yi ( - 104 ≤ xi, yi ≤ 104) — the coordinates of the stormtroopers on the battlefield. It is guaranteed that no stormtrooper stands at the same point with the gun. Multiple stormtroopers can stand at the same point.

Output

Print a single integer — the minimum number of shots Han Solo needs to destroy all the stormtroopers.

Examples

Input

4 0 0
1 1
2 2
2 0
-1 -1

Output

2

Input

2 1 2
1 1
1 0

Output

1

Note

Explanation to the first and second samples from the statement, respectively:

<image>

```python
n, x0, y0 = map(int, input().split())
slopes = {} # key: (num, den), val: count

for i in range(n):
    x, y = map(int, input().split())
    num = y - y0
    den = x - x0
    # print(num, den)
    if den == 0 and "inf" in slopes:
        slopes["inf"] += 1
    elif den == 0:
        slopes["inf"] = 1
    else:
        found = False
        for s in slopes:
            # print(isinstance(s, tuple))
            if isinstance(s, tuple) and num * s[1] == den * s[0]:
                slopes[s] += 1
                found = True
        if found == False:
            slopes[(num, den)] = 1

print(slopes.__len__())

```


540_C. Ice Cave

You play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend one level lower and the only way to do this is to fall through the ice.

The level of the cave where you are is a rectangular square grid of n rows and m columns. Each cell consists either from intact or from cracked ice. From each cell you can move to cells that are side-adjacent with yours (due to some limitations of the game engine you cannot make jumps on the same place, i.e. jump from a cell to itself). If you move to the cell with cracked ice, then your character falls down through it and if you move to the cell with intact ice, then the ice on this cell becomes cracked.

Let's number the rows with integers from 1 to n from top to bottom and the columns with integers from 1 to m from left to right. Let's denote a cell on the intersection of the r-th row and the c-th column as (r, c).

You are staying in the cell (r1, c1) and this cell is cracked because you've just fallen here from a higher level. You need to fall down through the cell (r2, c2) since the exit to the next level is there. Can you do this?

Input

The first line contains two integers, n and m (1 ≤ n, m ≤ 500) — the number of rows and columns in the cave description.

Each of the next n lines describes the initial state of the level of the cave, each line consists of m characters "." (that is, intact ice) and "X" (cracked ice).

The next line contains two integers, r1 and c1 (1 ≤ r1 ≤ n, 1 ≤ c1 ≤ m) — your initial coordinates. It is guaranteed that the description of the cave contains character 'X' in cell (r1, c1), that is, the ice on the starting cell is initially cracked.

The next line contains two integers r2 and c2 (1 ≤ r2 ≤ n, 1 ≤ c2 ≤ m) — the coordinates of the cell through which you need to fall. The final cell may coincide with the starting one.

Output

If you can reach the destination, print 'YES', otherwise print 'NO'.

Examples

Input

4 6
X...XX
...XX.
.X..X.
......
1 6
2 2

Output

YES

Input

5 4
.X..
...X
X.X.
....
.XX.
5 3
1 1

Output

NO

Input

4 7
..X.XX.
.XX..X.
X...X..
X......
2 2
1 6

Output

YES

Note

In the first sample test one possible path is:

<image>

After the first visit of cell (2, 2) the ice on it cracks and when you step there for the second time, your character falls through the ice as intended.

```python
import queue
MAX = 500
dr = [0,0,1,-1]
dc = [1,-1,0,0]
def isValid(r, c):
  return r in range(m) and c in range(n)

def BFS(sr, sc, fr, fc):
  q = [0] * (MAX * MAX)
  left = right = 0
  q[0] = (sr, sc)
  while left <= right:
    ur, uc = q[left]
    left += 1
    for i in range(4):
      vr = ur + dr[i]
      vc = uc + dc[i]
      if isValid(vr, vc):
        if maze[vr][vc] == '.':
          maze[vr][vc] = 'X'
          right += 1
          q[right] = (vr, vc)
        else:
          if(vr == fr) and (vc==fc):
            return True
  return False

if __name__ == '__main__':

  maze = []
  m, n = map(int, input().split())

  for i in range(m):
    temp = list(input())
    maze.append(temp)
  start, start2 = map(int, input().split())
#   s1 = Cell(start-1,start2-1)
  end1, end2 = map(int, input().split())
#   e = Cell(end1-1,end2-1)
  if(BFS(start - 1, start2 - 1, end1 - 1, end2 - 1)):
    print('YES')
  else:
    print('NO')
```


58_B. Coins

In Berland a money reform is being prepared. New coins are being introduced. After long economic calculations was decided that the most expensive coin should possess the denomination of exactly n Berland dollars. Also the following restriction has been introduced for comfort: the denomination of each coin should be divisible by the denomination of any cheaper coin. It is known that among all the possible variants the variant with the largest number of new coins will be chosen. Find this variant. Print in the order of decreasing of the coins' denominations.

Input

The first and only line contains an integer n (1 ≤ n ≤ 106) which represents the denomination of the most expensive coin.

Output

Print the denominations of all the coins in the order of decreasing. The number of coins must be the largest possible (with the given denomination n of the most expensive coin). Also, the denomination of every coin must be divisible by the denomination of any cheaper coin. Naturally, the denominations of all the coins should be different. If there are several solutins to that problem, print any of them.

Examples

Input

10

Output

10 5 1

Input

4

Output

4 2 1

Input

3

Output

3 1

```python
def O(x):
    l=[]
    if x==1:
        return 1
    for i in range(1,x//2+1):
        if x%i==0:
            l.append(i)
    print(x)
    return O(l[len(l)-1])
x=int(input())
O(x)
print(1)

```


631_A. Interview

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

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

<image>

Input

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

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

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

Output

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

Examples

Input

5
1 2 4 3 2
2 3 3 12 1

Output

22

Input

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

Output

46

Note

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

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

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

```python
read = lambda: map(int, input().split())
n = int(input())
a = list(read())
b = list(read())
f1 = f2 = 0
for i in a: f1 |= i
for i in b: f2 |= i
print(f1 + f2)

```


706_B. Interesting drink

Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that the price of one bottle in the shop i is equal to xi coins.

Vasiliy plans to buy his favorite drink for q consecutive days. He knows, that on the i-th day he will be able to spent mi coins. Now, for each of the days he want to know in how many different shops he can buy a bottle of "Beecola".

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of shops in the city that sell Vasiliy's favourite drink.

The second line contains n integers xi (1 ≤ xi ≤ 100 000) — prices of the bottles of the drink in the i-th shop.

The third line contains a single integer q (1 ≤ q ≤ 100 000) — the number of days Vasiliy plans to buy the drink.

Then follow q lines each containing one integer mi (1 ≤ mi ≤ 109) — the number of coins Vasiliy can spent on the i-th day.

Output

Print q integers. The i-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the i-th day.

Example

Input

5
3 10 8 6 11
4
1
10
3
11

Output

0
4
1
5

Note

On the first day, Vasiliy won't be able to buy a drink in any of the shops.

On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.

On the third day, Vasiliy can buy a drink only in the shop number 1.

Finally, on the last day Vasiliy can buy a drink in any shop.

```python
def binary(t,s):
    fir=0
    last=len(t)-1
    mid=0
    while(fir<=last):
        mid=(fir+last)//2
        if t[mid]>s:
            last=mid-1
        else:
            fir=mid+1
    return last+1

n=int(input())
t=list(map(int,input().split()))
m=int(input())
p=0
t.sort()
for i in range(m):
    s=int(input())
    print(binary(t,s))
```


729_D. Sea Battle

Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other.

Galya doesn't know the ships location. She can shoot to some cells and after each shot she is told if that cell was a part of some ship (this case is called "hit") or not (this case is called "miss").

Galya has already made k shots, all of them were misses.

Your task is to calculate the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship.

It is guaranteed that there is at least one valid ships placement.

Input

The first line contains four positive integers n, a, b, k (1 ≤ n ≤ 2·105, 1 ≤ a, b ≤ n, 0 ≤ k ≤ n - 1) — the length of the grid, the number of ships on the grid, the length of each ship and the number of shots Galya has already made.

The second line contains a string of length n, consisting of zeros and ones. If the i-th character is one, Galya has already made a shot to this cell. Otherwise, she hasn't. It is guaranteed that there are exactly k ones in this string.

Output

In the first line print the minimum number of cells such that if Galya shoot at all of them, she would hit at least one ship.

In the second line print the cells Galya should shoot at.

Each cell should be printed exactly once. You can print the cells in arbitrary order. The cells are numbered from 1 to n, starting from the left.

If there are multiple answers, you can print any of them.

Examples

Input

5 1 2 1
00100

Output

2
4 2

Input

13 3 2 3
1000000010001

Output

2
7 11

Note

There is one ship in the first sample. It can be either to the left or to the right from the shot Galya has already made (the "1" character). So, it is necessary to make two shots: one at the left part, and one at the right part.

```python
n,a,b,k = map(int, input().split())

open = 0
must = 0
must_arr = []

for i,c in enumerate(input()):
    if c == '1':
        open = 0
    else:
        open += 1
        if open == b:
            open = 0
            must += 1
            if must >= a:
                must_arr.append(i+1)

must -= a - 1

print(must)
print(*must_arr)
```


749_E. Inversions After Shuffle

You are given a permutation of integers from 1 to n. Exactly once you apply the following operation to this permutation: pick a random segment and shuffle its elements. Formally:

  1. Pick a random segment (continuous subsequence) from l to r. All <image> segments are equiprobable.
  2. Let k = r - l + 1, i.e. the length of the chosen segment. Pick a random permutation of integers from 1 to k, p1, p2, ..., pk. All k! permutation are equiprobable.
  3. This permutation is applied to elements of the chosen segment, i.e. permutation a1, a2, ..., al - 1, al, al + 1, ..., ar - 1, ar, ar + 1, ..., an is transformed to a1, a2, ..., al - 1, al - 1 + p1, al - 1 + p2, ..., al - 1 + pk - 1, al - 1 + pk, ar + 1, ..., an.

Inversion if a pair of elements (not necessary neighbouring) with the wrong relative order. In other words, the number of inversion is equal to the number of pairs (i, j) such that i < j and ai > aj. Find the expected number of inversions after we apply exactly one operation mentioned above.

Input

The first line contains a single integer n (1 ≤ n ≤ 100 000) — the length of the permutation.

The second line contains n distinct integers from 1 to n — elements of the permutation.

Output

Print one real value — the expected number of inversions. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 9.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if <image>.

Example

Input

3
2 3 1

Output

1.916666666666666666666666666667

```python

# Python3 program to count inversions using
# Binary Indexed Tree

# Returns sum of arr[0..index]. This function
# assumes that the array is preprocessed and
# partial sums of array elements are stored
# in BITree[].
def getSum( BITree, index):
    sum = 0 # Initialize result

    # Traverse ancestors of BITree[index]
    while (index > 0):

        # Add current element of BITree to sum
        sum += BITree[index]

        # Move index to parent node in getSum View
        index -= index & (-index)

    return sum

# Updates a node in Binary Index Tree (BITree)
# at given index in BITree. The given value
# 'val' is added to BITree[i] and all of its
# ancestors in tree.
def updateBIT(BITree, n, index, val):

    # Traverse all ancestors and add 'val'
    while (index <= n):

        # Add 'val' to current node of BI Tree
        BITree[index] += val

        # Update index to that of parent
        # in update View
        index += index & (-index)

# Returns count of inversions of size three
def getInvCount(arr, n):

    invcount = 0 # Initialize result

    # Find maximum element in arrays
    maxElement = max(arr)

    # Create a BIT with size equal to
    # maxElement+1 (Extra one is used
    # so that elements can be directly
    # be used as index)
    BIT = [0] * (maxElement + 1)
    for i in range(1, maxElement + 1):
        BIT[i] = 0
    for i in range(n - 1, -1, -1):
        invcount += getSum(BIT, arr[i] - 1)
        updateBIT(BIT, maxElement, arr[i], 1)
    return invcount

def getInvCountAdv(arr, n):

    invcount = 0 # Initialize result

    # Find maximum element in arrays
    maxElement = max(arr)

    # Create a BIT with size equal to
    # maxElement+1 (Extra one is used
    # so that elements can be directly
    # be used as index)
    BIT = [0] * (maxElement + 1)
    for i in range(1, maxElement + 1):
        BIT[i] = 0
    for i in range(n - 1, -1, -1):
        invcount += (i + 1) * getSum(BIT, arr[i] - 1)
        updateBIT(BIT, maxElement, arr[i], n-i)
    return invcount

# Driver code
n = int(input())
a = list(map(int,input().split()))
InvCount = getInvCount(a, n)
InvCountAdv = getInvCountAdv(a,n)
thirdSum = 0
for i in range(1,n+1):
    thirdSum += i * (i - 1) * (n- i + 1) / 2
print(InvCount - InvCountAdv / (n * (n + 1)) * 2 + thirdSum / (n * (n + 1)))

# Some part of this code is contributed by
# Shubham Singh(SHUBHAMSINGH10)
```


797_D. Broken BST

Let T be arbitrary binary tree — tree, every vertex of which has no more than two children. Given tree is rooted, so there exists only one vertex which doesn't have a parent — it's the root of a tree. Every vertex has an integer number written on it. Following algorithm is run on every value from the tree T:

  1. Set pointer to the root of a tree.
  2. Return success if the value in the current vertex is equal to the number you are looking for
  3. Go to the left child of the vertex if the value in the current vertex is greater than the number you are looking for
  4. Go to the right child of the vertex if the value in the current vertex is less than the number you are looking for
  5. Return fail if you try to go to the vertex that doesn't exist

Here is the pseudo-code of the described algorithm:

    bool find(TreeNode t, int x) {
        if (t == null)
            return false;
        if (t.value == x)
            return true;
        if (x < t.value)
            return find(t.left, x);
        else
            return find(t.right, x);
    }
    find(root, x);

The described algorithm works correctly if the tree is binary search tree (i.e. for each node the values of left subtree are less than the value in the node, the values of right subtree are greater than the value in the node). But it can return invalid result if tree is not a binary search tree.

Since the given tree is not necessarily a binary search tree, not all numbers can be found this way. Your task is to calculate, how many times the search will fail being running on every value from the tree.

If the tree has multiple vertices with the same values on them then you should run algorithm on every one of them separately.

Input

First line contains integer number n (1 ≤ n ≤ 105) — number of vertices in the tree.

Each of the next n lines contains 3 numbers v, l, r (0 ≤ v ≤ 109) — value on current vertex, index of the left child of the vertex and index of the right child of the vertex, respectively. If some child doesn't exist then number  - 1 is set instead. Note that different vertices of the tree may contain the same values.

Output

Print number of times when search algorithm will fail.

Examples

Input

3
15 -1 -1
10 1 3
5 -1 -1

Output

2

Input

8
6 2 3
3 4 5
12 6 7
1 -1 8
4 -1 -1
5 -1 -1
14 -1 -1
2 -1 -1

Output

1

Note

In the example the root of the tree in vertex 2. Search of numbers 5 and 15 will return fail because on the first step algorithm will choose the subtree which doesn't contain numbers you are looking for.

```python
from collections import deque

nodes = []
parents = []
values = []
broken = []
upperBound = []
lowerBound = []

n = int(input())

for _ in range(n):
    v, l, r = map(int, input().split())
    nodes.append((v, l - 1, r - 1))
    parents.append(-1)
    values.append(v)
    broken.append(False)
    upperBound.append(10 ** 9)
    lowerBound.append(-10 ** 9)

for i, (v, l, r) in enumerate(nodes):
    if l > -1:
        parents[l] = i
    if r > -1:
        parents[r] = i

root = -1
for i in range(n):
    if parents[i] == -1:
        root = i

proc = deque([root])
while len(proc) > 0:
    node = proc.popleft()
    v, l, r = nodes[node]
    if l > -1:
        proc.append(l)
        upperBound[l] = min(upperBound[node], v)
        lowerBound[l] = lowerBound[node]
        if not (lowerBound[l] <= nodes[l][0] <= upperBound[l]):
            broken[l] = True
    if r > -1:
        proc.append(r)
        upperBound[r] = upperBound[node]
        lowerBound[r] = max(lowerBound[node], v)
        if not (lowerBound[r] <= nodes[r][0] <= upperBound[r]):
            broken[r] = True

s = set([])
for v, b in zip(values, broken):
    if not b:
        s.add(v)

ans = 0
for v in values:
    if v not in s:
        ans += 1

print(ans)
```


843_A. Sorting by Subsequences

You are given a sequence a1, a2, ..., an consisting of different integers. It is required to split this sequence into the maximum number of subsequences such that after sorting integers in each of them in increasing order, the total sequence also will be sorted in increasing order.

Sorting integers in a subsequence is a process such that the numbers included in a subsequence are ordered in increasing order, and the numbers which are not included in a subsequence don't change their places.

Every element of the sequence must appear in exactly one subsequence.

Input

The first line of input data contains integer n (1 ≤ n ≤ 105) — the length of the sequence.

The second line of input data contains n different integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — the elements of the sequence. It is guaranteed that all elements of the sequence are distinct.

Output

In the first line print the maximum number of subsequences k, which the original sequence can be split into while fulfilling the requirements.

In the next k lines print the description of subsequences in the following format: the number of elements in subsequence ci (0 < ci ≤ n), then ci integers l1, l2, ..., lci (1 ≤ lj ≤ n) — indices of these elements in the original sequence.

Indices could be printed in any order. Every index from 1 to n must appear in output exactly once.

If there are several possible answers, print any of them.

Examples

Input

6
3 2 1 6 5 4

Output

4
2 1 3
1 2
2 4 6
1 5

Input

6
83 -75 -49 11 37 62

Output

1
6 1 2 3 4 5 6

Note

In the first sample output:

After sorting the first subsequence we will get sequence 1 2 3 6 5 4.

Sorting the second subsequence changes nothing.

After sorting the third subsequence we will get sequence 1 2 3 4 5 6.

Sorting the last subsequence changes nothing.

```python

n = int(input())
d = list(map(int, input().split()))

temp = d[:]
d.sort()
from bisect import bisect_left

A = [bisect_left(d,i) for i in temp]

del d,temp

f = [False]*len(A)

result = []

for i in range(n):
  if not f[i]:
    L = [i+1]
    f[i] = True
    j = A[i]
    while j != i:
      L.append(j+1)
      f[j] = True
      j = A[j]
    result.append(L)

print(len(result))
for L in result:
  print(len(L),' '.join(map(str,L)))
```


863_F. Almost Permutation

Recently Ivan noticed an array a while debugging his code. Now Ivan can't remember this array, but the bug he was trying to fix didn't go away, so Ivan thinks that the data from this array might help him to reproduce the bug.

Ivan clearly remembers that there were n elements in the array, and each element was not less than 1 and not greater than n. Also he remembers q facts about the array. There are two types of facts that Ivan remembers:

  * 1 li ri vi — for each x such that li ≤ x ≤ ri ax ≥ vi;
  * 2 li ri vi — for each x such that li ≤ x ≤ ri ax ≤ vi.

Also Ivan thinks that this array was a permutation, but he is not so sure about it. He wants to restore some array that corresponds to the q facts that he remembers and is very similar to permutation. Formally, Ivan has denoted the cost of array as follows:

<image>, where cnt(i) is the number of occurences of i in the array.

Help Ivan to determine minimum possible cost of the array that corresponds to the facts!

Input

The first line contains two integer numbers n and q (1 ≤ n ≤ 50, 0 ≤ q ≤ 100).

Then q lines follow, each representing a fact about the array. i-th line contains the numbers ti, li, ri and vi for i-th fact (1 ≤ ti ≤ 2, 1 ≤ li ≤ ri ≤ n, 1 ≤ vi ≤ n, ti denotes the type of the fact).

Output

If the facts are controversial and there is no array that corresponds to them, print -1. Otherwise, print minimum possible cost of the array.

Examples

Input

3 0

Output

3

Input

3 1
1 1 3 2

Output

5

Input

3 2
1 1 3 2
2 1 3 2

Output

9

Input

3 2
1 1 3 2
2 1 3 1

Output

-1

```python
import sys

def is_feasible(cnt,L,R):
	n = len(R)
	inter = [(L[i],R[i]) for i in range(n)]
	AUX = []
	feasible = True
	for x in range(n):
		for p in inter:
			if p[0] == x:
				AUX.append(p[1])

		while AUX and min(AUX) < x:
			AUX.remove(min(AUX))
		for quantity in range(cnt[x]):
			if AUX:
				AUX.remove(min(AUX))
			else:
				feasible = False
	return feasible

n,q = map(int,sys.stdin.readline().split())
L = [0 for i in range(n)]
R = [n-1 for i in range(n)]
for restriction in range(q):
	t,l,r,v = map(int,sys.stdin.readline().split())
	if t == 1:
		for k in range(l-1,r):
			L[k] = max(L[k],v-1)
	else:
		for k in range(l-1,r):
			R[k] = min(R[k],v-1)

is_possible = all(map(lambda x,y : x <= y,L,R))
if not is_possible:
	print(-1)
else:
	cnt = {x:L.count(x) for x in range(n)}
	had_pair = True
	while had_pair:
		had_pair = False
		for x in range(n-1,-1,-1):
			for y in range(n-1,-1,-1):
				if cnt[x] > cnt[y]+1:
					cnt[x] -= 1
					cnt[y] += 1
					has_pair = True
					if not is_feasible(cnt,L,R):
						cnt[x] += 1
						cnt[y] -= 1
						has_pair = False
					had_pair = had_pair or has_pair

	ans = sum([cnt[x]*cnt[x] for x in range(n)])
	print(ans)

```