There are two sisters Alice and Betty. You have $$$n$$$ candies. You want to distribute these $$$n$$$ candies between two sisters in such a way that:  Alice will get $$$a$$$ ($$$a > 0$$$) candies;  Betty will get $$$b$$$ ($$$b > 0$$$) candies;  each sister will get some integer number of candies;  Alice will get a greater amount of candies than Betty (i.e. $$$a > b$$$);  all the candies will be given to one of two sisters (i.e. $$$a+b=n$$$). Your task is to calculate the number of ways to distribute exactly $$$n$$$ candies between sisters in a way described above. Candies are indistinguishable.Formally, find the number of ways to represent $$$n$$$ as the sum of $$$n=a+b$$$, where $$$a$$$ and $$$b$$$ are positive integers and $$$a>b$$$.You have to answer $$$t$$$ independent test cases.

NoteFor the test case of the example, the $$$3$$$ possible ways to distribute candies are:  $$$a=6$$$, $$$b=1$$$;  $$$a=5$$$, $$$b=2$$$;  $$$a=4$$$, $$$b=3$$$.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of a test case contains one integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^9$$$) — the number of candies you have.

For each test case, print the answer — the number of ways to distribute exactly $$$n$$$ candies between two sisters in a way described in the problem statement. If there is no way to satisfy all the conditions, print $$$0$$$.

Input:
6
7
1
2
3
2000000000
763243547

Output:
3
0
0
1
999999999
381621773

Output:
3
0
0
1
999999999
381621773

Input:
10000
1999998163
1999998749
3608
1999995797
3253
1999998518
3146
938
1999996903
2957
966
1738464254
2474
2226
1999997073
1999995579
1168
91
1999998757
1999999297
3541
3769
70
3838
1045411991
1999996556
4163
1999999008
1999997424
1999997409
3413
2952
1999996689
1911
1999998790
1999997406
4161
1999998785
2273
1999998472
973
2749
1999996019
1999998967
1999999115
1999998605
3081
1633009152
1999997493
1999996534
1999997510
1999999805
1956085790
3818
1999997...

Output:
999999081
999999374
1803
999997898
1626
999999258
1572
468
999998451
1478
482
869232126
1236
1112
999998536
999997789
583
45
999999378
999999648
1770
1884
34
1918
522705995
999998277
2081
999999503
999998711
999998704
1706
1475
999998344
955
999999394
999998702
2080
999999392
1136
999999235
486
1374
999998009
999999483
999999557
999999302
1540
816504575
999998746
999998266
999998754
999999902
978042894
1908
999998701
999999380
999998341
1743
9999979...

Output:
999999081
999999374
1803
999997898
1626
999999258
1572
468
999998451
1478
482
869232126
1236
1112
999998536
999997789
583
45
999999378
999999648
1770
1884
34
1918
522705995
999998277
2081
999999503
999998711
999998704
1706
1475
999998344
955
999999394
999998702
2080
999999392
1136
999999235
486
1374
999998009
999999483
999999557
999999302
1540
816504575
999998746
999998266
999998754
999999902
978042894
1908
999998701
999999380
999998341
1743
999997960
953
999998982
936778166
301
999999608
879
261
999998090...

Input:
2
1
2

Output:
0
0

Output:
0
0

Input:
1
108139

Output: 54069

Input:
5
1
1
1
1
1

Output:
0
0
0
0
0

Output:
0
0
0
0
0

Input:
39
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

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

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

Input:
1
121112422

Output: 60556210

Input:
1
1411

Output: 705

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

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

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

Input:
39
7
1
2
3
2000000000
763243547
7
1
2
3
2000000000
763243547
7
1
2
3
2000000000
763243547
7
1
2
3
2000000000
763243547
7
1
2
3
2000000000
763243547
7
1
2
3
2000000000
763243547
7
1
2

Output:
3
0
0
1
999999999
381621773
3
0
0
1
999999999
381621773
3
0
0
1
999999999
381621773
3
0
0
1
999999999
381621773
3
0
0
1
999999999
381621773
3
0
0
1
999999999
381621773
3
0
0

Output:
3
0
0
1
999999999
381621773
3
0
0
1
999999999
381621773
3
0
0
1
999999999
381621773
3
0
0
1
999999999
381621773
3
0
0
1
999999999
381621773
3
0
0
1
999999999
381621773
3
0
0

Input:
39
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
32
34
35
36
37
35
39

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

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

Input:
98
710
896
635
909
528
799
184
970
731
285
481
62
829
815
204
927
48
958
858
549
722
900
290
96
414
323
488
140
494
286
783
551
896
580
724
766
841
914
200
170
384
664
14
203
582
203
678
502
677
318
189
144
97
330
169
20
492
233
198
876
697
624
877
514
828
41
575
959
499
786
621
878
547
409
194
59
657
893
230
559
170
238
752
854
385
365
415
505
584
434
135
136
610
525
945
889
941
579

Output:
354
447
317
454
263
399
91
484
365
142
240
30
414
407
101
463
23
478
428
274
360
449
144
47
206
161
243
69
246
142
391
275
447
289
361
382
420
456
99
84
191
331
6
101
290
101
338
250
338
158
94
71
48
164
84
9
245
116
98
437
348
311
438
256
413
20
287
479
249
392
310
438
273
204
96
29
328
446
114
279
84
118
375
426
192
182
207
252
291
216
67
67
304
262
472
444
470
289

Output:
354
447
317
454
263
399
91
484
365
142
240
30
414
407
101
463
23
478
428
274
360
449
144
47
206
161
243
69
246
142
391
275
447
289
361
382
420
456
99
84
191
331
6
101
290
101
338
250
338
158
94
71
48
164
84
9
245
116
98
437
348
311
438
256
413
20
287
479
249
392
310
438
273
204
96
29
328
446
114
279
84
118
375
426
192
182
207
252
291
216
67
67
304
262
472
444
470
289

Input:
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
102
1...

Output:
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50

Output:
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50

Input:
1411
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1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
2

Output:
1
1
2

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

Output:
0
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15

Output:
0
0
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15

Input:
1
54334

Output: 27166

Input:
1
54332

Output: 27165

Input:
1
54331

Output: 27165

Input:
1
54335

Output: 27167

Input:
1
54330

Output: 27164


