QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#863869#9977. Norte da Universidadeucup-team2796AC ✓845ms94656kbC++1717.8kb2025-01-20 00:44:582025-01-20 00:44:59

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3712kb

input:

5
11 5
NNNNN
NN???
WW???
WWEEE
WEEEE
WEEEE
WWEEE
WWEE?
SSSSS
?SSS?
??SS?
2 7
??S?N??
??S?N??
3 4
W??E
WEEE
?E??
2 2
??
??
3 3
???
???
???

output:

26
1587
18
56
1112

result:

ok 5 number(s): "26 1587 18 56 1112"

Test #2:

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

input:

100
4 4
??NN
????
????
S?S?
4 4
????
????
??E?
??S?
4 4
????
??NE
?S?E
S?S?
4 4
WN??
W???
?S??
??S?
4 4
?N??
????
?S??
??S?
4 4
????
W???
????
????
4 4
W???
W?N?
??E?
???E
4 4
??N?
????
W?EE
?S??
4 4
??N?
??N?
?S??
S??E
4 4
????
????
???E
?S?E
4 4
W???
W?N?
W?E?
S???
4 4
WN??
????
????
????
4 4
?N??...

output:

3280
4026
468
936
3627
15949
462
1362
858
5930
147
5520
1212
9733
2932
408
144
823
11866
7676
1212
477
458
96
2004
6949
2201
144
4612
15949
62
108
108
340
1212
936
3118
738
1568
954
104
4934
3350
276
1160
2649
974
360
374
1761
756
4369
477
1280
9826
72
980
1740
3280
3843
892
3214
1012
72
5681
1042
3...

result:

ok 100 numbers

Test #3:

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

input:

17
5 5
?????
??N??
?????
?????
NW???
3 5
?????
?????
E????
5 3
S?S
???
???
???
???
4 4
?E??
???S
N???
??W?
1 2
NW
1 2
EN
2 1
E
N
2 1
S
E
1 1
?
1 1
S
1 10
??NSNSNS??
4 4
????
?NE?
?WS?
????
4 4
????
?WN?
?SE?
????
3 3
???
???
???
4 4
?N??
???E
W???
??S?
4 4
??N?
W???
???E
?S??
4 4
W??E
????
WEEE
????

output:

0
196
6
0
0
0
0
0
4
1
49
81
81
1112
3607
3607
525

result:

ok 17 numbers

Test #4:

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

input:

100
4 4
W?NN
??NE
??E?
?S??
4 4
?N?N
WWN?
WS?E
?SSE
4 4
??NN
?WNE
W?EE
??SE
4 4
WNNN
?WN?
W??E
??S?
4 4
WNN?
???E
?SEE
?S??
4 4
??NN
W??E
?S??
??SE
4 4
WNNN
WW?E
WSEE
SSSE
4 4
WN?N
WW?E
?SEE
?SS?
4 4
WN??
?W?E
WS??
S??E
4 4
W??N
??NE
WSEE
??S?
4 4
W??N
??NE
???E
S??E
4 4
?N?N
W?N?
??EE
???E
4 4
?N?N...

output:

144
24
24
84
192
216
3
18
35
24
201
412
384
168
72
66
36
24
716
106
24
198
104
12
4
24
46
240
624
70
36
147
144
48
92
238
294
12
700
96
24
293
750
174
408
120
288
16
312
336
36
846
52
3691
1459
312
54
96
232
448
24
1158
2391
86
40
120
126
36
360
156
28
153
36
154
1212
16
160
96
66
178
93
156
36
192
...

result:

ok 100 numbers

Test #5:

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

input:

100
5 5
?????
?????
?????
??SE?
??S??
5 5
?????
???N?
????E
????E
??S??
5 5
?N??N
?W???
?W???
??S?E
SS???
5 5
W????
???NE
WW???
??SE?
S???E
5 5
???N?
????E
?????
???E?
?SS?E
5 5
??N??
W???E
???E?
WSSE?
S????
5 5
WN??N
???N?
?????
W???E
???S?
5 5
?NN?N
??N??
???EE
?????
S????
5 5
???N?
?????
W????
??...

output:

62196
84123
4080
744
36736
2379
9952
17487
25920
48774
28280
4196
236992
4888
11830
8022
22371
2385
6402
2376
57284
2823
2876
5744
7532
4542
12420
245266
114732
3420
37209
3381
4266
900
372
15336
9186
77644
39084
19770
2994
5724
84114
1154
56746
2406
3250
69785
2592
29811
10786
7200
6687
6984
9246
4...

result:

ok 100 numbers

Test #6:

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

input:

100
5 5
W?N?N
??NN?
?W???
?S?E?
?S???
5 5
?????
?WNN?
WW??E
W?S??
?S?S?
5 5
W??NN
W?N?E
????E
??S?E
S??SE
5 5
?N?N?
??NNE
?W?EE
WSS?E
SSSSE
5 5
WNN?N
???N?
W???E
WS???
??S??
5 5
WN?NN
?W???
WW?E?
??SEE
S?S?E
5 5
W?N?N
W??NE
?W???
W?SEE
SSSS?
5 5
W?NNN
???N?
???E?
?????
?SSSE
5 5
WNNN?
?WNN?
WW?EE
??...

output:

1521
2088
1098
80
3272
234
188
2656
72
2909
13088
6499
192
2840
1268
1392
1644
1116
512
66
2832
1344
1704
5588
448
1890
972
624
360
156
15405
4950
3824
624
120
108
1488
192
80
732
216
444
9987
1188
440
1488
780
92979
1480
5314
684
126
180
684
1032
6832
92
808
1952
276
774
232
152
1392
960
1614
192
4...

result:

ok 100 numbers

Test #7:

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

input:

100
4 4
??NN
????
????
S?S?
4 4
????
????
????
??S?
4 4
????
???E
???E
S?S?
4 4
WN??
W???
????
??S?
4 4
?N??
????
????
??S?
4 4
????
W???
????
????
4 4
W???
W???
????
???E
4 4
??N?
????
W??E
?S??
4 4
??N?
????
????
S??E
4 4
????
????
???E
?S?E
4 4
W???
W???
W???
S???
4 4
WN??
????
????
????
4 4
?N??...

output:

3280
15949
3896
2907
10238
15949
4877
3312
3555
5930
2635
5520
3096
9733
7339
1648
936
2895
11866
7676
2613
5520
3691
1238
4270
6949
2201
4184
4612
15949
512
4594
6114
4184
2613
2879
7282
1589
4116
3641
1212
4934
7646
986
4369
9868
2635
2512
1745
7339
7765
4369
4686
1280
9826
2120
2398
9826
3280
123...

result:

ok 100 numbers

Test #8:

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

input:

100
4 4
W?NN
???E
????
?S??
4 4
?N?N
W???
W??E
?SSE
4 4
??NN
???E
W??E
??SE
4 4
WNNN
????
W??E
??S?
4 4
WNN?
???E
???E
?S??
4 4
??NN
W??E
????
??SE
4 4
WNNN
W??E
W??E
SSSE
4 4
WN?N
W??E
???E
?SS?
4 4
WN??
???E
W???
S??E
4 4
W??N
???E
W??E
??S?
4 4
W??N
???E
???E
S??E
4 4
?N?N
W???
???E
???E
4 4
?N?N...

output:

1256
432
586
572
1118
634
56
348
437
778
624
1802
1398
426
474
1648
730
508
1594
106
572
1028
952
240
284
508
326
1028
1282
484
473
1380
5181
368
252
510
2262
204
3896
2291
672
719
1920
1362
5467
792
3583
1152
1648
818
4116
2656
832
3691
2713
1564
1367
1116
1250
1170
384
2728
4019
526
1007
3612
320
...

result:

ok 100 numbers

Test #9:

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

input:

100
4 4
WNNN
W??E
W??E
?SSE
4 4
?NN?
W??E
W??E
SSSE
4 4
WNNN
W???
W??E
SSSE
4 4
WN?N
W??E
W??E
SS?E
4 4
WNNN
W??E
W??E
SSSE
4 4
WNNN
W??E
W??E
SSSE
4 4
WNNN
???E
W??E
SS?E
4 4
WNNN
W??E
W???
SS?E
4 4
WNNN
W??E
W??E
SSSE
4 4
WNNN
W??E
???E
?SSE
4 4
WNNN
W??E
W??E
SSSE
4 4
WNNN
W??E
W??E
SSSE
4 4
WNNN...

output:

112
224
96
102
56
56
106
108
56
158
56
56
112
56
56
112
112
62
56
158
62
112
112
68
108
96
56
124
112
56
112
69
158
56
96
124
96
108
96
62
56
56
112
56
56
56
112
62
56
158
56
96
56
68
158
56
96
96
158
158
124
124
384
62
204
56
56
56
365
62
62
68
365
62
216
112
56
56
112
56
56
96
56
62
56
432
96
56
6...

result:

ok 100 numbers

Test #10:

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

input:

100
4 4
WNNN
WWNE
WSEE
?SSE
4 4
?NN?
WWNE
WS?E
SSSE
4 4
WNNN
WWN?
WSEE
SSSE
4 4
WN?N
WWNE
WS?E
SS?E
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN
?WNE
WSEE
SS?E
4 4
WNNN
WWNE
WSE?
SS?E
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN
WWNE
?S?E
?SSE
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN...

output:

2
12
2
6
1
1
2
2
1
9
1
1
2
1
1
18
18
3
1
10
3
2
2
3
2
2
1
2
2
1
2
1
2
3
2
2
6
2
2
3
1
3
6
3
3
1
2
3
1
63
1
2
1
8
2
1
2
6
3
6
2
2
24
1
12
3
1
1
8
3
1
1
24
1
4
2
3
3
2
1
1
2
1
1
3
6
2
3
3
1
1
9
4
6
2
1
2
8
2
1

result:

ok 100 numbers

Test #11:

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

input:

100
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN
WWNE
WSEE
?SSE
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN
WWNE
WSEE
SSS?
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN
WWNE
WSEE
SSSE
4 4
WNNN...

output:

1
1
1
2
1
1
2
1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
1
1
2
1
1
2
1
4
1
1
1
1
1
1
3
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
3
1

result:

ok 100 numbers

Test #12:

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

input:

100
5 5
WNNNN
WWNNE
W??EE
WSSEE
S?SSE
5 5
WNNNN
WWNNE
???E?
WS?EE
SSS?E
5 5
WNNNN
WWN?E
WW?EE
WSSEE
SSSSE
5 5
WNN?N
WWNNE
WW?EE
WSSE?
SSSSE
5 5
WNNNN
WWNNE
?W?EE
WSSE?
?SSSE
5 5
?NNNN
WWNNE
WW?EE
WSSEE
S?SSE
5 5
WNNNN
WWNNE
W??E?
WSSE?
SSSS?
5 5
WN?NN
WWNNE
WW?EE
W???E
SSSS?
5 5
WNNNN
WWNNE
WW?EE
?S...

output:

8
36
8
4
8
8
16
76
16
64
8
4
8
4
8
44
8
18
8
22
16
8
8
4
8
40
8
28
8
48
32
9
48
12
4
8
16
4
96
8
8
4
16
8
18
8
68
8
4
8
16
9
8
16
12
40
16
8
16
16
16
4
8
16
16
39
124
16
8
4
22
16
24
328
8
8
44
8
64
8
44
4
8
8
8
8
8
8
4
4
4
8
4
32
4
16
8
16
4
72

result:

ok 100 numbers

Test #13:

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

input:

100
5 5
WNNNN
WWNNE
WW?EE
WSSEE
SSSSE
5 5
WNNNN
WWNNE
WW?EE
WSSEE
SSSSE
5 5
WNNNN
WWNNE
WW?EE
WSSEE
SSSSE
5 5
WNNNN
WWNNE
WW?EE
WSSEE
SSSSE
5 5
WNNNN
WWNNE
WW?EE
WSSEE
SSSSE
5 5
WNNNN
WWNNE
WW?EE
WSSEE
S?SSE
5 5
WNNNN
WWNNE
WW?EE
WSSEE
SSSSE
5 5
WNNNN
WWNNE
WW?EE
WSS?E
SSSSE
5 5
WNNNN
WWNNE
WW?EE
WS...

output:

4
4
4
4
4
4
4
8
4
4
4
4
4
4
4
4
4
4
8
4
4
4
4
4
4
4
4
4
4
4
4
8
4
4
8
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
8
4
4
4
8
4
4
4
4
4
4
4
8
8
8
4
4
8
4
4
8
4
4
4
4
4
4
4
4
4
8
4
4
4
4
4
4
4
4
4
4
4
4
4
8
4
4

result:

ok 100 numbers

Test #14:

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

input:

100
6 6
WNNNNN
WWNNNE
WWWNEE
WWSEEE
WSSSEE
?SSSS?
6 6
WNN??N
?WNNNE
WWWNEE
WWSE?E
WSS?EE
SSSSSE
6 6
WN?NNN
W??NNE
W?WNEE
WWSEEE
WS?SE?
SSSSSE
6 6
W?NNNN
WWNNNE
WWWNEE
W?SEE?
WSSSEE
S?SSSE
6 6
WNNNN?
WWNNNE
WWWN?E
??SEE?
WSSSEE
SSS?SE
6 6
WNN?NN
?WNNNE
WWWN??
WWSEE?
WSSSEE
S?SSSE
6 6
WNNN?N
W?NNNE
WW...

output:

4
2
3
4
8
2
2
1
2
3
10
24
2
12
6
4
2
3
1
1
4
4
16
6
4
8
4
10
2
2
16
6
6
6
1
24
4
1
4
2
3
12
12
4
14
2
18
1
3
32
6
6
4
8
3
1
5
2
24
18
12
96
4
4
8
3
16
4
1
24
6
1
6
2
2
2
12
4
2
12
6
6
8
3
6
3
1
12
4
1
4
2
12
2
2
2
2
16
4
3

result:

ok 100 numbers

Test #15:

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

input:

100
6 6
WNNNNN
WWNNNE
?WWNEE
WWSEEE
WSSSEE
SSSSSE
6 6
WNNNNN
WWNNNE
WWWNEE
WWSEEE
WSSSEE
SSSSSE
6 6
WNNNNN
WWNNNE
WWWN?E
WWSEEE
WSSSEE
SSSSSE
6 6
WNNNNN
WWNNNE
WWWNE?
W?SEEE
WSSSEE
SSSSSE
6 6
WNNNNN
WWNNNE
WWWNE?
WWSEEE
WSSSEE
SSSSSE
6 6
WNNNNN
WWNNNE
WWWNEE
WWSEEE
WSSSEE
SSSSSE
6 6
WNNNNN
WWNNNE
WW...

output:

1
1
2
2
1
1
1
1
1
1
1
1
3
1
1
2
1
2
1
1
3
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
2
1
1
1
1
1
1
1
2
1
1
4
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
1
9
1
2
1
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok 100 numbers

Test #16:

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

input:

100
5 5
WNNNN
W???E
W???E
W???E
S?SSE
5 5
WNNNN
W???E
?????
W???E
SSS?E
5 5
WNNNN
W???E
W???E
W???E
SSSSE
5 5
WNN?N
W???E
W???E
W????
SSSSE
5 5
WNNNN
W???E
????E
W????
?SSSE
5 5
?NNNN
W???E
W???E
W???E
S?SSE
5 5
WNNNN
W???E
W????
W????
SSSS?
5 5
WN?NN
W???E
W???E
W???E
SSSS?
5 5
WNNNN
W???E
W???E
??...

output:

1167
2118
1112
1222
2554
2334
3554
2424
1778
7792
1212
1112
1112
1112
2945
2053
1866
2497
1212
1167
4448
1112
1212
1167
1778
4707
1277
1833
1112
4877
4848
1212
19966
2945
1112
1778
4406
1112
7624
1866
1112
1212
2334
1778
2108
2032
2334
1112
1112
1212
2118
1212
1112
2224
3089
1267
2224
1167
2224
2032...

