1261_A. Messy

You are fed up with your messy room, so you decided to clean it up.

Your room is a bracket sequence s=s_{1}s_{2}... s_{n} of length n. Each character of this string is either an opening bracket '(' or a closing bracket ')'.

In one operation you can choose any consecutive substring of s and reverse it. In other words, you can choose any substring s[l ... r]=s_l, s_{l+1}, ..., s_r and change the order of elements in it into s_r, s_{r-1}, ..., s_{l}.

For example, if you will decide to reverse substring s[2 ... 4] of string s="((()))" it will be equal to s="()(())".

A regular (aka balanced) bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1' and '+' between the original characters of the sequence. For example, bracket sequences "()()", "(())" are regular (the resulting expressions are: "(1)+(1)", "((1+1)+1)"), and ")(" and "(" are not.

A prefix of a string s is a substring that starts at position 1. For example, for s="(())()" there are 6 prefixes: "(", "((", "(()", "(())", "(())(" and "(())()".

In your opinion, a neat and clean room s is a bracket sequence that:

  * the whole string s is a regular bracket sequence;
  * and there are exactly k prefixes of this sequence which are regular (including whole s itself).

For example, if k = 2, then "(())()" is a neat and clean room.

You want to use at most n operations to make your room neat and clean. Operations are applied one after another sequentially.

It is guaranteed that the answer exists. Note that you do not need to minimize the number of operations: find any way to achieve the desired configuration in n or less operations.

Input

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

The first line of a test case contains two integers n and k (1 ≤ k ≤ n/2, 2 ≤ n ≤ 2000, n is even) — length of s and required number of regular prefixes.

The second line of a test case contains s of length n — the given bracket sequence. It contains only '(' and ')'.

It is guaranteed that there are exactly n/2 characters '(' and exactly n/2 characters ')' in the given string.

The sum of all values n over all the test cases in the input doesn't exceed 2000.

Output

For each test case print an answer.

In the first line print integer m (0 ≤ m ≤ n) — the number of operations. You do not need to minimize m, any value is suitable.

In the following m lines print description of the operations, each line should contain two integers l,r (1 ≤ l ≤ r ≤ n), representing single reverse operation of s[l ... r]=s_{l}s_{l+1}... s_{r}. Operations are applied one after another sequentially.

The final s after all operations should be a regular, also it should be exactly k prefixes (including s) which are regular.

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

Example

Input

