QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#89593#4577. Kingdom PartitionyouwikeAC ✓4ms5824kbC++142.2kb2023-03-20 18:12:012023-03-20 18:12:03

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3604kb

input:

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

output:

16
ABBCBA

result:

ok [n = 6, m = 7] 16

Test #2:

score: 0
Accepted
time: 2ms
memory: 3532kb

input:

3 2
3 2
1 2 3
3 1 2

output:

4
ABA

result:

ok [n = 3, m = 2] 4

Test #3:

score: 0
Accepted
time: 0ms
memory: 3472kb

input:

3 3
1 2
2 3 17
2 1 8
3 1 16

output:

32
ABA

result:

ok [n = 3, m = 3] 32

Test #4:

score: 0
Accepted
time: 2ms
memory: 3524kb

input:

4 6
1 4
4 3 14
4 1 1
1 3 5
2 1 8
4 2 2
3 2 17

output:

14
ABAB

result:

ok [n = 4, m = 6] 14

Test #5:

score: 0
Accepted
time: 2ms
memory: 3544kb

input:

5 10
4 2
5 1 1
2 3 18
5 4 11
2 1 9
4 2 7
4 1 20
4 3 11
5 2 11
3 1 10
3 5 3

output:

64
BBAAB

result:

ok [n = 5, m = 10] 64

Test #6:

score: 0
Accepted
time: 1ms
memory: 3532kb

input:

6 10
2 6
5 1 16
4 5 20
1 3 1
3 5 10
4 2 19
4 3 20
5 2 13
6 3 9
4 1 17
1 2 20

output:

61
CACCCB

result:

ok [n = 6, m = 10] 61

Test #7:

score: 0
Accepted
time: 2ms
memory: 3524kb

input:

7 10
3 2
1 2 16
6 7 15
6 1 17
6 2 14
2 7 10
2 4 14
1 3 19
3 2 8
7 5 7
4 6 4

output:

60
BBAAAAB

result:

ok [n = 7, m = 10] 60

Test #8:

score: 0
Accepted
time: 2ms
memory: 3540kb

input:

8 10
2 1
4 5 3
4 2 1
6 2 2
1 5 16
1 8 16
4 8 19
3 2 11
4 3 14
7 8 17
3 8 12

output:

28
BABBABBA

result:

ok [n = 8, m = 10] 28

Test #9:

score: 0
Accepted
time: 2ms
memory: 5580kb

input:

9 10
7 9
3 8 18
7 8 7
8 1 20
3 1 9
3 9 20
5 8 10
6 1 10
9 6 5
4 8 10
1 9 7

output:

28
ACAAABABB

result:

ok [n = 9, m = 10] 28

Test #10:

score: 0
Accepted
time: 2ms
memory: 3584kb

input:

10 10
7 5
4 5 15
4 7 4
1 5 6
7 9 5
8 4 1
4 2 10
3 10 14
6 5 7
6 2 11
1 10 19

output:

8
ABAABAABBB

result:

ok [n = 10, m = 10] 8

Test #11:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

11 10
1 8
9 2 18
4 5 15
2 8 14
11 3 4
8 9 20
2 6 13
6 4 2
4 3 3
7 3 17
1 11 10

output:

28
ABABAABBACB

result:

ok [n = 11, m = 10] 28

Test #12:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

10 16
5 6
7 6 28
5 9 27
5 1 23
5 10 15
1 6 21
5 8 20
3 6 25
4 6 30
8 6 29
5 4 15
5 2 29
2 6 23
5 3 29
10 6 27
9 6 17
5 7 18

output:

308
BBBAABAABA

result:

ok [n = 10, m = 16] 308

Test #13:

score: 0
Accepted
time: 2ms
memory: 3616kb

input:

40 76
40 27
7 27 56
16 27 55
4 27 59
31 27 72
35 27 84
40 36 63
40 32 65
20 27 66
40 4 54
1 27 53
40 22 80
40 12 58
37 27 73
40 6 69
32 27 87
34 27 75
13 27 65
40 17 75
40 5 90
40 1 95
10 27 70
40 3 68
33 27 100
17 27 67
19 27 82
12 27 64
40 14 94
5 27 84
40 39 94
40 34 66
40 11 53
18 27 97
40 37 82...

