2025 USP Try-outs
A. Yuyuan Market
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

In the bustling Yuyuan Market, young Li wants to buy jianzhi (traditional paper cuttings) from an artisan. The pieces are aligned in a row, each with a unique symbol, and Li can only purchase them in identical pairs following these rules:

  • If Li chooses a jianzhi at position $$$i$$$, he must immediately buy its pair at a position $$$j \gt i$$$.
  • After selecting a jianzhi, he cannot go back to buy an earlier one.

The price Li pays is the sum of the distances $$$j - i$$$ between all purchased pairs. Li wants to buy the maximum number of possible pairs in a single pass. Moreover, among all ways to achieve the maximum number of pairs, he wants to pay the minimum possible price. Help Li optimize his purchase.

Input

The first line contains an integer $$$N$$$ ($$$1 \leq N \leq 10^5$$$) — the number of symbols in the jianzhi row.

The following line contains $$$2N$$$ integers $$$A_i$$$ ($$$1 \leq A_i \leq N$$$) representing the symbols of the jianzhi in order. Each number between $$$1$$$ and $$$N$$$ appears exactly twice in the sequence.

Output

Print two space-separated integers: the maximum number of pairs Li can buy and the minimum possible price to buy that quantity.

Examples
Input
3
1 2 3 2 3 1
Output
1 2
Input
3
1 1 2 3 2 3
Output
2 3
Input
6
1 2 2 3 4 4 5 3 5 1 6 6
Output
4 5

B. The Search for Balance
time limit per test
1.5 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

Ying is a gaming fan and is developing a new RPG. In this game, each player starts with a character that has $$$0$$$ attack points and $$$0$$$ defense points. To customize their character, players can use power-ups.

The game will have $$$N$$$ power-ups, and each one can only be used once. Each power-up is defined by a pair of integers $$$(a, d)$$$, which modifies the attack and defense points. If a player with $$$A$$$ attack and $$$D$$$ defense chooses a power-up $$$(a, d)$$$, their character's new attributes will be $$$A+a$$$ attack and $$$D+d$$$ defense. Note that the values $$$a$$$ and $$$d$$$ can be negative, which means the final attack and defense attributes can also become negative.

The game developers say that a character is "balanced" if its final attack points, $$$A$$$, are in the interval $$$[A_1, A_2]$$$ and its final defense points, $$$D$$$, are in the interval $$$[D_1, D_2]$$$.

Ying wants to know in how many ways a player can obtain a balanced character. A "way" is defined by a distinct set of power-ups. Two sets are distinct if one contains a power-up that the other does not. The order in which the power-ups are applied does not matter.

Input

The first line contains an integer $$$N$$$ ($$$1 \leq N \leq 35$$$), the number of power-ups in the game. The next $$$N$$$ lines describe the power-ups. Each of these lines contains two integers $$$a$$$ and $$$d$$$ ($$$-10^9 \leq a, d \leq 10^9$$$). The last line contains four integers $$$A_1, D_1, A_2$$$ and $$$D_2$$$ ($$$-10^{12} \leq A_1 \leq A_2 \leq 10^{12}$$$ and $$$-10^{12} \leq D_1 \leq D_2 \leq 10^{12}$$$), which define the intervals for a character to be considered balanced.

Output

Print a single line containing an integer representing the number of distinct sets of power-ups that result in a balanced character.

Examples
Input
8
1 1
1 -1
-1 1
-1 -1
1 1
1 -1
-1 1
-1 -1
-1000 -1000 1000 1000
Output
256
Input
8
0 0
1 1
2 1
2 0
3 0
1 1
0 2
5 5
5 3 5 3
Output
2

C. Echoes of the Jade Library
time limit per test
4 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

After a mission between Shanghai and Tianjin, the spy Lian returns to his hidden base in the alleys of Shanghai. There, he receives a new assignment: to become the Guardian of the legendary Jade Library, concealed in the Longmen Valley.

The library holds $$$N$$$ scrolls, numbered from $$$1$$$ to $$$N$$$, each containing a string composed only of lowercase English letters. According to the court magicians, certain palindromic substrings hidden in these texts encode ancient instructions and magical secrets. Preserving the library means correctly identifying where and how many of these palindromes exist.

