The final match of the Berland Football Cup has been held recently. The referee has shown $$$n$$$ yellow cards throughout the match. At the beginning of the match there were $$$a_1$$$ players in the first team and $$$a_2$$$ players in the second team.The rules of sending players off the game are a bit different in Berland football. If a player from the first team receives $$$k_1$$$ yellow cards throughout the match, he can no longer participate in the match — he's sent off. And if a player from the second team receives $$$k_2$$$ yellow cards, he's sent off. After a player leaves the match, he can no longer receive any yellow cards. Each of $$$n$$$ yellow cards was shown to exactly one player. Even if all players from one team (or even from both teams) leave the match, the game still continues.The referee has lost his records on who has received each yellow card. Help him to determine the minimum and the maximum number of players that could have been thrown out of the game.

Print two integers — the minimum and the maximum number of players that could have been thrown out of the game.

NoteIn the first example it could be possible that no player left the game, so the first number in the output is $$$0$$$. The maximum possible number of players that could have been forced to leave the game is $$$4$$$ — one player from the first team, and three players from the second.In the second example the maximum possible number of yellow cards has been shown $$$(3 \cdot 6 + 1 \cdot 7 = 25)$$$, so in any case all players were sent off.

The first line contains one integer $$$a_1$$$ $$$(1 \le a_1 \le 1\,000)$$$ — the number of players in the first team. The second line contains one integer $$$a_2$$$ $$$(1 \le a_2 \le 1\,000)$$$ — the number of players in the second team. The third line contains one integer $$$k_1$$$ $$$(1 \le k_1 \le 1\,000)$$$ — the maximum number of yellow cards a player from the first team can receive (after receiving that many yellow cards, he leaves the game). The fourth line contains one integer $$$k_2$$$ $$$(1 \le k_2 \le 1\,000)$$$ — the maximum number of yellow cards a player from the second team can receive (after receiving that many yellow cards, he leaves the game). The fifth line contains one integer $$$n$$$ $$$(1 \le n \le a_1 \cdot k_1 + a_2 \cdot k_2)$$$ — the number of yellow cards that have been shown during the match.

Input:
2
3
5
1
8

Output: 0 4

Output: 0 4

Output:
0
4

Output: 0   4

Output: 0 4

Output: 0 4

Output:
0
4

Input:
3
1
6
7
25

Output: 4   4

Output:
4
4

Output: 4 4

Output: 4 4

Output:
4
4

Output: 4 4

Output: 4 4

Input:
6
4
9
10
89

Output: 5 9

Output: 5 9

Output: 5 9

Output:
5
9

Output: 5   9

Output:
5
9

Output: 5 9

Input:
10
6
5
3
56

Output:
4
13

Output: 4 13

Output: 4 13

Output: 4 13

Output:
4
13

Output: 4 13

Output: 4   13

Input:
1
8
6
1
11

Output:
6
8

Output: 6 8

Output: 6 8

Output:
6
8

Output: 6 8

Output: 6   8

Output: 6 8

Input:
8
4
1
2
9

Output: 5 8

Output: 5 8

Output: 5 8

Output:
5
8

Output: 5 8

Output: 5   8

Output:
5
8

Input:
1000
1000
1000
1000
1456999

Output: 0   1456

Output: 0 1456

Output: 0 1456

Output: 0 1456

Output:
0
1456

Output: 0 1456

Output:
0
1456

Input:
8
2
6
7
34

Output: 0   5

Output: 0 5

Output: 0 5

Output: 0 5

Output:
0
5

Output: 0 5

Output:
0
5

Input:
7
6
2
6
11

Output: 0   5

Output: 0 5

Output: 0 5

Output: 0 5

Output:
0
5

Output: 0 5

Output:
0
5

Input:
621
739
132
209
236198

Output: 1135 1358

Output:
1135
1358

Output:
1135
1358

Output: 1135 1358

Output: 1135 1358

Output: 1135 1358

Output: 1135   1358

Input:
998
967
976
961
1902359

Output: 989 1964

Output: 989   1964

Output: 989 1964

Output:
989
1964

Output: 989 1964

Output:
989
1964

Output: 989 1964

Input:
8
8
3
7
61

Output: 0 13

Output: 0   13

Output:
0
13

Output:
0
13

Output: 0 13

Output: 0 13

Output: 0 13

Input:
5
8
7
1
38

Output: 8 12

Output: 8 12

Output:
8
12

Output: 8 12

Output: 8 12

Output: 8   12

Output:
8
12

Input:
4
7
1
10
60

Output:
0
9

Output: 0 9

Output: 0 9

Output: 0 9

Output: 0 9

Output:
0
9

Output: 0   9

Input:
1
7
2
3
5

Output: 0 2

Output: 0 2

Output:
0
2

Output: 0   2

Output: 0 2

Output: 0 2

Output:
0
2

Input:
4
5
8
5
54

Output:
6
8

Output: 6 8

Output: 6 8

Output:
6
8

Output: 6 8

Output: 6   8

Output: 6 8

Input:
9
9
6
4
28

Output:
0
7

Output: 0 7

Output:
0
7

Output: 0   7

Output: 0 7

Output: 0 7

Output: 0 7

Input:
1
1
1
1
1

Output:
1
1

Output: 1 1

Output: 1   1

Output:
1
1

Output: 1 1

Output: 1 1

Output: 1 1

Input:
1
1
1
1
2

Output: 2 2

Output:
2
2

Output: 2 2

Output: 2 2

Output: 2 2

Output:
2
2

Output: 2   2

Input:
1000
1000
1000
1000
1999999

Output:
1999
1999

Output: 1999   1999

Output: 1999 1999

Output: 1999 1999

Output:
1999
1999

Output: 1999 1999

Output: 1999 1999

Input:
1000
1000
1000
1000
2000000

Output: 2000   2000

Output: 2000 2000

Output: 2000 2000

Output: 2000 2000

Output:
2000
2000

Output:
2000
2000

Output: 2000 2000

Input:
1000
1000
1000
1000
234567

Output:
0
234

Output: 0 234

Output: 0 234

Output:
0
234

Output: 0   234

Output: 0 234

Output: 0 234

Input:
1000
1000
1000
1000
1542000

Output: 0 1542

Output: 0 1542

Output: 0   1542

Output:
0
1542

Output: 0 1542

Output:
0
1542

Output: 0 1542

Input:
645
910
871
584
1093020

Output: 1340 1554

Output: 1340 1554

Output: 1340 1554

Output: 1340 1554

Output:
1340
1554

Output: 1340   1554

Output:
1340
1554

Input:
69
50
425
358
47212

Output: 106 118

Output: 106 118

Output: 106 118

Output:
106
118

Output:
106
118

Output: 106   118

Output: 106 118

Input:
493
599
875
539
754094

Output: 950 1091

Output: 950   1091

Output:
950
1091

Output: 950 1091

Output:
950
1091

Output: 950 1091

Output: 950 1091

Input:
45
583
686
390
257651

Output: 39 627

Output: 39   627

Output:
39
627

Output: 39 627

Output: 39 627

Output: 39 627

Output:
39
627

Input:
469
236
432
868
407315

Output: 564 704

Output: 564 704

Output:
564
704

Output: 564 704

Output: 564   704

Output:
564
704

Output: 564 704

Input:
893
376
689
346
744309

Output: 205 1267

Output: 205 1267

Output: 205 1267

Output: 205 1267

Output:
205
1267

Output:
205
1267

Output: 205   1267

Input:
21
924
435
527
495557

Output: 419 944

Output: 419   944

Output: 419 944

Output: 419 944

Output: 419 944

Output:
419
944

Output:
419
944

Input:
445
65
989
197
452410

Output: 10 509

Output:
10
509

Output:
10
509

Output: 10 509

Output: 10 509

Output: 10   509

Output: 10 509

Input:
869
909
438
379
724194

Output: 839 1775

Output:
839
1775

Output: 839 1775

Output: 839 1775

Output:
839
1775

Output: 839   1775

Output: 839 1775

Input:
997
754
992
152
1103189

Output: 1308 1750

Output: 1308   1750

Output: 1308 1750

Output:
1308
1750

Output: 1308 1750

Output: 1308 1750

Output:
1308
1750

Input:
421
702
250
334
339096

Output: 501 1121

Output: 501   1121

Output:
501
1121

Output: 501 1121

Output: 501 1121

Output:
501
1121

Output: 501 1121

Input:
549
250
995
811
748917

Output:
711
798

Output: 711 798

Output: 711 798

Output: 711 798

Output: 711   798

Output:
711
798

Output: 711 798

Input:
269
95
253
185
85627

Output:
359
363

Output: 359 363

Output: 359 363

Output:
359
363

Output: 359 363

Output: 359 363

Output: 359   363

Input:
398
235
999
663
552924

Output: 150 632

Output: 150   632

Output: 150 632

Output: 150 632

Output:
150
632

Output:
150
632

Output: 150 632

Input:
1
1
7
1
2

Output: 0 1

Output:
0
1

Output: 0 1

Output: 0 1

Output: 0 1

Output: 0   1

Output:
0
1

Input:
254
771
827
760
693168

Output:
0
900

Output:
0
900

Output: 0 900

Output: 0   900

Output: 0 900

Output: 0 900

Output: 0 900

Input:
708
360
819
836
642301

Output:
0
782

Output: 0   782

Output: 0 782

Output:
0
782

Output: 0 782

Output: 0 782

Output: 0 782

Input:
1
1
1
3
4

Output: 2 2

Output:
2
2

Output: 2 2

Output: 2 2

Output: 2 2

Output:
2
2

Output: 2   2

Input:
998
967
976
961
1903335

Output: 1965 1965

Output:
1965
1965

Output: 1965 1965

Output: 1965 1965

Output: 1965 1965

Output:
1965
1965

Output: 1965   1965

Input:
998
967
976
961
1901392

Output: 22 1963

Output: 22   1963

Output:
22
1963

Output:
22
1963

Output: 22 1963

Output: 22 1963

Output: 22 1963

Input:
1000
1000
1000
1000
998

Output:
0
0

Output: 0   0

Output: 0 0

Output: 0 0

Output:
0
0

Output: 0 0

Output: 0 0


There is a white sheet of paper lying on a rectangle table. The sheet is a rectangle with its sides parallel to the sides of the table. If you will take a look from above and assume that the bottom left corner of the table has coordinates $$$(0, 0)$$$, and coordinate axes are left and bottom sides of the table, then the bottom left corner of the white sheet has coordinates $$$(x_1, y_1)$$$, and the top right — $$$(x_2, y_2)$$$.After that two black sheets of paper are placed on the table. Sides of both black sheets are also parallel to the sides of the table. Coordinates of the bottom left corner of the first black sheet are $$$(x_3, y_3)$$$, and the top right — $$$(x_4, y_4)$$$. Coordinates of the bottom left corner of the second black sheet are $$$(x_5, y_5)$$$, and the top right — $$$(x_6, y_6)$$$.     Example of three rectangles. Determine if some part of the white sheet can be seen from the above after the two black sheets are placed. The part of the white sheet can be seen if there is at least one point lying not strictly inside the white sheet and strictly outside of both black sheets.

If some part of the white sheet can be seen from the above after the two black sheets are placed, print "YES" (without quotes). Otherwise print "NO".

NoteIn the first example the white sheet is fully covered by black sheets.In the second example the part of the white sheet can be seen after two black sheets are placed. For example, the point $$$(6.5, 4.5)$$$ lies not strictly inside the white sheet and lies strictly outside of both black sheets.

The first line of the input contains four integers $$$x_1, y_1, x_2, y_2$$$ $$$(0 \le x_1 < x_2 \le 10^{6}, 0 \le y_1 < y_2 \le 10^{6})$$$ — coordinates of the bottom left and the top right corners of the white sheet. The second line of the input contains four integers $$$x_3, y_3, x_4, y_4$$$ $$$(0 \le x_3 < x_4 \le 10^{6}, 0 \le y_3 < y_4 \le 10^{6})$$$ — coordinates of the bottom left and the top right corners of the first black sheet. The third line of the input contains four integers $$$x_5, y_5, x_6, y_6$$$ $$$(0 \le x_5 < x_6 \le 10^{6}, 0 \le y_5 < y_6 \le 10^{6})$$$ — coordinates of the bottom left and the top right corners of the second black sheet. The sides of each sheet of paper are parallel (perpendicular) to the coordinate axes.

Input:
2 2 4 4
1 1 3 5
3 1 5 5

Output: NO

Input:
3 3 7 5
0 0 4 6
0 0 7 4

Output: YES

