In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painted white. Your task is to repaint at most one cell the other color so that the picture has a 2 × 2 square, completely consisting of cells of the same color. If the initial picture already has such a square, the person should just say so and the test will be completed. Your task is to write a program that determines whether it is possible to pass the test. You cannot pass the test if either repainting any cell or no action doesn't result in a 2 × 2 square, consisting of cells of the same color.

NoteIn the first test sample it is enough to repaint the first cell in the second row. After such repainting the required 2 × 2 square is on the intersection of the 1-st and 2-nd row with the 1-st and 2-nd column.

Four lines contain four characters each: the j-th character of the i-th line equals "." if the cell in the i-th row and the j-th column of the square is painted white, and "#", if the cell is black.

Print "YES" (without the quotes), if the test can be passed and "NO" (without the quotes) otherwise.

Output: YES

Output: NO

Output: YES

Output: NO

Output: NO

Output: NO

Output: NO

Output: NO

Output: NO

Output: NO

Output: NO

Output: NO

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES

Output: YES


Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer pi (1 ≤ pi ≤ n).Little penguin Polo loves walking around this village. The walk looks like that. First he stands by a house number x. Then he goes to the house whose number is written on the plaque of house x (that is, to house px), then he goes to the house whose number is written on the plaque of house px (that is, to house ppx), and so on.We know that:  When the penguin starts walking from any house indexed from 1 to k, inclusive, he can walk to house number 1.  When the penguin starts walking from any house indexed from k + 1 to n, inclusive, he definitely cannot walk to house number 1.  When the penguin starts walking from house number 1, he can get back to house number 1 after some non-zero number of walks from a house to a house. You need to find the number of ways you may write the numbers on the houses' plaques so as to fulfill the three above described conditions. Print the remainder after dividing this number by 1000000007 (109 + 7).

The single line contains two space-separated integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ min(8, n)) — the number of the houses and the number k from the statement.

In a single line print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

Input: 5 2

Output: 54

Input: 7 4

Output: 1728

Input: 8 5

Output: 16875

Input: 8 1

Output: 823543

Input: 10 7

Output: 3176523

Input: 12 8

Output: 536870912

Input: 50 2

Output: 628702797

Input: 100 8

Output: 331030906

Input: 1000 8

Output: 339760446

Input: 999 7

Output: 490075342

Input: 685 7

Output: 840866481

Input: 975 8

Output: 531455228

Input: 475 5

Output: 449471303

Input: 227 6

Output: 407444135

Input: 876 8

Output: 703293724

Input: 1000 1

Output: 760074701

Input: 1000 2

Output: 675678679

Input: 1000 3

Output: 330155123

Input: 1000 4

Output: 660270610

Input: 1000 5

Output: 583047503

Input: 1000 6

Output: 834332109

Input: 657 3

Output: 771999480

Input: 137 5

Output: 160909830

Input: 8 8

Output: 2097152

Input: 9 8

Output: 2097152

Input: 1 1

Output: 1

Input: 2 1

Output: 1

Input: 2 2

Output: 2

Input: 3 3

Output: 9

Input: 473 4

Output: 145141007


Yaroslav, Andrey and Roman love playing cubes. Sometimes they get together and play cubes for hours and hours! Today they got together again and they are playing cubes. Yaroslav took unit cubes and composed them into an a × a × a cube, Andrey made a b × b × b cube and Roman made a c × c × c cube. After that the game was finished and the guys left. But later, Vitaly entered the room. He saw the cubes and wanted to make a cube as well. But what size should the cube be? Of course it should be a large cube with the side of length a + b + c. Besides, Vitaly decided to decompose the cubes built by Yaroslav, Andrey and Roman and compose his own large cube out of them. However, it turned out that the unit cubes he got from destroying the three cubes just weren't enough to make a large cube. We know that Vitaly was short of exactly n cubes. Vitaly got upset, demolished everything and left. As he was leaving, he met Petya and told him that there had been three cubes in the room and that he needed another n unit cubes to make his own large cube.Petya entered the room and saw the messily scattered cubes. He wanted to make it neat and orderly again. But he only knows that there had been three cubes, made of small unit cubes and that Vitaly needed n more unit cubes to make a large one! Help Petya understand, how many ways of sizes a, b, c are there to restore Yaroslav's, Andrey's and Roman's cubes.

The single line of the input contains integer n (1 ≤ n ≤ 1014). We know that all numbers a, b, c are positive integers. 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.

In the single line print the required number of ways. If it turns out that there isn't a single way of suitable sizes of a, b, c, print 0.


Shaass thinks a kitchen with all white floor tiles is so boring. His kitchen floor is made of n·m square tiles forming a n × m rectangle. Therefore he's decided to color some of the tiles in black so that the floor looks like a checkerboard, which is no two side-adjacent tiles should have the same color.Shaass wants to use a painter robot to color the tiles. In the beginning the robot is standing in a border tile (xs, ys) facing a diagonal direction (i.e. upper-left, upper-right, down-left or down-right). As the robot walks in the kitchen he paints every tile he passes even if it's painted before. Painting each tile consumes one unit of black paint. If at any moment the robot hits a wall of the kitchen he changes his direction according the reflection rules. Note that a tile gets painted when the robot enters the tile from another tile, in other words changing direction in the same tile doesn't lead to any painting. The first tile the robot is standing on, is also painted.The robot stops painting the first moment the floor is checkered. Given the dimensions of the kitchen and the position of the robot, find out the amount of paint the robot consumes before it stops painting the floor.Let's consider an examples depicted below.  If the robot starts at tile number 1 (the tile (1, 1)) of the left grid heading to down-right it'll pass tiles 1354236 and consumes 7 units of black paint on his way until he stops at tile number 6. But if it starts at tile number 1 in the right grid heading to down-right it will get stuck in a loop painting tiles 1, 2, and 3.