Lian must therefore answer $$$Q$$$ real-time queries. Each query defines an interval $$$[L, R]$$$ of scrolls and asks for the number of distinct palindromic substrings (of length $$$\geq 1$$$) that occur in at least one of the texts within that interval. Any incorrect response may trigger traps left by the library's ancient protectors.

These queries are made in real time and expect an immediate response.

Note: A palindrome is a sequence of letters that reads the same from left to right and from right to left. Examples: a, aa, aba, abba. Only palindromic substrings (i.e., contiguous segments) are considered.

Input

The first line contains two integers $$$N$$$ and $$$M$$$ ($$$1 \leq N \leq 10^5$$$, $$$1 \leq M \leq 2 \cdot 10^5$$$) — the number of scrolls and the number of magical queries.

The next $$$N$$$ lines contain the arcane texts $$$s_1, s_2, \dots, s_N$$$, each consisting of lowercase English letters a–z. No string is empty, and the total number of characters across all strings does not exceed $$$5 \cdot 10^5$$$.

Each of the following $$$M$$$ lines contains two integers $$$L$$$ and $$$R$$$ ($$$1 \leq L \leq R \leq N$$$), representing the range of scrolls the magi wish to examine.

Output

For each query, output a single line with the number of distinct palindromic substrings found in at least one of the strings from index $$$L$$$ to $$$R$$$, inclusive.

Remember: Since the queries are online, you must flush the output after each line (e.g., fflush(stdout) in C or cout.flush() in C++).

Example
Input
3 3
abc
aaa
aba
1 2
2 3
1 3
Output
5
5
6

D. The Seals of Shanghai
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

After his last mission, Lian, the spy, returns to Shanghai. In an ancient stone chest, he finds a sequence of numbers that protect an ancestral secret: the Seals of Shanghai.

To unlock the seals, Lian must follow a precise ritual. Initially, he chooses a fixed integer $$$M$$$ such that $$$1 \lt M \leq 10^9$$$. Then, he must perform a sequence of magical rounds. In each round, he chooses an integer $$$x$$$ with which he unlocks all the seals whose number $$$A_i$$$ satisfies $$$A_i \bmod M = x$$$.

Each round requires concentration and energy. Therefore, Lian wants to minimize the number of rounds to unlock all the seals. Additionally, he wants to know how many distinct values of $$$M$$$ allow him to achieve this minimum number of rounds.

Input

The first line contains an integer $$$N$$$ ($$$1 \leq N \leq 10^5$$$), the number of seals.

The second line contains $$$N$$$ integers $$$A_1, A_2, \dots, A_N$$$ ($$$1 \leq A_i \leq 10^9$$$), representing the numbers of the seals.

Output

Print two integers: the minimum number of rounds required to unlock all the seals and the number of distinct values of $$$M$$$ with which it is possible to achieve this minimum number of rounds.

Examples
Input
5
13 23 33 53 103
Output
1 3
Input
2
2 4
Output
1 1

E. Complexity of Quicksort
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

In the city of Shanghai, the young programmer Kai seeks the wisdom of his mentor, Master Wei. One day, Master Wei presented Kai with a challenge on algorithm analysis, a fundamental lesson to achieve mastery.

"Little Kai," said the Master, "a programmer's strength lies not in writing code, but in understanding it deeply. Observe this scroll. It describes the 'Wise Partitioning Method', a way of sorting sequences."

On the scroll was an algorithm, which coincidentally looks very much like an implementation of Quicksort in Python:

cmps = 0
def quicksort(A, l, r):
if r <= l:
return
# The Master chooses the middle element as a guide
m = (l + r) // 2
k = pivot(A, l, r, A[m])
quicksort(A, l, k - 1)
quicksort(A, k + 1, r)


def pivot(A, l, r, x):
# Each element is compared with the guide x
for y in A[l : r + 1]:
cmps += 1
if y < x:
A[l] = y
l += 1
elif y > x:
A[r] = y
r -= 1
A[l] = x
return l

The function $$$pivot(A,l,r,x)$$$ rearranges the values in the segment $$$A[l..r]$$$ as follows: values smaller than $$$x$$$ are moved to $$$A[l..k-1]$$$ (in the same relative order), values larger than $$$x$$$ are moved to $$$A[k+1..r]$$$ (in the reverse relative order), and the guide value $$$x$$$ is placed at $$$A[k]$$$.