Input:
5 2 10 5
3 1 7 6
8 1 11 7

Output: YES

Input:
0 0 1000000 1000000
0 0 499999 1000000
500000 0 1000000 1000000

Output: YES

Input:
50 100 100000 99000
13 4654 99999 1000000
0 0 1000000 45653

Output: YES

Input:
0 0 1000000 1000000
0 0 1000000 999999
0 0 999999 1000000

Output: YES

Input:
0 0 1000000 1000000
1 0 1000000 1000000
0 0 1000000 999999

Output: YES

Input:
128715 414887 594910 716176
443190 112845 919607 589041
76564 385268 123669 951664

Output: YES

Input:
347722 718484 584813 736820
280059 317406 997137 588815
388486 281361 399827 854715

Output: YES

Input:
0 0 1000000 1000000
0 0 999999 1000000
0 1 1000000 1000000

Output: YES

Input:
50 100 100000 99000
13 4654 999999 1000000
0 0 1000000 45654

Output: NO

Input:
50 100 100000 99000
0 0 1 1
999999 999999 1000000 1000000

Output: YES

Input:
50 100 100000 99000
0 0 100111 98999
49 65999 100000 99431

Output: NO

Input:
50 100 100000 99000
0 0 99999 1000000
51 0 100123 99321

Output: NO

Input:
10 10 11 11
10 10 11 11
10 10 11 11

Output: NO

Input:
50 100 100000 99000
49 99 1000000 99000
100 100 200 200

Output: NO

Input:
50 100 100000 99000
0 0 54443 1000000
54443 3 1000000 99001

Output: NO

Input:
50 100 100000 99000
0 0 54443 1000000
54444 3 1000000 99001

Output: YES

Input:
0 0 1000000 1000000
1 0 1000000 1000000
0 1 1000000 1000000

Output: YES

Input:
5 2 10 5
8 1 11 7
3 1 7 6

Output: YES

Input:
0 0 3 3
5 5 6 6
0 0 4 4

Output: NO

Input:
0 0 4 4
0 0 4 2
0 3 4 4

Output: YES

Input:
72 55 101 102
62 86 138 120
69 42 114 59

Output: YES

Input:
20928 630 21684 2628
5490 5362 23490 19143
17369 1636 25838 2841

Output: YES

Input:
2 6 8 8
1 2 3 3
1 3 10 10

Output: NO

Input:
0 2 4 3
1 1 4 5
0 2 3 3

Output: NO

Input:
5 1 9 3
0 2 1 9
4 1 10 3

Output: NO

Input:
62 28 73 92
106 65 119 152
77 52 128 99

Output: YES

Input:
1 7 2 8
0 0 1 1
1 4 2 9

Output: NO

Input:
44 17 46 92
43 14 58 101
65 36 110 124

Output: NO

Input:
0 4 2 7
4 3 7 8
6 0 8 1

Output: YES

Input:
6 6 7 9
0 1 3 7
5 6 7 9

Output: NO

Input:
44 63 82 114
76 46 95 147
41 63 138 146

Output: NO

Input:
1 1 3 3
1 1 3 2
1 2 3 3

Output: NO

Input:
100 0 110 10
99 5 111 11
99 1 111 6

Output: YES

Input:
5 5 9 9
0 0 4 4
5 5 9 9

Output: NO

Input:
33 47 44 78
76 71 162 159
3 28 81 101

Output: NO

Input:
6 6 10 8
10 3 16 9
2 3 7 11

Output: YES

Input:
96 64 120 82
102 1 135 107
99 67 111 93

Output: YES

Input:
1 2 3 4
1 1 4 4
5 5 9 9

Output: NO

Input:
386262 760032 542069 772227
911675 754955 999646 829927
378348 689243 743180 973455

Output: NO

Input:
63 8 84 16
13 30 15 52
25 7 84 19

Output: NO

Input:
623181 608349 717362 757936
654173 174442 707580 812338
649542 255816 917899 810891

Output: YES

Input:
10 62 11 94
8 57 29 86
9 66 45 89

Output: YES

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

Output: YES

Input:
40 40 61 55
18 33 83 96
52 20 53 40

Output: NO

Input:
2 34 5 38
64 51 79 65
51 52 79 84

Output: YES

Input:
1 4 9 9
1 1 10 2
1 3 9 9

Output: NO

Input:
6 33 79 56
18 18 93 78
39 10 58 84

Output: YES

Input:
28775 15542 38394 20166
26125 12713 57946 30999
2705 8834 5217 12154

Output: NO

Input:
25313 25296 30476 31203
2593 15252 22456 19837
19859 22944 31515 50105

Output: NO

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

Output: NO

Input:
10 10 20 20
9 9 21 11
9 19 21 21

Output: YES

Input:
3 0 6 7
3 0 8 4
3 1 10 5

Output: YES

Input:
12076 20776 30893 22819
20138 19000 30107 29254
3726 20088 28731 46619

Output: YES

Input:
3 0 4 1
6 6 10 9
3 0 4 8

Output: NO

Input:
30228 19166 31396 28305
17488 91 44825 10139
14405 17644 40771 38925

Output: NO

Input:
0 1 1 7
6 1 10 5
0 1 1 8

Output: NO

Input:
11360 21479 13661 21563
8924 9481 21073 27713
16778 27004 23110 32529

Output: NO

Input:
2 2 6 3
1 0 3 2
2 2 6 4

Output: NO

Input:
2 7 3 9
0 2 1 6
1 3 3 9

Output: NO

Input:
25739 32688 44216 35348
29800 22866 55114 54031
17721 29321 32956 40913

Output: NO

Input:
0 0 5 1
0 0 7 1
7 5 9 6

Output: NO

Input:
2 4 3 10
2 0 5 1
0 7 3 10

Output: YES

Input:
3 3 4 4
0 0 1 1
3 3 4 4

Output: NO

Input:
1 2 2 8
5 0 8 1
0 1 4 9

Output: NO

Input:
2 4 7 5
1 4 7 10
0 2 1 3

Output: NO

Input:
9 9 10 16
9 5 15 8
9 10 19 16

Output: YES

Input:
4 8 13 9
8 8 14 16
2 2 8 11

Output: NO

Input:
2 0 6 8
2 3 7 5
2 0 8 6

Output: YES

Input:
9 5 13 7
8 5 16 7
4 2 5 12

Output: NO

Input:
1 0 2 7
1 0 2 3
4 4 10 7

Output: YES

Input:
0 0 3 3
0 0 3 1
0 2 3 3

Output: YES

Input:
8 8 10 10
10 4 14 11
2 4 5 13

Output: YES

Input:
4 7 8 8
8 6 15 11
4 1 7 10

Output: YES

Input:
5 8 8 10
1 8 9 18
6 2 15 4

Output: NO

Input:
676584 172869 696986 939949
217531 247380 771662 973703
630670 592931 929942 967883

Output: YES

Input:
5 4 9 12
2 9 11 17
3 3 9 7

Output: YES

Input:
0 1 1 2
3 3 4 4
3 4 4 5

Output: YES

Input:
7 5 8 10
5 3 8 12
6 2 9 9

Output: NO

Input:
1 4 3 6
3 0 6 2
3 6 6 10

Output: YES

Input:
0 5 1 7
5 0 7 9
0 1 1 7

Output: NO

Input:
4 4 5 6
2 1 10 11
1 7 9 15

Output: NO

Input:
384066 916918 765119 935891
222262 945490 915577 995511
310286 10123 921636 688959

Output: YES

Input:
10 9 15 11
10 7 18 13
5 9 8 17

Output: NO

Input:
0 0 64000 67200
0 0 11392 512
200000 200000 200001 200001

Output: YES

Input:
2 2 3 10
8 1 18 10
5 2 9 7

Output: YES

Input:
41 37 49 42
22 27 27 53
40 27 73 61

Output: NO

Input:
17 12 20 15
8 7 19 29
0 11 12 15

Output: YES

Input:
15 14 17 15
0 0 8 1
9 7 18 19

Output: NO

Input:
2 3 4 4
26 3 31 39
29 2 30 21

Output: YES

Input:
6 6 7 15
14 10 19 35
3 2 15 11

Output: YES

Input:
3 2 5 10
2 1 10 4
3 8 9 12

Output: YES

Input:
2459 6365 5308 15923
1847 22052 15585 27089
336 308 27773 18664

Output: NO

Input:
5 5 7 7
0 0 2 9
3 3 9 9

Output: NO

Input:
4 12 20 15
5 11 26 21
14 8 18 18

Output: YES

Input:
11488 12686 14861 25322
263 9355 23103 24765
3524 20940 17452 29689

Output: NO

Input:
1 2 2 3
1 0 2 1
1 2 2 5

Output: NO

Input:
2 0 3 2
9 19 13 23
1 0 4 2

Output: NO

Input:
488689 537034 554397 658289
966606 109329 985284 598401
342151 126230 893625 984316

Output: NO

Input:
10 22 17 30
0 6 10 14
7 6 22 37

Output: NO

Input:
0 0 1 1
12 15 19 18
10 9 18 14

Output: YES

Input:
26 19 31 21
0 5 1 6
3 0 4 3

Output: YES

Input:
7 1 8 3
0 0 4 2
2 1 18 21

Output: NO

Input:
20 10 21 35
13 11 23 15
4 8 14 35

Output: YES

Input:
1 6 8 7
2 4 19 36
1 2 3 8

Output: NO

Input:
1 1 3 3
1 2 3 4
1 5 3 6

Output: YES

Input:
0 0 3 4
0 3 3 4
0 0 3 2

Output: YES

Input:
67 37 107 67
3 11 140 72
77 82 192 108

Output: NO

Input:
18819 25865 29363 26625
18424 24009 23338 30333
14928 4422 23749 31969

Output: YES

Input:
11326 10029 21783 23590
3523 10197 31181 30973
25733 4494 31445 24783

Output: YES

Input:
2975 7327 23972 7416
9620 220 31879 22310
2975 3099 14074 10669

Output: NO

Input:
2 2 3 3
3 3 4 4
2 2 3 3

Output: NO

Input:
14 5 18 17
9 8 22 25
12 16 27 35

Output: YES

Input:
305226 115092 351397 858801
179907 128966 724370 944812
78823 602023 461809 960582

Output: YES

Input:
9924 9975 22878 16516
12808 6652 28411 23264
8204 388 14798 5070

Output: YES

Input:
8 14 11 37
8 18 21 26
6 11 18 34

Output: YES

Input:
4 4 5 5
0 0 2 6
3 3 6 6

Output: NO

Input:
5 0 7 2
1 0 3 2
0 7 10 10

Output: YES

Input:
489631 107603 533004 219679
180507 27927 660647 671315
66302 622560 250301 900772

Output: NO

Input:
1 1 5 5
1 1 5 3
1 4 5 5

Output: YES

Input:
21221 4966 23465 12117
10451 1226 31617 12028
3206 8163 28643 29817

Output: NO

Input:
457749 221391 481637 901029
427621 205962 972764 927169
11595 580533 366640 796529

Output: NO

Input:
565785 704313 907569 768345
732991 292147 948744 894422
249829 311996 592862 996946

Output: YES

Input:
4 3 6 7
0 5 2 8
3 2 8 8

Output: NO

Input:
3 1 4 7
3 1 7 2
0 4 10 9

Output: YES

Input:
1 8 5 9
1 1 2 3
2 0 4 1

Output: YES

Input:
6 4 8 5
1 0 2 1
1 0 4 2

Output: YES

Input:
4 6 6 7
1 4 9 5
4 5 6 10

Output: NO

Input:
17091 4911 18849 17274
13934 15726 22311 21493
2884 3776 29047 15726

Output: NO

Input:
8 8 9 9
7 0 8 9
1 6 8 9

Output: YES

Input:
0 7 1 8
0 6 3 8
6 6 8 8

Output: NO

Input:
3 8 10 10
2 0 10 1
4 8 10 10

Output: YES

Input:
8656 18613 22899 20400
4553 218 16704 19833
11001 13673 30179 21141

Output: YES


Suppose you are stuck on a desert island. The only way to save yourself is to craft a wooden raft and go to the sea. Fortunately, you have a hand-made saw and a forest nearby. Moreover, you've already cut several trees and prepared it to the point that now you have $$$n$$$ logs and the $$$i$$$-th log has length $$$a_i$$$.The wooden raft you'd like to build has the following structure: $$$2$$$ logs of length $$$x$$$ and $$$x$$$ logs of length $$$y$$$. Such raft would have the area equal to $$$x \cdot y$$$. Both $$$x$$$ and $$$y$$$ must be integers since it's the only way you can measure the lengths while being on a desert island. And both $$$x$$$ and $$$y$$$ must be at least $$$2$$$ since the raft that is one log wide is unstable.You can cut logs in pieces but you can't merge two logs in one. What is the maximum area of the raft you can craft?