The first line of the input contains two integers n and m, (2 ≤ n, m ≤ 105). The second line contains two integers xs and ys (1 ≤ xs ≤ n, 1 ≤ ys ≤ m) and the direction robot is facing initially. Direction is one of the strings: "UL" (upper-left direction), "UR" (upper-right), "DL" (down-left) or "DR" (down-right). Note, that record (xs, ys) denotes the tile that is located at the xs-th row from the top and at the ys-th column from the left of the kitchen. It's guaranteed that the starting position will be a border tile (a tile with less than four side-adjacent tiles).

Print the amount of paint the robot consumes to obtain a checkered kitchen floor. Or print -1 if it never happens. Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.

Input:
3 4
1 1 DR

Output: 7

Input:
3 4
3 3 DR

Output: 11

Input:
3 3
1 1 DR

Output: -1

Input:
3 3
1 2 DL

Output: 4

Input:
2 5
2 3 DR

Output: 7

Input:
2 3
2 3 DL

Output: 3

Input:
3 2
3 1 DL

Output: 3

Input:
3 4
1 1 DL

Output: 7

Input:
2 2
2 2 UR

Output: 2

Input:
547 180
96 1 UR

Output: 135504

Input:
657 213
549 1 UL

Output: -1

Input:
76 153
1 74 UL

Output: 11626

Input:
80304 59860
27585 59860 UR

Output: 5862949615

Input:
15954 45613
15954 45142 UR

Output: -1

Input:
66972 6779
1 5667 UL

Output: 778336963

Input:
2622 82284
2540 1 UL

Output: 216075159

Input:
48517 68036
48517 31953 DR

Output: 5618298349

Input:
32132 32312
1 2 DR

Output: 1551509598

Input:
100000 99999
100000 1 DR

Output: 9999700003

Input:
100000 99999
1 99999 DR

Output: 9999700003

Input:
84166 43542
54265 43542 DR

Output: 7214569537

Input:
35185 19049
31553 1 DR

Output: -1

Input:
70834 99677
1 23598 DL

Output: 13418107690

Input:
16730 65966
12102 65966 DL

Output: 1171670331

Input:
52379 51718
52379 807 UR

Output: 3155460233

Input:
93151 27224
1 15542 UR

Output: 3301236001

Input:
39047 2730
16937 1 UR

Output: 195090753

Input:
74696 83359
74696 64325 UL

Output: 11273566961

Input:
99999 99999
99999 99999 UR

Output: -1

Input:
99999 99999
99999 99998 UR

Output: -1

Input:
2 2
2 2 UR

Output: 2

Input:
2 2
1 2 UR

Output: 2

Input:
9684 98536
9684 80875 DL

Output: 1908112615

Input:
45333 74042
1 43244 DL

Output: 4559265901

Input:
91228 54671
1674 1 DL

Output: 9870668501

Input:
32001 30178
32001 28119 UR

Output: 1850848001

Input:
77896 5684
18467 5684 UR

Output: 575273042

Input:
13546 91435
1002 1 UL

Output: -1

Input:
64435 19953
5705 19953 DR

Output: -1

Input:
5208 582
979 1 DR

Output: 3617888

Input:
51103 66871
1 57465 DL

Output: -1

Input:
86752 42377
72660 42377 DL

Output: 4398289793

Input:
22402 28129
22402 24340 DL

Output: -1

Input:
73420 3635
1 2940 UR

Output: 332220976

Input:
9070 74017
4901 1 UR

Output: -1

Input:
54965 59770
54965 14083 UL

Output: 4668092521

Input:
95737 26059
30821 26059 UL

Output: -1

Input:
41633 11811
5694 1 UL

Output: 491662111

Input:
93183 58113
1 39140 DR

Output: 5414953246

Input:
28833 43865
22853 1 DL

Output: -1

Input:
74728 19372
74728 18073 DL

Output: -1

Input:
10378 85660
7751 85660 DL

Output: -1

Input:
61396 66289
50382 1 UR

Output: -1

Input:
97045 41795
1 27338 UR

Output: 4055829600

Input:
32695 27547
17514 27547 UL

Output: -1

Input:
78590 3053
78590 239 UL

Output: -1

Input:
19363 78559
1 55927 UL

Output: -1

Input:
65258 49971
20976 1 DR

Output: 4857383821

Input:
7593 1397
1 1155 DL

Output: -1

Input:
43242 82025
19055 1 DL

Output: 6371542297

Input:
89137 57531
89137 3552 DL

Output: 5127940102

Input:
29910 43284
15956 43284 UR

Output: 2517815394

Input:
75805 18790
46466 1 UR

Output: -1

Input:
11455 85078
11455 39494 UL

Output: -1

Input:
47104 65707
27797 65707 UL

Output: -1

Input:
98122 41213
19832 1 UL

Output: 4804907081

Input:
33772 26966
1 6679 DR

Output: 1005599068

Input:
79667 2472
62739 2472 DR

Output: 301313741


One day Greg and his friends were walking in the forest. Overall there were n people walking, including Greg. Soon he found himself in front of a river. The guys immediately decided to get across the river. Luckily, there was a boat by the river bank, just where the guys were standing. We know that the boat can hold people with the total weight of at most k kilograms.Greg immediately took a piece of paper and listed there the weights of all people in his group (including himself). It turned out that each person weights either 50 or 100 kilograms. Now Greg wants to know what minimum number of times the boat needs to cross the river to transport the whole group to the other bank. The boat needs at least one person to navigate it from one bank to the other. As the boat crosses the river, it can have any non-zero number of passengers as long as their total weight doesn't exceed k.Also Greg is wondering, how many ways there are to transport everybody to the other side in the minimum number of boat rides. Two ways are considered distinct if during some ride they have distinct sets of people on the boat.Help Greg with this problem.