output:

5228
BAAABBBBAABABBACBAABAABAABBBAABAAAAABBBA

result:

ok [n = 40, m = 76] 5228

Test #14:

score: 0
Accepted
time: 2ms
memory: 5592kb

input:

40 48
7 12
7 26 88
21 12 60
7 5 57
16 12 99
22 12 91
7 16 90
7 3 53
7 35 83
7 15 57
23 12 97
31 12 57
25 12 54
7 8 88
27 12 54
7 21 94
39 12 85
7 25 82
1 12 96
7 17 76
10 12 78
38 12 84
7 30 67
7 31 79
7 4 80
7 33 65
3 12 63
37 12 77
7 28 99
7 36 64
4 12 59
17 12 92
7 20 64
40 12 57
7 34 82
7 29 82
...

output:

1838
ACABBBABBACBAAAAACCBBAABBBABABBBBBBBBAAA

result:

ok [n = 40, m = 48] 1838

Test #15:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

100 196
19 7
89 7 8953
70 7 9889
43 7 5719
19 26 6071
91 7 7849
46 7 8438
19 73 9138
8 7 9519
10 7 7677
69 7 5781
19 31 5948
76 7 7398
19 52 7646
25 7 6984
50 7 8264
100 7 9196
99 7 6509
19 42 9167
93 7 5838
19 27 6315
84 7 6255
19 45 5713
55 7 7563
44 7 7774
61 7 8876
19 57 5009
19 60 6306
13 7 809...

output:

1291946
BBABABBAAAABAAAABAABBBABBAABABABABBABBBABBBAAABBBBBAABBBAAAAABBAAABBBABBABABBBBBBABBABBAAABABBBBBAAB

result:

ok [n = 100, m = 196] 1291946

Test #16:

score: 0
Accepted
time: 2ms
memory: 3672kb

input:

100 67
97 58
97 52 6017
97 96 8763
97 14 9794
72 58 5042
92 58 8871
97 8 8621
97 38 8861
90 58 5775
97 61 6908
97 56 8734
97 12 6305
19 58 7839
97 45 5315
97 35 8133
97 31 5478
97 76 9501
12 58 8731
97 62 8205
97 19 8281
63 58 6094
97 85 9946
8 58 8815
87 58 7804
94 58 6176
97 77 7537
74 58 7891
10 ...

output:

148202
AABACABABACABBCCABBAABCBCCACCABACCBACBCCBBCBBCCCCCCBCCCBCBCCBBAACCACCACACACBBCBABCCCBCBCAABACABBACAA

result:

ok [n = 100, m = 67] 148202

Test #17:

score: 0
Accepted
time: 4ms
memory: 3772kb

input:

1000 1000
41 597
412 976 111983911
74 134 695911031
85 895 206857769
11 224 660317608
719 626 166619419
299 938 695578901
667 20 814230500
816 835 416428362
704 533 607179657
104 134 722785538
447 717 990111707
518 347 185913196
182 344 303670623
901 997 888151744
378 162 551452030
540 629 658075907...

output:

2672497774
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCACCCCCACCCCCCCCCACCCCACCCCCCCCCCCCCCCCCACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCCC...

result:

ok [n = 1000, m = 1000] 2672497774

Test #18:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

2 0
1 2

output:

0
AB

result:

ok [n = 2, m = 0] 0

Test #19:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

2 1
1 2
2 1 4987

output:

0
AB

result:

ok [n = 2, m = 1] 0

Test #20:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

1000 1000
41 597
412 976 1000000000
911 74 1000000000
134 31 1000000000
85 895 1000000000
769 11 1000000000
224 608 1000000000
719 626 1000000000
419 299 1000000000
938 901 1000000000
667 20 1000000000
500 816 1000000000
835 362 1000000000
704 533 1000000000
657 104 1000000000
134 538 1000000000
447...

output:

8000000000
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok [n = 1000, m = 1000] 8000000000