Master Wei then handed Kai a sequence of numbers representing the energy levels of a sleeping dragon. "A hasty apprentice would try to run this code to get the answer. But a true master can predict the cost without executing a single line."

"Your task, Kai," the Master concluded, "is to tell me the exact cost of the method for this sequence. Calculate the final value of the cost variable $$$cmps$$$ that would be obtained at the end of the $$$quicksort(A, 0, n-1)$$$ call. This is your lesson for today."

Input

The first line contains an integer $$$N$$$ ($$$1 \leq N \leq 2 \cdot 10^5$$$), the size of the array. The second line contains $$$N$$$ integers $$$A[0], \ldots, A[N-1]$$$ ($$$|A[i]| \leq 10^9$$$), the elements of the array. All elements of $$$A$$$ are distinct.

Output

A single integer, the total number of comparisons that Master Wei's method will perform.

Examples
Input
1
5
Output
0
Input
10
9 8 7 6 5 4 3 2 1 0
Output
25
Input
10
1 3 5 7 9 8 6 4 2 0
Output
54
Input
5
5 45 2 12 21
Output
11

F. Chinese Innovation
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

China has been unified, ending the Warring States Period and ushering in an era of innovations, such as teleportation. To connect the empire, the emperor has installed teleporters in various cities.

The empire consists of $$$n$$$ cities connected by $$$m$$$ roads, such that it is always possible to travel between any two cities using only these roads. Each road allows for bidirectional traffic and has a fixed travel cost.

Additionally, there are $$$k$$$ different types of teleporters. Two cities can connect instantly via teleportation only if both have a teleporter of the same type. However, the cost of using a teleporter depends on the city of origin, as each mayor sets the fee to be paid for leaving the city using the magical device. That is, even for the same type of teleporter, the usage cost can vary between cities.

The Japanese traveler Mori, upon arriving in China, does not understand its complex structure and is unable to determine the best routes for travel. He wishes to travel from city $$$1$$$ to city $$$n$$$. What is the minimum possible cost to make this journey, considering both the available roads and teleporters?

Input

The first line of input contains three integers: $$$n$$$, $$$m$$$, and $$$k$$$, representing the number of cities, the number of roads, and the number of distinct teleporter types, respectively. The values adhere to the constraints $$$2 \leq n \leq 2 \cdot 10^5$$$, $$$n - 1 \leq m \leq \min\left(\frac{n(n - 1)}{2}, 2 \cdot 10^5\right)$$$, and $$$0 \leq k \leq 2 \cdot 10^5$$$.

Each of the next $$$m$$$ lines describes an existing road between two cities. Each line contains three integers $$$u$$$, $$$v$$$, and $$$c$$$, indicating that there is a bidirectional road connecting cities $$$u$$$ and $$$v$$$ with a cost of $$$c$$$, where $$$1 \leq u, v \leq n$$$ and $$$1 \leq c \leq 10^9$$$. It is guaranteed that there is at least one path between any two cities using only roads, that there are no two distinct roads connecting the same pair of cities, and that no road connects a city to itself.

Next, for each of the $$$n$$$ cities, there is a line containing an integer $$$t$$$, indicating the number of teleporters available in that city, with $$$0 \leq t \leq 2 \cdot 10^5$$$. This line is followed by $$$t$$$ pairs of integers $$$(u_i, c_i)$$$, representing that a teleporter of type $$$u_i$$$ is available in the city, and the cost to use it from this city is $$$c_i$$$, where $$$1 \leq u_i \leq k$$$ and $$$1 \leq c_i \leq 10^9$$$. A single teleporter type may not exist in any city, exist in only one, or exist in multiple cities.

It is guaranteed that the same teleporter type does not appear twice in the same city and that the total sum of available teleporters across all cities does not exceed $$$\min(nk, 2 \cdot 10^5)$$$.

Output

Print a single integer representing the minimum cost to travel between cities $$$1$$$ and $$$n$$$.

Examples
Input
3 2 1
1 2 5
2 3 3
1
1 4
0
1
1 3
Output
4
Input
6 7 2
1 2 1
2 3 3
1 3 5
2 4 2
3 5 2
5 6 7
4 6 5
1
1 7
2
1 5
2 1
0
0
0
1
1 100
Output
6

G. Incompatible Pairs
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

