1413_E. Solo mid Oracle

Meka-Naruto plays a computer game. His character has the following ability: given an enemy hero, deal a instant damage to him, and then heal that enemy b health points at the end of every second, for exactly c seconds, starting one second after the ability is used. That means that if the ability is used at time t, the enemy's health decreases by a at time t, and then increases by b at time points t + 1, t + 2, ..., t + c due to this ability.

The ability has a cooldown of d seconds, i. e. if Meka-Naruto uses it at time moment t, next time he can use it is the time t + d. Please note that he can only use the ability at integer points in time, so all changes to the enemy's health also occur at integer times only.

The effects from different uses of the ability may stack with each other; that is, the enemy which is currently under k spells gets k⋅ b amount of heal this time. Also, if several health changes occur at the same moment, they are all counted at once.

Now Meka-Naruto wonders if he can kill the enemy by just using the ability each time he can (that is, every d seconds). The enemy is killed if their health points become 0 or less. Assume that the enemy's health is not affected in any way other than by Meka-Naruto's character ability. What is the maximal number of health points the enemy can have so that Meka-Naruto is able to kill them?

Input

The first line contains an integer t (1≤ t≤ 10^5) standing for the number of testcases.

Each test case is described with one line containing four numbers a, b, c and d (1≤ a, b, c, d≤ 10^6) denoting the amount of instant damage, the amount of heal per second, the number of heals and the ability cooldown, respectively.

Output

For each testcase in a separate line print -1 if the skill can kill an enemy hero with an arbitrary number of health points, otherwise print the maximal number of health points of the enemy that can be killed.

Example

Input

7
1 1 1 1
2 2 2 2
1 2 3 4
4 3 2 1
228 21 11 3
239 21 11 3
1000000 1 1000000 1

Output

1
2
1
5
534
-1
500000500000

Note

In the first test case of the example each unit of damage is cancelled in a second, so Meka-Naruto cannot deal more than 1 damage.

In the fourth test case of the example the enemy gets:

  * 4 damage (1-st spell cast) at time 0;
  * 4 damage (2-nd spell cast) and 3 heal (1-st spell cast) at time 1 (the total of 5 damage to the initial health);
  * 4 damage (3-nd spell cast) and 6 heal (1-st and 2-nd spell casts) at time 2 (the total of 3 damage to the initial health);
  * and so on.

One can prove that there is no time where the enemy gets the total of 6 damage or more, so the answer is 5. Please note how the health is recalculated: for example, 8-health enemy would not die at time 1, as if we first subtracted 4 damage from his health and then considered him dead, before adding 3 heal.

In the sixth test case an arbitrarily healthy enemy can be killed in a sufficient amount of time.

In the seventh test case the answer does not fit into a 32-bit integer type.

```python
# region fastio  # from https://codeforces.com/contest/1333/submission/75948789
import sys, io, os

BUFSIZE = 8192

class FastIO(io.IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = io.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(io.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")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
#endregion

T = int(input())
for _ in range(T):
    A, B, C, D = map(int, input().split())
    if C * B < A:
        print(-1)
        continue
    n = A // B // D
    ans = A * (n + 1) - n*(n+1)//2 * B*D
    #print(f"n={n}")
    print(ans)

```


1455_E. Four Points

You are given four different integer points p_1, p_2, p_3 and p_4 on XY grid.

In one step you can choose one of the points p_i and move it in one of four directions by one. In other words, if you have chosen point p_i = (x, y) you can move it to (x, y + 1), (x, y - 1), (x + 1, y) or (x - 1, y).

Your goal to move points in such a way that they will form a square with sides parallel to OX and OY axes (a square with side 0 is allowed).

What is the minimum number of steps you need to make such a square?

Input

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

Each test case consists of four lines. Each line contains two integers x and y (0 ≤ x, y ≤ 10^9) — coordinates of one of the points p_i = (x, y).

All points are different in one test case.

Output

For each test case, print the single integer — the minimum number of steps to make a square.

Example

Input

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

Output

8
7
5

Note

In the first test case, one of the optimal solutions is shown below:

<image> Each point was moved two times, so the answer 2 + 2 + 2 + 2 = 8.

In the second test case, one of the optimal solutions is shown below:

<image> The answer is 3 + 1 + 0 + 3 = 7.

In the third test case, one of the optimal solutions is shown below:

<image> The answer is 1 + 1 + 2 + 1 = 5.

```python
import sys,os,io
input = sys.stdin.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from random import *
T = int(input())
ans = [0]*T
for t in range(T):
  X,Y = [0]*4,[0]*4
  A = [0]*4
  for i in range(4):
    X[i],Y[i] = map(int, input().split())
    # X[i], Y[i] = choices(range(1,11),k=2)
    # print(X[i],Y[i])
    A[i] = [X[i], Y[i]]
  X.sort(); Y.sort(); A.sort()
  cnt = 0
  for i in range(2):
    rank = 1
    for j in range(4):
      if A[i][1] < A[j][1]:
        rank += 1
    if rank<=2:
      cnt += 1
  if cnt!=1:
    ans[t] += min(Y[2]-Y[1], X[2]-X[1])*2
  x_min = X[2]-X[1]; x_max = X[3]-X[0]
  y_min = Y[2]-Y[1]; y_max = Y[3]-Y[0]
  if x_max<y_min:
    ans[t] += (X[3]-X[2])+(X[1]-X[0])
    ans[t] += (Y[3]-Y[2])+(Y[1]-Y[0])+2*(y_min-x_max)
  elif y_max<x_min:
    ans[t] += (X[3]-X[2])+(X[1]-X[0])+2*(x_min-y_max)
    ans[t] += (Y[3]-Y[2])+(Y[1]-Y[0])
  else:
    ans[t] += (X[3]-X[2])+(X[1]-X[0])
    ans[t] += (Y[3]-Y[2])+(Y[1]-Y[0])
  # print(ans[t])
print(*ans, sep='\n')
```


147_A. Punctuation

You are given a text that consists of lowercase Latin letters, spaces and punctuation marks (dot, comma, exclamation mark and question mark). A word is defined as a sequence of consecutive Latin letters.

Your task is to add spaces to the text by the following rules:

  * if there is no punctuation mark between two words, then they should be separated by exactly one space
  * there should be no spaces before each punctuation mark
  * there should be exactly one space after each punctuation mark

It is guaranteed that there is at least one word between any two punctuation marks. The text begins and ends with a Latin letter.

Input

The input data contains of a single non-empty line — the text whose length is no more than 10000 characters.

Output

Print the text, edited according to the rules. In this problem you should follow the output format very strictly. For example, extra space at the end of the output line is considered as wrong answer. Note that a newline character at the end of the line doesn't matter.

Examples

Input

galileo galilei was an   italian physicist  ,mathematician,astronomer

Output

galileo galilei was an italian physicist, mathematician, astronomer

Input

galileo  was  born  in  pisa

Output

galileo was born in pisa

```python
import re
s = input()+"a"
s = re.sub('\s+', ' ', s)
r = '.,?!'
for i in r:
    t = s.split(i)
    s = ""
    for j in t:
        s += j.strip() + i + " "
    s = s[:-2]
print(s[:-1])
```


1506_E. Restoring the Permutation

A permutation is a sequence of n integers from 1 to n, in which all numbers occur exactly once. For example, [1], [3, 5, 2, 1, 4], [1, 3, 2] are permutations, and [2, 3, 2], [4, 3, 1], [0] are not.

Polycarp was presented with a permutation p of numbers from 1 to n. However, when Polycarp came home, he noticed that in his pocket, the permutation p had turned into an array q according to the following rule:

  * q_i = max(p_1, p_2, …, p_i).

Now Polycarp wondered what lexicographically minimal and lexicographically maximal permutations could be presented to him.

An array a of length n is lexicographically smaller than an array b of length n if there is an index i (1 ≤ i ≤ n) such that the first i-1 elements of arrays a and b are the same, and the i-th element of the array a is less than the i-th element of the array b. For example, the array a=[1, 3, 2, 3] is lexicographically smaller than the array b=[1, 3, 4, 2].

For example, if n=7 and p=[3, 2, 4, 1, 7, 5, 6], then q=[3, 3, 4, 4, 7, 7, 7] and the following permutations could have been as p initially:

  * [3, 1, 4, 2, 7, 5, 6] (lexicographically minimal permutation);
  * [3, 1, 4, 2, 7, 6, 5];
  * [3, 2, 4, 1, 7, 5, 6];
  * [3, 2, 4, 1, 7, 6, 5] (lexicographically maximum permutation).

For a given array q, find the lexicographically minimal and lexicographically maximal permutations that could have been originally presented to Polycarp.

Input

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

The first line of each test case contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5).

The second line of each test case contains n integers q_1, q_2, …, q_n (1 ≤ q_i ≤ n).

It is guaranteed that the array q was obtained by applying the rule from the statement to some permutation p.

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

Output

For each test case, output two lines:

  * on the first line output n integers — lexicographically minimal permutation that could have been originally presented to Polycarp;
  * on the second line print n integers — lexicographically maximal permutation that could have been originally presented to Polycarp;

Example

Input

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

Output

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

```python
import sys,os,io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

t = int(input())
for _ in range (t):
    n = int(input())
    a = [int(i) for i in input().split()]
    vis = [0]*(n+1)
    vis[a[0]]=1
    for i in range (1,n):
        if a[i]!=a[i-1]:
            vis[a[i]]=1
    mini = [a[0]]
    maxi = [a[0]]

    available = []
    for i in range (1,n+1):
        if vis[i]==0:
            available.append(i)
    available.reverse()
    for i in range (1,n):
        if a[i]==a[i-1]:
            mini.append(available.pop())
        else:
            mini.append(a[i])
    available = []
    for i in range (1,a[0]):
        available.append(i)
    prev = a[0]
    for i in range (1,n):
        if a[i]==a[i-1]:
            maxi.append(available.pop())
        else:
            for j in range (prev+1,a[i]):
                available.append(j)
            prev = a[i]
            maxi.append(a[i])
    print(*mini)
    print(*maxi)
```


161_A. Dress'em in Vests!

The Two-dimensional kingdom is going through hard times... This morning the Three-Dimensional kingdom declared war on the Two-dimensional one. This (possibly armed) conflict will determine the ultimate owner of the straight line.