4
8 2
()(())()
10 3
))()()()((
2 1
()
2 1
)(

Output

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

Note

In the first example, the final sequence is "()(()())", where two prefixes are regular, "()" and "()(()())". Note, that all the operations except "5 8" in the example output are useless (they do not change s).

```python
import os, sys, math

def solve(seq, k):
	seq = [ 1 if a == '(' else -1 for a in seq ]
	size = len(seq)
	result = []

	def rotate(fr, to):
		assert fr <= to
		result.append((fr + 1, to + 1))
		while fr < to:
			seq[fr], seq[to] = seq[to], seq[fr]
			fr += 1
			to -= 1
		# print(''.join('(' if q > 0 else ')' for q in seq))
	def split(p1, p2):
		if p1 + 1 == p2:
			return False
		assert seq[p1] > 0 and seq[p2] < 0, (seq, p1, p2)
		i = p1
		while seq[i] > 0:
			i += 1
		rotate(p1 + 1, i)
		return True
	def merge(p):
		assert seq[p] < 0 and seq[p + 1] > 0, (p, seq)
		rotate(p, p + 1)
	d = 0
	x = 0
	while x < size:
		d += seq[x]
		x += 1
		if d < 0:
			start = x - 1
			while d < 0:
				d += seq[x]
				x += 1
			assert d == 0
			rotate(start, x - 1)

	zero_points = [ -1 ]
	d = 0
	for x in range(size):
		d += seq[x]
		if d == 0:
			zero_points.append(x)
	start = len(zero_points) - 1
	if start < k:
		zero_points_index = 0
		while start < k:
			p1 = zero_points[zero_points_index] + 1
			p2 = zero_points[zero_points_index + 1]
			if not split(p1, p2):
				zero_points_index += 1
			else:
				zero_points[zero_points_index] = p1 - 1 + 2
				start += 1
	elif start > k:
		zero_points_index = 1
		while start > k:
			merge(zero_points[zero_points_index])
			start -= 1
			zero_points_index += 1
	return result

#res = solve('(R' + ('(R)R' * 2) + ')')

if os.path.exists('testing'):
	name = os.path.basename(__file__)
	if name.endswith('.py'):
		name = name[:-3]
	src = open(name + '.in.txt', encoding='utf8')
	input = src.readline
num = int(input().strip())
for x in range(num):
	n, k = map(int, input().strip().split())
	n = input().strip()[:n]
	res = solve(n, k)
	print(len(res))
	for q in res:
		print(' '.join(map(str, q)))

```


1283_B. Candies Division

Santa has n candies and he wants to gift them to k kids. He wants to divide as many candies as possible between all k kids. Santa can't divide one candy into parts but he is allowed to not use some candies at all.

Suppose the kid who recieves the minimum number of candies has a candies and the kid who recieves the maximum number of candies has b candies. Then Santa will be satisfied, if the both conditions are met at the same time:

  * b - a ≤ 1 (it means b = a or b = a + 1);
  * the number of kids who has a+1 candies (note that a+1 not necessarily equals b) does not exceed ⌊k/2⌋ (less than or equal to ⌊k/2⌋).

⌊k/2⌋ is k divided by 2 and rounded down to the nearest integer. For example, if k=5 then ⌊k/2⌋=⌊5/2⌋=2.

Your task is to find the maximum number of candies Santa can give to kids so that he will be satisfied.

You have to answer t independent test cases.

Input

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

The next t lines describe test cases. The i-th test case contains two integers n and k (1 ≤ n, k ≤ 10^9) — the number of candies and the number of kids.

Output

For each test case print the answer on it — the maximum number of candies Santa can give to kids so that he will be satisfied.

Example

Input

5
5 2
19 4
12 7
6 2
100000 50010

Output

5
18
10
6
75015

Note

In the first test case, Santa can give 3 and 2 candies to kids. There a=2, b=3,a+1=3.

In the second test case, Santa can give 5, 5, 4 and 4 candies. There a=4,b=5,a+1=5. The answer cannot be greater because then the number of kids with 5 candies will be 3.

In the third test case, Santa can distribute candies in the following way: [1, 2, 2, 1, 1, 2, 1]. There a=1,b=2,a+1=2. He cannot distribute two remaining candies in a way to be satisfied.

In the fourth test case, Santa can distribute candies in the following way: [3, 3]. There a=3, b=3, a+1=4. Santa distributed all 6 candies.


1367_F1. Flying Sort (Easy Version)

This is an easy version of the problem. In this version, all numbers in the given array are distinct and the constraints on n are less than in the hard version of the problem.

You are given an array a of n integers (there are no equals elements in the array). You can perform the following operations on array elements:

  1. choose any index i (1 ≤ i ≤ n) and move the element a[i] to the begin of the array;
  2. choose any index i (1 ≤ i ≤ n) and move the element a[i] to the end of the array.

For example, if n = 5, a = [4, 7, 2, 3, 9], then the following sequence of operations can be performed:

  * after performing the operation of the first type to the second element, the array a will become [7, 4, 2, 3, 9];
  * after performing the operation of the second type to the second element, the array a will become [7, 2, 3, 9, 4].

You can perform operations of any type any number of times in any order.

Find the minimum total number of operations of the first and second type that will make the a array sorted in non-decreasing order. In other words, what is the minimum number of operations that must be performed so the array satisfies the inequalities a[1] ≤ a[2] ≤ … ≤ a[n].

Input

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

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

Then follow n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ 10^9) — an array that needs to be sorted by the given operations. All numbers in the given array are distinct.

The sum of n for all test cases in one test does not exceed 3000.

Output

For each test case output one integer — the minimum total number of operations of the first and second type, which will make the array sorted in non-decreasing order.

Example

Input

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

Output

2
2
0
2

Note

In the first test case, you first need to move 3, and then 2 to the beginning of the array. Therefore, the desired sequence of operations: [4, 7, 2, 3, 9] → [3, 4, 7, 2, 9] → [2, 3, 4, 7, 9].

In the second test case, you need to move the 1 to the beginning of the array, and the 8 — to the end. Therefore, the desired sequence of operations: [3, 5, 8, 1, 7] → [1, 3, 5, 8, 7] → [1, 3, 5, 7, 8].

In the third test case, the array is already sorted.

```python
t=int(input())
for you in range(t):
    n=int(input())
    l=input().split()
    li=[int(i) for i in l]
    z=list(li)
    z.sort()
    hashi=dict()
    for i in range(n):
        hashi[z[i]]=i+1
    for i in range(n):
        li[i]=hashi[li[i]]
    hashi=dict()
    dp=[0 for i in range(n)]
    for i in range(n):
        if(li[i]-1 in hashi):
            dp[i]=hashi[li[i]-1]+1
            hashi[li[i]]=dp[i]
        else:
            dp[i]=1
            hashi[li[i]]=1
    z=max(dp)
    print(n-z)

```


1389_A. LCM Problem

Let LCM(x, y) be the minimum positive integer that is divisible by both x and y. For example, LCM(13, 37) = 481, LCM(9, 6) = 18.

You are given two integers l and r. Find two integers x and y such that l ≤ x < y ≤ r and l ≤ LCM(x, y) ≤ r.

Input

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

Each test case is represented by one line containing two integers l and r (1 ≤ l < r ≤ 10^9).

Output

For each test case, print two integers:

  * if it is impossible to find integers x and y meeting the constraints in the statement, print two integers equal to -1;
  * otherwise, print the values of x and y (if there are multiple valid answers, you may print any of them).

Example

Input

4
1 1337
13 69
2 4
88 89

Output

6 7
14 21
2 4
-1 -1

```python
T=int(input())
for _ in range(T):
    l,r=map(int,input().split())
    if abs(l-r)==1 and l!=1:
        print(-1,-1)
    elif 2*l>r :
        print(-1,-1)
    else:
        print(l,2*l)

```


1409_D. Decrease the Sum of Digits

You are given a positive integer n. In one move, you can increase n by one (i.e. make n := n + 1). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of n be less than or equal to s.

You have to answer t independent test cases.

Input

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

The only line of the test case contains two integers n and s (1 ≤ n ≤ 10^{18}; 1 ≤ s ≤ 162).

Output

For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of n be less than or equal to s.

Example

Input

5
2 1
1 1
500 4
217871987498122 10
100000000000000001 1

Output

8
0
500
2128012501878
899999999999999999

```python
for _ in range(int(input())):
    n,k=[int(x) for x in input().split()]
    if n%k==0:print(0)
    else:print(k-(n%k))
```


1430_B. Barrels

You have n barrels lined up in a row, numbered from left to right from one. Initially, the i-th barrel contains a_i liters of water.

You can pour water from one barrel to another. In one act of pouring, you can choose two different barrels x and y (the x-th barrel shouldn't be empty) and pour any possible amount of water from barrel x to barrel y (possibly, all water). You may assume that barrels have infinite capacity, so you can pour any amount of water in each of them.

Calculate the maximum possible difference between the maximum and the minimum amount of water in the barrels, if you can pour water at most k times.

Some examples:

  * if you have four barrels, each containing 5 liters of water, and k = 1, you may pour 5 liters from the second barrel into the fourth, so the amounts of water in the barrels are [5, 0, 5, 10], and the difference between the maximum and the minimum is 10;
  * if all barrels are empty, you can't make any operation, so the difference between the maximum and the minimum amount is still 0.

Input

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

The first line of each test case contains two integers n and k (1 ≤ k < n ≤ 2 ⋅ 10^5) — the number of barrels and the number of pourings you can make.

The second line contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^{9}), where a_i is the initial amount of water the i-th barrel has.

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

Output

For each test case, print the maximum possible difference between the maximum and the minimum amount of water in the barrels, if you can pour water at most k times.

Example

Input

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

Output

10
0

```python
def solve():
    n,k=map(int,input().split())
    if n==1:
        print(0)
        return
    ls=list(map(int,input().split()))
    ls.sort()
    res=ls.pop()
    for i in range(k):
        if ls:
            res+=ls.pop()
    print(res)
    return

for _ in range(int(input())):
    solve()
```


1453_D. Checkpoints

Gildong is developing a game consisting of n stages numbered from 1 to n. The player starts the game from the 1-st stage and should beat the stages in increasing order of the stage number. The player wins the game after beating the n-th stage.

There is at most one checkpoint on each stage, and there is always a checkpoint on the 1-st stage. At the beginning of the game, only the checkpoint on the 1-st stage is activated, and all other checkpoints are deactivated. When the player gets to the i-th stage that has a checkpoint, that checkpoint is activated.

For each try of a stage, the player can either beat the stage or fail the stage. If they beat the i-th stage, the player is moved to the i+1-st stage. If they fail the i-th stage, the player is moved to the most recent checkpoint they activated, and they have to beat the stages after that checkpoint again.

For example, assume that n = 4 and the checkpoints are on the 1-st and 3-rd stages. The player starts at the 1-st stage. If they fail on the 1-st stage, they need to retry the 1-st stage because the checkpoint on the 1-st stage is the most recent checkpoint they activated. If the player beats the 1-st stage, they're moved to the 2-nd stage. If they fail it, they're sent back to the 1-st stage again. If they beat both the 1-st stage and the 2-nd stage, they get to the 3-rd stage and the checkpoint on the 3-rd stage is activated. Now whenever they fail on the 3-rd stage, or the 4-th stage after beating the 3-rd stage, they're sent back to the 3-rd stage. If they beat both the 3-rd stage and the 4-th stage, they win the game.

Gildong is going to build the stages to have equal difficulty. He wants you to find any series of stages and checkpoints using at most 2000 stages, where the [expected number](https://en.wikipedia.org/wiki/Expected_value) of tries over all stages is exactly k, for a player whose probability of beating each stage is exactly \cfrac{1}{2}.

Input

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

Each test case contains exactly one line. The line consists of a single integer k (1 ≤ k ≤ 10^{18}) — the expected number of tries over all stages Gildong wants to set for a player whose probability of beating each stage is exactly \cfrac{1}{2}.

Output

For each test case, print -1 if it's impossible to construct such a series of stages and checkpoints using at most 2000 stages.

Otherwise, print two lines. The first line should contain a single integer n (1 ≤ n ≤ 2000) – the number of stages. The second line should contain n integers, where the i-th integer represents whether the i-th stage has a checkpoint. The i-th integer should be 0 if the i-th stage doesn't have a checkpoint, and 1 if it has a checkpoint. Note that the first integer must be 1 according to the description.

Example

Input

4
1
2
8
12

Output

-1
1
1
4
1 1 1 1
5
1 1 0 1 1

Note

In the first and the second case, we can see that the 'easiest' series of stages is to have 1 stage with a checkpoint. This already requires 2 tries in expectation, so it is impossible to make it to require only 1 try.

In the third case, it takes 2 tries in expectation to beat each stage, and the player can always retry that stage without falling back to one of the previous stages if they fail it. Therefore the total expected number of tries is 8. Note that there exists an answer with fewer stages, but you are not required to minimize the number of stages used.

```python
t=int(input())
for _ in range(t):
  n=int(input())
  if n%2==1:
    print(-1)
    continue
  ans=[]
  tmp=0
  for i in range(2,62):
    if 1<<i&n:
      ans.append('1')
      for j in range(i-2):
        ans.append('0')
      tmp+=1
  for i in range(tmp):
    ans.append('1')
  if 2&n:
    ans.append('1')
  print(len(ans))
  print(' '.join(ans))

```


1477_B. Nezzar and Binary String

Nezzar has a binary string s of length n that he wants to share with his best friend, Nanako. Nanako will spend q days inspecting the binary string. At the same time, Nezzar wants to change the string s into string f during these q days, because it looks better.

It is known that Nanako loves consistency so much. On the i-th day, Nanako will inspect a segment of string s from position l_i to position r_i inclusive. If the segment contains both characters '0' and '1', Nanako becomes unhappy and throws away the string.

After this inspection, at the i-th night, Nezzar can secretly change strictly less than half of the characters in the segment from l_i to r_i inclusive, otherwise the change will be too obvious.

Now Nezzar wonders, if it is possible to avoid Nanako being unhappy and at the same time have the string become equal to the string f at the end of these q days and nights.

Input

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

The first line of each test case contains two integers n,q (1 ≤ n ≤ 2 ⋅ 10^5, 0 ≤ q ≤ 2 ⋅ 10^5).

The second line of each test case contains a binary string s of length n.

The third line of each test case contains a binary string f of length n.

Then q lines follow, i-th of them contains two integers l_i,r_i (1 ≤ l_i ≤ r_i ≤ n) — bounds of the segment, that Nanako will inspect on the i-th day.

It is guaranteed that the sum of n for all test cases doesn't exceed 2 ⋅ 10^5, and the sum of q for all test cases doesn't exceed 2 ⋅ 10^5.

Output

For each test case, print "YES" on the single line if it is possible to avoid Nanako being unhappy and have the string f at the end of q days and nights. Otherwise, print "NO".

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

Example

Input

4
5 2
00000
00111
1 5
1 3
2 1
00
01
1 2
10 6
1111111111
0110001110
1 10
5 9
7 10
1 7
3 5
6 10
5 2
10000
11000
2 5
1 3

Output

YES
NO
YES
NO

Note

In the first test case, \underline{00000} → \underline{000}11 → 00111 is one of the possible sequences of string changes.

In the second test case, it can be shown that it is impossible to have the string f at the end.

```python
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
    def __init__(self, file):
        self.newlines = 0
        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()

# --------------------------------------------------------------------

def RL(): return map(int, sys.stdin.readline().split())
def RLL(): return list(map(int, sys.stdin.readline().split()))
def N(): return int(input())
def S(): return input().strip()
def print_list(l): print(' '.join(map(str, l)))

# sys.setrecursionlimit(200000)
# import random
# from functools import reduce
# from functools import lru_cache
# from heapq import *
# from collections import deque as dq
# import math
# import bisect as bs
# from collections import Counter
# from collections import defaultdict as dc

def set_range(lx, rx, v, now):
    if l <= lx and r >= rx:
        label[now] = v
        node[now] = rx - lx if v else 0
        return
    mx = (lx + rx) >> 1
    nl = now << 1
    nr = nl + 1
    if label[now] != -1:     # 非对称操作启用该环节
        node[nl] = node[nr] = node[now] >> 1
        label[nl] = label[nr] = label[now]
        label[now] = -1
    if l < mx: set_range(lx, mx, v, nl)
    if r > mx: set_range(mx, rx, v, nr)
    node[now] = node[nl] +  node[nr]

def get_range(lx, rx, now):
    if l <= lx and r >= rx: return node[now]
    mx = (lx + rx) >> 1
    nl = now << 1
    nr = nl + 1
    if label[now] != -1: return min(rx, r) - max(lx, l) if label[now] else 0
    m1 = get_range(lx, mx, nl) if l < mx else 0
    m2 = get_range(mx, rx, nr) if r > mx else 0
    return m1 + m2

def match(lx, rx, now):
    if lx >= n: return False
    if now >= sn: return node[now] != s[lx]
    if label[now] != -1: return any(v != label[now] for v in s[lx:rx])
    mx = (rx + lx) >> 1
    return match(lx, mx, now << 1) or match(mx, rx, now << 1 | 1)

for _ in range(N()):
    n, q = RL()
    s, t = [int(c) for c in S()], [int(c) for c in S()]
    p = [tuple(RL()) for _ in range(q)]
    sn = 1 << n.bit_length()
    node = [0] * sn + t + [0] * (sn - n)
    label = [-1] * (2 * sn)
    for i in range(sn - 1, 0, -1): node[i] = node[i << 1] + node[i << 1 | 1]
    f = True
    for l, r in p[::-1]:
        l -= 1
        count = get_range(0, sn, 1) * 2
        if count == r - l:
            f = False
            break
        set_range(0, sn, 1 if count > r - l else 0, 1)
    print('YES' if f and not match(0, sn, 1) else 'NO')

```


1527_D. MEX Tree

You are given a tree with n nodes, numerated from 0 to n-1. For each k between 0 and n, inclusive, you have to count the number of unordered pairs (u,v), u ≠ v, such that the MEX of all the node labels in the shortest path from u to v (including end points) is k.

The MEX of a sequence of integers is the smallest non-negative integer that does not belong to the sequence.

Input

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

The first line of each test case contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^{5}).

The next n-1 lines of each test case describe the tree that has to be constructed. These lines contain two integers u and v (0 ≤ u,v ≤ n-1) denoting an edge between u and v (u ≠ v).

It is guaranteed that the given edges form a tree.

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

Output

For each test case, print n+1 integers: the number of paths in the tree, such that the MEX of all the node labels in that path is k for each k from 0 to n.

Example

Input

2
4
0 1
0 2
2 3
2
1 0

Output

1 2 1 1 1
0 0 1

Note

  1. In example case 1, <image>
    * For k = 0, there is 1 path that is from 2 to 3 as MEX([2, 3]) = 0.
    * For k = 1, there are 2 paths that is from 0 to 2 as MEX([0, 2]) = 1 and 0 to 3 as MEX([0, 2, 3]) = 1.
    * For k = 2, there is 1 path that is from 0 to 1 as MEX([0, 1]) = 2.
    * For k = 3, there is 1 path that is from 1 to 2 as MEX([1, 0, 2]) = 3
    * For k = 4, there is 1 path that is from 1 to 3 as MEX([1, 0, 2, 3]) = 4.
  2. In example case 2, <image>
    * For k = 0, there are no such paths.
    * For k = 1, there are no such paths.
    * For k = 2, there is 1 path that is from 0 to 1 as MEX([0, 1]) = 2.

```python
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
#from decimal import Decimal
#from fractions import Fraction
#sys.setrecursionlimit(100000)
#INF = float('inf')
mod = 998244353

def dfs(graph, start=0):
    n = len(graph)

    dp = [0] * n
    visited, finished, par = [False] * n, [False] * n, [0] * n

    stack = [start]
    while stack:
        start = stack[-1]

        # push unvisited children into stack
        if not visited[start]:
            visited[start] = True
            for child in graph[start]:
                if not visited[child]:
                    par[child] = start
                    stack.append(child)

        else:
            stack.pop()

            # base case
            dp[start] += 1

            # update with finished children
            for child in graph[start]:
                if finished[child]:
                    dp[start] += dp[child]

            finished[start] = True

    return dp, par

for t in range(int(data())):
    n=int(data())
    tree = [[] for i in range(n)]
    for i in range(n-1):
        u,v = mdata()
        tree[u].append(v)
        tree[v].append(u)
    dp, par = dfs(tree)
    ans = [0]*(n+1)
    for u in tree[0]:
        ans[0] += (dp[u]*(dp[u]-1))//2
    s = set()
    s.add(0)
    p = 1
    while p!=0:
        s.add(p)
        p = par[p]
    for u in tree[0]:
        if u in s:
            k=u
            break
    n1, n2 = 0, 1
    ans[1] = (n*(n-1))//2 - ans[0] - dp[1]*(n-dp[k])
    flag = True
    for i in range(2,n):
        p = i
        while p not in s:
            s.add(p)
            p = par[p]
        if p==i:
            continue
        if p==n1:
            if n1!=0:
                ans[i] = dp[n2]*(dp[n1]-dp[i])
            else:
                ans[i] = dp[n2]*(dp[n1] - dp[k] - dp[i])
            n1 = i
        elif p==n2:
            if n1!=0:
                ans[i] = dp[n1] * (dp[n2] - dp[i])
            else:
                ans[i] = (dp[n1] - dp[k]) * (dp[n2] - dp[i])
            n2 = i
        else:
            if n1!=0:
                ans[i] = dp[n1]*dp[n2]
            else:
                ans[i] = (dp[n1] - dp[k])*dp[n2]
            flag = False
            break
    if len(s) == n and flag:
        ans[-1] = 1
    outl(ans)

```


159_C. String Manipulation 1.0

One popular website developed an unusual username editing procedure. One can change the username only by deleting some characters from it: to change the current name s, a user can pick number p and character c and delete the p-th occurrence of character c from the name. After the user changed his name, he can't undo the change.

For example, one can change name "arca" by removing the second occurrence of character "a" to get "arc".

Polycarpus learned that some user initially registered under nickname t, where t is a concatenation of k copies of string s. Also, Polycarpus knows the sequence of this user's name changes. Help Polycarpus figure out the user's final name.

Input

The first line contains an integer k (1 ≤ k ≤ 2000). The second line contains a non-empty string s, consisting of lowercase Latin letters, at most 100 characters long. The third line contains an integer n (0 ≤ n ≤ 20000) — the number of username changes. Each of the next n lines contains the actual changes, one per line. The changes are written as "pi ci" (without the quotes), where pi (1 ≤ pi ≤ 200000) is the number of occurrences of letter ci, ci is a lowercase Latin letter. It is guaranteed that the operations are correct, that is, the letter to be deleted always exists, and after all operations not all letters are deleted from the name. The letters' occurrences are numbered starting from 1.

Output

Print a single string — the user's final name after all changes are applied to it.

Examples

Input

2
bac
3
2 a
1 b
2 c

Output

acb

Input

1
abacaba
4
1 a
1 a
1 c
2 b

Output

baa

Note

Let's consider the first sample. Initially we have name "bacbac"; the first operation transforms it into "bacbc", the second one — to "acbc", and finally, the third one transforms it into "acb".

```python
# cook your dish here
n=int(input())
s=list(input())*n
d={}
for i in range(len(s)):
    if s[i] not in d:
        d[s[i]]=[i]
    else:
        d[s[i]].append(i)
m=int(input())
for i in range(m):
    o,c=input().split()
    s[d[c].pop(int(o)-1)]=''
print(''.join(s))
```


201_A. Clear Symmetry

Consider some square matrix A with side n consisting of zeros and ones. There are n rows numbered from 1 to n from top to bottom and n columns numbered from 1 to n from left to right in this matrix. We'll denote the element of the matrix which is located at the intersection of the i-row and the j-th column as Ai, j.

Let's call matrix A clear if no two cells containing ones have a common side.

Let's call matrix A symmetrical if it matches the matrices formed from it by a horizontal and/or a vertical reflection. Formally, for each pair (i, j) (1 ≤ i, j ≤ n) both of the following conditions must be met: Ai, j = An - i + 1, j and Ai, j = Ai, n - j + 1.

Let's define the sharpness of matrix A as the number of ones in it.

Given integer x, your task is to find the smallest positive integer n such that there exists a clear symmetrical matrix A with side n and sharpness x.

Input

The only line contains a single integer x (1 ≤ x ≤ 100) — the required sharpness of the matrix.

Output

Print a single number — the sought value of n.

Examples

Input

4

Output

3

Input

9

Output

5

Note

The figure below shows the matrices that correspond to the samples:

<image>

```python
x=int(input())
n=1
while n*n+1<2*x:
    n+=2
if x==3:
    n=5
print(n)
```


225_E. Unsolvable

Consider the following equation:

<image> where sign [a] represents the integer part of number a.

Let's find all integer z (z > 0), for which this equation is unsolvable in positive integers. The phrase "unsolvable in positive integers" means that there are no such positive integers x and y (x, y > 0), for which the given above equation holds.

Let's write out all such z in the increasing order: z1, z2, z3, and so on (zi < zi + 1). Your task is: given the number n, find the number zn.

Input

The first line contains a single integer n (1 ≤ n ≤ 40).

Output

Print a single integer — the number zn modulo 1000000007 (109 + 7). It is guaranteed that the answer exists.

Examples

Input

1

Output

1

Input

2

Output

3

Input

3

Output

15


24_C. Sequence of points

You are given the following points with integer coordinates on the plane: M0, A0, A1, ..., An - 1, where n is odd number. Now we define the following infinite sequence of points Mi: Mi is symmetric to Mi - 1 according <image> (for every natural number i). Here point B is symmetric to A according M, if M is the center of the line segment AB. Given index j find the point Mj.

Input

On the first line you will be given an integer n (1 ≤ n ≤ 105), which will be odd, and j (1 ≤ j ≤ 1018), where j is the index of the desired point. The next line contains two space separated integers, the coordinates of M0. After that n lines follow, where the i-th line contain the space separated integer coordinates of the point Ai - 1. The absolute values of all input coordinates will not be greater then 1000.

Output

On a single line output the coordinates of Mj, space separated.

Examples

Input

3 4
0 0
1 1
2 3
-5 3

Output

14 0

Input

3 1
5 5
1000 1000
-1000 1000
3 100

Output

1995 1995

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

ax = []
ay = []

mx, my = map(int, input().split())

for i in range(n):
    x, y = map(int, input().split())
    ax.append(x)
    ay.append(y)

k %= 2*n

for i in range(k):
    mx = 2*ax[i % n] - mx
    my = 2*ay[i % n] - my

print(mx, " ", my)
```


298_A. Snow Footprints

There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint on the i-th block. If there already is a footprint on the i-th block, the new footprint will cover the old one.

<image>

At the beginning, there were no footprints. Then polar bear Alice starts from the s-th block, makes a sequence of moves and ends in the t-th block. It is known that Alice never moves outside of the road.

You are given the description of Alice's footprints. Your task is to find a pair of possible values of s, t by looking at the footprints.

Input

The first line of the input contains integer n (3 ≤ n ≤ 1000).

The second line contains the description of the road — the string that consists of n characters. Each character will be either "." (a block without footprint), or "L" (a block with a left footprint), "R" (a block with a right footprint).

It's guaranteed that the given string contains at least one character not equal to ".". Also, the first and the last character will always be ".". It's guaranteed that a solution exists.

Output

Print two space-separated integers — the values of s and t. If there are several possible solutions you can print any of them.

Examples

Input

9
..RRLL...

Output

3 4

Input

11
.RRRLLLLL..

Output

7 5

Note

The first test sample is the one in the picture.

```python
arg = int(input())
s2=input()

start = -1
ending = -1

flag9 = 0

if "R" in s2:
	for n in range(0, arg):
		if s2[n]=="R" and flag9 == 0:
			start = n + 1
			flag9 = 1
		if s2[n]== "R" and s2[n+1] == "L":
			ending = n + 1
		elif s2[n] == "R":
			ending = n + 2
else:
	for n in range(0, arg):
		if s2[n]=="L" and flag9 == 0:
			ending = n
			flag9 = 1
		if s2[n]== "L" and s2[n+1]==".":
			start = n + 1

print(start, ending)
```


320_D. Psychos in a Line

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

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

Input

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

Output

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

Examples

Input

10
10 9 7 8 6 5 3 4 2 1

Output

2

Input

6
1 2 3 4 5 6

Output

0

Note

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

```python
n = int(input())
aa = list(map(int,input().split()))
live = []
ans=0
for i in range(n-1,-1,-1):
    c = 0
    while len(live)!=0 and live[-1][0]<aa[i]:
        c = max(c+1,live[-1][1])
        live.pop()
    if c>ans: ans =c
    live.append((aa[i],c))
print(ans)
```


369_A. Valera and Plates

Valera is a lazy student. He has m clean bowls and k clean plates.

Valera has made an eating plan for the next n days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, he needs exactly one clean plate or bowl. We know that Valera can cook only two types of dishes. He can eat dishes of the first type from bowls and dishes of the second type from either bowls or plates.

When Valera finishes eating, he leaves a dirty plate/bowl behind. His life philosophy doesn't let him eat from dirty kitchenware. So sometimes he needs to wash his plate/bowl before eating. Find the minimum number of times Valera will need to wash a plate/bowl, if he acts optimally.

Input

The first line of the input contains three integers n, m, k (1 ≤ n, m, k ≤ 1000) — the number of the planned days, the number of clean bowls and the number of clean plates.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 2). If ai equals one, then on day i Valera will eat a first type dish. If ai equals two, then on day i Valera will eat a second type dish.

Output

Print a single integer — the minimum number of times Valera will need to wash a plate/bowl.

Examples

Input

3 1 1
1 2 1

Output

1

Input

4 3 1
1 1 1 1

Output

1

Input

3 1 2
2 2 2

Output

0

Input

8 2 2
1 2 1 2 1 2 1 2

Output

4

Note

In the first sample Valera will wash a bowl only on the third day, so the answer is one.

In the second sample, Valera will have the first type of the dish during all four days, and since there are only three bowls, he will wash a bowl exactly once.

In the third sample, Valera will have the second type of dish for all three days, and as they can be eaten from either a plate or a bowl, he will never need to wash a plate/bowl.

```python
class CodeforcesTask369ASolution:
    def __init__(self):
        self.result = ''
        self.n_m_k = []
        self.plan = []

    def read_input(self):
        self.n_m_k = [int(x) for x in input().split(" ")]
        self.plan = [int(x) for x in input().split(" ")]

    def process_task(self):
        cleans = 0
        bowls, plates = self.n_m_k[1], self.n_m_k[2]
        for day in self.plan:
            if day == 1:
                if bowls:
                    bowls -= 1
                else:
                    cleans += 1
            else:
                if plates:
                    plates -= 1
                elif bowls:
                    bowls -= 1
                else:
                    cleans += 1
        self.result = str(cleans)

    def get_result(self):
        return self.result

if __name__ == "__main__":
    Solution = CodeforcesTask369ASolution()
    Solution.read_input()
    Solution.process_task()
    print(Solution.get_result())

```


391_B. Word Folding

You will receive 5 points for solving this problem.

Manao has invented a new operation on strings that is called folding. Each fold happens between a pair of consecutive letters and places the second part of the string above first part, running in the opposite direction and aligned to the position of the fold. Using this operation, Manao converts the string into a structure that has one more level than there were fold operations performed. See the following examples for clarity.

We will denote the positions of folds with '|' characters. For example, the word "ABRACADABRA" written as "AB|RACA|DAB|RA" indicates that it has been folded three times: first, between the leftmost pair of 'B' and 'R' letters; second, between 'A' and 'D'; and third, between the rightmost pair of 'B' and 'R' letters. Here are several examples of folded strings:

    "ABCDEF|GHIJK" |  "A|BCDEFGHIJK" |  "AB|RACA|DAB|RA" |  "X|XXXXX|X|X|XXXXXX"
                   |                 |                   |       XXXXXX
        KJIHG      |   KJIHGFEDCB    |      AR           |       X
       ABCDEF      |            A    |     DAB           |       X
                   |                 |     ACAR          |       XXXXX
                   |                 |       AB          |           X

One last example for "ABCD|EFGH|IJ|K":

     K
    IJ
    HGFE
    ABCD

Manao noticed that each folded string can be viewed as several piles of letters. For instance, in the previous example, there are four piles, which can be read as "AHI", "BGJK", "CF", and "DE" from bottom to top. Manao wonders what is the highest pile of identical letters he can build using fold operations on a given word. Note that the pile should not contain gaps and should start at the bottom level. For example, in the rightmost of the four examples above, none of the piles would be considered valid since each of them has gaps, starts above the bottom level, or both.

Input

The input will consist of one line containing a single string of n characters with 1 ≤ n ≤ 1000 and no spaces. All characters of the string will be uppercase letters.

This problem doesn't have subproblems. You will get 5 points for the correct submission.

Output

Print a single integer — the size of the largest pile composed of identical characters that can be seen in a valid result of folding operations on the given string.

Examples

Input

ABRACADABRA

Output

3

Input

ABBBCBDB

Output

3

Input

AB

Output

1

Note

Consider the first example. Manao can create a pile of three 'A's using the folding "AB|RACAD|ABRA", which results in the following structure:

    ABRA
    DACAR
       AB

In the second example, Manao can create a pile of three 'B's using the following folding: "AB|BB|CBDB".

    CBDB
    BB
    AB

Another way for Manao to create a pile of three 'B's with "ABBBCBDB" is the following folding: "AB|B|BCBDB".

     BCBDB
     B
    AB

In the third example, there are no folds performed and the string is just written in one line.

```python
t = {}
for i, c in enumerate(input()):
    if c not in t: t[c] = (i, 1)
    elif (t[c][0] - i) & 1: t[c] = (i, t[c][1] + 1)
print(max(b for a, b in t.values()))
```


413_A. Data Recovery

Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.

The testing goes in n steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer in R2 is keeping a report record on the work of the processor: he writes down the minimum and the maximum measured temperature in his notebook. His assistant had to write down all temperatures into his notebook, but (for unknown reasons) he recorded only m.

The next day, the engineer's assistant filed in a report with all the m temperatures. However, the chief engineer doubts that the assistant wrote down everything correctly (naturally, the chief engineer doesn't doubt his notes). So he asked you to help him. Given numbers n, m, min, max and the list of m temperatures determine whether you can upgrade the set of m temperatures to the set of n temperatures (that is add n - m temperatures), so that the minimum temperature was min and the maximum one was max.

Input

The first line contains four integers n, m, min, max (1 ≤ m < n ≤ 100; 1 ≤ min < max ≤ 100). The second line contains m space-separated integers ti (1 ≤ ti ≤ 100) — the temperatures reported by the assistant.

Note, that the reported temperatures, and the temperatures you want to add can contain equal temperatures.

Output

If the data is consistent, print 'Correct' (without the quotes). Otherwise, print 'Incorrect' (without the quotes).

Examples

Input

2 1 1 2
1

Output

Correct

Input

3 1 1 3
2

Output

Correct

Input

2 1 1 3
2

Output

Incorrect

Note

In the first test sample one of the possible initial configurations of temperatures is [1, 2].

In the second test sample one of the possible initial configurations of temperatures is [2, 1, 3].

In the third test sample it is impossible to add one temperature to obtain the minimum equal to 1 and the maximum equal to 3.

```python
n, m, mmin, mmax = map(int, input().split())
s = list(map(int, input().split()))
s = sorted(s)
if s[0] < mmin or s[m - 1] > mmax:
    print("Incorrect")
elif s[0] == mmin and s[m - 1] == mmax:
    print("Correct")
elif s[0] != mmin and s[m - 1] != mmax:
    if n - m < 2:
        print("Incorrect")
    else:
        print("Correct")
elif s[0] != mmin or s[m - 1] != mmax:
    if n - m < 1:
        print("Incorrect")
    else:
        print("Correct")
```


43_C. Lucky Tickets

Vasya thinks that lucky tickets are the tickets whose numbers are divisible by 3. He gathered quite a large collection of such tickets but one day his younger brother Leonid was having a sulk and decided to destroy the collection. First he tore every ticket exactly in two, but he didn’t think it was enough and Leonid also threw part of the pieces away. Having seen this, Vasya got terrified but still tried to restore the collection. He chose several piece pairs and glued each pair together so that each pair formed a lucky ticket. The rest of the pieces Vasya threw away reluctantly. Thus, after the gluing of the 2t pieces he ended up with t tickets, each of which was lucky.

When Leonid tore the tickets in two pieces, one piece contained the first several letters of his number and the second piece contained the rest.

Vasya can glue every pair of pieces in any way he likes, but it is important that he gets a lucky ticket in the end. For example, pieces 123 and 99 can be glued in two ways: 12399 and 99123.

What maximum number of tickets could Vasya get after that?

Input

The first line contains integer n (1 ≤ n ≤ 104) — the number of pieces. The second line contains n space-separated numbers ai (1 ≤ ai ≤ 108) — the numbers on the pieces. Vasya can only glue the pieces in pairs. Even if the number of a piece is already lucky, Vasya should glue the piece with some other one for it to count as lucky. Vasya does not have to use all the pieces. The numbers on the pieces an on the resulting tickets may coincide.

Output

Print the single number — the maximum number of lucky tickets that will be able to be restored. Don't forget that every lucky ticket is made of exactly two pieces glued together.

Examples

Input

3
123 123 99

Output

1

Input

6
1 1 1 23 10 3

Output

1

```python
n=int(input())
inp = list(map(int,input().split()))
l=[0,0,0]
for item in inp:
    l[item%3]+=1
a=l[0]
b=l[1]
c=l[2]
print (min(b,c)+a//2)
```


509_D. Restoring Numbers

Vasya had two arrays consisting of non-negative integers: a of size n and b of size m. Vasya chose a positive integer k and created an n × m matrix v using the following formula:

<image>

Vasya wrote down matrix v on a piece of paper and put it in the table.

A year later Vasya was cleaning his table when he found a piece of paper containing an n × m matrix w. He remembered making a matrix one day by the rules given above but he was not sure if he had found the paper with the matrix v from those days. Your task is to find out if the matrix w that you've found could have been obtained by following these rules and if it could, then for what numbers k, a1, a2, ..., an, b1, b2, ..., bm it is possible.

Input

The first line contains integers n and m (1 ≤ n, m ≤ 100), separated by a space — the number of rows and columns in the found matrix, respectively.

The i-th of the following lines contains numbers wi, 1, wi, 2, ..., wi, m (0 ≤ wi, j ≤ 109), separated by spaces — the elements of the i-th row of matrix w.

Output

If the matrix w could not have been obtained in the manner described above, print "NO" (without quotes) in the single line of output.

Otherwise, print four lines.

In the first line print "YES" (without quotes).

In the second line print an integer k (1 ≤ k ≤ 1018). Note that each element of table w should be in range between 0 and k - 1 inclusively.

In the third line print n integers a1, a2, ..., an (0 ≤ ai ≤ 1018), separated by spaces.

In the fourth line print m integers b1, b2, ..., bm (0 ≤ bi ≤ 1018), separated by spaces.

Examples

Input

2 3
1 2 3
2 3 4

Output

YES
1000000007
0 1
1 2 3

Input

2 2
1 2
2 0

Output

YES
3
0 1
1 2

Input

2 2
1 2
2 1

Output

NO

Note

By <image> we denote the remainder of integer division of b by c.

It is guaranteed that if there exists some set of numbers k, a1, ..., an, b1, ..., bm, that you could use to make matrix w, then there also exists a set of numbers that meets the limits 1 ≤ k ≤ 1018, 1 ≤ ai ≤ 1018, 1 ≤ bi ≤ 1018 in the output format. In other words, these upper bounds are introduced only for checking convenience purposes.

```python
"""
Codeforces Contest 289 Div 2 Problem D

Author  : chaotic_iak
Language: Python 3.4.2
"""

################################################### SOLUTION

def main():
    n,m = read()
    matrix = [read() for _ in range(n)]
    mod = 10**11
    for i in range(n-1):
        poss = set()
        for j in range(m):
            poss.add(matrix[i+1][j] - matrix[i][j])
        if len(poss) > 2: return "NO"
        if len(poss) == 2 and mod != 10**11 and mod != max(poss) - min(poss): return "NO"
        if len(poss) == 2: mod = max(poss) - min(poss)
    if mod <= max(max(matrix[i]) for i in range(n)): return "NO"
    print("YES")
    print(mod)
    write([(matrix[i][0] - matrix[0][0]) % mod for i in range(n)])
    print()
    write(matrix[0])

#################################################### HELPERS

def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    inputs = input().strip()
    if mode == 0: return inputs
    if mode == 1: return inputs.split()
    if mode == 2: return list(map(int, inputs.split()))

def write(s="\n"):
    if s is None: s = ""
    if isinstance(s, list): s = " ".join(map(str, s))
    s = str(s)
    print(s, end="")

write(main())
```


584_C. Marina and Vasya

Marina loves strings of the same length and Vasya loves when there is a third string, different from them in exactly t characters. Help Vasya find at least one such string.

More formally, you are given two strings s1, s2 of length n and number t. Let's denote as f(a, b) the number of characters in which strings a and b are different. Then your task will be to find any string s3 of length n, such that f(s1, s3) = f(s2, s3) = t. If there is no such string, print  - 1.

Input

The first line contains two integers n and t (1 ≤ n ≤ 105, 0 ≤ t ≤ n).

The second line contains string s1 of length n, consisting of lowercase English letters.

The third line contain string s2 of length n, consisting of lowercase English letters.

Output

Print a string of length n, differing from string s1 and from s2 in exactly t characters. Your string should consist only from lowercase English letters. If such string doesn't exist, print -1.

Examples

Input

3 2
abc
xyc

Output

ayd

Input

1 0
c
b

Output

-1

```python
fs = frozenset(list("abc"))

def calc(s1, s2):
    return len(list(filter(lambda x: x[0] == x[1], zip(s1, s2))))

if __name__ == '__main__':
    n, t = map(int, input().split())
    s1 = input()
    s2 = input()

    q = n - t
    c = calc(s1, s2)
    need = q - c
    w = 0

    ss = ['x'] * len(s1)

    if n - c >= 2 * need:
        for i in range(len(s1)):
            ss[i] = list(fs - frozenset(s1[i]) - frozenset(s2[i]))[0]
            if s1[i] == s2[i]:
                ss[i] = s1[i]

            if s1[i] == s2[i] and need < 0 and w > need:
                w -= 1
                ss[i] = list(fs - frozenset(s1[i]) - frozenset(s2[i]))[0]

            if s1[i] != s2[i] and need > 0 and w < 2 * need:
                if w >= need:
                    ss[i] = s2[i]
                else:
                    ss[i] = s1[i]

                w += 1

        print(''.join(ss))
    else:
        print('-1')
```


606_C. Sorting Railway Cars

An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it either to the beginning of the train, or to the end of the train, at his desire. What is the minimum number of actions David Blaine needs to perform in order to sort the train?

Input

The first line of the input contains integer n (1 ≤ n ≤ 100 000) — the number of cars in the train.

The second line contains n integers pi (1 ≤ pi ≤ n, pi ≠ pj if i ≠ j) — the sequence of the numbers of the cars in the train.

Output

Print a single integer — the minimum number of actions needed to sort the railway cars.

Examples

Input

5
4 1 2 5 3

Output

2

Input

4
4 1 3 2

Output

2

Note

In the first sample you need first to teleport the 4-th car, and then the 5-th car to the end of the train.

```python
def LIS(s):
    n = len(s)
    L = [0]*n
    appear = [False]*n
    L[0] = 1
    find = [-1]*n
    appear[s[0]] = True
    find[s[0]] = 0
    for i in range(1,len(s)):
        if s[i]>0 and appear[s[i]-1]:
            L[i] = L[find[s[i]-1]] + 1
        else:
            L[i] = 1
        appear[s[i]] = True
        find[s[i]] = i
    return max(L)
def BIS(s):
    n = len(s)
    L = [0]*n
    appear = [False]*n
    L[n-1] = 1
    find = [-1]*n
    appear[s[n-1]] = True
    find[s[n-1]] = n-1
    for i in range(n-2,-1,-1):
        if s[i]+1 < n and appear[s[i]+1]:
            L[i] = L[find[s[i]-1]] + 1
        else:
            L[i] = 1
        appear[s[i]] = True
        find[s[i]] = i
    return max(L)
n = int(input())
L = list(map(int,input().split()))
L = [x-1 for x in L]
print(n-max(LIS(L),BIS(L)))

```


628_C. Bear and String Distance

Limak is a little polar bear. He likes nice strings — strings of length n, consisting of lowercase English letters only.

The distance between two letters is defined as the difference between their positions in the alphabet. For example, <image>, and <image>.

Also, the distance between two nice strings is defined as the sum of distances of corresponding letters. For example, <image>, and <image>.

Limak gives you a nice string s and an integer k. He challenges you to find any nice string s' that <image>. Find any s' satisfying the given conditions, or print "-1" if it's impossible to do so.

As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.

Input

The first line contains two integers n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 106).

The second line contains a string s of length n, consisting of lowercase English letters.

Output

If there is no string satisfying the given conditions then print "-1" (without the quotes).

Otherwise, print any nice string s' that <image>.

Examples

Input

4 26
bear

Output

roar

Input

2 7
af

Output

db

Input

3 1000
hey

Output

-1

```python
#import sys
#sys.stdin = open('in', 'r')
#n = int(input())
#a = [int(x) for x in input().split()]
alph = 'abcdefghijklmnopqrstuvwxyz'
n,k = map(int, input().split())
s = input()
res = ''
for c in s:
    if k > 0:
        r = ord('z') - ord(c)
        l = ord(c) - ord('a')
        if r >= l:
            if k >= r:
                res += 'z'
                k -= r
            else:
                res += chr(ord(c) + k)
                k = 0
        else:
            if k >= l:
                res += 'a'
                k -= l
            else:
                res += chr(ord(c) - k)
                k = 0
    else:
        res += c
print(res if k == 0 else -1)

```


652_D. Nested Segments

You are given n segments on a line. There are no ends of some segments that coincide. For each segment find the number of segments it contains.

Input

The first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of segments on a line.

Each of the next n lines contains two integers li and ri ( - 109 ≤ li < ri ≤ 109) — the coordinates of the left and the right ends of the i-th segment. It is guaranteed that there are no ends of some segments that coincide.

Output

Print n lines. The j-th of them should contain the only integer aj — the number of segments contained in the j-th segment.

Examples

Input

4
1 8
2 3
4 7
5 6

Output

3
0
1
0

Input

3
3 4
1 5
2 6

Output

0
1
1

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

from __future__ import division, print_function

import collections

def least_significant_bit(i):
    return ((i) & -(i))

class FenwickTree():
    def __init__(self, n):
        # 1-indexed
        self.n = n + 1
        self.data = [0,] * self.n

    def add(self, index, value):
        # 1-indexed
        i = index + 1
        while i < self.n:
            self.data[i] += value
            i += least_significant_bit(i)

    def prefix_sum(self, index):
        # 1-indexed
        i = index + 1
        result = 0
        while i > 0:
            result += self.data[i]
            i -= least_significant_bit(i)
        return result

    def range_sum(self, start, end):
        return self.prefix_sum(end) - self.prefix_sum(start-1)

def main():
    import sys
    data = collections.deque(map(int, sys.stdin.buffer.read().decode('ascii').split()))
    n = data.popleft()
    left = [0,] * n
    right = [0,] * n
    for i in range(n):
        a, b = data.popleft(), data.popleft()
        left[i] = a
        right[i] = b
    order = list(range(n))
    order.sort(key=lambda x: left[x])
    for i, k in enumerate(order):
        left[k] = i
    order = list(range(n))
    order.sort(key=lambda x:right[x])
    res = [0, ] * n
    ft = FenwickTree(n)
    for i, k in enumerate(order):
        a = left[k]
        res[k] = i - ft.prefix_sum(a-1)
        ft.add(a, 1)
    sys.stdout.buffer.write('\n'.join(str(x) for x in res).encode('ascii'))
    return 0

if __name__ == '__main__':
    main()

```


678_B. The Same Calendar

The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.

The calendar is so beautiful that she wants to know what is the next year after y when the calendar will be exactly the same. Help Taylor to find that year.

Note that leap years has 366 days. The year is leap if it is divisible by 400 or it is divisible by 4, but not by 100 (<https://en.wikipedia.org/wiki/Leap_year>).

Input

The only line contains integer y (1000 ≤ y < 100'000) — the year of the calendar.

Output

Print the only integer y' — the next year after y when the calendar will be the same. Note that you should find the first year after y with the same calendar.

Examples

Input

2016

Output

2044

Input

2000

Output

2028

Input

50501

Output

50507

Note

Today is Monday, the 13th of June, 2016.

```python
y = int(input())

r = 0

def getDays(year):
    if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
        return 366
    else:
        return 365

days = getDays(y)

while r == 0 or not (r % 7 == 0 and getDays(y) == days):
    r += getDays(y)
    y += 1

print(y)
```


700_B. Connecting Universities

Treeland is a country in which there are n towns connected by n - 1 two-way road such that it's possible to get from any town to any other town.

In Treeland there are 2k universities which are located in different towns.

Recently, the president signed the decree to connect universities by high-speed network.The Ministry of Education understood the decree in its own way and decided that it was enough to connect each university with another one by using a cable. Formally, the decree will be done!

To have the maximum sum in the budget, the Ministry decided to divide universities into pairs so that the total length of the required cable will be maximum. In other words, the total distance between universities in k pairs should be as large as possible.

Help the Ministry to find the maximum total distance. Of course, each university should be present in only one pair. Consider that all roads have the same length which is equal to 1.

Input

The first line of the input contains two integers n and k (2 ≤ n ≤ 200 000, 1 ≤ k ≤ n / 2) — the number of towns in Treeland and the number of university pairs. Consider that towns are numbered from 1 to n.

The second line contains 2k distinct integers u1, u2, ..., u2k (1 ≤ ui ≤ n) — indices of towns in which universities are located.

The next n - 1 line contains the description of roads. Each line contains the pair of integers xj and yj (1 ≤ xj, yj ≤ n), which means that the j-th road connects towns xj and yj. All of them are two-way roads. You can move from any town to any other using only these roads.

Output

Print the maximum possible sum of distances in the division of universities into k pairs.

Examples

Input

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

Output

6

Input

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

Output

9

Note

The figure below shows one of possible division into pairs in the first test. If you connect universities number 1 and 6 (marked in red) and universities number 2 and 5 (marked in blue) by using the cable, the total distance will equal 6 which will be the maximum sum in this example.

<image>

```python
def bfs(source):

    q = [0] * (n + 1);

    fa = [-1] * n

    l, r = [1] * 2

    fa[source] = source

    q[1] = source

    while l <= r:

        x = q[l]

        l += 1

        for y in e[x]:

            if  fa[y] == -1:

                fa[y] = x

                r += 1

                q[r] = y

    i = r;

    while i >= 1:

        x = q[i]

        for y in e[x]:

            if fa[y] == x:

                sum[x] += sum[y]

                dp[x] += dp[y] + min(sum[y], m - sum[y])

        i -= 1

n, m =[int(x) for x in input().split()]

m <<= 1

t = [int(x) for x in input().split()]

e = [list() for i in range(n)]

sum = [0] * n

dp = [0] * n

#print(len(e), e)

for i in range(n - 1):

    x, y = [int(a) for a in input().split()]

    e[x - 1].append(y - 1)

    e[y - 1].append(x - 1)

for x in t:

    sum[x - 1] = 1

bfs(0)

print(dp[0])

# Made By Mostafa_Khaled
```


722_D. Generating Sets

You are given a set Y of n distinct positive integers y1, y2, ..., yn.

Set X of n distinct positive integers x1, x2, ..., xn is said to generate set Y if one can transform X to Y by applying some number of the following two operation to integers in X:

  1. Take any integer xi and multiply it by two, i.e. replace xi with 2·xi.
  2. Take any integer xi, multiply it by two and add one, i.e. replace xi with 2·xi + 1.

Note that integers in X are not required to be distinct after each operation.

Two sets of distinct integers X and Y are equal if they are equal as sets. In other words, if we write elements of the sets in the array in the increasing order, these arrays would be equal.

Note, that any set of integers (or its permutation) generates itself.

You are given a set Y and have to find a set X that generates Y and the maximum element of X is mininum possible.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 50 000) — the number of elements in Y.

The second line contains n integers y1, ..., yn (1 ≤ yi ≤ 109), that are guaranteed to be distinct.

Output

Print n integers — set of distinct integers that generate Y and the maximum element of which is minimum possible. If there are several such sets, print any of them.

Examples

Input

5
1 2 3 4 5

Output

4 5 2 3 1

Input

6
15 14 3 13 1 12

Output

12 13 14 7 3 1

Input

6
9 7 13 17 5 11

Output

4 5 2 6 3 1

```python
from collections import defaultdict
import heapq

pow=[1]
for i in range(30):
    pow.append(pow[-1]*2)

n=int(input())
b=list(map(int,input().split()))
d=defaultdict(lambda:0)
for j in b:
    d[j]=1
for j in range(n):
    b[j]=-b[j]
heapq.heapify(b)
ans=[]
f=1
while(f):
    j= -heapq.heappop(b)
    can=0
    for i in range(31):
        curr=(j-(j%pow[i]))//pow[i]
        if curr<1:
            break
        if d[curr]==0:
            heapq.heappush(b,-curr)
            d[curr]=1
            can=1
            break
    if not can:
        heapq.heappush(b,-j)
        break

for j in range(n):
    b[j]=-b[j]

print(*b)

```


744_B. Hongcow's Game

This is an interactive problem. In the interaction section below you will see the information about flushing the output.

In this problem, you will be playing a game with Hongcow. How lucky of you!

Hongcow has a hidden n by n matrix M. Let Mi, j denote the entry i-th row and j-th column of the matrix. The rows and columns are labeled from 1 to n.

The matrix entries are between 0 and 109. In addition, Mi, i = 0 for all valid i. Your task is to find the minimum value along each row, excluding diagonal elements. Formally, for each i, you must find <image>.

To do this, you can ask Hongcow some questions.

A question consists of giving Hongcow a subset of distinct indices {w1, w2, ..., wk}, with 1 ≤ k ≤ n. Hongcow will respond with n integers. The i-th integer will contain the minimum value of min1 ≤ j ≤ kMi, wj.

You may only ask Hongcow at most 20 questions — he thinks you only need that many questions answered.

When you are ready to answer, print out a single integer  - 1 on its own line, then n integers on the next line. The i-th integer should be the minimum value in the i-th row of the matrix, excluding the i-th element. Do not forget to flush the final answer as well. Printing the answer does not count as asking a question.

You will get Wrong Answer verdict if

  * Your question or answers are not in the format described in this statement.
  * You ask strictly more than 20 questions.
  * Your question contains duplicate indices.
  * The value of k in your question does not lie in the range from 1 to n, inclusive.
  * Your final answer is not correct.

You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below).

Input

The first line of input will contain a single integer n (2 ≤ n ≤ 1, 000).

Output

To print the final answer, print out the string -1 on its own line. Then, the next line should contain n integers. The i-th integer should be the minimum value of the i-th row of the matrix, excluding elements on the diagonal. Do not forget to flush your answer!

Interaction

To ask a question, print out a single integer k on its own line, denoting the size of your subset. Then, the next line should contain k integers w1, w2, ... wk. Note, you must flush your output to get a response.

Hongcow will respond by printing out a line with n integers. The i-th integer in this line represents the minimum value of Mi, wj where j is between 1 and k.

You may only ask a question at most 20 times, otherwise, you will get Wrong Answer.

To flush you can use (just after printing an integer and end-of-line):

  * fflush(stdout) in C++;
  * System.out.flush() in Java;
  * stdout.flush() in Python;
  * flush(output) in Pascal;
  * See the documentation for other languages.

Hacking To hack someone, use the following format

    n
    M_{1,1} M_{1,2} ... M_{1,n}
    M_{2,1} M_{2,2} ... M_{2,n}
    ...
    M_{n,1} M_{n,2} ... M_{n,n}

Of course, contestant programs will not be able to see this input.

Examples

Input

3
0 0 0
2 7 0
0 0 4
3 0 8
0 5 4

Output

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

Input

2
0 0
0 0

Output

1
2
1
1
-1
0 0

Note

In the first sample, Hongcow has the hidden matrix

    [
     [0, 3, 2],
     [5, 0, 7],
     [4, 8 ,0],
    ]

Here is a more readable version demonstrating the interaction. The column on the left represents Hongcow, while the column on the right represents the contestant.

    3
                  3
                  1 2 3
    0 0 0
                  1
                  3
    2 7 0
                  2
                  1 2
    0 0 4
                  1
                  2
    3 0 8
                  1
                  1
    0 5 4
                  -1
                  2 5 4

For the second sample, it is possible for off-diagonal elements of the matrix to be zero.

```python
from sys import stdout

def g(k, p):
    print(str(k) + '\n' + ' '.join(map(str, p)))
    stdout.flush()

n = int(input())
s = [9e9] * n

def f(q):
    global s
    p = [k + 1 for k, v in enumerate(q) if v]
    g(len(p), p)
    s = [i if j else min(i, int(k)) for i, j, k in zip(s, q, input().split())]
    return [not v for v in q]

k = 1
while k < n:
    f(f([not (i & k) for i in range(n)]))
    k *= 2
g(-1, s)
```


791_C. Bear and Different Names

In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if there are two Bobs?).

A group of soldiers is effective if and only if their names are different. For example, a group (John, Bob, Limak) would be effective, while groups (Gary, Bob, Gary) and (Alice, Alice) wouldn't.

You are a spy in the enemy's camp. You noticed n soldiers standing in a row, numbered 1 through n. The general wants to choose a group of k consecutive soldiers. For every k consecutive soldiers, the general wrote down whether they would be an effective group or not.

You managed to steal the general's notes, with n - k + 1 strings s1, s2, ..., sn - k + 1, each either "YES" or "NO".

  * The string s1 describes a group of soldiers 1 through k ("YES" if the group is effective, and "NO" otherwise).
  * The string s2 describes a group of soldiers 2 through k + 1.
  * And so on, till the string sn - k + 1 that describes a group of soldiers n - k + 1 through n.

Your task is to find possible names of n soldiers. Names should match the stolen notes. Each name should be a string that consists of between 1 and 10 English letters, inclusive. The first letter should be uppercase, and all other letters should be lowercase. Names don't have to be existing names — it's allowed to print "Xyzzzdj" or "T" for example.

Find and print any solution. It can be proved that there always exists at least one solution.

Input

The first line of the input contains two integers n and k (2 ≤ k ≤ n ≤ 50) — the number of soldiers and the size of a group respectively.

The second line contains n - k + 1 strings s1, s2, ..., sn - k + 1. The string si is "YES" if the group of soldiers i through i + k - 1 is effective, and "NO" otherwise.

Output

Find any solution satisfying all given conditions. In one line print n space-separated strings, denoting possible names of soldiers in the order. The first letter of each name should be uppercase, while the other letters should be lowercase. Each name should contain English letters only and has length from 1 to 10.

If there are multiple valid solutions, print any of them.

Examples

Input

8 3
NO NO YES YES YES NO

Output

Adam Bob Bob Cpqepqwer Limak Adam Bob Adam

Input

9 8
YES NO

Output

R Q Ccccccccc Ccocc Ccc So Strong Samples Ccc

Input

3 2
NO NO

Output

Na Na Na

Note

In the first sample, there are 8 soldiers. For every 3 consecutive ones we know whether they would be an effective group. Let's analyze the provided sample output:

  * First three soldiers (i.e. Adam, Bob, Bob) wouldn't be an effective group because there are two Bobs. Indeed, the string s1 is "NO".
  * Soldiers 2 through 4 (Bob, Bob, Cpqepqwer) wouldn't be effective either, and the string s2 is "NO".
  * Soldiers 3 through 5 (Bob, Cpqepqwer, Limak) would be effective, and the string s3 is "YES".
  * ...,
  * Soldiers 6 through 8 (Adam, Bob, Adam) wouldn't be effective, and the string s6 is "NO".

```python
import sys
import math
from math import *
import builtins
import collections
import bisect
import os
from io import BytesIO, IOBase

def print(x, end='\n'):
    sys.stdout.write(str(x) + end)

# IO helpers
def get_int():
    return int(input())

def get_list_ints():
    return list(map(int, input().split()))

def get_char_list():
    s = input()
    return list(s[:len(s) - 1])

def get_tuple_ints():
    return tuple(map(int, input().split()))

def print_iterable(p):
    print(" ".join(map(str, p)))

def CountFrequency(arr):
    return collections.Counter(arr)

def reverse(s):
    l=len(s)
    for i in range(l//2):
        s[i],s[l-i-1]=s[l-i-1],s[i]
    return s

def binary_search(arr, x):
    low = 0
    high = len(arr) - 1
    mid = 0
    while low <= high:
        mid = (high + low) // 2
        if arr[mid] < x:
            low = mid + 1
        elif arr[mid] > x:
            high = mid - 1
        else:
            return mid
    return high

#STD lower bound equivalent in python
def lower_bound(arr,x):
    return bisect.bisect_left(arr, x, lo=0, hi=len(arr))

 #STD upper bound equivalent in python
def upper_bound(arr,x):
    return bisect.bisect_right(arr, x, lo=0, hi=len(arr))

def pow(a,n):
    if n==0:
        return 1
    elif n%2==0:
        return ((pow(a,n//2)%const)*(pow(a,n//2)%const))%const
    else:
        return ((pow(a,n//2)%const)*(pow(a,n//2)%const)*(a%const))%const

def main():
    [n,k]=get_list_ints()
    list=["Aa","Ab","Ac","Ad","Ae","Af","Ag","Ah","Ai","Aj","Ak","Al","Am","An","Ao","Ap","Aq","Ar","As","At","Au","Av","Aw","Ax","Ay","Az","Ba","Bb","Bc","Bd","Be","Bf","Bg","Bh","Bi","Bj","Bk","Bl","Bm","Bn","Bo","Bp","Bq","Br","Bs","Bt","Bu","Bv","Bw","Bx","By","Bz"]
    listi=[i for i in input().split()]
    lista=list[:k-1]
    for j in range(n-k+1):
        if listi[j]=="NO":
            lista.append(lista[1-k])
        else:
            lista.append(list[j+k-1])
    print_iterable(lista)
    pass

##Fast Input Output

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()
```


858_C. Did you mean...

Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.

Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are three or more consonants in a row in the word. The only exception is that if the block of consonants has all letters the same, then this block (even if its length is greater than three) is not considered a typo. Formally, a word is typed with a typo if there is a block of not less that three consonants in a row, and there are at least two different letters in this block.

For example:

  * the following words have typos: "hellno", "hackcerrs" and "backtothefutttture";
  * the following words don't have typos: "helllllooooo", "tobeornottobe" and "oooooo".

When Beroffice editor finds a word with a typo, it inserts as little as possible number of spaces in this word (dividing it into several words) in such a way that each of the resulting words is typed without any typos.

Implement this feature of Beroffice editor. Consider the following letters as the only vowels: 'a', 'e', 'i', 'o' and 'u'. All the other letters are consonants in this problem.

Input

The only line contains a non-empty word consisting of small English letters. The length of the word is between 1 and 3000 letters.

Output

Print the given word without any changes if there are no typos.

If there is at least one typo in the word, insert the minimum number of spaces into the word so that each of the resulting words doesn't have any typos. If there are multiple solutions, print any of them.

Examples

Input

hellno

Output

hell no

Input

abacaba

Output

abacaba

Input

asdfasdf

Output

asd fasd f

```python
s = input()
res = []
l = 0
for r in range(2, len(s)):
    if r - l >= 2 and not any(c in 'aeiou' for c in s[r - 2:r + 1]) and s[r - 2:r + 1].count(s[r]) < 3:
        res.append(s[l:r])
        l = r
res.append(s[l:])
print(' '.join(res))
```


883_I. Photo Processing

Evlampiy has found one more cool application to process photos. However the application has certain limitations.

Each photo i has a contrast vi. In order for the processing to be truly of high quality, the application must receive at least k photos with contrasts which differ as little as possible.

Evlampiy already knows the contrast vi for each of his n photos. Now he wants to split the photos into groups, so that each group contains at least k photos. As a result, each photo must belong to exactly one group.

He considers a processing time of the j-th group to be the difference between the maximum and minimum values of vi in the group. Because of multithreading the processing time of a division into groups is the maximum processing time among all groups.

Split n photos into groups in a such way that the processing time of the division is the minimum possible, i.e. that the the maximum processing time over all groups as least as possible.

Input

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 3·105) — number of photos and minimum size of a group.