There are $$$n$$$ cities in Berland and some pairs of them are connected by two-way roads. It is guaranteed that you can pass from any city to any other, moving along the roads. Cities are numerated from $$$1$$$ to $$$n$$$.Two fairs are currently taking place in Berland — they are held in two different cities $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le n$$$; $$$a \ne b$$$).Find the number of pairs of cities $$$x$$$ and $$$y$$$ ($$$x \ne a, x \ne b, y \ne a, y \ne b$$$) such that if you go from $$$x$$$ to $$$y$$$ you will have to go through both fairs (the order of visits doesn't matter). Formally, you need to find the number of pairs of cities $$$x,y$$$ such that any path from $$$x$$$ to $$$y$$$ goes through $$$a$$$ and $$$b$$$ (in any order).Print the required number of pairs. The order of two cities in a pair does not matter, that is, the pairs $$$(x,y)$$$ and $$$(y,x)$$$ must be taken into account only once.

The first line of the input contains an integer $$$t$$$ ($$$1 \le t \le 4\cdot10^4$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are specified. The first line of each test case contains four integers $$$n$$$, $$$m$$$, $$$a$$$ and $$$b$$$ ($$$4 \le n \le 2\cdot10^5$$$, $$$n - 1 \le m \le 5\cdot10^5$$$, $$$1 \le a,b \le n$$$, $$$a \ne b$$$) — numbers of cities and roads in Berland and numbers of two cities where fairs are held, respectively. The following $$$m$$$ lines contain descriptions of roads between cities. Each of road description contains a pair of integers $$$u_i, v_i$$$ ($$$1 \le u_i, v_i \le n$$$, $$$u_i \ne v_i$$$) — numbers of cities connected by the road. Each road is bi-directional and connects two different cities. It is guaranteed that from any city you can pass to any other by roads. There can be more than one road between a pair of cities. The sum of the values of $$$n$$$ for all sets of input data in the test does not exceed $$$2\cdot10^5$$$. The sum of the values of $$$m$$$ for all sets of input data in the test does not exceed $$$5\cdot10^5$$$.

Print $$$t$$$ integers — the answers to the given test cases in the order they are written in the input.

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

Output:
4
0
1

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

Output:
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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0
...

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

Output:
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
9
0
0
0
0
0
0
0
5
0
0
0
0
0
5
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
15
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
2
0
6
0
0
0
0
0
0
0
0
0
0
10
0
1
0
0
0
2
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
2
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
4
0
2
0
0
0
0
0
0
0
0
0
1
0
0
2
1
0
0
0
0
0
0
0
0
0
0
...

Input:
1
200000 199999 54282 134037
119784 126361
126361 160660
126361 84639
126361 152057
164562 99758
20799 126361
126361 160081
60757 68848
199620 126361
664 86874
126361 193759
35614 126361
129440 126361
664 34729
180592 664
664 18227
4096 181894
126361 74133
171178 126361
68478 664
184465 664
187328 99758
126361 8954
126361 187509
126361 160044
126361 39863
90586 126361
128921 126361
32337 126361
664 12118
195195 126361
22633 664
46408 126361
138563 126361
113266 126361
4...

Output: 0

Input:
1
200000 199999 79032 178241
140045 70147
106325 102259
61129 173318
81223 166944
180826 116147
176998 152003
15783 176436
159845 66168
12022 102259
75824 66192
164746 88891
87973 51530
15178 197909
150729 192771
47846 165885
137309 88648
64214 7607
163758 65909
101466 49181
44330 84717
83627 55120
198143 60906
169878 117926
48139 163758
144986 199280
181977 26415
139725 129554
37307 154896
59938 127996
171994 164142
124962 39745
13642 61473
198205 187854
106903 17721
64...

Output: 0

Input:
1
200000 199999 196325 90880
138313 82598
186959 153152
183244 49461
67888 174897
6828 76367
52460 11192
181959 164877
198743 159273
147008 50282
197665 91557
77481 53736
144326 152181
8247 38706
34973 144561
52312 163684
181637 184442
169080 183644
16600 88747
74536 67039
147762 88213
11248 168737
150343 68899
197595 192395
106734 87086
122052 113291
169481 95217
20315 34981
91760 132683
33208 43816
59975 172468
166426 12688
158484 77576
145798 21545
159033 130466
17610...

Output: 0

Input:
1
200000 199999 161778 74821
64162 103691
17726 163996
148712 55652
183931 180843
66633 160878
65110 151529
46772 95515
102093 107742
81446 163015
47865 178368
64746 175736
143550 110540
113714 78027
54518 3356
61298 51550
118017 20674
158329 76992
163724 53927
93477 61861
7739 87711
197907 7020
52667 50183
46969 133467
126720 198730
164224 89998
184290 108917
23834 147544
164248 10729
152741 136222
153528 160079
74167 100830
80259 21340
102029 18637
139795 141283
90886 ...

Output: 0

Input:
1
200000 199999 120567 130162
33597 139093
166530 9254
27160 87287
138830 64214
51845 146129
115732 127990
194518 42424
74618 169929
33118 74667
3102 23356
191614 53807
69111 167913
148629 89567
62133 98357
122141 20948
78458 129002
148318 166540
129129 16222
17771 101879
85326 120051
70740 16497
135644 94486
40677 13970
53683 30740
83861 66402
121277 109569
41687 124351
174042 59724
115253 74646
60046 198363
120144 186957
195385 35873
56384 19354
13115 199118
11995 9867...

Output: 0

Input:
1
200000 199999 197521 62559
178563 40385
132330 191726
196319 2239
14893 151507
59385 5744
172095 102553
162511 146402
188382 199312
71445 62592
21228 187202
138807 73138
82212 100731
33517 69654
127889 34828
155234 135769
110471 123793
36799 144502
93945 178366
87844 66891
22215 76836
88220 91280
12734 12554
68988 134312
33721 45832
191041 118321
49426 147051
197682 16997
28883 171815
46858 64211
29232 138769
154381 174251
130145 72357
114040 10698
168764 1023
56796 18...

Output: 68

Input:
1
200000 199999 29800 178857
59714 154917
162773 60066
35104 151474
62803 65252
114627 195229
150949 119973
64364 192245
143298 115636
96855 68062
170992 130646
66695 54885
11837 19175
177987 192091
127100 141921
191096 142711
188878 71466
79688 172547
63014 115051
178567 90498
185768 137084
51036 179417
172469 144541
67562 925
82218 132007
154808 193709
19936 71317
124345 80235
85112 114964
88175 109117
123599 105084
110709 194843
87958 78255
145729 91811
145478 128471
...

Output: 0

Input:
1
200000 199999 175907 142631
116242 168819
168878 162483
129231 5047
16784 134862
14013 195156
116851 120886
122653 136171
198273 95238
105938 190240
88255 53609
24789 25873
155450 74281
47485 140411
193367 133135
180998 178151
63039 153502
3873 27086
72482 34662
132924 98580
20171 26838
4263 171173
124207 69297
171951 7234
131489 62359
106137 3368
79294 40441
189488 44241
22459 130149
48892 93591
110795 9264
29695 195041
43350 3125
172021 68577
47828 181889
198201 9570...

Output: 0

Input:
1
200000 199999 140661 152824
172879 127415
95385 163285
74512 55342
66202 176548
14334 98513
120610 147192
198246 2802
83596 51830
179363 4020
46614 97015
182400 53866
74227 176490
12561 85733
99256 2139
25961 65397
131189 31645
158827 125725
74910 67900
97351 150838
150541 38105
129435 93903
130220 11658
74171 1486
82914 42000
88430 83014
127244 118379
95478 40591
60473 62567
38422 128299
99111 170021
47549 104990
99729 162178
47648 129039
95408 123483
118963 57681
19...

Output: 0

Input:
1
200000 199999 116853 29695
23216 20785
138631 454
2486 99687
63697 34483
150587 21410
33530 193794
161575 92058
44053 65600
91110 89159
24801 128067
33521 93302
102194 112702
17615 89091
12557 180298
6958 117559
139254 174815
27546 50972
142240 105029
29430 9079
85859 122409
94675 158736
165261 170448
144452 42858
42141 193853
71287 91446
91271 156969
23992 139364
79931 85931
49766 102146
153911 105545
139220 91564
73776 143401
61397 185675
78399 135253
44942 198856
1...

Output: 156

Input:
1
200000 199999 91387 4818
146524 58349
88804 47203
66291 90885
39832 33464
18352 2202
152352 19736
112747 185189
198078 53731
47493 69860
21586 108084
15734 109247
113017 74344
187520 99054
169379 119285
30168 129943
89008 16388
111228 199428
66269 177064
49290 22984
144425 157929
146452 196623
129004 83079
140322 154654
41539 5508
136412 18154
76144 10910
32337 50167
112216 79960
166161 94916
130319 159656
131860 164557
193842 78671
35761 175466
167927 125253
5636 4065...

Output: 8444939322

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

Output: 0

Input:
1
100 99 37 93
26 49
26 70
67 26
26 99
30 26
26 42
26 92
2 26
22 26
26 25
57 26
44 26
5 8
26 61
81 26
26 80
50 26
26 46
26 45
26 83
5 29
53 26
14 26
26 11
36 26
26 64
26 55
93 26
33 26
74 26
26 32
5 26
82 26
37 26
5 4
3 26
26 35
26 51
59 26
5 41
26 21
26 43
15 26
26 9
39 26
100 26
26 72
26 24
26 96
26 52
87 26
26 12
26 73
54 26
79 5
5 16
66 26
26 38
78 26
26 7
26 91
26 69
26 90
26 71
13 26
26 86
26 20
47 26
63 26
85 26
26 6
75 26
26 ...

Output: 0

Input:
1
100 99 60 75
84 91
14 41
57 38
14 85
14 88
64 4
14 91
17 78
52 76
28 76
14 55
24 97
42 96
69 76
14 95
50 15
35 15
1 91
62 76
14 87
13 14
91 59
90 21
86 89
14 86
42 39
14 60
80 95
74 42
8 86
7 86
78 14
23 42
33 42
42 20
14 25
15 14
42 56
19 42
15 46
100 14
79 91
43 65
55 36
71 14
15 72
14 3
29 72
58 14
76 48
51 14
97 49
37 14
44 76
14 18
68 76
14 64
15 97
15 34
9 72
57 14
76 40
26 14
83 91
42 77
42 14
15 75
55 10
76 45
27 57
94 42
70...

Output: 0

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

Output: 49

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

Output: 285

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

Output: 2162

Input:
2000
71 93 68 22
17 54
61 6
27 40
36 46
6 39
50 8
71 13
66 51
55 38
62 60
14 67
19 51
69 45
14 29
14 16
29 56
63 34
50 47
69 22
63 40
66 47
43 59
8 21
57 59
13 39
3 27
50 43
25 7
71 12
46 5
46 67
55 71
10 65
41 29
33 40
69 13
1 25
5 6
4 54
34 39
60 37
43 1
33 53
1 32
44 4
34 36
68 24
16 11
51 61
43 28
28 14
27 13
48 3
15 42
18 1
14 6
31 19
53 39
15 36
30 53
39 49
69 20
67 44
52 65
13 35
48 70
22 71
8 65
9 39
43 59
23 47
43 23
14 33
...

Output:
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5
0
0
0
0
0
0
0
0
0
18
0
18
0
0
0
0
0
0
0
0
66
0
12
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
8
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
390
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

Input:
2000
55 70 49 29
20 45
5 13
24 12
43 17
4 52
25 22
21 42
2 36
2 34
17 3
40 8
3 50
23 14
22 44
17 54
31 17
6 44
8 17
53 12
1 13
2 10
53 46
27 17
21 22
48 28
15 17
1 4
26 20
27 44
25 2
40 4
31 33
18 8
25 47
29 24
16 24
17 26
43 22
23 31
17 16
12 1
38 24
43 35
31 12
6 19
33 8
20 3
32 7
45 12
45 54
12 4
7 9
33 32
32 18
52 37
9 24
12 48
43 42
30 19
11 40
25 41
43 12
49 33
46 24
45 4
55 49
51 48
13 31
39 41
20 50
65 68 41 39
32 65
56 50
1...

Output:
0
0
0
0
0
0
0
20
12
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
20
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
18
0
0
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
80
0
0
3
0
0
0
0
0
0
0
0
15
0
0
0
0
0
0
0
0
0
36
0
0
0
0
24
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
2
0
0
0
5
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
8
0
0
0
6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

Input:
2000
80 81 53 19
27 65
50 41
45 9
35 40
26 38
28 37
37 18
66 60
47 50
18 49
75 5
25 12
20 66
74 6
18 23
26 6
79 54
26 3
9 6
70 69
22 44
52 28
4 37
26 48
27 35
5 18
37 66
73 26
47 37
40 4
37 58
22 61
32 60
31 56
53 11
79 47
75 35
56 14
39 68
7 24
37 71
51 11
22 10
62 42
68 78
18 30
37 7
64 55
37 21
70 42
37 8
47 57
35 34
55 67
63 68
37 68
37 33
43 51
51 66
35 42
66 55
56 37
35 37
1 32
35 22
25 29
18 80
60 15
21 2
37 72
16 21
17 21
47 ...

Output:
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
27
0
0
0
0
0
0
0
0
0
0
0
7
0
0
0
0
0
0
0
0
0
0
0
0
0
0
36
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
54
0
0
0
0
0
23
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

Input:
1
200000 500000 175592 62486
64883 186283
117004 79772
188970 167992
35399 121353
84700 188170
75862 61279
52272 80109
117580 68800
137856 105749
149528 85691
165566 84710
136045 3254
73749 163902
127359 24483
105090 178292
168649 152098
39819 107175
94484 190154
198847 19690
14904 170083
86863 60474
125450 25875
97895 40480
129098 41077
26364 96659
166459 158894
168269 73522
65002 2064
128092 48040
80132 178125
84438 85367
197437 102905
157124 33892
5931 63017
120728 36...

Output: 0

Input:
1
200000 199999 126628 126178
19932 14567
19932 132168
157648 19932
93813 19932
145616 19932
51234 19932
97489 19932
138149 19932
16979 19932
164730 19932
19932 71783
19932 160137
55479 19932
101622 19932
19932 120349
19932 188157
19932 105781
23703 19932
114278 19932
185412 19932
29078 19932
113740 19932
18967 19932
74407 19932
162971 19932
41467 19932
141025 19932
19932 179325
182548 19932
19932 131210
9172 19932
19932 61762
19932 21221
19932 180599
19932 55505
183486...

Output: 0

Input:
1
200000 199999 39988 100621
10330 42967
54087 71723
71723 68827
71723 161147
71723 31341
42967 1307
181942 42967
19859 71723
71723 24540
71723 130377
123803 71723
80201 132704
151005 71723
177672 103116
71723 52956
158220 71723
114112 71723
158031 71723
141771 42967
69170 161876
71723 41386
68056 71723
71723 17138
77579 71723
163093 71723
103116 113623
19336 71723
71723 184314
17696 42967
56640 103116
182536 71723
69170 103200
125505 71723
133085 71723
71723 61544
9192...

Output: 0

Input:
1
200000 199999 19095 13981
32635 74521
105287 151336
172824 15869
129521 154592
24448 29357
36529 197987
39206 183392
154592 25041
58892 154592
43130 14317
109146 39206
167306 36529
70013 151336
84665 15869
111103 151336
15316 43705
116524 36529
168518 154592
128109 86932
74521 5399
154592 17399
54023 65852
102356 65852
2612 15869
112225 154592
60238 151336
74819 65852
130 154592
39206 95749
15869 128033
36529 98066
43705 199963
185325 16856
151336 111107
36529 36517
1...

Output: 0

Input:
1
200000 199999 53484 51260
172318 57540
2720 85542
70942 154124
31890 80708
85017 84272
161976 194491
120978 48631
141810 167472
99620 57490
121344 22377
104076 107187
164765 10820
184650 137923
102824 187609
155386 184258
28233 66996
61533 65546
103658 172909
124467 175090
181737 169236
36726 144539
46478 61365
147715 78467
66250 56615
142595 155854
193985 117339
189563 45950
160496 169518
161725 36636
64864 96882
86230 63446
51521 114460
190922 96588
70562 182502
7125...

Output: 0

Input:
1
200000 199999 37258 187130
195091 124073
156387 152511
165752 40829
152492 9349
168263 51344
131092 123073
29349 187238
143185 174883
183945 138294
196716 46725
133573 177730
138361 50711
62503 37868
73601 193450
62661 24664
133133 9786
148615 70031
142648 33142
106065 100798
163986 131588
113130 164556
92581 155818
150322 111620
173960 77531
35213 45598
198146 157810
14417 44837
185849 132460
127780 169931
167898 41962
177761 74435
11241 138219
120893 139650
33644 8249...

Output: 0

Input:
1
200000 199999 47871 78464
121170 186051
90000 73061
20349 146639
125226 18191
5364 102358
104130 87649
160925 67219
93279 53274
162996 25881
59018 145720
30272 114408
150422 100475
41050 175037
150692 185038
91631 21495
195331 159114
23573 191468
171887 195724
184882 107792
164130 57690
188302 27144
194162 77656
180706 63625
78910 58023
20328 52172
53847 73359
170080 51553
165061 145038
147220 38484
175498 158045
102159 75366
178980 190563
65261 170643
183046 172966
12...

Output: 4

Input:
1
200000 199999 165833 143483
125299 910
63370 166375
194538 123220
138442 26621
121114 5440
1515 193613
85317 80081
12234 158781
178214 54886
88075 88255
149009 128377
102428 93606
190637 180444
81609 159447
2309 60506
21500 174550
19528 10338
181335 163104
176190 183388
36802 110823
138098 121903
140123 128628
45255 64404
30694 194695
87076 168545
64172 170484
175664 148460
184912 77372
76882 166386
166279 166485
69381 87358
157808 42231
35725 38734
76838 120330
48241 ...

Output: 0

Input:
1
200000 199999 43641 29327
167924 174571
52960 28490
135235 105741
27215 72006
47702 8561
79989 85800
159340 161784
132078 117772
110607 194697
111022 25471
10887 38978
104515 178609
27092 155812
135524 15709
88048 106567
139974 14811
3885 59572
110621 17042
175213 187768
41634 146088
184998 151558
7156 159093
82505 29109
185992 100879
137379 117269
77891 4372
6890 70061
193533 147510
36392 79032
125023 137095
46459 75808
152364 180003
25382 91320
68072 64985
115262 101...

Output: 0

Input:
1
200000 199999 145480 116998
176251 153006
45823 111910
185780 189730
131445 196668
10973 21132
150581 143739
5522 120523
153001 179741
127956 82796
140352 198312
67156 146880
113799 36821
168701 15121
174714 96882
116035 128674
109501 90032
12799 65837
104820 52025
79289 52621
37177 112125
85776 120259
9606 119845
17675 179925
154032 53240
12062 167958
91532 53299
28926 128792
87877 106067
77410 12580
62441 4563
74628 105953
184782 1688
2323 48245
174678 121302
73054 1...

Output: 391

Input:
1
200000 199999 184016 37182
169721 126688
131271 181027
56044 130247
196996 158400
14286 54999
39920 83398
22687 111205
33526 170674
175101 85319
75233 33251
176269 132181
151831 46814
174584 77666
78884 111739
94563 28297
87940 106481
6769 160638
41496 10916
29081 96985
74090 43856
58486 177937
193705 165985
58021 16965
50238 177228
34706 163092
112762 34648
127588 15594
93019 23250
161021 165112
103628 36921
154828 59599
63873 171850
129449 70936
98350 174354
174818 6...

Output: 4950

Input:
1
200000 199999 6566 131687
176856 42788
162879 36559
42254 27625
1399 88102
174741 72724
66116 142871
172245 67304
140145 37889
102903 117602
65005 39300
53951 19621
71400 80966
147941 49897
53918 152502
107212 52590
189459 19543
145400 95337
66023 86768
120366 35716
198933 66119
25490 147871
100031 183393
186655 151139
39538 186660
61865 63246
174399 29975
196541 193411
159669 4292
140762 67686
78088 6639
189962 173805
139263 45918
1887 121902
187953 197501
13140 16787...

Output: 435

Input:
1
200000 199999 184640 178521
196133 45196
175078 17579
162741 7138
150824 133284
155790 98678
21913 169815
52084 127314
51971 181084
185738 68389
43663 129191
151753 165463
140863 10021
197548 157413
143432 94544
153350 31955
119711 193704
173258 97022
20956 108775
11014 183307
90094 72135
177121 112621
196005 148574
122116 196155
17781 130472
108130 192725
194265 112048
95985 64678
120452 189048
123730 23327
136526 98905
98402 37579
183968 82827
117784 149626
166955 686...

Output: 0

Input:
1
200000 199999 76796 41265
87901 48553
45920 68356
33185 34325
129866 97759
32556 163860
183925 38781
174641 167073
85282 11039
127169 8512
130272 152125
166124 35056
116866 149235
166713 122577
94788 86484
194484 107825
163348 104110
30392 114604
23993 137936
175473 184422
99956 171561
16064 79140
97773 8180
138800 88253
196816 34399
128328 170251
87018 46947
81377 185151
193214 154406
199159 58128
21544 115367
73773 181859
43918 113642
2066 24812
130139 102802
42440 6...

Output: 485776

Input:
1
200000 199999 124343 37500
36610 136386
73978 186292
96192 97195
33974 75745
170364 184195
22132 114435
177644 42317
46183 46634
34598 166736
175999 26874
51160 157422
177204 58877
160622 99499
62105 147231
115690 40367
149154 125533
90131 53792
193877 24553
197920 189732
97422 68342
99168 5182
15803 135091
176777 122222
51716 60921
144953 156231
67315 55702
138123 76852
165085 36039
149355 102740
156987 147015
111277 47017
123572 7101
76174 125563
55436 111051
116371 ...

Output: 4990652758

Input:
40000
40002 380001 1 2
1 3
1 5
1 7
1 9
1 11
1 13
1 15
1 17
1 19
1 21
1 23
1 25
1 27
1 29
1 31
1 33
1 35
1 37
1 39
1 41
1 43
1 45
1 47
1 49
1 51
1 53
1 55
1 57
1 59
1 61
1 63
1 65
1 67
1 69
1 71
1 73
1 75
1 77
1 79
1 81
1 83
1 85
1 87
1 89
1 91
1 93
1 95
1 97
1 99
1 101
1 103
1 105
1 107
1 109
1 111
1 113
1 115
1 117
1 119
1 121
1 123
1 125
1 127
1 129
1 131
1 133
1 135
1 137
1 139
1 141
1 143
1 145
1 147
1 149
1 151
1 153
1 155
...

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


Consider the following experiment. You have a deck of $$$m$$$ cards, and exactly one card is a joker. $$$n$$$ times, you do the following: shuffle the deck, take the top card of the deck, look at it and return it into the deck.Let $$$x$$$ be the number of times you have taken the joker out of the deck during this experiment. Assuming that every time you shuffle the deck, all $$$m!$$$ possible permutations of cards are equiprobable, what is the expected value of $$$x^k$$$? Print the answer modulo $$$998244353$$$.

Print one integer — the expected value of $$$x^k$$$, taken modulo $$$998244353$$$ (the answer can always be represented as an irreducible fraction $$$\frac{a}{b}$$$, where $$$b \mod 998244353 \ne 0$$$; you have to print $$$a \cdot b^{-1} \mod 998244353$$$).

Input: 1 1 1

Output: 1

Input: 1 1 5000

Output: 1

Input: 2 2 2

Output: 499122178

Input: 998244352 1337 5000

Output: 326459680

Input: 569716410 849619604 1232

Output: 551386348

Input: 569716410 849619604 5000

Output: 122094144

Input: 588636954 730833344 4490

Output: 389991357

Input: 588636954 730833344 5000

Output: 216118622

Input: 213292922 8067309 44

Output: 332601538

Input: 213292922 8067309 5000

Output: 529462868

Input: 232213466 585535513 4789

Output: 454306758

Input: 232213466 585535513 5000

Output: 350297073

Input: 251134010 189925189 3047

Output: 120053431

Input: 251134010 189925189 5000

Output: 103457138


The Oak has $$$n$$$ nesting places, numbered with integers from $$$1$$$ to $$$n$$$. Nesting place $$$i$$$ is home to $$$b_i$$$ bees and $$$w_i$$$ wasps.Some nesting places are connected by branches. We call two nesting places adjacent if there exists a branch between them. A simple path from nesting place $$$x$$$ to $$$y$$$ is given by a sequence $$$s_0, \ldots, s_p$$$ of distinct nesting places, where $$$p$$$ is a non-negative integer, $$$s_0 = x$$$, $$$s_p = y$$$, and $$$s_{i-1}$$$ and $$$s_{i}$$$ are adjacent for each $$$i = 1, \ldots, p$$$. The branches of The Oak are set up in such a way that for any two pairs of nesting places $$$x$$$ and $$$y$$$, there exists a unique simple path from $$$x$$$ to $$$y$$$. Because of this, biologists and computer scientists agree that The Oak is in fact, a tree.A village is a nonempty set $$$V$$$ of nesting places such that for any two $$$x$$$ and $$$y$$$ in $$$V$$$, there exists a simple path from $$$x$$$ to $$$y$$$ whose intermediate nesting places all lie in $$$V$$$. A set of villages $$$\cal P$$$ is called a partition if each of the $$$n$$$ nesting places is contained in exactly one of the villages in $$$\cal P$$$. In other words, no two villages in $$$\cal P$$$ share any common nesting place, and altogether, they contain all $$$n$$$ nesting places.The Oak holds its annual Miss Punyverse beauty pageant. The two contestants this year are Ugly Wasp and Pretty Bee. The winner of the beauty pageant is determined by voting, which we will now explain. Suppose $$$\mathcal{P}$$$ is a partition of the nesting places into $$$m$$$ villages $$$V_1, \ldots, V_m$$$. There is a local election in each village. Each of the insects in this village vote for their favorite contestant. If there are strictly more votes for Ugly Wasp than Pretty Bee, then Ugly Wasp is said to win in that village. Otherwise, Pretty Bee wins. Whoever wins in the most number of villages wins.As it always goes with these pageants, bees always vote for the bee (which is Pretty Bee this year) and wasps always vote for the wasp (which is Ugly Wasp this year). Unlike their general elections, no one abstains from voting for Miss Punyverse as everyone takes it very seriously.Mayor Waspacito, and his assistant Alexwasp, wants Ugly Wasp to win. He has the power to choose how to partition The Oak into exactly $$$m$$$ villages. If he chooses the partition optimally, determine the maximum number of villages in which Ugly Wasp wins.

NoteIn the first test case, we need to partition the $$$n = 4$$$ nesting places into $$$m = 3$$$ villages. We can make Ugly Wasp win in $$$2$$$ villages via the following partition: $$$\{\{1, 2\}, \{3\}, \{4\}\}$$$. In this partition,  Ugly Wasp wins in village $$$\{1, 2\}$$$, garnering $$$181$$$ votes as opposed to Pretty Bee's $$$170$$$;  Ugly Wasp also wins in village $$$\{3\}$$$, garnering $$$111$$$ votes as opposed to Pretty Bee's $$$70$$$;  Ugly Wasp loses in the village $$$\{4\}$$$, garnering $$$0$$$ votes as opposed to Pretty Bee's $$$50$$$. Thus, Ugly Wasp wins in $$$2$$$ villages, and it can be shown that this is the maximum possible number.In the second test case, we need to partition the $$$n = 2$$$ nesting places into $$$m = 1$$$ village. There is only one way to do this: $$$\{\{1, 2\}\}$$$. In this partition's sole village, Ugly Wasp gets $$$563$$$ votes, and Pretty Bee also gets $$$563$$$ votes. Ugly Wasp needs strictly more votes in order to win. Therefore, Ugly Wasp doesn't win in any village.

The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) denoting the number of test cases. The next lines contain descriptions of the test cases.  The first line of each test case contains two space-separated integers $$$n$$$ and $$$m$$$ ($$$1 \le m \le n \le 3000$$$). The second line contains $$$n$$$ space-separated integers $$$b_1, b_2, \ldots, b_n$$$ ($$$0 \le b_i \le 10^9$$$). The third line contains $$$n$$$ space-separated integers $$$w_1, w_2, \ldots, w_n$$$ ($$$0 \le w_i \le 10^9$$$). The next $$$n - 1$$$ lines describe the pairs of adjacent nesting places. In particular, the $$$i$$$-th of them contains two space-separated integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le n$$$, $$$x_i \neq y_i$$$) denoting the numbers of two adjacent nesting places. It is guaranteed that these pairs form a tree. It is guaranteed that the sum of $$$n$$$ in a single file is at most $$$10^5$$$.

