1372_B. Omkar and Last Class of Math

In Omkar's last class of math, he learned about the least common multiple, or LCM. LCM(a, b) is the smallest positive integer x which is divisible by both a and b.

Omkar, having a laudably curious mind, immediately thought of a problem involving the LCM operation: given an integer n, find positive integers a and b such that a + b = n and LCM(a, b) is the minimum value possible.

Can you help Omkar solve his ludicrously challenging math problem?

Input

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

Each test case consists of a single integer n (2 ≤ n ≤ 10^{9}).

Output

For each test case, output two positive integers a and b, such that a + b = n and LCM(a, b) is the minimum possible.

Example

Input

3
4
6
9

Output

2 2
3 3
3 6

Note

For the first test case, the numbers we can choose are 1, 3 or 2, 2. LCM(1, 3) = 3 and LCM(2, 2) = 2, so we output 2 \ 2.

For the second test case, the numbers we can choose are 1, 5, 2, 4, or 3, 3. LCM(1, 5) = 5, LCM(2, 4) = 4, and LCM(3, 3) = 3, so we output 3 \ 3.

For the third test case, LCM(3, 6) = 6. It can be shown that there are no other pairs of numbers which sum to 9 that have a lower LCM.

```python
from math import ceil, sqrt

for _ in range(int(input())):
    n = int(input())
    if n % 2 == 0: print(n // 2, n // 2)
    else:
        for i in range(3, ceil(sqrt(n)) + 1):
            if n % i == 0:
                print(n // i, n - (n // i))
                break
        else:
            print(1, n - 1)

```


1395_A. Boboniu Likes to Color Balls

Boboniu gives you

  * r red balls,
  * g green balls,
  * b blue balls,
  * w white balls.

He allows you to do the following operation as many times as you want:

  * Pick a red ball, a green ball, and a blue ball and then change their color to white.

You should answer if it's possible to arrange all the balls into a palindrome after several (possibly zero) number of described operations.

Input

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

For each of the next T cases, the first line contains four integers r, g, b and w (0≤ r,g,b,w≤ 10^9).

Output

For each test case, print "Yes" if it's possible to arrange all the balls into a palindrome after doing several (possibly zero) number of described operations. Otherwise, print "No".

Example

Input

4
0 1 1 1
8 1 9 3
0 0 0 0
1000000000 1000000000 1000000000 1000000000

Output

No
Yes
Yes
Yes

Note

In the first test case, you're not able to do any operation and you can never arrange three balls of distinct colors into a palindrome.

In the second test case, after doing one operation, changing (8,1,9,3) to (7,0,8,6), one of those possible palindromes may be "rrrwwwbbbbrbbbbwwwrrr".

A palindrome is a word, phrase, or sequence that reads the same backwards as forwards. For example, "rggbwbggr", "b", "gg" are palindromes while "rgbb", "gbbgr" are not. Notice that an empty word, phrase, or sequence is palindrome.

```python
n = int(input(''))
for i in range(n):
    r,g,b,w= map(int,input().split())
    num = r%2+g%2+b%2+w%2
    less = min(r,min(g,b))
    if less == 0:
        if num > 1:
            print('No')
        else:
            print('Yes')
    else:
        if num == 2:
            print('No')
        else:
            print('Yes')

```


1419_D1. Sage's Birthday (easy version)

This is the easy version of the problem. The difference between the versions is that in the easy version all prices a_i are different. You can make hacks if and only if you solved both versions of the problem.

Today is Sage's birthday, and she will go shopping to buy ice spheres. All n ice spheres are placed in a row and they are numbered from 1 to n from left to right. Each ice sphere has a positive integer price. In this version all prices are different.

An ice sphere is cheap if it costs strictly less than two neighboring ice spheres: the nearest to the left and the nearest to the right. The leftmost and the rightmost ice spheres are not cheap. Sage will choose all cheap ice spheres and then buy only them.

You can visit the shop before Sage and reorder the ice spheres as you wish. Find out the maximum number of ice spheres that Sage can buy, and show how the ice spheres should be reordered.

Input

The first line contains a single integer n (1 ≤ n ≤ 10^5) — the number of ice spheres in the shop.

The second line contains n different integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the prices of ice spheres.

Output

In the first line print the maximum number of ice spheres that Sage can buy.

In the second line print the prices of ice spheres in the optimal order. If there are several correct answers, you can print any of them.

Example

Input

5
1 2 3 4 5

Output

2
3 1 4 2 5

Note

In the example it's not possible to place ice spheres in any order so that Sage would buy 3 of them. If the ice spheres are placed like this (3, 1, 4, 2, 5), then Sage will buy two spheres: one for 1 and one for 2, because they are cheap.

```python
n = int(input())
a = sorted([int(i) for i in input().split()])

b = []
for i in range(n // 2):
    b.append(a[-1-i])
    b.append(a[i])
if n % 2 == 1:
    b.append(a[n // 2])

print((n - 1) // 2)
print(' '.join([str(i) for i in b]))

```


1437_D. Minimal Height Tree