Print the only integer — the maximum area of the raft you can craft.

NoteIn the first example, you can cut the log of the length $$$9$$$ in $$$5$$$ parts: $$$2 + 2 + 2 + 2 + 1$$$. Now you can build $$$2 \times 2$$$ raft using $$$2$$$ logs of length $$$x = 2$$$ and $$$x = 2$$$ logs of length $$$y = 2$$$.In the second example, you can cut $$$a_4 = 18$$$ into two pieces $$$9 + 9$$$ and $$$a_8 = 28$$$ in three pieces $$$10 + 9 + 9$$$. Now you can make $$$10 \times 9$$$ raft using $$$2$$$ logs of length $$$10$$$ and $$$10$$$ logs of length $$$9$$$.

The first line contains the only integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the number of logs you have. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$2 \le a_i \le 5 \cdot 10^5$$$) — the corresponding lengths of the logs. It's guaranteed that you can always craft at least $$$2 \times 2$$$ raft.

Input:
1
9

Output: 4

Input:
9
9 10 9 18 9 9 9 28 9

Output: 90

Input:
2
11 12

Output: 18

Input:
9
3 4 3 5 3 3 10 6 4

Output: 20

Input:
20
5 4 8 2 8 6 7 5 3 4 4 5 4 2 4 14 2 2 4 2

Output: 35

Input:
5
12 12 16 16 16

Output: 55

Input:
5
28 28 29 26 28

Output: 115

Input:
7
28 23 27 12 28 23 14

Output: 120

Input:
10
2 2 2 4 3 2 2 5 5 4

Output: 12

Input:
10
28 22 16 35 32 23 22 35 26 35

Output: 209

Input:
10
3 8 15 14 7 15 8 9 5 15

Output: 63

Input:
10
21 28 33 27 33 28 34 25 24 11

Output: 198

Input:
16902
33785 33784 11263 11264 11263 11264 11263 11264 11263 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 11262 ...

Output: 190350324

Input:
90792
181565 181564 60523 60524 60523 60524 60523 60524 60523 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 60522 6052...

Output: 5494913424

Input:
10
2 3 3 3 2 2 3 3 10 10

Output: 21

Input:
125000
2 2 2 2 3 2 2 3 3 3 3 3 2 3 2 2 2 3 2 3 3 2 2 2 2 2 3 2 3 2 2 2 3 2 3 3 2 2 3 3 3 2 2 2 2 3 2 2 3 2 3 2 2 2 3 3 2 2 3 2 2 2 2 3 2 2 2 3 3 2 3 3 2 2 3 3 2 2 2 3 3 3 2 2 2 2 3 2 3 3 2 2 2 2 2 3 2 2 2 3 3 3 3 2 2 3 3 2 3 3 2 2 3 2 2 2 2 3 3 2 3 3 2 2 3 2 2 3 2 2 2 2 3 2 2 2 3 3 3 3 2 2 2 3 3 2 2 3 2 2 2 3 2 2 2 3 2 2 3 3 2 3 2 3 3 2 2 3 3 3 3 3 3 3 3 2 3 3 2 2 2 3 3 3 2 2 2 3 2 3 3 2 3 3 2 3 2 2 3 2 2 2 3 3 3 3 2 2 3 3 2 2 2 2 3 2 3 3 2 2 3 3 2 2 3 2 3 2 2 3 2 3 2 2 2 3 3 3 3 2 2 3 3 3 3 3 3 2 3 3 3 2...

Output: 500000

Input:
120001
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

Output: 516000

Input:
500000
296144 433053 180408 321749 157544 283827 66105 287559 390887 287312 445968 152487 414849 207967 199059 168249 103496 328179 406652 50017 211298 407293 153846 202861 243418 84153 481400 338098 438723 22300 166321 284645 353141 105160 135890 66051 114724 16969 430338 16188 389418 460022 186506 214697 440757 405694 119881 213006 11102 210882 430538 183299 450616 351045 123667 200547 162656 228370 346939 415552 158034 319258 437777 57913 167499 228251 420886 70355 138933 427158 331181 322682 367763 39...

Output: 83294333411

Input:
500000
488518 177553 73804 468737 450707 151148 117097 136330 355980 318723 403938 499178 47464 2914 284785 397700 47696 140979 355315 443811 244540 197211 156063 246605 84763 9898 205473 380062 17829 278944 185751 466948 121935 333445 30197 355915 110300 87129 424992 256406 62234 96759 296217 135453 205718 281403 128637 64801 449027 200556 457456 292433 25551 49430 9861 50482 481003 328122 173055 266037 468347 364396 46763 397364 255391 390113 146353 137013 464648 436832 467757 67416 100672 484127 417094...

Output: 83315166738

Input:
500000
180894 434109 479257 127783 231814 18468 168089 497157 333130 350133 349851 333812 192135 309918 370511 127152 491895 441722 303977 337606 277782 487128 170338 290349 426107 435642 441603 434084 108990 23533 193125 149251 402786 61731 412446 133722 105876 169346 407589 496624 247106 233496 405929 56209 458621 145054 137393 428653 386954 202288 484374 401566 100485 259871 396054 388358 299351 415817 499170 116522 290717 409534 143691 248874 343284 39918 371820 203672 290364 446507 92278 300092 34563...

Output: 83314666740

Input:
500000
373268 190666 384710 274771 24977 385788 219081 345928 310280 381544 295765 168447 324750 104866 456238 368660 436094 242466 252640 219344 311024 289102 184612 334093 255395 373444 165676 476049 188095 280178 200499 331554 171581 290016 306753 423585 101452 239506 402242 236844 419921 370232 3585 476964 223582 8706 146149 280449 324881 191962 499235 10700 187476 470311 294306 226235 105641 15571 325286 467006 101030 454672 252675 100383 431177 189723 97287 270330 116081 444124 228854 44826 78547 15...

Output: 83369505063

Input:
500000
65643 447222 290163 421759 306083 265166 282130 206755 275373 412955 253735 3081 469421 411869 41965 98112 380294 43210 201303 113139 344266 79020 198887 389894 96740 299190 401806 18014 267200 24766 207873 13857 440375 30360 189003 201392 97028 309666 396896 477062 92737 19026 113297 397720 488542 372357 166962 144301 262808 181637 26153 119833 262410 168696 180500 76170 423988 115323 139346 317492 411342 11868 349603 451891 7014 351584 322754 336988 453853 453798 353374 277502 311455 235869 46208...

Output: 83327000064

Input:
500000
258018 191722 195617 68749 99247 132487 333122 55526 252524 444366 199649 337714 102036 206817 127691 339620 324494 343952 149965 6934 377509 380994 213161 433638 438084 224935 125879 59979 358361 281411 215247 196160 221227 258645 83310 491255 92604 391883 379492 217281 277609 155762 223009 318475 253504 236008 175718 8154 200735 183368 53071 228966 337344 379136 66694 414046 230279 203018 465461 167977 233712 57006 458588 291343 94907 1390 48221 391589 279569 463473 489951 22236 44364 327821 1397...

Output: 83230834148

Input:
500000
450392 448278 101070 215737 380353 499807 384115 416353 217617 475777 145562 172349 234651 13822 213418 69072 268693 144696 98628 388671 398694 170912 215379 477381 279430 162737 362009 101944 437466 25999 222621 378462 490021 486930 465559 269062 88179 462043 374146 457500 450424 292499 320663 227174 6408 99660 184474 359948 138662 173043 79989 338099 412278 89578 464945 263981 48627 302770 291577 6405 44026 102144 55517 142852 182799 163251 273688 458247 105286 473147 114471 254912 277273 419773 ...

Output: 83357775500

Input:
500000
142768 204835 494466 374782 161460 367128 435107 265124 194767 7188 103532 6983 379322 308768 299144 310580 212893 445439 47291 282467 431936 460829 229653 21126 120775 88482 86082 143908 28628 282644 242051 60766 270872 215216 347810 58926 83755 44261 356742 197719 123240 429235 430375 147930 271368 463311 193230 223801 76589 162717 94850 447232 487211 287962 351139 101858 354916 390465 117693 356889 354338 147282 164501 494361 258635 313056 499154 24906 443058 470765 238991 499645 10182 499668 49...

Output: 83296666812

Input:
500000
319 79 838 639 668 92 552 881 619 964 967 522 263 357 658 759 523 393 907 612 516 372 134 592 128 435 227 435 430 26 503 408 562 227 98 583 4 469 210 869 94 467 403 398 449 239 233 934 262 351 775 318 969 674 94 899 103 109 767 866 876 931 37 956 380 603 319 530 958 838 590 325 619 327 206 965 619 470 174 475 4 628 347 313 604 458 234 746 581 661 296 57 877 763 446 189 861 134 44 947 749 848 82 249 224 728 931 979 854 315 973 406 590 565 851 743 861 985 455 906 283 930 904 885 585 406 851 472 439 8...

Output: 45050000

Input:
500000
512 227 709 582 930 78 997 788 368 779 44 904 846 57 319 846 42 628 531 170 262 409 971 976 21 617 808 72 556 556 765 134 328 613 441 213 14 137 963 100 615 24 107 12 920 252 353 60 932 38 716 197 277 102 534 860 470 427 941 461 553 676 453 470 730 910 341 681 765 570 864 97 78 237 970 815 32 877 436 370 434 390 724 805 89 619 250 385 689 527 713 314 194 771 611 824 604 891 844 711 312 146 642 843 773 74 816 221 827 52 350 226 750 604 181 471 949 572 82 472 808 765 679 179 814 136 521 179 889 781 8...

Output: 45000000

Input:
500000
830 250 97 44 274 546 85 178 554 719 558 723 430 836 25 933 639 783 592 369 7 445 810 3 476 674 390 663 119 88 510 342 140 561 267 325 24 322 279 891 494 98 373 63 312 266 427 622 41 643 656 433 710 172 332 259 400 745 71 493 747 501 307 857 81 217 568 708 492 944 782 949 974 147 377 789 364 802 56 783 428 152 663 780 573 655 185 897 316 393 693 570 430 217 776 541 267 212 3 396 391 442 560 920 965 419 185 382 719 350 164 92 267 564 430 761 118 800 789 957 335 37 18 35 44 222 315 527 981 733 832 58...

Output: 45000000

Input:
500000
58 55 16 95 66 92 29 72 21 60 44 86 81 27 43 45 95 15 45 76 14 99 31 71 64 75 60 33 10 60 14 10 36 94 54 31 55 9 58 86 57 14 83 81 56 53 38 76 79 45 82 40 4 84 5 73 42 53 63 100 51 97 97 15 45 25 89 25 52 75 24 75 69 54 14 10 18 69 78 70 84 36 12 41 64 70 44 65 47 44 66 14 44 46 16 70 43 7 19 21 69 8 42 45 51 48 10 18 41 2 88 100 52 15 33 77 93 13 41 83 17 87 96 74 41 96 34 42 19 87 38 51 12 19 79 74 26 65 40 83 3 81 92 32 44 46 77 75 30 73 81 10 5 98 85 14 32 66 83 83 94 32 82 64 74 10 78 27 39 37...

Output: 12906660

Input:
500000
26290 42081 24521 23105 275 28007 34786 12413 26713 14853 36704 26525 33647 45868 44695 7912 18566 27251 33176 32808 22009 27279 11235 15153 40458 22055 23039 31588 36595 21425 42440 32559 9293 21425 18400 15620 3626 48483 11227 44455 28161 2079 46458 48056 20781 10140 26192 36146 905 28998 49179 29939 814 29841 49161 151 31536 18023 30544 35810 47718 32785 23709 12006 38177 10802 32863 41968 8676 36344 11627 46284 32418 48701 25115 48200 39352 49956 39759 35269 29234 1557 27216 11968 3297 48332 20...

Output: 6253542160

Input:
500000
277734 499589 132406 332716 281776 231094 324562 106714 407429 199646 238730 441067 141625 453423 221784 205383 21598 415286 273720 355522 24786 290312 304983 425109 15576 192425 56846 202113 365977 180824 177598 423291 235351 441336 403163 442712 339833 100907 421163 144308 125950 337274 270078 60645 390695 218599 279708 360100 421501 79277 38837 413122 27036 83236 444509 195095 116689 361373 350868 462069 290778 273185 198880 272252 82289 248957 314045 8449 484892 250131 316595 395450 50184 43881...

