A - Automatic Map Generator

Time Limit: 2 sec / Memory Limit: 256 MB

Problem

As is known to all, Okinawa is comprised of various islands. Cat Snuke wants to draw a simple map to include some of these islands. However, since the size of the paper is limited, Snuke will not be able to draw the map in details.

Therefore, Cat Snuke divides the paper into grids, which have H horizontal rows and W vertical columns. For each block of the grids, it will be filled with either a . that represents the sea or a # that represents the land.

Each island consists of blocks of land. For two blocks that represent land, we say that they belong to the same island, only if they had coincident edges or vertexes, or they were connected by other blocks that have coincident edges or vertexes. Otherwise, we say these two blocks belong to different islands.

Suppose that there is only sea beyond Snuke’s map. Also, please note that the blocks of land that is surrounded by sea that is surrounded by an island belong to another island (rather than the outer island).

Cat Snuke needs to follow the rules above to draw exactly K islands on the paper. Please decide whether Snuke is able to draw. If your answer was yes, please find a solution.


Input

Inputs will be given by standard input in following format

H W K
  • At the first line, H (1 ≦ H ≦ 100)W (1 ≦ W ≦ 100)K (1 ≦ K ≦ 10,000) will be given divided by spaces.

Output

Output IMPOSSIBLE if it is impossible to draw exactly K islands. Otherwise, output H lines where the i_{th} line has W letters, and the j_{th} letter from the left side of the i_{th} line must be the letter that Cat Snuke draws on her paper.

If there are multiple possible solutions, it is allowed to output any of them.

Print a newline at the end of output.


Input Example 1

6 7 4

Output Example 1

#.#####
..#...#
#.#.#.#
#.#...#
#..####
.#..###

There are four islands. Although the land block at the 3rd row from the top and the 5th column from the left is surrounded by an outer island, they are separated because that there is sea between them and they share no edges nor vertices.


Input Example 2

2 4 3

Output Example 2

IMPOSSIBLE

The paper is too small to draw a map that satisfies the conditions.


Input Example 3

20 50 10

Output Example 3

..................................................
...........................................#......
..........................................#.......
..................................................
..........................................#.......
..............................................#...
.....................................##..#....##..
.........................................##..###..
..........................#...............#####...
..........................................####....
.........................................###......
......##...............#..............#.#.........
.......##.............................##..........
........#.............................###.........
.....................................##...........
.............................#.......##...........
.............................#..#.................
...........................#....#.................
..................................................
..................................................
B - Beware of the Sogginess!

Time Limit: 2 sec / Memory Limit: 512 MB

Problem

Hence Wolf Sothe likes eating Okinawa Soba (a kind of famous food in Okinawa, which is made of noodles and soup), he comes to an Okinawa Soba restaurant today. There are N different kinds of Okinawa Soba. At the beginning, the i_{th} kind of Okinawa Soba consists of a_i grams of noodles and b_i grams of soup.

Noodles will absorb soup after being purchased. Specifically, for the i_{th} kind of Okinawa Soba, if we had waited for t (t is a real number such that t≧0) seconds after the purchase, the weight of the noodles will be min( a_i + t , a_i + b_i ) grams, the weight of soup will be max( b_i − t , 0 ) grams. The waiting time for each kind of Okinawa Soba is independent.

Wolf Sothe will choose a few kinds of Okinawa Soba among the N kinds to buy. For each kind of Okinawa Soba, there is only 1 item available.

Wolf Sothe wants to eat X or more than X grams of noodles and Y or more than Y grams of soup in total. Find the best solution that only needs the minimum amount of items of Okinawa Soba.

Please note that it costs no time for Wolf Sothe for eating Okinawa Soba, thus while Wolf Sothe is eating there is no absorption. In the other words, noodles will not absorb soup while Wolf Sothe is eating.


Input

Inputs will be given by standard input in following format.

N X Y
a_1 b_1
:
a_N b_N
  • At the first line, integer N(1≦N≦50), X(1≦X≦10,000), Y(1≦Y≦10,000) will be given divided by spaces.
  • From the second line there are N additional lines, for each line a_i (1≦ a_i ≦10,000), b_i (1≦ b_i ≦10,000) will be given divided by spaces.

Output

Please output the number of the minimum amount of items of Okinawa Soba that needs to be purchased to let Wolf Sothe to eat X or more than X grams of noodles and Y or more than Y grams of soup.

If there is no solution that meets Wolf Sothe’s need, output -1.

Print a newline at the end of output.


Input Example 1

