Moamen and Ezzat are playing a game. They create an array $$$a$$$ of $$$n$$$ non-negative integers where every element is less than $$$2^k$$$.Moamen wins if $$$a_1 \,\&\, a_2 \,\&\, a_3 \,\&\, \ldots \,\&\, a_n \ge a_1 \oplus a_2 \oplus a_3 \oplus \ldots \oplus a_n$$$.Here $$$\&$$$ denotes the bitwise AND operation, and $$$\oplus$$$ denotes the bitwise XOR operation.Please calculate the number of winning for Moamen arrays $$$a$$$.As the result may be very large, print the value modulo $$$1\,000\,000\,007$$$ ($$$10^9 + 7$$$).

For each test case, print a single value — the number of different arrays that Moamen wins with. Print the result modulo $$$1\,000\,000\,007$$$ ($$$10^9 + 7$$$).

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 5$$$)— the number of test cases.  Each test case consists of one line containing two integers $$$n$$$ and $$$k$$$ ($$$1 \le n\le 2\cdot 10^5$$$, $$$0 \le k \le 2\cdot 10^5$$$).

Input:
3
3 1
2 1
4 0

Output:
5
2
1

Output:
5
2
1

Output:
5

2
1

Output:
5
2
1

Output:
5
2
1

Output:
5
2
1

Output:
5
2
1

Output:
5

2

1

Output:
5
2
1

Output:
5
2
1

Output:
5
2
1

Input:
5
200000 200000
24567 23423
1 200000
200000 1
200000 0

Output:
226490044
470587519
175895282
87947641
1

Output:
226490044
470587519
175895282
87947641
1

Output:
226490044
470587519
175895282
87947641
1

Output:
226490044
470587519
175895282
87947641
1

Output:
226490044
470587519
175895282
87947641
1

Output:
226490044
470587519
175895282
87947641
1

Output:
226490044
470587519
175895282
87947641
1

Output:
226490044
470587519
175895282
87947641
1

Output:
226490044
470587519
175895282
87947641
1

Input:
5
2 200000
199991 200000
100000 1024
1024 0
200000 2048

Output:
4428492
573667126
741012999
1
386630993

Output:
4428492
573667126
741012999
1
386630993

Output:
4428492
573667126
741012999
1
386630993

Output:
4428492
573667126
741012999
1
386630993

Output:
4428492
573667126
741012999
1
386630993

Output:
4428492
573667126
741012999
1
386630993

Output:
4428492
573667126
741012999
1
386630993

Output:
4428492
573667126
741012999
1
386630993

Input:
5
199991 200000
199992 200000
199992 200000
199992 200000
199996 200000

Output:
573667126
913020909
913020909
913020909
41788052

Output:
573667126
913020909
913020909
913020909
41788052

Output:
573667126
913020909
913020909
913020909
41788052

Output:
573667126
913020909
913020909
913020909
41788052

Output:
573667126
913020909
913020909
913020909
41788052

Output:
573667126
913020909
913020909
913020909
41788052

Output:
573667126
913020909
913020909
913020909
41788052

Output:
573667126
913020909
913020909
913020909
41788052

Input:
5
200000 200000
200000 200000
200000 200000
200000 200000
200000 200000

Output:
226490044
226490044
226490044
226490044
226490044

Output:
226490044
226490044
226490044
226490044
226490044

Output:
226490044
226490044
226490044
226490044
226490044

Output:
226490044
226490044
226490044
226490044
226490044

Output:
226490044
226490044
226490044
226490044
226490044

Output:
226490044
226490044
226490044
226490044
226490044

Output:
226490044
226490044
226490044
226490044
226490044

Output:
226490044
226490044
226490044
226490044
226490044

Input:
5
60522 167713
36426 133836
48772 148202
133447 125228
103497 63591

Output:
418576030
232137381
395057418
5669223
765611330

Output:
418576030
232137381
395057418
5669223
765611330

Output:
418576030
232137381
395057418
5669223
765611330

Output:
418576030
232137381
395057418
5669223
765611330

Output:
418576030
232137381
395057418
5669223
765611330

Output:
418576030
232137381
395057418
5669223
765611330

Output:
418576030
232137381
395057418
5669223
765611330

Output:
418576030
232137381
395057418
5669223
765611330

Input:
5
60522 200000
36426 200000
48772 200000
133447 200000
103497 200000

Output:
88692754
877803650
810867890
817679867
55853432

Output:
88692754
877803650
810867890
817679867
55853432

Output:
88692754
877803650
810867890
817679867
55853432

Output:
88692754
877803650
810867890
817679867
55853432

Output:
88692754
877803650
810867890
817679867
55853432

Output:
88692754
877803650
810867890
817679867
55853432

Output:
88692754
877803650
810867890
817679867
55853432

Output:
88692754
877803650
810867890
817679867
55853432

Input:
5
22 167713
26 133836
72 148202
47 125228
97 63591

Output:
304668051
8504791
826876273
876327971
867434228

Output:
304668051
8504791
826876273
876327971
867434228

Output:
304668051
8504791
826876273
876327971
867434228

Output:
304668051
8504791
826876273
876327971
867434228

Output:
304668051
8504791
826876273
876327971
867434228

Output:
304668051
8504791
826876273
876327971
867434228

Output:
304668051
8504791
826876273
876327971
867434228

Output:
304668051
8504791
826876273
876327971
867434228

Input:
5
22 59
26 60
72 72
47 3
97 16

Output:
719147166
712743436
592556526
300790496
472187775

Output:
719147166
712743436
592556526
300790496
472187775

Output:
719147166
712743436
592556526
300790496
472187775

Output:
719147166
712743436
592556526
300790496
472187775

Output:
719147166
712743436
592556526
300790496
472187775

Output:
719147166
712743436
592556526
300790496
472187775

Output:
719147166
712743436
592556526
300790496
472187775

Output:
719147166
712743436
592556526
300790496
472187775

Input:
5
22 578
26 604
72 839
47 857
97 400

Output:
31027543
136918279
784949490
553888953
423365820

Output:
31027543
136918279
784949490
553888953
423365820

Output:
31027543
136918279
784949490
553888953
423365820

Output:
31027543
136918279
784949490
553888953
423365820

Output:
31027543
136918279
784949490
553888953
423365820

Output:
31027543
136918279
784949490
553888953
423365820

Output:
31027543
136918279
784949490
553888953
423365820

Output:
31027543
136918279
784949490
553888953
423365820

Input:
5
522 1981
426 1890
772 1010
1447 1859
1497 1362

Output:
128766123
527181212
212725943
540481455
161044419

Output:
128766123
527181212
212725943
540481455
161044419

Output:
128766123
527181212
212725943
540481455
161044419

Output:
128766123
527181212
212725943
540481455
161044419

Output:
128766123
527181212
212725943
540481455
161044419

Output:
128766123
527181212
212725943
540481455
161044419

Output:
128766123
527181212
212725943
540481455
161044419

Output:
128766123
527181212
212725943
540481455
161044419

Input:
5
522 3161
426 3209
772 2238
1447 1372
3497 3893

Output:
270381413
22435266
915213608
465693385
486274412

Output:
270381413
22435266
915213608
465693385
486274412

Output:
270381413
22435266
915213608
465693385
486274412

Output:
270381413
22435266
915213608
465693385
486274412

Output:
270381413
22435266
915213608
465693385
486274412

Output:
270381413
22435266
915213608
465693385
486274412

Output:
270381413
22435266
915213608
465693385
486274412

Output:
270381413
22435266
915213608
465693385
486274412

Input:
5
2522 4467
426 3791
772 4195
1447 2006
5497 2673

Output:
387599759
635311356
552472895
752772609
931791909

Output:
387599759
635311356
552472895
752772609
931791909

Output:
387599759
635311356
552472895
752772609
931791909

Output:
387599759
635311356
552472895
752772609
931791909

Output:
387599759
635311356
552472895
752772609
931791909

Output:
387599759
635311356
552472895
752772609
931791909

Output:
387599759
635311356
552472895
752772609
931791909

Output:
387599759
635311356
552472895
752772609
931791909

Input:
5
4522 2314
4426 2886
772 5081
5447 5120
7497 7239

Output:
583234568
559552720
122646970
48480085
917539288

Output:
583234568
559552720
122646970
48480085
917539288

Output:
583234568
559552720
122646970
48480085
917539288

Output:
583234568
559552720
122646970
48480085
917539288

Output:
583234568
559552720
122646970
48480085
917539288

Output:
583234568
559552720
122646970
48480085
917539288

Output:
583234568
559552720
122646970
48480085
917539288

Output:
583234568
559552720
122646970
48480085
917539288

Input:
5
522 1278
6426 4981
8772 2685
3447 3137
3497 8752

Output:
501733812
294571525
722429686
914702675
280411108

Output:
501733812
294571525
722429686
914702675
280411108

Output:
501733812
294571525
722429686
914702675
280411108

Output:
501733812
294571525
722429686
914702675
280411108

Output:
501733812
294571525
722429686
914702675
280411108

Output:
501733812
294571525
722429686
914702675
280411108

Output:
501733812
294571525
722429686
914702675
280411108

Output:
501733812
294571525
722429686
914702675
280411108

Input:
5
8522 11028
426 7666
772 1884
1447 9437
11497 840

Output:
513847
273162268
889133064
851232032
371101041

Output:
513847
273162268
889133064
851232032
371101041

Output:
513847
273162268
889133064
851232032
371101041

Output:
513847
273162268
889133064
851232032
371101041

Output:
513847
273162268
889133064
851232032
371101041

Output:
513847
273162268
889133064
851232032
371101041

Output:
513847
273162268
889133064
851232032
371101041

Output:
513847
273162268
889133064
851232032
371101041

Input:
5
12522 19
6426 11199
10772 1658
3447 5303
3497 2454

Output:
525725396
826606325
692029170
486489284
495668637

Output:
525725396
826606325
692029170
486489284
495668637

Output:
525725396
826606325
692029170
486489284
495668637

Output:
525725396
826606325
692029170
486489284
495668637

Output:
525725396
826606325
692029170
486489284
495668637

Output:
525725396
826606325
692029170
486489284
495668637

Output:
525725396
826606325
692029170
486489284
495668637

Output:
525725396
826606325
692029170
486489284
495668637

Input:
5
4522 7771
4426 15425
772 9303
13447 13626
15497 8407

Output:
814565803
486206530
368488320
3354994
899076399

Output:
814565803
486206530
368488320
3354994
899076399

Output:
814565803
486206530
368488320
3354994
899076399

Output:
814565803
486206530
368488320
3354994
899076399

Output:
814565803
486206530
368488320
3354994
899076399

Output:
814565803
486206530
368488320
3354994
899076399

Output:
814565803
486206530
368488320
3354994
899076399

Output:
814565803
486206530
368488320
3354994
899076399

Input:
5
8522 3000
6426 17386
6772 11564
1447 9637
5497 16252

Output:
389346184
345023944
936288148
96774688
697294112

Output:
389346184
345023944
936288148
96774688
697294112

Output:
389346184
345023944
936288148
96774688
697294112

Output:
389346184
345023944
936288148
96774688
697294112

Output:
389346184
345023944
936288148
96774688
697294112

Output:
389346184
345023944
936288148
96774688
697294112

Output:
389346184
345023944
936288148
96774688
697294112

Output:
389346184
345023944
936288148
96774688
697294112

Input:
5
522 2785
16426 4821
8772 9458
13447 4313
3497 17838

Output:
440235472
659823308
469802878
46158886
333866633

Output:
440235472
659823308
469802878
46158886
333866633

Output:
440235472
659823308
469802878
46158886
333866633

Output:
440235472
659823308
469802878
46158886
333866633

Output:
440235472
659823308
469802878
46158886
333866633

Output:
440235472
659823308
469802878
46158886
333866633

Output:
440235472
659823308
469802878
46158886
333866633

Output:
440235472
659823308
469802878
46158886
333866633

Input:
5
14522 5674
16426 10901
10772 1084
15447 20499
17497 3424

Output:
992009897
858050302
314846315
338328822
241087122

Output:
992009897
858050302
314846315
338328822
241087122

Output:
992009897
858050302
314846315
338328822
241087122

Output:
992009897
858050302
314846315
338328822
241087122

Output:
992009897
858050302
314846315
338328822
241087122

Output:
992009897
858050302
314846315
338328822
241087122

Output:
992009897
858050302
314846315
338328822
241087122

Output:
992009897
858050302
314846315
338328822
241087122

Input:
5
20522 18433
12426 1766
772 12777
13447 20072
23497 22354

Output:
258002497
24400553
383535095
564262189
141733393

Output:
258002497
24400553
383535095
564262189
141733393

Output:
258002497
24400553
383535095
564262189
141733393

Output:
258002497
24400553
383535095
564262189
141733393

Output:
258002497
24400553
383535095
564262189
141733393

Output:
258002497
24400553
383535095
564262189
141733393

Output:
258002497
24400553
383535095
564262189
141733393

Output:
258002497
24400553
383535095
564262189
141733393

Input:
5
6522 1207
12426 6846
2772 4748
17447 20123
5497 2514

Output:
222061841
456839279
641365823
295160810
605774697

Output:
222061841
456839279
641365823
295160810
605774697

Output:
222061841
456839279
641365823
295160810
605774697

Output:
222061841
456839279
641365823
295160810
605774697

Output:
222061841
456839279
641365823
295160810
605774697

Output:
222061841
456839279
641365823
295160810
605774697

Output:
222061841
456839279
641365823
295160810
605774697

Output:
222061841
456839279
641365823
295160810
605774697