NoteIn the first test Greg walks alone and consequently, he needs only one ride across the river.In the second test you should follow the plan:  transport two 50 kg. people;  transport one 50 kg. person back;  transport one 100 kg. person;  transport one 50 kg. person back;  transport two 50 kg. people. That totals to 5 rides. Depending on which person to choose at step 2, we can get two distinct ways.

The first line contains two integers n, k (1 ≤ n ≤ 50, 1 ≤ k ≤ 5000) — the number of people, including Greg, and the boat's weight limit. The next line contains n integers — the people's weights. A person's weight is either 50 kilos or 100 kilos. You can consider Greg and his friends indexed in some way.

In the first line print an integer — the minimum number of rides. If transporting everyone to the other bank is impossible, print an integer -1. In the second line print the remainder after dividing the number of ways to transport the people in the minimum number of rides by number 1000000007 (109 + 7). If transporting everyone to the other bank is impossible, print integer 0.

Input:
1 50
50

Output:
1
1

Input:
3 100
50 50 100

Output:
5
2

Input:
2 50
50 50

Output:
-1
0

Input:
5 258
100 100 50 50 50

Output:
3
72

Input:
8 191
50 100 50 100 50 100 100 50

Output:
11
19318272

Input:
3 121
100 100 50

Output:
-1
0

Input:
8 271
100 50 100 50 50 50 100 50

Output:
5
78090

Input:
2 233
50 100

Output:
1
1

Input:
2 153
100 50

Output:
1
1

Input:
5 257
50 50 50 50 50

Output:
1
1

Input:
49 290
100 100 100 100 100 100 100 100 50 100 50 100 100 100 50 50 100 50 50 100 100 100 100 100 100 50 100 100 50 100 50 50 100 100 100 50 50 50 50 50 100 100 100 50 100 50 100 50 50

Output:
39
99624366

Input:
29 129
50 50 50 100 100 100 50 100 50 50 50 100 50 100 100 100 50 100 100 100 50 50 50 50 50 50 50 50 50

Output:
77
37050209

Input:
32 121
100 100 100 100 100 50 100 100 50 100 50 100 50 100 50 100 50 50 50 100 100 50 100 100 100 100 50 100 50 100 100 50

Output:
101
245361086

Input:
3 118
100 100 100

Output:
-1
0

Input:
10 4894
100 50 50 50 100 50 50 100 50 100

Output:
1
1

Input:
36 250
50 100 100 50 100 100 100 50 50 100 50 50 50 50 50 50 100 50 100 100 100 100 100 100 100 50 50 100 50 50 100 100 100 100 100 50

Output:
27
77447096

Input:
31 291
50 100 100 50 100 100 100 50 100 100 100 100 50 50 50 100 100 100 50 100 100 50 50 50 50 100 100 50 50 100 100

Output:
23
393964729

Input:
31 161
100 50 50 50 50 100 50 100 50 100 100 50 50 100 100 50 100 50 50 100 50 100 100 50 50 100 50 50 100 50 100

Output:
43
670669365

Input:
5 123
50 100 50 50 50

Output:
9
4536

Input:
43 293
50 50 100 100 50 100 100 50 100 100 50 100 50 100 50 50 50 50 50 100 100 100 50 50 100 50 100 100 100 50 100 100 100 50 50 50 100 50 100 100 50 100 50

Output:
31
658920847

Input:
23 100
50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50

Output:
43
689584957

Input:
41 218
50 50 100 50 100 100 50 100 100 50 50 100 50 50 50 50 100 50 100 50 50 50 100 50 50 50 50 100 100 100 100 100 100 50 100 50 100 100 100 50 50

Output:
39
298372053

Input:
11 4668
50 100 100 100 50 100 50 50 100 100 100

Output:
1
1

Input:
43 178
50 50 100 100 100 50 100 100 50 100 100 100 50 100 50 100 50 50 100 100 50 100 100 50 50 50 100 50 50 50 100 50 100 100 100 50 100 50 50 50 50 100 100

Output:
63
503334985

Input:
33 226
50 50 50 50 50 100 100 100 100 50 100 50 100 50 100 50 100 100 50 50 50 100 100 50 50 100 50 100 50 100 50 50 50

Output:
31
370884215

Input:
1 2994
100

Output:
1
1

Input:
1 204
50

Output:
1
1

Input:
33 123
50 100 100 100 50 100 50 50 50 50 50 100 100 50 100 50 100 50 50 50 50 50 50 50 100 100 50 50 100 100 100 100 100

Output:
93
337243149

Input:
34 2964
50 50 50 50 50 100 50 100 50 100 100 50 50 50 50 50 50 100 100 100 50 50 100 100 50 50 50 100 50 100 100 50 100 50

Output:
1
1

Input:
27 200
50 50 50 50 100 100 50 50 100 100 100 50 100 50 100 50 50 100 100 100 50 100 100 50 50 50 100

Output:
25
271877303

Input:
31 197
50 100 50 50 100 50 100 100 100 50 50 100 50 100 50 50 50 50 100 100 50 50 100 50 50 50 50 50 100 50 100

Output:
41
24368657

Input:
28 183
50 100 100 50 100 50 100 100 50 100 50 100 100 100 50 50 100 50 50 50 100 50 100 50 50 100 100 100

Output:
41
844409785

Input:
48 204
100 100 100 50 50 50 50 100 100 50 100 100 50 100 50 50 50 100 100 100 50 100 50 50 50 100 50 100 50 100 100 100 50 50 100 100 100 50 100 50 50 50 50 50 100 50 50 50

Output:
45
538567333

Input:
5 188
50 50 50 50 50

Output:
3
30