The Two-dimensional kingdom has a regular army of n people. Each soldier registered himself and indicated the desired size of the bulletproof vest: the i-th soldier indicated size ai. The soldiers are known to be unpretentious, so the command staff assumes that the soldiers are comfortable in any vests with sizes from ai - x to ai + y, inclusive (numbers x, y ≥ 0 are specified).

The Two-dimensional kingdom has m vests at its disposal, the j-th vest's size equals bj. Help mobilize the Two-dimensional kingdom's army: equip with vests as many soldiers as possible. Each vest can be used only once. The i-th soldier can put on the j-th vest, if ai - x ≤ bj ≤ ai + y.

Input

The first input line contains four integers n, m, x and y (1 ≤ n, m ≤ 105, 0 ≤ x, y ≤ 109) — the number of soldiers, the number of vests and two numbers that specify the soldiers' unpretentiousness, correspondingly.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) in non-decreasing order, separated by single spaces — the desired sizes of vests.

The third line contains m integers b1, b2, ..., bm (1 ≤ bj ≤ 109) in non-decreasing order, separated by single spaces — the sizes of the available vests.

Output

In the first line print a single integer k — the maximum number of soldiers equipped with bulletproof vests.

In the next k lines print k pairs, one pair per line, as "ui vi" (without the quotes). Pair (ui, vi) means that soldier number ui must wear vest number vi. Soldiers and vests are numbered starting from one in the order in which they are specified in the input. All numbers of soldiers in the pairs should be pairwise different, all numbers of vests in the pairs also should be pairwise different. You can print the pairs in any order.

If there are multiple optimal answers, you are allowed to print any of them.

Examples

Input

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

Output

2
1 1
3 2

Input

3 3 2 2
1 5 9
3 5 7

Output

3
1 1
2 2
3 3

Note

In the first sample you need the vests' sizes to match perfectly: the first soldier gets the first vest (size 1), the third soldier gets the second vest (size 3). This sample allows another answer, which gives the second vest to the fourth soldier instead of the third one.

In the second sample the vest size can differ from the desired size by at most 2 sizes, so all soldiers can be equipped.

```python
n, m, x, y = map(int, input().split())
a_n = [i for i in map(int, input().split())]
b_m = [i for i in map(int, input().split())]

count = 0
result = []
i = 0
j = 0
while j < m and i < n:
    if b_m[j] > a_n[i] + y:
        i += 1
    elif b_m[j] < a_n[i] - x:
        j += 1
    else:
        count += 1
        result.append((i+1, j+1))
        i += 1
        j += 1
print(count)
for i in result:
    print(i[0], i[1])
```


180_C. Letter

Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them were uppercase.

Patrick believes that a message is fancy if any uppercase letter stands to the left of any lowercase one. In other words, this rule describes the strings where first go zero or more uppercase letters, and then — zero or more lowercase letters.

To make the message fancy, Patrick can erase some letter and add the same letter in the same place in the opposite case (that is, he can replace an uppercase letter with the lowercase one and vice versa). Patrick got interested in the following question: what minimum number of actions do we need to make a message fancy? Changing a letter's case in the message counts as one action. Patrick cannot perform any other actions.

Input

The only line of the input contains a non-empty string consisting of uppercase and lowercase letters. The string's length does not exceed 105.

Output

Print a single number — the least number of actions needed to make the message fancy.

Examples

Input

PRuvetSTAaYA

Output

5

Input

OYPROSTIYAOPECHATALSYAPRIVETSTASYA

Output

0

Input

helloworld

Output

0

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

def main():
    import bisect
    import math
    # import itertools
    # import heapq
    # from queue import PriorityQueue, LifoQueue, SimpleQueue

    # import sys.stdout.flush() use for interactive problems
    alpha = 'abcdefghijklmnopqrstuvwxyz'
    ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    inf = 1e17
    mod = 10 ** 9 + 7

    # Max = 10**6
    # primes = []
    # prime = [True for i in range(10**6+1)]
    # p = 2
    # while (p * p <= Max+1):
    #
    #     # If prime[p] is not
    #     # changed, then it is a prime
    #     if (prime[p] == True):
    #
    #         # Update all multiples of p
    #         for i in range(p * p, Max+1, p):
    #             prime[i] = False
    #     p += 1
    #
    # for p in range(2, Max+1):
    #     if prime[p]:
    #         primes.append(p)

    def factorial(n):
        f = 1

        for i in range(1, n + 1):
            f = (f * i) % mod  # Now f never can
        # exceed 10^9+7

        return f

    def ncr(n, r):
        # initialize numerator
        # and denominator
        num = den = 1
        for i in range(r):
            num = (num * (n - i)) % mod
            den = (den * (i + 1)) % mod
        return (num * pow(den,
                          mod - 2, mod)) % mod

    def solve(s):

        dp = [0]
        lower = 0
        for i in range(len(s)):
            if s[i].isupper():
                dp.append(min(lower,dp[-1]+1))
            else:
                lower += 1
        return dp[-1]

        pass

    t = 1#int(input())
    ans = []
    for _ in range(1):
        # n = int(input())
        # n,k = map(int, input().split())
        # arr = [int(x) for x in input().split()]
        # queries = [int(x) for x in input().split()]
        # arr = list(input())
        s = input()
        # t = input()
        # customers = []
        # for i in range(n):
        #     customers.append([int(x) for x in input().split()])
        # k = int(input())
        # s = [int(x) for x in input().split()]
        # qs = []
        # for j in range(q):
        #     r,c = map(int,input().split())
        #     qs.append((r,c))

        ans.append(solve(s))

    for j in range(len(ans)):
        #print('Case #' + str(j + 1) + ": " + str(ans[j]))
        print(ans[j])

    pass

# region fastio

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")

# endregion

if __name__ == "__main__":
    main()

```


203_D. Hit Ball

When Valera was playing football on a stadium, it suddenly began to rain. Valera hid in the corridor under the grandstand not to get wet. However, the desire to play was so great that he decided to train his hitting the ball right in this corridor. Valera went back far enough, put the ball and hit it. The ball bounced off the walls, the ceiling and the floor corridor and finally hit the exit door. As the ball was wet, it left a spot on the door. Now Valera wants to know the coordinates for this spot.

Let's describe the event more formally. The ball will be considered a point in space. The door of the corridor will be considered a rectangle located on plane xOz, such that the lower left corner of the door is located at point (0, 0, 0), and the upper right corner is located at point (a, 0, b) . The corridor will be considered as a rectangular parallelepiped, infinite in the direction of increasing coordinates of y. In this corridor the floor will be considered as plane xOy, and the ceiling as plane, parallel to xOy and passing through point (a, 0, b). We will also assume that one of the walls is plane yOz, and the other wall is plane, parallel to yOz and passing through point (a, 0, b).

We'll say that the ball hit the door when its coordinate y was equal to 0. Thus the coordinates of the spot are point (x0, 0, z0), where 0 ≤ x0 ≤ a, 0 ≤ z0 ≤ b. To hit the ball, Valera steps away from the door at distance m and puts the ball in the center of the corridor at point <image>. After the hit the ball flies at speed (vx, vy, vz). This means that if the ball has coordinates (x, y, z), then after one second it will have coordinates (x + vx, y + vy, z + vz).

See image in notes for clarification.

When the ball collides with the ceiling, the floor or a wall of the corridor, it bounces off in accordance with the laws of reflection (the angle of incidence equals the angle of reflection). In the problem we consider the ideal physical model, so we can assume that there is no air resistance, friction force, or any loss of energy.

Input

The first line contains three space-separated integers a, b, m (1 ≤ a, b, m ≤ 100). The first two integers specify point (a, 0, b), through which the ceiling and one of the corridor walls pass. The third integer is the distance at which Valera went away from the door.

The second line has three space-separated integers vx, vy, vz (|vx|, |vy|, |vz| ≤ 100, vy < 0, vz ≥ 0) — the speed of the ball after the hit.

It is guaranteed that the ball hits the door.

Output

Print two real numbers x0, z0 — the x and z coordinates of point (x0, 0, z0), at which the ball hits the exit door. The answer will be considered correct, if its absolute or relative error does not exceed 10  - 6.

Examples

Input

7 2 11
3 -11 2

Output

6.5000000000 2.0000000000

Input

7 2 11
4 -3 3

Output

4.1666666667 1.0000000000

Note

<image>

```python
from fractions import Fraction
from math import inf

a, b, m = map(int, input().split(' '))
x, y, z = map(int, input().split(' '))

cx, cy, cz = Fraction(a / 2), Fraction(m), Fraction(0)

while cy > 0:
    if cx == 0:
        x = abs(x)
    elif cx == a:
        x = -abs(x)

    if cz == 0:
        z = abs(z)
    elif cz == b:
        z = -abs(z)

    if x == 0:
        time_x = inf
    elif x > 0:
        time_x = (a - cx) / x
    else:
        time_x = cx / -x

    time_y = -cy / y

    if z == 0:
        time_z = inf
    elif z > 0:
        time_z = (b - cz) / z
    else:
        time_z = cz / -z

    time = min(time_x, time_y, time_z)

    cx += time * x
    cy += time * y
    cz += time * z

print(float(cx), float(cz))

```


252_A. Little Xor

Little Petya likes arrays that consist of non-negative integers a lot. Recently his mom has presented him one such array consisting of n elements. Petya immediately decided to find there a segment of consecutive elements, such that the xor of all numbers from this segment was maximal possible. Help him with that.

The xor operation is the bitwise exclusive "OR", that is denoted as "xor" in Pascal and "^" in C/C++/Java.

Input

The first line contains integer n (1 ≤ n ≤ 100) — the number of elements in the array. The second line contains the space-separated integers from the array. All numbers are non-negative integers strictly less than 230.

Output

Print a single integer — the required maximal xor of a segment of consecutive elements.

Examples

Input

5
1 2 1 1 2

Output

3

Input

3
1 2 7

Output

7

Input

4
4 2 4 8

Output

14

Note

In the first sample one of the optimal segments is the segment that consists of the first and the second array elements, if we consider the array elements indexed starting from one.

The second sample contains only one optimal segment, which contains exactly one array element (element with index three).

```python
import itertools
import functools
def allSubArrays(xs):
    n = len(xs)
    indices = list(range(n+1))
    for i,j in itertools.combinations(indices,2):
        yield xs[i:j]
n=int(input())
my_list=list(map(int,input().split(" ")))
list_=list(allSubArrays(my_list))
for i in range(len(list_)):
    list_[i]=functools.reduce(lambda x,y:x^y,list_[i])