Test #21:

score: 0
Accepted
time: 4ms
memory: 5824kb

input:

1000 2000
299 333
253 95 1000000000
914 230 1000000000
233 132 1000000000
591 105 1000000000
510 163 1000000000
222 690 1000000000
514 891 1000000000
839 323 1000000000
866 406 1000000000
840 442 1000000000
442 838 1000000000
817 376 1000000000
303 902 1000000000
350 459 1000000000
662 973 100000000...

output:

8000000000
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok [n = 1000, m = 2000] 8000000000

Test #22:

score: 0
Accepted
time: 3ms
memory: 5708kb

input:

3 3
3 2
1 2 85
3 2 35
1 3 163

output:

170
BBA

result:

ok [n = 3, m = 3] 170

Test #23:

score: 0
Accepted
time: 2ms
memory: 3516kb

input:

4 4
4 3
2 1 53
4 3 163
1 3 187
1 4 145

output:

290
ABBA

result:

ok [n = 4, m = 4] 290

Test #24:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

5 8
3 5
1 2 199
2 4 15
4 1 19
2 3 44
3 5 71
4 5 13
5 2 23
4 3 36

output:

102
ABABB

result:

ok [n = 5, m = 8] 102

Test #25:

score: 0
Accepted
time: 2ms
memory: 3536kb

input:

6 10
2 6
3 2 192
6 4 160
4 5 140
3 1 45
2 4 142
1 4 42
6 2 42
1 5 42
6 3 187
6 1 30

output:

711
CACCCB

result:

ok [n = 6, m = 10] 711

Test #26:

score: 0
Accepted
time: 2ms
memory: 3496kb

input:

7 10
3 1
7 5 58
6 3 70
1 2 144
6 5 55
4 1 154
4 3 148
7 6 54
5 4 122
3 5 39
2 4 172

output:

494
BAABABB

result:

ok [n = 7, m = 10] 494

Test #27:

score: 0
Accepted
time: 2ms
memory: 3524kb

input:

8 10
6 7
1 5 21
3 2 188
2 1 51
1 7 161
6 4 10
3 5 164
1 6 120
2 5 35
3 7 68
4 7 51

output:

330
ABAABABC

result:

ok [n = 8, m = 10] 330

Test #28:

score: 0
Accepted
time: 2ms
memory: 3588kb

input:

9 10
9 1
7 2 88
3 8 195
5 2 46
5 8 74
6 5 7
9 2 188
8 7 43
6 8 180
6 7 130
6 1 63

output:

197
BBCCCCCCA

result:

ok [n = 9, m = 10] 197

Test #29:

score: 0
Accepted
time: 2ms
memory: 3516kb

input:

10 10
8 6
6 2 123
5 7 26
1 6 112
10 6 131
2 8 188
7 8 61
6 9 6
8 3 62
9 3 192
10 3 94

output:

246
ABBCABBAAA

result:

ok [n = 10, m = 10] 246

Test #30:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

11 10
3 4
4 10 103
10 6 81
11 1 74
11 2 66
3 7 57
3 10 101
8 3 129
6 1 156
2 9 42
5 6 29

output:

202
AAABABBBBAB

result:

ok [n = 11, m = 10] 202

Test #31:

score: 0
Accepted
time: 2ms
memory: 3540kb

input:

3 2
1 2
2 1 20
1 3 13

output:

0
ABB

result:

ok [n = 3, m = 2] 0

Test #32:

score: 0
Accepted
time: 2ms
memory: 3480kb

input:

4 5
1 2
1 4 12
3 4 8
4 2 9
1 3 19
1 2 12

output:

24
ABBA

result:

ok [n = 4, m = 5] 24

Test #33:

score: 0
Accepted
time: 2ms
memory: 3536kb

input:

5 9
5 3
1 3 9
5 4 11
2 5 12
4 1 20
1 5 2
4 3 16
3 2 4
4 2 14
2 1 18

output:

54
CCBCA

result:

ok [n = 5, m = 9] 54

Test #34:

score: 0
Accepted
time: 2ms
memory: 3552kb

input:

6 13
3 5
4 6 11
6 5 19
1 3 7
1 6 13
3 6 14
4 1 3
5 4 4
2 6 13
5 1 5
2 1 13
3 5 1
4 2 8
3 4 13

output:

62
CCACBC

result:

ok [n = 6, m = 13] 62

Test #35:

score: 0
Accepted
time: 2ms
memory: 3604kb

input:

7 20
6 3
7 3 12
1 6 20
7 6 20
4 7 11
1 5 4
5 7 16
5 4 3
6 4 20
2 7 7
1 3 14
4 1 7
6 3 13
6 2 18
3 2 7
1 7 4
3 5 20
2 1 3
5 2 14
5 6 17
4 2 1

output:

148
CCBCCAC

result:

ok [n = 7, m = 20] 148

Test #36:

score: 0
Accepted
time: 2ms
memory: 5632kb

input:

8 20
4 5
8 7 9
2 4 1
2 5 15
5 7 17
2 7 8
6 3 16
4 6 4
8 6 4
5 1 18
6 7 19
4 3 4
2 3 20
8 4 19
3 1 2
2 1 20
3 8 1
7 4 2
3 5 8
5 8 17
6 1 14

output:

88
ABAABBAB

result:

ok [n = 8, m = 20] 88

Test #37:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

9 20
9 5
6 9 11
6 4 8
3 8 20
6 5 18
7 2 9
8 2 13
2 6 9
9 2 8
2 3 7
8 5 10
3 1 11
4 2 5
6 3 18
2 1 10
8 1 1
4 9 19
9 8 18
9 7 17
9 5 3
3 4 14

output:

93
CCCCBCBCA

result:

ok [n = 9, m = 20] 93

Test #38:

score: 0
Accepted
time: 2ms
memory: 3588kb

input:

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

output:

54
CABCBCCCCC

result:

ok [n = 10, m = 20] 54

Test #39:

score: 0
Accepted
time: 2ms
memory: 5580kb

input:

11 20
8 4
11 5 15
4 2 7
2 11 1
11 3 17
8 2 10
2 10 11
6 8 20
5 2 11
7 5 15
9 3 12
7 1 20
4 5 8
7 4 9
7 8 2
3 10 5
6 2 17
1 11 18
2 7 6
3 5 6
11 9 6

output:

53
CCCBCBCACCC

result:

ok [n = 11, m = 20] 53

Test #40:

score: 0
Accepted
time: 0ms
memory: 5656kb

input:

100 1000
23 4
81 35 13411
4 43 8687
40 7 11214
82 31 11941
44 75 7341
45 21 11316
84 45 10643
88 75 13172
85 26 9333
12 7 17204
10 76 17508
53 26 6136
1 31 6124
35 3 11409
39 20 11052
22 1 2910
30 1 9591
99 71 16579
55 50 14508
60 86 14377
58 75 16626
63 80 5941
53 51 9943
98 36 3051
9 32 19914
65 8...

output:

324410
CCCBCCCCCCCCCCCCCCCCCCACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

result:

ok [n = 100, m = 1000] 324410

Test #41:

score: 0
Accepted
time: 2ms
memory: 3744kb

input:

50 1000
44 46
29 28 14593
28 27 14272
27 6 8822
6 28 9113
1 19 2426
49 42 10198
3 45 17726
19 37 15539
4 2 8222
4 37 12992
19 39 3363
21 31 2447
28 42 8759
13 45 2460
33 20 14607
28 4 12478
39 22 8244
16 47 909
31 36 1330
41 30 19412
12 49 16004
46 13 2905
40 47 4031
38 14 19082
4 47 3038
37 3 9291
...

output:

739601
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCACBCCCC

result:

ok [n = 50, m = 1000] 739601

Test #42:

score: 0
Accepted
time: 4ms
memory: 5656kb

input:

50 1000
32 6
45 24 162825298
24 15 562845820
7 21 100373311
49 1 292184058
26 7 311922681
32 37 183526840
31 8 61832956
3 40 443301169
31 46 146971596
5 16 143708838
44 34 814163587
38 18 615669834
38 3 49742744
30 2 679253423
6 34 47835122
50 29 379684721
16 32 153841454
29 35 435578145
47 5 206228...