For each test case, output a single line containing a single integer denoting the maximum number of villages in which Ugly Wasp wins, among all partitions of The Oak into $$$m$$$ villages.

Input:
2
4 3
10 160 70 50
70 111 111 0
1 2
2 3
3 4
2 1
143 420
214 349
2 1

Output:
2
0

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

Output:
0
0
0
2
0
1
1
2
2

Input:
100
20 14
933619649 965172850 363466665 814833206 88289068 274646294 154573138 7461079 412781057 845293813 699420953 473004395 560568579 742395990 904244553 965996519 119779612 17236024 437897634 922556285
930891247 963057590 363656911 812597797 86199946 271971152 151350293 5247153 410707700 843705401 697478275 470359066 558363016 742016118 903411302 963747862 117870771 14385133 435878713 919962632
16 14
3 15
1 5
16 4
11 6
18 8
14 9
10 7
1 7
20 16
13 19
11 16
8 2
16 12
1 17
6 13
6 15
8...

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

Input:
100
20 19
819675635 292916699 889039182 541427561 604866919 892935871 631733137 387967937 96515010 597899924 330079083 631876682 43345022 274877041 108478694 195631693 392882388 464322117 147249248 250894602
894082678 301242353 873741752 700389878 694133359 890616712 558848721 350835259 78177892 741058278 215366995 685831927 147128155 222945079 243983325 181582599 366660711 626487090 273288467 307561298
1 15
19 18
10 4
19 10
8 6
6 10
19 14
19 1
12 7
8 17
4 11
10 3
2 6
1 13
16 6
2 20
9 1...

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