Output: 83305833548

Input:
499999
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 1...

Output: 83332999999

Input:
499994
5 2 4 9 4 6 10 10 14 9 14 17 10 14 15 17 18 15 18 23 18 27 29 30 31 29 26 27 33 36 34 34 29 40 41 39 40 36 43 46 39 45 44 41 47 50 44 47 52 56 47 53 51 57 55 61 60 57 56 56 67 60 67 63 70 71 73 74 71 67 69 77 74 79 78 77 79 77 79 86 83 81 81 89 85 84 92 91 93 94 88 90 95 97 99 101 100 104 100 105 97 104 103 106 102 110 106 114 105 110 110 117 112 113 117 113 116 118 121 118 121 125 123 124 121 125 130 130 128 134 136 129 129 136 136 138 134 137 144 146 141 143 145 146 148 149 144 146 152 154 148 15...

Output: 83332163880

Input:
499994
2 2 2 2 9 2 8 14 13 15 9 13 12 16 19 19 22 21 16 22 19 28 22 29 22 28 28 27 34 29 32 36 35 32 38 33 42 43 41 45 43 48 47 44 41 43 43 52 46 51 50 58 57 50 58 60 60 54 58 62 63 61 65 61 62 64 73 74 68 67 75 74 74 75 80 75 79 75 79 77 77 80 84 84 87 90 90 88 91 87 94 92 89 95 94 99 97 102 99 106 100 104 100 106 104 107 106 104 113 114 113 114 119 115 115 113 113 122 123 118 119 121 127 129 121 123 129 131 126 129 134 137 130 138 137 132 140 136 141 143 138 144 141 145 146 150 150 154 153 148 155 148 1...

Output: 83332155324

Input:
499994
2 2 4 3 10 2 6 10 9 14 8 15 11 16 20 18 15 15 23 21 24 27 24 25 24 23 33 34 33 34 34 29 34 31 34 33 42 34 45 41 44 43 43 41 44 48 44 47 47 49 47 54 54 55 54 60 57 62 60 61 59 58 60 63 68 64 65 70 68 75 71 77 78 79 71 80 76 81 75 83 77 84 81 86 90 90 83 86 88 87 96 91 98 93 100 100 97 99 97 96 98 101 108 102 111 107 103 108 114 114 108 111 116 116 120 120 117 124 116 124 118 124 120 127 121 123 124 129 125 128 135 134 139 137 131 136 143 138 138 143 145 148 149 143 141 151 146 144 146 154 155 152 14...

Output: 83332158714

Input:
404659
404659 404657 404656 404656 404656 404656 404656 404656 404656 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329 202329...

Output: 81873846153

Input:
404661
404661 404659 404658 404658 404658 404658 404658 404658 404658 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330 202330...

Output: 81874655470

Input:
404663
404663 404661 404660 404660 404660 404660 404660 404660 404660 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331 202331...

Output: 81875464791

Input:
186906
373793 373792 124599 124600 124599 124600 124599 124600 124599 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598 124598...

Output: 23288113788

Input:
186907
373796 373795 124600 124601 124600 124601 124600 124601 124600 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599 124599...

Output: 23288425293

Input:
30
6 8 3 5 7 10 6 7 30 21 5 4 6 2 3 16 10 15 3 12 12 5 5 14 4 5 3 4 3 5

Output: 114

Input:
30
11 18 20 15 4 4 2 7 8 2 22 23 18 27 11 21 47 7 19 10 8 4 32 4 20 22 29 8 5 4

Output: 261


Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $$$p$$$ (which may be positive, negative, or zero). To combine their tastes, they invented $$$p$$$-binary numbers of the form $$$2^x + p$$$, where $$$x$$$ is a non-negative integer.For example, some $$$-9$$$-binary ("minus nine" binary) numbers are: $$$-8$$$ (minus eight), $$$7$$$ and $$$1015$$$ ($$$-8=2^0-9$$$, $$$7=2^4-9$$$, $$$1015=2^{10}-9$$$).The boys now use $$$p$$$-binary numbers to represent everything. They now face a problem: given a positive integer $$$n$$$, what's the smallest number of $$$p$$$-binary numbers (not necessarily distinct) they need to represent $$$n$$$ as their sum? It may be possible that representation is impossible altogether. Help them solve this problem.For example, if $$$p=0$$$ we can represent $$$7$$$ as $$$2^0 + 2^1 + 2^2$$$.And if $$$p=-9$$$ we can represent $$$7$$$ as one number $$$(2^4-9)$$$.Note that negative $$$p$$$-binary numbers are allowed to be in the sum (see the Notes section for an example).

If it is impossible to represent $$$n$$$ as the sum of any number of $$$p$$$-binary numbers, print a single integer $$$-1$$$. Otherwise, print the smallest possible number of summands.

Note$$$0$$$-binary numbers are just regular binary powers, thus in the first sample case we can represent $$$24 = (2^4 + 0) + (2^3 + 0)$$$.In the second sample case, we can represent $$$24 = (2^4 + 1) + (2^2 + 1) + (2^0 + 1)$$$.In the third sample case, we can represent $$$24 = (2^4 - 1) + (2^2 - 1) + (2^2 - 1) + (2^2 - 1)$$$. Note that repeated summands are allowed.In the fourth sample case, we can represent $$$4 = (2^4 - 7) + (2^1 - 7)$$$. Note that the second summand is negative, which is allowed.In the fifth sample case, no representation is possible.

The only line contains two integers $$$n$$$ and $$$p$$$ ($$$1 \leq n \leq 10^9$$$, $$$-1000 \leq p \leq 1000$$$).

Input: 24 0

Output: 2

Input: 24 1

Output: 3

Input: 24 -1

Output: 4

Input: 4 -7

Output: 2

Input: 1 1

Output: -1

Input: 10 7

Output: -1

Input: 3 -179

Output: 5

Input: 12345678 -123

Output: 12

Input: 1000000000 1000

Output: 16

Input: 1 0

Output: 1

Input: 1 -1

Output: 1

Input: 536870912 0

Output: 1

Input: 536870911 0

Output: 29

Input: 1 -1000

Output: 8

Input: 100500 -179

Output: 8

Input: 1000000000 -1000

Output: 14

Input: 536870812 1

Output: 24

Input: 536870812 -1

Output: 26

Input: 1 1000

Output: -1

Input: 1001 1000

Output: 1

Input: 13 -987

Output: 7

Input: 101 50

Output: -1

Input: 1001 500

Output: -1

Input: 13 6

Output: -1

Input: 5 2

Output: -1

Input: 67108838 -1

Output: 26

Input: 11 5

Output: -1

Input: 19 6

Output: -1

Input: 21 10

Output: -1

Input: 2001 1000

Output: -1

Input: 17 8

Output: -1

Input: 3002 1000

Output: -1

Input: 332639425 -399

Output: 13

Input: 9 8

Output: 1

Input: 3 2

Output: 1

Input: 678 169

Output: -1

Input: 2 1

Output: 1

Input: 9 4

Output: -1

Input: 29 9

Output: -1

Input: 782 156

Output: -1

Input: 1999 999

Output: -1

Input: 47 23

Output: -1

Input: 3998 999

Output: -1

Input: 4 3

Output: 1

Input: 746 248

Output: -1

Input: 2 -1000

Output: 8

Input: 35 11

Output: -1

Input: 16777215 0

Output: 24


The only difference between easy and hard versions is constraints.The BerTV channel every day broadcasts one episode of one of the $$$k$$$ TV shows. You know the schedule for the next $$$n$$$ days: a sequence of integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le k$$$), where $$$a_i$$$ is the show, the episode of which will be shown in $$$i$$$-th day.The subscription to the show is bought for the entire show (i.e. for all its episodes), for each show the subscription is bought separately.How many minimum subscriptions do you need to buy in order to have the opportunity to watch episodes of purchased shows $$$d$$$ ($$$1 \le d \le n$$$) days in a row? In other words, you want to buy the minimum number of TV shows so that there is some segment of $$$d$$$ consecutive days in which all episodes belong to the purchased shows.

Print $$$t$$$ integers — the answers to the test cases in the input in the order they follow. The answer to a test case is the minimum number of TV shows for which you need to purchase a subscription so that you can watch episodes of the purchased TV shows on BerTV for $$$d$$$ consecutive days. Please note that it is permissible that you will be able to watch more than $$$d$$$ days in a row.

NoteIn the first test case to have an opportunity to watch shows for two consecutive days, you need to buy a subscription on show $$$1$$$ and on show $$$2$$$. So the answer is two.In the second test case, you can buy a subscription to any show because for each show you can find a segment of three consecutive days, consisting only of episodes of this show.In the third test case in the unique segment of four days, you have four different shows, so you need to buy a subscription to all these four shows.In the fourth test case, you can buy subscriptions to shows $$$3,5,7,8,9$$$, and you will be able to watch shows for the last eight days.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then $$$t$$$ test case descriptions follow. The first line of each test case contains three integers $$$n, k$$$ and $$$d$$$ ($$$1 \le n \le 100$$$, $$$1 \le k \le 100$$$, $$$1 \le d \le n$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le k$$$), where $$$a_i$$$ is the show that is broadcasted on the $$$i$$$-th day. It is guaranteed that the sum of the values of $$$n$$$ for all test cases in the input does not exceed $$$100$$$.

Input:
4
5 2 2
1 2 1 2 1
9 3 3
3 3 3 2 2 2 1 1 1
4 10 4
10 8 6 4
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3

Output:
2
1
4
5

Output:
2
1
4
5

Input:
10000
4 4 1
4 3 3 1
9 1 7
1 1 1 1 1 1 1 1 1
1 7 1
4
3 7 3
7 1 2
3 6 2
4 5 6
8 7 3
6 3 5 7 3 6 4 3
5 6 2
2 3 6 3 4
1 7 1
5
4 4 1
3 1 3 1
7 2 4
2 1 1 1 1 2 1
4 5 1
1 5 4 1
9 10 1
7 4 4 4 6 3 7 10 7
3 8 1
6 4 3
1 7 1
4
5 7 5
7 5 3 5 5
5 10 2
5 10 9 10 1
2 2 1
2 2
6 10 4
4 10 5 1 7 2
7 10 2
8 5 7 3 2 2 4
2 9 1
8 3
3 10 3
1 2 9
10 9 1
7 2 4 3 4 1 5 8 8 7
9 4 5
2 2 3 2 4 4 1 1 2
6 9 2
6 2 3 1 9 9
5 8 1
5 2 1 5 8
9 5 3
3 1 5 2 1 2 2 4 1
6 10 1
8 6 4 10 10 10
...

Output:
1
1
1
3
2
3
2
1
1
1
1
1
1
1
3
2
1
4
1
1
3
1
3
1
1
2
1
1
1
5
1
1
3
4
1
3
3
1
2
1
2
2
1
2
1
1
1
5
4
2
1
2
1
2
2
3
2
1
1
2
4
2
2
3
5
2
1
5
2
1
2
1
3
1
1
1
1
1
1
1
3
1
2
1
1
2
1
1
2
1
4
1
1
3
1
1
1
3
1
1
2
1
2
4
1
3
3
1
1
2
1
3
1
2
2
1
1
2
2
1
4
1
1
3
3
3
1
1
2
2
2
1
1
1
2
1
3
1
1
1
1
1
1
1
1
1
3
4
6
3
1
1
1
2
3
1
1
1
2
1
1
4
1
3
1
3
1
1
1
1
2...

Input:
10000
25 2 1
1 2 2 1 2 2 2 2 2 2 2 1 1 1 2 2 2 1 2 2 1 1 1 2 1
24 27 19
19 2 15 17 4 8 20 13 1 2 19 2 6 9 22 16 17 20 23 25 26 8 6 24
4 10 1
10 7 7 9
11 15 1
2 2 6 3 3 5 11 15 8 12 3
19 20 3
10 8 8 9 8 6 1 8 20 10 9 18 20 16 4 12 9 10 2
22 8 11
5 3 5 1 7 7 2 4 6 4 5 8 6 1 3 7 2 7 2 5 7 6
16 4 6
1 1 4 3 2 1 2 1 3 3 2 3 3 3 3 2
19 25 5
14 18 2 11 14 12 15 16 21 11 16 12 17 7 18 23 2 3 4
26 16 1
2 14 12 14 5 6 5 6 15 11 9 7 15 3 3 4 8 13 1 4 4 8 3 1 12 9
19 13 9
11 2 3 13 6 8 7 2 6 3 9 7 1...