result:

ok 100 numbers

Test #17:

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

input:

100
5 5
W?N?N
?????
?????
?????
?S???
5 5
?????
?????
W???E
W????
?S?S?
5 5
W??NN
W???E
????E
????E
S??SE
5 5
?N?N?
????E
????E
W???E
SSSSE
5 5
WNN?N
?????
W???E
W????
??S??
5 5
WN?NN
?????
W????
????E
S?S?E
5 5
W?N?N
W???E
?????
W???E
SSSS?
5 5
W?NNN
?????
?????
?????
?SSSE
5 5
WNNN?
?????
W???E
??...

output:

68780
107846
5301
7748
17619
7081
4406
14315
10801
5549
29902
34107
19172
41704
12899
19976
14673
13405
20720
1277
81812
13570
17058
79196
12767
72898
19369
33472
13932
5301
154115
63250
9418
2323
3104
5008
35639
5839
6449
23079
24279
12657
41780
34694
10174
21275
21787
149113
5384
12464
134998
8226...

result:

ok 100 numbers

Test #18:

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

input:

100
5 5
?????
????E
?????
????E
?????
5 5
?????
?????
?????
?????
S????
5 5
?????
?????
?????
????E
?S???
5 5
??N??
?????
?????
????E
???S?
5 5
??N??
?????
?????
????E
S?S?E
5 5
W????
?????
?????
?????
?????
5 5
?????
?????
?????
?????
???S?
5 5
????N
????E
W????
?????
?????
5 5
?????
?????
?????
??...

output:

304812
295045
267282
176600
64775
295045
408362
97899
607712
305610
348526
206116
607712
295045
92970
607712
85899
137254
436030
607712
271680
436030
206116
100958
607712
295045
185016
607712
216858
176600
295045
607712
408362
133026
280284
607712
110693
408362
267282
408362
205549
607712
216858
800...

result:

ok 100 numbers

Test #19:

score: 0
Accepted
time: 555ms
memory: 71952kb

input:

12
765 583
NNNNNNNNNN?N?NNNNN?NNNNN?NNNN?NN??NNNN?NNNNNNNNNN?NNNNNNNNNNNNNN?N?N?N?NN?NNNNNNNNNNNNNN?NNNN?NNNN?NNNNNNNN?NNNNN?NNNNNNNEEEEEEE?E?EEEEEE?EEEEEEE?EEEEEEEEEEEEEE?E?EEEEEEEE?E??EEEEEEEEEE?EEEEEEEEEEEEEE?EEE??EEEEE?EEE??EEEEEEEEEEEEEEEEEEEEEEEEEEE?EEE?EEEEEEEEEEEEEEEEEEEEEEE?EEEEEEEE?EEEEEEE...

output:

495851866
809507864
679420791
96
404843191
24576
206848
880640
238
876
32
1

result:

ok 12 numbers

Test #20:

score: 0
Accepted
time: 506ms
memory: 46976kb

input:

22
315 1
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
W
?
W
?
?
?
?
?
?
?
?
W
?
?
?
?
?
?
?
?
?
?
W
?
?
?
?
?
E
?
?
?
?
?
?
W
?
?
?
?
E
?
?
?
E
?
?
W
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?
W
?
W
?
?
?
?
?
?
?
?
?
W
?
?
?
W
?
?
?
?
?
E
?
?
?
?
?
?
?
?
?
?
E
?
?
?
?
?
?
E
?
E
?
?
?
?
W
?
?...

output:

477528076
932253017
546414821
436231729
767212961
753425299
746144816
69571238
94774841
712039816
100770782
536292699
933083168
749292585
233240851
531252741
404400992
730535288
377486731
14112
441
11

result:

ok 22 numbers

Test #21:

score: 0
Accepted
time: 512ms
memory: 59924kb

input:

19
880 207
?NN??N?N??N?NN?N?NNN??N??N??N?N?NN??N?NNN?N?NN?N?NN?N?N?N????N?NN???N?N?N?????N?N?N?N?NN????NN??????N?N??NNNN???NN?N??NN???N?NNNN???NNNN??N???N?NNNN???N?NNN??N???????N??NN??N??NN??NNN?N??N?N??NNNNNN?N?NN?NN?
NNN???NN?N?N???NN??NNN?N??N????NNNN???N??NN?????N??NNNNNNNNN?NNNNN?N???NNN??NN??N...

output:

990920646
235051208
878168566
363195075
575282830
858642597
99475123
381319260
252544862
337440096
772543116
128902076
47387889
444596147
11946
24
3
1
4

result:

ok 19 numbers

Test #22:

score: 0
Accepted
time: 489ms
memory: 40068kb

input:

24
860 251
NNNNNNN???NNNNN?N?NN?NN?N??NN???N??NNN????NNNNN??N??NNNN?NN?NNN??NNN?????N?NNN?N?NN?NNN??NNNNNNN?N?N?N?NEEEE?EE?EEE?E?E??E??EEE??E?E?EEE?E??EE?EEEEE??E?E?E??EEE????E?E?E??E??EEEEEEEE??E?E?E?E?EE??EEE??E??EE??E??E???EE?E?E??E?EEE?E?EEEEEE??EEEEE?E?E??E
?N?????NN???N?????NN?????N?N??N?N???N...