Input:
100
8 3
63544672 523108582 476614493 345113413 639640383 210237171 303030936 252779340
65478289 525346958 477256561 347479329 640885169 211067107 304855885 253624059
1 5
6 5
1 4
8 5
7 2
7 1
6 3
7 7
653838847 826105114 729914571 234372550 294874394 153297501 158261406
654754522 826794241 732100996 233974601 295843745 154461183 160385832
2 1
5 2
4 2
2 6
7 6
6 3
4 1
856327849 634582180 828236582 96020145
856674648 634165587 827948597 95705513
4 1
1 3
1 2
11 3
298366596 206976616 114...

Output:
3
6
0
0
1
0
0
0
0
0
0
0
0
2
0
0
0
0
2
1
0
3
0
0
0
1
0
0
2
2
0
0
1
0
0
0
0
0
0
0
0
0
0
4
2
0
0
0
0
0
0
0
2
5
0
0
6
3
0
0
0
0
5
2
0
2
0
2
2
0
0
0
0
0
0
0
4
0
0
2
0
2
0
0
1
0
5
0
0
1
0
4
0
0
0
0
5
7
0
0

Input:
100
10 2
688962708 359928517 580757924 667292133 630695474 865929563 754873715 856395634 756815118 825545160
432864142 111271545 263156443 382058086 410340348 520497223 447245065 667322739 368592349 521153710
6 2
3 9
4 3
5 9
1 9
8 3
2 3
10 5
5 7
62 44
418614474 826668067 267201545 660274722 836248757 751736627 350473379 414643790 955904225 618445773 172397492 615634146 168423366 451077417 262069859 686412287 644706373 614379853 409430227 258148533 920404396 262337946 146266127 321083663 78705...

Output:
0
2
13
0
18
4
10
48
0
0
2
2
2
12
21
6
0
31
0
0
0
20
0
28
0
0
2
19
19
4
50
18
0
18
0
26
1
9
0
0
22
12
26
0
0
9
20
0
11
0
23
25
84
5
31
0
0
44
19
0
0
3
0
0
24
0
0
11
0
26
0
1
0
0
0
0
5
0
16
0
0
0
28
0
0
39
35
0
4
1
0
2
36
1
11
41
52
110
0
1

Input:
100
49 11
372849412 829108290 71969133 576667576 822545756 927366687 570856629 722173139 529275978 774464674 325359992 792763587 227340453 887447956 630867013 819951354 912532354 420719157 799795200 413771279 968743458 499166228 372076038 150945159 687235124 667906286 213620475 317853265 157317829 518777452 392617180 578434791 936702456 691831398 833283212 609298921 438048938 284501314 292313574 879542806 785951168 147487415 444760286 183115246 774670180 910505285 272990469 317262527 800647010
388224507...

Output:
10
0
0
16
17
1
2
0
0
0
0
42
0
0
0
1
0
18
0
1
17
10
1
16
7
0
64
8
7
0
62
9
0
0
0
1
0
0
0
14
3
0
0
0
0
2
0
6
0
0
0
6
0
0
0
1
0
0
0
0
0
0
0
5
6
0
0
0
0
0
0
0
1
0
3
0
17
0
0
5
21
0
2
27
0
49
0
22
3
0
0
0
0
0
0
0
0
2
0
1

Input:
100
268 183
570488812 886438114 185187188 898649957 751311838 307849273 800398820 778318722 632008055 760363659 651904064 285498497 691657755 701742528 807367216 143301152 361753986 141423513 416233203 740088955 250554145 433605119 422387157 598182310 728741561 143415346 380605572 526937052 454907094 330853540 358356836 310256062 686925324 739742614 566192036 200184078 444954058 826428297 276258468 90093360 207321911 320524822 776835786 203653628 584253300 341142250 19901632 659162506 137986399 4383683 3...

Output:
182
0
0
0
80
15
0
0
0
49
6
0
1
0
0
0
62
2
116
63
82
20
2
1
88
1
9
0
0
11
23
0
0
0
0
0
0
48
0
0
4
4
4
34
111
0
66
100
9
0
16
0
145
0
0
1
5
3
2
42
0
0
0
0
32
11
0
35
0
0
5
0
0
5
6
0
15
1
0
10
0
0
1
0
20
0
1
16
11
0
12
0
11
76
0
0
0
16
2
6

Input:
65
1266 1261
732331196 739685129 870200853 433084899 378575698 833908125 347601869 279781369 951921289 995598317 241559385 829677172 454647811 113203652 857619309 465588074 224688691 788155764 350791534 838600038 480240351 568676325 321674414 280623635 998981116 909210785 112988628 188864016 887062635 525407501 639264209 286626159 866814442 523818303 686993087 374131266 481114212 713669130 608756358 861340354 674759489 6629871 803281252 48131469 524243753 856642197 68185176 846869368 56018507 373429906 5...

Output:
494
44
713
193
335
386
38
1108
328
896
1131
300
77
207
80
474
280
812
1740
72
247
13
7
333
280
95
65
5
1755
175
563
223
278
272
13
22
453
109
504
18
3
117
39
43
113
395
987
250
1287
484
1344
689
111
628
455
52
68
35
971
776
20
87
370
303
193

Input:
37
2915 1648
440876858 283721805 515014337 372953426 999514870 124214171 714415430 346707777 266949894 563351954 161846292 89229389 954287060 895226142 907730859 131349799 387092064 688946628 220369752 979879437 354691378 685801668 739801035 442494732 775995822 949904155 759156010 902142630 577127588 596397115 506706661 203004540 919621473 931410391 430430549 653516453 910799108 506381335 948670701 965836049 650384329 328742591 804791409 397727770 398184516 971326045 581571948 402108126 238153785 2884078...

Output:
412
406
741
91
132
1160
668
453
876
1507
343
1599
775
233
54
1235
1300
1329
1078
964
1342
381
1099
1146
529
1473
72
1363
80
483
216
170
875
125
1142
151
921

Input:
37
2583 1540
286315978 529533692 677117374 569157526 470963030 965074620 269334763 384219144 924877508 919303587 208210600 771889418 284813169 190267138 763931150 515655402 478267574 453774803 333844526 284339218 694597621 538167110 287761724 683763521 689588530 622429707 899368568 240955630 321098331 613000021 281179526 969500005 796700647 160169782 170341679 253238612 390138996 379902221 367745105 420964332 206227397 465283114 899338697 489605175 425115639 442532040 722972781 814835236 224103176 560234...

Output:
0
7
2
994
1155
0
1588
965
3
0
1282
0
2
1328
187
202
212
102
1167
1355
129
1443
883
5
45
5
0
0
5
12
17
4
1285
1513
214
1649
1094

Input:
74
2 2
683339779 29844151
683339779 29844151
1 2
2 1
6 5
0 7
1 2
2 1
0 665323849
1000000000 665323849
2 1
2 1
78790407 1000000000
78790407 0
1 2
2 1
0 1000000000
1000000000 0
2 1
2 2
7 1
2 4
1 2
1 1
1000000000
1000000000
2 1
1000000000 0
0 1000000000
1 2
2 1
35 60
14 32
1 2
1 1
0
0
2 1
888184311 0
888184311 1000000000
2 1
1 1
1
1
2 2
55 53
73 7
2 1
2 2
30 33
31 90
1 2
2 1
1000000000 842546765
0 842546765
2 1
1 1
81
52
2 1
1000000000 1000000000
...

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

Input:
100
3 2
5 2 9
1 6 7
3 2
3 1
2 2
1 1
0 0
1 2
3 1
2 36 92
70 82 77
3 1
2 1
3 2
8 3 6
8 0 1
1 3
3 2
3 2
10 3 6
5 8 3
1 3
2 1
3 2
9 9 28
25 4 34
1 2
2 3
3 3
294702982 688718281 682841704
966858413 277643382 551048817
1 3
2 1
2 1
0 0
1 1
1 2
3 2
32 29 93
91 2 7
3 1
2 1
3 3
347821062 536259173 581885225
551239541 530183487 439135620
2 1
1 3
3 3
4 10 2
6 4 8
2 3
3 1
3 2
316630611 987582460 634011699
540106890 802478632 227160542
2 3
1 3
3 2
10 9 4
8 2 7...

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

Input:
100
4 3
243718501 558085689 418364345 790072060
341787082 707804642 275598117 268481651
4 2
3 4
1 3
3 2
1 10 8
7 8 3
2 1
3 1
3 2
1 0 0
0 1 1
3 1
1 2
3 2
1 0 0
0 1 1
1 2
3 1
3 1
4 6 8
3 0 9
2 3
1 2
4 4
943622853 231079370 761200925 813630789
356275561 449032947 724369349 265479296
1 4
2 3
3 4
4 2
398056793 382105525 615874993 352747938
262568206 100249358 748663437 969133163
2 1
2 4
2 3
4 3
47 83 88 55
23 45 65 62
4 1
4 2
1 3
4 3
61 25 37 55
60 86 33 76
2 1
2...

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

Input:
100
4 3
0 2 2 2
1 0 0 0
1 4
1 3
1 2
5 4
793368424 867293323 417924725 312884556 437574394
788181712 275252988 682575054 388714893 432665693
5 1
3 5
3 2
4 3
4 3
3 3 0 4
2 5 1 8
2 4
2 3
2 1
4 3
1 87 9 19
50 6 80 39
3 4
2 3
1 3
4 3
9 3 9 4
7 7 7 10
4 3
1 3
2 3
4 1
13 97 11 90
1 57 46 74
2 3
2 4
3 1
4 3
6 2 56 101
3471 80 2402 85
4 1
4 3
2 4
4 4
10 2 10 3
0 5 0 5
2 4
1 4
2 3
4 3
1 9 0 3
8 3 10 3
4 1
3 4
2 3
4 3
3471 80 2402 85
6 2 56 101
2 4
4 3
4 1
...

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

Input:
100
5 3
70469860 532849215 934482712 440581893 184876080
323838056 738558519 726713355 817923040 812811838
3 5
2 5
2 4
1 5
5 3
410292361 907512550 811210298 875554900 54147796
131310130 897426187 642756626 435067191 699151404
3 4
5 1
3 2
2 5
5 2
775683511 595647820 217435226 630721771 830555828
559674230 722951467 755963861 436657999 66781142
3 2
5 4
2 4
4 1
5 4
318486392 811277447 282929369 195744960 330919981
668541345 425861854 230057146 862305218 600884528
3 2
5 3
2 1
3 4
5...

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

Input:
100
5 4
3 10 7 2 3
1 5 4 9 5
5 1
4 1
3 1
1 2
5 2
6 27 83 21 17
71 20 75 41 39
2 3
1 2
2 4
5 1
5 2
7 4 5 5 3
2 10 9 8 6
1 5
2 4
4 1
3 2
5 2
70 29 9 85 13
22 7 77 77 50
1 2
5 1
4 1
3 1
5 2
30 17 97 43 93
84 14 61 89 21
1 3
5 2
1 5
1 4
5 3
33 62 82 66 44
65 9 53 88 30
4 2
5 2
2 3
1 3
5 3
5 3 0 10 8
7 1 5 7 2
5 3
2 4
1 5
3 4
5 3
4 10 0 8 4
2 10 3 9 3
5 2
3 4
4 5
4 1
5 3
3 8 2 0 5
0 9 5 6 2
1 3
5 4
5 2
1 5
5 3
61 90 75 23 2
64 36 61 20 99
2 3
5...

Output:
2
2
2
1
1
2
1
1
2
2
1
1
4
2
1
2
4
1
4
2
1
2
1
2
3
2
2
1
3
2
2
2
0
1
1
3
0
2
0
2
3
3
1
2
2
1
0
2
1
1
0
2
2
3
1
2
1
0
1
1
2
2
1
1
2
1
2
1
1
2
1
1
2
2
2
1
3
2
1
2
1
0
0
3
1
2
2
2
1
2
2
3
5
4
2
2
1
1
1
0

Input:
100
6 3
134990023 82591007 342003726 361960933 691744064 886789515
547444864 775378507 223855933 402864770 830110732 874624437
5 4
1 4
5 2
6 1
6 3
5 3
2 2 0 0 0
0 0 5 5 5
1 2
2 3
2 4
2 5
5 1
8 3 0 2 3
7 5 1 3 1
3 5
1 3
1 4
2 3
6 5
365215088 550579583 946106732 248164753 898341286 760482210
363778700 434191112 850558582 999814424 819389794 855419083
4 6
6 5
1 5
3 2
1 3
6 3
830935240 529561006 435254394 301408576 911296270 170065509
479053518 514607888 814064603 137112838 748...