Output:
1
14
1
1
2
7
2
4
1
6
7
2
7
9
4
3
2
8
4
6
1
4
4
4
3
3
2
5
9
1
3
3
3
1
7
1
1
1
1
1
6
1
6
1
4
2
2
5
5
5
4
5
2
1
2
1
1
2
6
2
1
3
8
6
2
1
4
1
17
2
11
1
8
1
4
8
5
2
1
1
1
4
2
10
4
1
8
5
7
1
11
1
2
2
1
11
6
1
4
6
16
1
12
8
4
5
1
2
6
12
2
3
3
2
2
1
6
4
13
2
11
3
4
13
1
7
5
5
11
4
3
6
6
2
1
1
9
4
9
9
13
2
5
1
1
14
5
1
10
2
2
6
1
4
1
1
2
7
1
3
1
6
2
2
4
...

Input:
1
200000 50000 100000
43620 16520 24169 29319 35300 6092 8697 40998 15469 16541 45920 21696 48009 37549 35849 6966 45977 49376 47590 10302 36127 14270 35645 20850 15907 32338 30934 35216 32431 48365 11343 28651 42051 4611 3208 48408 8001 13308 3528 34450 48338 44549 214 35127 25599 21629 13920 49465 30152 33128 22087 20254 29457 18159 30113 18369 20976 35278 49478 42126 44353 31877 49348 4138 43970 17640 12092 38376 23575 4559 13202 45493 27767 29431 14560 2957 25933 37550 11475 36643 29624 38619 38461 3...

Output: 43168

Input:
1
200000 1 100000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

Output: 1

Input:
1
200000 10 100000
1 9 2 9 4 1 9 4 2 6 4 10 5 2 9 6 4 3 7 5 10 2 6 7 5 8 7 2 4 1 1 1 3 3 7 10 2 6 4 5 4 10 10 2 6 2 1 4 8 3 1 2 5 8 3 4 10 8 7 5 9 5 5 5 8 4 1 10 8 7 6 9 7 7 5 7 9 4 8 10 1 5 9 5 7 7 6 9 5 4 3 5 7 10 5 6 3 2 10 3 2 10 3 10 5 3 5 4 10 10 2 9 3 3 6 2 3 6 5 1 9 1 5 6 6 9 1 9 8 3 9 7 1 3 2 7 6 5 5 8 3 10 5 1 4 9 3 4 1 9 8 2 8 5 2 6 6 3 10 7 1 2 9 3 3 7 6 9 7 2 9 9 1 8 8 2 5 2 4 8 1 8 7 3 6 5 3 10 4 2 10 9 5 5 8 6 9 1 1 8 9 2 7 7 1 10 8 10 6 5 5 2 10 10 8 3 8 9 3 7 1 2 8 6 5 6 9 4 6 1 3 4 6 3 ...

Output: 10

Input:
1
200000 100 20000
56 54 36 40 73 78 52 47 66 20 77 100 36 93 23 31 59 97 74 29 58 88 27 97 37 81 15 20 89 75 8 61 52 78 1 26 86 7 63 46 21 74 39 72 38 77 68 82 97 84 79 96 65 47 42 45 70 66 28 58 81 34 81 14 52 73 75 74 87 65 82 63 56 86 56 99 32 24 18 20 60 25 97 77 28 49 53 7 35 21 10 74 34 95 30 5 4 77 69 49 81 2 5 50 32 72 50 9 7 44 15 80 70 45 39 69 12 5 61 84 33 10 88 32 94 91 24 22 49 88 99 38 30 30 1 96 27 60 4 84 89 3 21 70 21 39 69 11 28 7 17 39 71 30 19 33 91 93 26 45 6 86 61 57 80 91 5 28 64...

Output: 100

Input:
1
200000 999996 100000
1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96 101 106 111 116 121 126 131 136 141 146 151 156 161 166 171 176 181 186 191 196 201 206 211 216 221 226 231 236 241 246 251 256 261 266 271 276 281 286 291 296 301 306 311 316 321 326 331 336 341 346 351 356 361 366 371 376 381 386 391 396 401 406 411 416 421 426 431 436 441 446 451 456 461 466 471 476 481 486 491 496 501 506 511 516 521 526 531 536 541 546 551 556 561 566 571 576 581 586 591 596 601 606 611 616 621 626 631 ...

Output: 100000

Input:
1
200000 1000000 200000
1000000 999995 999990 999985 999980 999975 999970 999965 999960 999955 999950 999945 999940 999935 999930 999925 999920 999915 999910 999905 999900 999895 999890 999885 999880 999875 999870 999865 999860 999855 999850 999845 999840 999835 999830 999825 999820 999815 999810 999805 999800 999795 999790 999785 999780 999775 999770 999765 999760 999755 999750 999745 999740 999735 999730 999725 999720 999715 999710 999705 999700 999695 999690 999685 999680 999675 999670 999665 999660 9...

Output: 200000

Input:
1
200000 1000 100000
620 192 107 955 564 521 642 381 695 916 549 124 253 339 472 162 131 282 959 678 207 154 876 995 734 39 412 999 815 355 18 165 430 993 27 603 666 794 993 261 70 259 289 24 684 893 292 512 941 852 393 42 314 25 25 970 671 168 914 583 666 819 637 194 512 972 681 283 401 767 709 892 607 366 529 164 211 563 726 197 72 746 537 94 150 347 365 281 320 276 734 646 118 894 974 967 68 260 563 746 985 119 431 778 249 428 511 158 692 99 125 553 877 954 302 832 611 137 181 895 51 860 150 916 284 6...

Output: 1000

Input:
1
200000 100000 100000
8647 17914 36109 89778 78993 55133 74489 27482 57585 98271 77889 47476 26434 78910 72270 37433 77590 94218 26776 81236 7857 52297 75984 96580 13420 37206 57335 15966 38003 44862 95973 906 76808 94689 51811 80545 49598 60279 5137 72373 67166 84168 43937 97833 79109 97555 66522 57877 67492 14888 45878 78979 86655 76238 22212 32085 91951 14238 83686 38492 81248 57509 57652 11778 87283 25990 28664 96610 45117 5398 15632 33866 83494 31775 58512 71264 17548 46621 80189 6618 19549 76932 5...

Output: 62936

Input:
1
200000 1000000 200000
470364 225896 287028 539970 507065 834358 221882 79921 952537 675938 918775 600012 658158 451805 585924 200704 727836 877423 589359 95563 175804 737263 148093 693378 834010 564940 1442 668171 699064 243399 367947 932004 332361 500470 581460 457946 747126 822659 687570 763411 734109 359915 138955 532165 905740 554112 955385 526332 377610 359080 408012 320280 805135 892507 484900 811596 483912 864488 223962 260705 468 390385 483192 247665 841481 651754 428156 822508 897711 270750 80...

Output: 181244

Input:
1
200000 1000000 20000
533722 392695 889264 562461 855026 138921 815803 461194 257052 45665 831069 886688 652160 561837 516684 283787 634185 14587 677319 708000 762661 815073 509775 30098 637512 723030 819497 202814 848040 970165 882077 948960 348866 282945 296186 444252 966548 552732 274192 16694 895137 572174 815092 350234 717680 652165 545471 904085 37325 47183 763599 162009 423431 10401 212741 944445 276272 304020 763078 730235 106465 974498 982395 46321 795699 969837 135760 488480 863430 883321 2125...

Output: 19770

Input:
1
200000 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Output: 1

Input:
1
200000 1000000 1
780737 872203 852770 369033 859738 846341 851594 954282 684383 209632 798015 36250 376958 793324 203798 459743 621399 649416 45468 297431 261695 620652 512718 793583 992894 200416 98975 368684 265169 695427 834486 116518 889256 354565 349037 240328 345769 475500 788435 452690 948139 738003 87787 656919 874748 293479 823979 451391 310748 446952 936638 761542 417856 248622 69762 416315 588495 748898 540043 217410 102504 122304 887006 865619 229595 6236 653431 864185 887339 426521 687555 ...

Output: 1

Input:
1
200000 999996 1
1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96 101 106 111 116 121 126 131 136 141 146 151 156 161 166 171 176 181 186 191 196 201 206 211 216 221 226 231 236 241 246 251 256 261 266 271 276 281 286 291 296 301 306 311 316 321 326 331 336 341 346 351 356 361 366 371 376 381 386 391 396 401 406 411 416 421 426 431 436 441 446 451 456 461 466 471 476 481 486 491 496 501 506 511 516 521 526 531 536 541 546 551 556 561 566 571 576 581 586 591 596 601 606 611 616 621 626 631 636 6...

Output: 1

Input:
1
200000 999996 199999
1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96 101 106 111 116 121 126 131 136 141 146 151 156 161 166 171 176 181 186 191 196 201 206 211 216 221 226 231 236 241 246 251 256 261 266 271 276 281 286 291 296 301 306 311 316 321 326 331 336 341 346 351 356 361 366 371 376 381 386 391 396 401 406 411 416 421 426 431 436 441 446 451 456 461 466 471 476 481 486 491 496 501 506 511 516 521 526 531 536 541 546 551 556 561 566 571 576 581 586 591 596 601 606 611 616 621 626 631 ...

Output: 199999

Input:
10000
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 1000000 1
1
1 100000...

Output:
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

Input:
10000
20 1000000 5
50000 100000 150000 200000 250000 300000 350000 400000 450000 500000 550000 600000 650000 700000 750000 800000 850000 900000 950000 1000000
20 1000000 5
50000 100000 150000 200000 250000 300000 350000 400000 450000 500000 550000 600000 650000 700000 750000 800000 850000 900000 950000 1000000
20 1000000 5
50000 100000 150000 200000 250000 300000 350000 400000 450000 500000 550000 600000 650000 700000 750000 800000 850000 900000 950000 1000000
20 1000000 5
50000 100000 150000 20000...

Output:
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5...

Input:
10000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000
1 1000000 1
1000000...

Output:
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

Input:
10000
20 1000000 6
42 18468 6335 26501 19170 15725 11479 29359 26963 24465 5706 28146 23282 16828 9962 492 2996 11943 4828 5437
20 1000000 6
32392 14605 3903 154 293 12383 17422 18717 19719 19896 5448 21727 14772 11539 1870 19913 25668 26300 17036 9895
20 1000000 6
28704 23812 31323 30334 17674 4665 15142 7712 28254 6869 25548 27645 32663 32758 20038 12860 8724 9742 27530 779
20 1000000 6
12317 3036 22191 1843 289 30107 9041 8943 19265 22649 27447 23806 15891 6730 24371 15351 15007 31102 24394 3549...

Output:
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6...

Input:
10000
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
16 9 8
3 1 ...

Output:
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5...

Input:
1
6969 100 100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Output: 1

Input:
10000
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
1 1000000 1
777
...

Output:
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

Input:
30
4 4 1
3 3 1 2
4 4 1
4 1 4 1
1 1 1
1
3 2 1
2 1 2
4 4 2
3 2 2 2
4 2 4
1 2 2 2
1 4 1
4
2 3 1
2 3
2 2 1
2 2
4 4 2
1 2 4 2
4 4 1
2 4 4 3
4 3 1
1 3 1 3
1 1 1
1
2 2 2
2 1
2 4 1
1 4
2 4 1
3 4
1 2 1
1
2 4 2
2 1
3 1 2
1 1 1
2 4 1
1 4
2 3 1
3 3
4 2 2
2 1 2 2
3 2 2
2 2 1
4 3 1
2 2 1 2
2 3 1
1 3
4 4 4
3 2 2 3
1 4 1
1
2 1 2
1 1
1 4 1
4
2 3 1
3 3

Output:
1
1
1
1
1
2
1
1
1
2
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1

Output:
1
1
1
1
1
2
1
1
1
2
1
1
1
2
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1

Input:
15
6 4 6
2 3 2 3 4 2
7 8 4
5 6 2 7 7 3 3
8 1 5
1 1 1 1 1 1 1 1
1 5 1
1
2 7 2
6 7
6 8 4
8 5 4 1 6 6
1 8 1
2
3 8 2
2 3 3
2 2 1
1 1
8 2 5
2 2 1 1 1 1 1 1
7 6 4
2 4 1 1 2 4 3
8 8 2
6 5 6 1 3 1 2 8
5 6 1
6 1 2 6 2
6 5 5
1 5 2 4 4 5
7 1 6
1 1 1 1 1 1 1

Output:
3
2
1
1
2
3
1
1
1
1
3
2
1
3
1

Output:
3
2
1
1
2
3
1
1
1
1
3
2
1
3
1

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