Input:
5
12522 27839
20426 6881
24772 26346
17447 22381
3497 17251

Output:
627048439
692531689
257860359
672149186
484947029

Output:
627048439
692531689
257860359
672149186
484947029

Output:
627048439
692531689
257860359
672149186
484947029

Output:
627048439
692531689
257860359
672149186
484947029

Output:
627048439
692531689
257860359
672149186
484947029

Output:
627048439
692531689
257860359
672149186
484947029

Output:
627048439
692531689
257860359
672149186
484947029

Output:
627048439
692531689
257860359
672149186
484947029

Input:
5
20522 18989
6426 23733
18772 19072
13447 4385
23497 10041

Output:
373779991
752041429
675278712
56027611
995446610

Output:
373779991
752041429
675278712
56027611
995446610

Output:
373779991
752041429
675278712
56027611
995446610

Output:
373779991
752041429
675278712
56027611
995446610

Output:
373779991
752041429
675278712
56027611
995446610

Output:
373779991
752041429
675278712
56027611
995446610

Output:
373779991
752041429
675278712
56027611
995446610

Output:
373779991
752041429
675278712
56027611
995446610

Input:
5
20522 2314
4426 7311
16772 25205
13447 30239
15497 27795

Output:
387713371
567907291
567266418
203396676
877257118

Output:
387713371
567907291
567266418
203396676
877257118

Output:
387713371
567907291
567266418
203396676
877257118

Output:
387713371
567907291
567266418
203396676
877257118

Output:
387713371
567907291
567266418
203396676
877257118

Output:
387713371
567907291
567266418
203396676
877257118

Output:
387713371
567907291
567266418
203396676
877257118

Output:
387713371
567907291
567266418
203396676
877257118

Input:
5
522 8443
8426 120
6772 32508
5447 9690
23497 31112

Output:
643620372
188787712
137493209
985755740
63055698

Output:
643620372
188787712
137493209
985755740
63055698

Output:
643620372
188787712
137493209
985755740
63055698

Output:
643620372
188787712
137493209
985755740
63055698

Output:
643620372
188787712
137493209
985755740
63055698

Output:
643620372
188787712
137493209
985755740
63055698

Output:
643620372
188787712
137493209
985755740
63055698

Output:
643620372
188787712
137493209
985755740
63055698

Input:
5
8522 19723
24426 317
24772 34
1447 2271
23497 29933

Output:
383106358
628462794
993108917
908084822
666947024

Output:
383106358
628462794
993108917
908084822
666947024

Output:
383106358
628462794
993108917
908084822
666947024

Output:
383106358
628462794
993108917
908084822
666947024

Output:
383106358
628462794
993108917
908084822
666947024

Output:
383106358
628462794
993108917
908084822
666947024

Output:
383106358
628462794
993108917
908084822
666947024

Output:
383106358
628462794
993108917
908084822
666947024

Input:
5
20522 9466
18426 17637
16772 16118
35447 22061
23497 36309

Output:
311763651
947379706
930924417
51525703
485235024

Output:
311763651
947379706
930924417
51525703
485235024

Output:
311763651
947379706
930924417
51525703
485235024

Output:
311763651
947379706
930924417
51525703
485235024

Output:
311763651
947379706
930924417
51525703
485235024

Output:
311763651
947379706
930924417
51525703
485235024

Output:
311763651
947379706
930924417
51525703
485235024

Output:
311763651
947379706
930924417
51525703
485235024

Input:
5
20522 12967
36426 14501
8772 19546
13447 38726
23497 3234

Output:
250838410
728681630
204085208
354081072
252539854

Output:
250838410
728681630
204085208
354081072
252539854

Output:
250838410
728681630
204085208
354081072
252539854

Output:
250838410
728681630
204085208
354081072
252539854

Output:
250838410
728681630
204085208
354081072
252539854

Output:
250838410
728681630
204085208
354081072
252539854

Output:
250838410
728681630
204085208
354081072
252539854

Output:
250838410
728681630
204085208
354081072
252539854

Input:
5
26522 28224
6426 4535
24772 21028
31447 35982
17497 28737

Output:
614165725
295215954
111774336
788811583
94457069

Output:
614165725
295215954
111774336
788811583
94457069

Output:
614165725
295215954
111774336
788811583
94457069

Output:
614165725
295215954
111774336
788811583
94457069

Output:
614165725
295215954
111774336
788811583
94457069

Output:
614165725
295215954
111774336
788811583
94457069

Output:
614165725
295215954
111774336
788811583
94457069

Output:
614165725
295215954
111774336
788811583
94457069

Input:
5
36522 17830
16426 33675
32772 1463
37447 18818
39497 38127

Output:
577845706
434136514
327930500
445732548
64901596

Output:
577845706
434136514
327930500
445732548
64901596

Output:
577845706
434136514
327930500
445732548
64901596

Output:
577845706
434136514
327930500
445732548
64901596

Output:
577845706
434136514
327930500
445732548
64901596

Output:
577845706
434136514
327930500
445732548
64901596

Output:
577845706
434136514
327930500
445732548
64901596

Output:
577845706
434136514
327930500
445732548
64901596

Input:
5
18522 39204
30426 32870
32772 13018
7447 37823
5497 27005

Output:
574158496
375944045
191068937
374319462
675339196

Output:
574158496
375944045
191068937
374319462
675339196

Output:
574158496
375944045
191068937
374319462
675339196

Output:
574158496
375944045
191068937
374319462
675339196

Output:
574158496
375944045
191068937
374319462
675339196

Output:
574158496
375944045
191068937
374319462
675339196

Output:
574158496
375944045
191068937
374319462
675339196

Output:
574158496
375944045
191068937
374319462
675339196

Input:
5
20522 15275
36426 23993
772 4851
13447 47491
47497 10125

Output:
92383711
556307867
214845295
536176885
274345529

Output:
92383711
556307867
214845295
536176885
274345529

Output:
92383711
556307867
214845295
536176885
274345529

Output:
92383711
556307867
214845295
536176885
274345529

Output:
92383711
556307867
214845295
536176885
274345529

Output:
92383711
556307867
214845295
536176885
274345529

Output:
92383711
556307867
214845295
536176885
274345529

Output:
92383711
556307867
214845295
536176885
274345529

Input:
5
10522 49291
36426 49737
48772 14993
33447 42227
3497 6588

Output:
357088684
352090898
955599131
643643684
112221458

Output:
357088684
352090898
955599131
643643684
112221458

Output:
357088684
352090898
955599131
643643684
112221458

Output:
357088684
352090898
955599131
643643684
112221458

Output:
357088684
352090898
955599131
643643684
112221458

Output:
357088684
352090898
955599131
643643684
112221458

Output:
357088684
352090898
955599131
643643684
112221458

Output:
357088684
352090898
955599131
643643684
112221458

Input:
5
32522 22058
12426 18213
28772 45814
17447 46926
31497 1982

Output:
941012026
735826088
313320819
406320729
449754690

Output:
941012026
735826088
313320819
406320729
449754690

Output:
941012026
735826088
313320819
406320729
449754690

Output:
941012026
735826088
313320819
406320729
449754690

Output:
941012026
735826088
313320819
406320729
449754690

Output:
941012026
735826088
313320819
406320729
449754690

Output:
941012026
735826088
313320819
406320729
449754690

Output:
941012026
735826088
313320819
406320729
449754690

Input:
5
26522 46763
24426 20644
42772 46922
1447 50380
23497 32679

Output:
420121807
910007568
314559436
499243470
664092465

Output:
420121807
910007568
314559436
499243470
664092465

Output:
420121807
910007568
314559436
499243470
664092465

Output:
420121807
910007568
314559436
499243470
664092465

Output:
420121807
910007568
314559436
499243470
664092465

Output:
420121807
910007568
314559436
499243470
664092465

Output:
420121807
910007568
314559436
499243470
664092465

Output:
420121807
910007568
314559436
499243470
664092465

Input:
5
12522 2866
20426 46782
24772 15392
45447 8381
31497 32520

Output:
59985038
334121
139590791
847779639
571037452

Output:
59985038
334121
139590791
847779639
571037452

Output:
59985038
334121
139590791
847779639
571037452

Output:
59985038
334121
139590791
847779639
571037452

Output:
59985038
334121
139590791
847779639
571037452

Output:
59985038
334121
139590791
847779639
571037452

Output:
59985038
334121
139590791
847779639
571037452

Output:
59985038
334121
139590791
847779639
571037452

Input:
5
46522 40903
2426 51978
6772 5583
43447 16967
5497 14176

Output:
967627092
37949128
600680035
666312473
626901798

Output:
967627092
37949128
600680035
666312473
626901798

Output:
967627092
37949128
600680035
666312473
626901798

Output:
967627092
37949128
600680035
666312473
626901798

Output:
967627092
37949128
600680035
666312473
626901798

Output:
967627092
37949128
600680035
666312473
626901798

Output:
967627092
37949128
600680035
666312473
626901798

Output:
967627092
37949128
600680035
666312473
626901798

Input:
5
20522 4881
36426 45854
48772 33403
13447 20564
23497 16268

Output:
229899021
477092059
917047148
793264543
794742767

Output:
229899021
477092059
917047148
793264543
794742767

Output:
229899021
477092059
917047148
793264543
794742767

Output:
229899021
477092059
917047148
793264543
794742767

Output:
229899021
477092059
917047148
793264543
794742767

Output:
229899021
477092059
917047148
793264543
794742767

Output:
229899021
477092059
917047148
793264543
794742767

Output:
229899021
477092059
917047148
793264543
794742767

Input:
5
12522 3232
24426 29310
38772 39110
55447 18296
15497 9786

Output:
696066472
793085020
101346244
47764496
12580539

Output:
696066472
793085020
101346244
47764496
12580539

Output:
696066472
793085020
101346244
47764496
12580539

Output:
696066472
793085020
101346244
47764496
12580539

Output:
696066472
793085020
101346244
47764496
12580539

Output:
696066472
793085020
101346244
47764496
12580539

Output:
696066472
793085020
101346244
47764496
12580539

Output:
696066472
793085020
101346244
47764496
12580539

Input:
5
52522 10077
4426 42688
16772 59779
13447 55100
47497 39698

Output:
809810100
223467262
929221981
920037472
559355407

Output:
809810100
223467262
929221981
920037472
559355407

Output:
809810100
223467262
929221981
920037472
559355407

Output:
809810100
223467262
929221981
920037472
559355407

Output:
809810100
223467262
929221981
920037472
559355407

Output:
809810100
223467262
929221981
920037472
559355407

Output:
809810100
223467262
929221981
920037472
559355407

Output:
809810100
223467262
929221981
920037472
559355407

Input:
5
14522 43036
60426 4985
54772 28204
37447 11075
17497 16728

Output:
819216143
42480091
344412023
800016372
228614960

Output:
819216143
42480091
344412023
800016372
228614960

Output:
819216143
42480091
344412023
800016372
228614960

Output:
819216143
42480091
344412023
800016372
228614960

Output:
819216143
42480091
344412023
800016372
228614960

Output:
819216143
42480091
344412023
800016372
228614960

Output:
819216143
42480091
344412023
800016372
228614960

Output:
819216143
42480091
344412023
800016372
228614960

Input:
5
522 28717
8426 35475
40772 49700
5447 42746
23497 29250

Output:
74659798
451164750
71292169
55083431
893651755

Output:
74659798
451164750
71292169
55083431
893651755

Output:
74659798
451164750
71292169
55083431
893651755

Output:
74659798
451164750
71292169
55083431
893651755

Output:
74659798
451164750
71292169
55083431
893651755

Output:
74659798
451164750
71292169
55083431
893651755

Output:
74659798
451164750
71292169
55083431
893651755

Output:
74659798
451164750
71292169
55083431
893651755

Input:
5
40522 32643
6426 10515
38772 15930
3447 27180
3497 49771

Output:
964909104
163185257
287214352
745808150
311967807

Output:
964909104
163185257
287214352
745808150
311967807

Output:
964909104
163185257
287214352
745808150
311967807

Output:
964909104
163185257
287214352
745808150
311967807

Output:
964909104
163185257
287214352
745808150
311967807

Output:
964909104
163185257
287214352
745808150
311967807

Output:
964909104
163185257
287214352
745808150
311967807

Output:
964909104
163185257
287214352
745808150
311967807

Input:
5
44522 55545
60426 6915
24772 6685
37447 10900
23497 34907

Output:
174955742
88129650
238023853
148013756
539202850

Output:
174955742
88129650
238023853
148013756
539202850

Output:
174955742
88129650
238023853
148013756
539202850

Output:
174955742
88129650
238023853
148013756
539202850

Output:
174955742
88129650
238023853
148013756
539202850

Output:
174955742
88129650
238023853
148013756
539202850

Output:
174955742
88129650
238023853
148013756
539202850

Output:
174955742
88129650
238023853
148013756
539202850

Input:
5
4522 31786
2426 2907
66772 47
5447 64736
47497 48777

Output:
243258496
546453886
657584641
295422815
581001485

Output:
243258496
546453886
657584641
295422815
581001485

Output:
243258496
546453886
657584641
295422815
581001485

Output:
243258496
546453886
657584641
295422815
581001485

Output:
243258496
546453886
657584641
295422815
581001485

Output:
243258496
546453886
657584641
295422815
581001485

Output:
243258496
546453886
657584641
295422815
581001485

Output:
243258496
546453886
657584641
295422815
581001485

Input:
5
20522 53736
56426 4658
16772 40371
73447 29991
23497 62948

Output:
800737564
983143562
489457079
594790725
702380134

Output:
800737564
983143562
489457079
594790725
702380134