3 9 7
3 4
8 1
4 5

Output Example 1

2

Purchase the 1st and the 3rd kind of Okinawa Soba. For the 1st kind of Okinawa Soba, wait 2 second before eating. For the 3rd kind of Okinawa Soba, eat it as soon as it is purchased. Thus, it is possible to eat (3 + 2) + (4 + 0) = 9 grams of noodles and (4 − 2) + (5 − 0) = 7 grams of soup.


Input Example 2

5 20 24
8 1
4 6
10 3
10 2
5 10

Output Example 2

-1

Because there is less than 24 grams of soup in total, it is impossible to meet Wolf Sothe’s need even if all kinds of Okinawa Soba were purchased. Thus, output -1.


Input Example 3

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

Output Example 3

3
C - Cat versus Wolf

Time Limit: 2 sec / Memory Limit: 256 MB

Problem

Cat Snuke and Wolf Sothe are going to play a kind of game to celebrate the new year. There are N designed levels of blocks, on the top of the blocks there is a Daruma doll (a kind of Japanese traditional ornament). 2 players will keep removing blocks one by one alternately and keep the Daruma on the top.

The following figure shows an example of blocks, the placement of the odd-numbered level (from the bottom) blocks, and the placement of the even-numbered level (from the bottom) blocks.

sample

Here is an example of blocks (the figure on the left), the plan view of the placement of the odd-numbered level (from the bottom) blocks (the figure in the middle), and the plan view of the placement of the even-numbered level (from the bottom) blocks (the figure on the right).

Cat Snuke starts first, then they repeat removing one block each time from the remaining blocks in turn (alternately). However, it is not allowed for a player to remove a block if removing this block will cause unstable placement of the rest blocks. Any other blocks are allowed to be removed. If there are only blocks that are not allowed to be removed, the player who is in turn loses the game.

Unstable Placement is defined as follows: among the N level blocks there are 1 or more levels that have no block or only have 1 block on the end of either side on that level.

The status of an ongoing game will be given. Because Cat Snuke starts first, if there are even number blocks that have been removed, then the next turn is Cat Snuke’s. Otherwise, if there are odd number blocks that have been removed, the next turn is Wolf Sothe’s. Please decide which player will finally win if both of them play as best as they can.


Input

Inputs will be given by standard input in following format.

N
c_{1, 1, 1}c_{1, 1, 2}c_{1, 1, 3}
c_{1, 2, 1}c_{1, 2, 2}c_{1, 2, 3}
c_{1, 3, 1}c_{1, 3, 2}c_{1, 3, 3}
c_{2, 1, 1}c_{2, 1, 2}c_{2, 1, 3}
c_{2, 2, 1}c_{2, 2, 2}c_{2, 2, 3}
c_{2, 3, 1}c_{2, 3, 2}c_{2, 3, 3}
:
c_{N, 1, 1}c_{N, 1, 2}c_{N, 1, 3}
c_{N, 2, 1}c_{N, 2, 2}c_{N, 2, 3}
c_{N, 3, 1}c_{N, 3, 2}c_{N, 3, 3}
  • At the first line, an integer N(1≦N≦50,000) will be given.
  • From the second line there are 3N additional lines to give the status of an ongoing game. In these lines, from the 3i -2_{th} line to the 3i_{th} line there is information about the i_{th} level (from the bottom) blocks. At the 3(i-1) + j(1≦i≦N,1≦j≦3) line, c_{i, j, 1}, c_{i, j, 2}, c_{i, j, 3} will be given without any separator. These are either # or .. If c_{i, j, k} is #, it means that the block that in the corresponding position (please refer to the figure below) of i_{th} level (from the bottom) has NOT been removed. If c_{i, j, k} is ., it means that the block that in the corresponding position of i_{th} level (from the bottom) has been removed.
  • If i(1≦i≦N) is odd, for k = 1, 2, 3, c_{i, 1, k} = c_{i, 2, k} = c_{i, 3, k}.
  • If i(1≦i≦N) is even, for j = 1, 2, 3, c_{i, j, 1} = c_{i, j, 2} = c_{i, j, 3}
sample

The figure on the left shows the plan view of the corresponding placement of the odd-numbered level (from the bottom) blocks. The figure on the right shows the plan view of the corresponding placement of the even-numbered level (from the bottom) blocks.

There is no input that has already been an unstable placement .

Output

Please decide which player will finally win if both of them play as best as they can. If Cat Snuke wins, output Snuke in one line. Otherwise, if Wolf Sothe wins, output Sothe in one line.