Output:
3
3
4
2
4
2
2
4
1
1

Output:
3
3
4
2
4
2
2
4
1
1

Input:
5
17 10 1
8 5 10 7 4 7 2 9 8 10 7 2 6 5 1 1 5
22 13 5
1 9 12 4 6 1 8 10 1 11 1 2 1 6 8 12 11 8 10 6 2 12
13 25 7
22 7 19 12 7 17 7 6 22 19 5 5 23
1 6 1
6
1 15 1
7

Output:
1
3
5
1
1

Output:
1
3
5
1
1

Input:
1
100 90 100
8 39 60 46 68 2 42 45 7 54 89 78 16 59 21 29 5 30 20 12 64 42 34 33 13 17 55 30 54 31 23 27 38 36 2 49 45 43 47 55 4 6 55 38 60 16 34 86 67 76 55 86 39 62 12 58 74 51 10 31 38 85 50 61 48 35 69 24 64 53 4 19 15 35 28 22 88 3 25 60 9 40 67 47 26 57 58 61 65 21 76 4 15 35 37 49 62 45 81 32

Output: 67

Input:
1
100 100 100
100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

Output: 100

Input:
1
100 50 100
22 28 34 29 43 8 12 12 4 29 36 38 22 5 19 38 4 41 20 33 39 11 2 40 42 8 33 23 20 47 45 30 47 33 27 23 50 26 30 43 8 3 4 38 46 32 20 19 10 3 18 29 21 19 37 30 12 38 27 44 24 39 25 18 50 44 37 22 39 41 18 26 37 40 40 16 38 9 12 36 27 31 45 47 31 31 29 48 25 7 29 24 10 2 8 3 36 48 8 9

Output: 42

Input:
1
100 1 100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output: 1

Input:
1
100 10 100
9 2 2 3 5 2 2 3 4 9 5 3 6 2 1 4 4 8 6 2 3 10 4 1 5 2 8 8 3 9 2 7 2 3 4 2 2 8 9 7 10 3 7 7 4 4 8 8 9 7 1 8 10 3 6 8 1 9 4 6 5 6 9 2 9 6 7 10 5 8 7 10 6 1 9 2 10 10 10 9 6 5 6 9 2 8 1 2 2 5 6 6 3 3 7 10 10 1 6 3

Output: 10

Input:
1
100 2 100
2 1 2 2 1 2 2 1 1 2 2 2 2 2 1 1 1 1 2 1 1 1 2 2 2 1 1 1 2 1 1 1 1 2 1 1 1 1 2 2 2 2 1 2 2 1 2 1 1 1 1 2 2 2 1 1 2 1 2 2 2 2 1 1 1 2 1 1 1 1 1 2 1 2 1 2 1 2 1 1 2 1 1 2 1 1 1 1 1 1 1 2 1 2 1 2 2 2 1 2

Output: 2

Input:
1
100 16 100
1 11 2 2 13 8 3 15 8 11 13 1 16 16 3 5 12 10 11 16 1 14 16 8 14 3 15 8 2 8 10 1 16 14 8 4 2 10 3 8 3 5 8 10 4 12 11 8 8 15 16 5 7 6 3 9 15 7 1 14 14 2 13 4 10 6 12 13 9 8 9 2 9 3 2 12 9 3 8 11 14 9 3 3 15 10 12 10 10 16 2 12 13 7 6 7 13 1 14 15

Output: 16

Input:
1
100 100 50
40 23 65 71 63 65 82 49 42 62 80 68 30 97 95 11 19 16 50 33 99 40 100 88 7 52 83 80 68 30 32 40 67 16 45 89 54 88 9 42 40 65 96 97 9 100 53 84 40 40 66 13 47 30 71 14 83 18 35 70 73 52 17 91 87 59 81 5 84 94 1 9 23 90 32 91 69 77 38 84 38 74 6 26 100 47 39 23 84 90 67 86 67 80 31 51 71 97 69 68

Output: 34

Input:
1
100 100 33
78 92 82 75 58 98 94 39 38 88 89 78 2 95 53 47 74 95 14 92 49 44 8 67 31 77 90 20 16 92 19 32 26 75 81 4 79 46 21 44 5 19 64 72 13 9 74 58 84 62 70 86 77 4 39 97 1 67 98 99 89 34 29 13 24 2 69 68 30 66 77 16 26 49 1 25 89 26 28 25 96 55 51 44 10 7 36 75 12 81 31 46 52 55 48 78 82 95 39 44

Output: 28

Input:
1
100 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output: 1

Input:
1
100 20 1
10 17 9 8 11 8 8 3 7 20 11 10 7 7 2 13 10 7 7 10 7 8 4 17 20 9 5 18 12 8 3 5 19 1 18 14 9 11 12 11 11 12 12 9 13 8 20 3 8 1 15 20 6 18 8 1 13 11 4 17 12 15 4 4 11 19 18 5 2 12 15 20 5 8 11 16 14 13 17 14 14 5 6 8 8 13 6 3 18 14 8 14 11 11 9 4 18 1 16 6

Output: 1

Input:
1
100 20 2
18 1 3 1 13 1 3 15 3 2 7 14 1 8 1 10 1 1 9 18 11 6 9 12 17 5 6 7 13 14 9 4 6 14 7 14 19 6 13 10 7 2 17 3 10 11 11 7 2 4 9 12 11 6 20 20 4 16 7 10 8 4 19 18 2 4 6 5 20 2 12 6 20 20 18 7 11 20 10 2 8 5 16 4 19 17 18 9 7 9 13 10 3 12 18 2 6 12 18 10

Output: 1

Input:
1
100 100 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Output: 1

Input:
1
100 100 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Output: 2

Input:
1
100 100 10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Output: 10

Input:
1
100 100 99
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Output: 99

Input:
1
100 100 100
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Output: 100

Input:
1
100 100 1
100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

Output: 1

Input:
1
100 100 2
100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

Output: 2

Input:
1
100 100 3
100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

Output: 3

Input:
1
100 100 99
100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

Output: 99


Your program fails again. This time it gets "Wrong answer on test 233".This is the harder version of the problem. In this version, $$$1 \le n \le 2\cdot10^5$$$. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems.The problem is to finish $$$n$$$ one-choice-questions. Each of the questions contains $$$k$$$ options, and only one of them is correct. The answer to the $$$i$$$-th question is $$$h_{i}$$$, and if your answer of the question $$$i$$$ is $$$h_{i}$$$, you earn $$$1$$$ point, otherwise, you earn $$$0$$$ points for this question. The values $$$h_1, h_2, \dots, h_n$$$ are known to you in this problem.However, you have a mistake in your program. It moves the answer clockwise! Consider all the $$$n$$$ answers are written in a circle. Due to the mistake in your program, they are shifted by one cyclically.Formally, the mistake moves the answer for the question $$$i$$$ to the question $$$i \bmod n + 1$$$. So it moves the answer for the question $$$1$$$ to question $$$2$$$, the answer for the question $$$2$$$ to the question $$$3$$$, ..., the answer for the question $$$n$$$ to the question $$$1$$$.We call all the $$$n$$$ answers together an answer suit. There are $$$k^n$$$ possible answer suits in total.You're wondering, how many answer suits satisfy the following condition: after moving clockwise by $$$1$$$, the total number of points of the new answer suit is strictly larger than the number of points of the old one. You need to find the answer modulo $$$998\,244\,353$$$.For example, if $$$n = 5$$$, and your answer suit is $$$a=[1,2,3,4,5]$$$, it will submitted as $$$a'=[5,1,2,3,4]$$$ because of a mistake. If the correct answer suit is $$$h=[5,2,2,3,4]$$$, the answer suit $$$a$$$ earns $$$1$$$ point and the answer suite $$$a'$$$ earns $$$4$$$ points. Since $$$4 > 1$$$, the answer suit $$$a=[1,2,3,4,5]$$$ should be counted.

Output one integer: the number of answers suits satisfying the given condition, modulo $$$998\,244\,353$$$.

The first line contains two integers $$$n$$$, $$$k$$$ ($$$1 \le n \le 2\cdot10^5$$$, $$$1 \le k \le 10^9$$$) — the number of questions and the number of possible answers to each question. The following line contains $$$n$$$ integers $$$h_1, h_2, \dots, h_n$$$, ($$$1 \le h_{i} \le k)$$$ — answers to the questions.

Input:
3 3
1 3 1

Output: 9

Input:
5 5
1 1 4 2 2

Output: 1000

Input:
6 2
1 1 2 2 1 1

Output: 16

Input:
15 10
1 5 5 6 2 4 9 7 2 4 8 7 8 8 9

Output: 809573316

Input:
100 100
82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 9 3 55 37 85 46 22 84 52 98 41 21 77 63 17 62 91

Output: 490987641

Input:
200000 1000000000
580970703 454399803 656715015 482989922 956780431 123139627 293564365 512661288 914941210 364578624 941205521 124687247 674601481 488146057 173334239 632631141 362284792 313184184 248508805 487251295 947672840 803940002 400265751 866588821 24148576 766057409 351568365 730513156 787832999 225621173 743686688 887386123 841349516 776980670 902806032 674397422 282439487 378224964 463416800 209940823 184116469 554304592 462399224 292200400 69240679 563390736 659347587 238730825 20665171 83952...

Output: 975873204

Input:
10 100000
48997 48997 22146 22146 22146 22146 22146 22146 22146 48997

Output: 921332324

Input:
200000 1000000000
651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 651131309 65...

Output: 109797225

Input:
200000 2
1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1...

Output: 180444414

Input:
1 1
1

Output: 0

Input:
200000 1000000000
459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 459428075 45...

Output: 0

Input:
200000 2
2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2...

Output: 926556038

Input:
3000 3000
181 2205 1265 2445 465 746 1043 2042 1422 2065 1796 1483 1245 2460 2559 221 1812 1552 1827 837 322 1062 1778 1633 2716 2101 236 2128 2683 734 906 2333 2188 951 2667 1312 2230 2489 2586 1132 7 2258 901 706 1616 1700 376 2437 2756 1140 2240 2325 2765 620 1289 1916 343 1129 417 1099 1699 2597 2962 2374 2638 342 971 2388 2919 1598 2648 2720 964 1065 414 1931 862 850 2968 2775 2800 878 2493 589 1108 1167 31 1616 374 810 349 768 2327 345 1786 1905 2019 1602 2156 2721 2459 2159 917 2429 1148 2548 2830 ...

Output: 199835884

Input:
200000 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

Output: 0

Input:
200000 2
2 1 1 2 2 1 1 2 1 1 1 2 2 1 1 1 1 2 1 2 1 1 2 2 1 1 2 2 1 2 1 1 2 1 1 1 1 2 1 1 1 1 1 2 1 2 1 1 1 2 1 1 2 2 2 2 1 1 2 2 1 1 2 1 1 1 1 2 1 1 2 1 1 1 1 1 2 1 1 2 2 1 2 1 1 1 1 1 2 2 1 1 1 2 1 1 1 2 1 2 2 2 2 2 1 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 1 2 2 1 1 1 2 1 1 2 1 1 1 1 2 1 1 1 1 2 2 2 2 2 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 2 2 2 1 1 1 2 2 2 2 2 1 1 1 2 2 1 1 1 1 2 1 2 1 1 2 2 2 2 1 1 2 1 1 1 2 2 2 2 1 1 2 1 2 1 1 1 2 1 1 1 2 2 1 2 1 2 2 2 1 2 1 2 2 1 2 1 1 1 1 1 2 1 1 1 2 1 2 2 1 1 1 2 2 2 1 2 1 2 1...

Output: 606640172

Input:
200000 10
2 1 1 1 3 1 10 8 4 3 7 1 8 2 2 3 7 10 7 2 9 4 6 8 9 3 6 3 9 2 7 6 7 1 1 7 6 6 5 5 6 5 4 10 1 8 1 3 10 3 6 9 3 3 1 8 7 10 2 3 10 3 10 2 2 7 2 5 3 10 4 6 4 6 6 4 6 10 8 4 1 9 4 10 9 7 2 4 9 3 7 3 1 4 5 3 10 8 9 8 9 1 8 1 9 6 3 5 9 2 2 6 7 2 9 2 8 9 8 3 9 4 10 5 5 2 1 8 3 8 4 1 8 2 6 1 7 7 8 5 7 5 6 10 1 2 2 4 5 3 7 2 4 3 3 7 5 9 8 9 9 5 5 4 10 9 9 5 6 3 2 6 1 2 1 7 5 6 6 4 6 5 6 1 7 5 6 8 1 1 1 1 5 3 8 3 4 3 4 5 1 6 5 8 7 1 2 1 3 3 1 1 9 6 9 6 2 3 4 3 1 6 4 1 3 6 4 1 9 1 5 3 1 9 3 10 4 6 4 2 9 5 1...