output:

341478607
178477640
238866597
760490789
257385777
966030498
382950
17975058
941514615
518956768
441211809
720564832
119182965
630491877
568600592
337282588
150218111
742601423
1174797
130397105
841359738
4
3
4

result:

ok 24 numbers

Test #23:

score: 0
Accepted
time: 488ms
memory: 44260kb

input:

18
147 952
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW...

output:

10
84
12
6
6
3
6
6
30
20
12
1
1
3
1
1
1
1

result:

ok 18 numbers

Test #24:

score: 0
Accepted
time: 563ms
memory: 68016kb

input:

15
436 889
????WW??WW??W?W??????????????W??W????W??W?????W??W?????W???W???????W?????WW?W?WWW????????W???W???????W??W???W??W??????W??WW???W????W???W??W?????W???W?W???W??W??WW????WW???W?W?????????WW??W??W??W?????W???????????????????WW???????W?????W??W????W???????W?????W?W????W??????W??W????????????W??...

output:

678653349
813503368
855534745
141741923
240556704
621219704
835678972
378931916
695727293
29409441
690997659
566505909
512
945
22

result:

ok 15 numbers

Test #25:

score: 0
Accepted
time: 507ms
memory: 39168kb

input:

20
227 589
??????????????N????????????????????????????N?????????N????N??N????????????????????????N???????????????N?N??????????????????????N????????????????????????????????????N??????????????????????????????????????????????????????????????????????????????????????????N???N?????????????????N??????????N...

output:

23724695
903940930
972972674
56000607
295146118
789975841
85356456
738999969
594065648
320536346
824044585
868075890
53458887
922844342
997807315
39224260
939578467
99855333
507873
120

result:

ok 20 numbers

Test #26:

score: 0
Accepted
time: 498ms
memory: 52044kb

input:

24
63 10
NNN??NNNNN
NNNN?NNNNN
NNNN?N?NNN
NNNN?NNNNN
NNNN?NNNNN
NNNN?NNNNN
NN?N?NNNNN
NNNN?NN?NN
NNNN?NNNNN
NNNN?NNNNN
NNNN?NNNNN
NN?N?NNNNN
NNNN?NNNNN
NNNN?NNNNN
WNNN?NNNNN
WNNN?NNNNN
WNNN?NNEEE
WWNN?NN?EE
WWWN?EEEEE
???NEEEEEE
WWWWS?????
????SEEEEE
????SSSSEE
????SSS?EE
????SSS?EE
????SSSSSS
????S...

output:

326370
312
48
511690219
3456
360710125
310378483
1474560
562036693
576
4
144
10616832
3686400
11520
192
4
2048
6144
1
144
1
1
1

result:

ok 24 numbers

Test #27:

score: 0
Accepted
time: 538ms
memory: 66304kb

input:

15
760 907
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN?NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

output:

1179648
3
26880
48
1168
384
700
4
4
4554
31000
171
1
2
1

result:

ok 15 numbers

Test #28:

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

input:

100
5 5
?????
????E
???E?
????E
?????
5 5
?????
?????
?????
?????
S????
5 5
?????
?????
?????
??S?E
?S???
5 5
??N??
?????
???E?
????E
???S?
5 5
??N??
?W???
???E?
?S??E
S?S?E
5 5
W????
?????
?????
?????
?????
5 5
?????
?????
?????
?????
???S?
5 5
????N
????E
W????
?????
?????
5 5
?????
???N?
???E?
??...

output:

183652
295045
131874
85068
5940
295045
408362
97899
62196
46395
348526
28359
264396
116672
48975
607712
85899
137254
147159
159947
101076
175350
9288
100958
607712
295045
16384
73199
216858
48972
295045
73199
408362
133026
280284
264396
110693
56949
39262
408362
205549
108046
216858
80044
88164
1471...

result:

ok 100 numbers

Test #29:

score: 0
Accepted
time: 10ms
memory: 3712kb

input:

100
20 20
????????????????N???
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????W???????????
????????????????????
????????????????????
????????????????????
?????????????????...

output:

586796468
221211796
867397739
362607979
883021206
233724419
343425119
807220470
691873075
560628093
688228894
336900540
353947584
709868107
916478088
850736219
964417914
633008700
217817356
391493420
814621992
293860528
267902871
717565266
834296852
221211796
498799202
60757172
946016985
755859677
4...

result:

ok 100 numbers

Test #30:

score: 0
Accepted
time: 192ms
memory: 4736kb

input:

100
100 100
????????N???????????N????????????????????????????????????????????N??????NNN??????????N?????N?N??????
W?N?????N?N????????????????N??????????????N???????????????????????N????????????????????NN?????????N?
????????N?????N???????????N????????N??????????????????N??NN???????????N?????N?????????...

output:

758848487
861154028
602970439
512446399
25663106
724414534
700731192
546538125
116542851
117480947
938035713
885313028
441819094
408274153
151433929
226379666
16039612
774453614
449416623
492626771
863800251
660202519
299435234
458909323
190525323
485308641
960961388
880110687
66149174
706826258
735...

result:

ok 100 numbers

Test #31:

score: 0
Accepted
time: 493ms
memory: 7424kb

input:

50
200 200
????????????????????????????????????????????????????????????????????????????N???????????????N???????????????????????????????????????????????N?????????????????????N??????????????????N??????????????????
??????????????????????N????????????????????????????????N????????????????????????????????...

output:

247704959
744325470
198507833
715432657
840365608
873993617
331697995
761138370
146516677
940965919
233927536
700743722
455157827
578805483
12012052
585224966
989820960
564474059
69742457
530873230
23842490
897292407
883766446
973730723
509472518
898956780
732133520
274060035
447634090
906966470
368...

result:

ok 50 numbers

Test #32:

score: 0
Accepted
time: 824ms
memory: 94488kb

input:

2
1000 1000
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

487094092
45772777

result:

ok 2 number(s): "487094092 45772777"

Test #33:

score: 0
Accepted
time: 845ms
memory: 94644kb

input:

2
1000 1000
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

787327214
590378330

result:

ok 2 number(s): "787327214 590378330"

Test #34:

score: 0
Accepted
time: 826ms
memory: 94604kb

input:

2
1000 1000
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

646561987
401945201

result:

ok 2 number(s): "646561987 401945201"

Test #35:

score: 0
Accepted
time: 597ms
memory: 94620kb

input:

2
1000 1000
WNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN?NNNNNNNN??NNN?NNNNNNNNNNNNNNNNNNN?N?NNN?NNNN??NNNNNNNNNNNNNN?NNNNNNNNNNNNNNNNNNNNN?N?NNNNNNNNNNNNNNNNNN?N?NNNNNN?NNNN??NNNN?NNNNNNNNNNNNNNNN?NNNNNNN?NNNNNNNNNNNNNNNN?NNNNNN?NNNNNNNNNNNNNN?NN??NNNNN?NN?NNNNNNN?NNNNNNNNNNNNNNNNNNNNNNNNNNN?NNNNNNNNNNN?...

output:

342746715
556741699

result:

ok 2 number(s): "342746715 556741699"

Test #36:

score: 0
Accepted
time: 598ms
memory: 94616kb

input:

2
1000 1000
?NNNNN?NNNN??NNN?NNNN?NNN?NN??NNNNNNNNN?NN?N?NNN???NNNN?N??N?N??N?N?N???NNNNN?NNN?N?NNNNN?NN??NNNN?N??NN?N?NNN?NNN?N?NNNNN?NNNNNNN?N??NNN??NNN??NNNNNN????NNNNNNN?NN?NN?NNNNN?NNN??NNN???NNNNNNN?NN??NNNN?NNN??NNNNNNN?N?N?NNNN???NN????NNN?NNNNNNN?NNN?NN?NN?N????NNN?NNN?NNN?NN??N?N?NNNN??NN?...

output:

523452305
740042462

result:

ok 2 number(s): "523452305 740042462"

Test #37:

score: 0
Accepted
time: 610ms
memory: 94640kb

input:

2
1000 1000
??N??????N??N?NNNN??N?N?NNN?N?NNNNN?N?N?N?NNNNN?N?N?NN?NNN??N?N??NNN?NN?N???NN?NNN??NNN????N?N?N???N?????????NN?N?NNNNNNNN?N?NNNN?N?N?NNNNN?NN?N?NN???NN?????NN?N?NNNNN?NN???NN?N??N??NN?NNN???NNN?N??????NNNN??N??N??N?N?N???N???NNN?????NN??NNN???NN????N???NN?????NNN?NNNNN?N??NN????????N???...

output:

533627345
125506500

result:

ok 2 number(s): "533627345 125506500"

Test #38:

score: 0
Accepted
time: 602ms
memory: 94648kb

input:

2
1000 1000
?N????NN?N?NN?N???N?NN?N???????NNN??N?????N????NN?NN??NN?N?N?N???N????????????????N?N?N?N??N?N?N?N?N???N???????N?N?????N?N??N???NNN????N??N?????NNN????N?N????N??N?N?N??????????N??????N???NNN???N??N????N???N??????NN?NN???N?N???N???N?N??????N????N???N??NNN??????NN???????N?????NN???N?N?N???...

output:

447793898
753797144

result:

ok 2 number(s): "447793898 753797144"

Test #39:

score: 0
Accepted
time: 598ms
memory: 94528kb

input:

2
1000 1000
??????????????N?N???N???????????N??????N?N??????N?????????N????N??????????????????????N?????????N??????????N??????????N????????????????N??????????N?????N???????????????N????????????????N??????NN?N??????????????N????????N?????N????N???N????????NN??N??????????N????????????????N????????????...

output:

596830528
965666023

result:

ok 2 number(s): "596830528 965666023"

Test #40:

score: 0
Accepted
time: 838ms
memory: 94648kb

input:

2
1000 1000
??N??????N??N?NNNN??N?N?NNN?N?NNNNN?N?N?N?NNNNN?N?N?NN?NNN??N?N??NNN?NN?N???NN?NNN??NNN????N?N?N???N?????????NN?N?NNNNNNNN?N?NNNN?N?N?NNNNN?NN?N?NN???NN?????NN?N?NNNNN?NN???NN?N??N??NN?NNN???NNN?N??????NNNN??N??N??N?N?N???N???NNN?????NN??NNN???NN????N???NN?????NNN?NNNNN?N??NN????????N???...

output:

66731539
589061946

result:

ok 2 number(s): "66731539 589061946"

Test #41:

score: 0
Accepted
time: 829ms
memory: 94520kb