Input:
29 108
100 50 100 100 100 100 100 50 50 100 100 100 50 100 50 50 100 50 100 50 50 100 100 50 50 50 100 100 50

Output:
87
417423429

Input:
50 125
50 50 50 100 100 50 100 100 50 50 100 100 100 100 100 100 50 50 100 50 100 100 50 50 50 100 100 50 100 100 100 100 100 100 100 50 50 50 100 50 50 50 50 100 100 100 100 100 50 50

Output:
153
971933773

Input:
50 2263
50 100 50 100 50 100 100 100 50 50 50 100 100 100 100 100 100 50 50 100 50 100 50 50 100 50 50 100 100 50 100 100 100 50 50 50 100 50 100 50 50 50 50 50 100 100 50 50 100 50

Output:
3
211048352

Input:
50 110
50 100 100 50 50 50 50 50 50 50 100 100 50 100 50 50 50 50 100 50 100 100 100 100 50 100 100 100 100 50 50 50 50 50 100 100 50 100 50 100 100 50 50 100 50 100 50 50 100 100

Output:
143
105841088

Input:
50 185
100 50 50 50 50 50 100 50 100 50 100 100 50 50 100 100 100 50 50 100 50 100 50 50 100 100 100 100 100 50 50 100 100 100 50 100 50 100 50 50 100 50 100 50 50 100 50 50 100 100

Output:
73
930170107

Input:
50 207
50 100 100 100 100 50 100 100 100 50 100 100 100 50 100 100 50 100 50 100 50 100 100 100 50 100 50 50 100 50 100 100 50 100 100 100 100 50 100 100 100 100 50 50 50 100 100 50 100 100

Output:
55
833060250

Input:
3 49
50 50 50

Output:
-1
0

Input:
3 50
50 50 50

Output:
-1
0

Input:
3 99
100 50 50

Output:
-1
0

Input:
4 100
100 100 100 50

Output:
-1
0


Greg has a pad. The pad's screen is an n × m rectangle, each cell can be either black or white. We'll consider the pad rows to be numbered with integers from 1 to n from top to bottom. Similarly, the pad's columns are numbered with integers from 1 to m from left to right.Greg thinks that the pad's screen displays a cave if the following conditions hold:  There is a segment [l, r] (1 ≤ l ≤ r ≤ n), such that each of the rows l, l + 1, ..., r has exactly two black cells and all other rows have only white cells.  There is a row number t (l ≤ t ≤ r), such that for all pairs of rows with numbers i and j (l ≤ i ≤ j ≤ t) the set of columns between the black cells in row i (with the columns where is these black cells) is the subset of the set of columns between the black cells in row j (with the columns where is these black cells). Similarly, for all pairs of rows with numbers i and j (t ≤ i ≤ j ≤ r) the set of columns between the black cells in row j (with the columns where is these black cells) is the subset of the set of columns between the black cells in row i (with the columns where is these black cells). Greg wondered, how many ways there are to paint a cave on his pad. Two ways can be considered distinct if there is a cell that has distinct colors on the two pictures.Help Greg.

The first line contains two integers n, m — the pad's screen size (1 ≤ n, m ≤ 2000).

In the single line print the remainder after dividing the answer to the problem by 1000000007 (109 + 7).

Input: 1 1

Output: 0

Input: 4 4

Output: 485

Input: 3 5

Output: 451

Input: 5 3

Output: 185

Input: 5 5

Output: 6751

Input: 7 8

Output: 5898445

Input: 9 8

Output: 72459477

Input: 10 10

Output: 33937168

Input: 100 100

Output: 631601096

Input: 100 110

Output: 257801865

Input: 100 200

Output: 852627600

Input: 1 1000

Output: 499500

Input: 1000 1

Output: 0

Input: 1000 3

Output: 1333331

Input: 3 1000

Output: 977762109

Input: 10 1000

Output: 298998986

Input: 10 500

Output: 659024105

Input: 250 250

Output: 331145635

Input: 500 1000

Output: 169229174

Input: 1000 500

Output: 900561408

Input: 1000 1000

Output: 950299696

Input: 1 2

Output: 1

Input: 2000 2000

Output: 627008355

Input: 1500 2000

Output: 294292096

Input: 2000 1777

Output: 20685302

Input: 1999 1994

Output: 785234759

Input: 1994 1995

Output: 854486105

Input: 1 2000

Output: 1999000

Input: 2000 1

Output: 0

Input: 2 2000

Output: 668322662

Input: 2000 2

Output: 2001000

Input: 3 1999

Output: 583178527

Input: 1998 4

Output: 542192517


Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.For example, let's say that Vitaly's favourite digits are 1 and 3, then number 12 isn't good and numbers 13 or 311 are. Also, number 111 is excellent and number 11 isn't. Now Vitaly is wondering, how many excellent numbers of length exactly n are there. As this number can be rather large, he asks you to count the remainder after dividing it by 1000000007 (109 + 7).A number's length is the number of digits in its decimal representation without leading zeroes.

The first line contains three integers: a, b, n (1 ≤ a < b ≤ 9, 1 ≤ n ≤ 106).

Print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

Input: 1 3 3

Output: 1

Input: 2 3 10

Output: 165

Input: 6 8 14215

Output: 651581472

Input: 4 9 104671

Output: 329390901

Input: 6 7 78755

Output: 0

Input: 1 8 265

Output: 461320265

Input: 3 9 37413

Output: 461358757

Input: 1 7 49055

Output: 461364774

Input: 3 4 11028

Output: 461668105

Input: 2 6 32377

Output: 887598327

Input: 3 5 80791

Output: 999993599

Input: 4 8 11857

Output: 999991923

Input: 1 3 10785

Output: 999952603

Input: 4 6 11808

Output: 999925731

Input: 1 2 11857