Output: 765986981

Input:
200000 10
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 ...

Output: 619770013

Input:
200000 1000
384 384 384 447 202 202 202 498 498 498 498 567 567 567 567 567 567 661 661 94 727 727 70 70 70 70 70 70 70 70 70 323 323 323 323 323 323 323 323 323 56 654 157 899 899 354 354 347 347 313 113 746 746 254 254 675 675 675 561 561 561 561 284 284 284 284 284 297 758 335 470 470 470 854 854 805 805 805 805 805 805 805 805 805 933 282 282 282 215 515 515 515 985 985 985 135 844 844 57 57 636 636 636 636 897 176 176 176 176 387 387 116 116 741 741 724 724 724 835 835 538 538 574 574 574 574 574 574...

Output: 946453012

Input:
200000 2
2 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 1 1 1 1 1 2 2 2 2 2 2 2 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 1 1 1 2 2 2 2 2 2 2 2 2 2 2 1 1 2 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 2 2 1 1...

Output: 478453610

Input:
199999 1000000000
542493651 907318041 633473282 575693632 937794057 290783159 648922590 128290555 979072570 386408161 320538458 913749502 326071812 824830280 96390599 240935421 226881415 265277379 207987256 965552912 380380649 682873803 759135492 210577459 419273683 15073279 588033606 80682951 519379955 233376930 448455261 390635535 468706680 126333976 658109548 311729076 438759577 644061549 956678363 323675714 383606030 548714189 855946708 68279976 147966613 181321229 183575495 211207100 646470511 887877...

Output: 825365344

Input:
199999 1000000000
479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 479280576 47...

Output: 817060183

Input:
199999 1000000000
521379924 76529682 49724842 679495519 98019070 48836423 487999610 571547332 210588499 418305368 198547533 72635181 256460420 48691070 316475496 800021302 753859849 689097686 331071380 162063003 495889692 461748703 75895454 937545407 231646526 299060477 596025559 661157160 237621938 767990010 529138836 250939904 256490493 545680512 579337647 313610902 386669933 923476383 27146244 580123611 570923406 584242765 92643317 820568294 408849846 233869538 929323751 870208880 187531386 981904536 8...

Output: 696482707


You have $$$n \times n$$$ square grid and an integer $$$k$$$. Put an integer in each cell while satisfying the conditions below.  All numbers in the grid should be between $$$1$$$ and $$$k$$$ inclusive.  Minimum number of the $$$i$$$-th row is $$$1$$$ ($$$1 \le i \le n$$$).  Minimum number of the $$$j$$$-th column is $$$1$$$ ($$$1 \le j \le n$$$). Find the number of ways to put integers in the grid. Since the answer can be very large, find the answer modulo $$$(10^{9} + 7)$$$.  These are the examples of valid and invalid grid when $$$n=k=2$$$.

Print the answer modulo $$$(10^{9} + 7)$$$.

NoteIn the first example, following $$$7$$$ cases are possible.  In the second example, make sure you print the answer modulo $$$(10^{9} + 7)$$$.

The only line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 250$$$, $$$1 \le k \le 10^{9}$$$).

Input: 2 2

Output: 7

Input: 123 456789

Output: 689974806

Input: 250 1000000000

Output: 770503193

Input: 250 1

Output: 1

Input: 1 3

Output: 1

Input: 3 497285769

Output: 790515254

Input: 3 212096267

Output: 501206544

Input: 4 221874066

Output: 274467242

Input: 244 315404017

Output: 868949606

Input: 218 325181815

Output: 230476135

Input: 246 629926913

Output: 283598434

Input: 216 639704712

Output: 319243107

Input: 244 22597665

Output: 56808536

Input: 218 737408162

Output: 720936813

Input: 242 747185961

Output: 365665959

Input: 220 51931060

Output: 944377763

Input: 244 61708858

Output: 84446310

Input: 216 104981514

Output: 943178465

Input: 208 1

Output: 1

Input: 236 1

Output: 1

Input: 242 106758452

Output: 437620405

Input: 216 411503551

Output: 618370501

Input: 244 126314049

Output: 662993833

Input: 214 431059147

Output: 37643610

Input: 242 440836946

Output: 687163955

Input: 220 528762598

Output: 944995733

Input: 244 833507696

Output: 89218992

Input: 218 548318195

Output: 721573920

Input: 242 558095993

Output: 300047623

Input: 224 26911790

Output: 554883010

Input: 206 1

Output: 1

Input: 234 1

Output: 1

Input: 10 19549

Output: 843886139


Ania has a large integer $$$S$$$. Its decimal representation has length $$$n$$$ and doesn't contain any leading zeroes. Ania is allowed to change at most $$$k$$$ digits of $$$S$$$. She wants to do it in such a way that $$$S$$$ still won't contain any leading zeroes and it'll be minimal possible. What integer will Ania finish with?

Output the minimal possible value of $$$S$$$ which Ania can end with. Note that the resulting integer should also have $$$n$$$ digits.

NoteA number has leading zeroes if it consists of at least two digits and its first digit is $$$0$$$. For example, numbers $$$00$$$, $$$00069$$$ and $$$0101$$$ have leading zeroes, while $$$0$$$, $$$3000$$$ and $$$1010$$$ don't have leading zeroes.

The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq n \leq 200\,000$$$, $$$0 \leq k \leq n$$$) — the number of digits in the decimal representation of $$$S$$$ and the maximum allowed number of changed digits. The second line contains the integer $$$S$$$. It's guaranteed that $$$S$$$ has exactly $$$n$$$ digits and doesn't contain any leading zeroes.

Input:
5 3
51528

Output: 10028

Input:
3 2
102

Output: 100

Input:
1 1
1

Output: 0

Input:
8 3
76185080

Output: 10085080

Input:
10 9
6605076924

Output: 1000000000

Input:
17 14
70419129275429261

Output: 10000000000000061

Input:
1 0
1

Output: 1

Input:
1 1
0

Output: 0

Input:
2 1
16

Output: 10

Input:
1 0
0

Output: 0

Input:
1 0
7

Output: 7

Input:
1 1
9

Output: 0

Input:
5 4
39837

Output: 10007

Input:
50 30
57206210120809502631460958076295309729525641641207

Input:
2 2
10

Output: 10

Input:
5 5
10000

Output: 10000

Input:
1 1
5

Output: 0

Input:
2 2
99

Output: 10

Input:
5 5
55555

Output: 10000

Input:
3 3
123

Output: 100

Input:
1 1
2

Output: 0

Input:
4 4
1111

Output: 1000

Input:
4 4
1234

Output: 1000

Input:
5 5
11111

Output: 10000

Input:
5 5
12345

Output: 10000

Input:
2 1
99

Output: 19

Input:
6 6
123456

Output: 100000

Input:
1 0
5

Output: 5

Input:
5 5
56789

Output: 10000

Input:
3 3
555

Output: 100

Input:
3 3
185

Output: 100

Input:
3 3
888

Output: 100

Input:
5 5
99999

Output: 10000

Input:
5 5
11234

Output: 10000

Input:
4 4
9999

Output: 1000

Input:
1 1
8

Output: 0

Input:
5 5
51528

Output: 10000

Input:
3 3
100

Output: 100

Input:
6 2
123456

Output: 100456

Input:
2 2
11

Output: 10

Input:
3 3
999

Output: 100

Input:
5 5
65412

Output: 10000

Input:
3 3
111

Output: 100

Input:
4 4
5555

Output: 1000

Input:
10 5
1000054300

Output: 1000000000

Input:
5 5
54321

Output: 10000

Input:
3 3
300

Output: 100

Input:
1 1
3

Output: 0

Input:
1 0
2

Output: 2


Dawid has four bags of candies. The $$$i$$$-th of them contains $$$a_i$$$ candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of candies in total?Note, that you can't keep bags for yourself or throw them away, each bag should be given to one of the friends.

Output YES if it's possible to give the bags to Dawid's friends so that both friends receive the same amount of candies, or NO otherwise. Each character can be printed in any case (either uppercase or lowercase).

NoteIn the first sample test, Dawid can give the first and the third bag to the first friend, and the second and the fourth bag to the second friend. This way, each friend will receive $$$12$$$ candies.In the second sample test, it's impossible to distribute the bags.

The only line contains four integers $$$a_1$$$, $$$a_2$$$, $$$a_3$$$ and $$$a_4$$$ ($$$1 \leq a_i \leq 100$$$) — the numbers of candies in each bag.

Input: 1 7 11 5

Output: YES

Input: 7 3 2 5

Output: NO

Input: 3 14 36 53

Output: YES

Input: 30 74 41 63

Output: YES

Input: 92 69 83 97

Output: NO

Input: 26 52 7 19

Output: YES

Input: 72 52 62 62

Output: YES

Input: 1 1 1 1

Output: YES

Input: 70 100 10 86

Output: NO

Input: 14 10 18 24

Output: NO

Input: 20 14 37 71

Output: YES

Input: 1 1 2 1

Output: NO

Input: 2 4 1 1

Output: YES

Input: 34 11 84 39

Output: YES

Input: 76 97 99 74

Output: YES

Input: 44 58 90 53

Output: NO

Input: 18 88 18 18

Output: NO

Input: 48 14 3 31

Output: YES

Input: 72 96 2 26

Output: YES

Input: 69 7 44 30

Output: NO

Input: 66 68 16 82

Output: NO

Input: 100 100 100 100

Output: YES

Input: 100 98 99 97

Output: YES

Input: 1 100 100 1

Output: YES

Input: 100 100 99 100

Output: NO

Input: 99 100 3 98

Output: NO

Input: 4 4 4 5

Output: NO

Input: 2 6 3 2

Output: NO

Input: 7 3 6 3

Output: NO

Input: 14 9 10 6

Output: NO

Input: 2 4 6 6

Output: NO

Input: 4 2 4 2

Output: YES

Input: 4 4 4 8

Output: NO

Input: 6 4 8 6

Output: YES

Input: 97 95 91 27

Output: NO

Input: 1 2 3 2

Output: YES

Input: 1 2 8 9

Output: YES

Input: 5 10 1 6

Output: YES

Input: 1 2 3 5

Output: NO

Input: 3 5 1 3

Output: YES

Input: 1 2 3 3

Output: NO

Input: 1 1 14 12

Output: YES

Input: 1 1 1 2

Output: NO

Input: 6 3 6 6

Output: NO

Input: 10 2 3 5

Output: YES

Input: 1 2 10 7

Output: YES

Input: 3 1 1 1

Output: YES

Input: 1 2 5 5

Output: NO

Input: 2 3 10 10

Output: NO

Input: 2 2 4 6

Output: NO

Input: 1 1 10 20

Output: NO

Input: 1 1 3 1

Output: YES

Input: 1 2 1 3

Output: NO

Input: 18 17 17 20

Output: NO

Input: 3 2 1 1

Output: NO

Input: 1 1 4 5

Output: NO

Input: 90 30 30 30

Output: YES

Input: 1 2 6 3

Output: YES

Input: 2 3 3 4

Output: YES

Input: 1 1 4 2

Output: YES

Input: 1 1 2 3

Output: NO

Input: 1 1 3 4

Output: NO

Input: 2 1 28 9

Output: NO

Input: 1 2 3 4

Output: YES

Input: 1 2 4 5

Output: YES

Input: 2 2 6 2

Output: YES

Input: 2 3 2 5

Output: NO

Input: 5 7 1 3

Output: YES

Input: 4 4 12 4

Output: YES

Input: 1 2 2 7

Output: NO


You are given $$$a$$$ uppercase Latin letters 'A' and $$$b$$$ letters 'B'.The period of the string is the smallest such positive integer $$$k$$$ that $$$s_i = s_{i~mod~k}$$$ ($$$0$$$-indexed) for each $$$i$$$. Note that this implies that $$$k$$$ won't always divide $$$a+b = |s|$$$.For example, the period of string "ABAABAA" is $$$3$$$, the period of "AAAA" is $$$1$$$, and the period of "AABBB" is $$$5$$$.Find the number of different periods over all possible strings with $$$a$$$ letters 'A' and $$$b$$$ letters 'B'.

Print the number of different periods over all possible strings with $$$a$$$ letters 'A' and $$$b$$$ letters 'B'.