The second line contains n integers v1, v2, ..., vn (1 ≤ vi ≤ 109), where vi is the contrast of the i-th photo.

Output

Print the minimal processing time of the division into groups.

Examples

Input

5 2
50 110 130 40 120

Output

20

Input

4 1
2 3 4 1

Output

0

Note

In the first example the photos should be split into 2 groups: [40, 50] and [110, 120, 130]. The processing time of the first group is 10, and the processing time of the second group is 20. Maximum among 10 and 20 is 20. It is impossible to split the photos into groups in a such way that the processing time of division is less than 20.

In the second example the photos should be split into four groups, each containing one photo. So the minimal possible processing time of a division is 0.

```python
from bisect import bisect_left, bisect_right

class Result:
    def __init__(self, index, value):
        self.index = index
        self.value = value

class BinarySearch:
    def __init__(self):
        pass

    @staticmethod
    def greater_than(num: int, func, size: int = 1):
        """Searches for smallest element greater than num!"""
        if isinstance(func, list):
            index = bisect_right(func, num)
            if index == len(func):
                return Result(None, None)
            else:
                return Result(index, func[index])
        else:
            alpha, omega = 0, size - 1
            if func(omega) <= num:
                return Result(None, None)
            while alpha < omega:
                if func(alpha) > num:
                    return Result(alpha, func(alpha))
                if omega == alpha + 1:
                    return Result(omega, func(omega))
                mid = (alpha + omega) // 2
                if func(mid) > num:
                    omega = mid
                else:
                    alpha = mid

    @staticmethod
    def less_than(num: int, func, size: int = 1):
        """Searches for largest element less than num!"""
        if isinstance(func, list):
            index = bisect_left(func, num) - 1
            if index == -1:
                return Result(None, None)
            else:
                return Result(index, func[index])
        else:
            alpha, omega = 0, size - 1
            if func(alpha) >= num:
                return Result(None, None)
            while alpha < omega:
                if func(omega) < num:
                    return Result(omega, func(omega))
                if omega == alpha + 1:
                    return Result(alpha, func(alpha))
                mid = (alpha + omega) // 2
                if func(mid) < num:
                    alpha = mid
                else:
                    omega = mid

# ------------------- fast io --------------------
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")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi

def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)

def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y

for _ in range(int(input()) if not True else 1):
    # l, r, m = map(int, input().split())
    n, k = map(int, input().split())
    # c, d = map(int, input().split())
    a = sorted(list(map(int, input().split())))
    if k == 1:
        print(0)
        continue
    # b = list(map(int, input().split()))
    bs = BinarySearch()
    a=[0] + a
    d = [False]*(n+1)
    def check(x):
        dp = list(d)
        dp[0] = True
        if a[k] - a[1] <= x:
            dp[k] = True
        else:return 0
        cur = 1
        for i in range(k+1, n+1):
            while cur <= n and a[i]-a[cur] > x:
                cur += 1
            while cur <= n and not dp[cur-1]:
                cur += 1
            if cur <= i-k+1:
                dp[i] = True
        return dp[-1]

    alpha, omega = 0, 10 ** 9
    ans = omega
    while alpha < omega:
        mid = (alpha + omega) // 2
        x = mid
        if check(x):
            omega = mid
            ans = omega
        else:
            alpha = mid + 1
    print(ans)
```