Output:
3
3
1
2
2
1
6
0
0
1
1
3
2
3
3
0
2
3
3
2
1
2
1
2
4
0
2
2
2
1
1
1
0
3
3
2
2
1
2
3
1
2
2
0
1
2
0
2
2
3
2
3
1
2
2
2
1
2
1
4
3
0
1
3
2
3
4
4
3
2
2
2
2
0
0
3
3
1
1
3
2
2
0
3
1
3
2
2
2
1
2
2
3
2
0
0
3
2
1
1

Input:
100
6 4
58 85 88 31 64 40
0 85 92 36 33 36
5 1
3 6
1 2
1 4
1 3
6 2
680844695 768903934 649946197 404106201 307266173 187683003
977504613 874518206 781428675 59834771 611866769 52607781
5 6
2 5
1 2
1 3
4 1
6 2
94 65 39 49 67 5
62 11 97 18 47 23
2 4
2 6
3 1
2 1
2 5
6 3
50 90 2 26 87 4
9 9 58 61 41 69
1 5
2 3
2 5
4 2
2 6
6 6
92 87 56 57 5 53
45 67 57 62 1 68
6 4
6 5
3 5
1 5
1 2
6 2
7 43 49 92 98 63
1 56 42 29 98 72
6 4
5 1
2 5
4 3
2 4
6 2
874363240 297069275 2...

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

Input:
100
6 5
8 0 7 7 4 6
5 6 7 4 6 7
5 3
6 4
5 4
2 4
1 2
6 2
6 6 4 5 3 10
4 0 4 5 8 9
6 2
3 2
5 2
1 3
4 2
6 3
9 3 2 4 10 5
1 2 10 2 2 5
6 5
2 5
4 6
3 5
1 6
6 3
3 4 2 3 7 1
1 0 2 5 5 3
6 2
5 3
6 3
3 4
1 4
6 2
14 53 90 80 79 7
95 45 68 94 78 93
5 6
1 3
6 2
6 4
6 3
6 3
5 8 6 4 7 1
9 10 9 0 7 0
6 4
5 6
1 4
2 3
4 2
6 3
2 8 3 3 2 7
2 9 8 5 1 0
5 2
1 3
3 5
4 1
6 3
6 1
84 29 88 41 67 95
29 66 79 21 100 92
4 2
2 3
3 6
5 3
1 5
6 3
1 10 3 6 9 1
1 6 0 10 0 ...

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

Input:
100
7 4
19826333 425301481 924066716 478489841 920406041 353188472 139228770
998672579 529085871 114408207 280547881 488779252 855685429 398776892
7 4
3 6
7 2
7 3
3 1
5 7
7 7
334810617 179109896 813200536 169505786 596153607 860362852 73645601
990608904 348903352 31250181 213231027 46711155 283863152 384071291
4 6
4 1
2 7
1 7
2 5
7 3
7 6
409455012 854426952 575872818 315870275 938129035 867786053 130122431
564398492 434246640 624120126 499087510 23119840 632462371 890927208
4 7
3 4
...

Output:
3
4
3
4
2
3
3
2
2
1
3
3
2
3
2
5
2
0
3
4
3
5
2
4
5
2
2
4
4
1
4
4
2
0
1
2
3
3
3
4
4
4
2
2
2
2
2
2
2
5
3
3
3
2
1
5
2
2
3
2
3
3
0
2
2
2
0
2
0
2
3
1
3
5
3
3
1
1
2
3
2
2
4
4
4
5
4
3
2
3
1
4
4
3
1
1
2
3
2
4

Input:
100
7 5
73 57 59 8 58 22 43
81 38 53 33 33 11 73
7 4
6 2
3 7
5 3
1 6
4 1
7 1
344008338 134238142 559223918 470617964 51895680 632023779 215911420
835423870 332733484 52498153 734596408 558762661 352085196 435257767
2 1
7 6
3 6
6 4
4 5
1 4
7 5
81 16 75 75 57 26 25
78 56 38 87 67 1 73
1 4
1 7
3 7
2 7
2 6
5 7
7 6
60 81 81 2 35 94 46
57 78 45 36 50 28 98
5 7
3 6
3 4
5 4
4 1
2 5
7 6
88 51 71 83 78 27 21
3 20 26 99 48 66 51
1 4
1 7
3 5
4 2
5 1
6 1
7 6
41 60 8 42 1 8...

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

Input:
100
7 6
1 7 6 2 4 5 2
8 10 2 9 2 0 3
5 7
5 3
6 5
2 5
6 1
4 6
7 7
10 6 7 6 10 1 0
4 10 3 2 9 0 2
6 7
4 6
1 7
7 5
2 1
3 5
7 5
3 6 2 0 10 0 1
3 1 1 10 3 8 4
4 2
6 1
3 6
1 7
4 7
7 5
7 2
95 12 17 61 38 82 18
57 41 22 53 54 21 71
1 4
1 7
6 7
4 2
1 5
3 5
7 6
9 3 10 3 6 0 6
4 9 8 7 0 0 8
2 3
1 5
6 5
3 4
3 6
7 1
7 5
9 2 10 3 1 6 0
8 1 10 4 8 9 2
5 6
3 2
7 1
7 3
7 6
3 4
7 3
49 11 46 66 58 77 77
27 85 88 48 78 28 46
7 5
6 4
2 7
4 3
5 4
7 1
7 3
81 74 98 ...

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

Input:
100
7 4
1 2 3 5 9 0 0
4 7 2 8 0 4 8
6 5
1 5
7 5
1 3
3 4
6 2
7 3
4 1 1 5 7 1 8
8 4 5 7 7 10 3
5 2
3 2
1 5
6 4
7 3
4 3
7 4
5 7 6 7 4 7 3
6 5 3 7 4 2 1
7 2
3 2
3 4
7 5
1 6
3 1
7 4
2036 9526 4597 9817 4685 2789 6458
3093 2276 2222 2 4043 1 2089
1 7
1 2
3 1
5 6
1 4
4 6
8 5
47 27366 40 23421 22523 19429 130 22950
650 108 1327 449 458 870 317 1480
2 5
5 7
8 4
1 4
8 3
4 7
6 7
7 4
7 3 1 3 7 10 7
2 5 7 0 7 9 0
6 4
7 6
1 6
6 3
6 5
2 3
11 5
441216165 759218471 9...

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

Input:
100
11 2
982757278 364464099 184829575 41514543 626996456 245675923 768559811 733790411 1056276 752724677 78632726
111965402 862723926 910915049 33660238 32026702 178579343 231571313 177267045 873637105 641655620 416865019
9 10
9 7
3 5
11 9
3 4
2 1
8 7
7 5
3 1
5 6
12 3
7389269 237657530 782696194 834293901 896101147 806572032 771729806 289880300 393150361 89703724 611699603 107299825
987675845 438330146 677622415 157622305 266164888 48639109 162157507 63311598 596469268 779298806 493782929 ...

Output:
1
2
5
6
5
1
2
4
5
2
6
0
3
5
1
1
4
3
9
2
7
0
0
2
5
7
3
3
3
3
7
4
7
3
2
3
7
6
5
3
5
4
2
8
2
6
2
3
5
7
7
3
8
3
4
5
3
4
4
5
7
4
4
0
7
9
3
2
1
5
5
10
5
4
4
5
1
8
4
1
4
8
6
8
9
4
4
9
1
1
4
2
5
4
6
6
2
7
5
3

Input:
100
30 16
386814599 971157685 753485776 620106107 898005417 29828398 181126807 976693217 370405686 40004903 982807649 246315184 477972861 84351842 317455424 796042367 944498202 35349839 908615842 653276224 261401316 699020786 100357479 694068592 395408011 847678521 910859233 302825006 144434236 799625163
931966439 81296395 321930163 783419191 77154365 704104093 372592557 81206892 982407715 828083849 362868470 808845410 851709331 815499543 330505040 599500700 217701224 899028940 181871618 46159317 104339...

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

Input:
100
30 15
715878666 263015363 885546891 252183522 10439209 158468551 741668308 873416453 795214593 885795498 899360640 575223071 944352108 904329315 818226145 79859009 131478816 886111535 755756532 138550714 834136719 3434601 814066426 939025663 607463501 954755008 914163060 626660556 187519541 671971368
177408939 883768505 144083188 595949986 980184858 438544474 789743005 16319937 84902354 569778649 60765618 829766514 9352512 810521411 499498752 790781101 555272888 333114912 69365431 862912676 24861702...

Output:
11
92
12
130
4
110
210
14
133
13
0
1
92
17
0
16
142
0
95
211
143
10
1
147
86
2
110
12
145
124
15
4
208
13
148
148
147
2
153
219
12
3
138
2
1
2
106
14
154
123
160
156
16
14
146
221
10
0
0
18
2
1
2
134
13
223
14
2
148
20
136
2
2
214
161
1
21
1
0
141
2
110
114
123
0
131
3
85
2
11
144
0
14
149
5
153
10
13
17
80

Input:
74
300 299
29907490 919514141 842463015 192639915 47772394 175542966 950205957 428998610 927878804 205702120 44326407 187729466 473409713 89860171 425378472 673633597 515998164 986169893 920364752 885941842 989905220 62300310 922597155 785815767 474190630 152075299 115038746 951608079 746906104 756284277 984563131 438653966 99607474 859775058 437620958 491778688 454787911 8850746 866624584 99450452 285857494 968248471 1354855 761876477 81041560 282276845 956627585 249215105 905373626 23417213 596110270 2...

Output:
153
293
1071
1217
131
0
1325
145
1017
0
0
163
911
2034
2027
292
893
129
1
154
293
166
2021
2205
1
1368
161
1512
144
1356
116
293
147
1647
3
1456
124
921
900
2107
135
1132
133
1
1350
2
122
0
2
0
142
16
2
292
1239
125
26
1334
2
1477
153
1051
2249
150
2
1608
22
1513
162
149
292
154
150
1623

Input:
33
3000 1
230368863 909812362 161467704 729088902 62034030 608578531 975495087 450283799 478958096 59377567 887355658 193029103 526829274 175087888 519268105 637963032 973089173 973121716 147333922 976855016 181150728 121212203 615218322 855656122 203623334 265119219 892364268 149669057 979994082 277176505 997380662 298579116 344120679 45771257 33347839 403500773 447383028 365975887 555168709 601910497 816643357 389912733 187451145 84370374 185979054 57275609 487775662 768645407 85333966 308931300 976392...

Output:
0
1494
1494
1505
1520
1494
1276
1528
1
1552
1601
1154
2063
3
3
2
1507
1
1
2
1437
3
1520
1520
0
1264
1409
1534
1404
1
0
1507
1541

Input:
33
3000 1500
972232 165948825 98058819 177636402 189649326 185663236 110245150 106904717 90588556 167024126 124737992 79391317 189586534 53193478 116803011 76888251 154608621 156115030 146936354 128918997 109151992 99279468 66223690 78534783 120506734 63135604 124354493 162702783 156142766 170953957 89088941 175994736 74570078 93104587 193409539 147045474 193869660 175438249 175775913 165284396 154335567 129356350 161695441 161687128 104027779 129998749 130539951 195265116 169650856 171676465 168807124 1...

Output:
0
1344
1318
1514
1
1491
1684
1504
1345
3
2
1
1
0
2
1539
1648
219
1461
1363
1268
1520
1517
1
1489
3
1489
1252
2
190
1370
1509
217

Input:
100
99 90
24848034 509907894 304657434 274667668 361226637 91055155 583834253 286909391 927606482 77805610 452979607 97270279 484075646 64576298 946419972 289416194 741385710 598683810 578077658 945173944 569402950 229729085 863406908 290524057 241518219 452987326 667798035 977982057 15207076 658502659 524891985 193111098 266923775 257137386 210458477 979605117 581907654 915098463 650420517 289103860 163341469 221695299 246434280 204943988 536361005 209236271 482301217 415839762 768691643 684211653 97997...

Output:
71
0
3
13
18
1
52
34
30
2
7
6
0
57
14
0
0
5
0
37
0
37
14
10
1
32
14
13
11
32
7
0
7
3
11
14
16
1
14
12
17
17
0
37
8
7
0
5
24
1
18
6
36
24
3
29
7
8
36
17
8
7
36
26
24
21
2
2
3
1
22
61
28
0
10
24
12
1
9
1
21
9
13
0
2
24
3
36
0
34
17
0
6
4
3
2
4
6
4
40