print(max(list_))

```


277_B. Set of Points

Convexity of a set of points on the plane is the size of the largest subset of points that form a convex polygon. Your task is to build a set of n points with the convexity of exactly m. Your set of points should not contain three points that lie on a straight line.

Input

The single line contains two integers n and m (3 ≤ m ≤ 100, m ≤ n ≤ 2m).

Output

If there is no solution, print "-1". Otherwise, print n pairs of integers — the coordinates of points of any set with the convexity of m. The coordinates shouldn't exceed 108 in their absolute value.

Examples

Input

4 3

Output

0 0
3 0
0 3
1 1

Input

6 3

Output

-1

Input

6 6

Output

10 0
-10 0
10 1
9 1
9 -1
0 -2

Input

7 4

Output

176166 6377
709276 539564
654734 174109
910147 434207
790497 366519
606663 21061
859328 886001

```python
def f(x):
    return int(x * x + 1e7)

def g(x):
    return -f(x)

n, m = map(int, input().split())

if(m == 3):
    if(n == 3):
        print('0 0')
        print('1 0')
        print('0 1')
    elif(n == 4):
        print('0 0')
        print('1 1')
        print('10000 0')
        print('0 10000')
    else:
        print(-1)
else:
    for i in range(m):
        print(i, f(i))
    for i in range(n - m):
        print(i, g(i))
```


29_D. Ant on the Tree

Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.

An ant stands at the root of some tree. He sees that there are n vertexes in the tree, and they are connected by n - 1 edges so that there is a path between any pair of vertexes. A leaf is a distinct from root vertex, which is connected with exactly one other vertex.

The ant wants to visit every vertex in the tree and return to the root, passing every edge twice. In addition, he wants to visit the leaves in a specific order. You are to find some possible route of the ant.

Input

The first line contains integer n (3 ≤ n ≤ 300) — amount of vertexes in the tree. Next n - 1 lines describe edges. Each edge is described with two integers — indexes of vertexes which it connects. Each edge can be passed in any direction. Vertexes are numbered starting from 1. The root of the tree has number 1. The last line contains k integers, where k is amount of leaves in the tree. These numbers describe the order in which the leaves should be visited. It is guaranteed that each leaf appears in this order exactly once.

Output

If the required route doesn't exist, output -1. Otherwise, output 2n - 1 numbers, describing the route. Every time the ant comes to a vertex, output it's index.

Examples

Input

3
1 2
2 3
3

Output

1 2 3 2 1

Input

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

Output

1 2 4 5 4 6 4 2 1 3 1

Input

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

Output

-1

```python
n = int(input())
adj = [[] for i in range(n)]
adj2 = [[] for i in range(n)]
for i in range(n-1):
    u,v = map(int,input().split())
    adj[u-1].append(v-1)
    adj[v-1].append(u-1)

leaf = {}
a = list(map(int,input().split()))
for i in range(len(a)):
    leaf[a[i]-1] = i
inf = 200000
def dfs1(v,frm,adj2):
    if len(adj[v]) == 1 and v!=0:
        return (inf if v not in leaf else leaf[v],v)
    best = float("inf")
    for u in adj[v]:
        if u != frm:
            c = dfs1(u,v,adj2)
            adj2[v].append(c)
            best = min(best,c[0])
    return (best,v)

dfs1(0,-1,adj2)
path = []
for i in range(n):
    adj2[i].sort()
#print(*adj2)
def dfs2(v,frm,path):
    path.append(v+1)
    for _,u in adj2[v]:
        if u!=frm:
            dfs2(u,v,path)
    if frm!=-1:
        path.append(frm+1)
dfs2(0,-1,path)
gd = []
for i in path:
    if i-1 in leaf:
        gd.append(i)

if gd == a:
    print(*path)
else:
    print(-1)

```


371_A. K-Periodic Array

This task will exclusively concentrate only on the arrays where all elements equal 1 and/or 2.

Array a is k-period if its length is divisible by k and there is such array b of length k, that a is represented by array b written exactly <image> times consecutively. In other words, array a is k-periodic, if it has period of length k.

For example, any array is n-periodic, where n is the array length. Array [2, 1, 2, 1, 2, 1] is at the same time 2-periodic and 6-periodic and array [1, 2, 1, 1, 2, 1, 1, 2, 1] is at the same time 3-periodic and 9-periodic.

For the given array a, consisting only of numbers one and two, find the minimum number of elements to change to make the array k-periodic. If the array already is k-periodic, then the required value equals 0.

Input

The first line of the input contains a pair of integers n, k (1 ≤ k ≤ n ≤ 100), where n is the length of the array and the value n is divisible by k. The second line contains the sequence of elements of the given array a1, a2, ..., an (1 ≤ ai ≤ 2), ai is the i-th element of the array.

Output

Print the minimum number of array elements we need to change to make the array k-periodic. If the array already is k-periodic, then print 0.

Examples

Input

6 2
2 1 2 2 2 1

Output

1

Input

8 4
1 1 2 1 1 1 2 1

Output

0

Input

9 3
2 1 1 1 2 1 1 1 2

Output

3

Note

In the first sample it is enough to change the fourth element from 2 to 1, then the array changes to [2, 1, 2, 1, 2, 1].

In the second sample, the given array already is 4-periodic.

In the third sample it is enough to replace each occurrence of number two by number one. In this case the array will look as [1, 1, 1, 1, 1, 1, 1, 1, 1] — this array is simultaneously 1-, 3- and 9-periodic.

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

print(sum(min(x.count(1), x.count(2)) for x in (a[i::k] for i in range(k))))

```


415_D. Mashmokh and ACM

Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced programmer. Actually he is not a programmer at all. So he wasn't able to solve them. That's why he asked you to help him with these tasks. One of these tasks is the following.

A sequence of l integers b1, b2, ..., bl (1 ≤ b1 ≤ b2 ≤ ... ≤ bl ≤ n) is called good if each number divides (without a remainder) by the next number in the sequence. More formally <image> for all i (1 ≤ i ≤ l - 1).

Given n and k find the number of good sequences of length k. As the answer can be rather large print it modulo 1000000007 (109 + 7).

Input

The first line of input contains two space-separated integers n, k (1 ≤ n, k ≤ 2000).

Output

Output a single integer — the number of good sequences of length k modulo 1000000007 (109 + 7).

Examples

Input

3 2

Output

5

Input

6 4

Output

39

Input

2 1

Output

2

Note

In the first sample the good sequences are: [1, 1], [2, 2], [3, 3], [1, 2], [1, 3].

```python
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    n,k = LI()
    t = [0] * n
    t[0] = 1

    for _ in range(k):
        u = [0] * n
        for i in range(n):
            b = t[i] % mod
            for j in range(i,n,i+1):
                u[j] += b
        t = u

    return sum(t) % mod

print(main())

```


442_B. Andrey and Problem

Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him.

Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset.

Input

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point.

Output

Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9.

Examples

Input

4
0.1 0.2 0.3 0.8

Output

0.800000000000

Input

2
0.1 0.2

Output

0.260000000000

Note

In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one.

In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26.

```python
n=int(input())
from itertools import combinations

a = sorted(list(map(float, input().split())), reverse=True)
#a=[0.01]*100
if max(a) == 1:
    print(1)
    quit()
n=len(a)
pre = [1]*100
pre[0] = 1 - a[0]
for i in range(1, n):
    pre[i] = pre[i-1] * (1-a[i])

ans = 0
for i in range(1,n+1):
    anss=0
    for j in range(i):
        anss = anss + pre[i-1] / (1-a[j]) * a[j]
    ans = max(ans, anss)
print(ans)
```


464_C. Substitutes in Number

Andrew and Eugene are playing a game. Initially, Andrew has string s, consisting of digits. Eugene sends Andrew multiple queries of type "di → ti", that means "replace all digits di in string s with substrings equal to ti". For example, if s = 123123, then query "2 → 00" transforms s to 10031003, and query "3 → " ("replace 3 by an empty string") transforms it to s = 1212. After all the queries Eugene asks Andrew to find the remainder after division of number with decimal representation equal to s by 1000000007 (109 + 7). When you represent s as a decimal number, please ignore the leading zeroes; also if s is an empty string, then it's assumed that the number equals to zero.

Andrew got tired of processing Eugene's requests manually and he asked you to write a program for that. Help him!

Input

The first line contains string s (1 ≤ |s| ≤ 105), consisting of digits — the string before processing all the requests.

The second line contains a single integer n (0 ≤ n ≤ 105) — the number of queries.

The next n lines contain the descriptions of the queries. The i-th query is described by string "di->ti", where di is exactly one digit (from 0 to 9), ti is a string consisting of digits (ti can be an empty string). The sum of lengths of ti for all queries doesn't exceed 105. The queries are written in the order in which they need to be performed.

Output

Print a single integer — remainder of division of the resulting number by 1000000007 (109 + 7).

Examples

Input

123123
1
2->00

Output

10031003

Input

123123
1
3->

Output

1212

Input

222
2
2->0
0->7

Output

777

Input

1000000008
0

Output

1

Note

Note that the leading zeroes are not removed from string s after the replacement (you can see it in the third sample).

```python
mod=pow(10,9)+7
def sub_and_eval(n):
    if n=='':
        return 0
    ans=v[int(n[0])]
    for i in range(1,len(n)):
        ans=(d[int(n[i])]*ans+v[int(n[i])])%mod
    return ans
def prod_d(n):
    ans=1
    for e in n:
        ans=ans*d[int(e)]%mod
    return ans
s=input()
v={i:i for i in range(10)}
d={i:10 for i in range(10)}

k=int(input())
arr=[]
for _ in range(k):
    a,b=input().split('->')
    arr.append((a,b))
for a,b in reversed(arr):
    v[int(a)]=sub_and_eval(b)
    d[int(a)]=prod_d(b)
print(sub_and_eval(s))

```


488_B. Candy Boxes

There is an old tradition of keeping 4 boxes of candies in the house in Cyberland. The numbers of candies are special if their arithmetic mean, their median and their range are all equal. By definition, for a set {x1, x2, x3, x4} (x1 ≤ x2 ≤ x3 ≤ x4) arithmetic mean is <image>, median is <image> and range is x4 - x1. The arithmetic mean and median are not necessary integer. It is well-known that if those three numbers are same, boxes will create a "debugging field" and codes in the field will have no bugs.