In the heart of the Forbidden City, the Emperor has ordered the performance of the great "Celestial Dance" to ensure the harmony of the empire. A sequence of dancers, representing the primordial forces, is positioned in a line. Yang dancers (represented by '(') and Yin dancers (represented by ')') form a sequence.

For the grand finale of the dance, each Yang dancer must be paired with a Yin dancer who is positioned further down the line. The beauty of this ancestral dance lies in its complexity: the paths of the pairs can cross, symbolizing the intertwined threads of fate. Therefore, multiple choreographies are possible, with different ways to pair Yin and Yang dancers. It is guaranteed that there always exists a valid choreography.

However, the imperial astrologers have warned that certain pairs are "incompatible". An incompatible pair is a specific Yang dancer and Yin dancer who, if paired together, make it impossible for all the other dancers to find a partner, thus breaking the cosmic harmony of the ritual.

For example, in the formation (()), any pair that is formed (such as the 1st with the 3rd, or the 1st with the 4th) always allows the remaining dancers to form a valid pair. Therefore, for (()), there are no incompatible pairs. However, in the formation ()(), if we try to pair the 1st dancer (Yang) with the 4th dancer (Yin), the remaining dancers are the 2nd (Yin) and the 3rd (Yang). Since the remaining Yin dancer comes before the Yang dancer, they cannot form a pair. Thus, the pair (1, 4) is incompatible.

Your task, as the Imperial Master Choreographer, is to analyze the initial formation of the dancers and determine the total number of incompatible pairs, so they can be avoided in the ceremony.

Input

The first line contains a single integer $$$N$$$ ($$$1 \leq N \leq 10^6$$$), the number of dancers in the sequence.

The second line contains a sequence of $$$N$$$ characters, representing the dancers. It is guaranteed that there always exists a valid choreography.

Output

Print a single integer: the number of incompatible pairs in the given sequence.

Examples
Input
4
(())
Output
0
Input
4
()()
Output
1
Input
8
(()())()
Output
3

H. The Wisdom of Master Wei
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

In the ancient and majestic city of Shanghai, future stage of the ICPC World Finals, a young programmer named Kai dreams of achieving the mastery of his mentor, the legendary Master Wei.

One day, while debugging complex code at the Wild Goose Pagoda, Kai asked, "Master, your experience is as vast as the Yellow River. When will my programming journey be exactly half of yours?"

Master Wei, with an enigmatic smile, replied: "Little grasshopper, experience is measured by years of practice. I started programming in year $$$W$$$, and you started in year $$$K$$$. There will come an exact year when my years of practice will be double yours. Find that year, and you will find the clarity you seek."

Help Kai solve his master's riddle.

Input

The input consists of a single line with two integers $$$W$$$ and $$$K$$$ ($$$0\leq W \lt K \leq 10^9$$$), representing the year Master Wei started programming and the year Kai started, respectively.

Output

Print a single number: the year when the master's experience will be exactly double Kai's.

Examples
Input
1975 1995
Output
2015
Input
1989 2007
Output
2025
Input
0 1000000000
Output
2000000000

I. Bath
time limit per test
5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

In the turbulent times of the Warring States, the renowned warrior Na Tan and his companions traveled to participate in a martial arts tournament. They are all staying in the same room, and before the competition, Na Tan decides to go to the baths to clear his mind. However, upon finishing, he realizes that he made a mistake: he forgot to grab the towel!

Fortunately, the room is empty at the moment, but his companions may return at any moment. Na Tan, determined not to be seen in an embarrassing situation, needs to leave the bath, grab the towel, and return as quickly as possible, without being caught.

The room can be represented by a simple polygon (that is, a polygon whose sides do not cross), and Na Tan's path must occur entirely within this polygon. The door of the bath is located at one of the vertices of the polygon, while the towel is at some point inside the polygon, but not necessarily at a vertex. Na Tan moves at a constant speed of 1 unit per second.

Given this, what is the minimum time required for Na Tan to fetch the towel and return to the bath?

Input

The first line consists of an integer $$$n$$$ ($$$3 \leq n \leq 500$$$) indicating the number of points in the polygon.

The next $$$n$$$ lines contain two integers $$$x$$$ and $$$y$$$ ($$$-10^6 \leq x, y \leq 10^6$$$) that represent the vertices of the polygon. It is guaranteed that the polygon is simple, the vertices are given in counterclockwise order, and that the door of the bath is located at the first vertex of the polygon.