Input:
100
99 73
965934185 374692604 531121013 83895915 814644517 105399059 611698368 60331609 171543362 41068987 868925238 430625743 34870791 964130117 405269735 126542247 990214320 220797288 9924153 979465483 530212080 400157416 989159599 415580788 529426457 477889402 885953670 32087102 441221142 284946367 428881987 375529435 279659387 116525882 882899117 536340198 700917959 948321122 27433638 993745093 461878097 789390425 985573536 911001886 421671608 149062815 779701476 441530034 419395687 16288217 68996166...

Output:
0
21
4
0
0
10
13
1
27
4
8
4
0
4
0
14
14
12
0
23
0
1
10
0
15
4
2
0
3
9
1
0
0
0
0
6
0
1
5
1
9
2
25
7
0
2
1
8
46
10
0
36
38
0
3
24
15
45
5
6
3
1
29
8
0
0
0
0
1
0
0
19
7
1
12
0
0
15
10
3
4
48
3
10
0
1
0
0
7
2
0
5
9
3
3
14
19
28
0
0

Input:
100
71 62
152877369 75294178 579181478 216922117 849302728 324338447 250378112 664358229 337293795 617976674 340884367 544400305 292876036 723909092 914699755 634443348 320991250 584116226 19290385 460748518 517239355 303673563 500538935 227604865 832736491 458421148 545684500 859144574 940631249 55204148 602110492 781321500 740223477 261826439 681080977 674547153 188706555 228970581 153400505 846130019 172547134 960796591 898489990 65933186 441020521 201861460 131133369 31791537 535399809 255770386 4354...

Output:
47
9
65
42
7
10
7
6
28
9
4
8
1
1
3
1
5
4
0
0
1
4
0
1
0
64
2
2
26
14
6
9
10
5
7
0
7
34
22
6
14
6
1
5
11
2
25
1
21
7
24
3
3
33
17
2
0
6
2
5
0
2
3
0
10
0
10
9
10
2
5
4
30
4
10
10
5
1
16
5
0
16
4
2
25
8
18
36
1
1
20
59
5
25
1
14
10
21
50
5

Input:
100
4 1
457322763 12566667 898571874 918467421
457322762 12566667 898571875 918467421
2 1
1 4
2 3
1 1
364401826
364401826
5 2
432548424 247125438 494750652 666291511 379172607
432548426 247125440 494750653 666291513 379172608
3 2
2 1
5 2
2 4
5 3
846475217 318852568 970242579 543123998 688726029
846475220 318852571 970242581 543123999 688726031
2 1
2 3
4 2
5 2
2 1
778572151 519638476
778572153 519638477
2 1
2 2
276034625 331240360
276034624 331240360
1 2
4 3
492366745 174371...

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

Input:
100
2 2
168923531 706808197
162298156 709231509
1 2
3 1
144910143 377277947 606052481
118053322 376899838 540470057
2 1
3 2
4 3
697886894 823641362 174592362 415028906
725704051 857701460 122926660 369298571
1 3
1 2
1 4
3 3
740835530 715015602 727223354
864012361 702927091 787882323
2 3
3 1
5 3
792685174 221826296 47117600 723330657 188930478
746104965 279368960 66355341 729540950 322006997
5 4
3 2
5 1
5 2
2 2
350507302 230329593
273041985 210747620
2 1
5 3
200043739 417393...

Output:
1
0
1
2
3
0
3
0
1
1
1
0
0
0
0
0
0
2
4
1
1
1
0
0
1
0
0
2
1
3
1
1
1
1
4
0
1
3
2
0
2
2
2
0
1
3
0
0
2
0
2
2
1
0
0
0
1
5
0
0
0
0
2
0
0
1
0
2
1
2
0
0
2
1
0
0
1
0
2
1
0
0
0
1
0
2
0
4
1
1
1
1
1
0
1
1
1
2
1
2

Input:
100
5 1
983257039 756021897 219226803 785743593 921243401
131849434 148913823 616411870 730608446 487572884
3 4
5 4
5 1
2 4
2 2
605983555 521629891
255199222 331427636
1 2
1 1
59250985
824689415
3 1
135901061 53353914 594198153
769950394 146009149 856431962
3 1
2 1
2 1
693413511 651621981
654789460 842526425
1 2
1 1
242538508
29325742
4 4
432985480 884948563 299569283 590428372
930709972 331613135 709421264 173884468
2 4
2 1
3 2
3 2
770743450 164212448 801757689
546567298...

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

Input:
100
58 28
238688636 583319392 894977236 475655981 943631125 286859606 776373418 872044681 485012732 142446898 898250584 679775645 642567469 58729910 782797820 806824611 357905323 938525011 793951448 783695399 216406530 306966833 96521195 766130997 956732369 138733149 838495051 661238724 834207757 514144754 289938613 682160955 865996329 190198276 678676789 631515376 251008558 977213954 217655275 122612734 998610789 270248211 669623406 670520403 702292798 151217793 152754370 528164940 32350130 13334418 609...

Output:
25
0
6
22
29
3
0
7
18
4
0
0
2
1
13
32
4
1
9
7
12
1
0
0
0
19
8
1
51
17
0
0
0
32
1
14
12
20
24
26
3
0
11
0
15
11
0
21
18
2
10
0
42
1
0
9
18
0
0
0
11
0
11
15
12
2
0
23
10
8
6
21
8
4
0
1
1
0
17
27
21
2
15
16
15
14
9
24
7
55
0
2
0
11
4
17
19
25
23
19

Input:
100
85 72
764642078 894063884 679473494 945594195 223837032 776886471 374287509 493518209 134394915 720332599 974261784 609090455 357423370 728787428 900543662 395772914 968527461 722429549 267290760 512837184 453382398 224360954 811406552 953899221 191098732 652833883 676902822 907173453 683528492 934979749 427760621 633428736 624913338 336812333 317705877 409852820 242253787 919943809 521430385 189226168 342888475 784032466 933551106 359617143 641019924 205456286 734726380 949509749 660187366 244984658...

Output:
7
32
10
16
1
0
0
17
5
2
60
3
0
6
17
11
8
12
46
9
3
22
31
56
24
30
1
2
12
3
5
8
4
8
4
4
6
2
10
7
5
0
3
5
29
11
39
22
13
38
4
6
29
32
0
26
2
7
18
0
9
33
63
2
17
17
0
65
15
5
1
19
30
90
1
5
3
28
8
15
23
12
43
16
12
24
8
14
11
12
48
7
15
29
1
3
2
3
10
30

Input:
100
98 16
822662381 922606765 216694484 740757642 105113478 872964713 266371903 62553042 439335472 97692744 970671259 739787244 384629453 367658720 531248793 910324322 593313375 532987681 677621653 996717611 402083143 386087455 174819568 893375901 716285485 505936523 303860706 767327118 868292054 268892130 712383597 226294811 150452975 463151277 937588350 126864529 203196001 205121718 165954594 277853892 927607587 624103756 645330437 288237183 525391309 644324994 643067311 502046726 366144981 294232626 6...

Output:
11
7
1
3
11
13
1
0
0
6
0
4
7
1
5
7
9
16
8
12
8
2
4
2
12
11
6
3
6
11
12
1
3
4
4
6
8
1
0
4
0
4
0
0
4
16
11
1
0
7
2
14
3
3
2
1
2
3
9
0
2
0
2
5
0
0
2
12
4
1
0
0
4
5
5
0
1
1
7
7
0
1
0
4
0
8
11
6
6
0
7
14
5
5
0
7
8
9
11
18

Input:
100
93 54
427778050 995826963 455575879 656065285 805460554 667279022 945300064 922847494 480191774 557531734 845663641 385532976 227562784 812445915 420171210 887744524 828726332 544757458 804314740 878891750 344247831 324346230 409966217 464470159 895262731 702897067 860550469 912093149 691475119 745031106 498150441 580255501 708366533 884715877 539651246 348914493 935847749 977948509 873304195 488426436 359510585 320339710 329213443 953397828 338690196 349958804 544908737 383355967 839981027 723132495...

Output:
0
0
0
0
0
2
4
0
0
0
1
0
0
12
0
51
0
6
0
51
4
15
0
12
27
0
1
0
0
0
0
10
4
0
61
12
0
0
0
0
50
1
41
0
12
27
1
1
0
5
6
0
6
25
11
6
15
42
17
0
0
0
8
0
43
0
0
0
0
24
6
0
8
0
55
0
0
28
11
0
25
4
0
20
32
2
1
1
0
0
42
41
0
2
0
0
0
0
0
42

Input:
100
90 67
416299060 189893326 687907943 630178436 548571783 436268267 522993113 673246928 270177289 699760874 655379124 916743076 738704573 401352135 847101858 947493693 237895243 597922673 724397923 849731112 396223449 782580639 809671075 772752706 780759284 276115359 642237808 984626343 746949558 790128855 424379209 610607622 455028795 516560688 515435710 566901767 631474403 322947281 974019774 950842951 308609602 708933408 193055749 831087379 937878002 597783468 372368247 897404579 265131476 199729574...

Output:
0
10
0
0
0
0
39
0
6
7
0
0
6
0
0
0
0
18
0
0
0
0
0
4
5
52
0
0
0
0
0
0
0
0
0
0
9
47
3
9
0
0
19
8
0
7
3
0
0
34
3
0
20
1
0
11
8
33
76
0
31
48
0
0
64
2
26
6
3
2
6
0
0
0
0
17
0
35
3
0
6
0
0
0
13
0
0
0
34
16
3
12
4
0
2
13
0
0
11
0

Input:
62
398 341
663406199 2751951 41673058 512405971 318711815 461753593 527285906 681730799 684214039 519221386 101740316 101027468 677495458 302742386 564304447 513893773 401256618 47996374 723379193 301853945 377755062 823212027 287599232 356681019 501954794 288952606 510817979 197223789 357036509 614706595 494866062 779906351 330869176 136306150 286253558 551822379 541467656 546983471 687681955 846244125 35041941 812034328 69637713 255434971 445269372 871260684 745818681 407373824 699804676 129506895 5920...

Output:
341
2302
1335
205
107
330
367
623
801
207
293
276
12
340
1681
191
20
314
1589
2
415
380
1625
120
1076
16
65
1488
211
85
898
542
103
185
4
299
538
1785
25
20
301
422
65
255
206
1652
62
1021
171
990
17
33
446
849
475
984
593
22
67
2068
100
322

Input:
53
2394 2289
919803624 884323884 586217910 530635968 521519074 265999224 433347804 245767186 750275200 748716979 774153609 590781505 609170679 767061918 260275223 330350062 618621552 24083861 493492513 472317672 388420188 365466382 335302432 185337328 889391216 876857784 557799057 666380134 399212019 807304012 890558197 29011223 103050875 640687061 223509703 753677761 715366432 171076086 258276858 532781652 947549922 514149416 27343608 818411635 761005484 245228626 570721529 307221596 653702477 848733396...

Output:
1079
527
529
1356
664
389
829
441
477
913
833
624
453
340
576
198
1180
997
1088
152
101
334
864
1229
714
891
508
986
1074
1290
555
295
1503
1004
882
503
659
1061
377
392
1250
386
882
737
306
1090
907
20
117
1134
1004
945
610

Input:
34
3000 1304
506699063 896354473 999045204 744994650 357393369 256197407 360113058 135659924 461924971 345822944 830554677 434402685 650915721 947517968 393404460 837097117 716574927 973996918 874206343 533151673 615351904 863622623 190133867 333768258 253773579 799587701 631882371 870262785 294990696 832078509 138811761 972287250 473050932 461573421 138218172 846943872 655104495 642171253 193158867 485937023 679508646 962394881 604351232 605738436 182268463 617396846 955753260 446462710 550171323 952244...

Output:
13
1798
3
5
1438
0
2
0
3
2
3
1273
3
15
1697
1700
0
1375
71
2
2
11
87
2
1713
1652
1345
1782
511
1408
4
0
1681
116