input:

2
1000 1000
WNNN?N?NNN?N??NN?NNNNNNN?NNNN?N?NNN?N??NNNNN?NN?NNN?NNNNNNN?NNNNNNNNNNNNNNNNN??NNN?NNNNNN?NNNNN?NNNNN?NNNNNNNNNN?????NN?NNNNNN?N?N?NNNN?NN?NNNNNNNNNNNNN?NNNNN?NNNNNN?NNN??NNNNNNNNNNNN?N?N?NNN?NNNNNNNNN?NNN?NNNN?NNNNN??NN?NNNNNNNN?N?NN?NN?NNNNNNN?NNNN?NNNNNNNNNN?NNNNNN?N?NNN??N?NNNNN?NNN?...

output:

373994106
296424563

result:

ok 2 number(s): "373994106 296424563"

Test #42:

score: 0
Accepted
time: 241ms
memory: 4736kb

input:

100
100 100
?N??N?N??N?N?N?NNN?NNNN???N??N?NNNNNN?N????NNNNN??N?N?NNNNNNNNNNN??N???NNNNNNNN?NNN?N?N?NN?NNNNN??NN
W??????????????????????????????????????????????????????????????????????????????????????????????????E
W?????????????????????????????????????????????????????????????????????????????????????...

output:

9706505
673554850
623768610
289877236
932377933
749826613
406293776
42688934
765689434
15335650
13173923
573784723
921168167
689696031
473654783
867414706
859481437
481363922
384616862
139300016
88010123
921107882
584430736
126963700
457784522
519615655
352354062
173210452
176161408
304200671
855058...

result:

ok 100 numbers

Test #43:

score: 0
Accepted
time: 844ms
memory: 94656kb

input:

2
1000 1000
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

837254874
837254874

result:

ok 2 number(s): "837254874 837254874"

Test #44:

score: 0
Accepted
time: 614ms
memory: 22144kb

input:

10
1000 200
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????...

output:

164910063
164910063
164910063
164910063
164910063
164910063
164910063
164910063
164910063
164910063

result:

ok 10 numbers

Test #45:

score: 0
Accepted
time: 577ms
memory: 21536kb

input:

10
200 1000
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

164910063
164910063
164910063
164910063
164910063
164910063
164910063
164910063
164910063
164910063

result:

ok 10 numbers

Test #46:

score: 0
Accepted
time: 531ms
memory: 5888kb

input:

100
1000 20
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
???????????????...

output:

667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
...

result:

ok 100 numbers

Test #47:

score: 0
Accepted
time: 504ms
memory: 5256kb

input:

100
20 1000
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
667149095
...

result:

ok 100 numbers

Test #48:

score: 0
Accepted
time: 47ms
memory: 3968kb

input:

100
40 50
??????????????????????????????????????????????????
??????????????????????????????????????????????????
??????????????????????????????????????????????????
??????????????????????????????????????????????????
??????????????????????????????????????????????????
???????????????????????????????????...

output:

104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
104583095
...

result:

ok 100 numbers

Test #49:

score: 0
Accepted
time: 484ms
memory: 46084kb

input:

17
872 444
?NN???????N???????????N???N?N????NN??????N???N??????????????N?????N?????N????????N????N??N???????????N????????NN?N??N??N?NN???????????????????????????????????N????NN?N?????N???N?N?N??N???N????N???N?N??NNN?N?????????N???N???N????????N?????N??N?N??NN??N???N?N?NNN??????N????N?N?????N?N????N?...

output:

612985010
9922570
308244590
152205738
156241649
355578832
321005122
862214536
937834332
877681003
894317758
514853316
116904787
27914001
465
6223
26

result:

ok 17 numbers

Test #50:

score: 0
Accepted
time: 618ms
memory: 43904kb

input:

21
510 231
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????...

output:

44757456
39855453
957800154
965341139
329484279
755097242
357088391
772309439
649763774
879926753
788427222
601824463
161269581
439174417
424735383
193609703
370704440
970565690
212
4083
11

result:

ok 21 numbers

Test #51:

score: 0
Accepted
time: 537ms
memory: 59600kb

input:

15
908 147
????????????????????N??????????????????????????????????????????????????N???????????????????????N?????????????????????????????????????????N?????????
????N??????????N?????N???????????????????????N?????????????????????????????????????N???????????????????N?????????????????????N???????????????...

output:

59586994
435418713
861859757
908924666
579347935
322852143
2789439
666175590
959700155
486598427
868680681
383949218
120588
11
4

result:

ok 15 numbers

Test #52:

score: 0
Accepted
time: 518ms
memory: 78628kb

input:

17
126 5
NNNN?
NNNN?
NN?N?
NNNN?
NNNN?
NNNN?
NNNN?
NNNN?
NNNN?
NNNN?
N?NN?
NN?N?
NNNN?
NNNN?
NNNN?
NNNN?
NNNN?
NNNN?
NNNN?
NNNN?
NNNN?
NNNN?
NNNN?
NNNN?
NNNN?
NNNN?
?NNN?
NNNN?
NNNN?
NNNN?
NNNN?
NNN??
WNNN?
WNNN?
WNNN?
WW?N?
WWWN?
???NE
WWWW?
WWW?S
WSS?S
WSS?S
SSS?S
?SS?S
SSS?S
?SS?S
SSS?S
SSS?S
SSS...