The last line contains two integers $$$x$$$ and $$$y$$$ ($$$-10^6 \leq x, y \leq 10^6$$$) that represent the point of the towel.

It is guaranteed that any three points, including the towel, are not collinear.

Output

Print the minimum time in seconds for Na Tan to go and return starting from the first point and going to the towel. The answer will be considered correct if the absolute or relative difference is less than $$$10^{-4}$$$.

Examples
Input
4
0 0
10 0
10 10
0 10
8 9
Output
24.083189158
Input
6
0 20
0 0
40 0
40 50
20 40
20 20
30 32
Output
71.240998704
Input
8
0 80
0 0
50 0
50 60
30 60
30 20
20 20
20 80
40 33
Output
179.293545340

J. The Messenger's Disguise
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

In the Warring States period of ancient China, espionage was the key to survival. An agent named Lian has received a critical mission: to deliver a message from his base in Shanghai (represented on the map by vertex $$$S$$$) to an allied general in the walled city of Tianjin (vertex $$$T$$$).

Lian's spymaster warned him: "Our enemies are cunning. They know all the roads and expect an urgent messenger to use the fastest possible path. If you arrive from Shanghai to Tianjin in record time, your identity will be revealed."

The order was clear: calculate the shortest path length, $$$D$$$, but do not use it. Instead, to pass as a common merchant who might have taken a detour, you must follow a path of length exactly $$$D+1$$$.

To have flexibility and escape routes, Lian needs to know how many travel options meet this condition. Your task is to help him count the number of distinct paths from Shanghai to Tianjin with a length of precisely one more than the minimum.

Input

The first line contains four integers $$$N, M, S,$$$ and $$$T$$$ ($$$1 \leq N, M \leq 10^6, 1 \leq S \neq T \leq N$$$), representing the number of cities and roads in China, the starting vertex ($$$S$$$, Shanghai), and the destination vertex ($$$T$$$, Tianjin). The next $$$M$$$ lines each contain two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i \neq v_i \leq N$$$), indicating that there is a bidirectional road between cities $$$u_i$$$ and $$$v_i$$$.

Output

Print a single integer: the number of distinct paths from Shanghai to Tianjin with a length of one more than the minimum. As this number can be very large, print the result modulo $$$10^9+7$$$.

Examples
Input
5 6 1 3
1 2
2 3
1 4
4 2
2 5
5 3
Output
2
Input
3 5 1 2
1 2
1 3
1 3
2 3
2 3
Output
4
Input
2 1 1 2
1 2
Output
0
Note

A path from Shanghai to Tianjin is guaranteed to exist. Multiple roads may exist between the same pair of cities.

K. Cake Hater
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Agent Wang is a very reserved person and prefers not to share his birthday. However, the MaratonUSP trio managed to find out when his birthday is!

To celebrate, the trio decided to bake a cake from scratch. The responsibility for the recipe fell to Antonio, the trio's cook — but there's a problem: Antonio does not like cakes.

After some investigation, Antonio discovered which cake ingredients he doesn't like and decided simply not to use them in the preparation, even if it compromises the result. The cake recipe is divided into several steps, and each step uses a list of ingredients. The cake will become bad if, in any step, more than one third of the ingredients of of the step are missing.

What is the first step in which the cake becomes bad, if any?

Input

The first line contains an integer $$$N$$$ ($$$1 \leq N \leq 10^3$$$), the number of steps.

The second line contains two integers $$$A$$$ and $$$B$$$ ($$$1 \leq B \leq A \leq 3 \cdot 10^5$$$), the total number of ingredients and the number of ingredients Antonio does not like.

The third line contains $$$B$$$ distinct integers between $$$1$$$ and $$$A$$$, indicating the ingredients Antonio does not like.

Each of the next $$$N$$$ lines represents a step, containing an integer $$$M$$$ ($$$1 \leq M \leq A$$$), the number of ingredients in that step, followed by $$$M$$$ distinct integers between $$$1$$$ and $$$A$$$ representing the ingredients of the step.

The sum of the number of ingredients in all steps is at most $$$3 \cdot 10^5$$$.

Output

Print a single integer, the index of the first step in which the cake becomes bad, or $$$-1$$$ if no step makes the cake become bad.

Example
Input
3
6 3
1 3 5
4 1 2 4 6
3 2 3 4
6 6 5 4 3 2 1
Output
3
Note