907_D. Seating of Students

Students went into a class to write a test and sat in some way. The teacher thought: "Probably they sat in this order to copy works of each other. I need to rearrange them in such a way that students that were neighbors are not neighbors in a new seating."

The class can be represented as a matrix with n rows and m columns with a student in each cell. Two students are neighbors if cells in which they sit have a common side.

Let's enumerate students from 1 to n·m in order of rows. So a student who initially sits in the cell in row i and column j has a number (i - 1)·m + j. You have to find a matrix with n rows and m columns in which all numbers from 1 to n·m appear exactly once and adjacent numbers in the original matrix are not adjacent in it, or determine that there is no such matrix.

Input

The only line contains two integers n and m (1 ≤ n, m ≤ 105; n·m ≤ 105) — the number of rows and the number of columns in the required matrix.

Output

If there is no such matrix, output "NO" (without quotes).

Otherwise in the first line output "YES" (without quotes), and in the next n lines output m integers which form the required matrix.

Examples

Input

2 4

Output

YES
5 4 7 2
3 6 1 8

Input

2 1

Output

NO

Note

In the first test case the matrix initially looks like this:

    1 2 3 4
    5 6 7 8

It's easy to see that there are no two students that are adjacent in both matrices.

In the second test case there are only two possible seatings and in both of them students with numbers 1 and 2 are neighbors.