Output:
800737564
983143562
489457079
594790725
702380134

Output:
800737564
983143562
489457079
594790725
702380134

Output:
800737564
983143562
489457079
594790725
702380134

Output:
800737564
983143562
489457079
594790725
702380134

Output:
800737564
983143562
489457079
594790725
702380134

Output:
800737564
983143562
489457079
594790725
702380134

Input:
5
32522 70109
12426 71675
54772 11619
43447 61148
5497 59767

Output:
259396182
765449308
27678822
989349622
136295276

Output:
259396182
765449308
27678822
989349622
136295276

Output:
259396182
765449308
27678822
989349622
136295276

Output:
259396182
765449308
27678822
989349622
136295276

Output:
259396182
765449308
27678822
989349622
136295276

Output:
259396182
765449308
27678822
989349622
136295276

Output:
259396182
765449308
27678822
989349622
136295276

Output:
259396182
765449308
27678822
989349622
136295276

Input:
5
20522 27100
36426 19806
48772 30101
13447 72881
63497 20955

Output:
845118508
102134845
740378448
957821706
759188985

Output:
845118508
102134845
740378448
957821706
759188985

Output:
845118508
102134845
740378448
957821706
759188985

Output:
845118508
102134845
740378448
957821706
759188985

Output:
845118508
102134845
740378448
957821706
759188985

Output:
845118508
102134845
740378448
957821706
759188985

Output:
845118508
102134845
740378448
957821706
759188985

Output:
845118508
102134845
740378448
957821706
759188985

Input:
5
26522 80986
62426 38438
76772 37666
43447 27239
13497 10653

Output:
15029095
525260305
861843978
164167061
701313289

Output:
15029095
525260305
861843978
164167061
701313289

Output:
15029095
525260305
861843978
164167061
701313289

Output:
15029095
525260305
861843978
164167061
701313289

Output:
15029095
525260305
861843978
164167061
701313289

Output:
15029095
525260305
861843978
164167061
701313289

Output:
15029095
525260305
861843978
164167061
701313289

Output:
15029095
525260305
861843978
164167061
701313289

Input:
5
68522 77585
48426 29779
24772 57939
73447 34586
59497 1126

Output:
618495042
550975242
522053296
783499166
960428842

Output:
618495042
550975242
522053296
783499166
960428842

Output:
618495042
550975242
522053296
783499166
960428842

Output:
618495042
550975242
522053296
783499166
960428842

Output:
618495042
550975242
522053296
783499166
960428842

Output:
618495042
550975242
522053296
783499166
960428842

Output:
618495042
550975242
522053296
783499166
960428842

Output:
618495042
550975242
522053296
783499166
960428842

Input:
5
28522 21694
40426 71172
52772 47783
61447 31928
27497 72150

Output:
518077479
596707440
638440559
973868480
799215443

Output:
518077479
596707440
638440559
973868480
799215443

Output:
518077479
596707440
638440559
973868480
799215443

Output:
518077479
596707440
638440559
973868480
799215443

Output:
518077479
596707440
638440559
973868480
799215443

Output:
518077479
596707440
638440559
973868480
799215443

Output:
518077479
596707440
638440559
973868480
799215443

Output:
518077479
596707440
638440559
973868480
799215443

Input:
5
36522 6298
60426 65175
32772 49609
37447 40527
39497 68728

Output:
260751469
836872195
12494412
153815728
709694981

Output:
260751469
836872195
12494412
153815728
709694981

Output:
260751469
836872195
12494412
153815728
709694981

Output:
260751469
836872195
12494412
153815728
709694981

Output:
260751469
836872195
12494412
153815728
709694981

Output:
260751469
836872195
12494412
153815728
709694981

Output:
260751469
836872195
12494412
153815728
709694981

Output:
260751469
836872195
12494412
153815728
709694981

Input:
5
80522 13536
6426 18454
78772 78078
73447 880
23497 82319

Output:
812348970
719313504
248545775
654529015
5930487

Output:
812348970
719313504
248545775
654529015
5930487

Output:
812348970
719313504
248545775
654529015
5930487

Output:
812348970
719313504
248545775
654529015
5930487

Output:
812348970
719313504
248545775
654529015
5930487

Output:
812348970
719313504
248545775
654529015
5930487

Output:
812348970
719313504
248545775
654529015
5930487

Output:
812348970
719313504
248545775
654529015
5930487

Input:
5
64522 50719
76426 17985
32772 22133
53447 62282
51497 50268

Output:
704169853
729060138
881606279
991848271
544274182

Output:
704169853
729060138
881606279
991848271
544274182

Output:
704169853
729060138
881606279
991848271
544274182

Output:
704169853
729060138
881606279
991848271
544274182

Output:
704169853
729060138
881606279
991848271
544274182

Output:
704169853
729060138
881606279
991848271
544274182

Output:
704169853
729060138
881606279
991848271
544274182

Output:
704169853
729060138
881606279
991848271
544274182

Input:
5
48522 65231
22426 75375
66772 58717
17447 24560
55497 76940

Output:
936486310
24729470
774762575
257895456
323271573

Output:
936486310
24729470
774762575
257895456
323271573

Output:
936486310
24729470
774762575
257895456
323271573

Output:
936486310
24729470
774762575
257895456
323271573

Output:
936486310
24729470
774762575
257895456
323271573

Output:
936486310
24729470
774762575
257895456
323271573

Output:
936486310
24729470
774762575
257895456
323271573

Output:
936486310
24729470
774762575
257895456
323271573

Input:
5
20522 53850
36426 13980
48772 85787
13447 69672
47497 92782

Output:
3597531
233500310
975586073
89817081
124854905

Output:
3597531
233500310
975586073
89817081
124854905

Output:
3597531
233500310
975586073
89817081
124854905

Output:
3597531
233500310
975586073
89817081
124854905

Output:
3597531
233500310
975586073
89817081
124854905

Output:
3597531
233500310
975586073
89817081
124854905

Output:
3597531
233500310
975586073
89817081
124854905

Output:
3597531
233500310
975586073
89817081
124854905

Input:
5
68522 72136
62426 69558
38772 16169
31447 52010
17497 84468

Output:
991039517
66825943
357651709
703220994
505948904

Output:
991039517
66825943
357651709
703220994
505948904

Output:
991039517
66825943
357651709
703220994
505948904

Output:
991039517
66825943
357651709
703220994
505948904

Output:
991039517
66825943
357651709
703220994
505948904

Output:
991039517
66825943
357651709
703220994
505948904

Output:
991039517
66825943
357651709
703220994
505948904

Output:
991039517
66825943
357651709
703220994
505948904

Input:
5
60522 34392
36426 92971
48772 47765
33447 90408
3497 41078

Output:
991485105
482392881
132303178
849810533
55123956

Output:
991485105
482392881
132303178
849810533
55123956

Output:
991485105
482392881
132303178
849810533
55123956

Output:
991485105
482392881
132303178
849810533
55123956

Output:
991485105
482392881
132303178
849810533
55123956

Output:
991485105
482392881
132303178
849810533
55123956

Output:
991485105
482392881
132303178
849810533
55123956

Output:
991485105
482392881
132303178
849810533
55123956

Input:
1
1 0

Output: 1

Output: 1

Output: 1

Output: 1

Output: 1

Output: 1


Note that the memory limit in this problem is lower than in others.You have a vertical strip with $$$n$$$ cells, numbered consecutively from $$$1$$$ to $$$n$$$ from top to bottom.You also have a token that is initially placed in cell $$$n$$$. You will move the token up until it arrives at cell $$$1$$$.Let the token be in cell $$$x > 1$$$ at some moment. One shift of the token can have either of the following kinds:   Subtraction: you choose an integer $$$y$$$ between $$$1$$$ and $$$x-1$$$, inclusive, and move the token from cell $$$x$$$ to cell $$$x - y$$$.  Floored division: you choose an integer $$$z$$$ between $$$2$$$ and $$$x$$$, inclusive, and move the token from cell $$$x$$$ to cell $$$\lfloor \frac{x}{z} \rfloor$$$ ($$$x$$$ divided by $$$z$$$ rounded down). Find the number of ways to move the token from cell $$$n$$$ to cell $$$1$$$ using one or more shifts, and print it modulo $$$m$$$. Note that if there are several ways to move the token from one cell to another in one shift, all these ways are considered distinct (check example explanation for a better understanding).

Print the number of ways to move the token from cell $$$n$$$ to cell $$$1$$$, modulo $$$m$$$.

NoteIn the first test, there are three ways to move the token from cell $$$3$$$ to cell $$$1$$$ in one shift: using subtraction of $$$y = 2$$$, or using division by $$$z = 2$$$ or $$$z = 3$$$.There are also two ways to move the token from cell $$$3$$$ to cell $$$1$$$ via cell $$$2$$$: first subtract $$$y = 1$$$, and then either subtract $$$y = 1$$$ again or divide by $$$z = 2$$$.Therefore, there are five ways in total.

The only line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 4 \cdot 10^6$$$; $$$10^8 < m < 10^9$$$; $$$m$$$ is a prime number) — the length of the strip and the modulo.

Input: 3 998244353

Output: 5

Output: 5

Output: 5

Output: 5

Output: 5

Output: 5

Input: 5 998244353

Output: 25

Output: 25

Output: 25

Output: 25

Output: 25

Output: 25

Input: 42 998244353

Output: 793019428

Output: 793019428

Output: 793019428

Output: 793019428

Output: 793019428

Output: 793019428

Input: 787788 100000007

Output: 94810539

Output: 94810539

Output: 94810539

Output: 94810539

Output: 94810539

Output: 94810539

Input: 363 418169771

Output: 65078475

Output: 65078475

Output: 65078475

Output: 65078475

Output: 65078475

Output: 65078475

Input: 103537 463252301

Output: 242323213

Output: 242323213

Output: 242323213

Output: 242323213

Output: 242323213

Output: 242323213

Input: 4000000 810370681

Output: 328403187

Output: 328403187

Output: 328403187

Output: 328403187

Output: 328403187

Output: 328403187

Input: 2 872207251

Output: 2

Output: 2

Output: 2

Output: 2

Output: 2

Output: 2

Input: 3998017 100000007

Output: 26756421

Output: 26756421

Output: 26756421

Output: 26756421

Output: 26756421

Output: 26756421

Input: 3999130 999999937

Output: 310436673

Output: 310436673

Output: 310436673

Output: 310436673

Output: 310436673

Output: 310436673

Input: 2924225 234660347

Output: 195688584

Output: 195688584

Output: 195688584

Output: 195688584

Output: 195688584

Output: 195688584

Input: 182550 383331199

Output: 234598461

Output: 234598461

Output: 234598461

Output: 234598461

Output: 234598461

Output: 234598461

Input: 15260 936347479

Output: 534567654

Output: 534567654

Output: 534567654

Output: 534567654

Output: 534567654

Output: 534567654

Input: 1851 248535541

Output: 66118746

Output: 66118746

Output: 66118746

Output: 66118746

Output: 66118746

Output: 66118746

Input: 47 318786553

Output: 134462650

Output: 134462650

Output: 134462650

Output: 134462650

Output: 134462650

Output: 134462650

Input: 16 879902963

Output: 61715

Output: 61715

Output: 61715

Output: 61715

Output: 61715

Output: 61715

Input: 4 539424923

Output: 12

Output: 12

Output: 12

Output: 12

Output: 12

Output: 12

Input: 4000000 638439467

Output: 595337260

Output: 595337260

Output: 595337260

Output: 595337260

Output: 595337260

Output: 595337260

Input: 3999992 135986881

Output: 85093537

Output: 85093537

Output: 85093537

Output: 85093537

Output: 85093537

Output: 85093537

Input: 3999915 686455787

Output: 528276430

Output: 528276430

Output: 528276430

Output: 528276430

Output: 528276430

Output: 528276430

Input: 3999103 726275063

Output: 433687548

Output: 433687548

Output: 433687548

Output: 433687548

Output: 433687548

Output: 433687548

Input: 3994356 686802749

Output: 43415427

Output: 43415427

Output: 43415427

Output: 43415427

Output: 43415427

Output: 43415427

Input: 3912472 178711691

Output: 113174790

Output: 113174790

Output: 113174790

Output: 113174790

Output: 113174790

Output: 113174790

Input: 3205208 612881327

Output: 177676343

Output: 177676343

Output: 177676343

Output: 177676343

Output: 177676343

Output: 177676343

Input: 69420 998244353

Output: 279238034

Output: 279238034

Output: 279238034

Output: 279238034

Output: 279238034

Output: 279238034

Input: 4000000 100000037

Output: 25315880

Output: 25315880

Output: 25315880

Output: 25315880

Output: 25315880

Output: 25315880

Input: 4000000 100000039

Output: 42183279

Output: 42183279

Output: 42183279

Output: 42183279

Output: 42183279

Output: 42183279

Input: 4000000 100004291

Output: 32586026

Output: 32586026

Output: 32586026

Output: 32586026

Output: 32586026

Output: 32586026

Input: 4000000 998244353

Output: 710440601

Output: 710440601

Output: 710440601

Output: 710440601

Output: 710440601

Output: 710440601

Input: 4000000 100000007

Output: 3494247

Output: 3494247

Output: 3494247

Output: 3494247

Output: 3494247

Output: 3494247

Input: 4000000 686455787

Output: 385194408

Output: 385194408

Output: 385194408

Output: 385194408

Output: 385194408

Output: 385194408

Input: 4000000 100000801

Output: 63677450

Output: 63677450

Output: 63677450

Output: 63677450

Output: 63677450

Output: 63677450

Input: 4000000 100054489

Output: 71115185

Output: 71115185