output:

40436523387
CCCCCBCCCCCCCCCCCCCCCCCCCCCCCCCACCCCCCCCCCCCCCCCCC

result:

ok [n = 50, m = 1000] 40436523387

Test #43:

score: 0
Accepted
time: 2ms
memory: 3752kb

input:

699 1000
440 298
539 58 15687
668 283 14393
304 539 19515
637 424 19247
40 311 6743
110 574 9832
1 58 18020
665 319 15556
518 604 19043
332 487 11994
63 575 13754
560 428 4706
302 659 2047
97 685 11362
303 325 19620
216 394 3483
589 106 12196
270 404 3124
122 381 8781
164 156 14823
678 260 14286
676...

output:

18687
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok [n = 699, m = 1000] 18687

Test #44:

score: 0
Accepted
time: 3ms
memory: 5696kb

input:

1000 1000
761 70
556 541 14086
748 518 1120
395 459 1377
484 667 12787
385 168 3154
69 524 15401
778 159 10261
175 879 11676
508 87 19387
498 332 2167
163 882 18900
780 511 8995
207 863 12542
223 252 14068
216 284 2606
682 882 372
980 846 13118
181 362 10127
272 274 15863
979 450 8801
397 929 7936
9...

output:

29877
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCCCCCCCCACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok [n = 1000, m = 1000] 29877

Test #45:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

1000 100
495 787
627 876 5232
646 752 15260
617 786 18509
37 47 16581
569 137 11109
626 105 2898
159 839 15700
59 455 2622
518 327 764
47 765 11872
710 749 11583
929 579 5861
906 429 15037
226 555 14542
610 636 19248
582 315 4684
294 954 12837
73 195 19993
139 286 2812
689 25 17593
97 115 2083
726 6...

output:

0
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok [n = 1000, m = 100] 0

Test #46:

score: 0
Accepted
time: 2ms
memory: 3688kb

input:

1000 500
656 950
302 935 19789
716 905 6696
370 894 1025
36 886 2486
856 845 19372
408 458 16546
278 445 1723
557 709 4120
311 85 6034
468 752 3349
217 179 19308
219 329 10016
981 898 13717
191 847 12072
605 664 10789
681 486 863
692 578 10718
871 429 8471
225 706 1544
469 167 15098
68 944 14891
604...

output:

0
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCCCCCCCC...

result:

ok [n = 1000, m = 500] 0

Test #47:

score: 0
Accepted
time: 1ms
memory: 3784kb

input:

1000 1000
575 344
932 302 51206
664 496 108734
168 912 146586
133 743 120290
38 671 192857
303 220 127944
778 162 122161
419 352 191763
270 92 148478
838 632 31904
705 929 73766
32 270 24697
87 370 108218
965 545 9368
296 298 143755
558 455 178013
20 264 86794
300 105 77586
886 350 192099
110 423 18...

output:

184895
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok [n = 1000, m = 1000] 184895

Test #48:

score: 0
Accepted
time: 1ms
memory: 4024kb

input:

1000 2000
264 40
703 846 36944
782 307 91698
675 717 183092
342 187 184634
435 857 191653
864 232 79967
410 668 107630
137 999 185786
764 810 104781
911 621 134259
41 260 36609
695 285 26290
282 864 90709
336 408 122696
155 439 114285
505 228 188959
874 390 27217
359 488 149087
343 633 145592
65 799...

output:

510580
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCACCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok [n = 1000, m = 2000] 510580

Test #49:

score: 0
Accepted
time: 4ms
memory: 3912kb

input:

1000 2000
299 333
253 95 96814914
230 233 431872132
591 105 409541510
163 222 97465690
514 891 504910839
323 866 490905406
840 442 238133442
838 817 852449376
303 902 736089350
459 662 877627973
993 980 519838322
111 246 875479690
378 419 158354974
422 152 923578077
908 301 760645803
782 483 3494385...

output:

5984027496
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok [n = 1000, m = 2000] 5984027496