Print a newline at the end of output.


Input Example 1

2
#.#
#.#
#.#
###
###
...

Output Example 1

Snuke

If cat Snuke removes the block on the end of side that has not been removed on the 2nd level (from the bottom), Wolf Sothe will have no block that can be removed.


Input Example 2

4
###
###
###
...
###
###
##.
##.
##.
###
###
###

Output Example 2

Sothe

Input Example 3

4
###
###
###
...
###
###
.#.
.#.
.#.
###
###
###

Output Example 3

Sothe

Please note that there are 3 blocks that have been removed by the input status, thus the next turn is Wolf Sothe’s.

D - Dictionary for Shiritori Game

Time Limit: 2 sec / Memory Limit: 256 MB

Problem

In a country where N different kinds characters are being used, there is a dictionary that contains M entries, each entry is a definition for a word. All the kinds of characters are listed as character 1, character 2, ..., character N. The i_{th} entry (as a word) of this dictionary begins with the letter p_i, and ends with the letter q_i.

Cat Snuke and Wolf Sothe will use this dictionary to play a game called Shiritori . (Please note that Shiritori in this game is different from a normal Shiritori game.)

  • The first move will be made by Cat Snuke, then two players will move alternately.
  • For the first move, the player in turn has to say a word the begins with character 1. If there are no any words that begin with character 1, the player in turn loses.
  • For the rest moves, the player of that turn has to say any word that begins with the last character of the word being said in the previous move from the dictionary. If there is not any appropriate word, the player in turn loses.
  • Any word can be said any number of times .

There should be some dictionaries that two players can not change the result of the game even if they tried their best. For these dictionaries, in this case, we want to find out if the first player or the second player will win, or even the game will never halt.

All the words in the dictionary will be given. We can assume that the two players will try their best. Please decide if the first player (Cat Snuke) or the second player (Wolf Sothe) will win, or even the game will never halt.


Input

Inputs will be given by standard input in following format.

N M
p_1 q_1
p_2 q_2
:
p_M q_M
  • At the first line, an integer N(1≦N≦100,000)M(1≦M≦200,000) will be given.
  • From the second line there are M lines that represent all the words in this dictionary. For the i_{th} line, integer p_i(1≦p_i≦N) and q_i(1≦q_i≦N) will be given divided by space.

It is possible that there are different words that begin with the same character and end with the same character. In other words, it is possible that p_i = p_j and q_i = q_j even when i \neq j.

Output

Assume that two players will try their best. Output Snuke if the first player wins, output Sothe if the second player wins in one line. If the game will never halt, output Draw in one line.

Print a newline at the end of output.


Input Example 1

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

Output Example 1

Sothe
  • For the first move, Cat Snuke has to say the first word.
  • For the second move, if Wolf Sothe said the 6th word, Cat Snuke will have no appropriate word to say for the next move, thus Wolf Sothe wins.

Input Example 2

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

Output Example 2

Draw

Input Example 3

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

Output Example 3

Snuke

Input Example 4

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

Output Example 4

Sothe

Please note that for the first move it is possible that there is no appropriate word that can be said.

E - Enormous XOR Rectangle

Time Limit: 2 sec / Memory Limit: 256 MB

Problem

Cat Snuke received a paper that has been divided into grids having H horizontal rows and W vertical columns as a birthday gift. For each block a number is written as shown in the figure below.

sample

More precisely, the number, which is written in the i_{th} row from the top of the rectangle paper and j_{th} column from the left of the rectangle paper, is (i - 1) \times W + (j - 1).

Cat Snuke wants to choose a partial rectangle from this rectangle paper, then find the value obtained by bitwise xor for all the numbers in this partial rectangle. Specifically, Cat Snuke will choose integers t,b(1≦t≦b≦H),l,r(1≦l≦r≦W), then calculate the value obtained by bitwise xor for all the numbers in the area from the top of the rectangle between the t_{th} row and the b_{th} row (including both ends), form the left of the rectangle between the l_{th} column and r_{th} column (including both ends).

Cat Snuke is able to choose any values for t,b,l,r. Please calculate the maximum value that can be obtained.


Input

Inputs will be given by standard input in following format

H W
  • At the first line, H(1≦H≦1,000,000,000), W(1≦W≦1,000,000,000) , will be given divided by space.

Output

Please calculate the maximum value that can be obtained, then output it in one line.

Print a newline at the end of output.


Input Example 1

4 5

Output Example 1

31
sample