output:

456
335544088
636758841
2359296
811553767
720
3840
576728798
554
3041280
96
28028
5700
2097152
256
32
1

result:

ok 17 numbers

Test #53:

score: 0
Accepted
time: 510ms
memory: 66176kb

input:

14
760 907
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN?NNNNNNNNNN?NNNNNNNNNNNNNNNNNNNNNNNN?NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN?NNNNNNNNNNNNNNNNNNNNNNNNNNNNN?NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

output:

4608
1949476
8
144
32768
6144
375
7800
1
10287093
8
4
1
1

result:

ok 14 numbers

Test #54:

score: 0
Accepted
time: 408ms
memory: 5888kb

input:

100
1000 20
??N???N???NN?N????N?
??????N????N?N??????
N???N???????????N???
?????NN??????N???N??
???????N????????????
?N????N??????N??NN??
???N??N?N?????N??N??
?NNN?NNN?????N???N??
????N??N???N?N??N???
N????N?????????NN???
?N??????N???N???????
??N??N???????N?N????
??NNN?N????NN??N????
N????????????N?...

output:

486621398
281955089
924975166
555017315
207196623
661495251
436021895
557361861
583405314
748209038
172932669
44507485
291841094
1192487
243791972
946688054
699355074
931190526
454876089
13636448
423544000
803973354
670977599
459571396
104449989
190145452
730817660
626995715
272193253
334138073
4700...

result:

ok 100 numbers

Test #55:

score: 0
Accepted
time: 486ms
memory: 5888kb

input:

100
1000 20
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
??????????????N?????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
????????????????????
???????????????...

output:

753873082
299516552
583404479
731049094
814007786
848395571
828559286
834804789
914501594
627259271
950602881
881315876
248476832
76193742
336642516
579748974
106628487
21980683
652646755
270827716
235794004
649525291
391670665
566168720
859579165
208362069
497420992
417628364
74972138
167924606
891...

result:

ok 100 numbers

Test #56:

score: 0
Accepted
time: 415ms
memory: 5760kb

input:

100
1000 20
????????N???????????
??????????????N?????
?N??N????????N??????
????????????????????
????????????????????
??????????????N?????
????????????????????
???????????????N????
??????????N???N????N
????????????????N???
????????????????????
????????????????????
????????????????????
???????????????...

output:

320967789
520753865
667288929
550925285
415571828
663833777
41583962
518185832
959438731
796280511
822593543
342977374
915965913
531301778
99253152
682595722
647667115
790244354
431507104
154763574
951059504
648848459
563035911
795323200
271958843
422774605
249671801
653715221
381826316
527187811
17...

result:

ok 100 numbers

Test #57:

score: 0
Accepted
time: 375ms
memory: 5888kb

input:

100
1000 20
NNNNNNNN?NNNNN????NN
NNNNNNNNNNNNNN???N?N
NNNNNNNN??NNNN???NNN
NNNNNNNNNNNNNN???NNN
NNNNNNNNN?NNNN???NNN
NNNNNNNNNNNNNN???NNN
NNNNNNNN?NNNNN???NNN
NNNNNNNNNNNNNN???NNN
NNNNNNNNNNNNNN???NNN
NNNNNNNNNNNNNN???NNN
NNNNNNN?NNNNNN???NNN
NNNNNNNNNNNNNN???NNN
NNNNNNNNNNNNNN???NNN
NNNNNNNNNNN?NN?...

output:

1120
4
16
24
514786857
12
192
2913
48
2
72
2
18
252
1
240
96
32
3568
420
24
288
96
221558400
24
420
54
560
4
8560
12
2352
12
64
540
3
18
60
9760
10584
36
325470
192
4
720
1603980
140
8
210
8
400
2
252
32
96
305280
6
3
8
28368
2816
24
6
16
4
112004248
18
847310766
32
4
883
2
6
8
24
4928
12
10644
48
2...

result:

ok 100 numbers

Test #58:

score: 0
Accepted
time: 372ms
memory: 5888kb

input:

100
1000 20
NNNNNN?NNNNNNNNNNNNN
NNNNNN?NNNNNNNNNNNNN
NNNNNN?NNNNNNNNNNNNN
NN?NNN?NNNNNNNNNNNNN
NNNNNN?NNNNNNNNNNNNN
NNNNNN?NNNNNNNNNNNNN
NNNNNN?NNNNNNNNNNNNN
NNNNNN?NNNNNNNNNNNNN
NNNNNN?NNNNNNNNNNNNN
NNNNNN??NNNNNNNNNNNN
NNNNNN?NNNNNNNNNNNNN
NNNNNN?NNNNNNNNNNNNN
NNNNNN?NNNNNNNNNNNNN
NNNN?N?NNNNNNNN...

output:

9
925
105
30
24
2
2
6
1428
6
1320
32
42
10
899
6
6
54
2
334662
16
4
2
6
3
1
1392498
12
5
2
6
8
1
3
6
504
2
20
36
2
2
3204
1
2
168
954
18
4
10
210
138415
32
9
2
4
16
3
15
10
6
6
654
4
1
18
731
18
6
1
1914
278061142
2
24
12
180
2
8
6
1
1
10
2
72
24
16
53900
18
2
15
4
8
9
28
118288566
29205
1653
48
1
1...

result:

ok 100 numbers

Extra Test:

score: 0
Extra Test Passed