Input:
34
3000 415
914286465 150317386 446528676 307697196 735139035 831697604 717493685 708331239 832996673 364247508 595091361 103046505 284110948 906675978 800655707 654498686 151340382 132982873 681714642 228657309 623463264 202676512 162970066 620122266 595808234 745576286 631521385 144244114 407757044 82532456 113976006 125376689 613796954 75077550 674986595 694106414 953936345 42551682 600386482 201989257 302388015 341388652 781249264 363541839 220586787 93059110 267707913 558157248 523620536 720780832 6...

Output:
266
517
4
76
31
489
156
5
360
15
593
3
334
20
322
18
310
582
138
28
51
23
367
0
365
494
324
542
468
14
222
370
0
14

Input:
100
1000 698
350566799 135615916 111649768 263794191 127035752 303110559 908063197 975843392 903461041 938521902 992461519 733688523 301508078 684885170 349144673 821193835 690995161 217512286 872048796 835048295 77610556 238843286 598783796 828365459 400855185 365042950 458307195 745459952 220907730 180456710 634773149 204309625 638674638 229437492 187815436 748951698 597275468 486754827 713419233 769029181 535152532 64354193 49004008 49261042 400730519 821457981 111608324 931283251 679901366 978607306 ...

Output:
439
8
31
1
0
360
138
523
663
20
84
327
404
263
47
12
24
325
646
12
3
573
447
116
472
446
431
359
128
373
1
449
7
6
0
30
481
0
665
421
10
573
35
0
385
74
4
275
14
2
8
689
367
474
0
12
0
0
489
635
1
9
439
5
2
325
3
0
496
2
84
386
25
0
94
663
2
134
3
172
186
0
191
48
108
24
475
30
350
23
54
0
49
607
311
48
663
242
28
11

Input:
34
3000 722
792106645 245515222 215822611 437308607 276506205 641197836 152528976 524828635 560976210 742901220 333951036 920444420 669333894 389865764 411091090 694358731 136140740 855898146 505017732 814484374 411874361 736722248 271582446 361557757 671143138 977288927 865934957 410887096 450047856 642170500 429194300 427396046 336727244 856366008 459270987 237874949 597992695 459595490 812337282 241822063 455607183 643423739 249190656 923971001 655776580 236517813 366621567 283855617 605313602 4743186...

Output:
5
191
34
469
4
9
21
28
574
867
914
4
0
92
389
1204
658
817
795
120
465
1379
11
862
7
0
733
2
0
9
1003
512
30
0

Input:
34
3000 1079
753250248 139732060 165421124 983928639 349408625 873542698 697548295 638535732 706238800 355693689 161135266 891543641 310786395 714629209 645059866 114863834 540515641 912752443 966648558 311118144 222793598 665177671 259437810 672329538 325631432 428067937 415206033 488312896 429387783 641803255 280034564 147974308 954982396 692021459 707921184 710589254 147488716 365457913 777908379 754080962 580696868 787788287 691535066 276743261 678017864 565166313 919424555 987107557 715321807 893002...

Output:
28
8
463
17
24
1052
6
0
17
160
8
2
36
21
0
8
206
16
46
204
319
43
66
0
1371
4
1406
601
41
0
916
1483
6
22

Input:
34
3000 1551
116821125 323604875 480241329 98987973 272396803 552819914 40022530 24586556 124689214 202780230 258994252 215122709 89142498 207063200 262288888 435832227 563498553 152291937 547184594 318465349 161098535 400091980 7104480 406704704 357907919 304642319 151643844 538217222 156834941 515480740 702077994 384639552 544819686 449498599 548742978 521635490 460316395 49199759 399729035 67417565 301767439 498924757 540067364 628912640 636851636 422502052 86857267 133038662 545970192 564154748 58131...

Output:
1551
1333
0
1545
1881
0
37
2039
0
1734
1753
0
0
1991
0
0
1498
1989
1344
1517
993
2
1885
1759
1126
118
0
1579
0
1293
1274
920
0
4

Input:
34
1000 450
412246355 677892855 431140580 823577612 496235251 524384303 45789890 857852428 407646763 194255594 362117208 42559099 601509148 75338297 796713940 284552850 543325874 313490426 414443785 612412338 498020940 187536744 777590335 413057716 790598769 706223333 780128935 426670055 385268119 342400852 833977761 865789387 445783325 317661171 544713896 159291868 653845406 229107261 809795273 790541561 852552798 417019484 210472180 437980560 383089398 108267930 407554354 691802961 691955586 68630142 5...

Output:
450
77
0
561
1011
392
743
14
1419
0
22
634
0
0
409
600
993
868
643
17
987
38
0
0
0
616
552
555
44
0
54
0
0
0


Recall that the permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array) and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).A sequence $$$a$$$ is a subsegment of a sequence $$$b$$$ if $$$a$$$ can be obtained from $$$b$$$ by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. We will denote the subsegments as $$$[l, r]$$$, where $$$l, r$$$ are two integers with $$$1 \le l \le r \le n$$$. This indicates the subsegment where $$$l-1$$$ elements from the beginning and $$$n-r$$$ elements from the end are deleted from the sequence.For a permutation $$$p_1, p_2, \ldots, p_n$$$, we define a framed segment as a subsegment $$$[l,r]$$$ where $$$\max\{p_l, p_{l+1}, \dots, p_r\} - \min\{p_l, p_{l+1}, \dots, p_r\} = r - l$$$. For example, for the permutation $$$(6, 7, 1, 8, 5, 3, 2, 4)$$$ some of its framed segments are: $$$[1, 2], [5, 8], [6, 7], [3, 3], [8, 8]$$$. In particular, a subsegment $$$[i,i]$$$ is always a framed segments for any $$$i$$$ between $$$1$$$ and $$$n$$$, inclusive.We define the happiness of a permutation $$$p$$$ as the number of pairs $$$(l, r)$$$ such that $$$1 \le l \le r \le n$$$, and $$$[l, r]$$$ is a framed segment. For example, the permutation $$$[3, 1, 2]$$$ has happiness $$$5$$$: all segments except $$$[1, 2]$$$ are framed segments.Given integers $$$n$$$ and $$$m$$$, Jongwon wants to compute the sum of happiness for all permutations of length $$$n$$$, modulo the prime number $$$m$$$. Note that there exist $$$n!$$$ (factorial of $$$n$$$) different permutations of length $$$n$$$.

NoteFor sample input $$$n=3$$$, let's consider all permutations of length $$$3$$$:  $$$[1, 2, 3]$$$, all subsegments are framed segment. Happiness is $$$6$$$.  $$$[1, 3, 2]$$$, all subsegments except $$$[1, 2]$$$ are framed segment. Happiness is $$$5$$$.  $$$[2, 1, 3]$$$, all subsegments except $$$[2, 3]$$$ are framed segment. Happiness is $$$5$$$.  $$$[2, 3, 1]$$$, all subsegments except $$$[2, 3]$$$ are framed segment. Happiness is $$$5$$$.  $$$[3, 1, 2]$$$, all subsegments except $$$[1, 2]$$$ are framed segment. Happiness is $$$5$$$.  $$$[3, 2, 1]$$$, all subsegments are framed segment. Happiness is $$$6$$$. Thus, the sum of happiness is $$$6+5+5+5+5+6 = 32$$$.

Print $$$r$$$ ($$$0 \le r < m$$$), the sum of happiness for all permutations of length $$$n$$$, modulo a prime number $$$m$$$.

Input: 1 993244853

Output: 1

Input: 2 993244853

Output: 6

Input: 3 993244853

Output: 32

Input: 2019 993244853

Output: 923958830

Input: 2020 437122297

Output: 265955509

Input: 250000 993244853

Output: 872048421

Input: 244435 994838543

Output: 634651929

Input: 234324 994631069

Output: 720229385

Input: 249996 997202249

Output: 633673455

Input: 32433 992864681

Output: 302084847

Input: 4 389349601

Output: 180

Input: 5 141602633

Output: 1116

Input: 6 223676287

Output: 7728

Input: 7 110998807

Output: 59904

Input: 8 848339069

Output: 518400

Input: 9 298827211

Output: 4982400

Input: 10 876938317

Output: 52842240

Input: 11 739198003

Output: 614200320

Input: 12 273157301

Output: 122791732

Input: 13 797912417

Output: 234147739

Input: 14 353847517

Output: 42904792

Input: 249997 996061721

Output: 69046617

Input: 249998 990040613

Output: 108188702

Input: 249999 992509109

Output: 854585866

Input: 250000 996140731

Output: 227969454

Input: 2341 994476991

Output: 121932216

Input: 1000 100000651

Output: 92079298

Input: 100000 100000921

Output: 51605491

Input: 20422 956269049

Output: 895579878

Input: 40424 285650803

Output: 114646354

Input: 60426 547574749

Output: 323978028

Input: 80428 410667659

Output: 284512223

Input: 100432 858603079

Output: 763015781

Input: 120424 735211237

Output: 78258285

Input: 140426 454141843

Output: 451934478

Input: 160428 434183023

Output: 156691255

Input: 180420 266525887

Output: 239713633

Input: 200422 984828937

Output: 556345906

Input: 220424 428927617

Output: 43877713

Input: 240422 623039447