Output: 71115185

Output: 71115185

Output: 71115185

Output: 71115185


This version of the problem differs from the next one only in the constraint on $$$n$$$.Note that the memory limit in this problem is lower than in others.You have a vertical strip with $$$n$$$ cells, numbered consecutively from $$$1$$$ to $$$n$$$ from top to bottom.You also have a token that is initially placed in cell $$$n$$$. You will move the token up until it arrives at cell $$$1$$$.Let the token be in cell $$$x > 1$$$ at some moment. One shift of the token can have either of the following kinds:   Subtraction: you choose an integer $$$y$$$ between $$$1$$$ and $$$x-1$$$, inclusive, and move the token from cell $$$x$$$ to cell $$$x - y$$$.  Floored division: you choose an integer $$$z$$$ between $$$2$$$ and $$$x$$$, inclusive, and move the token from cell $$$x$$$ to cell $$$\lfloor \frac{x}{z} \rfloor$$$ ($$$x$$$ divided by $$$z$$$ rounded down). Find the number of ways to move the token from cell $$$n$$$ to cell $$$1$$$ using one or more shifts, and print it modulo $$$m$$$. Note that if there are several ways to move the token from one cell to another in one shift, all these ways are considered distinct (check example explanation for a better understanding).

The only line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$10^8 < m < 10^9$$$; $$$m$$$ is a prime number) — the length of the strip and the modulo.

Input: 3 998244353

Output: 5

Output: 5

Output: 5

Output: 5

Output: 5

Output: 5

Output: 5

Output: 5

Output: 5

Input: 5 998244353

Output: 25

Output: 25

Output: 25

Output: 25

Output: 25

Output: 25

Output: 25

Output: 25

Output: 25

Input: 42 998244353

Output: 793019428

Output: 793019428

Output: 793019428

Output: 793019428

Output: 793019428

Output: 793019428

Output: 793019428

Output: 793019428

Input: 349 528449821

Output: 190306170

Output: 190306170

Output: 190306170

Output: 190306170

Output: 190306170

Output: 190306170

Output: 190306170

Output: 190306170

Input: 158032 121694641

Output: 114975792

Output: 114975792

Output: 114975792

Output: 114975792

Output: 114975792

Output: 114975792

Output: 114975792

Input: 200000 665880409

Output: 86083213

Output: 86083213

Output: 86083213

Output: 86083213

Output: 86083213

Output: 86083213

Output: 86083213

Input: 2 554714911

Output: 2

Output: 2

Output: 2

Output: 2

Output: 2

Output: 2

Output: 2

Input: 199568 100000007

Output: 31278679

Output: 31278679

Output: 31278679

Output: 31278679

Output: 31278679

Output: 31278679

Output: 31278679

Input: 199862 999999937

Output: 750469605

Output: 750469605

Output: 750469605

Output: 750469605

Output: 750469605

Output: 750469605

Output: 750469605

Input: 140750 872921717

Output: 17972639

Output: 17972639

Output: 17972639

Output: 17972639

Output: 17972639

Output: 17972639

Output: 17972639

Input: 8045 992942057

Output: 882251038

Output: 882251038

Output: 882251038

Output: 882251038

Output: 882251038

Output: 882251038

Output: 882251038

Input: 634 982032773

Output: 695544646

Output: 695544646

Output: 695544646

Output: 695544646

Output: 695544646

Output: 695544646

Output: 695544646

Input: 48 166017469

Output: 119670181

Output: 119670181

Output: 119670181

Output: 119670181

Output: 119670181

Output: 119670181

Output: 119670181

Input: 6 732284177

Output: 55

Output: 55

Output: 55

Output: 55

Output: 55

Output: 55

Output: 55

Input: 200000 187160003

Output: 147468989

Output: 147468989

Output: 147468989

Output: 147468989

Output: 147468989

Output: 147468989

Output: 147468989

Input: 199995 597768679

Output: 390104637

Output: 390104637

Output: 390104637

Output: 390104637

Output: 390104637

Output: 390104637

Output: 390104637

Input: 200000 558920641

Output: 14322946

Output: 14322946

Output: 14322946

Output: 14322946

Output: 14322946

Output: 14322946

Output: 14322946

Input: 199660 160959167

Output: 32483089

Output: 32483089

Output: 32483089

Output: 32483089

Output: 32483089

Output: 32483089

Output: 32483089

Input: 191683 549754339

Output: 207301921

Output: 207301921

Output: 207301921

Output: 207301921

Output: 207301921

Output: 207301921

Output: 207301921

Input: 124953 922406879

Output: 768303295

Output: 768303295

Output: 768303295

Output: 768303295

Output: 768303295

Output: 768303295

Output: 768303295


Mr. Chanek has an integer represented by a string $$$s$$$. Zero or more digits have been erased and are denoted by the character _. There are also zero or more digits marked by the character X, meaning they're the same digit.Mr. Chanek wants to count the number of possible integer $$$s$$$, where $$$s$$$ is divisible by $$$25$$$. Of course, $$$s$$$ must not contain any leading zero. He can replace the character _ with any digit. He can also replace the character X with any digit, but it must be the same for every character X.As a note, a leading zero is any 0 digit that comes before the first nonzero digit in a number string in positional notation. For example, 0025 has two leading zeroes. An exception is the integer zero, (0 has no leading zero, but 0000 has three leading zeroes).

Output an integer denoting the number of possible integer $$$s$$$.

NoteIn the first example, the only possible $$$s$$$ is $$$25$$$.In the second and third example, $$$s \in \{100, 200,300,400,500,600,700,800,900\}$$$.In the fifth example, all possible $$$s$$$ will have at least one leading zero.

One line containing the string $$$s$$$ ($$$1 \leq |s| \leq 8$$$). The string $$$s$$$ consists of the characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, _, and X.

Input: X

Input: XX


Mr. Chanek wants to knit a batik, a traditional cloth from Indonesia. The cloth forms a grid $$$a$$$ with size $$$n \times m$$$. There are $$$k$$$ colors, and each cell in the grid can be one of the $$$k$$$ colors.Define a sub-rectangle as an ordered pair of two cells $$$((x_1, y_1), (x_2, y_2))$$$, denoting the top-left cell and bottom-right cell (inclusively) of a sub-rectangle in $$$a$$$. Two sub-rectangles $$$((x_1, y_1), (x_2, y_2))$$$ and $$$((x_3, y_3), (x_4, y_4))$$$ have the same pattern if and only if the following holds:   they have the same width ($$$x_2 - x_1 = x_4 - x_3$$$);  they have the same height ($$$y_2 - y_1 = y_4 - y_3$$$);  for every pair $$$(i, j)$$$ where $$$0 \leq i \leq x_2 - x_1$$$ and $$$0 \leq j \leq y_2 - y_1$$$, the color of cells $$$(x_1 + i, y_1 + j)$$$ and $$$(x_3 + i, y_3 + j)$$$ are equal. Count the number of possible batik color combinations, such that the subrectangles $$$((a_x, a_y),(a_x + r - 1, a_y + c - 1))$$$ and $$$((b_x, b_y),(b_x + r - 1, b_y + c - 1))$$$ have the same pattern.Output the answer modulo $$$10^9 + 7$$$.

Output an integer denoting the number of possible batik color combinations modulo $$$10^9 + 7$$$.

NoteThe following are all $$$32$$$ possible color combinations in the first example.

The first line contains five integers $$$n$$$, $$$m$$$, $$$k$$$, $$$r$$$, and $$$c$$$ ($$$1 \leq n, m \leq 10^9$$$, $$$1 \leq k \leq 10^9$$$, $$$1 \leq r \leq \min(10^6, n)$$$, $$$1 \leq c \leq \min(10^6, m)$$$) — the size of the batik, the number of colors, and size of the sub-rectangle. The second line contains four integers $$$a_x$$$, $$$a_y$$$, $$$b_x$$$, and $$$b_y$$$ ($$$1 \leq a_x, b_x \leq n$$$, $$$1 \leq a_y, b_y \leq m$$$) — the top-left corners of the first and second sub-rectangle. Both of the sub-rectangles given are inside the grid ($$$1 \leq a_x + r - 1$$$, $$$b_x + r - 1 \leq n$$$, $$$1 \leq a_y + c - 1$$$, $$$b_y + c - 1 \leq m$$$).

Input:
3 3 2 2 2
1 1 2 2

Output: 32

Output: 32

Output: 32

Input:
4 5 170845 2 2
1 4 3 1

Output: 756680455

Output: 756680455

Output: 756680455

Input:
2 500000003 712653643 2 896241
1 343018144 1 343018144

Output: 1

Output: 1

Output: 1

Input:
55 60 883964366 47 37
8 14 8 11

Output: 575284735

Output: 575284735

Output: 575284735

Input:
63 65 706363358 28 20
33 3 35 13

Output: 75550567

Output: 75550567

Output: 75550567

Input:
39 48 925054140 32 26
4 14 4 22

Output: 493165595

Output: 493165595

Output: 493165595

Input:
84 8 681138185 8 6
2 2 65 3

Output: 284376979

Output: 284376979

Output: 284376979

Input:
78 15 967084213 68 15
6 1 9 1

Output: 735990901

Output: 735990901

Output: 735990901

Input:
53 79 864470674 29 68
16 7 17 10

Output: 915799654

Output: 915799654

Output: 915799654

Input:
95 76 780165187 52 54
21 7 25 20

Output: 107285575

Output: 107285575

Output: 107285575

Input:
74 46 616259587 58 26
1 7 11 9

Output: 894317354

Output: 894317354

Output: 894317354

Input:
62 23 831213918 43 23
19 1 20 1

Output: 78933780

Output: 78933780

Output: 78933780

Input:
91 70 553300732 47 69
31 2 41 2

Output: 990706354

Output: 990706354

Output: 990706354

Input:
1 225896556 692281482 1 750856
1 137400676 1 73477222

Output: 28745794

Output: 28745794

Output: 28745794

Input:
612244127 1 520629493 438701 1
606433327 1 62611302 1

Output: 352024843

Output: 352024843

Output: 352024843

Input:
1000000000 1000000000 1000000000 1000000 1000000
69420 69420 69423 69423

Output: 176638891

Output: 176638891

Output: 176638891

Input:
1000000000 1000000000 1000000000 999987 999995
555555555 555555555 555555553 555555554

Output: 915290242

Output: 915290242

Output: 915290242

Input:
999876877 999999898 1000000000 999990 999978
24082002 170845 24082000 170842

Output: 113661238

Output: 113661238

Output: 113661238

Input:
224279712 681889278 586602384 995524 653256
131527798 181313191 93668397 333798254

Output: 796813183

Output: 796813183

Output: 796813183

Input:
509702566 262449977 834744439 159006 338084
59257202 181127448 352364267 85148196

Output: 26544849

Output: 26544849

Output: 26544849

Input:
148372813 835742098 605539349 949785 368809
98121767 705227816 2009992 83409357

Output: 62183519

Output: 62183519

Output: 62183519

Input:
668775901 899736493 861668260 96121 972164
628635372 503210393 364803336 59823197

Output: 495638566

Output: 495638566

Output: 495638566

Input:
649447930 484428518 896889113 19993 39197
316188994 151830831 86040053 192975280

Output: 482572283

Output: 482572283

Output: 482572283

Input:
317978118 516355503 563741456 823898 917145
303368564 34438928 303547237 35074157

Output: 832720962

Output: 832720962

Output: 832720962

Input:
606866924 608383673 964448402 895347 816649
57638772 565191689 58154550 565259566

Output: 644467392

Output: 644467392

Output: 644467392

Input:
997824195 298198038 671030405 831526 973640
694897941 219757278 695597597 220039071

Output: 885735196

Output: 885735196

Output: 885735196

Input:
284251850 196700229 713578389 995979 967011
237351355 75633985 237356031 75775611

Output: 889823267

Output: 889823267

Output: 889823267

Input:
727799968 611623105 644959424 942303 807555
372191613 152626658 372904242 153091978

Output: 433633

Output: 433633

Output: 433633

Input:
500000003 865102056 740048609 449299 846600
375530078 124770851 375530078 124770851

Output: 1

Output: 1

Output: 1

Input:
1 1 1 1 1
1 1 1 1

Output: 1

Output: 1

Output: 1


You are given two strings $$$s$$$ and $$$t$$$ consisting of lowercase Latin letters. The length of $$$t$$$ is $$$2$$$ (i.e. this string consists only of two characters).In one move, you can choose any character of $$$s$$$ and replace it with any lowercase Latin letter. More formally, you choose some $$$i$$$ and replace $$$s_i$$$ (the character at the position $$$i$$$) with some character from 'a' to 'z'.You want to do no more than $$$k$$$ replacements in such a way that maximizes the number of occurrences of $$$t$$$ in $$$s$$$ as a subsequence.Recall that a subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements.

Print one integer — the maximum possible number of occurrences of $$$t$$$ in $$$s$$$ as a subsequence if you replace no more than $$$k$$$ characters in $$$s$$$ optimally.

NoteIn the first example, you can obtain the string "abab" replacing $$$s_1$$$ with 'a' and $$$s_4$$$ with 'b'. Then the answer is $$$3$$$.In the second example, you can obtain the string "ssddsdd" and get the answer $$$10$$$.In the fourth example, you can obtain the string "aaacaaa" and get the answer $$$15$$$.

The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200$$$; $$$0 \le k \le n$$$) — the length of $$$s$$$ and the maximum number of moves you can make. The second line of the input contains the string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. The third line of the input contains the string $$$t$$$ consisting of two lowercase Latin letters.

Input:
4 2
bbaa
ab

Output: 3