For example, the obtained value of t=3,b=4,l=3,r=5 is 12 xor 13 xor 14 xor 17 xor 18 xor 19 = 31, this is the maximum value that can be obtained in this case.


Input Example 2

314159265 358979323

Output Example 2

144115188075855871
F - Falconry

Time Limit: 8 sec / Memory Limit: 512 MB

Problem

Falconry is a kind of hunting using a bird of prey. One day, three falconers (the person who do falconry) decided to carry out the next competition.

There are N checkpoints on a two-dimensional plane, the i_{th} checkpoint exists on the point of which the coordinate is (x_i,y_i). The three falconers exist on the points of which the coordinates are (x_a, y_a), (x_b, y_b), (x_c, y_c). Each one of them has one bird. In the beginning, every bird stays with its owner, thus the coordinate of it is the same as that of its owner.

When the competition begins, 3 birds will start to move. The purpose of this competition is to let all the checkpoints to be passed through by one bird at least, and to minimize the sum of the moving distance of the three birds. In this case, distance refers to the Euclidean Distance. The distance between two points (x_s, y_s) and (x_t, y_t) is \sqrt{(x_s - x_t)^2 + (y_s - y_t)^2}.

Checkpoints can be passed through in any order. For a bird, it is allowed to pass no checkpoint or pass all the checkpoints. Also, the same checkpoint can be passed through more than once. In addition, suppose that each bird can choose the optimal way to move.

The coordinates of all the checkpoints and the three falconers will be given. Please find the minimum value of the sum of the moving distance of three birds.


Input

Inputs will be given by standard input in following format

N
x_1 y_1
x_2 y_2
:
x_N y_N
x_a y_a
x_b y_b
x_c y_c
  • For the first line, N (1 ≦ N ≦ 18) will be given.
  • From the second line, there are N additional lines, for each line the coordinate of a checkpoint will be given. For the i_{th} line, integer x_i(-10,000≦x_i≦10,000), y_i(-10,000≦y_i≦10,000) will be given divided by a space.
  • For the (N+2)_{th} line, x_a(-10,000≦x_a≦10,000)y_a(-10,000≦y_a≦10,000) will be given divided by a space.
  • For the (N+3)_{th} line, x_b(-10,000≦x_b≦10,000)y_b(-10,000≦y_b≦10,000) will be given divided by a space.
  • For the (N+4)_{th} line x_c(-10,000≦x_c≦10,000)y_c(-10,000≦y_c≦10,000) will be given divided by a space.

In addition, all the coordinates are different from each other.

In other words, if i \neq j then (x_i, y_i) \neq (x_j, y_j).

Also, for each i (1 ≦ i ≦ N), (x_i, y_i) \neq (x_a, y_a), (x_i, y_i) \neq (x_b, y_b) and (x_i, y_i) \neq (x_c, y_c) will hold. Furthermore, (x_a, y_a) \neq (x_b, y_b), (x_b, y_b) \neq (x_c, y_c) and (x_c, y_c) \neq (x_a, y_a) will hold.

Output

Output the minimum value of the sum of the moving distance of three birds when all the checkpoints have been passed through by at least one bird in one line.

The output is acceptable if absolute error or relative error is 10^{-6} or less.

Print a newline at the end of output.


Input Example 1

3
1 1
102 98
197 -197
0 0
100 100
200 -200

Output Example 1

8.485281374239
  • If the bird that starts from (x_a, y_a) passes through the first checkpoint, the moving distance will be \sqrt{2}.
  • If the bird that starts from (x_b, y_b) passes through the second checkpoint, the moving distance will be 2\sqrt{2}.
  • If the bird that starts from (x_c, y_c) passes through the third checkpoint, the moving distance will be 3\sqrt{2}.

Hence, by moving 6\sqrt{2}all the checkpoints will be passed through at least once.


Input Example 2

3
1 3
2 1
0 -2
0 0
-500 0
0 1000

Output Example 2

7.841619252964

If the bird that starts from (x_a, y_a) passes the third checkpoint, then passes the second checkpoint, then passes the first checkpoint, the moving distance in total will be 2 + \sqrt{13} + \sqrt{5}.


Input Example 3

6
3 7
1 10
-2 -5
-3 4
0 2
6 6
-3 9
0 4
1 1

Output Example 3

22.585258012904
G - Gorgeous Vases

Time Limit: 8 sec / Memory Limit: 256 MB

Problem