Output: 291729074


Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $$$n$$$ light bulbs in a single row. Each bulb has a number from $$$1$$$ to $$$n$$$ (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the garland. Now Vadim wants to put them back on.Vadim wants to put all bulb back on the garland. Vadim defines complexity of a garland to be the number of pairs of adjacent bulbs with numbers with different parity (remainder of the division by $$$2$$$). For example, the complexity of 1 4 2 3 5 is $$$2$$$ and the complexity of 1 3 5 7 6 4 2 is $$$1$$$.No one likes complexity, so Vadim wants to minimize the number of such pairs. Find the way to put all bulbs back on the garland, such that the complexity is as small as possible.

NoteIn the first example, one should place light bulbs as 1 5 4 2 3. In that case, the complexity would be equal to 2, because only $$$(5, 4)$$$ and $$$(2, 3)$$$ are the pairs of adjacent bulbs that have different parity.In the second case, one of the correct answers is 1 7 3 5 6 4 2.

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of light bulbs on the garland. The second line contains $$$n$$$ integers $$$p_1,\ p_2,\ \ldots,\ p_n$$$ ($$$0 \le p_i \le n$$$) — the number on the $$$i$$$-th bulb, or $$$0$$$ if it was removed.

Output a single number — the minimum complexity of the garland.

Input:
5
0 5 0 2 3

Output: 2

Input:
7
1 0 0 5 0 0 2

Output: 1

Input:
1
0

Output: 0

Input:
20
7 0 9 0 5 0 15 0 0 1 17 0 11 19 0 0 3 0 13 0

Output: 15

Input:
20
9 0 0 0 18 0 11 0 0 4 0 15 0 0 0 14 0 0 5 0

Output: 6

Input:
20
13 0 0 12 14 0 19 0 15 0 8 0 7 0 9 0 20 0 0 10

Output: 5

Input:
20
1 0 0 13 0 0 16 0 0 4 0 0 7 0 19 0 0 10 0 0

Output: 3

Input:
20
0 0 0 0 0 0 0 0 0 9 16 19 3 6 11 1 7 4 13 12

Output: 8

Input:
20
0 0 0 0 0 0 0 0 0 2 0 0 0 0 1 0 19 9 6 0

Output: 3

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

Output: 54

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

Output: 48

Input:
100
0 15 61 36 45 40 76 56 86 60 42 0 19 11 0 94 0 0 65 32 35 27 54 18 72 4 99 30 95 10 9 81 79 0 0 13 2 66 0 62 77 58 100 50 87 17 41 6 70 78 82 0 89 0 96 0 0 0 51 33 68 55 21 1 24 91 7 0 69 8 0 85 0 0 0 71 28 49 84 48 20 5 14 63 59 73 0 57 52 3 46 31 34 97 0 67 80 23 53 25

Output: 43

Input:
100
39 0 46 92 0 0 11 0 21 47 0 29 72 20 0 37 31 58 71 0 0 66 4 77 12 44 0 100 0 13 10 0 0 17 0 65 9 28 85 0 0 3 53 14 95 68 33 1 59 18 0 0 87 0 0 0 78 73 0 86 40 55 2 0 6 63 24 0 26 23 88 41 61 0 34 96 76 0 80 5 67 0 0 70 97 49 69 38 89 50 99 8 81 0 0 25 43 0 94 91

Output: 42

Input:
100
5 42 0 0 4 66 46 98 70 77 0 0 0 0 49 88 0 0 28 54 0 10 0 0 86 0 17 0 0 52 82 71 8 3 0 81 0 0 47 76 0 13 1 0 93 97 94 85 0 84 58 40 0 0 45 65 0 99 51 32 0 0 16 36 0 56 6 79 0 83 68 0 0 0 90 0 67 53 0 0 29 92 0 35 25 22 26 0 37 0 0 0 91 64 89 0 60 0 95 63

Output: 26

Input:
100
40 94 74 72 0 0 91 0 0 0 37 39 0 93 31 0 52 68 0 30 0 82 99 0 14 41 0 2 92 0 0 0 56 59 84 36 0 0 98 0 0 61 0 0 0 22 0 0 27 69 45 46 0 64 96 90 42 0 9 33 57 0 24 0 4 1 55 28 0 0 70 0 78 0 0 0 0 81 0 71 0 0 60 0 0 18 86 0 0 0 0 0 0 0 0 0 43 0 0 83

Output: 19

Input:
100
13 0 0 52 40 62 0 0 0 0 0 82 0 0 98 0 36 75 0 27 0 0 0 4 79 74 46 70 65 0 60 67 18 69 0 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 19 0 0 77 0 0 76 59 0 91 11 0 0 0 29 0 0 0 54 15 0 0 0 57 0 96 0 0 0 28 0 0 72 44 89 0 95 0 0 99 64 0 90 0 0 0 0 0 0 10

Output: 17

Input:
100
0 92 0 75 16 87 0 0 0 0 5 0 0 0 0 60 0 0 52 35 0 17 59 0 0 0 57 0 0 0 0 0 0 0 0 58 41 0 0 0 44 38 0 0 0 0 0 0 68 0 0 67 25 89 0 0 0 0 0 0 0 47 39 0 0 0 0 0 40 0 74 3 0 0 0 0 0 0 0 0 0 81 45 0 0 0 0 0 0 0 0 64 0 0 0 0 0 56 2 11

Output: 13

Input:
100
0 0 41 0 0 0 0 0 0 0 58 30 0 0 0 93 0 0 0 0 0 0 0 0 0 0 0 0 40 12 0 0 0 0 0 0 0 0 0 0 0 85 0 51 0 0 0 0 39 0 0 62 0 0 0 0 20 0 0 0 0 0 0 0 75 27 0 0 0 0 72 0 0 0 0 98 0 0 0 0 0 0 50 0 0 0 0 0 0 38 37 0 0 0 0 0 0 32 0 100

Output: 9

Input:
100
0 0 0 0 0 0 0 0 0 0 0 55 0 0 0 0 0 0 27 0 0 0 0 0 0 88 0 0 0 0 0 15 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 75 0 0 0 0 0 0 0 0 0 0 0 0 47 0 0 0 0 0 0 71 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 59 0 0 0 6

Output: 7

Input:
100
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0

Output: 1

Input:
100
0 0 0 0 0 0 0 0 0 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Output: 1

Input:
100
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 69 63 77 67 28 7 23 97 99 20 42 50 43 27 81 18 76 87 79 52 37 29 24 65 85 83 68 25 10 45 75 33 15 66 71 6 21 64 47 22 8 39 57 4 1 19 35 12 34 13 9 53 40 62 94 44 90 31

Output: 30

Input:
100
32 33 78 99 27 24 31 60 39 62 46 47 18 56 58 12 67 61 83 79 59 11 40 38 88 94 15 4 98 95 49 8 63 91 25 81 3 28 5 41 90 84 64 19 43 96 36 37 30 1 9 13 70 72 69 16 71 23 93 20 77 66 100 54 73 82 35 89 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Output: 37

Input:
100
67 0 54 0 62 0 37 29 0 25 0 0 59 0 2 0 0 11 74 0 12 0 64 0 24 0 94 0 3 26 0 0 41 0 32 0 20 0 16 100 0 0 76 0 82 0 30 0 27 0 49 0 86 0 92 0 90 0 61 0 1 0 72 0 63 0 23 0 48 0 70 0 96 0 33 0 14 0 38 0 9 0 0 47 17 0 0 66 43 0 22 0 97 0 58 0 0 13 39 0

Output: 24

Input:
100
57 0 0 48 0 0 60 0 0 3 0 0 77 0 0 26 0 0 89 0 0 7 0 0 69 0 0 68 0 0 44 0 0 82 0 0 71 0 0 88 0 0 76 0 0 0 56 0 42 0 0 61 0 10 0 0 0 98 0 0 84 0 0 74 0 0 72 0 0 79 0 0 65 0 0 23 0 0 1 27 0 0 0 0 17 0 0 93 0 0 21 0 0 85 0 0 18 0 22 0

Output: 11

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

Output: 89

Input:
100
1 0 0 4 5 0 7 0 9 10 11 12 13 0 0 15 17 0 19 20 21 22 23 0 25 26 27 0 0 30 31 0 33 0 0 0 0 39 0 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 0 0 59 60 61 62 0 64 65 0 67 68 69 0 71 72 0 73 75 0 76 79 0 80 0 82 83 0 85 0 0 88 89 90 91 0 93 94 95 0 97 98 99 100

Output: 59

Input:
100
0 0 0 4 5 0 0 0 9 0 0 0 0 0 0 0 17 0 0 21 0 23 22 24 0 26 27 28 0 30 0 0 0 0 0 0 0 38 39 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 55 0 57 0 59 60 61 62 0 0 65 0 0 0 0 0 71 72 0 0 0 0 77 78 79 0 0 0 0 0 0 0 0 0 0 90 0 0 93 94 0 0 0 0 98 0

Output: 18

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

Output: 89

Input:
100
100 99 98 97 96 0 0 93 92 0 90 0 0 87 86 85 84 0 0 81 80 79 0 76 0 75 74 0 72 71 0 0 68 67 0 0 64 63 62 61 60 59 58 0 56 55 54 0 52 51 49 0 48 0 46 45 0 43 42 41 0 39 38 37 36 35 0 0 32 31 30 29 28 27 26 0 0 23 22 21 20 19 18 17 0 16 14 0 12 11 10 0 8 0 6 0 0 2 3 1

Output: 55

Input:
100
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 82 0 0 0 78 0 76 0 0 73 0 0 70 68 0 0 66 0 0 0 0 0 0 0 0 0 0 55 0 53 52 0 50 0 0 0 46 45 44 0 43 0 0 0 0 37 36 0 0 0 0 0 30 0 28 0 26 0 0 22 0 21 20 0 18 0 0 15 0 13 0 0 0 9 0 0 6 0 0 3 0 1

Output: 14

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

Output: 81

Input:
100
35 84 41 46 27 82 81 38 69 24 1 52 0 18 0 0 75 98 11 0 0 40 15 0 43 8 0 0 61 0 12 30 0 0 21 16 31 74 33 0 0 56 0 90 99 68 0 80 53 44 5 64 17 0 0 0 0 48 97 78 0 63 9 10 37 32 0 0 87 0 96 49 93 28 65 0 71 66 79 0 20 14 0 95 0 94 13 0 77 36 85 60 23 0 3 92 73 58 67 0

Output: 58

Input:
100
0 0 0 78 67 0 0 0 7 20 0 0 0 66 0 0 1 0 0 0 0 0 0 0 0 36 0 0 57 0 0 55 0 34 13 2 0 0 0 0 0 91 0 32 0 0 0 0 0 87 0 0 0 40 0 0 15 0 0 0 0 0 75 0 0 0 0 0 0 35 0 17 0 0 0 71 48 0 0 0 97 0 69 64 0 80 0 0 25 0 9 0 0 6 0 0 0 0 85 0

Output: 19

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

Output: 50

Input:
100
43 98 51 37 89 46 0 0 55 54 92 0 67 35 66 88 62 9 13 32 87 79 36 0 0 80 3 73 57 0 31 0 0 52 38 0 0 30 59 0 0 93 100 0 42 0 86 0 94 0 90 0 64 0 82 26 39 40 8 6 91 44 48 0 53 99 85 41 69 0 0 16 0 23 15 97 0 75 10 83 0 0 56 63 61 0 17 0 0 21 58 0 81 70 29 0 34 95 18 19

Output: 34

Input:
100
97 2 21 55 0 0 0 0 75 0 20 0 13 0 0 0 65 84 0 0 0 88 0 15 91 0 0 0 62 0 0 0 0 0 0 0 0 0 0 0 0 0 0 71 0 90 0 0 10 68 43 39 0 0 0 0 0 25 50 0 0 0 0 37 0 0 0 0 69 0 0 0 64 0 0 0 0 0 0 53 0 0 56 6 0 0 0 46 0 0 89 0 0 0 0 0 0 0 0 82

Output: 17

Input:
100
67 0 83 0 49 0 23 0 55 0 0 9 31 0 25 0 59 0 95 29 0 0 91 0 21 0 85 51 0 0 37 0 7 0 13 0 43 79 0 0 17 0 75 0 35 0 97 0 5 0 71 0 15 0 61 0 3 0 27 0 53 0 81 41 0 0 39 0 87 0 47 0 65 0 11 0 89 0 99 0 45 0 19 0 93 33 0 0 77 0 57 0 73 0 0 1 63 0 69 0

Output: 85

Input:
100
63 0 0 20 0 0 47 0 0 28 0 0 0 19 0 98 0 0 7 0 0 12 0 0 59 0 0 4 0 0 21 0 0 36 0 0 0 65 0 84 0 0 91 0 0 78 0 25 0 0 0 90 0 0 41 0 0 44 0 0 77 0 0 26 0 0 45 0 0 58 0 0 95 0 0 24 0 0 83 0 0 42 0 61 0 0 0 2 0 0 11 0 70 0 0 0 89 0 0 66

Output: 33

Input:
100
0 29 0 0 23 0 0 0 3 0 0 0 25 0 0 0 73 0 0 63 0 0 0 0 37 0 0 51 0 0 0 0 55 0 0 0 69 0 0 0 33 0 0 0 41 0 0 0 45 0 0 0 61 0 0 0 31 0 0 0 49 0 0 0 91 0 0 0 43 0 0 0 83 0 0 17 0 0 0 0 39 0 0 0 97 0 0 0 27 0 0 0 95 0 0 0 67 0 0 0

Output: 31

Input:
100
40 0 54 83 0 0 13 0 87 0 56 0 4 0 6 0 29 0 10 0 69 0 14 0 100 0 24 0 44 0 79 0 93 0 65 0 88 0 81 0 47 0 61 0 45 0 89 0 94 0 0 78 2 49 0 0 0 75 26 0 7 0 57 71 0 0 73 72 0 0 0 5 55 0 18 0 74 0 82 0 9 0 0 80 16 0 36 0 11 0 52 0 84 0 77 0 22 0 42 0

Output: 22

Input:
100
55 0 0 19 0 0 13 0 0 58 0 73 0 0 0 22 0 0 97 0 0 1 0 0 10 0 0 25 0 0 52 0 0 0 61 0 28 0 0 67 0 0 46 0 0 0 85 0 0 88 0 16 0 0 4 0 0 37 0 0 34 0 0 40 0 43 0 0 0 91 0 0 79 0 0 82 0 0 0 94 0 31 0 0 76 0 0 70 0 0 49 0 0 100 0 0 64 0 0 7

Output: 22

Input:
100
25 0 0 0 71 0 0 0 0 66 0 0 76 0 0 0 59 0 0 0 69 0 0 0 28 0 0 0 83 0 0 0 6 0 0 0 52 0 0 0 2 0 0 0 81 0 0 31 0 0 0 0 17 0 0 0 78 0 0 0 0 40 0 0 0 14 0 0 9 0 0 0 34 0 0 0 47 0 0 0 24 0 0 0 49 0 0 0 86 0 0 0 42 0 0 0 4 0 0 0

Output: 13

Input:
77
0 0 0 0 53 0 43 0 0 0 25 0 0 16 0 0 0 0 0 0 0 55 0 50 0 0 0 0 0 0 0 0 0 0 18 21 75 0 0 0 0 0 0 0 0 0 0 0 0 33 0 0 57 63 0 0 0 60 0 22 23 0 0 0 0 65 0 17 0 0 0 44 67 0 0 0 31

Output: 10

Input:
7
0 0 0 7 0 0 0

Output: 1