Monocarp had a tree which consisted of n vertices and was rooted at vertex 1. He decided to study BFS ([Breadth-first search](https://en.wikipedia.org/wiki/Breadth-first_search)), so he ran BFS on his tree, starting from the root. BFS can be described by the following pseudocode:

    a = [] # the order in which vertices were processed
    q = Queue()
    q.put(1) # place the root at the end of the queue
    while not q.empty():
        k = q.pop() # retrieve the first vertex from the queue
        a.append(k) # append k to the end of the sequence in which vertices were visited
        for y in g[k]: # g[k] is the list of all children of vertex k, sorted in ascending order
            q.put(y)

Monocarp was fascinated by BFS so much that, in the end, he lost his tree. Fortunately, he still has a sequence of vertices, in which order vertices were visited by the BFS algorithm (the array a from the pseudocode). Monocarp knows that each vertex was visited exactly once (since they were put and taken from the queue exactly once). Also, he knows that all children of each vertex were viewed in ascending order.

Monocarp knows that there are many trees (in the general case) with the same visiting order a, so he doesn't hope to restore his tree. Monocarp is okay with any tree that has minimum height.

The height of a tree is the maximum depth of the tree's vertices, and the depth of a vertex is the number of edges in the path from the root to it. For example, the depth of vertex 1 is 0, since it's the root, and the depth of all root's children are 1.

Help Monocarp to find any tree with given visiting order a and minimum height.

Input

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

The first line of each test case contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of vertices in the tree.

The second line of each test case contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n; a_i ≠ a_j; a_1 = 1) — the order in which the vertices were visited by the BFS algorithm.

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 minimum possible height of a tree with the given visiting order a.

Example

Input

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

Output

3
1
1

Note

In the first test case, there is only one tree with the given visiting order:

<image>

In the second test case, there is only one tree with the given visiting order as well:

<image>

In the third test case, an optimal tree with the given visiting order is shown below:

<image>

```python
tests = int (input())
for test in range (tests):
  n = int (input())
  a = list(map (int, input().split()))
  res = 1
  tails = 1
  ntails = 0
  i = 1
  while i < n:
    if tails == 0:
      res += 1
      tails = ntails
      ntails = 0

    while (i + 1 < n and a[i] < a[i+1]):
      i += 1
      ntails += 1
    i += 1
    ntails += 1
    tails -= 1

  print (res)

```


1462_B. Last Year's Substring

Polycarp has a string s[1 ... n] of length n consisting of decimal digits. Polycarp performs the following operation with the string s no more than once (i.e. he can perform operation 0 or 1 time):

  * Polycarp selects two numbers i and j (1 ≤ i ≤ j ≤ n) and removes characters from the s string at the positions i, i+1, i+2, …, j (i.e. removes substring s[i ... j]). More formally, Polycarp turns the string s into the string s_1 s_2 … s_{i-1} s_{j+1} s_{j+2} … s_{n}.

For example, the string s = "20192020" Polycarp can turn into strings:

  * "2020" (in this case (i, j)=(3, 6) or (i, j)=(1, 4));
  * "2019220" (in this case (i, j)=(6, 6));
  * "020" (in this case (i, j)=(1, 5));
  * other operations are also possible, only a few of them are listed above.

Polycarp likes the string "2020" very much, so he is wondering if it is possible to turn the string s into a string "2020" in no more than one operation? Note that you can perform zero operations.

Input

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

The first line of each test case contains an integer n (4 ≤ n ≤ 200) — length of the string s. The next line contains a string s of length n consisting of decimal digits. It is allowed that the string s starts with digit 0.

Output

For each test case, output on a separate line:

  * "YES" if Polycarp can turn the string s into a string "2020" in no more than one operation (i.e. he can perform 0 or 1 operation);
  * "NO" otherwise.

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

Example

Input

6
8
20192020
8
22019020
4
2020
5
20002
6
729040
6
200200

Output

YES
YES
YES
NO
NO
NO

Note

In the first test case, Polycarp could choose i=3 and j=6.

In the second test case, Polycarp could choose i=2 and j=5.

In the third test case, Polycarp did not perform any operations with the string.


1487_C. Minimum Ties

A big football championship will occur soon! n teams will compete in it, and each pair of teams will play exactly one game against each other.

There are two possible outcomes of a game:

  * the game may result in a tie, then both teams get 1 point;
  * one team might win in a game, then the winning team gets 3 points and the losing team gets 0 points.

The score of a team is the number of points it gained during all games that it played.

You are interested in a hypothetical situation when all teams get the same score at the end of the championship. A simple example of that situation is when all games result in ties, but you want to minimize the number of ties as well.

Your task is to describe a situation (choose the result of each game) so that all teams get the same score, and the number of ties is the minimum possible.

Input

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

Then the test cases follow. Each test case is described by one line containing one integer n (2 ≤ n ≤ 100) — the number of teams.

Output

For each test case, print (n(n - 1))/(2) integers describing the results of the games in the following order: the first integer should correspond to the match between team 1 and team 2, the second — between team 1 and team 3, then 1 and 4, ..., 1 and n, 2 and 3, 2 and 4, ..., 2 and n, and so on, until the game between the team n - 1 and the team n.

The integer corresponding to the game between the team x and the team y should be 1 if x wins, -1 if y wins, or 0 if the game results in a tie.

All teams should get the same score, and the number of ties should be the minimum possible. If there are multiple optimal answers, print any of them. It can be shown that there always exists a way to make all teams have the same score.

Example

Input

2
2
3

Output

0
1 -1 1

Note

In the first test case of the example, both teams get 1 point since the game between them is a tie.

In the second test case of the example, team 1 defeats team 2 (team 1 gets 3 points), team 1 loses to team 3 (team 3 gets 3 points), and team 2 wins against team 3 (team 2 gets 3 points).

```python
import math
import sys
import collections
import bisect
import heapq

ans = []
testcases = int(sys.stdin.readline())

for _ in range(testcases):

    n = int(sys.stdin.readline())

    arr = [[None]*n for i in range(n)]

    if n % 2 == 0:
        x = 1
        y = 0
        for i in range(n//2):
            arr[y][x] = 0
            arr[x][y] = 0
            x += 2
            y += 2
    num = (n-1)//2

    for i in range(n):
        curr = num
        if i % 2 == 0:
            for j in range(i+1,n):
                if arr[i][j] is None:
                    arr[i][j] = 1
                    curr -= 1

                if curr == 0:
                    break
        else:
            for j in range(n-1,i,-1):
                if arr[i][j] is None:
                    arr[i][j] = 1
                    curr -= 1

                if curr == 0:
                    break

        if i % 2 == 1:
            num -= 1

    for i in range(n-1):
        for j in range(i+1,n):
            if arr[i][j] == None:
                print(-1, end=" ")
            else:
                print(arr[i][j], end = " ")

```


1510_K. King's Task

The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task.

There is a permutation p_i of numbers from 1 to 2n. You can make two types of operations.

  1. Swap p_1 and p_2, p_3 and p_4, ..., p_{2n-1} and p_{2n}.
  2. Swap p_1 and p_{n+1}, p_2 and p_{n+2}, ..., p_{n} and p_{2n}.

The task is to find the minimal number of operations required to sort the given permutation.

The Knight was not that smart actually, but quite charming, so the princess asks you to help him to solve the King's task.

Input

The first line contains the integer n (1≤ n≤ 1000). The second line contains 2n integers p_i — the permutation of numbers from 1 to 2n.

Output

Print one integer — the minimal number of operations required to sort the permutation. If it is impossible to sort the permutation using these operations, print -1.

Examples

Input

3
6 3 2 5 4 1

Output

3

Input

2
3 4 2 1

Output

-1

Input

4
1 2 3 4 5 6 7 8

Output

0

Note

In the first example, you can sort the permutation in three operations:

  1. Make operation 1: 3, 6, 5, 2, 1, 4.
  2. Make operation 2: 2, 1, 4, 3, 6, 5.
  3. Make operation 1: 1, 2, 3, 4, 5, 6.

```python
from sys import maxsize

N = int(input())
org_arr = list(map(int, input().split()))
sorted_arr = list(range(1, 2 * N + 1))

cost = maxsize
pos = False
for swap in range(2):
	arr = org_arr.copy()
	tmp_cost = 0
	while arr[0] != 1:
		if swap:
			arr = arr[N:] + arr[:N]
		else:
			for idx in range(0, 2 * N - 1, 2):
				arr[idx], arr[idx + 1] = arr[idx + 1], arr[idx]
		swap = not swap
		tmp_cost += 1
	if arr == sorted_arr:
		pos = True
		cost = min(tmp_cost, cost)
if pos:
	print(cost)
else:
	print(-1)
```


1538_E. Funny Substrings

Polycarp came up with a new programming language. There are only two types of statements in it:

  * "x := s": assign the variable named x the value s (where s is a string). For example, the statement var := hello assigns the variable named var the value hello. Note that s is the value of a string, not the name of a variable. Between the variable name, the := operator and the string contains exactly one space each.
  * "x = a + b": assign the variable named x the concatenation of values of two variables a and b. For example, if the program consists of three statements a := hello, b := world, c = a + b, then the variable c will contain the string helloworld. It is guaranteed that the program is correct and the variables a and b were previously defined. There is exactly one space between the variable names and the = and + operators.

All variable names and strings only consist of lowercase letters of the English alphabet and do not exceed 5 characters.

The result of the program is the number of occurrences of string haha in the string that was written to the variable in the last statement.

Polycarp was very tired while inventing that language. He asks you to implement it. Your task is — for given program statements calculate the number of occurrences of string haha in the last assigned variable.

Input

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

The first line of each test case contains a single integer n (1 ≤ n ≤ 50) — the number of statements in the program. All variable names and strings are guaranteed to consist only of lowercase letters of the English alphabet and do not exceed 5 characters.

This is followed by n lines describing the statements in the format described above. It is guaranteed that the program is correct.

Output

For each set of input data, output the number of occurrences of the haha substring in the string that was written to the variable in the last statement.

Example

Input

4
6
a := h
b := aha
c = a + b
c = c + c
e = c + c
d = a + c
15
x := haha
x = x + x
x = x + x
x = x + x
x = x + x
x = x + x
x = x + x
x = x + x
x = x + x
x = x + x
x = x + x
x = x + x
x = x + x
x = x + x
x = x + x
1
haha := hah
5
haahh := aaaha
ahhhh = haahh + haahh
haahh = haahh + haahh
ahhhh = ahhhh + haahh
ahhaa = haahh + ahhhh

Output

3
32767
0
0

Note

In the first test case the resulting value of d is hhahahaha.

```python
def count(string):
    c=0
    for i in range(len(string)-3):
        k=0
        va=0
        for j in "haha":
            if string[i+k]==j:
                va+=1
            else:
                break
            k+=1
        if va==4:
            c+=1
    return c
def values(string):
    length=len(string)
    occurance=0
    if length>=3:
        prifix=string[:3]
        suffix=string[length-3:]
        occurance=count(string)
    else:
        prifix=string[:]
        suffix=string[:]
    lis=[length,occurance,prifix,suffix]
    return lis
for _ in range(int(input())):
    n=int(input())
    a=[]
    for i in range(n):
        a.append(input())
    d={}
    e=0
    for i in a:
        if ":" in i:
            ind=i.index(":")
            lis=values(i[ind+3:])
            d[i[:ind-1]]=lis
        else:
            ind=i.index("=")
            plus=i.index("+")
            left=i[ind+2:plus-1]
            right=i[plus+2:]
            le=d[left][0]+d[right][0]
            occ=d[left][1]+d[right][1]
            ts=d[left][3]+d[right][2]
            if d[left][0]<3 and d[right][0]<3:
                pr=d[left][2]+d[right][2]
                pri=pr[:3]
                suf=pr[-3:]
            elif d[left][0]<3 and d[right][0]>=3:
                pri=d[left][2]+d[right][2]
                pri=pri[:3]
                suf=d[right][3]
            elif d[left][0]>=3 and d[right][0]<3:
                pri=d[left][2]
                suf=d[left][3]+d[right][2]
                suf=suf[-3:]
            else:
                pri=d[left][2]
                suf=d[right][3]
            occ+=count(ts)
            d[i[:ind-1]]=[le,occ,pri,suf]
        if e==n-1:
            print(d[i[:ind-1]][1])
            break
        e+=1

```


186_A. Comparing Strings

Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told "no genome, no degree". That means that all dwarves should write a thesis on genome. Dwarven genome is far from simple. It is represented by a string that consists of lowercase Latin letters.

Dwarf Misha has already chosen the subject for his thesis: determining by two dwarven genomes, whether they belong to the same race. Two dwarves belong to the same race if we can swap two characters in the first dwarf's genome and get the second dwarf's genome as a result. Help Dwarf Misha and find out whether two gnomes belong to the same race or not.

Input

The first line contains the first dwarf's genome: a non-empty string, consisting of lowercase Latin letters.

The second line contains the second dwarf's genome: a non-empty string, consisting of lowercase Latin letters.

The number of letters in each genome doesn't exceed 105. It is guaranteed that the strings that correspond to the genomes are different. The given genomes may have different length.

Output

Print "YES", if the dwarves belong to the same race. Otherwise, print "NO".

Examples

Input

ab
ba

Output

YES

Input

aa
ab

Output

NO

Note

  * First example: you can simply swap two letters in string "ab". So we get "ba".
  * Second example: we can't change string "aa" into string "ab", because "aa" does not contain letter "b".

```python
g1=list(input())
g2=list(input())
cntr=0
if sorted(g1)!=sorted(g2):
    print('NO')
else:
    for i in range(len(g1)):
        if g1[i]!=g2[i]:
                cntr=cntr+1
    if cntr==2:
        print('YES')
    else:
        print('NO')
```


232_B. Table

John Doe has an n × m table. John Doe can paint points in some table cells, not more than one point in one table cell. John Doe wants to use such operations to make each square subtable of size n × n have exactly k points.

John Doe wondered, how many distinct ways to fill the table with points are there, provided that the condition must hold. As this number can be rather large, John Doe asks to find its remainder after dividing by 1000000007 (109 + 7).

You should assume that John always paints a point exactly in the center of some cell. Two ways to fill a table are considered distinct, if there exists a table cell, that has a point in one way and doesn't have it in the other.

Input

A single line contains space-separated integers n, m, k (1 ≤ n ≤ 100; n ≤ m ≤ 1018; 0 ≤ k ≤ n2) — the number of rows of the table, the number of columns of the table and the number of points each square must contain.

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

Output

In a single line print a single integer — the remainder from dividing the described number of ways by 1000000007 (109 + 7).

Examples

Input

5 6 1

Output

45

Note

Let's consider the first test case:

<image> The gray area belongs to both 5 × 5 squares. So, if it has one point, then there shouldn't be points in any other place. If one of the white areas has a point, then the other one also must have a point. Thus, there are about 20 variants, where the point lies in the gray area and 25 variants, where each of the white areas contains a point. Overall there are 45 variants.

```python
n,m,k=map(int,input().split())
M=int(1e9+7)

N=n*n
iv=[0]*(N+1)
iv[1]=1
for i in range(2, N+1):
    iv[i]=M-M//i*iv[M%i]%M
f1=[1]*(N+1)
for i in range(1, N+1):
    f1[i]=f1[i-1]*i%M
f2=[1]*(N+1)
for i in range(1, N+1):
    f2[i]=f2[i-1]*iv[i]%M
left=m%n
#m/n+1, m/n
def powM(b, p):
    r=1
    while p>0:
        if p%2>0:
            r=r*b%M
        b=b*b%M
        p//=2
    return r
c=[[powM(f1[n]*f2[j]%M*f2[n-j]%M, m//n+i) for j in range(n+1)] for i in range(2)]
#print(c)
dp=[[0]*(k+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(k+1):
        #prune
        if j>i*n or j<k-(n-i)*n:
            continue
        for l in range(min(n, k-j)+1):
            # i,j -> i+1,j+l
            dp[i+1][j+l]=(dp[i+1][j+l]+c[i<left][l]*dp[i][j])%M
print(dp[n][k])
```


258_A. Little Elephant and Bits

The Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.

To make sure that the number a fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from number a in the binary record. At that a new number appears. It consists of the remaining binary digits, written in the corresponding order (possible, with leading zeroes).

The Little Elephant wants the number he is going to write on the paper to be as large as possible. Help him find the maximum number that he can obtain after deleting exactly one binary digit and print it in the binary notation.

Input

The single line contains integer a, written in the binary notation without leading zeroes. This number contains more than 1 and at most 105 digits.

Output

In the single line print the number that is written without leading zeroes in the binary notation — the answer to the problem.

Examples

Input

101

Output

11

Input

110010

Output

11010

Note

In the first sample the best strategy is to delete the second digit. That results in number 112 = 310.

In the second sample the best strategy is to delete the third or fourth digits — that results in number 110102 = 2610.

```python
n=input()
c=0
res=''
for i in range(len(n)):
    if(n[i]=='0' and c==0):
        c+=1
    elif(n[i]=='0' and c>0):
        res+="0"
    elif(n[i]=='1'):
        res+="1"
    else:
        pass
l=len(res)
if c==0:
    res=res[:l-1]
print(res)

```


281_A. Word Capitalization

Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.

Note, that during capitalization all the letters except the first one remains unchanged.

Input

A single line contains a non-empty word. This word consists of lowercase and uppercase English letters. The length of the word will not exceed 103.

Output

Output the given word after capitalization.

Examples

Input

ApPLe

Output

ApPLe

Input

konjac

Output

Konjac

```python
n=list(input())
print(n[0].upper()+str(''.join(n[1:])))

```


330_A. Cakeminator

You are given a rectangular cake, represented as an r × c grid. Each cell either has an evil strawberry, or is empty. For example, a 3 × 4 cake may look as follows:

<image>

The cakeminator is going to eat the cake! Each time he eats, he chooses a row or a column that does not contain any evil strawberries and contains at least one cake cell that has not been eaten before, and eats all the cake cells there. He may decide to eat any number of times.

Please output the maximum number of cake cells that the cakeminator can eat.

Input

The first line contains two integers r and c (2 ≤ r, c ≤ 10), denoting the number of rows and the number of columns of the cake. The next r lines each contains c characters — the j-th character of the i-th line denotes the content of the cell at row i and column j, and is either one of these:

  * '.' character denotes a cake cell with no evil strawberry;
  * 'S' character denotes a cake cell with an evil strawberry.

Output

Output the maximum number of cake cells that the cakeminator can eat.

Examples

Input

3 4
S...
....
..S.

Output

8

Note

For the first example, one possible way to eat the maximum number of cake cells is as follows (perform 3 eats).

<image> <image> <image>

```python
r,c = map(int,input().split())
data = [list(input()) for i in range(r)]

total=0
for i in range(r):
    if 'S' not in data[i]:
        total+=c
row = total//c
for j in range(c):
    for k in range(r):
        if data[k][j]=='S':
            break
    else:
        total=total+r-row
print(total)

```


420_C. Bug in Code

Recently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code? Each of the n coders on the meeting said: 'I know for sure that either x or y did it!'

The head of the company decided to choose two suspects and invite them to his office. Naturally, he should consider the coders' opinions. That's why the head wants to make such a choice that at least p of n coders agreed with it. A coder agrees with the choice of two suspects if at least one of the two people that he named at the meeting was chosen as a suspect. In how many ways can the head of F choose two suspects?

Note that even if some coder was chosen as a suspect, he can agree with the head's choice if he named the other chosen coder at the meeting.

Input

The first line contains integers n and p (3 ≤ n ≤ 3·105; 0 ≤ p ≤ n) — the number of coders in the F company and the minimum number of agreed people.

Each of the next n lines contains two integers xi, yi (1 ≤ xi, yi ≤ n) — the numbers of coders named by the i-th coder. It is guaranteed that xi ≠ i, yi ≠ i, xi ≠ yi.

Output

Print a single integer –– the number of possible two-suspect sets. Note that the order of the suspects doesn't matter, that is, sets (1, 2) и (2, 1) are considered identical.

Examples

Input

4 2
2 3
1 4
1 4
2 1

Output

6

Input

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

Output

1

```python
from collections import defaultdict
from bisect import bisect_left as lower
import sys
input = sys.stdin.readline
def put():
    return map(int, input().split())

try:
    n,m = put()
    cnt, mp, ans = [0]*n, defaultdict(), [0]*n
    for _ in range(n):
        x,y = put()
        x,y = x-1,y-1
        key = (min(x,y), max(x,y))
        if key in mp:
            mp[key]+=1
        else:
            mp[key]=1
        cnt[x]+=1
        cnt[y]+=1

except:
    print('lol')

for (x,y),val in mp.items():
    if cnt[x]+cnt[y]>= m and cnt[x]+cnt[y]-val<m:
        ans[x]-=1
        ans[y]-=1

scnt = cnt.copy()
scnt.sort()
for i in range(n):
    ans[i]+= n-lower(scnt, m-cnt[i])
    if 2*cnt[i]>=m:
        ans[i]-=1

print(sum(ans)//2)

```


447_A. DZY Loves Hash

DZY has a hash table with p buckets, numbered from 0 to p - 1. He wants to insert n numbers, in the order they are given, into the hash table. For the i-th number xi, DZY will put it into the bucket numbered h(xi), where h(x) is the hash function. In this problem we will assume, that h(x) = x mod p. Operation a mod b denotes taking a remainder after division a by b.

However, each bucket can contain no more than one element. If DZY wants to insert an number into a bucket which is already filled, we say a "conflict" happens. Suppose the first conflict happens right after the i-th insertion, you should output i. If no conflict happens, just output -1.

Input

The first line contains two integers, p and n (2 ≤ p, n ≤ 300). Then n lines follow. The i-th of them contains an integer xi (0 ≤ xi ≤ 109).

Output

Output a single integer — the answer to the problem.

Examples

Input

10 5
0
21
53
41
53

Output

4

Input

5 5
0
1
2
3
4

Output

-1

```python
Str=input()
ss=[int(s) for s in Str.split() if s.isdigit()]
p=ss[0]
n=ss[1]
ll=[]
for i in range(n):
    x=int(input())
    r=x%p
    if r not in ll:
        ll.append(r)
    else:
        print(i+1)
        break
else:
    print(-1)

```


469_B. Chat Online

Little X and Little Z are good friends. They always chat online. But both of them have schedules.

Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the time when he gets up. If he gets up at time 0, he will be online at any moment of time between c1 and d1, between c2 and d2, ..., between cq and dq (all borders inclusive). But if he gets up at time t, these segments will be shifted by t. They become [ci + t, di + t] (for all i).

If at a moment of time, both Little X and Little Z are online simultaneosly, they can chat online happily. You know that Little X can get up at an integer moment of time between l and r (both borders inclusive). Also you know that Little X wants to get up at the moment of time, that is suitable for chatting with Little Z (they must have at least one common moment of time in schedules). How many integer moments of time from the segment [l, r] suit for that?

Input

The first line contains four space-separated integers p, q, l, r (1 ≤ p, q ≤ 50; 0 ≤ l ≤ r ≤ 1000).

Each of the next p lines contains two space-separated integers ai, bi (0 ≤ ai < bi ≤ 1000). Each of the next q lines contains two space-separated integers cj, dj (0 ≤ cj < dj ≤ 1000).

It's guaranteed that bi < ai + 1 and dj < cj + 1 for all valid i and j.

Output

Output a single integer — the number of moments of time from the segment [l, r] which suit for online conversation.

Examples

Input

1 1 0 4
2 3
0 1

Output

3

Input

2 3 0 20
15 17
23 26
1 4
7 11
15 17

Output

20

```python
p,q,l,r=list(map(int,input().split()))
a=[]
for i in range(p):
    k,j=list(map(int,input().split()))
    a.append((k,j))
b=[]
for i in range(q):
    k,j=list(map(int,input().split()))
    b.append((k,j))
b.sort(key=lambda h:h[0])
count=0
for i in range(l,r+1):
    for j in range(len(b)):
        gg=0
        for k in range(len(a)):
            if b[j][0]+i<=a[k][0]<= a[k][1]<=b[j][1]+i or a[k][0]<=b[j][0]+i<=a[k][1]<=b[j][1]+i or b[j][0]+i<=a[k][0]<=b[j][1]+i<=a[k][1] or a[k][0]<=b[j][0]+i<=b[j][1]+i<=a[k][1]:
                count+=1
                gg=1
                break
        if gg==1:
            break
print(count)

```


491_A. Up the hill

Hiking club "Up the hill" just returned from a walk. Now they are trying to remember which hills they've just walked through.

It is known that there were N stops, all on different integer heights between 1 and N kilometers (inclusive) above the sea level. On the first day they've traveled from the first stop to the second stop, on the second day they've traveled from the second to the third and so on, and on the last day they've traveled from the stop N - 1 to the stop N and successfully finished their expedition.

They are trying to find out which heights were their stops located at. They have an entry in a travel journal specifying how many days did they travel up the hill, and how many days did they walk down the hill.

Help them by suggesting some possible stop heights satisfying numbers from the travel journal.

Input

In the first line there is an integer non-negative number A denoting the number of days of climbing up the hill. Second line contains an integer non-negative number B — the number of days of walking down the hill (A + B + 1 = N, 1 ≤ N ≤ 100 000).

Output

Output N space-separated distinct integers from 1 to N inclusive, denoting possible heights of the stops in order of visiting.

Examples

Input

0
1

Output

2 1

Input

2
1

Output

1 3 4 2

```python
A, B = int(input()), int(input())

print(*range(B+1, A+B+2), *reversed(range(1, B+1)))
```


515_B. Drazil and His Happy Friends

Drazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan.

There are n boys and m girls among his friends. Let's number them from 0 to n - 1 and 0 to m - 1 separately. In i-th day, Drazil invites <image>-th boy and <image>-th girl to have dinner together (as Drazil is programmer, i starts from 0). If one of those two people is happy, the other one will also become happy. Otherwise, those two people remain in their states. Once a person becomes happy (or if he/she was happy originally), he stays happy forever.

Drazil wants to know whether he can use this plan to make all his friends become happy at some moment.

Input

The first line contains two integer n and m (1 ≤ n, m ≤ 100).

The second line contains integer b (0 ≤ b ≤ n), denoting the number of happy boys among friends of Drazil, and then follow b distinct integers x1, x2, ..., xb (0 ≤ xi < n), denoting the list of indices of happy boys.

The third line conatins integer g (0 ≤ g ≤ m), denoting the number of happy girls among friends of Drazil, and then follow g distinct integers y1, y2, ... , yg (0 ≤ yj < m), denoting the list of indices of happy girls.

It is guaranteed that there is at least one person that is unhappy among his friends.

Output

If Drazil can make all his friends become happy by this plan, print "Yes". Otherwise, print "No".

Examples

Input

2 3
0
1 0

Output

Yes

Input

2 4
1 0
1 2

Output

No

Input

2 3
1 0
1 1

Output

Yes

Note

By <image> we define the remainder of integer division of i by k.

In first sample case:

  * On the 0-th day, Drazil invites 0-th boy and 0-th girl. Because 0-th girl is happy at the beginning, 0-th boy become happy at this day.
  * On the 1-st day, Drazil invites 1-st boy and 1-st girl. They are both unhappy, so nothing changes at this day.
  * On the 2-nd day, Drazil invites 0-th boy and 2-nd girl. Because 0-th boy is already happy he makes 2-nd girl become happy at this day.
  * On the 3-rd day, Drazil invites 1-st boy and 0-th girl. 0-th girl is happy, so she makes 1-st boy happy.
  * On the 4-th day, Drazil invites 0-th boy and 1-st girl. 0-th boy is happy, so he makes the 1-st girl happy. So, all friends become happy at this moment.

```python
def slve(n,m,b,g):
    bo = [0] * n;gi = [0] * m;i=0
    for i in range(1, len(b)):
        bo[b[i]] = 1
    for i in range(1, len(g)):
        gi[g[i]] = 1
    while i <=10000:
        if bo[(i % n)] == 1 or gi[(i % m)] == 1:bo[(i % n)], gi[(i % m)] = 1, 1
        if bo == [1] * n and gi == [1] * m:return 'Yes'
        i+=1
    return 'No'

n,m=map(int,input().split());b=list(map(int,input().split()));g=list(map(int,input().split()));print(slve(n,m,b,g))

```


542_C. Idempotent functions

Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function <image>, that for any <image> the formula g(g(x)) = g(x) holds.

Let's denote as f(k)(x) the function f applied k times to the value x. More formally, f(1)(x) = f(x), f(k)(x) = f(f(k - 1)(x)) for each k > 1.

You are given some function <image>. Your task is to find minimum positive integer k such that function f(k)(x) is idempotent.

Input

In the first line of the input there is a single integer n (1 ≤ n ≤ 200) — the size of function f domain.

In the second line follow f(1), f(2), ..., f(n) (1 ≤ f(i) ≤ n for each 1 ≤ i ≤ n), the values of a function.

Output

Output minimum k such that function f(k)(x) is idempotent.

Examples

Input

4
1 2 2 4

Output

1

Input

3
2 3 3

Output

2

Input

3
2 3 1

Output

3

Note

In the first sample test function f(x) = f(1)(x) is already idempotent since f(f(1)) = f(1) = 1, f(f(2)) = f(2) = 2, f(f(3)) = f(3) = 2, f(f(4)) = f(4) = 4.

In the second sample test:

  * function f(x) = f(1)(x) isn't idempotent because f(f(1)) = 3 but f(1) = 2;
  * function f(x) = f(2)(x) is idempotent since for any x it is true that f(2)(x) = 3, so it is also true that f(2)(f(2)(x)) = 3.

In the third sample test:

  * function f(x) = f(1)(x) isn't idempotent because f(f(1)) = 3 but f(1) = 2;
  * function f(f(x)) = f(2)(x) isn't idempotent because f(2)(f(2)(1)) = 2 but f(2)(1) = 3;
  * function f(f(f(x))) = f(3)(x) is idempotent since it is identity function: f(3)(x) = x for any <image> meaning that the formula f(3)(f(3)(x)) = f(3)(x) also holds.

```python
from random import randint
from copy import deepcopy

n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= 1

def gen(n):
    a = []
    for i in range(n):
        a.append(randint(0, n - 1))
    return a

def stupid(a, v=False):
    n = len(a)
    init = [a[i] for i in range(n)]

    k = 1
    good = False
    while not good:
        good = True
        if v:
            print(a)
        for i in range(n):
            if a[a[i]] != a[i]:
                good = False
        if good:
            break
        k += 1
        b = [0 for i in range(n)]
        for i in range(n):
            b[i] = init[a[i]]

        a = [b[i] for i in range(n)]

    return k

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

def solve(a, v=False):
    n = len(a)
    d = [0 for i in range(n)]
    on_cycle = [False for i in range(n)]
    cycle_length = [0 for i in range(n)]
    until = [0 for i in range(n)]
    to_len = [0 for i in range(n)]

    for i in range(n):
        if a[i] == i:
            on_cycle[i] = True
            cycle_length[i] = 1
            continue
        cur = i
        cnt = 1
        for j in range(3 * n):
            cur = a[cur]
            cnt += cur == i
        on_cycle[i] = cnt > 1

        if on_cycle[i]:
            cur = i
            steps = 0
            for j in range(3 * n):
                cur = a[cur]
                steps += 1
                if cur == i:
                    break
            cycle_length[i] = steps

    for i in range(n):
        if not on_cycle[i]:
            cur = i
            steps = 0
            for j in range(n + 1):
                cur = a[cur]
                steps += 1
                if on_cycle[cur]:
                    break
            until[i] = steps
            to_len[i] = cycle_length[cur]

    if v:
        print('cycle', cycle_length)
        print('until', until)
    lcm = 1
    low = 0
    for i in range(n):
        if on_cycle[i]:
            lcm = get_lcm(lcm, cycle_length[i])
        else:
            low = max(low, until[i])
            continue
            to = to_len[i]
            p = until[i]

            if p % to:
                p = ((p // to) + 1) * to
            low = max(low, p)
            if v:
                print(i, p, to)
    ans = lcm
    while ans < low:
        ans += lcm
    return ans

print(solve(a))
while False:
    a = gen(randint(1, 15))
    print(a)
    print(stupid(deepcopy(a)))
    print(solve(deepcopy(a)))
    assert(stupid(deepcopy(a)) == solve(deepcopy(a)))

```


569_D. Symmetric and Transitive

Little Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term "equivalence relation". These relations are very important in many areas of mathematics. For example, the equality of the two numbers is an equivalence relation.

A set ρ of pairs (a, b) of elements of some set A is called a binary relation on set A. For two elements a and b of the set A we say that they are in relation ρ, if pair <image>, in this case we use a notation <image>.

Binary relation is equivalence relation, if:

  1. It is reflexive (for any a it is true that <image>);
  2. It is symmetric (for any a, b it is true that if <image>, then <image>);
  3. It is transitive (if <image> and <image>, than <image>).

Little Johnny is not completely a fool and he noticed that the first condition is not necessary! Here is his "proof":

Take any two elements, a and b. If <image>, then <image> (according to property (2)), which means <image> (according to property (3)).

It's very simple, isn't it? However, you noticed that Johnny's "proof" is wrong, and decided to show him a lot of examples that prove him wrong.

Here's your task: count the number of binary relations over a set of size n such that they are symmetric, transitive, but not an equivalence relations (i.e. they are not reflexive).

Since their number may be very large (not 0, according to Little Johnny), print the remainder of integer division of this number by 109 + 7.

Input

A single line contains a single integer n (1 ≤ n ≤ 4000).

Output

In a single line print the answer to the problem modulo 109 + 7.

Examples

Input

1

Output

1

Input

2

Output

3

Input

3

Output

10

Note

If n = 1 there is only one such relation — an empty one, i.e. <image>. In other words, for a single element x of set A the following is hold: <image>.

If n = 2 there are three such relations. Let's assume that set A consists of two elements, x and y. Then the valid relations are <image>, ρ = {(x, x)}, ρ = {(y, y)}. It is easy to see that the three listed binary relations are symmetric and transitive relations, but they are not equivalence relations.


590_B. Chip 'n Dale Rescue Rangers

A team of furry rescue rangers was sitting idle in their hollow tree when suddenly they received a signal of distress. In a few moments they were ready, and the dirigible of the rescue chipmunks hit the road.

We assume that the action takes place on a Cartesian plane. The headquarters of the rescuers is located at point (x1, y1), and the distress signal came from the point (x2, y2).

Due to Gadget's engineering talent, the rescuers' dirigible can instantly change its current velocity and direction of movement at any moment and as many times as needed. The only limitation is: the speed of the aircraft relative to the air can not exceed <image> meters per second.

Of course, Gadget is a true rescuer and wants to reach the destination as soon as possible. The matter is complicated by the fact that the wind is blowing in the air and it affects the movement of the dirigible. According to the weather forecast, the wind will be defined by the vector (vx, vy) for the nearest t seconds, and then will change to (wx, wy). These vectors give both the direction and velocity of the wind. Formally, if a dirigible is located at the point (x, y), while its own velocity relative to the air is equal to zero and the wind (ux, uy) is blowing, then after <image> seconds the new position of the dirigible will be <image>.

Gadget is busy piloting the aircraft, so she asked Chip to calculate how long will it take them to reach the destination if they fly optimally. He coped with the task easily, but Dale is convinced that Chip has given the random value, aiming only not to lose the face in front of Gadget. Dale has asked you to find the right answer.

It is guaranteed that the speed of the wind at any moment of time is strictly less than the maximum possible speed of the airship relative to the air.

Input

The first line of the input contains four integers x1, y1, x2, y2 (|x1|, |y1|, |x2|, |y2| ≤ 10 000) — the coordinates of the rescuers' headquarters and the point, where signal of the distress came from, respectively.

The second line contains two integers <image> and t (0 < v, t ≤ 1000), which are denoting the maximum speed of the chipmunk dirigible relative to the air and the moment of time when the wind changes according to the weather forecast, respectively.

Next follow one per line two pairs of integer (vx, vy) and (wx, wy), describing the wind for the first t seconds and the wind that will blow at all the remaining time, respectively. It is guaranteed that <image> and <image>.

Output

Print a single real value — the minimum time the rescuers need to get to point (x2, y2). You answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

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

Examples

Input

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

Output

3.729935587093555327

Input

0 0 0 1000
100 1000
-50 0
50 0

Output

11.547005383792516398

```python
from math import sqrt
import re

class point2:

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def length(self):
        return sqrt(self.x * self.x + self.y * self.y)

def xmult(a, b):
    return a.x * b.y - a.y * b.x

def dmult(a, b):
    return a.x * b.x + a.y * b.y

x1, y1, x2, y2 = map(float, re.split("\ +", input().strip()))
v, t = map(float, re.split("\ +", input().strip()))
vx, vy = map(float, re.split("\ +", input().strip()))
wx, wy = map(float, re.split("\ +", input().strip()))

if x1 == x2 and y1 == y2:
    print(0)
    exit()

u = point2(vx, vy)
w = point2(wx, wy)
d = point2(x2 - x1, y2 - y1)
l = d.length()

h = xmult(d, u) / d.length()
s = dmult(d, u) / d.length()
v1 = sqrt(v * v - h * h) + s

t1 = d.length() / v1
if t1 <= t:
    print(t1)
else:
    x1 = x1 + t * u.x
    y1 = y1 + t * u.y

    l, r = 0.0, 1e9
    while r - l > 1e-7:
        mid = (l + r) / 2
        _x1, _y1 = x1 + mid * w.x, y1 + mid * w.y
        d = point2(x2 - _x1, y2 - _y1).length()
        if d < (mid + t) * v:
            r = mid
        else:
            l = mid

    print(l + t)

```


612_A. The Text Splitting

You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.

For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".

Note it is allowed to split the string s to the strings only of length p or to the strings only of length q (see the second sample test).

Input

The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100).