Input:
7 3
asddsaf
sd

Output: 10

Input:
15 6
qwertyhgfdsazxc
qa

Output: 16

Input:
7 2
abacaba
aa

Output: 15

Output: 19900

Output: 19900

Output: 2206

Output: 713

Output: 232

Output: 276

Output: 59

Output: 32

Output: 2464

Output: 608

Output: 167

Output: 282

Output: 25

Output: 32

Output: 3741

Output: 1435

Output: 674

Output: 600

Output: 318

Output: 274

Output: 8984

Output: 6428

Output: 5415

Output: 4106

Output: 6216

Output: 3125

Output: 19900

Output: 19503

Output: 9177

Output: 8355

Output: 7065

Output: 6380

Output: 19900

Output: 10000

Output: 10000

Output: 10000

Output: 9927

Output: 9938

Output: 10000

Input:
2 0
as
as

Output: 1

Input:
2 1
as
sa

Output: 0

Input:
2 2
as
sa

Output: 1

Input:
2 1
aa
sb

Output: 0

Input:
11 4
bdfbdbccdad
ab

Output: 10

Output: 10000

Output: 10000


In Omkar's last class of math, he learned about the least common multiple, or $$$LCM$$$. $$$LCM(a, b)$$$ is the smallest positive integer $$$x$$$ which is divisible by both $$$a$$$ and $$$b$$$.Omkar, having a laudably curious mind, immediately thought of a problem involving the $$$LCM$$$ operation: given an integer $$$n$$$, find positive integers $$$a$$$ and $$$b$$$ such that $$$a + b = n$$$ and $$$LCM(a, b)$$$ is the minimum value possible.Can you help Omkar solve his ludicrously challenging math problem?

For each test case, output two positive integers $$$a$$$ and $$$b$$$, such that $$$a + b = n$$$ and $$$LCM(a, b)$$$ is the minimum possible.

NoteFor the first test case, the numbers we can choose are $$$1, 3$$$ or $$$2, 2$$$. $$$LCM(1, 3) = 3$$$ and $$$LCM(2, 2) = 2$$$, so we output $$$2 \ 2$$$.For the second test case, the numbers we can choose are $$$1, 5$$$, $$$2, 4$$$, or $$$3, 3$$$. $$$LCM(1, 5) = 5$$$, $$$LCM(2, 4) = 4$$$, and $$$LCM(3, 3) = 3$$$, so we output $$$3 \ 3$$$.For the third test case, $$$LCM(3, 6) = 6$$$. It can be shown that there are no other pairs of numbers which sum to $$$9$$$ that have a lower $$$LCM$$$.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \leq t \leq 10$$$). Description of the test cases follows. Each test case consists of a single integer $$$n$$$ ($$$2 \leq n \leq 10^{9}$$$).

Input:
3
4
6
9

Output:
2 2
3 3
3 6

Input:
3
4
5
2

Output:
2 2
1 4
1 1

Input:
8
527
622
63
423
147
791
838
903

Output:
31 496
311 311
21 42
141 282
49 98
113 678
419 419
301 602

Input:
6
861605021
68328580
877214985
692261986
3399371
684035729

Output:
1 861605020
34164290 34164290
292404995 584809990
346130993 346130993
199963 3199408
52618133 631417596

Input:
10
201963219
303973760
54544086
751923241
687055210
1649300
203977471
402504158
14556710
207186606

Output:
67321073 134642146
151986880 151986880
27272043 27272043
17486587 734436654
343527605 343527605
824650 824650
1 203977470
201252079 201252079
7278355 7278355
103593303 103593303

Input:
8
4
10
9
2
6
2
6
6

Output:
2 2
5 5
3 6
1 1
3 3
1 1
3 3
3 3

Input:
2
7
8

Output:
1 6
4 4

Input:
6
294048
763985
486901
359327
977269
431116

Output:
147024 147024
152797 611188
1471 485430
1 359326
1 977268
215558 215558

Input:
2
328547178
28450577

Output:
164273589 164273589
1 28450576

Input:
1
42443736

Output: 21221868 21221868

Input:
1
646185419

Output: 58744129 587441290

Input:
1
784975562

Output: 392487781 392487781

Input:
1
142930164

Output: 71465082 71465082

Input:
10
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000

Output:
500000000 500000000
500000000 500000000
500000000 500000000
500000000 500000000
500000000 500000000
500000000 500000000
500000000 500000000
500000000 500000000
500000000 500000000
500000000 500000000

Input:
1
1000000000

Output: 500000000 500000000

Input:
1
2

Output: 1 1

Input:
10
999999733
999999733
999999733
999999733
999999733
999999733
999999733
999999733
999999733
999999733

Output:
1 999999732
1 999999732
1 999999732
1 999999732
1 999999732
1 999999732
1 999999732
1 999999732
1 999999732
1 999999732

Input:
10
996788159
996788159
996788159
996788159
996788159
996788159
996788159
996788159
996788159
996788159

Output:
31627 996756532
31627 996756532
31627 996756532
31627 996756532
31627 996756532
31627 996756532
31627 996756532
31627 996756532
31627 996756532
31627 996756532

Input:
6
988945538
826161801
753987902
90107430
303400713
958438508

Output:
494472769 494472769
275387267 550774534
376993951 376993951
45053715 45053715
101133571 202267142
479219254 479219254

Input:
7
13881727
399705329
4040273
562529221
51453229
165146341
104085043

Output:
21589 13860138
25933 399679396
20509 4019764
28111 562501110
10211 51443018
17291 165129050
16363 104068680

Input:
3
312736423
170982179
270186827

Output:
19031 312717392
21701 170960478
16979 270169848

Input:
7
21103739
157343101
218561743
285460211
3775711
806739229
255032251

Output:
19853 21083886
16673 157326428
15139 218546604
25309 285434902
7753 3767958
30781 806708448
16063 255016188

Input:
2
30849937
619420033

Output:
22469 30827468
27961 619392072

Input:
1
792717909

Output: 264239303 528478606

Input:
6
682299640
402232729
615880174
837345547
139232179
210082106

Output:
341149820 341149820
1 402232728
307940087 307940087
156601 837188946
6053573 133178606
105041053 105041053

Input:
9
203197635
675378503
971363026
746226358
441100327
941328384
321242664
890263904
284574795

Output:
67732545 135465090
35546237 639832266
485681513 485681513
373113179 373113179
35257 441065070
470664192 470664192
160621332 160621332
445131952 445131952
94858265 189716530

Input:
2
565258040
932782779

Output:
282629020 282629020
310927593 621855186

Input:
10
998244353
998244353
998244353
998244353
998244353
998244353
998244353
998244353
998244353
998244353

Output:
1 998244352
1 998244352
1 998244352
1 998244352
1 998244352
1 998244352
1 998244352
1 998244352
1 998244352
1 998244352


Note that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter $$$y$$$ Koa selects can be any letter from the first $$$20$$$ lowercase letters of English alphabet (read statement for better understanding). You can make hacks in these problems independently.Koa the Koala has two strings $$$A$$$ and $$$B$$$ of the same length $$$n$$$ ($$$|A|=|B|=n$$$) consisting of the first $$$20$$$ lowercase English alphabet letters (ie. from a to t).In one move Koa:  selects some subset of positions $$$p_1, p_2, \ldots, p_k$$$ ($$$k \ge 1; 1 \le p_i \le n; p_i \neq p_j$$$ if $$$i \neq j$$$) of $$$A$$$ such that $$$A_{p_1} = A_{p_2} = \ldots = A_{p_k} = x$$$ (ie. all letters on this positions are equal to some letter $$$x$$$).  selects any letter $$$y$$$ (from the first $$$20$$$ lowercase letters in English alphabet).  sets each letter in positions $$$p_1, p_2, \ldots, p_k$$$ to letter $$$y$$$. More formally: for each $$$i$$$ ($$$1 \le i \le k$$$) Koa sets $$$A_{p_i} = y$$$. Note that you can only modify letters in string $$$A$$$.Koa wants to know the smallest number of moves she has to do to make strings equal to each other ($$$A = B$$$) or to determine that there is no way to make them equal. Help her!

For each test case: Print on a single line the smallest number of moves she has to do to make strings equal to each other ($$$A = B$$$) or $$$-1$$$ if there is no way to make them equal.

5
3
aab
bcc
4
cabc
abcb
3
abc
tsr
4
aabd
cccd
5
abcbd
bcdda

Note  In the $$$1$$$-st test case Koa:   selects positions $$$1$$$ and $$$2$$$ and sets $$$A_1 = A_2 = $$$ b ($$$\color{red}{aa}b \rightarrow \color{blue}{bb}b$$$).  selects positions $$$2$$$ and $$$3$$$ and sets $$$A_2 = A_3 = $$$ c ($$$b\color{red}{bb} \rightarrow b\color{blue}{cc}$$$).   In the $$$2$$$-nd test case Koa:   selects positions $$$1$$$ and $$$4$$$ and sets $$$A_1 = A_4 = $$$ a ($$$\color{red}{c}ab\color{red}{c} \rightarrow \color{blue}{a}ab\color{blue}{a}$$$).  selects positions $$$2$$$ and $$$4$$$ and sets $$$A_2 = A_4 = $$$ b ($$$a\color{red}{a}b\color{red}{a} \rightarrow a\color{blue}{b}b\color{blue}{b}$$$).  selects position $$$3$$$ and sets $$$A_3 = $$$ c ($$$ab\color{red}{b}b \rightarrow ab\color{blue}{c}b$$$).    In the $$$3$$$-rd test case Koa:   selects position $$$1$$$ and sets $$$A_1 = $$$ t ($$$\color{red}{a}bc \rightarrow \color{blue}{t}bc$$$).  selects position $$$2$$$ and sets $$$A_2 = $$$ s ($$$t\color{red}{b}c \rightarrow t\color{blue}{s}c$$$).  selects position $$$3$$$ and sets $$$A_3 = $$$ r ($$$ts\color{red}{c} \rightarrow ts\color{blue}{r}$$$).