In the first test case, there are $$$3$$$ steps and $$$6$$$ ingredients, and Antonio does not like ingredients $$$1$$$, $$$3$$$, and $$$5$$$.

In the first step, out of $$$4$$$ ingredients, Antonio does not like ingredient $$$1$$$. Thus, the cake does not become bad.

In the second step, out of $$$3$$$ ingredients, Antonio does not like ingredient $$$3$$$. Antonio removes exactly one third of the ingredients, so the cake does not become bad.

In the third and last step, out of $$$6$$$ ingredients, Antonio does not like half of them. Thus, the cake becomes bad.

L. Game of Life
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Given a board of size $$$N \times N$$$, where each cell can be alive, dead, or uninhabitable, simulate the evolution of the board for $$$K$$$ iterations based on the following rules:

$$$\bullet$$$ A live cell ($$$\texttt{'1'}$$$) dies if it has an odd number of live neighbors.

$$$\bullet$$$ A dead cell ($$$\texttt{'0'}$$$) becomes alive if it has an odd number of live neighbors.

$$$\bullet$$$ An uninhabitable cell ($$$\texttt{'#'}$$$) never changes state and is never considered alive.

Each cell has up to 8 neighbors (horizontal, vertical, and diagonal).

Your goal is to determine the final state of the board after $$$K$$$ iterations.

Input

The first line contains two integers $$$N$$$ and $$$K$$$ ($$$2 \leq N \leq 8$$$, $$$1 \leq K \leq 10^9$$$) — the size of the board and the number of iterations.

The next $$$N$$$ lines contain $$$N$$$ characters each, describing the initial state of the board.

Let $$$S_{i,j}$$$ be the character in the $$$i$$$-th row and $$$j$$$-th column:

$$$\bullet$$$ $$$S_{i,j} = \texttt{'1'}$$$ if the cell is alive,

$$$\bullet$$$ $$$S_{i,j} = \texttt{'0'}$$$ if the cell is dead,

$$$\bullet$$$ $$$S_{i,j} = \texttt{'#'}$$$ if the cell is uninhabitable.

Output

Print $$$N$$$ lines, each containing $$$N$$$ characters, representing the final state of the board after $$$K$$$ iterations.

Examples
Input
4 1
#101
0000
1100
1100
Output
#101
1111
0000
0000
Input
2 1000000000
01
##
Output
00
##

M. Nomad
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Due to the high rent prices in Shanghai, Kai, of the Yafa clan, has become homeless. Fortunately, he has already found a new place! However, he will need to wait for exactly $$$D$$$ days until he can move in.

In the meantime, he has evaluated his options and found $$$N$$$ places, represented by indices from $$$1$$$ to $$$N$$$, where he can spend the night. Each place, however, has a tolerance limit: after a certain number of consecutive days, Kai will be kicked out.

For each of the $$$N$$$ places, an integer $$$d_i$$$ has been determined, representing the maximum number of consecutive days he can sleep at the $$$i$$$-th location before being expelled. It is possible that $$$d_i = 0$$$; in this case, it means Kai cannot spend even a single night at that location.

Your goal is to create an accommodation plan for Kai to get through the $$$D$$$ days by alternating between these places, without exceeding the consecutive day limit of any of them. Kai can return to a place later, as long as each new consecutive stay respects the limit.

Write a program that determines if it is possible to create such a plan. If so, produce a sequence of places (indices from $$$1$$$ to $$$N$$$), indicating where Kai should sleep on each of the $$$D$$$ days. Otherwise, print $$$-1$$$.

Input

The first line contains two integers $$$N$$$ and $$$D$$$ ($$$1 \leq N, D \leq 10^5$$$), representing the number of available places and the number of days Kai needs to wait, respectively.

The second line contains $$$N$$$ integers $$$d_1, d_2, \ldots, d_N$$$ ($$$0 \leq d_i \leq 10^5$$$), where $$$d_i$$$ is the tolerance limit of the $$$i$$$-th place.

Output

Print $$$D$$$ integers, the sequence of places representing the accommodation plan. If it is not possible to create a plan, print $$$-1$$$.

Examples
Input
3 5
0 1 3
Output
2 3 3 3 2
Input
10 1
0 0 0 0 0 0 0 0 0 0
Output
-1