The second line contains the string s consists of lowercase and uppercase latin letters and digits.

Output

If it's impossible to split the string s to the strings of length p and q print the only number "-1".

Otherwise in the first line print integer k — the number of strings in partition of s.

Each of the next k lines should contain the strings in partition. Each string should be of the length p or q. The string should be in order of their appearing in string s — from left to right.

If there are several solutions print any of them.

Examples

Input

5 2 3
Hello

Output

2
He
llo

Input

10 9 5
Codeforces

Output

2
Codef
orces

Input

6 4 5
Privet

Output

-1

Input

8 1 1
abacabac

Output

8
a
b
a
c
a
b
a
c

```python
n, p, q = map(int, input().split())
s = input()
for i in range(n // p + 1):
    for j in range(n // q + 1):
        if i * p + j * q == n:
            print(i + j)
            for k in range(i):
                print(s[k * p: (k + 1) * p])
            for k in range(j):
                print(s[i * p + k * q: i * p + (k + 1) * q])
            exit()
print(-1)

```


632_A. Grandma Laura and Apples

Grandma Laura came to the market to sell some apples. During the day she sold all the apples she had. But grandma is old, so she forgot how many apples she had brought to the market.

She precisely remembers she had n buyers and each of them bought exactly half of the apples she had at the moment of the purchase and also she gave a half of an apple to some of them as a gift (if the number of apples at the moment of purchase was odd), until she sold all the apples she had.