Cat Snuke has a pair of vases. One is noted as vase 1, the other one is noted as vase 2. At first, the vase 1 contains A blue flowers and B red flowers. In addition, the number of blue flowers is larger than or equal to the number of red flower, in other words, A ≧ B. In addition, vase 2 is empty, contains neither blue flowers nor red flowers.

By the way, Cat Snuke doesn’t like mixing a specific number of red flowers with a specific number of blue flowers. Such combination is called as a Dirty Placement . There are N different Dirty Placements in total, the i_{th} Dirty Placement is the combination of precisely p_i blue flowers and q_i red flowers.

Cat Snuke wants to move all the flowers that are in vase 1 to vase 2 one by one. However, Cat Snuke has to follow the following rules.

  • For vase 1 and vase 2, the number of the blue flowers should always be larger than or equal to that of the red flowers.
  • For vase 1 and vase 2, the combination of the number of the blue flowers and the number of the red flowers must not be any Dirty Placement (at anytime).

In accordance with the above rules, answer the number of all the possible methods that can move all the flower in vase 1 to vase 2, modulo 1,000,000,007. Please note that all the flowers with the same color are indistinguishable (identical).


Input

Inputs will be given by standard input in following format

A B N
p_1 q_1
p_2 q_2
:
p_N q_N
  • For the first line, A、B(1≦B≦A≦100,000)N(0≦N≦20) will be given divided by spaces.
  • From the second line there are N additional lines to give all the Dirty Placements. For the i_{th} line, integer p_i(1≦p_i≦A)q_i(1≦q_i≦B,q_i≦p_i) will be given divided by spaces.

Output

Please output the remainder when the number of all the possible methods that can move all the flower in vase 1 to vase 2, modulo 1,000,000,007.

Print a newline at the end of output.


Input Example 1

3 1 0

Output Example 1

2

As shown below, there are two possible ways to move flowers.

  • The moving order is as, blue, blue, red, blue.
  • The moving order is as, blue, red, blue, blue.

Input Example 2

7 5 3
4 2
6 1
5 4

Output Example 2

0

Input Example 3

98765 43210 5
314 159
26535 8979
3238 46
26433 8327
950 288

Output Example 3

763788532
H - Happy 2015

Time Limit: 2 sec / Memory Limit: 512 MB

Problem

As the end of year 2015 approaching, the downtown area has been lighted up to celebrate year’s end. At this year, Cat Snuke also enjoys making a light-up device for the downtown area.

The downtown can be regarded as a one-dimensional line of numbers. There are N lights that have been installed on this number line. When the power of the i_{th} light is on, it can illuminate an interval of [l_i, r_i] (inclusive).

Although Cat Snuke can switch on the N lights independently as his wish, he wants to try different illumination combinations as many as possible. Then, if we had tried all the combinations of 2^N illumination combinations, we want to know how many different illumination combinations there are, of which each combination is a set of points that for each point in it can be illuminated by one or more lights.

When we tried all the 2^N illumination combination, please answer the number of the different illumination combinations, modulo 1,000,000,007.


Input

Inputs will be given by standard input in following format

N
l_1 r_1
l_2 r_2
:
l_N r_N
  • At the first line, an integer N(1≦N≦2,000) will be given divided by a space.
  • From the second line there are N additional lines to give the information about the illumination range. For the i_{th} line, integer l_i, r_i(0≦l_i<r_i≦1,000,000,000) will be given divided by a space.

Output

Please answer the number of the different illumination combinations, modulo 1,000,000,007.

Print a newline at the end of output.


Input Example 1

4
0 1
1 2
0 2
1 3

Output Example 1

6

There are 16 different ways of attaching the light power, but there are only 6 different illumination combinations, \{φ\}, \{[0, 1]\}, \{[1, 2]\}, \{[0, 2]\}, \{[1, 3]\}, \{[0, 3]\}.


Input Example 2

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

Output Example 2

240

Input Example 3

14
0 1
2 3
4 5
6 7
8 9
10 11
12 13
14 15
16 17
18 19
0 3
4 7
8 13
14 19

Output Example 3

2025
I - Implementation Addict

Time Limit: 2 sec / Memory Limit: 256 MB

Problem

Wolf Sothe loves implementing online judge problems, he wants to solve as many problems as possible. However, if he keeps solving problems every day without a rest, day by day the number of problems that can be solved in a day will reduce.

So, sometimes Wolf Sothe takes a day off. On that day, Wolf Sothe will not solve any problem, then for the next day and later Wolf Sothe will be able to solve problems.