Each test contains multiple test cases. The first line contains $$$t$$$ ($$$1 \le t \le 10$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of strings $$$A$$$ and $$$B$$$. The second line of each test case contains string $$$A$$$ ($$$|A|=n$$$). The third line of each test case contains string $$$B$$$ ($$$|B|=n$$$). Both strings consists of the first $$$20$$$ lowercase English alphabet letters (ie. from a to t). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

Input:
5
3
aab
bcc
4
cabc
abcb
3
abc
tsr
4
aabd
cccd
5
abcbd
bcdda

Output:
2
3
3
2
4

Input:
10
63
lififbihkchchkfkdjlldihjcfejlcglkfcebgfkchehkglgjijifldlcddihlk
ccfhhllhgfifgbjfhfhjciibjhhhiilfelichbckffileedkdcbgljlglegejdh
63
mnglnimelmikkdlinpkpgiljgmkkidmndjmgjildjgofjgpjkikeeohekghlpjf
miejldmhfkjehnjkmgodddfoegfnjfelmilmpmpigdfkfnnijipmijhlgjefhfj
64
efifcbadhaeghhgfdadffhafeggbcabdeffehghhhgiigeabedbdhgcdhegfbdbb
hefhfbigfcchdgdedahceeiedhahheeibdcaiaaiiiedfbcehgiefabbbachbaci
84
acbabbaccaabcabcaacccbcbbcaaacabacaccaaaccabbbbaaabbbbbcccbaccbbbbaabaacabcbccbcaacb
baaacbcaaabcc...

Output:
15
18
12
4
2
7
3
11
14
11

Input:
10
23
cdccbbcbcbbbcdbccbdbcdb
cccbccdbbcddcbdddbddbdd
38
lkmlojilojnjonnlonnmhkkhhjhmolnmnjmknk
jomhnojhokhnknkohiiomimomihnkhihjojnjn
63
hhekjljilhiellfedihjhiklildfhfjkihdjkilfllhfgjjldeddjdghedffihj
gelgielijleddljlhgghfkjggehiefkkkggjefjhhkhhkdikgkedehdgjhkkkif
8
eigcfhhb
bifbbgbh
97
ddcdddddcccccccccdddcccdcddcdccddccccdcddcdddcddcdcccdccccddccdcdcddccccdcddccdddccddccddcdddcddc
ccccddddcddccdcddcddcccdccddcccccdcddcdcccdcccccdcddccdddcddddcddccddcccdcdcddcddcdccddccdcdcdccc
33
ffffff...

Output:
4
10
13
6
2
0
15
16
15
9

Output:
19
19
19
19
19
19
19
19
19
19

Output:
0
0
0
0
0
0
0
0
0
0

Output:
18
34
14
16
38
4
8
14
28
2

Output:
33
36
4
10
4
10
16
12
6
17

Output:
0
0
0
0
0
0
0
0
0
0

Output:
18
16
7
10
5
8
4
3
2
0

Output:
38
36
33
26
16
28
22
24
22
19

Output:
34
16
34
22
28
4
1
1
1
1

Output: 5

Output:
18
15
8
6
6
5
5
4
1
0

Output:
10
30
18
28
27
12
10
19
16
3

Output:
19
19
19
19
19
19
19
19
19
19

Output:
0
0
0
0
0
0
0
0
0
0

Output: 2

Output: 0

Output:
0
0
0
0
0
0
0
0
0
0

Output:
0
0
0
0
0
0
0
0
0
0

Output:
38
36
34
22
27
28
16
12
21
16

Output:
9
10
11
9
5
4
6
4
2
0

Output:
38
36
34
32
29
27
17
12
11
15

Output:
17
15
11
7
6
5
4
4
2
0

Output:
38
36
33
32
21
25
16
12
11
11

Output:
13
11
9
9
5
6
4
3
2
0

Output:
38
36
33
26
25
22
19
13
12
17

Output:
11
8
14
7
10
5
3
2
2
0

Output: 4

Output: 8

Output: 5

Output: 11

Output: 7

Input:
10
20
abcdefghijklmnopqrst
bcdefghijklmnopqrsta
20
bcdefghijklmnopqrsta
cdefghijklmnopqrstab
20
cdefghijklmnopqrstab
defghijklmnopqrstabc
20
defghijklmnopqrstabc
efghijklmnopqrstabcd
20
efghijklmnopqrstabcd
fghijklmnopqrstabcde
20
fghijklmnopqrstabcde
ghijklmnopqrstabcdef
20
ghijklmnopqrstabcdef
hijklmnopqrstabcdefg
20
hijklmnopqrstabcdefg
ijklmnopqrstabcdefgh
20
ijklmnopqrstabcdefgh
jklmnopqrstabcdefghi
20
jklmnopqrstabcdefghi
klmnopqrstabcdefghij

Output:
20
20
20
20
20
20
20
20
20
20

Output: 12

Output: 16

Output: 19

Input:
3
1
j
j
5
iijhi
hhjjj
5
ccccc
cccdd

Output:
0
2
1

Input:
4
5
qpqoq
ooopo
3
kkl
lll
5
hifif
fhhhi
4
bbbb
ccbb

Output:
3
1
3
1

Output:
2
18
8
6
28
3
2
1
1
3

Output:
10
10
22
4
30
0
1
11
12
11

Output:
26
30
28
5
15
1
6
1
1
1

Output:
26
14
38
10
0
29
7
1
1
0

Output:
2
0
6
10
4
2
6
1
1
1

Output:
18
14
12
2
0
22
6
6
3
1

Input:
10
89
nnonooonnnnnnooooonnnoooonoonnonnnonnnnooonnooonooooononnnonononnnooononoonoonoonoonnnonn
nnnnonnnoonooonnonoonnoonnonononooonnnnnoonnnnnonnoonononononoononnnoonnnooonoooononoonon
19
ggggggggggggggggggg
ggggggggggggggggggg
71
opqqorrqqorrororqpoprpprpooprprpqpopoorqqpopqrpqrqopproqproporoqrrppqro
qoqoqpppopoooqoqorpoproopoqoqppqqqpqrorqqqqqqpoqpropppqqropoppqqopppopp
49
noonoonnoonnoooooooonnoonnonononnnoonnnononoooono
noonoononnnoonnnnnnnoononnononnooonoonnoonoonnnno
85
onononnnnoononn...

Output:
2
0
6
2
2
8
8
8
8
7

Input:
10
67
eegfeggefefgggegegffgfefffgeffgegefeegeeggeegeefgefgeeeeffeeegffeff
ffgefeeffefggggfeeggfeggfeffgeeggggffggggfegeegeefggfggfeegegffgfef
29
fbdcfdceeceefeeaaacedcfdbefff
cdcdbcbefeddeeccabfbfcccccaad
7
hfffeee
gffeegh
81
cbbbcccbbbbcbbcbbbbbbccbcbccbccbbccbcccbccbccbbcbccbccbbbcccbccccbcbcccbbbbbccccb
cbccbbbbbbbccbbcbccccbcccbcbcbbcbbccbcccccbbccbbbbbbbbbcbcccccbbcbcbcbcccbcccbbbb
95
ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
ggggggg...

Output:
4
7
3
2
0
6
7
8
0
7

Input:
10
49
eegeehheeefehehggffehheghggfhgfggghfggfgeghfhffeh
efgfghgfheefhegfghffghfegehfggfghhhffegeeeffeefhf
16
efffdfeedffffdfe
efeedefdffefdfde
59
fffeeghghehgeigffjiiigeigggejhjgejjjjihjijffehihhjfjjejfgeh
jfhhhiehjeihhgeiehgfeihfifggjeifgjefihhghgjjeighiigjgffefji
4
gggg
hfhf
19
jjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjj
42
nmqnpmnpqnqpponoqqopqqqqooqommqmnnmpqpqmnp
mqpqmonqmopmppmpnnnomonomppmmmqmqoqpoonomm
42
qornoqosnqrnsnpnrqsqqpsspnpspqnqqrsrsorrpq
opporoonrrooqnssnqqsqqssnsrrsnrqnq...

Output:
6
3
9
2
0
6
8
7
8
2

Input:
10
18
effeedeefdeefddedd
dfddeeddffdffffdff
26
feefdegggefdegeefeegeddfdg
fgeffgfeegfffgdggeefgggfdg
94
omooolllolmlnlnmolnoonmoloollolllnoooolololnmmnmnnnommlommomolllmmnlommlnlmmllllnoomllloomllmn
mlmlmllommnlnoolnlollmlmnmnlnlononmomnolmmlnooomommmolnomoonlnnloomoomlmnooomlmlnlommnnnnmnlnm
11
degefefeedf
efdffffgdfe
16
dddddccdccdddddd
dcccdcddcddcdccd
37
bcbceadebbeeaebbacddddeeebbdebcceeada
edeadcbdebccbbcdddabedeecdedbadabacba
4
gfhf
hiik
54
dccccdcccdccdccddcccddccddcdddddcdcc...

Output:
3
4
5
4
2
7
4
2
4
8

Input:
10
100
ijikijjijijjjkikijkjjkiikijiikkjjjjkkkikkjijkijiiijjijikikjjjkjkijikkjkkkkiiikjiiijjkikkkkjkkjjjjjik
jjijikjijiijjkikkjjjjikjkkiikikjiijijjjkjikkkkkiikkkijjkijjkiiiijikkjjkjjkikkiikkjjjijjjiikjkijjjjji
96
ooonkmnnlmknoknmlmollknonnnkmnoklnnkloklmonkomnmlmnmlmonoknkonlllkmklonlklolonknokonolmkmlmnnllk
nnlonomnmlmmkkmkmnnommlloknklknmknlnkolmklnnnnknmlmlnlmmmkkloolnokoonnkkmnlooollmolnmnmoknlmkonn
27
ddeeededeeeeeddeedeeedeeede
eddeeedddddedeeeeededdeeedd
21
prprsqqrrspqrosqosrqp
sqororqrs...

Output:
4
8
2
6
8
8
7
0
2
4

Input:
10
77
hhiihiiihhhiiihiiihhhhiiiihhiiiiihhiiiiihiihihhhhhhhihhiiihiiiiiihhiihihhiiih
hhiiihihiiihihiiiiihhihiiihiiiiiiihiihiihihiiiihhhhhhiihiiiiihhihhhhhhiihhhih
89
opoppoppopppppppopooppoppppppopoppopooppoooppooopoppoopppopppopppopoopoopopoopppopppopopp
ooppopopopppooooppoopppopoopoopoppppoppppopopooppppopoooopopopoopopppppoooooooooooopppppp
99
knmknklllmlmonnkkkkkkmkllmmoolkoonmonnmklmokolmmlmkknnnlmmnokknklloklnklommnnlmnomlkolloklnmkomlolk
nmnnkoonkomonnlmklokmlkmmkknolknknollnloklnoonklnmknmn...

Output:
2
2
8
2
4
2
2
5
0
4

Input:
10
59
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
9
egdegfdfg
dfeeffdgf
7
eeefeef
feffefe
54
ffhfffehefffgffhheehheghggffehehfhgffffhgehfggggeghfgf
eefffefeggfefgefhfhhggffgeefgfefgeeefhfgfefhgfffeehfhf
37
oopmmnnoomomlmloonnmnloonnplpoomppnmo
lllllmmnolnplpnollnplnoopnllomoolmolo
1
c
a
73
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
ooooooooooooooooooooooooooooooooooooooooooooooooo...

Output:
0
4
2
6
6
1
0
2
8
2

Input:
10
29
osooqnnnqoopppsossonssrnroqqs
qqoospsqssnqssqqopqpqsqnrrqsn
9
iiiiiiiii
iiiiiiiii
84
onoomnnoonoomnmnmmmmmononnomnonmnoomnmnomooomooonnmmnonommmmnmnnmmmnnomoonomnmmnnonm
onnononononmmmnnonmoomnnnnmmmnonmonoonoommmnmomnmoomomnoonoomnnnnnmnmmmmnnonmnonnonn
70
fghffehfeeeefgegfeegheeefhfgefegheefhfggfegefehgfghgfhghffeffeghfeeffg
hegfhffghggfefefehfehhgghegfgehhfhheheheffgfeeeeffheehfgeefgeheehhgfgh
22
hihjhhjikgjikhgigkjjih
hikjhhhhkijhhkihkhkgjk
97
edggdfeegfeggfdgdfggffdfegeeeggdffee...

Output:
6
0
4
6
6
6
2
7
4
8

Input:
10
6
llllll
llllll
81
opopoooooppoooopopopopoppppoppoopoppooopopopoopooopoooppoppppppppppopoopoppppppoo
ppppoooooppopoopppopppoppoopoopopopppppoooopooppoppooopoppoopooopooopooopoooopopp
32
bcbeddcbdddececebbcbdeedbedbdeeb
cbddeedebdcbbbbcdceceddcdddecdbb
36
cccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccc
44
ffffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffff
2
oo
oo
39
nnnommmmnomnnnnmnnmmmnonnnoonnmnnoonnnn
nnnonnmoononmm...

Output:
0
2
6
0
0
0
4
9
0
8

Input:
10
80
nmmmnmnnnnnnmnnnmnnnnnmmmnnnnmnnmnmmmnmmnnmmmnmmmnnnmmmnnmmnmnnnmmnmnmmmmnmmnnnm
mnnnmnmnnmnmmmmnnmmnmmnnnmnmnnnnmnmmnmnmnnmnmnmnnmmmnnmnmnnmnmnnmmmmnnmnmnmnmmmm
33
dgeghfcegeggefhedghcfegedhehefggc
echfdfcchfhdhfhdgeheefeeeceedfgcd
54
dhhfccdffchdfdhggdeechceecfeheghegefccchcgfcgfddeccgcd
dhdggefdhggcfgfccfegfgefegchegdhcegdhghedhechfdhdcffeg
47
dcdcddccccdcdddcdcccdddcccdcccddccddcdddcdddccd
ccccccdddddddddcccddcdddddddccdddcdccccddddcddd
33
jklkmnnnmimmnkkjjkllkilmlkmllmnjn
lkmlnkjj...

Output:
2
7
9
2
8
0
2
8
0
9

Input:
10
74
gilnrhiljjpnoognjhpjninjgglprgniqjlpqlirjphlnjmrjloongngljjqiqgphkgllnrkqp
rnpgnrkphhjgijigpkpnjmjkgnrrrjongkigjhjgimlokkhrhlknqknnpmgpimhlplpkropohg
67
gkmhikhhlkjjmkilklmglljklkjlkiihmhgkhimhglllmjjihlhkgkkmmgmmghjgikj
kjliiijgkjgmhlhkkggjjmjljihmljjhmmlghgghighgljmmjhigimmigjiiggjhlgi
53
hlkbkekgdjdlkiiekbieeheijbcjdfikclfgchleccjfhcjgkeegj
jjikhjjdkhciigbjkbfggecfeihdccdjbihgchcifbgekkjlhgcbg
78
lpjpjnlklkoihpiqnjpholinjihnimoipqipnkpnonmhnopkkmljnqlimlnhmmllkijjkmimqoklpm
khijmmmikhn...

Output:
17
10
14
15
4
6
12
8
7
12

Input:
10
38
nlpilhimpokmqqoipoilqiomohnsqqslprmmnm
jqslnjrnprhkiolhshkqsronprklopppnslimh
52
efheeefffeiegfgghhfeiieeihehgefieffhhihgiiigeieefehi
hhihefhehhhiiihggggfifheeehigeiggffhegiehfhgfhifhiff
24
gcjefeihcdefjejjfgicjggi
ijiidgecjdhjjedcgffedieh
41
fffffffffffffffffffffffffffffffffffffffff
fffffffffffffffffffffffffffffffffffffffff
67
gfcgebfjhihieeggggcjjcciijccejhichdfhhijejffhbdiiejejdighjhhgjggdfb
iddicbjdjccfccbidfegecigcfecjhfdhdgbfbhfeecdbibeedjdgifbbjjjfgihhhb
26
ehehgdgfgiidighieff...

Output:
14
7
10
0
13
7
11
8
13
15

Input:
10
99
lcegieajggfkdjjkbccglihkfbhjhgdhgcecjgdilghkjjjfbdflgjifchcegjadahekekibbaaakfhhjeclijfifflcfbbhabc
degccajhjlhlcjdggkbjcfjeackdhblalibbldkfcicbibjlkhjdiicgafhafkhhfgkgdadifidfdjehklehaeielefjbbccage
44
iliiihihljhjiijkklliilkkkkiijkijhkjihjjlkkki
kkhjiiiiijhikjlkhkkilkkkhijlljjjhkljhlikjlij
21
gldgfhhhgiikkelfjdkdj
kefifiejgjgfjkfddhgke
89
eccadbcecdcaebbcccaeebdeecdeaaecdacadabaaaabdceacdcdacbcadeedbedebeacebbeedeabadcbdcdeedb
cddbbeeabbbdbcdaceebaedbadbbbbadbcebebeadccdaecacdeebbaebccd...

Output:
19
6
11
8
8
10
0
14
12
0

Input:
10
96
cdcddcccccceecdddcddddceceeeedcddcedccccdedcdddcecedeecccccdccdeecedddedccedccdddceecccdcceeecec
ccecdeeccdceecececddecddcdcceddeedcdeedceddecccededeeeddeddcdedddcdececeeedcedddeceecdeeeddddedc
56
gjjehgddghjhhfddgfjijfhiiehdfhdfeeefgiiegdihfeiigegjihjj
jdffghgjeihijjeeejdeffihigehghfgijgdgejdjjedjegiieeieedg
88
lkjkihihimninmiihljmminhmkllkllhijjknjklnhhhknmilhlnjknikjnhhljihhkinjlnhkhmjkilnnnjkijn
iiikmilhlkmnikinjnjnnkiihlnnlikikkkjhkhmmhkllnikikhkjjljmmimlhhkimklhjlmjhhhimnijnkijkhi
96
...

Output:
4
10
10
6
9
3
16
0
13
12

Input:
10
52
ddedddeeeddedddddeeeeeeeededdeddeedeeeeddedeeeedddee
eddeedddeeeddeddedddedeeeeddddeeededdddddeeeedededdd
17
lnlkkjljllmijjhik
kghjkhgkmmhhlihmn
97
ejlehbfdeeiegclehkjifececikgljkhhgfffhjlklhgljbkjjjghcecedfgejhedgiekikhbebejldhkjkghchccllgklkjl
lchjifggidigkibdkjbkiciidgfkbkiegdkfijlgciigeledbicjciikigkflhjhjfkidjjdggfbdeiilidlcbekjdilgjhfe
64
hdmjbgdmeilcgfcighidjgkfddbihgcdbikggjjkfjdcechcfcifjcgfmgebhjef
flkeefbgkjeklhicbhhelhgdcfddbdihmeeffmhmklggdkfmbdfdjjcidfffhiil
20
hhhhhhhhhhh...

Output:
2
8
14
16
0
3
15
16
2
4

Input:
10
21
effeeffeeeeeffffefefe
feeeeeffeefeeeeeffeef
68
njcdmhgjlkdkcgmneilghddcijieegeigcgkegcjmjlkgfnfdceckkknfejeicjkfjij
gjmeehldfhfimjflegnhlmdddineijnkcdgffggmdijnhkdnidclmelieedfeinmiihc
6
fbfcbf
fcgbbf
23
ohkmmmknjmmjnjiihmliojl
lpkimhlolnjjiolnhmiljlh
30
gfeedeedcdbiecgbhgieggcffjcjbg
jdefchiefjjccdgdbhjfgghjbfhbdd
100
gffhgfhfhhgffhfffhffgffghhhffgfhffhfghgfggfhghhhhgggfhhhgfggggfhhfhghghffghhhffhfhhfgfffffhffgghhhgh
fhfggffhhhghghhfhfgfgfhghhfffgfghfffgffghggghhfgghhfgfhhghghhhghf...

Output:
2
16
3
10
10
4
6
15
7
8

Input:
10
89
eeefefffefffefeefffffeeeeeffeefeffeeeefeffeffeeeefeefeffefeffefeeeeeeffeefffeeffeeeffeeef
eeeffefeffeffffffffeeeeeefeeeffffefffeefeffeefefeeeeefefeefffefeffffeeeeefeefffeeeeffeeef
93
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
61
dadcdcbcbaaacdccdcaadaadaabbbdacabacddddadaddbdadcbccabdbbcdc
bdddddabdbdaccccaabadaddcdbcbbdaadcbaaabaadbadaddabbcdddacca...

Output:
2
0
6
8
4
0
0
13
10
6

Input:
10
63
nongpppjnhkolipplhhgghklkknmihohohjmiollplhklhmnkohokhnojmjjmok
jgnipgippnjilnkhnjnnlkmmlnnnopgkmlggkimhpjknihpiignjgkipmgnhihg
93
bcccbcbbcccccccbccccbcccbbcbcbbbbccbccbcbccbcbbbbbbccbbcbbcccccbcccbcccccccbbcccbbbbcbccbbccc
bccbbcccbbccbcccbcbbbcccccbbcbbcbbcbbcbbbbbbbbbbbbcbbcbcbbccbcccbcbccbbbbcbccbbccbbcbbcbccbcb
23
mjllhijmllnhkjjjmihhmli
kkhmkmmijlkkmkljilhnkmm
17
mjhmhkggiflihlfff
gfimmhjifmghjlffg
59
jjoghfjmnlgknjihgnhjngmjogolgomfmjfglkhkhnnijmimjfjlnnhmhgo
jnlgfnggkinohkjijo...

Output:
13
2
8
9
14
17
11
13
4
17

Output:
0
0
0
0
0
0
0
0
0
0

Output: 2

Output: 8

Output: 0

Output: 2

Output: 28

Input:
1
6
abcabc
bcacab

Output: 4


The only difference between easy and hard versions is on constraints. In this version constraints are lower. You can make hacks only if all versions of the problem are solved.Koa the Koala is at the beach!The beach consists (from left to right) of a shore, $$$n+1$$$ meters of sea and an island at $$$n+1$$$ meters from the shore.She measured the depth of the sea at $$$1, 2, \dots, n$$$ meters from the shore and saved them in array $$$d$$$. $$$d_i$$$ denotes the depth of the sea at $$$i$$$ meters from the shore for $$$1 \le i \le n$$$.Like any beach this one has tide, the intensity of the tide is measured by parameter $$$k$$$ and affects all depths from the beginning at time $$$t=0$$$ in the following way:  For a total of $$$k$$$ seconds, each second, tide increases all depths by $$$1$$$.  Then, for a total of $$$k$$$ seconds, each second, tide decreases all depths by $$$1$$$.  This process repeats again and again (ie. depths increase for $$$k$$$ seconds then decrease for $$$k$$$ seconds and so on ...).Formally, let's define $$$0$$$-indexed array $$$p = [0, 1, 2, \ldots, k - 2, k - 1, k, k - 1, k - 2, \ldots, 2, 1]$$$ of length $$$2k$$$. At time $$$t$$$ ($$$0 \le t$$$) depth at $$$i$$$ meters from the shore equals $$$d_i + p[t \bmod 2k]$$$ ($$$t \bmod 2k$$$ denotes the remainder of the division of $$$t$$$ by $$$2k$$$). Note that the changes occur instantaneously after each second, see the notes for better understanding. At time $$$t=0$$$ Koa is standing at the shore and wants to get to the island. Suppose that at some time $$$t$$$ ($$$0 \le t$$$) she is at $$$x$$$ ($$$0 \le x \le n$$$) meters from the shore:  In one second Koa can swim $$$1$$$ meter further from the shore ($$$x$$$ changes to $$$x+1$$$) or not swim at all ($$$x$$$ stays the same), in both cases $$$t$$$ changes to $$$t+1$$$.  As Koa is a bad swimmer, the depth of the sea at the point where she is can't exceed $$$l$$$ at integer points of time (or she will drown). More formally, if Koa is at $$$x$$$ ($$$1 \le x \le n$$$) meters from the shore at the moment $$$t$$$ (for some integer $$$t\ge 0$$$), the depth of the sea at this point  — $$$d_x + p[t \bmod 2k]$$$  — can't exceed $$$l$$$. In other words, $$$d_x + p[t \bmod 2k] \le l$$$ must hold always.  Once Koa reaches the island at $$$n+1$$$ meters from the shore, she stops and can rest.Note that while Koa swims tide doesn't have effect on her (ie. she can't drown while swimming). Note that Koa can choose to stay on the shore for as long as she needs and neither the shore or the island are affected by the tide (they are solid ground and she won't drown there). Koa wants to know whether she can go from the shore to the island. Help her!

For each test case: Print Yes if Koa can get from the shore to the island, and No otherwise. You may print each letter in any case (upper or lower).

NoteIn the following $$$s$$$ denotes the shore, $$$i$$$ denotes the island, $$$x$$$ denotes distance from Koa to the shore, the underline denotes the position of Koa, and values in the array below denote current depths, affected by tide, at $$$1, 2, \dots, n$$$ meters from the shore.In test case $$$1$$$ we have $$$n = 2, k = 1, l = 1, p = [ 0, 1 ]$$$.Koa wants to go from shore (at $$$x = 0$$$) to the island (at $$$x = 3$$$). Let's describe a possible solution:  Initially at $$$t = 0$$$ the beach looks like this: $$$[\underline{s}, 1, 0, i]$$$.  At $$$t = 0$$$ if Koa would decide to swim to $$$x = 1$$$, beach would look like: $$$[s, \underline{2}, 1, i]$$$ at $$$t = 1$$$, since $$$2 > 1$$$ she would drown. So Koa waits $$$1$$$ second instead and beach looks like $$$[\underline{s}, 2, 1, i]$$$ at $$$t = 1$$$.  At $$$t = 1$$$ Koa swims to $$$x = 1$$$, beach looks like $$$[s, \underline{1}, 0, i]$$$ at $$$t = 2$$$. Koa doesn't drown because $$$1 \le 1$$$.  At $$$t = 2$$$ Koa swims to $$$x = 2$$$, beach looks like $$$[s, 2, \underline{1}, i]$$$ at $$$t = 3$$$. Koa doesn't drown because $$$1 \le 1$$$.  At $$$t = 3$$$ Koa swims to $$$x = 3$$$, beach looks like $$$[s, 1, 0, \underline{i}]$$$ at $$$t = 4$$$.  At $$$t = 4$$$ Koa is at $$$x = 3$$$ and she made it! We can show that in test case $$$2$$$ Koa can't get to the island.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$)  — the number of test cases. Description of the test cases follows. The first line of each test case contains three integers $$$n$$$, $$$k$$$ and $$$l$$$ ($$$1 \le n \le 100; 1 \le k \le 100; 1 \le l \le 100$$$) — the number of meters of sea Koa measured and parameters $$$k$$$ and $$$l$$$. The second line of each test case contains $$$n$$$ integers $$$d_1, d_2, \ldots, d_n$$$ ($$$0 \le d_i \le 100$$$)  — the depths of each meter of sea Koa measured. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$100$$$.

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