So each buyer took some integral positive number of apples, but maybe he didn't pay for a half of an apple (if the number of apples at the moment of the purchase was odd).

For each buyer grandma remembers if she gave a half of an apple as a gift or not. The cost of an apple is p (the number p is even).

Print the total money grandma should have at the end of the day to check if some buyers cheated her.

Input

The first line contains two integers n and p (1 ≤ n ≤ 40, 2 ≤ p ≤ 1000) — the number of the buyers and the cost of one apple. It is guaranteed that the number p is even.

The next n lines contains the description of buyers. Each buyer is described with the string half if he simply bought half of the apples and with the string halfplus if grandma also gave him a half of an apple as a gift.

It is guaranteed that grandma has at least one apple at the start of the day and she has no apples at the end of the day.

Output

Print the only integer a — the total money grandma should have at the end of the day.

Note that the answer can be too large, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.

Examples

Input

2 10
half
halfplus

Output

15

Input

3 10
halfplus
halfplus
halfplus

Output

55

Note

In the first sample at the start of the day the grandma had two apples. First she sold one apple and then she sold a half of the second apple and gave a half of the second apple as a present to the second buyer.

```python
n,k = map(int,input().split())
s = [input() for i in range(n)]
s = s[::-1]
x = 0
# print(s)
cost = 0
for i in s:
    if i == "halfplus":
        x = 2*x+1
        cost += x/2*k
    else:
        x = 2*x
        cost += x/2*k
print(int(cost))
```