NoteAll the possible periods for the first example:   $$$3$$$ "BBABBA"  $$$4$$$ "BBAABB"  $$$5$$$ "BBBAAB"  $$$6$$$ "AABBBB" All the possible periods for the second example:   $$$3$$$ "BAABAABA"  $$$5$$$ "BAABABAA"  $$$6$$$ "BABAAABA"  $$$7$$$ "BAABAAAB"  $$$8$$$ "AAAAABBB" Note that these are not the only possible strings for the given periods.

The first line contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$) — the number of letters 'A' and 'B', respectively.

Input: 2 4

Output: 4

Input: 5 3

Output: 5

Input: 1 1

Output: 1

Input: 1 2

Output: 2

Input: 2 1

Output: 2

Input: 1000000000 1

Output: 500000001

Input: 1 1000000000

Output: 500000001

Input: 1000000000 1000000000

Output: 1999936805

Input: 49464524 956817411

Output: 1006177186

Input: 917980664 839933539

Output: 1757835091

Input: 491529509 18016963

Output: 509460797

Input: 65078353 196100387

Output: 261146454

Input: 933594493 374183811

Output: 1307707417

Input: 1000000000 956817411

Output: 1956733985

Input: 1000000000 839933539

Output: 1839852485

Input: 1000000000 18016963

Output: 1017851489

Input: 1 122878623

Output: 61439312

Input: 1 300962047

Output: 150481024

Input: 1 479045471

Output: 239522736

Input: 956817411 1000000000

Output: 1956733985

Input: 839933539 1000000000

Output: 1839852485

Input: 18016963 1000000000

Output: 1017851489

Input: 804463085 1

Output: 402231543

Input: 982546509 1

Output: 491273255

Input: 865662637 1

Output: 432831319

Input: 500000000 515868890

Output: 1015808858

Input: 500000000 693952314

Output: 1193887001

Input: 500000000 577068442

Output: 1077006614

Input: 97590986 500000000

Output: 597537504

Input: 275674410 500000000

Output: 775621118

Input: 453757834 500000000

Output: 953699599

Input: 310973933 310973932

Output: 621912604

Input: 194090061 194090063

Output: 388152264

Input: 728340333 728340331

Output: 1456626719

Input: 611471244 611471251

Output: 1222892906

Input: 943610807 943610806

Output: 1887160182

Input: 486624528 486624569

Output: 973204768

Input: 355140669 355140562

Output: 710242885

Input: 370754498 370754723

Output: 741469514

Input: 310973932 310973933

Output: 621912604

Input: 194090063 194090061

Output: 388152264

Input: 728340331 728340333

Output: 1456626719

Input: 611471251 611471244

Output: 1222892906

Input: 943610806 943610807

Output: 1887160182

Input: 486624569 486624528

Output: 973204768

Input: 355140562 355140669

Output: 710242885

Input: 370754723 370754498

Output: 741469514

Input: 1 3

Output: 2

Input: 3 1

Output: 2

Input: 2 2

Output: 3

Input: 1 4

Output: 3

Input: 2 3

Output: 4

Input: 3 2

Output: 4

Input: 4 1

Output: 3


The only difference between easy and hard versions is the length of the string.You are given a string $$$s$$$ and a string $$$t$$$, both consisting only of lowercase Latin letters. It is guaranteed that $$$t$$$ can be obtained from $$$s$$$ by removing some (possibly, zero) number of characters (not necessary contiguous) from $$$s$$$ without changing order of remaining characters (in other words, it is guaranteed that $$$t$$$ is a subsequence of $$$s$$$).For example, the strings "test", "tst", "tt", "et" and "" are subsequences of the string "test". But the strings "tset", "se", "contest" are not subsequences of the string "test".You want to remove some substring (contiguous subsequence) from $$$s$$$ of maximum possible length such that after removing this substring $$$t$$$ will remain a subsequence of $$$s$$$.If you want to remove the substring $$$s[l;r]$$$ then the string $$$s$$$ will be transformed to $$$s_1 s_2 \dots s_{l-1} s_{r+1} s_{r+2} \dots s_{|s|-1} s_{|s|}$$$ (where $$$|s|$$$ is the length of $$$s$$$).Your task is to find the maximum possible length of the substring you can remove so that $$$t$$$ is still a subsequence of $$$s$$$.

Print one integer — the maximum possible length of the substring you can remove so that $$$t$$$ is still a subsequence of $$$s$$$.

The first line of the input contains one string $$$s$$$ consisting of at least $$$1$$$ and at most $$$200$$$ lowercase Latin letters. The second line of the input contains one string $$$t$$$ consisting of at least $$$1$$$ and at most $$$200$$$ lowercase Latin letters. It is guaranteed that $$$t$$$ is a subsequence of $$$s$$$.

Input:
bbaba
bb

Output: 3

Input:
baaba
ab

Output: 2

Input:
abcde
abcde

Output: 0

Input:
asdfasdf
fasd

Output: 3

Output: 5

Output: 101

Output: 199

Output: 150

Output: 21

Output: 6

Output: 8

Output: 198

Input:
m
m

Output: 0

Input:
td
t

Output: 1

Input:
ipz
z

Output: 2

Input:
cel
c

Output: 2

Output: 4

Output: 101

Output: 199

Output: 150

Output: 21

Output: 4

Output: 7

Output: 198

Output: 4

Output: 100

Output: 199

Output: 151

Output: 20

Output: 5

Output: 5

Output: 198

Output: 11

Output: 100000

Output: 199999

Output: 150002

Output: 2001

Output: 12

Output: 12

Output: 198000

Output: 12

Output: 100004

Output: 199998

Output: 150005

Output: 202

Output: 22

Output: 52

Output: 19800

Output: 12

Output: 10001

Output: 199997

Output: 150005

Output: 20924

Output: 11

Output: 11

Output: 19897

Input:
npynh
nnh

Output: 2

Input:
aa
a

Output: 1

Input:
abcc
acc

Output: 1

Output: 180

Input:
tsypkoisgayandsuckedhisdadsdick
tsypkoisgay

Output: 20

Output: 100

Output: 100

Input:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa

Output: 27

Output: 99

Output: 0

Output: 100

Output: 109

Output: 111


In the city of Saint Petersburg, a day lasts for $$$2^{100}$$$ minutes. From the main station of Saint Petersburg, a train departs after $$$1$$$ minute, $$$4$$$ minutes, $$$16$$$ minutes, and so on; in other words, the train departs at time $$$4^k$$$ for each integer $$$k \geq 0$$$. Team BowWow has arrived at the station at the time $$$s$$$ and it is trying to count how many trains have they missed; in other words, the number of trains that have departed strictly before time $$$s$$$. For example if $$$s = 20$$$, then they missed trains which have departed at $$$1$$$, $$$4$$$ and $$$16$$$. As you are the only one who knows the time, help them!Note that the number $$$s$$$ will be given you in a binary representation without leading zeroes.

Output a single number — the number of trains which have departed strictly before the time $$$s$$$.

NoteIn the first example $$$100000000_2 = 256_{10}$$$, missed trains have departed at $$$1$$$, $$$4$$$, $$$16$$$ and $$$64$$$.In the second example $$$101_2 = 5_{10}$$$, trains have departed at $$$1$$$ and $$$4$$$.The third example is explained in the statements.

The first line contains a single binary number $$$s$$$ ($$$0 \leq s < 2^{100}$$$) without leading zeroes.


Mislove had an array $$$a_1$$$, $$$a_2$$$, $$$\cdots$$$, $$$a_n$$$ of $$$n$$$ positive integers, but he has lost it. He only remembers the following facts about it: The number of different numbers in the array is not less than $$$l$$$ and is not greater than $$$r$$$; For each array's element $$$a_i$$$ either $$$a_i = 1$$$ or $$$a_i$$$ is even and there is a number $$$\dfrac{a_i}{2}$$$ in the array.For example, if $$$n=5$$$, $$$l=2$$$, $$$r=3$$$ then an array could be $$$[1,2,2,4,4]$$$ or $$$[1,1,1,1,2]$$$; but it couldn't be $$$[1,2,2,4,8]$$$ because this array contains $$$4$$$ different numbers; it couldn't be $$$[1,2,2,3,3]$$$ because $$$3$$$ is odd and isn't equal to $$$1$$$; and it couldn't be $$$[1,1,2,2,16]$$$ because there is a number $$$16$$$ in the array but there isn't a number $$$\frac{16}{2} = 8$$$.According to these facts, he is asking you to count the minimal and the maximal possible sums of all elements in an array.

Output two numbers — the minimal and the maximal possible sums of all elements in an array.

NoteIn the first example, an array could be the one of the following: $$$[1,1,1,2]$$$, $$$[1,1,2,2]$$$ or $$$[1,2,2,2]$$$. In the first case the minimal sum is reached and in the last case the maximal sum is reached.In the second example, the minimal sum is reached at the array $$$[1,1,1,1,1]$$$, and the maximal one is reached at the array $$$[1,2,4,8,16]$$$.

The only input line contains three integers $$$n$$$, $$$l$$$ and $$$r$$$ ($$$1 \leq n \leq 1\,000$$$, $$$1 \leq l \leq r \leq \min(n, 20)$$$) — an array's size, the minimal number and the maximal number of distinct elements in an array.

Input: 4 2 2

Output: 5 7

Input: 5 1 5

Output: 5 31

Input: 106 16 18

Output: 65625 11796479

Input: 114 18 19

Output: 262239 25427967

Input: 655 3 18

Output: 659 83755007

Input: 1000 1 20

Output: 1000 514850815

Input: 1000 20 20

Output: 1049555 514850815

Input: 1 1 1

Output: 1 1

Input: 588 13 15

Output: 8766 9420799

Input: 408 13 13

Output: 8586 1626111

Input: 879 17 17

Output: 131933 56623103

Input: 17 2 14

Output: 18 40959

Input: 624 7 17

Output: 744 39911423

Input: 1000 1 1

Output: 1000 1000


Natasha's favourite numbers are $$$n$$$ and $$$1$$$, and Sasha's favourite numbers are $$$m$$$ and $$$-1$$$. One day Natasha and Sasha met and wrote down every possible array of length $$$n+m$$$ such that some $$$n$$$ of its elements are equal to $$$1$$$ and another $$$m$$$ elements are equal to $$$-1$$$. For each such array they counted its maximal prefix sum, probably an empty one which is equal to $$$0$$$ (in another words, if every nonempty prefix sum is less to zero, then it is considered equal to zero). Formally, denote as $$$f(a)$$$ the maximal prefix sum of an array $$$a_{1, \ldots ,l}$$$ of length $$$l \geq 0$$$. Then: $$$$$$f(a) = \max (0, \smash{\displaystyle\max_{1 \leq i \leq l}} \sum_{j=1}^{i} a_j )$$$$$$Now they want to count the sum of maximal prefix sums for each such an array and they are asking you to help. As this sum can be very large, output it modulo $$$998\: 244\: 853$$$.

Output the answer to the problem modulo $$$998\: 244\: 853$$$.

The only line contains two integers $$$n$$$ and $$$m$$$ ($$$0 \le n,m \le 2\,000$$$).

Input: 0 2

Output: 0

Input: 2 0

Output: 2

Input: 2 2

Output: 5

Input: 2000 2000

Output: 674532367

Input: 0 0

Output: 0

Input: 11 2

Output: 716

Input: 1 4

Output: 1

Input: 5 13

Output: 4048

Input: 60 59

Output: 271173738

Input: 27 16

Output: 886006554

Input: 1134 1092

Output: 134680101

Input: 756 1061

Output: 72270489

Input: 953 1797

Output: 557692333

Input: 76 850

Output: 103566263

Input: 24 1508

Output: 540543518

Input: 1087 1050

Output: 973930225

Input: 149 821

Output: 64450770

Input: 983 666

Output: 917123830

Input: 45 1323

Output: 357852234

Input: 1994 1981

Output: 596939902

Input: 1942 1523

Output: 89088577

Input: 1891 1294

Output: 696966158

Input: 1132 1727

Output: 878164775

Input: 1080 383

Output: 161999131

Input: 1028 1040

Output: 119840364

Input: 976 1698

Output: 621383232

Input: 38 656

Output: 814958661

Input: 872 1313

Output: 261808476

Input: 1935 856

Output: 707458926

Input: 1883 1513

Output: 265215482

Input: 0 2000

Output: 0

Input: 2000 0

Output: 2000

Input: 1991 1992

Output: 518738831

Input: 1935 1977

Output: 16604630

Input: 1990 2000

Output: 516468539

Input: 1915 1915

Output: 534527105