For example, 1, 1, 3, 3 is the example of 4 numbers meeting the condition because their mean, median and range are all equal to 2.

Jeff has 4 special boxes of candies. However, something bad has happened! Some of the boxes could have been lost and now there are only n (0 ≤ n ≤ 4) boxes remaining. The i-th remaining box contains ai candies.

Now Jeff wants to know: is there a possible way to find the number of candies of the 4 - n missing boxes, meeting the condition above (the mean, median and range are equal)?

Input

The first line of input contains an only integer n (0 ≤ n ≤ 4).

The next n lines contain integers ai, denoting the number of candies in the i-th box (1 ≤ ai ≤ 500).

Output

In the first output line, print "YES" if a solution exists, or print "NO" if there is no solution.

If a solution exists, you should output 4 - n more lines, each line containing an integer b, denoting the number of candies in a missing box.

All your numbers b must satisfy inequality 1 ≤ b ≤ 106. It is guaranteed that if there exists a positive integer solution, you can always find such b's meeting the condition. If there are multiple answers, you are allowed to print any of them.

Given numbers ai may follow in any order in the input, not necessary in non-decreasing.

ai may have stood at any positions in the original set, not necessary on lowest n first positions.

Examples

Input

2
1
1

Output

YES
3
3

Input

3
1
1
1

Output

NO

Input

4
1
2
2
3

Output

YES

Note

For the first sample, the numbers of candies in 4 boxes can be 1, 1, 3, 3. The arithmetic mean, the median and the range of them are all 2.

For the second sample, it's impossible to find the missing number of candies.

In the third example no box has been lost and numbers satisfy the condition.

You may output b in any order.

```python
n=int(input())
if n==0:
    print('YES')
    print(1)
    print(1)
    print(3)
    print(3)
else:
    lis=[]
    for i in range(n):
        lis.append(int(input()))
    lis.sort()

    if n==1:
        print('YES')
        print(lis[0])
        print(3*lis[0])
        print(3*lis[0])

    if n==2:
        if lis[1]-lis[0]>2*lis[0]:
            print('NO')
        else:
            print('YES')
            print(4*lis[0]-lis[1])
            print(3*lis[0])
    if n==3:
        if lis[1]+lis[2]==4*lis[0] and max(lis[1],lis[2])<=3*lis[0]:
            print('YES')
            print(3*lis[0])
        elif lis[2]==3*lis[0]:
            print('YES')
            print(4*lis[0]-lis[1])
        elif (lis[0]+lis[1])*3==4*lis[2]:
            print('YES')
            print(int(lis[2]/3))
        else:
            print('NO')
    if n==4:
        if lis[3]==3*lis[0] and lis[1]+lis[2]==4*lis[0]:
            print('YES')
        else:
            print('NO')

```


512_A. Fox And Names

Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.

After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in lexicographical order in normal sense. But it was always true that after some modification of the order of letters in alphabet, the order of authors becomes lexicographical!

She wants to know, if there exists an order of letters in Latin alphabet such that the names on the paper she is submitting are following in the lexicographical order. If so, you should find out any such order.

Lexicographical order is defined in following way. When we compare s and t, first we find the leftmost position with differing characters: si ≠ ti. If there is no such position (i. e. s is a prefix of t or vice versa) the shortest string is less. Otherwise, we compare characters si and ti according to their order in alphabet.

Input

The first line contains an integer n (1 ≤ n ≤ 100): number of names.

Each of the following n lines contain one string namei (1 ≤ |namei| ≤ 100), the i-th name. Each name contains only lowercase Latin letters. All names are different.

Output

If there exists such order of letters that the given names are sorted lexicographically, output any such order as a permutation of characters 'a'–'z' (i. e. first output the first letter of the modified alphabet, then the second, and so on).

Otherwise output a single word "Impossible" (without quotes).

Examples

Input

3
rivest
shamir
adleman

Output

bcdefghijklmnopqrsatuvwxyz

Input

10
tourist
petr
wjmzbmr
yeputons
vepifanov
scottwu
oooooooooooooooo
subscriber
rowdark
tankengineer

Output

Impossible

Input

10
petr
egor
endagorion
feferivan
ilovetanyaromanova
kostka
dmitriyh
maratsnowbear
bredorjaguarturnik
cgyforever

Output

aghjlnopefikdmbcqrstuvwxyz

Input

7
car
care
careful
carefully
becarefuldontforgetsomething
otherwiseyouwillbehacked
goodluck

Output

acbdefhijklmnogpqrstuvwxyz

```python
import sys
import heapq

n = int(sys.stdin.readline().strip())
w = []
g = {i:set({}) for i in "azertyuiopqsdfghjklmwxcvbn"}
for i in range(n):
	w.append(sys.stdin.readline().strip())
for i in range(n-1):
	idx = 0
	while idx < min(len(w[i]), len(w[i+1])) - 1 and w[i][idx] == w[i+1][idx]:
		idx += 1
	if w[i][idx] == w[i+1][idx] and len(w[i]) > len(w[i+1]):
		print('Impossible')
		break
	if w[i][idx] != w[i+1][idx]:
		g[w[i+1][idx]].add(w[i][idx])
else:
	ans = ""
	while g:
		for i in "azertyuiopqsdfghjklmwxcvbn":
			if i in g and not g[i]:
				ans += i
				del g[i]
				for j in "azertyuiopqsdfghjklmwxcvbn":
					if j in g and i in g[j]:
						g[j].remove(i)
				break
		else:
			print("Impossible")
			break
	else:
		print(ans)
```


536_B. Tavas and Malekas

Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead.

<image>

Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions x1 < x2 < ... < xk where p matches s. More formally, for each xi (1 ≤ i ≤ k) he condition sxisxi + 1... sxi + |p| - 1 = p is fullfilled.

Then Malekas wrote down one of subsequences of x1, x2, ... xk (possibly, he didn't write anything) on a piece of paper. Here a sequence b is a subsequence of sequence a if and only if we can turn a into b by removing some of its elements (maybe no one of them or all).

After Tavas woke up, Malekas told him everything. He couldn't remember string s, but he knew that both p and s only contains lowercase English letters and also he had the subsequence he had written on that piece of paper.

Tavas wonders, what is the number of possible values of s? He asked SaDDas, but he wasn't smart enough to solve this. So, Tavas asked you to calculate this number for him.

Answer can be very large, so Tavas wants you to print the answer modulo 109 + 7.

Input

The first line contains two integers n and m, the length of s and the length of the subsequence Malekas wrote down (1 ≤ n ≤ 106 and 0 ≤ m ≤ n - |p| + 1).

The second line contains string p (1 ≤ |p| ≤ n).

The next line contains m space separated integers y1, y2, ..., ym, Malekas' subsequence (1 ≤ y1 < y2 < ... < ym ≤ n - |p| + 1).

Output

In a single line print the answer modulo 1000 000 007.

Examples

Input

6 2
ioi
1 3

Output

26

Input

5 2
ioi
1 2

Output

0

Note

In the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.

Here |x| denotes the length of string x.

Please note that it's possible that there is no such string (answer is 0).

```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")
##########################################################
from collections import Counter,defaultdict
import math
#for _ in range(int(input())):
    #n=int(input())
def matching(s):
    le = len(s)
    pi=[0]*le
    for i in range(1,le):
        j=pi[i-1]
        while j>0 and s[i]!=s[j]:
            j=pi[j-1]
        if(s[i]==s[j]):
            j+=1
        pi[i]=j
    #return pi
    ## to return list of values
    w=set()
    i=le-1
    while pi[i]!=0:
        w.add(le-pi[i])
        i=pi[i]-1
    return w

n,m=map(int,input().split())
p=input()
if m==0:
    print(pow(26,n,10**9+7))
    sys.exit()
arr=list(map(int, input().split()))
#a1=list(map(int, input().split()))

ans=0
l=len(p)
pre=matching(p)
filled=l
for i in range(1,m):
    if (arr[i]-arr[i-1]<l and (arr[i]-arr[i-1]) not in pre):

        print(0)
        sys.exit()
    filled+=min(l,arr[i]-arr[i-1])

print(pow(26,n-filled,10**9+7))

```


560_C. Gerald's Hexagon

Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it.

He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles.

Input

The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≤ ai ≤ 1000) — the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists.

Output

Print a single integer — the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.

Examples

Input

1 1 1 1 1 1

Output

6

Input

1 2 1 2 1 2

Output

13

Note

This is what Gerald's hexagon looks like in the first sample:

<image>

And that's what it looks like in the second sample:

<image>


586_E. Alice, Bob, Oranges and Apples

Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on each one they wrote a letter, either 'A', or the letter 'B'. Then they began to remove the cards one by one from left to right, every time they removed a card with the letter 'A', Alice gave Bob all the fruits she had at that moment and took out of the bag as many apples and as many oranges as she had before. Thus the number of oranges and apples Alice had, did not change. If the card had written letter 'B', then Bob did the same, that is, he gave Alice all the fruit that he had, and took from the bag the same set of fruit. After the last card way removed, all the fruit in the bag were over.

You know how many oranges and apples was in the bag at first. Your task is to find any sequence of cards that Alice and Bob could have played with.

Input

The first line of the input contains two integers, x, y (1 ≤ x, y ≤ 1018, xy > 1) — the number of oranges and apples that were initially in the bag.

Output

Print any sequence of cards that would meet the problem conditions as a compressed string of characters 'A' and 'B. That means that you need to replace the segments of identical consecutive characters by the number of repetitions of the characters and the actual character. For example, string AAABAABBB should be replaced by string 3A1B2A3B, but cannot be replaced by 2A1A1B2A3B or by 3AB2A3B. See the samples for clarifications of the output format. The string that you print should consist of at most 106 characters. It is guaranteed that if the answer exists, its compressed representation exists, consisting of at most 106 characters. If there are several possible answers, you are allowed to print any of them.

If the sequence of cards that meet the problem statement does not not exist, print a single word Impossible.

Examples

Input

1 4

Output

3B

Input

2 2

Output

Impossible

Input

3 2

Output

1A1B

Note

In the first sample, if the row contained three cards with letter 'B', then Bob should give one apple to Alice three times. So, in the end of the game Alice has one orange and three apples, and Bob has one apple, in total it is one orange and four apples.

In second sample, there is no answer since one card is not enough for game to finish, and two cards will produce at least three apples or three oranges.