660_D. Number of Parallelograms

You are given n points on a plane. All the points are distinct and no three of them lie on the same line. Find the number of parallelograms with the vertices at the given points.

Input

The first line of the input contains integer n (1 ≤ n ≤ 2000) — the number of points.

Each of the next n lines contains two integers (xi, yi) (0 ≤ xi, yi ≤ 109) — the coordinates of the i-th point.

Output

Print the only integer c — the number of parallelograms with the vertices at the given points.

Example

Input

4
0 1
1 0
1 1
2 0

Output

1

```python
n=int(input())
def inp(n):
    coor=[[int(i) for i in input().split()] for j in range(n)]

    return coor

coor=inp(n)

def newlist(a):
    d={}
    s=len(a)
    for i in range(1,s):
        for j in range(i):
            if (a[i][0]+a[j][0],a[i][1]+a[j][1]) in d:
                d[a[i][0]+a[j][0],a[i][1]+a[j][1]]+=1
            else:
                d[a[i][0]+a[j][0],a[i][1]+a[j][1]]=1
    return d
def newd(d):
    sum2=0
    for l in d:
        sum2+=d[l]*(d[l]-1)/2
    return int(sum2)

print(newd(newlist(coor)))

```


707_B. Bakery

Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities.

To bake muffins in her bakery, Masha needs to establish flour supply from some storage. There are only k storages, located in different cities numbered a1, a2, ..., ak.

Unforunately the law of the country Masha lives in prohibits opening bakery in any of the cities which has storage located in it. She can open it only in one of another n - k cities, and, of course, flour delivery should be paid — for every kilometer of path between storage and bakery Masha should pay 1 ruble.

Formally, Masha will pay x roubles, if she will open the bakery in some city b (ai ≠ b for every 1 ≤ i ≤ k) and choose a storage in some city s (s = aj for some 1 ≤ j ≤ k) and b and s are connected by some path of roads of summary length x (if there are more than one path, Masha is able to choose which of them should be used).

Masha is very thrifty and rational. She is interested in a city, where she can open her bakery (and choose one of k storages and one of the paths between city with bakery and city with storage) and pay minimum possible amount of rubles for flour delivery. Please help Masha find this amount.

Input

The first line of the input contains three integers n, m and k (1 ≤ n, m ≤ 105, 0 ≤ k ≤ n) — the number of cities in country Masha lives in, the number of roads between them and the number of flour storages respectively.

Then m lines follow. Each of them contains three integers u, v and l (1 ≤ u, v ≤ n, 1 ≤ l ≤ 109, u ≠ v) meaning that there is a road between cities u and v of length of l kilometers .

If k > 0, then the last line of the input contains k distinct integers a1, a2, ..., ak (1 ≤ ai ≤ n) — the number of cities having flour storage located in. If k = 0 then this line is not presented in the input.

Output

Print the minimum possible amount of rubles Masha should pay for flour delivery in the only line.

If the bakery can not be opened (while satisfying conditions) in any of the n cities, print  - 1 in the only line.

Examples

Input

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

Output

3

Input

3 1 1
1 2 3
3

Output

-1

Note

<image>

Image illustrates the first sample case. Cities with storage located in and the road representing the answer are darkened.

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

    graph = [dict() for i in range(n + 1)]

    for i in range(m):
        u, v, l = list(map(int, input().split()))
        if v not in graph[u]:
            graph[u][v] = l
            graph[v][u] = l
        else:
            graph[u][v] = min(graph[u][v], l)
            graph[v][u] = min(graph[v][u], l)

    if k > 0:

        a = list(map(int, input().split()))
        warehouse = [False] * (10 ** 5 + 1)

        for i in a:
            warehouse[i] = True

        ans = 2000000001
        for i in range(k):
            for key in graph[a[i]]:
                if not warehouse[key]:
                    ans = min(ans, graph[a[i]][key])

        if ans == 2000000001:
            print(-1)
        else:
            print(ans)
        return

    print(-1)

solve()
```


74_E. Shift It!

There is a square box 6 × 6 in size. It contains 36 chips 1 × 1 in size. Those chips contain 36 different characters — "0"-"9" and "A"-"Z". There is exactly one chip with each character.

You are allowed to make the following operations: you may choose one of 6 rows or one of 6 columns and cyclically shift the chips there to one position to the left or to the right (for the row) or upwards or downwards (for the column). Those operations are allowed to perform several times.

To solve the puzzle is to shift the chips using the above described operations so that they were written in the increasing order (exactly equal to the right picture). An example of solving the puzzle is shown on a picture below.

<image>

Write a program that finds the sequence of operations that solves the puzzle. That sequence should not necessarily be shortest, but you should not exceed the limit of 10000 operations. It is guaranteed that the solution always exists.

Input

The input data are represented by 6 lines containing 6 characters each. They are the puzzle's initial position. Those lines contain each character from the string "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" exactly once.

Output

On the first line print number n, which is the number of operations. On the next n lines print the sequence of operations one per line. An operation is described by a word consisting of two characters. The first character shows the direction where the row or the column will be shifted. The possible directions are "L", "R" (to the left, to the right correspondingly, we shift a row), "U", "D" (upwards, downwards correspondingly, we shift a column). The second character is the number of the row (or the column), it is an integer from "1" to "6". The rows are numbered from the top to the bottom, the columns are numbered from the left to the right.

The number of operations should not exceed 104. If there are several solutions, print any of them.

Examples

Input

01W345
729AB6
CD8FGH
IJELMN
OPKRST
UVQXYZ

Output

2
R2
U3

```python
ls="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
s,cnt,a1,a2=[],0,[],[]
for i in range(6):
	s.append(list(input()))

def add(c,i):
	global cnt
	cnt+=1
	a1.append(c)
	a2.append(i)

def right(i):
	add('R',i+1)
	tmp=s[i][5]
	for j in range(5,0,-1):
		s[i][j]=s[i][j-1]
	s[i][0]=tmp

def left(i):
	add('L',i+1)
	tmp=s[i][0]
	for j in range(5):
		s[i][j]=s[i][j+1]
	s[i][5]=tmp

def up(j):
	add('U',j+1)
	tmp=s[0][j]
	for i in range(5):
		s[i][j]=s[i+1][j]
	s[5][j]=tmp