The number of problems that Wolf Sothe can solve in a day is as follows:

  • If that day is a working day, we define the number of days that Wolf Sothe has kept solving problems as k (not including that day). Then Wolf Sothe can solve max(0, A − k \times B) problems during that day.
  • If that day is a rest day, during that day no problem will be solved.

Wolf Sothe wants to solve problems for N days. Let the N days be as a sequence from the 1st day to the N_{th} day. Suppose that Wolf Sothe doesn't solve problems before the 1st day.

In addition, we known in advance that there are some decided rest days.

A list of all the decided rest days will be given. For any other day, you can mark it as a rest day or a working day. Please find the maximum value of the number of problems that can be solved during N days.


Input

Inputs will be given by standard input in following format

N A B M
t_1
t_2
:
t_M
  • For the first line, integer N(1≦N≦1,000,000,000), A(1≦A≦1,000,000,000), B(1≦B≦1,000,000,000), M(0≦M≦100,000) will be given divided by spaces. M represents the number of the decided rest days.
  • From the second line there are M additional lines to give the information about decided rest days. For the i_{th} line, an integer t_i(1≦t_i≦N) that represents the t_i th decided rest day will be given. Please note that if i < j, then t_i<t_j

Output

Please output the maximum value of the number of problems that can be solved during N days in one line.

Print a newline at the end of output.


Input Example 1

5 6 2 0

Output Example 1

20

Suppose that Wolf Sothe rest on the 3rd day and solve problems on the remaining 4 days.

  • For the 1st day, Wolf Sothe has kept solving problems for 0 day. Thus, max(0, 6 − 0 \times 2) = 6 problems.
  • For the 2nd day, Wolf Sothe has kept solving problems for 1 day. Thus, max(0,6 − 1 \times 2) = 4 problems.
  • For the 3rd day, Wolf Sothe rests. Thus, 0 problem.
  • For the 4th day, Wolf Sothe has kept solving problems for 0 day. Thus, max(0, 6 − 0 \times 2) = 6 problems.
  • For the 5th day, Wolf Sothe has kept solving problems for 1 day. Thus, max(0, 6 − 1 \times 2) = 4 problems.

In conclusion, 6 + 4 + 0 + 6 + 4 = 20 will be solved in total.


Input Example 2

6 4 3 1
3

Output Example 2

13

Input Example 3

12 10 3 3
2
7
10

Output Example 3

71
J - Jungle

Time Limit: 8 sec / Memory Limit: 256 MB

Problem

Wolf Sothe owns a long land in the jungle. In this linear land, N trees grow at regular intervals. The size of the i_{th} tree from one end is given as t_i.

Inside the jungle it is dark because trees obstruct sunlight. In order to let sunlight shine into the jungle, Wolf Sothe considers cutting some of the N trees (or cutting no one). More specifically, trees will be cut with the following rules.

  • Up to M trees can be cut (no more than M).
  • Considering the impact on the surrounding ecosystem, it is not allowed to cut two or more trees in arbitrary K consecutive trees. More precisely, there is not i(1≦i≦N-K+1) such that 2 or more trees are cut in the i_{th}, (i + 1)_{th}, ......, (i + K-1)_{th} trees from one end.
  • If Wolf Sothe cuts the i_{th} tree from one end, the size of the tree t_i becomes 0.
  • We want the maximum value of the sum of sizes of K consecutive trees to be as small as possible. Namely, we want to minimize .

Since the size of the N trees and M, K have been given, when we make the optimal cutting choice for the trees, please obtain the minimum value of the maximum value of the sum of sizes of consecutive K trees.


Input

Inputs will be given by standard input in following format.

N M K
t_1
t_2
:
t_N
  • At the first line, integer N(1≦N≦100,000), M(1≦M≦N), K(1≦K≦N) will be given.
  • From the second line there are N additional lines to give information about sizes of trees. At the i_{th} line, integer t_i(1≦t_i≦1,000,000,000) will be given.

Output

Please print the minimum value of the maximum value of the sum of sizes of consecutive K trees, when we made the optimal cutting choice for the trees in a line.

Print a newline at the end of output.


Input Example 1

6 2 3
1
5
6
2
4
3

Output Example 1

7

If Wolf Sothe cuts the 3_{rd} and 6_{th} tree, the minimum value of the maximum value of the sum of sizes of consecutive 3 consecutive trees will be obtained when it is for the 2_{nd}, 3_{rd}, 4_{th} tree. The sum of sizes is 5+0+2=7.


Input Example 2

10 3 4
3
14
1
5
9
2
6
5
3
5

Output Example 2

17