Output: 999991923

Input: 2 4 88193

Output: 999976846

Input: 1 4 37226

Output: 999970594

Input: 2 5 53049

Output: 259705254

Input: 3 6 1000000

Output: 786609214

Input: 7 9 999999

Output: 53911803

Input: 8 9 999999

Output: 447886447

Input: 3 8 1000000

Output: 0

Input: 2 8 999999

Output: 0

Input: 1 6 997695

Output: 0

Input: 1 5 997694

Output: 0

Input: 5 9 997693

Output: 0

Input: 5 8 997690

Output: 21735480

Input: 7 8 2

Output: 0

Input: 6 9 1

Output: 2

Input: 8 9 111111

Output: 900401372

Input: 8 9 1000000

Output: 573697309

Input: 1 2 1000000

Output: 786609214


Yaroslav calls an array of r integers a1, a2, ..., ar good, if it meets the following conditions: |a1 - a2| = 1, |a2 - a3| = 1, ..., |ar - 1 - ar| = 1, |ar - a1| = 1, at that . An array of integers b1, b2, ..., br is called great, if it meets the following conditions:  The elements in it do not decrease (bi ≤ bi + 1).  If the inequalities 1 ≤ r ≤ n and 1 ≤ bi ≤ m hold.  If we can rearrange its elements and get at least one and at most k distinct good arrays. Yaroslav has three integers n, m, k. He needs to count the number of distinct great arrays. Help Yaroslav! As the answer may be rather large, print the remainder after dividing it by 1000000007 (109 + 7).Two arrays are considered distinct if there is a position in which they have distinct numbers.

The single line contains three integers n, m, k (1 ≤ n, m, k ≤ 100).

In a single line print the remainder after dividing the answer to the problem by number 1000000007 (109 + 7).

Input: 1 1 1

Output: 0

Input: 3 3 3

Output: 2

Input: 5 5 5

Output: 11

Input: 4 5 5

Output: 11

Input: 3 5 6

Output: 4

Input: 6 6 6

Output: 30

Input: 10 10 10

Output: 230

Input: 10 15 15

Output: 385

Input: 15 15 10

Output: 1267

Input: 15 13 14

Output: 1111

Input: 15 15 15

Output: 1373

Input: 25 26 27

Output: 47801

Input: 27 28 29

Output: 87601

Input: 5 30 30

Output: 86

Input: 30 30 30

Output: 264119

Input: 50 50 50

Output: 42497527

Input: 45 45 43

Output: 10123550

Input: 100 100 100

Output: 329466984

Input: 100 99 98

Output: 892915548

Input: 98 98 100

Output: 357694362

Input: 75 75 75

Output: 685997068

Input: 80 90 100

Output: 819270165

Input: 15 15 100

Output: 1457

Input: 20 3 100

Output: 63

Input: 18 3 90

Output: 54

Input: 25 5 100

Output: 821

Input: 30 3 100

Output: 98

Input: 40 2 100

Output: 20


You are given a rectangle grid. That grid's size is n × m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates — a pair of integers (x, y) (0 ≤ x ≤ n, 0 ≤ y ≤ m).Your task is to find a maximum sub-rectangle on the grid (x1, y1, x2, y2) so that it contains the given point (x, y), and its length-width ratio is exactly (a, b). In other words the following conditions must hold: 0 ≤ x1 ≤ x ≤ x2 ≤ n, 0 ≤ y1 ≤ y ≤ y2 ≤ m, .The sides of this sub-rectangle should be parallel to the axes. And values x1, y1, x2, y2 should be integers.  If there are multiple solutions, find the rectangle which is closest to (x, y). Here "closest" means the Euclid distance between (x, y) and the center of the rectangle is as small as possible. If there are still multiple solutions, find the lexicographically minimum one. Here "lexicographically minimum" means that we should consider the sub-rectangle as sequence of integers (x1, y1, x2, y2), so we can choose the lexicographically minimum one.

The first line contains six integers n, m, x, y, a, b (1 ≤ n, m ≤ 109, 0 ≤ x ≤ n, 0 ≤ y ≤ m, 1 ≤ a ≤ n, 1 ≤ b ≤ m).

Print four integers x1, y1, x2, y2, which represent the founded sub-rectangle whose left-bottom point is (x1, y1) and right-up point is (x2, y2).

Input: 9 9 5 5 2 1

Output: 1 3 9 7

Input: 100 100 52 50 46 56

Output: 17 8 86 92

Input: 100 100 16 60 42 75

Output: 0 0 56 100

Input: 100 100 28 22 47 50

Output: 0 0 94 100

Input: 100 100 44 36 96 21

Output: 0 25 96 46

Input: 100 100 56 46 1 47

Output: 55 0 57 94

Input: 100 100 20 53 6 22

Output: 6 1 33 100

Input: 100 100 32 63 2 41

Output: 30 18 34 100

Input: 100 100 48 73 63 16

Output: 16 65 79 81

Input: 100 100 13 59 14 20

Output: 0 0 70 100

Input: 36830763 28058366 30827357 20792295 11047103 20670351

Output: 25303805 7388015 36350908 28058366

Input: 87453374 60940601 74141787 32143714 78082907 33553425

Output: 9370467 15367001 87453374 48920426

Input: 71265727 62692710 12444778 3479306 21442685 5463351

Output: 0 0 64328055 16390053

Input: 48445042 43730155 14655564 6244917 43454856 2866363

Output: 0 4811735 43454856 7678098

Input: 85759276 82316701 8242517 1957176 10225118 547026

Output: 0 0 81800944 4376208

Input: 64748258 21983760 9107246 2437546 11247507 8924750

Output: 0 0 22495014 17849500

Input: 6561833 24532010 2773123 457562 6225818 23724637