```python
import bisect

def list_output(s):
    print(' '.join(map(str, s)))

def list_input(s='int'):
    if s == 'int':
        return list(map(int, input().split()))
    elif s == 'float':
        return list(map(float, input().split()))
    return list(map(str, input().split()))

n, m = map(int, input().split())
swapped = False
if n > m:
    n, m = m, n
    swapped = True

def check(M):
    for i in range(n):
        for j in range(m):
            if i-1 >= 0 and M[i-1][j] + m == M[i][j]:
                return False
            if i+1 < n and M[i+1][j] == M[i][j] + m:
                return False
            if j-1 >= 0 and M[i][j-1] + 1 == M[i][j]:
                return False
            if j+1 < m and M[i][j+1] == M[i][j] + 1:
                return False
    return True

def transpose(M):
    n = len(M)
    m = len(M[0])
    R = [[0 for i in range(n)] for j in range(m)]
    for i in range(n):
        for j in range(m):
            R[j][i] = M[i][j]
    return R

if n == 1 and m == 1:
    print('YES')
    print('1')
    exit(0)

if n <= 2 and m <= 3:
    print('NO')
    exit(0)

R = list()
if n == 3 and m == 3:
    R.append([4, 3, 8])
    R.append([9, 1, 6])
    R.append([5, 7, 2])
elif m == 4:
    if n == 1:
        R.append([3, 1, 4, 2])
    elif n == 2:
        R.append([5, 4, 7, 2])
        R.append([3, 6, 1, 8])
    elif n == 3:
        R.append([5, 4, 7, 2])
        R.append([3, 6, 1, 8])
        R.append([11, 9, 12, 10])
    elif n == 4:
        R.append([5, 4, 7, 2])
        R.append([3, 6, 1, 8])
        R.append([11, 9, 12, 10])
        R.append([14, 16, 15, 13])
else:
    M = [[(i-1) * m + j for j in range(1, m+1)] for i in range(1, n+1)]
    for i in range(n):
        row = list()
        if i%2 == 0:
            for j in range(0, m, 2):
                row.append(M[i][j])
            for j in range(1, m, 2):
                row.append(M[i][j])
        else:
            for j in range(1, m, 2):
                row.append(M[i][j])
            for j in range(0, m, 2):
                row.append(M[i][j])
        R.append(row)

if swapped:
    M = [[(i-1) * n + j for j in range(1, n+1)] for i in range(1, m+1)]
    M = transpose(M)
    S = [[0 for j in range(m)] for i in range(n)]
    for i in range(n):
        for j in range(m):
            r = (R[i][j]-1) // m
            c = (R[i][j]-1) % m
            S[i][j] = M[r][c]
    R = transpose(S)
    n, m = m, n
#print(check(R))
print('YES')
for i in range(n):
    print(' '.join(map(str, R[i])))

```