Output:
YES
NO
YES
YES
YES
NO
NO

Output:
Yes
No
Yes
Yes
Yes
No
No

Output:
Yes
No
Yes
Yes
Yes
No
No

Input:
32
3 1 2
1 3 1
3 1 2
1 3 2
3 1 2
1 3 3
3 1 2
2 1 1
3 1 2
2 1 2
3 1 2
2 1 3
3 1 2
2 2 1
3 1 2
2 2 2
3 1 2
2 2 3
3 1 2
2 3 1
3 1 2
2 3 2
3 1 2
2 3 3
3 1 2
3 1 1
3 1 2
3 1 2
3 1 2
3 1 3
3 1 2
3 2 1
3 1 2
3 2 2
3 1 2
3 2 3
3 1 2
3 3 1
3 1 2
3 3 2
3 1 2
3 3 3
3 1 3
1 1 1
3 1 3
1 1 2
3 1 3
1 1 3
3 1 3
1 2 1
3 1 3
1 2 2
3 1 3
1 2 3
3 1 3
1 3 1
5 100 100
100 100 100 5 3
1 1 1
0
4 1 1
0 0 1 0
6 4 7
1 2 3 4 3 2

Output:
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes

Output:
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes

Output:
NO
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES

Input:
5
20 31 5
4 4 3 0 0 1 0 0 5 4 4 5 3 5 0 5 2 2 0 1
20 49 5
1 2 2 1 4 3 1 5 0 3 2 1 0 5 1 2 3 4 5 4
20 40 69
59 67 9 69 34 27 6 0 4 25 34 28 35 17 0 9 28 62 1 9
20 19 92
1 2 57 53 32 11 15 70 26 81 83 48 5 87 60 18 31 85 23 10
20 44 74
68 4 74 65 64 50 60 9 3 39 61 49 57 74 21 70 31 18 24 21

Output:
No
No
Yes
Yes
Yes

Output:
No
No
Yes
Yes
Yes

Output:
NO
NO
YES
YES
YES

Input:
5
20 51 45
11 14 17 24 45 0 17 14 15 26 41 34 36 6 41 7 44 35 8 33
20 62 76
56 14 14 65 62 9 76 40 42 55 18 53 0 63 13 13 72 70 9 30
20 29 53
32 41 17 30 12 9 32 35 28 4 29 33 4 49 0 20 33 47 20 21
20 8 15
7 11 15 6 15 4 5 9 5 9 13 10 3 6 0 5 1 11 12 14
20 93 97
1 33 39 31 21 52 73 66 40 50 59 26 41 38 18 49 76 49 7 37

Output:
No
Yes
Yes
Yes
Yes

Output:
NO
YES
YES
YES
YES

Output:
No
Yes
Yes
Yes
Yes

Input:
1
100 90 100
0 27 51 8 16 1 17 92 57 5 21 24 4 92 1 20 58 99 77 46 84 58 40 83 3 15 20 83 41 75 75 12 95 51 70 90 39 86 31 7 44 71 24 32 83 51 68 89 20 35 61 49 3 4 91 16 58 71 92 93 62 65 94 42 78 82 90 87 91 68 71 1 47 91 88 22 91 64 75 21 90 57 10 69 60 96 66 86 4 3 71 84 75 55 56 96 73 21 48 47

Output: YES

Output: Yes

Input:
7
3 26 29
0 29 17
27 29 16
0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 6 6 6 6 6 6 10 10
3 10 17
0 3 3
21 21 17
0 0 0 12 12 12 12 12 12 2 1 1 1 1 1 1 17 17 17 17 17
17 13 19
0 0 7 7 7 19 19 19 19 19 19 19 19 6 6 6 4
10 27 8
0 0 0 8 8 6 6 6 6 6
6 36 52
0 0 0 0 8 8