In the third sample, cards contain letters 'AB', so after removing the first card Bob has one orange and one apple, and after removal of second card Alice has two oranges and one apple. So, in total it is three oranges and two apples.

```python
def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x
x, y = map(int, input().split())
if gcd(x, y) != 1:
    print ("Impossible")
    exit(0)
res = ""
while x > 0 and y > 0:
    if y > x:
        if x == 1:
            y -= 1
        res = res + str(y // x) + "B"
        y = y % x
    else:
        if y == 1:
            x -= 1
        res = res + str(x // y) + "A"
        x = x % y
print(res)

```


609_A. USB Flash Drives

Sean is trying to save a large file to a USB flash drive. He has n USB flash drives with capacities equal to a1, a2, ..., an megabytes. The file size is equal to m megabytes.

Find the minimum number of USB flash drives needed to write Sean's file, if he can split the file between drives.

Input

The first line contains positive integer n (1 ≤ n ≤ 100) — the number of USB flash drives.

The second line contains positive integer m (1 ≤ m ≤ 105) — the size of Sean's file.

Each of the next n lines contains positive integer ai (1 ≤ ai ≤ 1000) — the sizes of USB flash drives in megabytes.

It is guaranteed that the answer exists, i. e. the sum of all ai is not less than m.

Output

Print the minimum number of USB flash drives to write Sean's file, if he can split the file between drives.

Examples

Input

3
5
2
1
3

Output

2

Input

3
6
2
3
2

Output

3

Input

2
5
5
10

Output

1

Note

In the first example Sean needs only two USB flash drives — the first and the third.

In the second example Sean needs all three USB flash drives.

In the third example Sean needs only one USB flash drive and he can use any available USB flash drive — the first or the second.

```python
n = int(input())
m = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort(reverse=True)
for i in range(n):
    m -= a[i]
    if m <= 0:
        print(i+1)
        exit()

```


656_D. Rosetta Problem

    ++++++++[>+>++>+++>++++>+++++>++++++>+++++++>++++++++>+++++++++>++++++++++>+
    ++++++++++>++++++++++++>+++++++++++++>++++++++++++++>+++++++++++++++>+++++++
    +++++++++<<<<<<<<<<<<<<<<-]>>>>>>>>>>.<<<<<<<<<<>>>>>>>>>>>>>>++.--<<<<<<<<<
    <<<<<>>>>>>>>>>>>>+.-<<<<<<<<<<<<<>>>>>>>>>>>>>>--.++<<<<<<<<<<<<<<>>>>>>>>>
    >>>>>>----.++++<<<<<<<<<<<<<<<>>>>.<<<<>>>>>>>>>>>>>>--.++<<<<<<<<<<<<<<>>>>
    >>>>>>>>>>>---.+++<<<<<<<<<<<<<<<>>>>>>>>>>>>>>---.+++<<<<<<<<<<<<<<>>>>>>>>
    >>>>++.--<<<<<<<<<<<<>>>>>>>>>>>>>---.+++<<<<<<<<<<<<<>>>>>>>>>>>>>>++.--<<<
    <<<<<<<<<<<.

    DCBA:^!~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHdcbD`Y^]\UZYRv
    9876543210/.-,+*)('&%$#"!~}|{zyxwvutsrqponm+*)('&%$#cya`=^]\[ZYXWVUTSRQPONML
    KJfe^cba`_X]VzTYRv98TSRQ3ONMLEi,+*)('&%$#"!~}|{zyxwvutsrqponmlkjihgfedcba`_^
    ]\[ZYXWVUTSonPlkjchg`ed]#DCBA@?>=<;:9876543OHGLKDIHGFE>b%$#"!~}|{zyxwvutsrqp
    onmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMibafedcba`_X|?>Z<XWVUTSRKo\

<image>

    v34*8+6+,78+9*3+,93+9*5+,28+9*1+,55+9*4+,23*6*2*,91,@,+7*9*25,*48,+3*9+38,+<
    >62*9*2+,34*9*3+,66+9*8+,52*9*7+,75+9*8+,92+9*6+,48+9*3+,43*9*2+,84*,26*9*3^

Input

The input contains a single integer a (0 ≤ a ≤ 1 000 000).

Output

Output a single integer.

Example

Input

129

Output

1

```python
n=eval(input())
cnt=0
while n:
    a=n%8
    n=n//8
    if a==1:
        cnt+=1
print(cnt)
```


67_D. Optical Experiment

Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.

There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each hole. The holes are in a straight line.

<image>

Professor Wangdu is showing his experiment to his students. He shows that there are cases, when all the rays are intersected by every other ray. A curious student asked the professor: "Sir, there are some groups of rays such that all rays in that group intersect every other ray in that group. Can we determine the number of rays in the largest of such groups?".

Professor Wangdu now is in trouble and knowing your intellect he asks you to help him.

Input

The first line contains n (1 ≤ n ≤ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≤ xi ≤ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≤ yi ≤ n) shows that the yi-th ray exits from the i-th hole. All rays are numbered from 1 to n.

Output

Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other.

Examples

Input

5
1 4 5 2 3
3 4 2 1 5

Output

3

Input

3
3 1 2
2 3 1

Output

2

Note

For the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersected by each other one. There does not exist any group containing more than 3 rays satisfying the above-mentioned constraint.

```python
from bisect import bisect_left as bl
I=10000000
n=int(input())+1
c=[0]*n
for i,x in enumerate(map(int,input().split())): c[x]=i
d = [n-c[int(x)] for x in input().split()]
c=[I]*n
for i in d: c[bl(c,i)]=i
print( c.index(I))
```


702_D. Road to Post Office

Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to d kilometers.

Vasiliy's car is not new — it breaks after driven every k kilometers and Vasiliy needs t seconds to repair it. After repairing his car Vasiliy can drive again (but after k kilometers it will break again, and so on). In the beginning of the trip the car is just from repair station.

To drive one kilometer on car Vasiliy spends a seconds, to walk one kilometer on foot he needs b seconds (a < b).

Your task is to find minimal time after which Vasiliy will be able to reach the post office. Consider that in every moment of time Vasiliy can left his car and start to go on foot.

Input

The first line contains 5 positive integers d, k, a, b, t (1 ≤ d ≤ 1012; 1 ≤ k, a, b, t ≤ 106; a < b), where:

  * d — the distance from home to the post office;
  * k — the distance, which car is able to drive before breaking;
  * a — the time, which Vasiliy spends to drive 1 kilometer on his car;
  * b — the time, which Vasiliy spends to walk 1 kilometer on foot;
  * t — the time, which Vasiliy spends to repair his car.

Output

Print the minimal time after which Vasiliy will be able to reach the post office.

Examples

Input

5 2 1 4 10

Output

14

Input

5 2 1 4 5

Output

13

Note

In the first example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds) and then to walk on foot 3 kilometers (in 12 seconds). So the answer equals to 14 seconds.

In the second example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds), then repair his car (in 5 seconds) and drive 2 kilometers more on the car (in 2 seconds). After that he needs to walk on foot 1 kilometer (in 4 seconds). So the answer equals to 13 seconds.

```python
import math
d, k, a, b, t = map(int, input().split())

distance = a * t /((b -a )*b) + t /b
time = 0
n = math.ceil((d-distance)/k)

# print(distance)
# print(n)
if (k>d):
    print(d*a)
    exit(0)
if (k<distance):
    time = k*a + (d-k)*b
    print(time)
    exit(0)
if (n*k >=d):
    time = a*d + d//k*t
    if (d%k==0):
        time -= t
else:
    time = n*k*a + (n-1)*t +(d - n*k)*b
print(time)

```


746_E. Numbers Exchange

Eugeny has n cards, each of them has exactly one integer written on it. Eugeny wants to exchange some cards with Nikolay so that the number of even integers on his cards would equal the number of odd integers, and that all these numbers would be distinct.

Nikolay has m cards, distinct numbers from 1 to m are written on them, one per card. It means that Nikolay has exactly one card with number 1, exactly one card with number 2 and so on.

A single exchange is a process in which Eugeny gives one card to Nikolay and takes another one from those Nikolay has. Your task is to find the minimum number of card exchanges and determine which cards Eugeny should exchange.

Input

The first line contains two integers n and m (2 ≤ n ≤ 2·105, 1 ≤ m ≤ 109) — the number of cards Eugeny has and the number of cards Nikolay has. It is guaranteed that n is even.

The second line contains a sequence of n positive integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the numbers on Eugeny's cards.

Output

If there is no answer, print -1.

Otherwise, in the first line print the minimum number of exchanges. In the second line print n integers — Eugeny's cards after all the exchanges with Nikolay. The order of cards should coincide with the card's order in the input data. If the i-th card wasn't exchanged then the i-th number should coincide with the number from the input data. Otherwise, it is considered that this card was exchanged, and the i-th number should be equal to the number on the card it was exchanged to.

If there are multiple answers, it is allowed to print any of them.

Examples

Input

6 2
5 6 7 9 4 5

Output

1
5 6 7 9 4 2

Input

8 6
7 7 7 7 8 8 8 8

Output

6
7 2 4 6 8 1 3 5

Input

4 1
4 2 1 10

Output

-1

```python
n, m = map(int, input().split())
a = list(map(int, input().split()))

counter = 0

s = set(a)
nech = set()
chet = set()
for elem in a:
    if elem % 2:
        nech.add(elem)
    else:
        chet.add(elem)

while len(nech) > n // 2:
    nech.pop()
while len(chet) > n // 2:
    chet.pop()

l_n =  set([i for i in range(1, min(m + 1, 1000000), 2)])
l_ch = set([i for i in range(2, min(m + 1, 1000000), 2)])

l_ch.difference_update(chet)
l_n.difference_update(nech)

#print(l_ch)
#print(l_n, nech)

if len(l_ch) + len(chet) < n // 2 or len(l_n) + len(nech) < n // 2:
    print(-1)
else:
    n1 = len(chet)
    n2 = len(nech)
    for i in range(n):
        if a[i] in chet:
            chet.remove(a[i])
        elif a[i] in nech:
            nech.remove(a[i])
        else:
            counter += 1
            if (n//2 - n1) > 0:
                a[i] = l_ch.pop()
                n1 += 1
            else:
                a[i] = l_n.pop()
                n2 += 1

    print(counter)
    print(*a)
```


793_E. Problem of offices

Earlier, when there was no Internet, each bank had a lot of offices all around Bankopolis, and it caused a lot of problems. Namely, each day the bank had to collect cash from all the offices.