928_A. Login Verification

When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.

Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds and user-inattention related issues, it is prohibited to register a login if it is similar with an already existing login. More precisely, two logins s and t are considered similar if we can transform s to t via a sequence of operations of the following types:

  * transform lowercase letters to uppercase and vice versa;
  * change letter «O» (uppercase latin letter) to digit «0» and vice versa;
  * change digit «1» (one) to any letter among «l» (lowercase latin «L»), «I» (uppercase latin «i») and vice versa, or change one of these letters to other.

For example, logins «Codeforces» and «codef0rces» as well as «OO0OOO00O0OOO0O00OOO0OO_lol» and «OO0OOO0O00OOO0O00OO0OOO_1oI» are considered similar whereas «Codeforces» and «Code_forces» are not.

You're given a list of existing logins with no two similar amonst and a newly created user login. Check whether this new login is similar with any of the existing ones.

Input

The first line contains a non-empty string s consisting of lower and uppercase latin letters, digits and underline symbols («_») with length not exceeding 50 — the login itself.

The second line contains a single integer n (1 ≤ n ≤ 1 000) — the number of existing logins.

The next n lines describe the existing logins, following the same constraints as the user login (refer to the first line of the input). It's guaranteed that no two existing logins are similar.

Output

Print «Yes» (without quotes), if user can register via this login, i.e. none of the existing logins is similar with it.