Output: 0 0 6225818 23724637

Input: 33417574 19362112 17938303 4013355 10231192 2596692

Output: 166200 0 33417574 8439249

Input: 98540143 28776614 12080542 1456439 96484500 3125739

Output: 0 0 96484500 3125739

Input: 75549175 99860242 42423626 6574859 73199290 26030615

Output: 2349885 0 75549175 26030615

Input: 4309493 76088457 2523467 46484812 909115 53662610

Output: 1887086 960803 3159847 76088457

Input: 99373741 10548319 82293354 9865357 58059929 5328757

Output: 41313812 5219562 99373741 10548319

Input: 81460 7041354 53032 1297536 41496 5748697

Output: 27916 0 78148 6958949

Input: 5664399 63519726 1914884 13554302 2435218 44439020

Output: 697275 0 3132493 44439020

Input: 19213492 76256257 10302871 19808004 19174729 55280126

Output: 38763 0 19213492 55280126

Input: 61430678 95017800 11901852 27772249 25202227 87778634

Output: 0 0 25202227 87778634

Input: 1063740 2675928 277215 2022291 204933 298547

Output: 0 1183193 1024665 2675928

Input: 71580569 68590917 4383746 13851161 9868376 8579752

Output: 0 0 71545726 62203202

Input: 17818532 82586436 8482338 54895799 12444902 11112345

Output: 2259887 49339626 14704789 60451971

Input: 63651025 50179036 16141802 24793214 28944209 13993078

Output: 0 10800136 57888418 38786292

Input: 11996821 42550832 8901163 19214381 3510233 20406511

Output: 4976355 0 11996821 40813022

Input: 27048166 72584165 4785744 2001800 24615554 27645416

Output: 0 0 24615554 27645416

Input: 47001271 53942737 7275347 1652337 33989593 48660013

Output: 0 0 33989593 48660013

Input: 51396415 50182729 20810973 38206844 17823753 2905275

Output: 0 34333144 47530008 42080544

Input: 27087649 52123970 20327636 19640608 8481031 14569965

Output: 1644556 0 27087649 43709895

Input: 41635044 16614992 36335190 11150551 30440245 13728274

Output: 11194799 2886718 41635044 16614992

Input: 97253692 35192249 21833856 26094161 41611668 32149284

Output: 0 363858 45079307 35192249

Input: 60300478 3471217 11842517 3192374 27980820 507119

Output: 0 2456979 55961640 3471217

Input: 69914272 30947694 58532705 25740028 30431847 27728130

Output: 39482425 3219564 69914272 30947694

Input: 83973381 91192149 19059738 26429459 49573749 78006738

Output: 0 0 49573749 78006738

Input: 1000000000 1000000000 286536427 579261823 230782719 575570138

Output: 171145067 291476754 401927786 867046892

Input: 1000000000 1000000000 42362139 725664533 91213476 617352813

Output: 0 176862916 121617968 1000000000

Input: 1000000000 1000000000 503220555 167034539 244352073 511651840

Output: 276322201 0 730118908 950210560

Input: 1000000000 1000000000 259046267 313437250 252266478 848401810

Output: 132913028 0 385179506 848401810

Input: 1000000000 1000000000 867388331 312356312 405405075 887925029

Output: 594594925 0 1000000000 887925029

Input: 1000000000 1000000000 623214043 753726318 970868535 929707704

Output: 29131465 70292296 1000000000 1000000000

Input: 1000000000 1000000000 84072459 754904836 124007132 824006731

Output: 22068893 175993269 146076025 1000000000

Input: 1000000000 1000000000 839898171 196274842 131921537 865789406

Output: 773937402 0 905858939 865789406

Input: 1000000000 1000000000 448240235 342677552 992352294 907572080

Output: 0 0 992352294 907572080

Input: 1000000000 1000000000 837887296 643696230 478881476 45404539

Output: 42237048 598291691 1000000000 689100769

Input: 1000000000 500 1000 400 11 122

Output: 978 12 1022 500

Input: 1000000000 1000000000 1000000000 1000000000 1 1

Output: 0 0 1000000000 1000000000

Input: 1000000000 1000000000 1000000000 1000000000 1000000000 1

Output: 0 999999999 1000000000 1000000000

Input: 1000000000 999999999 1000 1000 1000000000 999999999

Output: 0 0 1000000000 999999999

Input: 70 10 20 5 5 3

Output: 12 0 27 9

Input: 1000000000 1000000000 500000000 500000000 500000000 500000001

Output: 250000000 249999999 750000000 750000000