Once Oleg the bank client heard a dialogue of two cash collectors. Each day they traveled through all the departments and offices of the bank following the same route every day. The collectors started from the central department and moved between some departments or between some department and some office using special roads. Finally, they returned to the central department. The total number of departments and offices was n, the total number of roads was n - 1. In other words, the special roads system was a rooted tree in which the root was the central department, the leaves were offices, the internal vertices were departments. The collectors always followed the same route in which the number of roads was minimum possible, that is 2n - 2.

One of the collectors said that the number of offices they visited between their visits to offices a and then b (in the given order) is equal to the number of offices they visited between their visits to offices b and then a (in this order). The other collector said that the number of offices they visited between their visits to offices c and then d (in this order) is equal to the number of offices they visited between their visits to offices d and then c (in this order). The interesting part in this talk was that the shortest path (using special roads only) between any pair of offices among a, b, c and d passed through the central department.

Given the special roads map and the indexes of offices a, b, c and d, determine if the situation described by the collectors was possible, or not.

Input

The first line contains single integer n (5 ≤ n ≤ 5000) — the total number of offices and departments. The departments and offices are numbered from 1 to n, the central office has index 1.

The second line contains four integers a, b, c and d (2 ≤ a, b, c, d ≤ n) — the indexes of the departments mentioned in collector's dialogue. It is guaranteed that these indexes are offices (i.e. leaves of the tree), not departments. It is guaranteed that the shortest path between any pair of these offices passes through the central department.

On the third line n - 1 integers follow: p2, p3, ..., pn (1 ≤ pi < i), where pi denotes that there is a special road between the i-th office or department and the pi-th department.

Please note the joint enumeration of departments and offices.

It is guaranteed that the given graph is a tree. The offices are the leaves, the departments are the internal vertices.

Output

If the situation described by the cash collectors was possible, print "YES". Otherwise, print "NO".

Examples

Input

5
2 3 4 5
1 1 1 1

Output

YES

Input

10
3 8 9 10
1 2 2 2 2 2 1 1 1

Output

NO

Input

13
13 12 9 7
1 1 1 1 5 5 2 2 2 3 3 4

Output

YES

Note

In the first example the following collector's route was possible: <image>. We can note that between their visits to offices a and b the collectors visited the same number of offices as between visits to offices b and a; the same holds for c and d (the collectors' route is infinite as they follow it each day).

In the second example there is no route such that between their visits to offices c and d the collectors visited the same number of offices as between visits to offices d and c. Thus, there situation is impossible.

In the third example one of the following routes is: <image>.

```python
n=int(input())
num=input().split(' ')
l=[0]*4
for i in range(4):
    l[i]=int(num[i])
t=tuple(l)
a,b,c,d=t
p=[0]*(n+1)
num=input().split(' ')
mp=[list() for _ in range(n+1)]
for i in range(2,n+1):
    p[i]=int(num[i-2])

    mp[p[i]].append(i)
s=[0]*(n+1)
def sof(i):
    if s[i]!=0:
        return s[i]
    if len(mp[i])>0:
        res=0
        for son in mp[i]:
            res+=sof(son)
        s[i]=res
        return res
    else:
        s[i]=1
        return 1
rootofl=list()
for leaf in l:
    while p[leaf]!=1:
        leaf=p[leaf]
    rootofl.append(leaf)
rootlist=list()
for rootson in mp[1]:
    if not rootson in rootofl:
        rootlist.append(rootson)
def canpick(a,des):
    if des==0:
        return True
    picklist=rootlist[:]
    for j in range(2):
        cur=a[j]
        while p[cur]!=1:
            fa=p[cur]
            for i in mp[fa]:
                if i!=cur :
                    picklist.append(i)
            cur=fa
    v=set()
    v.add(0)
    for i in range(len(picklist)):
        val=sof(picklist[i])
        v |= {ori+val
              for ori in v}
        if des in v:
            return True
    return False
    '''
    v=[False]*(n+1)
    v[0]=True

    for i in range(len(picklist)):
        val=sof(picklist[i])
        if des-val>=0 and v[des-val]:
            return True
        for j in range(des-val,-1,-1):
            if  v[j] :
                v[j+val]=True
    return False
    '''
m=sof(1)
if m%2==1:
    print('NO')
else:
    v1=m//2-1-sof(rootofl[2])
    v2=m//2-1-sof(rootofl[0])
    if canpick([a,b], v1) and canpick([c,d], v2):
        print('YES')
    else:
        print('NO')
```


814_B. An express train to reveries

Sengoku still remembers the mysterious "colourful meteoroids" she discovered with Lala-chan when they were little. In particular, one of the nights impressed her deeply, giving her the illusion that all her fancies would be realized.

On that night, Sengoku constructed a permutation p1, p2, ..., pn of integers from 1 to n inclusive, with each integer representing a colour, wishing for the colours to see in the coming meteor outburst. Two incredible outbursts then arrived, each with n meteorids, colours of which being integer sequences a1, a2, ..., an and b1, b2, ..., bn respectively. Meteoroids' colours were also between 1 and n inclusive, and the two sequences were not identical, that is, at least one i (1 ≤ i ≤ n) exists, such that ai ≠ bi holds.

Well, she almost had it all — each of the sequences a and b matched exactly n - 1 elements in Sengoku's permutation. In other words, there is exactly one i (1 ≤ i ≤ n) such that ai ≠ pi, and exactly one j (1 ≤ j ≤ n) such that bj ≠ pj.

For now, Sengoku is able to recover the actual colour sequences a and b through astronomical records, but her wishes have been long forgotten. You are to reconstruct any possible permutation Sengoku could have had on that night.

Input

The first line of input contains a positive integer n (2 ≤ n ≤ 1 000) — the length of Sengoku's permutation, being the length of both meteor outbursts at the same time.

The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ n) — the sequence of colours in the first meteor outburst.

The third line contains n space-separated integers b1, b2, ..., bn (1 ≤ bi ≤ n) — the sequence of colours in the second meteor outburst. At least one i (1 ≤ i ≤ n) exists, such that ai ≠ bi holds.

Output

Output n space-separated integers p1, p2, ..., pn, denoting a possible permutation Sengoku could have had. If there are more than one possible answer, output any one of them.

Input guarantees that such permutation exists.

Examples

Input

5
1 2 3 4 3
1 2 5 4 5

Output

1 2 5 4 3

Input

5
4 4 2 3 1
5 4 5 3 1

Output

5 4 2 3 1

Input

4
1 1 3 4
1 4 3 4

Output

1 2 3 4

Note

In the first sample, both 1, 2, 5, 4, 3 and 1, 2, 3, 4, 5 are acceptable outputs.

In the second sample, 5, 4, 2, 3, 1 is the only permutation to satisfy the constraints.

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

a = list(map(int, input().split()))
b = list(map(int, input().split()))

# generate all 4 possibilities
dupa = []
dupb = []
for i in range(len(a)):
    try:
        index = a[i+1:].index(a[i])
        dupa.append(i)
        dupa.append(index+i+1)
        break
    except ValueError:
        pass

for absent in range(1, len(a) + 1 ):
    if not absent in a:
        absenta = absent
        break

pa1 = list(a)
pa2 = list(a)
pa1[dupa[0]] = absenta
pa2[dupa[1]] = absenta

for i in range(len(b)):
    try:
        index = b[i+1:].index(b[i])
        dupb.append(i)
        dupb.append(index+i+1)
        break
    except ValueError:
        pass

for absent in range(1, len(b) + 1 ):
    if not absent in b:
        absentb = absent
        break

pb1 = list(b)
pb2 = list(b)

pb1[dupb[0]] = absentb
pb2[dupb[1]] = absentb

# print the right possibility
if (pa1>pb1)-(pa1<pb1) == 0 or (pa1>pb2)-(pa1<pb2) == 0:
    print( " ".join([str(x) for x in pa1]) )
else:
    print( " ".join([str(x) for x in pa2]) )

```


83_B. Doctor

There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and therefore knows exactly that the animal number i in the queue will have to visit his office exactly ai times. We will assume that an examination takes much more time than making tests and other extra procedures, and therefore we will assume that once an animal leaves the room, it immediately gets to the end of the queue to the doctor. Of course, if the animal has visited the doctor as many times as necessary, then it doesn't have to stand at the end of the queue and it immediately goes home.

Doctor plans to go home after receiving k animals, and therefore what the queue will look like at that moment is important for him. Since the doctor works long hours and she can't get distracted like that after all, she asked you to figure it out.

Input

The first line of input data contains two space-separated integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 1014). In the second line are given space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).

Please do not use the %lld specificator to read or write 64-bit numbers in C++. It is recommended to use cin, cout streams (you can also use the %I64d specificator).

Output

If the doctor will overall carry out less than k examinations, print a single number "-1" (without quotes). Otherwise, print the sequence of numbers — number of animals in the order in which they stand in the queue.

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

Examples

Input

3 3
1 2 1

Output

2

Input

4 10
3 3 2 1

Output

-1

Input

7 10
1 3 3 1 2 3 1

Output

6 2 3

Note

In the first sample test:

  * Before examination: {1, 2, 3}
  * After the first examination: {2, 3}
  * After the second examination: {3, 2}
  * After the third examination: {2}

In the second sample test:

  * Before examination: {1, 2, 3, 4, 5, 6, 7}
  * After the first examination: {2, 3, 4, 5, 6, 7}
  * After the second examination: {3, 4, 5, 6, 7, 2}
  * After the third examination: {4, 5, 6, 7, 2, 3}
  * After the fourth examination: {5, 6, 7, 2, 3}
  * After the fifth examination: {6, 7, 2, 3, 5}
  * After the sixth examination: {7, 2, 3, 5, 6}
  * After the seventh examination: {2, 3, 5, 6}
  * After the eighth examination: {3, 5, 6, 2}
  * After the ninth examination: {5, 6, 2, 3}
  * After the tenth examination: {6, 2, 3}

```python
from sys import stdin, stdout

n, k = map(int, stdin.readline().split())
values = list(map(int, stdin.readline().split()))

if sum(values) < k:
    stdout.write('-1')