Otherwise print «No» (without quotes).

Examples

Input

1_wat
2
2_wat
wat_1

Output

Yes

Input

000
3
00
ooA
oOo

Output

No

Input

_i_
3
__i_
_1_
I

Output

No

Input

La0
3
2a0
La1
1a0

Output

No

Input

abc
1
aBc

Output

No

Input

0Lil
2
LIL0
0Ril

Output

Yes

Note

In the second sample case the user wants to create a login consisting of three zeros. It's impossible due to collision with the third among the existing.

In the third sample case the new login is similar with the second one.

```python
def f(s):
    return s.lower().replace('1', 'l').replace('0', 'o').replace('i', 'l')

s = f(input())
n = int(input())

l = {f(input()) for _ in range(n)}

print('No' if s in l else 'Yes')

```


957_C. Three-level Laser

An atom of element X can exist in n distinct states with energies E1 < E2 < ... < En. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme.

Three distinct states i, j and k are selected, where i < j < k. After that the following process happens:

  1. initially the atom is in the state i,
  2. we spend Ek - Ei energy to put the atom in the state k,
  3. the atom emits a photon with useful energy Ek - Ej and changes its state to the state j,
  4. the atom spontaneously changes its state to the state i, losing energy Ej - Ei,
  5. the process repeats from step 1.