Bike is a smart boy who loves math very much. He invented a number called "Rotatable Number" inspired by 142857. As you can see, 142857 is a magic number because any of its rotatings can be got by multiplying that number by 1, 2, ..., 6 (numbers from one to number's length). Rotating a number means putting its last several digit into first. For example, by rotating number 12345 you can obtain any numbers: 12345, 51234, 45123, 34512, 23451. It's worth mentioning that leading-zeroes are allowed. So both 4500123 and 0123450 can be obtained by rotating 0012345. You can see why 142857 satisfies the condition. All of the 6 equations are under base 10.  142857·1 = 142857;  142857·2 = 285714;  142857·3 = 428571;  142857·4 = 571428;  142857·5 = 714285;  142857·6 = 857142. Now, Bike has a problem. He extends "Rotatable Number" under any base b. As is mentioned above, 142857 is a "Rotatable Number" under base 10. Another example is 0011 under base 2. All of the 4 equations are under base 2.  0011·1 = 0011;  0011·10 = 0110;  0011·11 = 1001;  0011·100 = 1100. So, he wants to find the largest b (1 < b < x) so that there is a positive "Rotatable Number" (leading-zeroes allowed) of length n under base b.Note that any time you multiply a rotatable number by numbers from 1 to its length you should get a rotating of that number.

The only line contains two space-separated integers n, x (1 ≤ n ≤ 5·106, 2 ≤ x ≤ 109).

Print a single integer — the largest b you found. If no such b exists, print -1 instead.

Input: 6 11

Output: 10

Input: 5 8

Output: -1

Input: 91 6579

Output: -1

Input: 96 4

Output: -1

Input: 100 3257

Output: 3250

Input: 1000002 10000000

Output: 9999997

Input: 96 9561

Output: 9547

Input: 96 7815

Output: 7801

Input: 96 8688

Output: 8674

Input: 100 3661

Output: 3654

Input: 4597694 3729016

Output: -1

Input: 4885608 36

Output: -1

Input: 4584720 292130

Output: 292083

Input: 4765486 2843533

Output: 2843506

Input: 4819150 1023221

Output: 1023185

Input: 4850940 1249925

Output: 1249882

Input: 4935742 3393126

Output: 3393099

Input: 93 115188153

Output: -1

Input: 100 2

Output: -1

Input: 96 951753385

Output: 951753371

Input: 100 998579551

Output: 998579544

Input: 96 226573140

Output: 226573126

Input: 96 201636768

Output: 201636754

Input: 100 935250127

Output: 935250120

Input: 4929388 408412310

Output: -1

Input: 4980752 887319973

Output: -1

Input: 4571442 2

Output: -1

Input: 4644832 2

Output: -1

Input: 4554552 52

Output: -1

Input: 4766386 4

Output: 2

Input: 4927750 67567983

Output: 67567954

Input: 4785600 847746219

Output: 847746176

Input: 4819162 628442864

Output: 628442844

Input: 4781760 695269412

Output: 695269366

Input: 4989580 580108834

Output: 580108807

Input: 4935012 726123193

Output: 726123159

Input: 4717098 77887266

Output: 77887234

Input: 4827750 360496418

Output: 360496372

Input: 4584690 111221963

Output: 111221906

Input: 4818060 238135431

Output: 238135373

Input: 4708386 739015039

Output: 739015006

Input: 4561488 973846429

Output: 973846392

Input: 4644952 261468430

Output: 261468404

Input: 4677246 515729434

Output: 515729391

Input: 4659468 326432989

Output: 326432950

Input: 4637782 744272977

Output: 744272957

Input: 4806718 719228528

Output: 719228500

Input: 4675062 317110372

Output: 317110324

Input: 4820422 270513305

Output: 270513285

Input: 4605448 125177681

Output: 125177650

Input: 4818060 238135431

Output: 238135373

Input: 4958188 50573541

Output: 50573516

Input: 4565598 65243634

Output: 65243602

Input: 4950138 943842183

Output: 943842145

Input: 1000033 987654321

Output: -1

Input: 1 100

Output: 99

Input: 1 2

Output: -1


In mathematics, the Pythagorean theorem — is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states: In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle). The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:a2 + b2 = c2where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.  Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 ≤ a ≤ b ≤ c ≤ n.

The only line contains one integer n (1 ≤ n ≤ 104) as we mentioned above.

Print a single integer — the answer to the problem.


Calendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calendar's scheme of leap years as follows: Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100; the centurial years that are exactly divisible by 400 are still leap years. For example, the year 1900 is not a leap year; the year 2000 is a leap year.   In this problem, you have been given two dates and your task is to calculate how many days are between them. Note, that leap years have unusual number of days in February.Look at the sample to understand what borders are included in the aswer.

The first two lines contain two dates, each date is in the format yyyy:mm:dd (1900 ≤ yyyy ≤ 2038 and yyyy:mm:dd is a legal date).

Input:
1900:01:01
2038:12:31

Output: 50768

Input:
1996:03:09
1991:11:12

Output: 1579

Input:
1999:12:31
2000:02:29

Output: 60

Input:
1903:09:27
1988:06:15

Output: 30943

Input:
1913:11:14
1901:05:11

Output: 4570

Input:
1915:01:01
2007:07:01

Output: 33784

Input:
1925:07:15
2010:06:22

Output: 31023

Input:
1935:10:08
1923:01:07

Output: 4657

Input:
1986:08:24
1926:04:13

Output: 22048

Input:
1932:11:18
2028:09:25

Output: 35010

Input:
1942:06:04
1982:12:29

Output: 14818

Input:
1993:08:25
1985:02:16

Output: 3112

Input:
1954:06:30
1911:05:04

Output: 15763

Input:
2005:08:01
1963:08:23

Output: 15319

Input:
2015:10:17
1966:07:12

Output: 17994

Input:
2025:08:10
2018:09:03

Output: 2533

Input:
2027:07:31
1945:04:06

Output: 30066

Input:
2037:05:16
1996:03:11

Output: 15041

Input:
1949:07:09
1901:10:24

Output: 17425

Input:
2028:04:11
1931:09:01

Output: 35287

Input:
1900:02:06
1997:12:07

Output: 35733

Input:
1902:09:06
1951:03:31

Output: 17738

Input:
1912:03:09
1954:06:17

Output: 15440

Input:
1963:05:02
2005:08:02

Output: 15433

Input:
1973:03:18
1932:11:07

Output: 14741

Input:
1934:01:09
1935:02:22

Output: 409

Input:
1985:08:24
1987:05:01

Output: 615

Input:
1995:06:03
1990:07:22

Output: 1777

Input:
1907:04:04
1902:10:01

Output: 1646

Input:
1910:01:11
1987:02:08

Output: 28152

Input:
1996:03:09
1996:03:09

Output: 0

Input:
1900:03:02
2038:03:01

Output: 50403

Input:
2000:01:02
2000:02:02

Output: 31

Input:
1999:04:08
1999:02:04

Output: 63

Input:
1999:01:01
1999:01:10