def down(j):
	add('D',j+1)
	tmp=s[5][j]
	for i in range(5,0,-1):
		s[i][j]=s[i-1][j]
	s[0][j]=tmp

def chg(i1,j1,i2,j2):
	if i1==i2:
		right(i1);up(j1);right(i1);down(j1)
		right(i1);up(j1);right(i1);down(j1)
		right(i1);up(j1);right(i1);right(i1);down(j1)
	else:
		down(j1);left(i1);down(j1);right(i1)
		down(j1);left(i1);down(j1);right(i1)
		down(j1);left(i1);down(j1);down(j1);right(i1)

for i in range(6):
	for j in range(6):
		toch=ls[i*6+j]
		for ni in range(6):
			for nj in range(6):
				if s[ni][nj]==toch:
					ii,jj=ni,nj
					while jj>j:
						chg(ii,jj-1,ii,jj)
						jj-=1
					while jj<j:
						chg(ii,jj,ii,jj+1)
						jj+=1
					while ii>i:
						chg(ii-1,jj,ii,jj)
						ii-=1
print(cnt)
for i in range(cnt):
	print(a1[i]+str(a2[i]))
```


798_C. Mike and gcd problem

Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.

Mike wants to change his sequence in order to make it beautiful. In one move he can choose an index i (1 ≤ i < n), delete numbers ai, ai + 1 and put numbers ai - ai + 1, ai + ai + 1 in their place instead, in this order. He wants perform as few operations as possible. Find the minimal number of operations to make sequence A beautiful if it's possible, or tell him that it is impossible to do so.

<image> is the biggest non-negative number d such that d divides bi for every i (1 ≤ i ≤ n).

Input

The first line contains a single integer n (2 ≤ n ≤ 100 000) — length of sequence A.

The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — elements of sequence A.

Output

Output on the first line "YES" (without quotes) if it is possible to make sequence A beautiful by performing operations described above, and "NO" (without quotes) otherwise.

If the answer was "YES", output the minimal number of moves needed to make sequence A beautiful.

Examples

Input

2
1 1

Output

YES
1

Input

3
6 2 4

Output

YES
0

Input

2
1 3

Output

YES
1

Note

In the first example you can simply make one move to obtain sequence [0, 2] with <image>.

In the second example the gcd of the sequence is already greater than 1.

```python
def gcd(a, b):
    while b:
        a, b = b, a % b

    return a

n = int(input())

a = list(map(int, input().split()))
ans = 0
l = 0

g = a[0]
for i in range(n):
    g = gcd(a[i], g)

if g > 1:
    print('YES\n0')
else:
    for i in range(n):
        if a[i] % 2:
            l += 1
        else:
            if l % 2:
                ans += l // 2 + 2
            else:
                ans += l // 2

            l = 0

    if l % 2:
        ans += l // 2 + 2
    else:
        ans += l // 2

    print('YES')
    print(ans)
```


818_E. Card Game Again

Vova again tries to play some computer card game.

The rules of deck creation in this game are simple. Vova is given an existing deck of n cards and a magic number k. The order of the cards in the deck is fixed. Each card has a number written on it; number ai is written on the i-th card in the deck.

After receiving the deck and the magic number, Vova removes x (possibly x = 0) cards from the top of the deck, y (possibly y = 0) cards from the bottom of the deck, and the rest of the deck is his new deck (Vova has to leave at least one card in the deck after removing cards). So Vova's new deck actually contains cards x + 1, x + 2, ... n - y - 1, n - y from the original deck.

Vova's new deck is considered valid iff the product of all numbers written on the cards in his new deck is divisible by k. So Vova received a deck (possibly not a valid one) and a number k, and now he wonders, how many ways are there to choose x and y so the deck he will get after removing x cards from the top and y cards from the bottom is valid?

Input

The first line contains two integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ 109).

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the numbers written on the cards.

Output

Print the number of ways to choose x and y so the resulting deck is valid.

Examples

Input

3 4
6 2 8

Output

4

Input

3 6
9 1 14

Output

1

Note

In the first example the possible values of x and y are:

  1. x = 0, y = 0;
  2. x = 1, y = 0;
  3. x = 2, y = 0;
  4. x = 0, y = 1.

```python
# ---------------------------iye ha aam zindegi---------------------------------------------
import math
import random
import heapq,bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
threading.stack_size(10**8)
mod = 10 ** 9 + 7
mod1 = 998244353

# ------------------------------warmup----------------------------
import os
import sys
from io import BytesIO, IOBase
sys.setrecursionlimit(300000)

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

# -------------------game starts now----------------------------------------------------import math
class TreeNode:
    def __init__(self, k, v):
        self.key = k
        self.value = v
        self.left = None
        self.right = None
        self.parent = None
        self.height = 1
        self.num_left = 1
        self.num_total = 1

class AvlTree:

    def __init__(self):
        self._tree = None

    def add(self, k, v):
        if not self._tree:
            self._tree = TreeNode(k, v)
            return
        node = self._add(k, v)
        if node:
            self._rebalance(node)

    def _add(self, k, v):
        node = self._tree
        while node:
            if k < node.key:
                if node.left:
                    node = node.left
                else:
                    node.left = TreeNode(k, v)
                    node.left.parent = node
                    return node.left
            elif node.key < k:
                if node.right:
                    node = node.right
                else:
                    node.right = TreeNode(k, v)
                    node.right.parent = node
                    return node.right
            else:
                node.value = v
                return

    @staticmethod
    def get_height(x):
        return x.height if x else 0

    @staticmethod
    def get_num_total(x):
        return x.num_total if x else 0

    def _rebalance(self, node):

        n = node
        while n:
            lh = self.get_height(n.left)
            rh = self.get_height(n.right)
            n.height = max(lh, rh) + 1
            balance_factor = lh - rh
            n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
            n.num_left = 1 + self.get_num_total(n.left)

            if balance_factor > 1:
                if self.get_height(n.left.left) < self.get_height(n.left.right):
                    self._rotate_left(n.left)
                self._rotate_right(n)
            elif balance_factor < -1:
                if self.get_height(n.right.right) < self.get_height(n.right.left):
                    self._rotate_right(n.right)
                self._rotate_left(n)
            else:
                n = n.parent

    def _remove_one(self, node):
        """
        Side effect!!! Changes node. Node should have exactly one child
        """
        replacement = node.left or node.right
        if node.parent:
            if AvlTree._is_left(node):
                node.parent.left = replacement
            else:
                node.parent.right = replacement
            replacement.parent = node.parent
            node.parent = None
        else:
            self._tree = replacement
            replacement.parent = None
        node.left = None
        node.right = None
        node.parent = None
        self._rebalance(replacement)

    def _remove_leaf(self, node):
        if node.parent:
            if AvlTree._is_left(node):
                node.parent.left = None
            else:
                node.parent.right = None
            self._rebalance(node.parent)
        else:
            self._tree = None
        node.parent = None
        node.left = None
        node.right = None

    def remove(self, k):
        node = self._get_node(k)
        if not node:
            return
        if AvlTree._is_leaf(node):
            self._remove_leaf(node)
            return
        if node.left and node.right:
            nxt = AvlTree._get_next(node)
            node.key = nxt.key
            node.value = nxt.value
            if self._is_leaf(nxt):
                self._remove_leaf(nxt)
            else:
                self._remove_one(nxt)
            self._rebalance(node)
        else:
            self._remove_one(node)

    def get(self, k):
        node = self._get_node(k)
        return node.value if node else -1

    def _get_node(self, k):
        if not self._tree:
            return None
        node = self._tree
        while node:
            if k < node.key:
                node = node.left
            elif node.key < k:
                node = node.right
            else:
                return node
        return None

    def get_at(self, pos):
        x = pos + 1
        node = self._tree
        while node:
            if x < node.num_left:
                node = node.left
            elif node.num_left < x:
                x -= node.num_left
                node = node.right
            else:
                return (node.key, node.value)
        raise IndexError("Out of ranges")

    @staticmethod
    def _is_left(node):
        return node.parent.left and node.parent.left == node

    @staticmethod
    def _is_leaf(node):
        return node.left is None and node.right is None

    def _rotate_right(self, node):
        if not node.parent:
            self._tree = node.left
            node.left.parent = None
        elif AvlTree._is_left(node):
            node.parent.left = node.left
            node.left.parent = node.parent
        else:
            node.parent.right = node.left
            node.left.parent = node.parent
        bk = node.left.right
        node.left.right = node
        node.parent = node.left
        node.left = bk
        if bk:
            bk.parent = node
        node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
        node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
        node.num_left = 1 + self.get_num_total(node.left)

    def _rotate_left(self, node):
        if not node.parent:
            self._tree = node.right
            node.right.parent = None
        elif AvlTree._is_left(node):
            node.parent.left = node.right
            node.right.parent = node.parent
        else:
            node.parent.right = node.right
            node.right.parent = node.parent
        bk = node.right.left
        node.right.left = node
        node.parent = node.right
        node.right = bk
        if bk:
            bk.parent = node
        node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
        node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
        node.num_left = 1 + self.get_num_total(node.left)

    @staticmethod
    def _get_next(node):
        if not node.right:
            return node.parent
        n = node.right
        while n.left:
            n = n.left
        return n