elif sum(values) > k:

    l = 0
    r = k + 1

    while (r - l > 1):
        m = (r + l) // 2
        cnt = 0

        for i in range(n):
            cnt += min(values[i], m)

        if cnt > k:
            r = m
        else:
            l = m

    for i in range(n):
        k -= min(values[i], l)
        values[i] -= min(values[i], l)

    i = 0
    while k:
        if values[i]:
            values[i] -= 1
            k -= 1

        i = (i + 1) % n

    for j in range(i, i + n):
        if values[j % n]:
            stdout.write(str(j % n + 1) + ' ')
```


886_C. Petya and Catacombs

A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.

Catacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number ti:

  * If Petya has visited this room before, he writes down the minute he was in this room last time;
  * Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i.

Initially, Petya was in one of the rooms at minute 0, he didn't write down number t0.

At some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?

Input

The first line contains a single integer n (1 ≤ n ≤ 2·105) — then number of notes in Petya's logbook.

The second line contains n non-negative integers t1, t2, ..., tn (0 ≤ ti < i) — notes in the logbook.

Output

In the only line print a single integer — the minimum possible number of rooms in Paris catacombs.

Examples

Input

2
0 0

Output

2

Input

5
0 1 0 1 3

Output

3

Note

In the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.

In the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1.

```python
c = int(input())
a = list(map(int, input().split()))
res = 0
b = []
for i in range(len(a)):
    b.append(False)
for i in range(len(a)):
    k = len(a) - i - 1
    m = 0
    while b[k] == False:
        b[k] = True
        k = a[k] - 1
        m = 1
        if (k == -1):
            break
    if m == 1:
        res = res + 1
print(res)
```


909_C. Python Indentation

In Python, code blocks don't have explicit begin/end or curly braces to mark beginning and end of the block. Instead, code blocks are defined by indentation.

We will consider an extremely simplified subset of Python with only two types of statements.

Simple statements are written in a single line, one per line. An example of a simple statement is assignment.

For statements are compound statements: they contain one or several other statements. For statement consists of a header written in a separate line which starts with "for" prefix, and loop body. Loop body is a block of statements indented one level further than the header of the loop. Loop body can contain both types of statements. Loop body can't be empty.

You are given a sequence of statements without indentation. Find the number of ways in which the statements can be indented to form a valid Python program.

Input

The first line contains a single integer N (1 ≤ N ≤ 5000) — the number of commands in the program. N lines of the program follow, each line describing a single command. Each command is either "f" (denoting "for statement") or "s" ("simple statement"). It is guaranteed that the last line is a simple statement.

Output

Output one line containing an integer - the number of ways the given sequence of statements can be indented modulo 109 + 7.

Examples

Input

4
s
f
f
s

Output

1

Input

4
f
s
f
s

Output

2

Note

In the first test case, there is only one way to indent the program: the second for statement must be part of the body of the first one.

    simple statement
    for statement
        for statement
            simple statement

In the second test case, there are two ways to indent the program: the second for statement can either be part of the first one's body or a separate statement following the first one.

    for statement
        simple statement
        for statement
            simple statement

or

    for statement
        simple statement
    for statement
        simple statement

```python
M=10**9+7
n=int(input())
a=[]
for i in range(n):
    a.append(input())
dp=[[0]*(n+5) for i in range(n+2)]
dp[0][0]=1
for i in range(1,n):
    count=0
    if a[i-1]=='f':
        for j in range(n-2,-1,-1):
            if dp[i-1][j]>0:
                dp[i][j+1]=(dp[i][j+1]+dp[i-1][j])%M
    else:
        for j in range(n-2,-1,-1):
            if dp[i-1][j]>0:
                count=(count+dp[i-1][j])%M
            dp[i][j]=(dp[i][j]+count)%M
print(sum(dp[n-1])%M)
```


958_E1. Guard Duty (easy)

The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly one assigned base (in other words, the assignment is a perfect matching). Since she knows how reckless her pilots are, she wants to be sure that any two (straight) paths – from a base to its assigned spaceship – do not intersect in the galaxy plane (that is, in 2D), and so there is no risk of collision.

Input

The first line contains two space-separated integers R, B(1 ≤ R, B ≤ 10). For 1 ≤ i ≤ R, the i + 1-th line contains two space-separated integers xi and yi (|xi|, |yi| ≤ 10000) denoting the coordinates of the i-th Rebel spaceship. The following B lines have the same format, denoting the position of bases. It is guaranteed that no two points coincide and that no three points are on the same line.

Output

If it is possible to connect Rebel spaceships and bases so as satisfy the constraint, output Yes, otherwise output No (without quote).

Examples

Input

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

Output

Yes

Input

2 1
1 0
2 2
3 1

Output

No

Note

For the first example, one possible way is to connect the Rebels and bases in order.

For the second example, there is no perfect matching between Rebels and bases.

```python
(R,B)=map(int,input().split())
for i in range(R+B):
    x=input()
if R==B:
    print('Yes')
else:
    print('No')
```


p02573 AtCoder Beginner Contest 177 - Friends

There are N persons called Person 1 through Person N.

You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times.

If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts.

Takahashi the evil wants to divide the N persons into some number of groups so that every person has no friend in his/her group.

At least how many groups does he need to make?

Constraints

* 2 \leq N \leq 2\times 10^5
* 0 \leq M \leq 2\times 10^5
* 1\leq A_i,B_i\leq N
* A_i \neq B_i

Input

Input is given from Standard Input in the following format:

N M
A_1 B_1
\vdots
A_M B_M

Output

Print the answer.

Examples

Input

5 3
1 2
3 4
5 1

Output

3

Input

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

Output

4

Input

10 4
3 1
4 1
5 9
2 6

Output

3

```python
from collections import deque

n,m=map(int,input().split())
f=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    f[a].append(b)
    f[b].append(a)
g=[0]*(n+1)
p=[0]*(n+1)
for i in range(1,n+1):
    if p[i]==0:
        p[i]=i
        data=[i]
        data=deque(data)
        while len(data)>0:
            pos=data.popleft()
            p[pos]=i
            for j in f[pos]:
                if p[j]==0:
                    data.append(j)
            f[pos]=[]
for i in range(n):
    g[p[i+1]]+=1
print(max(g))

```


p02704 AtCoder Beginner Contest 164 - I hate Matrix Construction

Given are an integer N and arrays S, T, U, and V, each of length N. Construct an N×N matrix a that satisfy the following conditions:

* a_{i,j} is an integer.
* 0 \leq a_{i,j} \lt 2^{64}.
* If S_{i} = 0, the bitwise AND of the elements in the i-th row is U_{i}.
* If S_{i} = 1, the bitwise OR of the elements in the i-th row is U_{i}.
* If T_{i} = 0, the bitwise AND of the elements in the i-th column is V_{i}.
* If T_{i} = 1, the bitwise OR of the elements in the i-th column is V_{i}.

However, there may be cases where no matrix satisfies the conditions.

Constraints

* All values in input are integers.
* 1 \leq N \leq 500
* 0 \leq S_{i} \leq 1
* 0 \leq T_{i} \leq 1
* 0 \leq U_{i} \lt 2^{64}
* 0 \leq V_{i} \lt 2^{64}

Input

Input is given from Standard Input in the following format:

N
S_{1} S_{2} ...  S_{N}
T_{1} T_{2} ...  T_{N}
U_{1} U_{2} ...  U_{N}
V_{1} V_{2} ...  V_{N}

Output

If there exists a matrix that satisfies the conditions, print one such matrix in the following format:

a_{1,1} ...  a_{1,N}
:
a_{N,1} ...  a_{N,N}

Note that any matrix satisfying the conditions is accepted.

If no matrix satisfies the conditions, print -1.

Examples

Input

2
0 1
1 0
1 1
1 0

Output

1 1
1 0

Input

2
1 1
1 0
15 15
15 11

Output

15 11
15 11

```python
from functools import reduce
import operator

N = int(input())
Ss = list(map(int, input().split()))
Ts = list(map(int, input().split()))
Us = list(map(int, input().split()))
Vs = list(map(int, input().split()))
mat = [[0] * N for _ in range(N)]
counts_r = [[0] * 64 for _ in range(N)]
counts_c = [[0] * 64 for _ in range(N)]

class NotOK(Exception):
    pass

try:
    for i in range(N):
        for j in range(N):
            x = 0
            if not Ss[i]:
                x |= Us[i]
            if not Ts[j]:
                x |= Vs[j]
            if Ss[i] and (~Us[i] & x):
                raise NotOK
            if Ts[j] and (~Vs[j] & x):
                raise NotOK
            if Ss[i] and Ts[j]:
                x |= Us[i] & Vs[j]
            mat[i][j] = x
            for k in range(64):
                if (x >> k) & 1:
                    counts_r[i][k] += 1
                    counts_c[j][k] += 1

    def corr(x, vals, ors, counts):
        for k in range(64):
            if (x >> k) & 1 == 0:
                continue
            for j in range(N):
                if ors[j]:
                    continue
                if counts[j][k] >= N - 1:
                    continue
                counts[j][k] += 1
                vals[j] += 1 << k
                x -= 1 << k
                if not x:
                    return x
                break
        return x

    for i in range(N):
        vals = mat[i]
        if Ss[i]:
            x = reduce(operator.or_, vals)
            if corr(Us[i] & ~x, vals, Ts, counts_c):
                raise NotOK
        else:
            x = reduce(operator.and_, vals)
            if x != Us[i]:
                raise NotOK
        vals = []
        for j in range(N):
            vals.append(mat[j][i])
        if Ts[i]:
            x = reduce(operator.or_, vals)
            if corr(Vs[i] & ~x, vals, Ss, counts_r):
                raise NotOK
            for j in range(N):
                mat[j][i] = vals[j]
        else:
            x = reduce(operator.and_, vals)
            if x != Vs[i]:
                raise NotOK
    for i in range(N):
        print(*mat[i])
except NotOK:
    print(-1)

```


p02833 AtCoder Beginner Contest 148 - Double Factorial

For an integer n not less than 0, let us define f(n) as follows:

* f(n) = 1 (if n < 2)
* f(n) = n f(n-2) (if n \geq 2)

Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).

Constraints

* 0 \leq N \leq 10^{18}

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of trailing zeros in the decimal notation of f(N).

Examples

Input

12

Output

1

Input

5

Output

0

Input

1000000000000000000

Output

124999999999999995

```python
n=int(input())
if n%2==1:print(0);exit()
A=0
add=10
while n>=add:
    A +=n//add
    add *=5