Test #50:

score: 0
Accepted
time: 2ms
memory: 3572kb

input:

1000 15
624 755
624 211 845709224
624 239 605539639
624 530 766192229
624 778 805304224
530 755 692997697
890 755 885176845
624 613 871690477
507 755 824974042
940 755 542561199
7 755 532744184
624 747 691399246
778 755 622988345
233 755 707066590
624 700 955316634
624 666 652675255

output:

2631972084
CCCCCCACCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCBCCCCCCCCCCCCCCCCCCCCCACCCCCBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

result:

ok [n = 1000, m = 15] 2631972084

Test #51:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

1000 207
368 303
682 303 985359201
780 303 632246702
30 303 800495266
523 303 646500869
517 303 790034078
74 303 681132766
123 303 837069331
368 1000 789146263
479 303 943766096
368 466 512472924
368 6 605405611
368 280 744999517
368 489 708637846
368 257 791548901
368 92 690603985
368 539 759782102...

output:

17397287620
CCCCCBCCCCCCCBCCBBACCCCCCCCCCACACCCCCCBBCCCACCCCAACCCBCCCCCCCCAACCCBCCCCCACCCCCCCCCBBCBCCACBCCCCCBACCCCCCCACCACCCCCCCCBCBAACCCBBCCCCCBACCCACCCCBCCCCCCCCBCCCCCCBCCCBBCBCCBCCACACCCBCCCCCBCCBCCCCCCCCCCCCCCCCCCBCBCCCCCCCCABACBCCCCCACCCCACCCCCCCCCCCCACCCCCCCCBCBCCCCCCCACCCCCCCCCCCCCCBCCCCCCCC...

result:

ok [n = 1000, m = 207] 17397287620

Test #52:

score: 0
Accepted
time: 2ms
memory: 3812kb

input:

1000 614
920 992
941 992 786932505
920 181 886197906
831 992 831267609
920 205 585494559
262 992 889156602
224 992 569138522
795 992 982194258
920 244 886440593
920 106 527633941
920 463 755802393
920 476 566203424
920 247 824258659
920 298 841037137
975 992 658463621
920 424 579402687
543 992 61782...

output:

123427880252
BABCCBCCBCBCCABCBBCBCACCCCABBCCCACABACCCCCABCCACBABCACBCABABACAACCCBCCCCCAACCCACACAABCBACCAAACCAABCCCACAAAAACCAAACCBBABCCACCCCCCBCABCCCCABBBABACBCCACABACCACABCBCABABACAAACBCCACCCCABCCCCBCBCCCAABABCCACBCCCAACBCABCABCACBCABACAABACCBCBCBACBBCCCCBBBABACACBCBBBBBBBCABCBABBBCCBACBABAACCCABACC...

result:

ok [n = 1000, m = 614] 123427880252

Test #53:

score: 0
Accepted
time: 3ms
memory: 5752kb

input:

1000 1014
768 784
768 590 948575426
768 219 516102390
768 692 919731005
768 663 996565982
768 488 900617904
651 784 602063303
768 646 788382834
113 784 649934111
768 242 723473743
788 784 969842181
214 784 714964052
768 766 817241193
526 784 510776739
503 784 683307010
550 784 844739975
330 784 5924...

output:

356501853268
BCCBABCCAABBCACABBABBAAAABBCCAACAACACCCBBBBBBCABACABBACBAABBCCBCBCBCABCAACBACABABBAAACBCCAAACABABBABBCBACABACCCBBCBCBBBABCCBBABBCCBABABAABCAAABBBACBACCABCACBAABCBABAABAAABBACABCCCBBBACABBABBAABBAABBBCCCACCBBABABBBACBBCBCCBCABAABCCBCCCABBABABBBCBAAACABBAABCCCAACBABBBABAABAACBAACABAABBBBB...

result:

ok [n = 1000, m = 1014] 356501853268

Test #54:

score: 0
Accepted
time: 3ms
memory: 3864kb

input:

1000 1436
320 473
763 473 728607103
320 164 718287984
320 36 758599623
320 895 781658931
243 473 546587458
590 473 985673335
320 776 915798895
320 123 538430898
195 473 523521644
320 658 595327292
320 646 744190836
932 473 531604055
320 197 510156725
320 306 964820080
509 473 857843935
320 804 68468...

output:

693752522566
CBCAABAABBBABABBBBBABABAAAAABABABABBAABBBAAABBBBBCBBABBBABBACAABAABABAABAAACAABCBBBCBBABBBBBBABACABABBBACABABABCBABBABAAAAAAAAAABBABBAABABAAAAAAABAAAABBAAAAAABAABBBABBBBABBBAAAAABBBBBBAABAAABABABBAABABAAABABAABBAAAAAAABCABCABABACCAABBBBBBBCABBCBBBBBABABBBBAABBABAAAABBABABBAABBBCABBBABAB...

result:

ok [n = 1000, m = 1436] 693752522566

Test #55:

score: 0
Accepted
time: 1ms
memory: 3884kb

input:

1000 1785
168 458
168 781 680648279
168 424 818986533
913 458 690249838
941 458 865663881
168 803 716059726
168 718 958224260
168 877 600148167
440 458 558382555
168 944 695927956
394 458 503110667
168 671 570682929
649 458 836070607
753 458 990494112
168 573 512020816
168 532 742382108
123 458 5208...

output:

1066345357520
BBBABBBBBAAAABAABBABABAAABABBABABABBBBBBAABBABAAAABBABBAABABAABBBABBAABABBAABAABBAABBAABBBABBAABBBBBBBBABBBBAAAABAABABBAABAAABBABABABBBBCAABBBBBABBABABABABABBBAAAAAAAAABAAABBAAABBABABAABAABBABAABABBAABBBAABABBBABAAABBBBBAABBAAABBAABAABBAAAABBABBBAABABBBAABABAAAABAABACAABBBBABABABABBAAB...

result:

ok [n = 1000, m = 1785] 1066345357520

Test #56:

score: 0
Accepted
time: 0ms
memory: 4060kb

input:

1000 1891
73 404
935 404 670523677
964 404 549325534
73 587 552956469
73 973 954106570
739 404 685267854
73 260 647659548
73 644 906055964
403 404 817598904
887 404 726497013
73 607 585368178
73 590 824321204
73 737 526037692
263 404 537368380
73 180 887694979
161 404 822736455
445 404 753999563
73 ...

output:

1207364325906
ABAAAABBBBBBAAABBBABAAAABBAAABABABBABAABABAABAAABABBABABBAAABBBBBABABBABAAABABBBBABBAABBBAAAAABAAABBBBBAAAAAAAAAABBBABABBBABABBABBABBAAAABAAAAABBBBABBABABAAAAAAABBBBBBABABBBBAABBABAABAAAABABBABABBBAABABAAABBBBABBBBAABBABBBBAABBABABBABBABBBABAAAABAAABABBAABAAAAABBABBAABBBABAABABABBBAAAB...

result:

ok [n = 1000, m = 1891] 1207364325906

Test #57:

score: 0
Accepted
time: 3ms
memory: 5772kb

input:

1000 1996
189 303
189 139 547965275
602 303 857535940
189 218 584538527
821 303 683926039
189 903 728691325
189 742 588494506
313 303 873486937
189 970 805181423
189 291 533598562
189 398 866943984
646 303 918042236
368 303 642904182
596 303 632888266
189 342 616077386
963 303 699396410
189 722 9385...

output:

1343864053202
AAABABBBBAAAAAABBBABABABBAAABBBBAABBAAABBABBBABABABABABBABAAABBABAABAABBBBABAABABBBAABBAAABABAABBABBBABBBAABBABBBABBABBBBAABAAAAAABABBBBBBAABBABBABBBBBAABBABBBAABAABABAAABBABBBAABBABABAABBABBBABBABBAABBBBBBBBBBAABAABAAABABBABABBBABABBAABBABBABAABBBBAAAAAAABBAABBAABABAABBAABAABAAAAAABAB...

result:

ok [n = 1000, m = 1996] 1343864053202