# -----------------------------------------------binary seacrh tree---------------------------------------
class SegmentTree1:
    def __init__(self, data, default=2**51, func=lambda a, b: a & b):
        """initialize the segment tree with data"""
        self._default = default
        self._func = func
        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()

        self.data = [default] * (2 * _size)
        self.data[_size:_size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = func(self.data[i + i], self.data[i + i + 1])

    def __delitem__(self, idx):
        self[idx] = self._default

    def __getitem__(self, idx):
        return self.data[idx + self._size]

    def __setitem__(self, idx, value):
        idx += self._size
        self.data[idx] = value
        idx >>= 1
        while idx:
            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            idx >>= 1

    def __len__(self):
        return self._len

    def query(self, start, stop):
        if start == stop:
            return self.__getitem__(start)
        stop += 1
        start += self._size
        stop += self._size

        res = self._default
        while start < stop:
            if start & 1:
                res = self._func(res, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                res = self._func(res, self.data[stop])
            start >>= 1
            stop >>= 1
        return res

    def __repr__(self):
        return "SegmentTree({0})".format(self.data)

# -------------------game starts now----------------------------------------------------import math
class SegmentTree:
    def __init__(self, data, default=0, func=lambda a, b: max(a , b)):
        """initialize the segment tree with data"""
        self._default = default
        self._func = func
        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()

        self.data = [default] * (2 * _size)
        self.data[_size:_size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = func(self.data[i + i], self.data[i + i + 1])

    def __delitem__(self, idx):
        self[idx] = self._default

    def __getitem__(self, idx):
        return self.data[idx + self._size]

    def __setitem__(self, idx, value):
        idx += self._size
        self.data[idx] = value
        idx >>= 1
        while idx:
            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            idx >>= 1

    def __len__(self):
        return self._len

    def query(self, start, stop):
        if start == stop:
            return self.__getitem__(start)
        stop += 1
        start += self._size
        stop += self._size

        res = self._default
        while start < stop:
            if start & 1:
                res = self._func(res, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                res = self._func(res, self.data[stop])
            start >>= 1
            stop >>= 1
        return res

    def __repr__(self):
        return "SegmentTree({0})".format(self.data)

# -------------------------------iye ha chutiya zindegi-------------------------------------
class Factorial:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorials = [1, 1]
        self.invModulos = [0, 1]
        self.invFactorial_ = [1, 1]

    def calc(self, n):
        if n <= -1:
            print("Invalid argument to calculate n!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.factorials):
            return self.factorials[n]
        nextArr = [0] * (n + 1 - len(self.factorials))
        initialI = len(self.factorials)
        prev = self.factorials[-1]
        m = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = prev * i % m
        self.factorials += nextArr
        return self.factorials[n]

    def inv(self, n):
        if n <= -1:
            print("Invalid argument to calculate n^(-1)")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        p = self.MOD
        pi = n % p
        if pi < len(self.invModulos):
            return self.invModulos[pi]
        nextArr = [0] * (n + 1 - len(self.invModulos))
        initialI = len(self.invModulos)
        for i in range(initialI, min(p, n + 1)):
            next = -self.invModulos[p % i] * (p // i) % p
            self.invModulos.append(next)
        return self.invModulos[pi]

    def invFactorial(self, n):
        if n <= -1:
            print("Invalid argument to calculate (n^(-1))!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.invFactorial_):
            return self.invFactorial_[n]
        self.inv(n)  # To make sure already calculated n^-1
        nextArr = [0] * (n + 1 - len(self.invFactorial_))
        initialI = len(self.invFactorial_)
        prev = self.invFactorial_[-1]
        p = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p
        self.invFactorial_ += nextArr
        return self.invFactorial_[n]

class Combination:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorial = Factorial(MOD)

    def ncr(self, n, k):
        if k < 0 or n < k:
            return 0
        k = min(k, n - k)
        f = self.factorial
        return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

# --------------------------------------iye ha combinations ka zindegi---------------------------------
def powm(a, n, m):
    if a == 1 or n == 0:
        return 1
    if n % 2 == 0:
        s = powm(a, n // 2, m)
        return s * s % m
    else:
        return a * powm(a, n - 1, m) % m

# --------------------------------------iye ha power ka zindegi---------------------------------
def sort_list(list1, list2):
    zipped_pairs = zip(list2, list1)

    z = [x for _, x in sorted(zipped_pairs)]

    return z

# --------------------------------------------------product----------------------------------------
def product(l):
    por = 1
    for i in range(len(l)):
        por *= l[i]
    return por

# --------------------------------------------------binary----------------------------------------
def binarySearchCount(arr, n, key):
    left = 0
    right = n - 1

    count = 0

    while (left <= right):
        mid = int((right + left) / 2)

        # Check if middle element is
        # less than or equal to key
        if (arr[mid] < key):
            count = mid + 1
            left = mid + 1

        # If key is smaller, ignore right half
        else:
            right = mid - 1

    return count

# --------------------------------------------------binary----------------------------------------
def countdig(n):
    c = 0
    while (n > 0):
        n //= 10
        c += 1
    return c
def binary(x, length):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y

def countGreater(arr, n, k):
    l = 0
    r = n - 1

    # Stores the index of the left most element
    # from the array which is greater than k
    leftGreater = n

    # Finds number of elements greater than k
    while (l <= r):
        m = int(l + (r - l) / 2)
        if (arr[m] >= k):
            leftGreater = m
            r = m - 1

        # If mid element is less than
        # or equal to k update l
        else:
            l = m + 1

    # Return the count of elements
    # greater than k
    return (n - leftGreater)

# --------------------------------------------------binary------------------------------------
n,k=map(int,input().split())
l=list(map(int,input().split()))
div=defaultdict(int)
su=defaultdict(list)
for i in range(2,int(math.sqrt(k))+1):
    while(k%i==0):
        k//=i
        div[i]+=1
if k>1:
    div[k]+=1
for j in div:
    su[j].append(0)
def find(ind):
    st=0
    end=ind
    ans=st
    while(st<=end):
        mid=(st+end)//2
        f=0
        for j in div:
            if su[j][ind+1]-su[j][mid]>=div[j]:
                continue
            else:
                f=1
                break
        if f==0:
            ans=mid
            st=mid+1
        else:
            end=mid-1
    return ans
ans=0
for i in range(n):
    f=0
    for j in div:
        c=0
        while(l[i]%j==0):
            l[i]//=j
            c+=1
        su[j].append(su[j][-1]+c)
        if su[j][i+1]<div[j]:
            f=1
    if f==1:
        continue
    u=find(i)
    ans+=u+1
print(ans)
```


844_A. Diversity

Calculate the minimum number of characters you need to change in the string s, so that it contains at least k different letters, or print that it is impossible.

String s consists only of lowercase Latin letters, and it is allowed to change characters only to lowercase Latin letters too.

Input

First line of input contains string s, consisting only of lowercase Latin letters (1 ≤ |s| ≤ 1000, |s| denotes the length of s).

Second line of input contains integer k (1 ≤ k ≤ 26).

Output

Print single line with a minimum number of necessary changes, or the word «impossible» (without quotes) if it is impossible.

Examples

Input

yandex
6

Output

0

Input

yahoo
5

Output

1

Input

google
7

Output

impossible

Note

In the first test case string contains 6 different letters, so we don't need to change anything.

In the second test case string contains 4 different letters: {'a', 'h', 'o', 'y'}. To get 5 different letters it is necessary to change one occurrence of 'o' to some letter, which doesn't occur in the string, for example, {'b'}.

In the third test case, it is impossible to make 7 different letters because the length of the string is 6.

```python
m=input()
n=int(input())
if n>len(m):
    print("impossible")
else:
    v=n-len(set(m))
    print(v if v>0 else 0)

```


864_D. Make a Permutation!

Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n.

Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of elements in his array in such a way that his array becomes a permutation (i.e. each of the integers from 1 to n was encountered in his array exactly once). If there are multiple ways to do it he wants to find the lexicographically minimal permutation among them.

Thus minimizing the number of changes has the first priority, lexicographical minimizing has the second priority.

In order to determine which of the two permutations is lexicographically smaller, we compare their first elements. If they are equal — compare the second, and so on. If we have two permutations x and y, then x is lexicographically smaller if xi < yi, where i is the first index in which the permutations x and y differ.

Determine the array Ivan will obtain after performing all the changes.

Input

The first line contains an single integer n (2 ≤ n ≤ 200 000) — the number of elements in Ivan's array.

The second line contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ n) — the description of Ivan's array.

Output

In the first line print q — the minimum number of elements that need to be changed in Ivan's array in order to make his array a permutation. In the second line, print the lexicographically minimal permutation which can be obtained from array with q changes.

Examples

Input

4
3 2 2 3

Output

2
1 2 4 3

Input

6
4 5 6 3 2 1

Output

0
4 5 6 3 2 1

Input

10
6 8 4 6 7 1 6 3 4 5

Output

3
2 8 4 6 7 1 9 3 10 5

Note

In the first example Ivan needs to replace number three in position 1 with number one, and number two in position 3 with number four. Then he will get a permutation [1, 2, 4, 3] with only two changed numbers — this permutation is lexicographically minimal among all suitable.

In the second example Ivan does not need to change anything because his array already is a permutation.

```python
def solve(printing):

    n = int(input())
    nums = [int(st)-1 for st in input().split(" ")]
    numdupe = [0] * n
    dupeindex = []
    dupeindexindv = {}
    missing = []

    if printing:
        print("nums"); print(nums)

    for i in range(n):
        numdupe[nums[i]] += 1

    for i in range(n):
        if numdupe[i] == 0:
            missing.append(i)

        if numdupe[nums[i]] >= 2:
            dupeindex.append(i)
            if nums[i] in dupeindexindv:
                dupeindexindv[nums[i]][1].append(i)
            else:
                dupeindexindv[nums[i]] = [0, [i], False]
                # left location, dupe indexs, if already located original

    for num in dupeindexindv:
        dupeindexindv[num][0] = len(dupeindexindv[num][1])

    if printing:
        print("missing"); print(missing)
        print("dupeindexindv"); print(dupeindexindv)

    misslen = len(missing)
    misindex = 0
    #answer = 0
    for index in dupeindex:

        if misslen <= misindex:
            break

        elif dupeindexindv[nums[index]][0] == 1 and not dupeindexindv[nums[index]][2]:
            # one spot left but original not located yet.
            # locate original.
            dupeindexindv[nums[index]][0] -= 1
            dupeindexindv[nums[index]][2] = True

        elif dupeindexindv[nums[index]][0] > 0:

            if dupeindexindv[nums[index]][2] or missing[misindex] < nums[index]:
                # num is smaller or original is already located.
                # locate missing number.
                dupeindexindv[nums[index]][0] -= 1
                nums[index] = missing[misindex]
                misindex += 1
                #answer += 1

            else: # locate original
                dupeindexindv[nums[index]][0] -= 1
                dupeindexindv[nums[index]][2] = True

    print(misslen)
    for num in nums:
        print(num+1, end = " ")

solve(False)

```


88_C. Trains

Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence.

When Vasya has some free time, he goes to one of his girlfriends. He descends into the subway at some time, waits the first train to come and rides on it to the end of the branch to the corresponding girl. However, the trains run with different frequencies: a train goes to Dasha's direction every a minutes, but a train goes to Masha's direction every b minutes. If two trains approach at the same time, Vasya goes toward the direction with the lower frequency of going trains, that is, to the girl, to whose directions the trains go less frequently (see the note to the third sample).

We know that the trains begin to go simultaneously before Vasya appears. That is the train schedule is such that there exists a moment of time when the two trains arrive simultaneously.

Help Vasya count to which girlfriend he will go more often.

Input

The first line contains two integers a and b (a ≠ b, 1 ≤ a, b ≤ 106).

Output

Print "Dasha" if Vasya will go to Dasha more frequently, "Masha" if he will go to Masha more frequently, or "Equal" if he will go to both girlfriends with the same frequency.

Examples

Input

3 7

Output

Dasha

Input

5 3

Output

Masha

Input

2 3

Output

Equal

Note

Let's take a look at the third sample. Let the trains start to go at the zero moment of time. It is clear that the moments of the trains' arrival will be periodic with period 6. That's why it is enough to show that if Vasya descends to the subway at a moment of time inside the interval (0, 6], he will go to both girls equally often.

If he descends to the subway at a moment of time from 0 to 2, he leaves for Dasha on the train that arrives by the second minute.

If he descends to the subway at a moment of time from 2 to 3, he leaves for Masha on the train that arrives by the third minute.

If he descends to the subway at a moment of time from 3 to 4, he leaves for Dasha on the train that arrives by the fourth minute.

If he descends to the subway at a moment of time from 4 to 6, he waits for both trains to arrive by the sixth minute and goes to Masha as trains go less often in Masha's direction.

In sum Masha and Dasha get equal time — three minutes for each one, thus, Vasya will go to both girlfriends equally often.

```python
a, b = input().split()
a = int(a); b = int(b)

def gcd(a, b):
	if a < b:
		return gcd(b, a)
	elif not a%b:
		return b
	return gcd(b, a%b)

lcm = a*b//gcd(a, b)

if a > b:
	d_count = lcm//a
	m_count = lcm//b - 1

	if m_count > d_count:
		print("Masha")
	elif m_count == d_count:
		print("Equal")
	else:
		print("Dasha")
else:

	d_count = lcm//a - 1
	m_count = lcm//b

	if m_count > d_count:
		print("Masha")
	elif m_count == d_count:
		print("Equal")
	else:
		print("Dasha")

```


913_A. Modular Exponentiation

The following problem is well-known: given integers n and m, calculate

<image>,

where 2n = 2·2·...·2 (n factors), and <image> denotes the remainder of division of x by y.

You are asked to solve the "reverse" problem. Given integers n and m, calculate

<image>.

Input

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

The second line contains a single integer m (1 ≤ m ≤ 108).

Output

Output a single integer — the value of <image>.

Examples

Input

4
42

Output

10

Input

1
58

Output

0

Input

98765432
23456789

Output

23456789

Note

In the first example, the remainder of division of 42 by 24 = 16 is equal to 10.

In the second example, 58 is divisible by 21 = 2 without remainder, and the answer is 0.

```python
n,m=int(input()),int(input())
n=min(n,31)
print(m%(2**n))

```


935_A. Fafa and his Company

Fafa owns a company that works on huge projects. There are n employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees.

Fafa finds doing this every time is very tiring for him. So, he decided to choose the best l employees in his company as team leaders. Whenever there is a new project, Fafa will divide the tasks among only the team leaders and each team leader will be responsible of some positive number of employees to give them the tasks. To make this process fair for the team leaders, each one of them should be responsible for the same number of employees. Moreover, every employee, who is not a team leader, has to be under the responsibility of exactly one team leader, and no team leader is responsible for another team leader.

Given the number of employees n, find in how many ways Fafa could choose the number of team leaders l in such a way that it is possible to divide employees between them evenly.

Input

The input consists of a single line containing a positive integer n (2 ≤ n ≤ 105) — the number of employees in Fafa's company.

Output

Print a single integer representing the answer to the problem.

Examples

Input

2

Output

1

Input

10

Output

3

Note

In the second sample Fafa has 3 ways:

  * choose only 1 employee as a team leader with 9 employees under his responsibility.
  * choose 2 employees as team leaders with 4 employees under the responsibility of each of them.
  * choose 5 employees as team leaders with 1 employee under the responsibility of each of them.

```python
n = int(input())
count = 1
for i in range(2,(n//2)+1):
    if (n-i)%i ==0:
        count+=1
print(count)

```


988_E. Divisibility by 25

You are given an integer n from 1 to 10^{18} without leading zeroes.

In one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes. In other words, after each move the number you have cannot contain any leading zeroes.

What is the minimum number of moves you have to make to obtain a number that is divisible by 25? Print -1 if it is impossible to obtain a number that is divisible by 25.

Input

The first line contains an integer n (1 ≤ n ≤ 10^{18}). It is guaranteed that the first (left) digit of the number n is not a zero.

Output

If it is impossible to obtain a number that is divisible by 25, print -1. Otherwise print the minimum number of moves required to obtain such number.

Note that you can swap only adjacent digits in the given number.

Examples

Input

5071

Output

4

Input

705

Output

1

Input

1241367

Output

-1

Note

In the first example one of the possible sequences of moves is 5071 → 5701 → 7501 → 7510 → 7150.

```python
def idx(s, c, start = 0):
    try:
        return s[::-1].index(c, start)
    except:
        return -1

def main():
    s = input()
    zero_cnt = 0
    while zero_cnt < len(s) - 1 and s[zero_cnt + 1] == '0':
        zero_cnt += 1

    i01 = idx(s, '0')
    i02 = idx(s, '0', i01 + 1)
    i2 = idx(s, '2')
    i5 = idx(s, '5')
    i7 = idx(s, '7')

    r = 666
    if i01 != -1 and i02 != -1:
        r = min(r, i01 + (i02 - 1))
    if i2 != -1 and i5 != -1:
        r = min(r, i2 + i5 - int(i2 > i5) + int((i2 == len(s) - 1 or i5 == len(s) - 1) and zero_cnt))
    if i5 != -1 and i01 != -1:
        # if there are more than 2 0s this one would never be the final answer
        r = min(r, i5 + i01 - int(i5 > i01))
    if i7 != -1 and i5 != -1:
        # 1 and 3 --> 3
        r = min(r, i7 + i5 - int(i7 > i5) + int((i7 == len(s) - 1 or i5 == len(s) - 1) and zero_cnt))

    print(r if r != 666 else -1)

if __name__ == '__main__':
    main()

```


p02597 AtCoder Beginner Contest 174 - Alter Altar

An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; `R` stands for red and `W` stands for white.

You can do the following two kinds of operations any number of times in any order:

* Choose two stones (not necessarily adjacent) and swap them.
* Choose one stone and change its color (from red to white and vice versa).

According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Constraints

* 2 \leq N \leq 200000
* c_i is `R` or `W`.

Input

Input is given from Standard Input in the following format:

N
c_{1}c_{2}...c_{N}

Output

Print an integer representing the minimum number of operations needed.

Examples

Input

4
WWRR

Output

2

Input

2
RR

Output

0

Input

8
WRWWRWRR

Output

3

```python
N = int(input())
S = input()

r = S.count('R')
ans = r - S[:r].count('R')
print(ans)
```


p02728 AtCoder Beginner Contest 160 - Distributing Integers

We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. For each k=1, ..., N, solve the problem below:

* Consider writing a number on each vertex in the tree in the following manner:
* First, write 1 on Vertex k.
* Then, for each of the numbers 2, ..., N in this order, write the number on the vertex chosen as follows:
* Choose a vertex that still does not have a number written on it and is adjacent to a vertex with a number already written on it. If there are multiple such vertices, choose one of them at random.
* Find the number of ways in which we can write the numbers on the vertices, modulo (10^9+7).

Constraints

* 2 \leq N \leq 2 \times 10^5
* 1 \leq a_i,b_i \leq N
* The given graph is a tree.

Input

Input is given from Standard Input in the following format:

N
a_1 b_1
:
a_{N-1} b_{N-1}

Output

For each k=1, 2, ..., N in this order, print a line containing the answer to the problem.

Examples

Input

3
1 2
1 3

Output

2
1
1

Input

2
1 2

Output

1
1

Input

5
1 2
2 3
3 4
3 5

Output

2
8
12
3
3

Input

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

Output

40
280
840
120
120
504
72
72


p02860 AtCoder Beginner Contest 145 - Echo

Given are a positive integer N and a string S of length N consisting of lowercase English letters.

Determine whether the string is a concatenation of two copies of some string. That is, determine whether there is a string T such that S = T + T.

Constraints

* 1 \leq N \leq 100
* S consists of lowercase English letters.
* |S| = N

Input

Input is given from Standard Input in the following format:

N
S

Output

If S is a concatenation of two copies of some string, print `Yes`; otherwise, print `No`.

Examples

Input

6
abcabc

Output

Yes

Input

6
abcadc

Output

No

Input

1
z

Output

No

```python
N=int(input());S=input()
print('Yes') if S[:N//2] == S[N//2:] else print('No')
```


p02995 AtCoder Beginner Contest 131 - Anti-Division

You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Constraints

* 1\leq A\leq B\leq 10^{18}
* 1\leq C,D\leq 10^9
* All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C D

Output

Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Examples

Input

4 9 2 3

Output

2

Input

10 40 6 8

Output

23

Input

314159265358979323 846264338327950288 419716939 937510582

Output

532105071133627368

```python
import fractions
a,b,c,d=map(int,input().split())
a-=1
e=c*d//fractions.gcd(c,d)
print(b-a-b//c+a//c-b//d+a//d+b//e-a//e)
```


p03136 AtCoder Beginner Contest 117 - Polygon

Determine if an N-sided polygon (not necessarily convex) with sides of length L_1, L_2, ..., L_N can be drawn in a two-dimensional plane.

You can use the following theorem:

Theorem: an N-sided polygon satisfying the condition can be drawn if and only if the longest side is strictly shorter than the sum of the lengths of the other N-1 sides.

Constraints

* All values in input are integers.
* 3 \leq N \leq 10
* 1 \leq L_i \leq 100

Input

Input is given from Standard Input in the following format:

N
L_1 L_2 ... L_N

Output

If an N-sided polygon satisfying the condition can be drawn, print `Yes`; otherwise, print `No`.

Examples

Input

4
3 8 5 1

Output

Yes

Input

4
3 8 4 1

Output

No

Input

10
1 8 10 5 8 12 34 100 11 3

Output

No

```python
input()
a, *b = sorted(map(int, input().split()), reverse=True)
print('Yes' if a < sum(b) else 'No')
```


p03281 AtCoder Beginner Contest 106 - 105

The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?

Constraints

* N is an integer between 1 and 200 (inclusive).

Input

Input is given from Standard Input in the following format:

N

Output

Print the count.

Examples

Input

105

Output

1

Input

7

Output

0

```python
import bisect

n = int(input())
print(bisect.bisect([105, 135, 165, 189, 195], n))

```