Output:
Yes
No
Yes
No
No
No
Yes

Output:
YES
NO
YES
NO
NO
NO
YES

Output:
Yes
No
Yes
No
No
No
Yes

Input:
6
14 26 12
0 0 0 0 0 12 12 12 3 3 3 3 3 3
14 33 17
0 14 14 11 7 7 7 7 7 7 0 0 0 0
9 6 4
0 0 0 0 1 1 0 0 0
30 33 60
0 0 0 0 48 48 48 48 48 48 48 48 48 42 42 42 42 42 42 42 42 42 36 13 2 2 2 2 51 51
8 18 5
0 0 1 1 1 1 2 2
6 22 21
0 0 0 0 0 0

Output:
No
Yes
Yes
Yes
Yes
Yes

Output:
No
Yes
Yes
Yes
Yes
Yes

Output:
NO
YES
YES
YES
YES
YES

Input:
6
28 43 27
0 0 0 0 0 0 0 0 0 12 12 12 12 12 12 12 12 12 12 4 20 13 13 13 13 13 13 13
7 6 1
0 0 0 0 0 0 0
6 23 23
0 0 0 0 0 0
12 45 33
0 0 0 10 10 10 10 10 10 10 10 10
15 47 24
0 20 20 2 2 0 0 0 0 4 4 14 14 23 23
19 10 12
0 0 0 0 0 0 0 0 0 8 8 8 10 10 0 0 9 9 9

Output:
Yes
No
Yes
Yes
No
Yes

Output:
Yes
No
Yes
Yes
No
Yes

Output:
YES
NO
YES
YES
NO
YES

Input:
1
26 40 25
0 0 0 16 16 16 16 16 16 20 21 9 9 9 9 9 2 2 2 2 2 2 2 2 0 7

Output: YES

Output: Yes

Input:
32
3 1 1
1 1 1
3 1 1
1 1 2
3 1 1
1 1 3
3 1 1
1 2 1
3 1 1
1 2 2
3 1 1
1 2 3
3 1 1
1 3 1
3 1 1
1 3 2
3 1 1
1 3 3
3 1 1
2 1 1
3 1 1
2 1 2
3 1 1
2 1 3
3 1 1
2 2 1
3 1 1
2 2 2
3 1 1
2 2 3
3 1 1
2 3 1
3 1 1
2 3 2
3 1 1
2 3 3
3 1 1
3 1 1
3 1 1
3 1 2
3 1 1
3 1 3
3 1 1
3 2 1
3 1 1
3 2 2
3 1 1
3 2 3
3 1 1
3 3 1
3 1 1
3 3 2
3 1 1
3 3 3
3 1 2
1 1 1
5 100 100
100 100 100 5 3
1 1 1
0
4 1 1
0 0 1 0
6 4 7
1 2 3 4 3 2

Output:
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
YES
YES
YES

Output:
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
Yes
Yes
Yes

Output:
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
Yes
Yes
Yes

Input:
32
3 1 3
2 2 1
3 1 3
2 2 2
3 1 3
2 2 3
3 1 3
2 3 1
3 1 3
2 3 2
3 1 3
2 3 3
3 1 3
3 1 1
3 1 3
3 1 2
3 1 3
3 1 3
3 1 3
3 2 1
3 1 3
3 2 2
3 1 3
3 2 3
3 1 3
3 3 1
3 1 3
3 3 2
3 1 3
3 3 3
3 2 1
1 1 1
3 2 1
1 1 2
3 2 1
1 1 3
3 2 1
1 2 1
3 2 1
1 2 2
3 2 1
1 2 3
3 2 1
1 3 1
3 2 1
1 3 2
3 2 1
1 3 3
3 2 1
2 1 1
3 2 1
2 1 2
3 2 1
2 1 3
3 2 1
2 2 1
5 100 100
100 100 100 5 3
1 1 1
0
4 1 1
0 0 1 0
6 4 7
1 2 3 4 3 2

Output:
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
Yes
Yes

Output:
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES

Output:
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
Yes
Yes

Input:
32
3 2 1
3 1 1
3 2 1
3 1 2
3 2 1
3 1 3
3 2 1
3 2 1
3 2 1
3 2 2
3 2 1
3 2 3
3 2 1
3 3 1
3 2 1
3 3 2
3 2 1
3 3 3
3 2 2
1 1 1
3 2 2
1 1 2
3 2 2
1 1 3
3 2 2
1 2 1
3 2 2
1 2 2
3 2 2
1 2 3
3 2 2
1 3 1
3 2 2
1 3 2
3 2 2
1 3 3
3 2 2
2 1 1
3 2 2
2 1 2
3 2 2
2 1 3
3 2 2
2 2 1
3 2 2
2 2 2
3 2 2
2 2 3
3 2 2
2 3 1
3 2 2
2 3 2
3 2 2
2 3 3
3 2 2
3 1 1
5 100 100
100 100 100 5 3
1 1 1
0
4 1 1
0 0 1 0
6 4 7
1 2 3 4 3 2

Output:
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES

Output:
No
No
No
No
No
No
No
No
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
Yes
Yes

Output:
No
No
No
No
No
No
No
No
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
Yes
Yes

Input:
29
3 2 2
3 3 1
3 2 2
3 3 2
3 2 2
3 3 3
3 2 3
1 1 1
3 2 3
1 1 2
3 2 3
1 1 3
3 2 3
1 2 1
3 2 3
1 2 2
3 2 3
1 2 3
3 2 3
1 3 1
3 2 3
1 3 2
3 2 3
1 3 3
3 2 3
2 1 1
3 2 3
2 1 2
3 2 3
2 1 3
3 2 3
2 2 1
3 2 3
2 2 2
3 2 3
2 2 3
3 2 3
2 3 1
3 2 3
2 3 2
3 2 3
2 3 3
3 2 3
3 1 1
3 2 3
3 1 2
3 2 3
3 1 3
3 2 3
3 2 1
5 100 100
100 100 100 5 3
1 1 1
0
4 1 1
0 0 1 0
6 4 7
1 2 3 4 3 2

Output:
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
YES
NO
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
YES

Output:
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes

Output:
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes

Input:
1
100 96 83
0 0 0 0 0 0 19 19 34 34 34 34 34 34 34 34 34 19 0 0 0 0 0 0 0 0 11 50 50 50 34 34 34 34 34 37 17 72 32 32 41 23 58 58 61 24 24 24 24 56 56 53 53 53 53 53 53 53 42 42 42 65 65 65 62 62 62 58 58 58 58 58 58 9 8 45 45 45 45 45 45 45 45 25 25 21 21 21 21 21 21 21 21 21 21 21 21 21 21 21

Output: YES

Output: Yes

Input:
5
20 79 89
89 4 44 33 7 40 52 45 34 26 7 59 34 59 67 20 88 58 3 24
20 72 60
51 45 26 59 57 54 51 33 32 24 46 31 11 10 5 42 52 10 47 46
20 26 32
31 27 14 7 2 23 22 21 19 27 31 12 23 31 0 11 28 20 31 30
20 89 47
30 25 36 33 38 4 16 40 14 0 26 22 37 7 10 45 16 19 15 5
20 35 12
8 6 9 6 7 1 2 7 7 12 0 9 6 8 4 3 11 1 2 5

Output:
Yes
No
No
Yes
No

Output:
Yes
No
No
Yes
No

Output:
YES
NO
NO
YES
NO

Input:
5
20 3 38
18 38 1 16 1 31 33 13 25 36 25 1 24 29 32 27 11 25 7 5
20 85 39
4 4 1 27 1 26 25 20 13 30 3 7 5 33 19 16 1 33 38 37
20 14 20
9 11 15 7 14 7 5 2 14 19 8 10 16 13 19 5 18 0 0 10
20 70 71
29 31 33 3 13 28 52 46 14 7 39 42 16 31 21 61 39 51 43 12
20 85 30
14 18 0 12 1 1 2 5 14 29 4 4 1 11 2 28 3 12 24 20

Output:
Yes
No
No
Yes
No

Output:
Yes
No
No
Yes
No

Output:
YES
NO
NO
YES
NO

Input:
1
100 100 100
0 26 47 30 76 93 69 0 27 71 71 54 87 52 96 27 44 9 13 5 83 55 27 19 70 100 83 85 50 37 47 85 0 5 16 33 51 93 86 77 76 62 79 83 58 78 24 10 54 49 12 79 62 96 58 58 81 14 25 9 70 35 18 54 50 80 99 90 12 52 8 44 75 82 69 85 29 41 7 39 74 22 23 87 47 71 89 7 96 30 51 75 27 92 94 13 7 61 20 7

Output: No

Output: NO

Input:
1
99 1 1
0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 1 0 0 1 0 1 1 0 1 1 1 0 1 0 0 0 1 1 1 1 0 0 1 0 1 0 0 1 0 0 1 1 0 0 0 0 1 1 0 1 1 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 0 0 0 1 0 0 0 1 1 1 1 1 1 0 0 0 0 1 0 0 1 1 1 0 1 0 0

Output: No

Output: NO

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

Output: No

Output: NO

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

Output: No

Output: NO

Input:
1
100 50 70
0 0 0 6 3 3 3 3 2 31 44 44 44 44 44 44 44 44 44 23 23 23 23 23 67 67 67 19 19 19 34 34 34 34 34 34 34 34 48 48 48 48 18 70 70 70 70 70 70 70 70 33 33 55 55 55 55 55 55 55 55 55 55 48 48 48 48 48 17 59 59 59 59 59 42 42 42 42 42 42 42 53 46 46 49 23 23 23 60 60 44 44 44 44 42 42 42 42 0 0

Output: No

Output: NO

Input:
1
10 5 10
0 0 0 1 1 1 1 1 5 5

Output: YES

Output: Yes

Input:
1
30 22 99
0 76 76 76 76 76 76 76 76 76 81 43 8 24 72 72 72 72 72 51 51 19 19 87 87 87 13 13 13 27

Output: YES

Output: Yes

Input:
1
100 4 31
0 22 22 22 22 22 22 22 22 22 22 22 15 15 26 26 28 28 17 17 17 17 17 17 17 17 17 17 17 24 11 11 11 11 11 11 11 11 11 11 11 11 11 11 1 1 11 11 27 27 10 10 10 10 10 10 10 31 31 31 9 9 9 9 9 19 18 18 18 10 10 10 10 10 10 10 10 10 10 21 21 21 21 21 21 21 7 7 9 9 23 23 4 4 4 9 9 9 9 9

Output: No

Output: NO

Input:
1
98 52 38
0 0 0 0 0 0 0 0 0 30 21 21 21 21 21 21 21 21 21 21 21 1 19 14 14 14 4 4 4 37 37 37 37 37 21 23 23 31 31 2 2 2 2 2 2 2 2 2 31 31 31 34 25 25 25 25 25 25 25 25 25 25 25 28 28 28 28 28 28 28 28 28 25 25 25 25 11 11 15 15 15 15 26 26 26 26 26 26 26 26 12 21 21 21 21 21 21 21

Output: No

Output: NO

Input:
1
96 96 79
0 0 0 0 0 0 0 0 0 59 59 59 59 59 36 36 36 36 36 36 36 36 36 36 36 77 77 6 52 52 52 52 54 54 54 54 54 54 54 54 66 66 66 65 65 65 2 2 2 2 56 56 56 56 7 7 7 7 14 14 14 14 14 14 14 14 14 14 14 12 12 12 12 12 12 10 23 16 16 16 40 40 40 40 40 40 40 30 30 30 30 30 30 30 30 7

Output: No

Output: NO

Input:
1
96 62 42
0 11 11 23 15 15 25 25 25 25 40 40 33 5 5 5 5 5 5 8 8 3 11 11 11 38 27 1 1 1 1 23 17 17 19 19 32 32 32 32 32 30 30 30 30 30 28 28 28 0 0 0 0 0 0 18 18 18 18 18 18 18 36 36 36 36 36 36 36 36 36 36 36 42 40 40 40 40 40 20 20 26 19 19 17 21 27 27 27 7 34 34 34 14 14 14

Output: No

Output: NO

Input:
1
99 41 65
0 18 28 48 6 54 38 2 4 45 23 1 19 17 32 22 3 5 2 54 18 55 38 47 54 11 59 16 65 24 8 32 4 55 59 21 60 39 61 24 44 24 62 56 48 61 58 25 14 48 34 63 57 2 38 43 53 21 39 33 47 56 2 58 44 10 49 40 41 52 54 64 58 52 51 7 25 58 19 19 12 62 29 47 45 56 48 17 24 24 17 19 63 13 60 20 47 24 53

Output: YES

Output: Yes

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

Output: YES

Output: Yes

Input:
1
93 66 47
0 8 6 24 1 19 18 44 26 30 5 19 14 6 36 6 14 13 11 0 45 40 8 17 6 34 29 45 19 39 33 10 23 42 0 5 22 31 23 46 40 17 41 39 41 45 12 25 44 6 29 46 19 15 24 40 41 36 0 9 40 17 45 41 35 25 9 4 30 32 34 25 16 18 44 28 8 10 12 20 37 11 45 46 29 27 15 40 7 35 35 23 1

Output: No

Output: NO

Input:
1
79 26 23
0 0 1 3 2 15 20 14 7 4 1 13 8 9 18 6 3 22 15 18 18 22 20 21 1 14 9 15 20 9 1 5 23 6 3 16 20 16 4 20 9 13 11 11 7 16 20 16 20 8 6 13 10 6 21 13 6 11 16 18 17 0 20 8 11 11 7 0 19 9 6 22 16 14 7 4 19 7 0

Output: No

Output: NO