print(A)
```


p02970 AtCoder Beginner Contest 134 - Golden Apple

There are N apple trees in a row. People say that one of them will bear golden apples.

We want to deploy some number of inspectors so that each of these trees will be inspected.

Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector deployed under the i-th tree (1 \leq i \leq N) will inspect the trees with numbers between i-D and i+D (inclusive).

Find the minimum number of inspectors that we need to deploy to achieve the objective.

Constraints

* All values in input are integers.
* 1 \leq N \leq 20
* 1 \leq D \leq 20

Input

Input is given from Standard Input in the following format:

N D

Output

Print the minimum number of inspectors that we need to deploy to achieve the objective.

Examples

Input

6 2

Output

2

Input

14 3

Output

2

Input

20 4

Output

3

```python
a,b = map(int, input().split())
t = 2*b + 1
print((a-1)//t+1)
```


p03106 AtCoder Beginner Contest 120 - K-th Common Divisor

You are given positive integers A and B.

Find the K-th largest positive integer that divides both A and B.

The input guarantees that there exists such a number.

Constraints

* All values in input are integers.
* 1 \leq A, B \leq 100
* The K-th largest positive integer that divides both A and B exists.
* K \geq 1

Input

Input is given from Standard Input in the following format:

A B K

Output

Print the K-th largest positive integer that divides both A and B.

Examples

Input

8 12 2

Output

2

Input

100 50 4

Output

5

Input

1 1 1

Output

1

```python
A,B,K = map(int,input().split())
L = []
for i in range(1,101):
  if A%i == 0 and B%i == 0:
    L.append(i)
print(L[len(L)-K])
```


p03253 AtCoder Beginner Contest 110 - Factorization

You are given positive integers N and M.

How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7.

Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''.

Constraints

* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^9

Input

Input is given from Standard Input in the following format:

N M

Output

Print the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.

Examples

Input

2 6

Output

4

Input

3 12

Output

18

Input

100000 1000000000

Output

957870001

```python
n, m = map(int, input().split())

yd = {}
i = 2
while m != 1:
  while m % i == 0:
    if i in yd:
      yd[i] += 1
    else:
      yd[i] = 1
    m //= i
  i += 1

ans = 1
for v in yd.values():
  start = v + n - 1
  c = 1
  for _ in range(v):
    c *= start
    start -= 1
  d = 1
  for _v in range(v):
    d *= (_v + 1)
  ans *= (c // d)
print(ans % 1000000007)

```


p03406 AtCoder Regular Contest 093 - Dark Horse

There are 2^N players, numbered 1, 2, ..., 2^N. They decided to hold a tournament.

The tournament proceeds as follows:

* Choose a permutation of 1, 2, ..., 2^N: p_1, p_2, ..., p_{2^N}.
* The players stand in a row in the order of Player p_1, Player p_2, ..., Player p_{2^N}.
* Repeat the following until there is only one player remaining in the row:
* Play the following matches: the first player in the row versus the second player in the row, the third player versus the fourth player, and so on. The players who lose leave the row. The players who win stand in a row again, preserving the relative order of the players.
* The last player who remains in the row is the champion.

It is known that, the result of the match between two players can be written as follows, using M integers A_1, A_2, ..., A_M given as input:

* When y = A_i for some i, the winner of the match between Player 1 and Player y (2 \leq y \leq 2^N) will be Player y.
* When y \neq A_i for every i, the winner of the match between Player 1 and Player y (2 \leq y \leq 2^N) will be Player 1.
* When 2 \leq x < y \leq 2^N, the winner of the match between Player x and Player y will be Player x.

The champion of this tournament depends only on the permutation p_1, p_2, ..., p_{2^N} chosen at the beginning. Find the number of permutation p_1, p_2, ..., p_{2^N} chosen at the beginning of the tournament that would result in Player 1 becoming the champion, modulo 10^9 + 7.

Constraints

* 1 \leq N \leq 16
* 0 \leq M \leq 16
* 2 \leq A_i \leq 2^N (1 \leq i \leq M)
* A_i < A_{i + 1} (1 \leq i < M)

Input

Input is given from Standard Input in the following format:

N M
A_1 A_2 ... A_M

Output

Print the answer.

Examples

Input

2 1
3

Output

8

Input

4 3
2 4 6

Output

0

Input

3 0

Output

40320

Input

3 3
3 4 7

Output

2688

Input

16 16
5489 5490 5491 5492 5493 5494 5495 5497 18993 18995 18997 18999 19000 19001 19002 19003

Output

816646464

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

def main():
    def com(com_n, com_r):
        return fac[com_n] * inv[com_r] * inv[com_n - com_r] % md

    md = 10 ** 9 + 7
    n, m = map(int, input().split())
    aa = list(map(lambda x: int(x) - 1, input().split()))
    n2 = 2 ** n

    # combinationの準備
    n_max = n2
    fac = [1]
    inv = [1] * (n_max + 1)
    k_fac_inv = 1
    for i in range(1, n_max + 1):
        k_fac_inv = k_fac_inv * i % md
        fac.append(k_fac_inv)
    k_fac_inv = pow(k_fac_inv, md - 2, md)
    for i in range(n_max, 1, -1):
        inv[i] = k_fac_inv
        k_fac_inv = k_fac_inv * i % md

    dp = [[0] * n2 for _ in range(m + 1)]
    dp[0][0] = 1
    for i in range(m):
        a = aa[m - 1 - i]
        for b in range(n2):
            pre = dp[i][b]
            if pre == 0: continue
            dp[i + 1][b] = (dp[i + 1][b] + pre) % md
            k = 1
            for _ in range(n):
                if b & k == 0 and n2 - a - b >= k:
                    nb = b | k
                    dp[i + 1][nb] = (dp[i + 1][nb] + pre * com(n2 - 1 - a - b, k - 1)) % md
                k <<= 1
    for b in range(n2):
        k = 1
        p = n2 - 1 - b
        for _ in range(n):
            if b & k == 0:
                dp[m][b] = dp[m][b] * com(p, k) % md
                p -= k
            k <<= 1
    ans = 0
    for b in range(n2):
        coff = -1 if bin(b).count("1") % 2 else 1
        ans = ans + coff * dp[m][b]
    k = 1
    for _ in range(n - 1):
        k <<= 1
        ans = ans * fac[k] % md
    ans = ans * n2 % md
    print(ans)

main()

```


p03569 CODE FESTIVAL 2017 qual C - Inserting 'x'

We have a string s consisting of lowercase English letters. Snuke can perform the following operation repeatedly:

* Insert a letter `x` to any position in s of his choice, including the beginning and end of s.

Snuke's objective is to turn s into a palindrome. Determine whether the objective is achievable. If it is achievable, find the minimum number of operations required.

Constraints

* 1 \leq |s| \leq 10^5
* s consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

s

Output

If the objective is achievable, print the number of operations required. If it is not, print `-1` instead.

Examples

Input

xabxa

Output

2

Input

ab

Output

-1

Input

a

Output

0

Input

oxxx

Output

3

```python
s = list(input())
l = 0
r = len(s)-1
cnt = 0
while r-l >0:
    if s[r] == s[l]:
        l += 1
        r -= 1
    elif s[r] != s[l] and s[r] == "x":
        r -=1
        cnt += 1
    elif s[r] != s[l] and s[l] == "x":
        l += 1
        cnt += 1
    else:
        print(-1)
        exit()
print(cnt)
```


p03724 AtCoder Grand Contest 014 - Unplanned Queries

Takahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.

First, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.

Then, Aoki gave him M queries. The i-th of them is as follows:

* Increment the number written at each edge along the path connecting vertices a_i and b_i, by one.

After Takahashi executed all of the queries, he told Aoki that, for every edge, the written number became an even number. However, Aoki forgot to confirm that the graph Takahashi created was actually a tree, and it is possible that Takahashi made a mistake in creating a tree or executing queries.

Determine whether there exists a tree that has the property mentioned by Takahashi.

Constraints

* 2 ≤ N ≤ 10^5
* 1 ≤ M ≤ 10^5
* 1 ≤ a_i,b_i ≤ N
* a_i ≠ b_i

Input

Input is given from Standard Input in the following format:

N M
a_1 b_1
:
a_M b_M

Output

Print `YES` if there exists a tree that has the property mentioned by Takahashi; print `NO` otherwise.

Examples

Input

4 4
1 2
2 4
1 3
3 4

Output

YES

Input

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

Output

NO

```python
N,M = map(int,input().split())
cnt = [0]*(N+10)
for i in range(M):
    a,b = map(int,input().split())
    cnt[a]+=1
    cnt[b]+=1

for c in cnt:
    if c%2 == 1:
        print('NO')
        import sys
        sys.exit()
print('YES')

```


p03888 CODE FESTIVAL 2016 Relay (Parallel) - Equivalent Resistance

In an electric circuit, when two resistors R_1 and R_2 are connected in parallel, the equivalent resistance R_3 can be derived from the following formula:

* \frac{1}{R_1} + \frac{1}{R_2} = \frac{1}{R_3}

Given R_1 and R_2, find R_3.

Constraints

* 1 \leq R_1, R_2 \leq 100
* R_1 and R_2 are integers.

Input

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

R_1 R_2

Output

Print the value of R_3.

The output is considered correct if the absolute or relative error is at most 10^{-6}.

Examples

Input

2 3

Output

1.2000000000

Input

100 99

Output

49.7487437186

```python
# -*- coding:utf-8 -*-
r1,r2 = map(int, input().split())
print((r1*r2)/(r1+r2))
```


p04047 AtCoder Grand Contest 001 - BBQ Easy

Snuke is having a barbeque party.

At the party, he will make N servings of Skewer Meal.

<image>

Example of a serving of Skewer Meal

He has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i. Also, he has an infinite supply of ingredients.

To make a serving of Skewer Meal, he picks 2 skewers and threads ingredients onto those skewers. Let the length of the shorter skewer be x, then the serving can hold the maximum of x ingredients.

What is the maximum total number of ingredients that his N servings of Skewer Meal can hold, if he uses the skewers optimally?

Constraints

* 1≦N≦100
* 1≦L_i≦100
* For each i, L_i is an integer.

Input

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

N
L_1 L_2 ... L_{2N}

Output

Print the maximum total number of ingredients that Snuke's N servings of Skewer Meal can hold.

Examples

Input

2
1 3 1 2

Output

3

Input

5
100 1 2 3 14 15 58 58 58 29

Output

135

```python
n=int(input())
l=sorted(list(map(int, input().split())))
ll=l[::2]
print(sum(ll))
```