Let's define the energy conversion efficiency as <image>, i. e. the ration between the useful energy of the photon and spent energy.

Due to some limitations, Arkady can only choose such three states that Ek - Ei ≤ U.

Help Arkady to find such the maximum possible energy conversion efficiency within the above constraints.

Input

The first line contains two integers n and U (3 ≤ n ≤ 105, 1 ≤ U ≤ 109) — the number of states and the maximum possible difference between Ek and Ei.

The second line contains a sequence of integers E1, E2, ..., En (1 ≤ E1 < E2... < En ≤ 109). It is guaranteed that all Ei are given in increasing order.

Output

If it is not possible to choose three states that satisfy all constraints, print -1.

Otherwise, print one real number η — the maximum possible energy conversion efficiency. Your answer is considered correct its absolute or relative error does not exceed 10 - 9.

Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if <image>.

Examples

Input

4 4
1 3 5 7

Output

0.5

Input

10 8
10 13 15 16 17 19 20 22 24 25

Output

0.875

Input

3 1
2 5 10

Output

-1

Note

In the first example choose states 1, 2 and 3, so that the energy conversion efficiency becomes equal to <image>.

In the second example choose states 4, 5 and 9, so that the energy conversion efficiency becomes equal to <image>.

```python
n,u = map(int,input().split())
a = list(map(int,input().split()))
i = 0
j = 1
f = 1
ma = -1
while not((i==j) and (i==n-1)):
    if j<=i:
        j+=1
    if j < n-1:
        if a[j+1]-a[i] <= u:
            j+=1
        else:
            if j-i >= 2:
                f=0
                #print(i,j)
                ma = max(ma,(a[j]-a[i+1])/(a[j]-a[i]))
            i+=1
    else:
        if j-i >= 2:
            f=0
            #print(i,j)
            ma = max(ma,(a[j]-a[i+1])/(a[j]-a[i]))
        i+=1
if f:print(-1)
else:print(ma)

```


982_C. Cut 'em all!

You're given a tree with n vertices.

Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.

Input

The first line contains an integer n (1 ≤ n ≤ 10^5) denoting the size of the tree.

The next n - 1 lines contain two integers u, v (1 ≤ u, v ≤ n) each, describing the vertices connected by the i-th edge.

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

Output

Output a single integer k — the maximum number of edges that can be removed to leave all connected components with even size, or -1 if it is impossible to remove edges in order to satisfy this property.

Examples

Input

4
2 4
4 1
3 1

Output

1

Input

3
1 2
1 3

Output

-1

Input

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

Output

4

Input

2
1 2

Output

0

Note

In the first example you can remove the edge between vertices 1 and 4. The graph after that will have two connected components with two vertices in each.

In the second example you can't remove edges in such a way that all components have even number of vertices, so the answer is -1.

```python
from collections import  defaultdict
import threading
from sys import stdin,setrecursionlimit
setrecursionlimit(300000)
input=stdin.readline

def dfs(node,g,par,sz):
	for i in g[node]:
		if i!=par:
			sz[node]+=dfs(i,g,node,sz)
	return sz[node]+1
def main():
	n=int(input())
	if n%2!=0:
		print(-1)
		exit(0)
	g=defaultdict(list)
	for i in range(n-1):
		x,y=map(int,input().strip().split())
		g[x-1].append(y-1)
		g[y-1].append(x-1)

	sz=[0]*(n)
	tt=[]
	dfs(0,g,-1,sz)
	res=0
	# print(sz)
	for i in range(1,n):
		if sz[i]%2!=0:
			res+=1
	print(res)

threading.stack_size(10 ** 8)
t = threading.Thread(target=main)
t.start()
t.join()
```


p02560 AtCoder Library Practice Contest - Floor Sum

In this problem, you should process T testcases.

For each testcase, you are given four integers N, M, A, B.

Calculate \sum_{i = 0}^{N - 1} floor((A \times i + B) / M).

Constraints

* 1 \leq T \leq 100,000
* 1 \leq N, M \leq 10^9
* 0 \leq A, B < M

Input

Input is given from Standard Input in the following format:

T
N_0 M_0 A_0 B_0
N_1 M_1 A_1 B_1
:
N_{T - 1} M_{T - 1} A_{T - 1} B_{T - 1}

Output

Print the answer for each testcase.

Example

Input

5
4 10 6 3
6 5 4 3
1 1 0 0
31415 92653 58979 32384
1000000000 1000000000 999999999 999999999

Output

3
13
0
314095480
499999999500000000

```python
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())

def floor_sum(n,m,a,b):  # sum((A*i+B)//M for i in range(N))
    res = 0
    res += (a//m)*n*(n-1)//2 + (b//m)*n
    a %= m
    b %= m
    y_max = (a*n+b)//m
    if y_max == 0:
        return res
    x_max = m*y_max-b
    res += (n+(-x_max)//a)*y_max
    res += floor_sum(y_max,a,m,(x_max+a-1)//a*a-x_max)
    return res

T = I()
for i in range(T):
    n,m,a,b = MI()
    print(floor_sum(n,m,a,b))

```


p02691 AtCoder Beginner Contest 166 - This Message Will Self-Destruct in 5s

You are the top spy of AtCoder Kingdom. To prevent the stolen secret from being handed to AlDebaran Kingdom, you have sneaked into the party where the transaction happens.

There are N attendees in the party, and they are given attendee numbers from 1 through N. The height of Attendee i is A_i.

According to an examination beforehand, you know that a pair of attendees satisfying the condition below will make the transaction.

* The absolute difference of their attendee numbers is equal to the sum of their heights.

There are \frac{N(N-1)}{2} ways to choose two from the N attendees and make a pair. Among them, how many satisfy the condition above?

P.S.: We cannot let you know the secret.

Constraints

* All values in input are integers.
* 2 \leq N \leq 2 \times 10^5
* 1 \leq A_i \leq 10^9\ (1 \leq i \leq N)

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \dots A_N

Output

Print the number of pairs satisfying the condition.

Examples

Input

6
2 3 3 1 3 1

Output

3

Input

6
5 2 4 2 8 8

Output

0

Input

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

Output

22

```python
n= int(input())
l=list(map(int,input().split()))
d={}
ans=0
for i in range(n):

    if i-l[i] in d:
        ans+=d[i-l[i]]
    if i+l[i] in d:
        d[i+l[i]]+=1
    else:
        d[i+l[i]]=1
print(ans)
```