Output: 9

Input:
2012:05:29
2012:02:29

Output: 90

Input:
1900:01:01
1900:01:01

Output: 0

Input:
1996:02:01
1996:01:27

Output: 5

Input:
1901:12:31
1901:12:31

Output: 0

Input:
2000:02:28
2000:02:28

Output: 0


Polycarpus is sure that his life fits the description: "first there is a white stripe, then a black one, then a white one again". So, Polycarpus is sure that this rule is going to fulfill during the next n days. Polycarpus knows that he is in for w good events and b not-so-good events. At least one event is going to take place during each day. As each day is unequivocally characterizes as a part of a white or a black stripe, then each day is going to have events of the same type only (ether good or not-so-good).What is the number of distinct ways this scenario can develop over the next n days if Polycarpus is in for a white stripe (a stripe that has good events only, the stripe's length is at least 1 day), the a black stripe (a stripe that has not-so-good events only, the stripe's length is at least 1 day) and a white stripe again (a stripe that has good events only, the stripe's length is at least 1 day). Each of n days will belong to one of the three stripes only.Note that even the events of the same type are distinct from each other. Even if some events occur on the same day, they go in some order (there are no simultaneous events).Write a code that prints the number of possible configurations to sort the events into days. See the samples for clarifications on which scenarios should be considered distinct. Print the answer modulo 1000000009 (109 + 9).

NoteWe'll represent the good events by numbers starting from 1 and the not-so-good events — by letters starting from 'a'. Vertical lines separate days.In the first sample the possible ways are: "1|a|2" and "2|a|1". In the second sample the possible ways are: "1|a|b|2", "2|a|b|1", "1|b|a|2" and "2|b|a|1". In the third sample the possible ways are: "1|ab|2", "2|ab|1", "1|ba|2" and "2|ba|1".

The single line of the input contains integers n, w and b (3 ≤ n ≤ 4000, 2 ≤ w ≤ 4000, 1 ≤ b ≤ 4000) — the number of days, the number of good events and the number of not-so-good events. It is guaranteed that w + b ≥ n.

Print the required number of ways modulo 1000000009 (109 + 9).

Input: 3 2 1

Output: 2

Input: 4 2 2

Output: 4

Input: 3 2 2

Output: 4

Input: 3 3 1

Output: 12

Input: 3 3 3

Output: 72

Input: 4 2 3

Output: 24

Input: 4 3 2

Output: 48

Input: 10 10 10

Output: 318389383

Input: 10 7 5

Output: 130636800

Input: 10 4 9

Output: 135283173

Input: 100 200 300

Output: 316471646

Input: 200 100 300

Output: 949581532

Input: 239 300 231

Output: 774612666

Input: 300 300 300

Output: 375912430

Input: 300 2 300

Output: 775907030

Input: 300 300 1

Output: 775907030

Input: 3 300 300

Output: 496527918

Input: 3 2 300

Output: 196174631

Input: 3 300 1

Output: 828107078

Input: 4000 1000 3000

Output: 876839920

Input: 4000 2000 2000

Output: 310481606

Input: 4000 100 3900

Output: 221262673

Input: 4000 2 3998

Output: 686088712

Input: 3 2 4000

Output: 938379934

Input: 3 4000 4000

Output: 680114446

Input: 4000 4000 1

Output: 63263244

Input: 4000 3998 2

Output: 296557186

Input: 4000 4000 4000

Output: 997463324

Input: 4000 4000 100

Output: 994443885

Input: 4000 100 4000

Output: 908339579


Professional sport is more than hard work. It also is the equipment, designed by top engineers. As an example, let's take tennis. Not only should you be in great shape, you also need an excellent racket! In this problem your task is to contribute to the development of tennis and to help to design a revolutionary new concept of a racket!The concept is a triangular racket. Ant it should be not just any triangle, but a regular one. As soon as you've chosen the shape, you need to stretch the net. By the time you came the rocket had n holes drilled on each of its sides. The holes divide each side into equal n + 1 parts. At that, the m closest to each apex holes on each side are made for better ventilation only and you cannot stretch the net through them. The next revolutionary idea as to stretch the net as obtuse triangles through the holes, so that for each triangle all apexes lay on different sides. Moreover, you need the net to be stretched along every possible obtuse triangle. That's where we need your help — help us to count the number of triangles the net is going to consist of.Two triangles are considered to be different if their pictures on the fixed at some position racket are different.

NoteFor the following picture n = 8, m = 2. White circles are the holes for ventilation, red circles — holes for net stretching. One of the possible obtuse triangles is painted red.

The first and the only input line contains two integers n, m .

Print a single number — the answer to the problem.

Input: 3 0

Output: 9

Input: 4 0

Output: 24

Input: 10 1

Output: 210

Input: 8 4

Output: 0

Input: 1 0

Output: 0

Input: 2 0

Output: 0

Input: 250 16

Output: 5615358

Input: 500 37

Output: 40969344

Input: 1000 141

Output: 159977052

Input: 25000 18

Output: 9577113629202

Input: 19000 5743

Output: 42723355320

Input: 23849 12

Output: 8327896907037

Input: 16756 4

Output: 2893984759194

Input: 12334 51

Output: 1120612094406

Input: 5123 323

Output: 48958836510

Input: 10000 0

Output: 616244609316

Input: 20000 10000

Output: 0

Input: 23847 32

Output: 8273206744692

Input: 16234 61

Output: 2562574374918

Input: 24122 587

Output: 7150209021150

Input: 50 4

Output: 37680

Input: 25000 0

Output: 9629267050260

Input: 32000 324

Output: 18688647739074

Input: 31987 0

Output: 20169570555456

Input: 31999 12

Output: 20135272837188

Input: 32000 0

Output: 20194172518050