QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#790242#9647. 数位 DPwsyear100 ✓764ms62436kbC++203.2kb2024-11-28 08:57:442024-11-28 08:57:47

Judging History

你现在查看的是最新测评结果

  • [2024-11-28 08:57:47]
  • 评测
  • 测评结果:100
  • 用时:764ms
  • 内存:62436kb
  • [2024-11-28 08:57:44]
  • 提交

answer

#include <bits/stdc++.h>

#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using u32 = unsigned int;
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

template<class T>inline void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T>inline void chkmx(T &x, T y) { if (y > x) x = y; }

using namespace std;

const int maxn = 1010;
const int maxm = 80010;

int n, m, k, q, b[maxn], p[maxn], pmn[maxn], len[maxm][32], fp[maxm], ps[maxm];
int sta[maxm][32], mi[maxm], tot, a[32], to0[maxm], precnt, to1[maxm][32], W[maxm][32];
u32 coe0[maxm], f[maxm], g[maxm], self[maxm];
map<vector<int>, int> mp;
string s;

void dfs(int dep, int sum) {
  if (dep == k + 1) {
    a[k]++;
    a[0] = 0;
    mi[++tot] = sum;
    rep (i, 0, k) sta[tot][i] = a[i];
    vector<int> p(k + 1);
    rep (i, 0, k) p[i] = a[i];
    mp[p] = tot;
    a[0] = 1;
    mi[++tot] = sum;
    rep (i, 0, k) sta[tot][i] = a[i];
    rep (i, 0, k) p[i] = a[i];
    mp[p] = tot;
    a[k]--;
    return;
  }
  rep (x, 0, (31 - sum) / dep) a[dep] = x, dfs(dep + 1, sum + x * dep);
}

u32 solve() {
  u32 ans = 0;
  rep (_, 1, tot) {
    int ok = 1;
    u32 val = f[_];
    rep (i, 0, k - 1) {
      if (!val) break;
      if (m >> i & 1) {
        if (sta[_][i] == 0) {
          val *= (precnt - len[_][i] + 1);
        }
      } else {
        if (sta[_][i] > 0) ok = 0;
      }
    }
    if (ok) ans += val;
  }
  return ans;
}

int main() {
  cin.tie(nullptr) -> ios::sync_with_stdio(false);
  cin >> n >> k >> q >> s, b[1] = 1;
  rep (i, 2, n) b[i] = (s[i - 2] == 'A' ? 1 : 0);
  dfs(1, 0);
  rep (_, 1, tot) {
    vector<int> p(k + 1);
    rep (i, 0, k) p[i] = sta[_][i];
    int pos = 0;
    while (pos < k && !p[pos]) pos++;
    if (pos) p[pos]++;
    to0[_] = mp[p], coe0[_] = 1u << pos;
  }
  int s = 0;
  rep (_, 1, tot) {
    vector<int> p(k + 1);
    rep (i, 0, k) p[i] = sta[_][i];
    per (i, k, 0) len[_][i] += len[_][i + 1] + max(0, p[i] - 1);
    while (fp[_] <= k && !p[fp[_]]) fp[_]++;
    rep (w, -1, k - 1) if (mi[_] + (w == -1 ? k : w) < 32) {
      s++;
      if (w == -1) {
        self[_] += (1u << k);
      } else {
        if (p[w] > 0) {
          self[_] -= (1u << w);
        } else {
          p[w] = 1;
          W[_][ps[_]] = w, to1[_][ps[_]++] = mp[p];
          p[w] = 0;
        }
      }
    }
  }
  vector<int> p(k + 1, 0);
  p[k] = 1, f[mp[p]] = 1;
  rep (i, 1, n) {
    rep (j, 1, tot) g[j] = f[j], f[j] = 0;
    if (b[i] == 0) {
      precnt++;
      rep (j, 1, tot) f[to0[j]] += g[j] * coe0[j];
    } else {
      int cnt = 0;
      rep (j, 1, tot) if (g[j]) {
        f[j] += g[j] * self[j];
        rep (id, 0, ps[j] - 1) {
          cnt++;
          int w = W[j][id], tar = to1[j][id];
          if (w < fp[j]) {
            f[tar] -= g[j] << w;
          } else {
            f[tar] -= (g[j] * (precnt - len[j][w] + 1)) << w;
          }
        }
      }
    }
  }
  while (q--) {
    cin >> m;
    cout << solve() << '\n';
  }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 4ms
memory: 17264kb

input:

4 5 200
AAA
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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
16
81
256
625
1296
2401
4096
6561
10000
14641
20736
28561
38416
50625
65536
83521
104976
130321
160000
194481
234256
279841
331776
390625
456976
531441
614656
707281
810000
923521
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
1048576
104857...

result:

ok 200 lines

Test #2:

score: 10
Accepted
time: 8ms
memory: 17464kb

input:

4 5 200
XXX
15
29
23
29
23
15
30
27
27
23
30
29
27
23
30
23
27
23
30
30
30
30
15
29
27
23
15
30
15
27
27
23
15
30
29
27
23
23
15
23
27
27
27
29
23
30
29
30
27
27
30
27
27
15
27
15
23
23
27
15
23
30
30
29
30
15
30
15
29
15
27
29
15
29
30
30
15
29
15
27
27
15
27
27
30
27
30
30
15
30
29
27
30
23
27
27
...

output:

1043136
962496
981696
962496
981696
1043136
961536
966336
966336
981696
961536
962496
966336
981696
961536
981696
966336
981696
961536
961536
961536
961536
1043136
962496
966336
981696
1043136
961536
1043136
966336
966336
981696
1043136
961536
962496
966336
981696
981696
1043136
981696
966336
966336...

result:

ok 200 lines

Test #3:

score: 10
Accepted
time: 6ms
memory: 17132kb

input:

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

output:

281568
632544
599340
327680
72280
890624
447576
447576
668702
305790
38328
281568
23936
668702
122880
228864
228864
814944
11440
1013855
599340
975600
777900
668702
38328
814944
88512
550400
52224
281568
228864
1048576
550400
632544
106428
599340
814944
11440
23936
88512
72280
228864
305790
939542
1...

result:

ok 200 lines

Test #4:

score: 10
Accepted
time: 8ms
memory: 17616kb

input:

4 5 200
AAA
2
1
6
16
0
20
5
25
24
27
10
5
25
14
2
3
18
11
5
27
23
21
19
7
25
20
25
15
29
20
5
11
25
1
19
6
13
18
31
30
17
14
10
12
16
18
29
27
24
2
23
24
26
14
18
29
6
9
21
0
18
27
10
12
6
0
20
6
29
25
18
18
27
6
29
10
23
19
24
15
6
22
11
9
5
25
19
9
14
0
22
30
3
13
19
13
15
10
5
21
14
21
27
3
31
25...

output:

810000
923521
456976
65536
1048576
20736
531441
2401
4096
625
234256
531441
2401
104976
810000
707281
38416
194481
531441
625
6561
14641
28561
390625
2401
20736
2401
83521
81
20736
531441
194481
2401
923521
28561
456976
130321
38416
1
16
50625
104976
234256
160000
65536
38416
81
625
4096
810000
6561...

result:

ok 200 lines

Test #5:

score: 10
Accepted
time: 13ms
memory: 17096kb

input:

4 5 200
OOX
9
13
15
3
12
7
25
14
30
31
10
10
5
29
28
2
31
16
24
9
9
16
25
7
7
22
3
17
29
10
30
19
27
20
3
24
5
11
23
17
30
14
31
19
20
11
4
15
23
2
26
26
13
25
12
15
28
22
25
13
28
13
4
19
8
14
19
17
21
21
5
6
19
23
16
28
4
16
31
22
11
28
22
5
31
30
24
11
30
25
10
28
4
23
28
0
6
10
28
10
17
22
26
5
...

output:

1044476
1043440
1043136
1048556
1043456
1048240
966640
1043200
961536
961280
1044416
1044416
1048316
962496
962560
1048560
961280
983040
966656
1044476
1044476
983040
966640
1048240
1048240
981760
1048556
983036
962496
1044416
961536
982960
966336
982016
1048556
966656
1048316
1044400
981696
983036
...

result:

ok 200 lines

Test #6:

score: 10
Accepted
time: 8ms
memory: 17024kb

input:

4 5 200
AAA
10
22
27
29
26
14
19
23
7
30
19
9
20
25
15
2
30
2
27
25
19
5
28
23
10
20
26
15
13
8
0
13
31
17
22
0
31
9
30
27
31
13
29
11
23
26
12
9
21
22
3
6
27
18
25
28
25
6
27
21
0
27
13
19
31
29
11
14
11
9
10
18
13
26
22
3
17
11
7
29
23
26
6
17
11
27
30
18
18
12
8
29
14
4
2
22
31
13
19
20
24
23
6
3...

output:

234256
10000
625
81
1296
104976
28561
6561
390625
16
28561
279841
20736
2401
83521
810000
16
810000
625
2401
28561
531441
256
6561
234256
20736
1296
83521
130321
331776
1048576
130321
1
50625
10000
1048576
1
279841
16
625
1
130321
81
194481
6561
1296
160000
279841
14641
10000
707281
456976
625
38416...

result:

ok 200 lines

Test #7:

score: 10
Accepted
time: 8ms
memory: 17088kb

input:

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

output:

14641
38416
1
279841
14641
331776
614656
194481
2401
4096
1296
38416
81
38416
83521
625
65536
625
130321
38416
14641
10000
625
194481
1
50625
160000
1296
104976
160000
614656
923521
130321
28561
625
810000
4096
456976
279841
531441
28561
10000
1
16
390625
4096
10000
194481
20736
279841
81
14641
1303...

result:

ok 200 lines

Test #8:

score: 10
Accepted
time: 8ms
memory: 18988kb

input:

4 5 200
OXX
29
17
13
0
4
0
0
15
14
21
18
9
13
27
16
27
29
30
4
31
3
23
31
9
23
20
9
29
28
1
26
7
26
21
17
27
18
25
23
14
13
14
30
6
25
24
15
28
0
6
14
10
7
13
26
22
9
5
20
15
21
23
20
22
9
27
18
6
17
3
26
31
12
20
26
6
19
17
5
13
26
31
18
30
18
30
20
31
27
18
29
29
2
31
28
6
0
7
6
22
18
28
9
13
12
2...

output:

962496
983036
1043440
1048576
1048320
1048576
1048576
1043136
1043200
982000
982976
1044476
1043440
966336
983040
966336
962496
961536
1048320
961280
1048556
981696
961280
1044476
981696
982016
1044476
962496
962560
1048575
966400
1048240
966400
982000
983036
966336
982976
966640
981696
1043200
1043...

result:

ok 200 lines

Test #9:

score: 10
Accepted
time: 3ms
memory: 19216kb

input:

4 5 200
XAA
30
14
15
21
5
17
14
25
14
20
20
9
11
10
11
1
5
4
9
17
24
29
26
5
20
12
30
3
14
31
31
5
22
23
3
2
28
12
26
23
9
18
20
26
25
3
16
26
2
23
24
1
12
9
18
25
19
20
19
3
12
11
4
20
25
5
22
14
15
22
11
7
23
5
10
24
18
0
9
10
23
19
22
15
26
30
26
20
12
19
25
6
23
24
11
19
18
31
29
28
18
18
26
5
2...

output:

2176
295488
261256
88572
733374
172350
295488
31164
295488
105984
105984
506782
418068
460768
418068
983103
733374
790272
506782
172350
40960
5112
22464
733374
105984
371200
2176
856138
295488
528
528
733374
72000
57672
856138
918000
9216
371200
22464
57672
506782
148960
105984
22464
31164
856138
19...

result:

ok 200 lines

Test #10:

score: 10
Accepted
time: 9ms
memory: 18948kb

input:

4 5 200
XXO
0
14
16
6
13
0
28
22
13
3
19
17
30
24
8
21
6
16
1
11
10
17
6
13
13
3
17
7
7
22
6
12
19
16
2
15
25
17
23
5
21
29
18
14
23
0
28
7
6
24
25
9
28
9
17
14
28
20
15
29
17
27
19
9
14
25
3
24
12
25
10
25
30
19
3
13
9
2
15
18
3
30
10
5
21
22
28
10
15
13
15
25
19
19
8
7
16
29
7
25
10
29
30
18
22
18...

output:

1048576
1043200
983040
1048256
1043440
1048576
962560
981760
1043440
1048556
982960
983036
961536
966656
1044480
982000
1048256
983040
1048575
1044400
1044416
983036
1048256
1043440
1043440
1048556
983036
1048240
1048240
981760
1048256
1043456
982960
983040
1048560
1043136
966640
983036
981696
10483...

result:

ok 200 lines

Subtask #2:

score: 10
Accepted

Test #11:

score: 10
Accepted
time: 44ms
memory: 31932kb

input:

20 8 20
AAAAAAAAAAAAAAAAAAA
255
254
253
252
251
250
249
248
247
246
245
244
243
242
241
240
239
238
237
236

output:

1
1048576
3486784401
0
1977800241
3104833536
3095271137
0
689956897
1661992960
1226119153
0
4176394193
1846542336
2980478145
0
1144323905
2182086656
2763774801
0

result:

ok 20 lines

Test #12:

score: 10
Accepted
time: 33ms
memory: 36460kb

input:

20 8 20
XXOOXXXOOOXOOXXXXXX
223
254
239
127
251
247
223
223
254
253
254
239
247
223
127
223
251
127
251
254

output:

3157225472
0
3157225472
3157225472
3157225472
3157225472
3157225472
3157225472
0
4230967296
0
3157225472
3157225472
3157225472
3157225472
3157225472
3157225472
3157225472
3157225472
0

result:

ok 20 lines

Test #13:

score: 10
Accepted
time: 40ms
memory: 33116kb

input:

20 8 20
AOAOAXAOAXAOAXAOAXA
1
139
141
253
49
89
100
235
106
169
177
199
27
63
169
104
191
54
239
54

output:

2596932351
444889112
642944536
3394047424
1995656860
1794163992
0
3083125088
3783262208
1396280088
2829574680
3125900656
2757493016
2952862816
1396280088
0
2713869248
3514826752
498553792
3514826752

result:

ok 20 lines

Test #14:

score: 10
Accepted
time: 40ms
memory: 32164kb

input:

20 8 20
AAAAAAXAAAAAAOAAAAA
182
64
25
84
227
184
255
183
201
39
43
232
217
63
4
94
85
164
120
175

output:

2580545536
0
841269017
0
4233876109
0
3196053143
4234287951
722457003
1479575031
4073032191
0
2835298401
89573919
0
1297088512
3057585635
0
0
2640696959

result:

ok 20 lines

Test #15:

score: 10
Accepted
time: 42ms
memory: 36816kb

input:

20 8 20
XXOOOXAOOXXOOAOXOXX
13
144
231
225
195
11
210
171
187
111
220
55
239
205
221
33
233
7
247
183

output:

1914607548
0
2820613408
4190143288
1349955368
4104752340
3682598912
763900496
850003872
344774176
0
3575735056
907161152
379632112
998910688
4293952878
1178842864
3866438084
3842625600
1048790816

result:

ok 20 lines

Test #16:

score: 10
Accepted
time: 34ms
memory: 32780kb

input:

20 8 20
AOXAXAAOAAXAAOAXOXX
40
187
158
14
49
213
39
29
254
181
46
220
231
142
40
90
206
88
36
191

output:

0
3193371575
835715072
4182769664
3263242009
3866789033
3429976231
1248772075
491782144
2441390825
946864128
0
2632295535
1047527424
0
3635412992
449839104
0
0
2726809173

result:

ok 20 lines

Test #17:

score: 10
Accepted
time: 41ms
memory: 36392kb

input:

20 8 20
AAAAAAAAAAAAAAAAOAX
141
207
65
228
151
65
57
252
94
252
199
62
47
228
194
151
255
55
238
61

output:

680445295
2794147121
2672008899
0
1498887811
2672008899
1254672067
0
565182464
0
715997235
3635412992
1301139995
0
110100480
1498887811
876053577
19247395
579862528
586255357

result:

ok 20 lines

Test #18:

score: 10
Accepted
time: 29ms
memory: 36536kb

input:

20 8 20
OXOAXXXAXOOAAOOAOOX
202
90
82
55
206
140
9
217
117
142
157
157
110
206
36
44
83
49
19
235

output:

1857028096
3828350976
1183842304
201104635
1857028096
0
1421874471
2356948025
3339221653
1884291072
142114461
142114461
397410304
1857028096
0
0
4020004345
3097298385
4204969527
550445409

result:

ok 20 lines

Test #19:

score: 10
Accepted
time: 44ms
memory: 32308kb

input:

20 8 20
AAAAAAAAAAAAAAAAAAA
117
85
62
163
251
104
153
178
187
114
155
237
75
61
231
30
69
9
222
106

output:

1504122353
46640497
4161798144
3797657873
1977800241
0
3554417505
2249195520
1941563185
2651848704
3039303601
2763774801
2490579697
4287090833
2881090913
1812987904
1915233073
611513377
4094689280
1863319552

result:

ok 20 lines

Test #20:

score: 10
Accepted
time: 32ms
memory: 31936kb

input:

20 8 20
XOXXXXXXOOOXAXOXXXX
41
169
154
217
104
167
76
158
178
90
201
227
187
90
26
239
5
34
183
210

output:

4294885121
4294006675
1752170496
4280995513
0
3331336011
0
1244659712
674234368
3195011072
4294156851
2856438223
1008201685
3195011072
2278555648
3165363643
67104071
1982857216
3855648865
2100297728

result:

ok 20 lines

Subtask #3:

score: 10
Accepted

Test #21:

score: 10
Accepted
time: 102ms
memory: 55504kb

input:

200 16 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
65535

output:

1

result:

ok single line: '1'

Test #22:

score: 10
Accepted
time: 101ms
memory: 55924kb

input:

200 16 1
OXOXXXOXXOXOXXOOOXXXXOOXXOOOXOOXOOXXOOOOXXOXOOXOXXXOXXXXXXXOXOXOOXOXXOOOXOOXXOOOXXXXOXXXOOXXOXOXOXXOOOOOOOOOOXXOXXXOXXOOOXOOXXXOOXXOXXOOOXOOOXOOOXOXXXXXOXOOOXXXXOXXXOOOOOOOXOOXOXXXXXOXOXOXOOXXXOXXOXX
63487

output:

0

result:

ok single line: '0'

Test #23:

score: 10
Accepted
time: 125ms
memory: 55976kb

input:

200 16 1
AXAXAXAOAOAXAXAOAOAXAXAOAOAOAXAOAOAOAXAOAOAOAOAXAXAOAOAXAOAOAOAXAOAXAXAOAOAOAXAOAXAOAXAOAOAOAOAXAXAXAXAXAXAOAXAOAOAOAOAXAXAOAXAXAOAXAXAOAXAOAOAXAOAOAXAXAOAXAOAXAOAOAOAOAOAOAOAOAXAXAOAOAOAOAOAOAXAOAOA
4359

output:

2017260928

result:

ok single line: '2017260928'

Test #24:

score: 10
Accepted
time: 105ms
memory: 55052kb

input:

200 16 1
AAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAA
8276

output:

0

result:

ok single line: '0'

Test #25:

score: 10
Accepted
time: 104ms
memory: 55992kb

input:

200 16 1
OOOOXOAOXXXOOAXXOOXOAXOXOXXAOOXXOXAXXXOOOAXOXOXOAOXXXOOAXXOOXXAOXOXOXAOXXOXXAOOOXOOAXOOXOOAOOOXXXAOXOOXOAOOOOOXAXOOOXOAXOXOOOAOXXOXXAOOOXOXAOOOOOOAOXXXOOAOOOOXXAOXOOXOAXXOXXXAXXXXOOAOOXXXXAOOXOOXAOOX
62733

output:

118423552

result:

ok single line: '118423552'

Test #26:

score: 10
Accepted
time: 126ms
memory: 55280kb

input:

200 16 1
XAXXAAOAOAOXOXAAAXAAXAAAXOAXAAXOXOAOAXOOAAAAAXAAOXAAAOOAOAAXAXXXOAOOOOXAAXAAAOAXOAAAXAAAAAAXOAAAAXAAOAAAAAOAAXOAOOXXAOAXOOAAAAOAAAAAAAAXXAAOAOOXAOAOAAAAAAAXAAXOAAOOAAXAAAXAAOAAXAXOXAXXXXOXXAOAAOAOAAA
36975

output:

3800841600

result:

ok single line: '3800841600'

Test #27:

score: 10
Accepted
time: 131ms
memory: 55564kb

input:

200 16 1
XAAXAXAAAAAXXAOAAOXAAAAXAAAAAAAAAAXOAAAAAAAXAAAAAAAOAAAAAOAAAAAAAAAOAAAAAOAAAAAAAAAAAAAAAAAAAAXAAAOOXAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAXAAOAAAAAAAAAAAAAAAOAAAAAXAAAAAAAAAAAAAAAAAAAAAAAXOAXAAAAAXAAAAAA
42961

output:

4143734528

result:

ok single line: '4143734528'

Test #28:

score: 10
Accepted
time: 93ms
memory: 55096kb

input:

200 16 1
XOOOXXXXOXXAOXXAOOXXOXAOXOOAOOOOAAXOAXOXXAOOOXXOOXOXOOXOXOXXXAOXOXOXOXXXAXOAOXXXOOOXXXXXOOOOOOXAOXXXAXOXXAOOOXXAOXOOXOOXOXXOXOXOOAOXOOAXAXXOXAOXXXXOOXAOXXOOXXOXAOOOOAXXAOOOXXOOXOOOXAOXXOXOAOXOXAOXOXX
32762

output:

0

result:

ok single line: '0'

Test #29:

score: 10
Accepted
time: 99ms
memory: 55908kb

input:

200 16 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXOAAAXAAXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAXAAAAAAAAAAAAAAAAAAAOAAAAOAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAOAAAAAAAAAAAAAAAA
55979

output:

347602944

result:

ok single line: '347602944'

Test #30:

score: 10
Accepted
time: 99ms
memory: 54656kb

input:

200 16 1
AXXOOOOXOOOOOXOXOAXOOXOXOXAOXOOXXXOXOAOOAOOAOXOAOXXXXOXAAOXOOXXXXAOOOXOXOXXOAOXXOXOXXXXXOOXAXOOXOOOOOOXXXXOOXOOOOOXOXOOXXOOXOXXXXOOOAXXOXOAOOXXOOXAOXXOXOXOXXXOOAXOXXAXOOAXXXOXAOOOXXOOOAOOOXOAXOXOXOXO
30929

output:

3913125083

result:

ok single line: '3913125083'

Subtask #4:

score: 10
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #31:

score: 10
Accepted
time: 106ms
memory: 56268kb

input:

200 16 200
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
65535
65534
65533
65532
65531
65530
65529
65528
65527
65526
65525
65524
65523
65522
65521...

output:

1
0
2868424865
0
1018802913
0
816568513
0
2244855105
0
1513528417
0
3780854561
0
2411474817
0
1879787649
0
398644769
0
3859808609
0
2723996737
0
2117052865
0
3741171169
0
2323352993
0
1163581185
0
802359553
0
590918561
0
3268577249
0
1787029441
0
2790164033
0
2761299809
0
1962577953
0
3641112193
0
2...

result:

ok 200 lines

Test #32:

score: 10
Accepted
time: 103ms
memory: 55136kb

input:

200 16 200
OXOOOXXOXOXOOOOXOXXXXXOXXOXXOOXOOOXXOOOOXOXOXXXXOXXOOOOXOOXOXOXXOXOOXXOXOXOXOOOXXOXOOOOOOOXXXXOOXOXOOXOOXOOXOOXXXXOOOXOXOOOOXXOOXXOXOXXOXOXOXXOXXXOXOOOXOXXXXOXXOOXOXOOXOOXOOOOOXXXXOXOXOXOXOXOOOXOOOOX
57343
65407
65519
64511
65503
64511
49151
64511
49151
61439
65503
65279
65279
65534
61439...

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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 200 lines

Test #33:

score: 10
Accepted
time: 199ms
memory: 55756kb

input:

200 16 200
AOAOAXAOAXAOAXAOAOAOAOAXAXAXAXAXAOAOAOAOAOAOAXAOAXAXAOAXAOAXAOAXAOAXAXAXAXAXAXAXAXAOAXAXAOAOAOAXAXAXAXAOAOAOAXAOAOAOAXAOAXAXAXAXAOAOAXAOAXAOAXAXAOAOAOAOAOAOAXAXAXAXAXAOAOAOAXAXAXAXAOAOAXAOAXAXAXAXAXA
31520
59491
7515
26442
43203
4412
54292
6905
19395
39481
27749
56643
61429
51923
31196
17...

output:

0
1102225408
2181070848
0
747520
0
0
949288960
2625937408
2570797056
2352480256
2263777280
1409286144
2195357696
0
0
0
0
0
0
0
0
2798518272
1246593024
3974234112
2230845440
912818176
2970583040
0
0
3687289280
0
3388145664
1892253696
0
0
0
3112173568
0
0
2096627712
2483281920
3926556672
0
0
0
1451753...

result:

ok 200 lines

Test #34:

score: 10
Accepted
time: 119ms
memory: 55944kb

input:

200 16 200
AAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAA
52382
9564
25024
51027
20908
54426
57892
13681
49596
56303
28359
7859
63912
58578
50740
5...

output:

0
0
0
3446743897
0
0
0
3579517845
0
116375673
3360612165
1123108825
0
0
0
0
3665728757
597459937
0
833292725
3766041737
0
359636469
435523013
0
0
0
0
0
0
2646344113
0
4072786529
1841934297
2228003597
2901828165
0
2662251305
0
0
4074738853
0
3186713229
960682457
0
3157640929
2414867013
0
0
1256840513...

result:

ok 200 lines

Test #35:

score: 10
Accepted
time: 117ms
memory: 55064kb

input:

200 16 200
XOXOOOAXOOXOOAXOXXOOAXXXXOXAXOOXXXAXOOXXXAXXXOOOAXOOOOOAOXOOXXAXXOOOOAXXOOXOAOXXXXOAXOOOOOAXXXOXOAXXOOOXAOOOXOXAXOOOXXAXXXXOXAOXXXXOAXXXXOOAOOOOOOAOXXOXOAOXOXOXAXOXXOXAXOXXXOAOXOXXOAXOXXOOAXXOXOOAOOX
10282
1585
29289
6570
42702
25836
53015
28198
10069
39731
12780
40571
53594
9191
31505
11...

output:

0
416534272
633290752
0
0
0
3068395520
0
945635328
1276968960
0
638582784
0
1111687168
823607296
2367244032
715063296
0
1829847040
0
0
0
0
0
1307574272
4224974848
0
0
0
4222042112
0
0
0
1436090368
0
0
0
3517890560
3308519424
4034150400
0
2137587712
2954821632
0
0
1142374400
0
0
0
0
3837542400
0
1042...

result:

ok 200 lines

Test #36:

score: 10
Accepted
time: 141ms
memory: 55832kb

input:

200 16 200
XXAAAOXXAAOAAAAAAXXAXXAXXOXOAAAOAOAXOAAAXOXXAAAXAOOAOOXAAXAXAOOOAOXOXAAAOAOOAXAXXOOOAXAAAXXAAXAAAAAAXAXAOXAAOXXOOAOAAAAXAAAXOAXOAAOAAXOOAAAOXAAAOAXAAAAXAXOXOXAXAXAAAOOXXXAAXAXAAXAAAAAAAAOAXAOXAAAAAAA
5792
60020
59739
43873
52052
50193
14658
58866
51983
36700
14033
44909
47996
60685
5167
1...

output:

0
0
2785239271
3810882207
0
1056878721
0
0
2009660665
0
3949685919
90567937
0
2386112449
2961428409
2495474817
1763440377
0
0
0
3490785119
2507289567
3847440121
1686629287
2141936249
233727353
3901966119
2767610279
0
320050271
3764389791
734539969
2793711711
0
3416668601
0
2064153503
0
0
2313730049
...

result:

ok 200 lines

Test #37:

score: 10
Accepted
time: 133ms
memory: 56092kb

input:

200 16 200
AAXAAAXAAAAAAAAAAAAAAAAAOAAXAAAAAXAXAAAAAAAAAAXAAAOAAAAAAAAAAAAAXXAAAAAAAAAAXOAAAAAAAAAAAAAAAAAAAAXAOAAAAAAAAAXAAAAAAAXAAAAAAAAOAAAAAOAAAAAAAAAAOXAXAAAAAAAAAOAAAAAAAAAAAAAOAAXAAAAAAAAAAAOAAAAAAOXAAAO
17281
33709
63144
26567
21976
34669
27038
21387
23582
61016
9215
65030
53987
46383
7218
3...

output:

2350527441
1541948637
0
512402433
0
2650868617
0
4294069601
0
0
3423306317
0
3570244141
1677055569
0
0
0
0
0
2186151325
4221119141
2904509357
84949089
2460779577
4062801565
0
443512641
2107103205
0
3999276365
2743835497
2736841437
0
3274681833
0
938296301
87666877
2445643973
0
0
3234008481
152590537...

result:

ok 200 lines

Test #38:

score: 10
Accepted
time: 133ms
memory: 55104kb

input:

200 16 200
OAXOXXXOXAOAAOXOXOXOOOXOXXXOXOOOOAXOXOXXOXAXOOOXOXXOXOOOOXOOOXXAXOXOXOOAOOOXAXOAOOOAXXXXAOAOAOXAXAXXOAXAOXOXOXOXOOOOXOAOOXXXOXOOXOXAOXOOOOXXOXXOOOXXOOXXXXOOOAOXOOXAAXXXOXXAOOOXOAXOXXOAXOXXXOAXXOXOOAO
14506
9350
45373
63818
11524
21207
53428
56071
24378
60785
45149
10489
43907
61556
53427
...

output:

0
0
2213806080
0
0
325943296
0
2452193280
0
641990656
1243217920
957267968
1547231232
0
2626478080
2363031552
376481792
0
0
0
4253802496
0
0
507183104
0
0
0
884613120
0
0
0
2651455488
905912320
0
3860725760
0
235397120
0
2526150656
2912944128
3863535616
0
3765272576
673054720
331972608
288380928
143...

result:

ok 200 lines

Test #39:

score: 10
Accepted
time: 126ms
memory: 55208kb

input:

200 16 200
AAAAAAAAAAAAAAAAAAAAOAAAAXAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAOAAAAAAOAAAXAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
10507
58474
45019
22501
61419
58351
39893
40185
30389
64429
48700
31377
44886
16299
5981
...

output:

137008075
0
2450650147
563612147
1136526817
2391539547
478037651
3493139899
2561613779
3986361291
0
3623025955
0
1310121257
4286525033
4042222371
2330679353
0
4246430875
1520484865
1935939603
0
0
0
0
1157371323
3468893233
1994235993
2997116641
1285280169
438600361
0
4056806067
247913979
0
3020619457...

result:

ok 200 lines

Test #40:

score: 10
Accepted
time: 114ms
memory: 55796kb

input:

200 16 200
OOXOXOXXOOOXOXXXXOOOOXXOOXXOOOXOXXXXXOOXXOAXXXXXAOOXOXXXOOOXXXXOOOAOOXXXOOXXAXXXOXOXOXXAOOOXXOOXAXOOOOXOOOOOAOOOOAOXXXXOXXXXXOOXXXOXXOXXAXXOAXXOOOOXXXOXOOOXXOXXOXOAXXXXXXOXOXXOXOOOXXXOXXXOXXOOOOAOOOX
41894
21117
9709
22647
16598
57838
47966
63134
59235
31110
59567
60988
20607
50555
26744
...

output:

0
3816816640
2041839616
3929243648
0
0
0
0
2090729472
0
3627679744
0
61702144
3887464448
0
4097048576
0
1691585536
0
0
0
3242905088
3210346496
0
2319056896
0
0
0
0
1149266048
2924085248
25681920
0
3039100928
0
0
0
1539112960
0
1264058368
0
0
3567386624
584581120
3199729664
1860829184
0
0
0
479723520...

result:

ok 200 lines

Subtask #5:

score: 10
Accepted

Dependency #3:

100%
Accepted

Test #41:

score: 10
Accepted
time: 116ms
memory: 61880kb

input:

200 30 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
527009106

output:

0

result:

ok single line: '0'

Test #42:

score: 10
Accepted
time: 109ms
memory: 62188kb

input:

200 30 1
OXXOXOOXOXOXXXOOOXXOOOXXOOXOXXOXXOXXOXXXOOXXOXXOXXXXXXXXXOXXXXOXXOXOOXOXOOXXXOXXOOXOXXXOXXXOOXOXXOOXXXXOXXXOXXXXXOXOXXXXXOXOXXXXXOOXOOOOOOXXXXXXOOXXOOXOXXXXXXXXOXXOOXOXXXXOOXOOOOOXOOXXXOOXOOOOXOOXXXO
388762601

output:

0

result:

ok single line: '0'

Test #43:

score: 10
Accepted
time: 150ms
memory: 61584kb

input:

200 30 1
AOAXAOAXAOAXAOAOAOAXAXAXAXAOAXAXAXAOAOAXAXAOAXAOAXAOAOAOAOAOAOAOAOAXAXAXAOAOAOAXAXAXAXAXAOAXAOAOAOAXAXAXAXAOAXAOAXAOAOAOAXAOAXAXAOAOAXAOAXAOAXAXAXAOAXAXAOAXAXAOAXAOAOAOAOAXAXAOAXAXAXAOAOAXAXAOAXAXAOA
654399953

output:

2197815296

result:

ok single line: '2197815296'

Test #44:

score: 10
Accepted
time: 128ms
memory: 62172kb

input:

200 30 1
AAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAA
44486386

output:

0

result:

ok single line: '0'

Test #45:

score: 10
Accepted
time: 107ms
memory: 61868kb

input:

200 30 1
OXOOOOAXXXXOOAXXXXOOAXXXOOOAXOXOOOAXOOXOXAXXOXOXAXOXOOOAXXXXXXAXOOOOXAXOOOXXAOXXOXOAXOXOOOAXOXXXXAOXXOXOAXXXOOOAOOOXXXAOOOOOOAOXXXOXAOOXXXOAOOXOOOAXOXXXOAXXXOXOAXOXXOOAXXXOOXAXOOXXOAOOOOXOAXXXXOOAXXX
454651397

output:

3019898880

result:

ok single line: '3019898880'

Test #46:

score: 10
Accepted
time: 128ms
memory: 62148kb

input:

200 30 1
XAAAXAAXXOAAAOOAAOOXAAXOXXOAOOAAAAAAXAXOAXOAXAAAAOAAOAOAOOAOOAAAOXXXAAXAOAAAXOOAAXOXAAXXAAAXOXOXAOXAOXAAOAXAXAXXAOAAOAXOXAAXAOOAAAXAAAAAXOXOAOOAAXXAXOXAAOOOOXXOAOXOAOOAOOOAAOAAXAAXXAOOAAOOAAAAOXOOOAA
1026828762

output:

0

result:

ok single line: '0'

Test #47:

score: 10
Accepted
time: 124ms
memory: 61628kb

input:

200 30 1
AAXAAOXAAAAAAAAAAAAAAOAAAAAAAAAAAAAAOXAAAAAXAAAAAAAAAAAAOAAAOAAAAAAAAAAXAAAAAAAAAAAAAAAAAAAAAAAAAAAAXAOAAAAAAAAAAAAAAOOAAAAAAAAAAAAOAAAOAAAAAAAAAAAAAAAAAAAAAXAAAAAOAOAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAA
824060991

output:

821356895

result:

ok single line: '821356895'

Test #48:

score: 10
Accepted
time: 117ms
memory: 61728kb

input:

200 30 1
AOAXXXOOXAOXOXAAOXOAOXOOXXOOAAOAOXXOXOAOXAXXOOAOXOXXOOOOXOOAXXXOAOOAAXXOOXXOOXXOOOXXOAOXXAXOXXXXXOXXAAOXOXOOXAXAAOXOOXXXXOOOXXOOOXOAXOOOOOAAOXXAXXOOXOXOOXOOOOOOOAOOXAOAAOXAXOOXXOOAXOXAXXXXXXOOXXOOXXO
359878851

output:

155738112

result:

ok single line: '155738112'

Test #49:

score: 10
Accepted
time: 137ms
memory: 62168kb

input:

200 30 1
OAAAAOAAAAAAAAAAOAAAAAAAAAAAAXAAAAAAAAAOAAAAAAAAXAAAAAAAAAAAAAAAAXAAAAAAAAAAAAAAAAOAAAAAOAXAAAAAAOAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXAAAAAAAAAAAAAAAAXAAAAAAAAAAAAAAAAAAAAAAAAA
738569495

output:

143868465

result:

ok single line: '143868465'

Test #50:

score: 10
Accepted
time: 110ms
memory: 62252kb

input:

200 30 1
XOXAOOOXXAOXAXXOXOXOOOXAOOOOXOOOXXOOXOOAOXXXXOXXOXOOOXOXXXOOXOOAXXOOOXXAXOXXXOXOXXXOOXXOOOOOXXXAXXXXXXXAXOOXAOOOXOXOXXXXXOOXOOOOXOOXXOOXXOXXXAOOXOOOOOOXAOXXXXXAAXOOXXOOXOOXXXXOXXOOXXAOOOOOOOOOXXOXXXO
184060352

output:

0

result:

ok single line: '0'

Subtask #6:

score: 10
Accepted

Test #51:

score: 10
Accepted
time: 235ms
memory: 61268kb

input:

1000 30 1000
XOOXOOXOOXXOXOXOOOXOXXOXOXXXOXXOXOOOXXOXOXOXXXXOOOOXOOXOXXOOOXXOXOOXOOOOOOXOOXOXXOXXXOOXXXOXXXOXXXOOOOXXXOOXXXXXXXXOXOOOOXOOOOXXOXXXXXXXXXOXOOXOOXOOOXXXXXXOOXXOXOOXXOXXXXXOOXOOOXXOOXOOXOXOOOOXXXOXOOXOXOXXXXOOXOXOOXXXXXOXOOXXXXXOXXOXOXXOXOOXOXOOOOXXOXOOXXXXOOXXOXXOOXXXXOXXOOXXXOOXOOOXOXO...

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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 lines

Test #52:

score: 10
Accepted
time: 235ms
memory: 61416kb

input:

1000 30 1000
XXOOXXXOOOXOXXXXOOXXXXXOXOOXOXXOXXXOXXOXOOOOXXXXOOXXXOOXXXOOOXOOOOOXOOOOXXXXOXXOXOOXXOXXXOXOOXXOXOXOXOXOOOOXOOOXXXOOOOOOOOOXXOOOOOXOOXOOXOOXXXOOOXXXOXOOOXXXOOOXXOOXOOOXXXOXOOOXOXXOXXXOOOOXOXXOOOOOXOOOOOXXOXOOXXOXOXXOOXXOXXXXXXXXOOXOOOOXXOOXXXOOXOXXOXOXOXXXXOOOXXOOXXOOXXOOXOXOOXXOOOXXXOX...

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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 lines

Test #53:

score: 10
Accepted
time: 236ms
memory: 61460kb

input:

1000 30 1000
XXOXOXXOOOXXXOXXXOXOOXXOOXXXXOXOOOXXXXOOOOOXOOOOOOOXOXOOXXOOXXOOOXOXXXOOXXXXXXOXXXOOOOXXOXOXOOXXOOOXXOXOXOOOOXXXXOOXXXXXOOXOOXOXXOXXXXOOXOXOXOXOOOOOOOOOOXXOOOXXOXXXXXOXOXOXXXOXOXXOXXXXOOOOOOXOOXOOXXOOOOOOOOXXXXOXOOXOOOOOOXOOXXXXOXXOOXXOXXXXXXXXOXXXXOOOXXXXOOXOOXOXXOOOOOXOOXXXXOOXXOOXOOO...

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
0
0
0
0
402653184
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3221225472
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 1000 lines

Test #54:

score: 10
Accepted
time: 239ms
memory: 61700kb

input:

1000 30 1000
XXOXXOXXOXOXXXXXOXXOXOOXXXOXXOXXOOOOOXXXXOXOOOXOXOXXXOXXOOOXXOXXXOXXOOOOXXOOXOXXOOOOXOOXXXOOOXOXOXOXXOOXXXOOOXXOXXOXXOOXOXOXXXXXOOXXXOOOOXXXOXOXXOXOOXOOOXXOXOXOOXXXXOOXXOOOOOXXXOXOXXOXOXOXOOXXXXOXOXOOOXOXXOOOOXOXOOXOOXXXXXOXOXOOXOXOOXOOXOXOOOXOOXXOOXXXOOXOXOOOXOOOXXXOOXOXOOXXOOOXXOOOXOO...

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
3221225472
0
0
0
0
0
0
0
0
0
0
0
0
3221225472
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 lines

Test #55:

score: 10
Accepted
time: 234ms
memory: 61324kb

input:

1000 30 1000
OOOXOOXOOXXOOXOOOOXXXXXXOOXXOXOOOXXXXOOOOXOXXXXOXOXOOXOXXXXOXOOXXOXOXXOXXXOOOOOOOXXXOXXOOOOXOOOOXOOXXOOXOXXOXOOOXOOXOXXXXOXXXOOOOXXOOXXOXXXXOOXOXOXXOOOOXXOOOOXOOXXOOOOXOOXXXXOXXOOOXXXXXOOXOOOXXXOOXOXXOOXOOOOOOOXXOXXXXXOXOXOXXXOOOXOOOXXOXXOOOXXOOOOXXOOXXOXOOXXXOOXOXXXOOXXOXXXXXOXOOOOXXXX...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
402653184
3221225472
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1593835520
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1530494976
0
0
0
0
0
0
0
0
0
0...

result:

ok 1000 lines

Test #56:

score: 10
Accepted
time: 240ms
memory: 61644kb

input:

1000 30 1000
XOOOOOXOOOOXXOXXXOXXXXXXXXXXOXOOXXXXXXXOXXOOOXXOXXXXXXXXXOXXXXOXXOOOXOOOXXOXXOXOOOXXXOXXOOXOOOXOOOXOOOXOXOXXXXXOOOOXOOOOXXXOXOOOXXXOOXXOOXOXXXOOXOXOOXXXOXOXXOXXXXOXXXOOXOOOOXXXXOOOOXXOOXXXXOXOXOOOXXOXOOXOOXOXXXOXOOXOXOXOXOOOXXXXOXOOXXOOXOOXOXXOOOXXXXOOOOXXXOOXXXXOOOOXXXXXXXXOXOXOOXXOXXO...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3221225472
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3221225472
0
0
0
0
3221225472
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 1000 lines

Test #57:

score: 10
Accepted
time: 236ms
memory: 62064kb

input:

1000 30 1000
XOXXXOXOOOOOOXOOXOOOOOXXXXXOOOXXXOXOXOXXOOOXXOOXXOOXOOOOOXOXXXXOXOOXOOXOXXXOOXOXOXOOXXXXXXXOXOOOOOOXXXOXOXOOOOOOXXXXXOOXXXXXXXXOXOOOOOXXOXOXOXOOOOXOXXOOOOXOOOXXOOXOXXOOOOOXXOOXOXOOOXOOXOOOXOOOOXXOXXXOOOOXXXOXOXXOXOOXXXXXOOOXOXXOXOXXOXXXOOOXXXXXOXOOXXOXOXOXXXOOXOOXXOOXXXXOOOOOXXXXOXOOXOO...

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
3221225472
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3221225472
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 lines

Test #58:

score: 10
Accepted
time: 217ms
memory: 62036kb

input:

1000 30 1000
XOOXOXOOOXOOXXXXOOOOOXXXXOOXXXOOOXXXOXXOOXXXOOOOOOXOOXXOOXXOOOOOOXXXXXOXOXOOOXOXOOXOOXXOOXOXOOXOOOOXOOXOOXXOOXXOXOOXXOXXXOOXOXXXXOOOOXXOOXOXOXOOOXOXOXOXOOOOOOOOOOOXOXXXOOXXOXXOOOOOXOXOXXXOXXOOOXOXXOXXXOXOOXXOXOOOXXOOXXXXOXXXXOOXXXOXXOOXOXOXXXXOXXXXOOOOOXOOXXXXXXOXXOOOXXOOXXXXXXOXXOOOXOO...

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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1593835520
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 1000 lines

Test #59:

score: 10
Accepted
time: 232ms
memory: 62156kb

input:

1000 30 1000
OXXOOXOXOXOOXOOOXXOOXXXXXXOXOXOOOOXXXOOXXXOXXXOXXXOXXOOXXOXOXXOOXOXXXXXOOXOOXOXOOXXXXXOOOOXOXOOOXXXOOOOOOOXOXOXXXXXXOOXOXOOOXXXXOXOXXOOXXOXOOOXXXOXXXOOOOOXXOXXOOOXXOXXXOXXOXXXXXOOOOXXXXOXOXOOXXOXXOOOOOOXXOXXXXXXOXOXOOXOXOXOOXXOOOXOXOOOXXOXOOXOOOXXOXXOXXOOXXOXXXOXOXOOXXXXXOOXOOXXXXOXXOOX...

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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 lines

Test #60:

score: 10
Accepted
time: 239ms
memory: 61200kb

input:

1000 30 1000
XXXOOOXXXXXOXOXXXOXOXOOXOXOXXOXOOXXOOXXOXOOOOOXXOOXXOOOOOOXXOXXXOOOOXXXOOXXXXOXOXXXOOOOXOXXOOXOXXXOXXXOXXOOXOXXOXOXOXOOOOOXXOOOXOOOXOOOOXOOXOOXOXOOXOOOOOOOXOXOOXOXOOOOXOOOXXOOXXXOXOOXXXXXXOXOXOOXOOXXXXXXXOOOXOOOXOOOOXXXOXOOXXXXXXOOXOOXXOOOOXOOOXOXXOXOXOXXOXOOOOOOXOXXOXOXXOXXOXXOOXXXXOXX...

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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3221225472
0
3221225472
0
0
0
0
0
0
0
0
0
0
0
3221225472
0
0
402653184
0
0
0
0
0
0
0...

result:

ok 1000 lines

Subtask #7:

score: 10
Accepted

Dependency #2:

100%
Accepted

Test #61:

score: 10
Accepted
time: 111ms
memory: 61200kb

input:

50 30 50
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
1073741823
1073741822
1073741821
1073741820
1073741819
1073741818
1073741817
1073741816
1073741815
1073741814
1073741813
1073741812
1073741811
1073741810
1073741809
1073741808
1073741807
1073741806
1073741805
1073741804
1073741803
1073741802...

output:

1
0
3500008393
0
1296002393
0
3718107313
0
3476558801
0
181411513
0
186088297
0
1146602977
0
3672755233
0
2249023017
0
3179466233
0
2541625233
0
2323835121
0
1673978393
0
2352489737
0
1133190593
0
807086657
0
3595037321
0
900219033
0
2269315185
0
3797176337
0
4048926585
0
2824724649
0
1674839969
0
1...

result:

ok 50 lines

Test #62:

score: 10
Accepted
time: 91ms
memory: 62168kb

input:

50 30 50
XOOXXOXOXOXXXOOXOXOXXOXXXOOXXOOOOOXOXXOOOOOXXXOXO
1065353215
1073479679
1073725439
1073479679
1073741815
1040187391
1073739775
1073741311
939524095
1073709055
1073741819
1073479679
1073610751
1073740799
1073733631
1006632959
1069547519
1056964607
1073741311
805306367
1073610751
1073217535
1...

output:

4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
4026531840
402...

result:

ok 50 lines

Test #63:

score: 10
Accepted
time: 136ms
memory: 62032kb

input:

50 30 50
AXAOAOAOAXAXAXAXAXAOAOAOAXAXAXAOAXAOAOAOAOAOAOAOA
466655695
893036324
443614444
264797723
47670940
750957032
524039822
249473615
1072507099
967547785
84929613
514304867
351282991
609275772
418139813
983226520
767113939
372311043
445100368
1044700166
836713833
82449048
399694425
314507104
60...

output:

3600839069
0
0
1153724549
0
0
0
3310374741
385396781
3926834225
2376355289
1737889133
1292492077
0
1691476969
0
2986645133
2835561589
0
0
673061089
0
2171140625
0
3794328645
3528247301
4259882397
1666432873
2229771213
1638044237
0
4093408993
1322657189
3422587297
1510401673
0
0
0
3456254117
40708343...

result:

ok 50 lines

Test #64:

score: 10
Accepted
time: 92ms
memory: 61852kb

input:

50 30 50
AAAAAAXAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAX
281593212
392255833
273418042
998403919
185297929
624538417
864806036
384548838
131747048
996527952
358610809
727702523
667774639
495239147
71294916
1014571373
95658543
955375795
345194210
241198002
435841681
381619736
959577864
376567710
62...

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
3313777664
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 50 lines

Test #65:

score: 10
Accepted
time: 92ms
memory: 62104kb

input:

50 30 50
OXXOXOAOXXOXXAOOXXOOAXOXXXOAOXXXOXAXOOXOOAXOOXOXA
400971089
229785691
773323865
692802211
116256289
509053740
391695786
898036813
759454535
943524220
422277433
557239217
1041831161
527596757
483929853
224742417
317391522
414274970
485277303
279015282
459743426
741082518
799441891
433493221
...

output:

444897523
1998782231
3605748179
1334674325
14836643
0
0
728160871
3645829995
0
87113761
3590395961
2184455115
1092540621
1975970239
2293744163
0
0
267593081
0
0
0
3677783759
4222817039
2422200985
0
0
0
1394085825
0
2101437319
0
0
0
0
868305833
4084279377
2649548239
0
2595000631
2640066783
0
0
340188...

result:

ok 50 lines

Test #66:

score: 10
Accepted
time: 128ms
memory: 62084kb

input:

50 30 50
XAXOAAAXAAAXAOAOOXOAAAAAAOAOAOOAXOAAXAOXXXAAOXOAX
886148863
1051670480
498757918
246903934
733255185
80199697
1056671388
56079286
1063566094
1038620881
508285868
803828790
749651145
1043353448
892219808
824168373
279987020
28568704
485491666
545757452
612654150
438016871
845970237
627702001...

output:

1807220736
0
0
0
879976448
1526912512
0
0
0
1168097280
0
0
1606467584
0
0
2874408960
0
0
0
0
0
324665344
2770993152
2814836736
1400635392
0
1603272704
3085697024
3005939712
0
0
0
2390841344
3866361856
0
2685017088
302432256
0
3551395840
0
590348288
672006144
2281308160
1220018176
0
2063966208
553041...

result:

ok 50 lines

Test #67:

score: 10
Accepted
time: 100ms
memory: 61516kb

input:

50 30 50
AAAAAAAAAAAXAXAAAAAAAAAAAAOAAAAAAAAAAAAXAAAAXAAAA
714290380
442345462
386132878
268295981
387576625
623822817
536773959
647779933
338540086
449604380
385372391
897053002
421344725
1037836350
11219530
610601689
235410698
115457124
195649710
477899435
685475218
691999515
661142670
128937554
2...

output:

0
0
0
18874368
2858582016
431652864
2524184576
1083211776
0
0
717455360
0
2547810304
0
0
1837985792
0
0
0
1139376128
0
1269923840
0
0
4128866304
0
2333212672
0
0
0
0
0
0
0
980025344
0
1737670656
2693775360
3622436864
0
0
3051716608
988168192
0
0
0
0
0
1647935488
0

result:

ok 50 lines

Test #68:

score: 10
Accepted
time: 96ms
memory: 61136kb

input:

50 30 50
OAOOXOXXOXOXXXXOXOXXOXXOXOOOXOOXXXOXOOOOOOXXXXXXA
275915975
1033936582
443931124
617412995
742237671
598416340
924101076
336853450
789685085
1056825861
854045454
108100848
920180458
737975303
8352860
981697595
355130988
453268063
166204476
299162549
537252974
845107560
242031497
821294986
8...

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

result:

ok 50 lines

Test #69:

score: 10
Accepted
time: 103ms
memory: 62144kb

input:

50 30 50
AAAAAAAAAAAAAAAAAAAXAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
401214671
707992659
967316840
928779361
529168336
414849
456532843
66809714
858442727
772030133
1013560916
66213714
972550836
718642003
890369450
724344733
196761654
590878277
658351339
209622322
2258325
192829003
746496271
467483150
8632030...

output:

2543386624
3233325056
0
3140214784
0
3478659008
4267081728
0
1883373568
1068023808
0
0
0
4005888000
0
3998613504
0
1180669952
2522480640
0
672664576
3318546432
3945562112
0
0
1903542272
0
0
0
1583185920
1134962688
0
0
0
0
2260381696
1780482048
3229679616
2271870976
0
0
2569011200
28606464
341311488
...

result:

ok 50 lines

Test #70:

score: 10
Accepted
time: 99ms
memory: 62248kb

input:

50 30 50
XXXXOXOOXXOOOXXXOOOXXOOOOAOXOOOOXOOOOOOOOXXXOXOOX
1027563938
602890438
147284209
302311801
144136502
240723151
20481481
595412473
785772957
916640807
758323006
335114787
509584629
796388028
975188010
431108571
915523864
942148816
575831487
710706820
1035931698
449016178
729538332
261498038
...

output:

0
0
747524769
3380075889
0
2628475341
2693960753
871986785
3947957945
3505107389
0
2213332933
435151529
0
0
2187599477
0
0
531731581
0
0
0
0
0
2284268189
31908689
350275301
0
1507519681
354355489
0
2751859589
0
2292920561
1351112957
0
0
0
889180857
2384619077
2101187973
0
0
1305368793
3778206205
347...

result:

ok 50 lines

Subtask #8:

score: 10
Accepted

Dependency #5:

100%
Accepted

Test #71:

score: 10
Accepted
time: 204ms
memory: 62140kb

input:

1000 30 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

1

result:

ok single line: '1'

Test #72:

score: 10
Accepted
time: 201ms
memory: 62112kb

input:

1000 30 1
OXOOOXOXXOOOXXOOOXOXXOOOXXOOOXXOOOXOOOOOOOXXXOXXXOOXXOOOOXXXXOOXXXOOOOXXXOXOXOXXOOOOXXXXXXOOOXXXXOOXXOOOOOOXXXOXXOXXXOOXOOOXOXOXXXOOXOOOOXOXOOOXOXOXOXXOOXOOOOOOXOXXOXOXXXOXXXXXXXOOXOXXOXXOOOXOXXXOOOOXOOOXXOXOOOXOXOXXXOXXOOXOOXOOOOXXOOXOOOXXOOXXOOXOOOXXOXXXXOOXXXOXOOXXXOOOXXXOOOOOXOOOOXXOXX...

output:

0

result:

ok single line: '0'

Test #73:

score: 10
Accepted
time: 369ms
memory: 62088kb

input:

1000 30 1
AXAOAXAOAOAXAOAOAOAOAOAXAXAOAOAOAOAOAOAOAOAXAXAOAXAXAOAXAXAXAOAXAOAOAXAXAXAXAOAOAXAXAXAXAXAXAOAOAOAXAXAOAXAXAOAOAXAXAXAOAOAXAXAOAXAOAOAOAXAXAOAXAOAOAOAXAXAXAOAOAOAXAOAXAXAOAOAXAXAXAXAOAXAXAOAXAXAOAOAOAOAOAXAXAOAXAOAXAOAOAOAOAOAXAOAXAOAXAXAXAXAXAXAOAXAXAXAOAXAOAXAXAXAOAXAXAOAXAXAXAOAXAOAXAX...

output:

1073741824

result:

ok single line: '1073741824'

Test #74:

score: 10
Accepted
time: 257ms
memory: 62036kb

input:

1000 30 1
AAAAAAXAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAA...

output:

2420059055

result:

ok single line: '2420059055'

Test #75:

score: 10
Accepted
time: 207ms
memory: 61248kb

input:

1000 30 1
XXOXOXAXOOXOXAXXXOXOAXXXOOXAOOOOOOAOOXOOOAXOOXOXAOXXOOOAXOOXOXAXXOXOXAXXOOOXAXOOXXOAOXOXOXAXXOXOXAXXOOXXAXXXXXOAXOXXXOAXOXOXOAXOXXOOAXOOOOXAXOOOXXAXOXXXOAXXOXOOAXOOXXXAXOOOXOAXOXXOXAXOXOXOAOXXXOXAXOOOXOAXOOOXXAOXXXXOAXXOXOOAOXXOOXAXOOOXXAXXOXXOAOOOOOOAOOOXXXAOOOOXXAXXOXXXAXXXXXXAXOOXXOAXOO...

output:

2114093056

result:

ok single line: '2114093056'

Test #76:

score: 10
Accepted
time: 272ms
memory: 61892kb

input:

1000 30 1
OAAAXOAXXOXAXAAOXAXOOAAAAXOAAAAAOOXOXAOOOOOAXAXOAAXXXAAXXXOAAOAAAXOOOOAOXXAXAAAAAOOXOAOAOAOXOAAXXAAAAOOXAAOAOAAAAOAXAAAAOAAXAAXOAAAXXXAAAAAAXAOOXAAAAAOAAOAAOXAAAAAXAOXXAAAXAAXAOXOAXAAAOOAAXOAOAAAAOOOOAOAOXOAAAAAOAAXOAXAOOAOAAAAAOAAAXAAAOXAAAOOXOOXOAOXAAOOAAXOAAAAAAAOXAXXOAAAXOXXXXOXXXXAXOO...

output:

0

result:

ok single line: '0'

Test #77:

score: 10
Accepted
time: 212ms
memory: 62108kb

input:

1000 30 1
AAAAAAAAAAAAAAAOAAAAAOAAAXAAAAAAAAAAAAAAAAAAAAAAAAXAAAAAAAAXAAAAAAAAAAOOAXAAAAAXAAAOXAAOAAAAAAAAAAAOAAAAAAAAAAAAAAOAAAAAAXAAAAAAAAAAAAAXAAAAAAOAAAAAAXAXAAAAAAAAAAAAAAOAAAAAAAAAAXXAAAXAAAAAAAAXAAAOAAAAAXAAAAAAAAAAAAAXAAAAAOAAAAAAXAAAAAAAXAAAOAAAAAAOAAXAAAAAAAAAAAAXAAAAAXAAAAAOAAAAAAOAAAXAAA...

output:

0

result:

ok single line: '0'

Test #78:

score: 10
Accepted
time: 204ms
memory: 61720kb

input:

1000 30 1
OOOXXOOXXXXXOOOOXXOXXXXXXOXOXXOXAOXOXAOOXXXOOXOXXXOOOAOOAXAXOOOOOXXOXOXXAOOXOOOXOOXOAOOXOAOOOOOXXOXOOAXXOXAOOXOOOXXOXOAXOAOOOXXOOXOAXOAXOOXXOOXOAAXOXXOOXAOXOAOAOXXXXXAXXXAXOAOOXOAXAOOAOAOXOXAXOOOXXOAXOOOXOXOAXXXXXXOXOOOOAOXXXAOXAAAAOOOXAOOOOXOXOXOAXOXOAOXXOXXOOXXXXOXXOOOXXAXXOXXOOXOXXXOOAX...

output:

0

result:

ok single line: '0'

Test #79:

score: 10
Accepted
time: 205ms
memory: 62432kb

input:

1000 30 1
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAOOAAAAAAAAAAAAAAAAXAAAAAAAXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAXAAXAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

2147483648

result:

ok single line: '2147483648'

Test #80:

score: 10
Accepted
time: 190ms
memory: 61752kb

input:

1000 30 1
XOOXXOOOXXXOOOOOOXXXOXAOOXXXXXOOOXXOXOXXXOXXAXXXOOOOOXOOXXXOOOXOOXXXOXXOXAXXXXXXXOOOXOOOXOOOXOXOOOXAOXXAOOXXXOOOOOOXOOXXXOOXXOOOXXXOXXXXOXOOOXXOXXXXOOOXOOOOAOXXXOXOOOOOXXOOXXXOOXXXOXXXAOXXXOOAOXOXXXXOOXOXOXOOXXOOOOAXOOXOXXXOAAOXXXOXOXXXXOOXXOOXXOXXXXAOXOOAOXXXOOOXXOOXOOXOXOXXOXOOOOOXXOOXXX...

output:

1077323173

result:

ok single line: '1077323173'

Subtask #9:

score: 10
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #7:

100%
Accepted

Test #81:

score: 10
Accepted
time: 139ms
memory: 62436kb

input:

200 30 200
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
1073741823
1073741822
1073741821
1073741820
1073741819
1073741818
1073741817
1073741816
1...

output:

1
0
2868424865
0
1018802913
0
816568513
0
2244855105
0
1513528417
0
3780854561
0
2411474817
0
1879787649
0
398644769
0
3859808609
0
2723996737
0
2117052865
0
3741171169
0
2323352993
0
1163581185
0
802359553
0
590918561
0
3268577249
0
1787029441
0
2790164033
0
2761299809
0
1962577953
0
3641112193
0
2...

result:

ok 200 lines

Test #82:

score: 10
Accepted
time: 125ms
memory: 62180kb

input:

200 30 200
XXOOXXXOOXOOXOXOXXXXXXOXOOOXOXOXOOOXXXXXXOOXXOXXXOOXXOOXXXXXOOXXOOOOXXOOOXXOOXOOXXXOXOXOOOXXXXXOOOXXOXOOOOOXOXXXXOXOOOXOXOOOXOOXOOOXXOOOOOXOXOOXXXXOOXOXXXOXXOOXXOXXXXXXOXXOXXOXXXXOOOXOOXOOXXXOXXOXOOX
1073741807
1073676287
805306367
939524095
1073741791
805306367
1065353215
1073741821
1069...

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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 200 lines

Test #83:

score: 10
Accepted
time: 223ms
memory: 61952kb

input:

200 30 200
AXAOAOAXAXAOAOAOAOAOAXAOAXAXAXAOAXAXAXAOAOAXAXAOAOAXAXAXAOAXAOAOAXAOAXAXAOAOAXAOAOAXAOAXAXAXAXAOAOAOAOAXAOAXAOAXAXAOAOAOAOAOAXAXAXAOAOAXAXAOAXAXAXAXAXAXAOAXAOAXAOAXAOAXAXAOAXAXAXAOAOAOAXAXAXAXAOAOAOA
932289783
428898031
1047503440
898827571
633585551
977430988
325925521
900035666
11106534...

output:

0
2147483648
0
973078528
0
0
805306368
0
0
0
0
0
0
0
0
0
964689920
0
0
0
0
2147483648
1342177280
0
0
134217728
0
0
0
3657433088
104792064
2147483648
0
0
0
0
0
2147483648
3489660928
671088640
3758096384
0
0
0
0
671088640
0
2952790016
0
303038464
0
2550136832
0
0
0
2147483648
0
1342177280
4160749568
2...

result:

ok 200 lines

Test #84:

score: 10
Accepted
time: 146ms
memory: 61860kb

input:

200 30 200
AAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAAAAAXAAAAAAOAAA
411325454
767715509
863147211
371260297
856121748
321300515
873912606
531655331
75856859
...

output:

0
1563455145
3675873453
1186223789
0
162734269
0
321790541
3766966893
1885903893
2246913409
2174193289
0
894256741
1910804305
4073157969
0
2669275197
0
0
0
0
0
4020736601
0
3213827185
2725511613
3575528769
2580749589
2741749769
0
0
0
0
0
2165388657
30552389
0
0
0
1731804289
0
0
0
0
0
3227951585
1957...

result:

ok 200 lines

Test #85:

score: 10
Accepted
time: 138ms
memory: 62116kb

input:

200 30 200
OXXOOXAOXOOOXAOOOOXOAXXXXXOAOXXOOOAXOOXXXAXOXXXOAXOOXXOAXOOOOXAOOXOXXAXXXOXOAOXOXOOAXXOOXXAXOXOOXAXXOOOOAOOOXXOAOOXOXOAOOOXOOAXXOOXOAXXXOXOAOOOXXXAXXXOOXAXXOXOOAXXOOXXAOOOXXXAOXXXXOAXXXOOOAXOXXOOAOXO
568750445
884346374
957049162
416600907
67542396
1037594210
792763779
266852479
47651711
...

output:

1073741824
0
0
2415919104
0
0
1543503872
0
0
0
1073741824
0
0
1073741824
2348810240
0
2030043136
3946840064
0
0
0
0
0
0
0
0
0
0
0
4026531840
3383754752
1073741824
0
0
0
0
2483027968
0
0
4026531840
0
0
0
4026531840
1543503872
4009754624
0
0
0
0
0
0
0
0
0
0
0
0
1073741824
0
1879048192
0
0
0
0
0
374131...

result:

ok 200 lines

Test #86:

score: 10
Accepted
time: 143ms
memory: 62368kb

input:

200 30 200
AAAAAAXAOAAAAOXOOOOAAOXXAAXAAAAOXOAXXOAOOXAAXOAAAAAXAOOAAAOXAOAOAAAXAOXAXAAOAXXAXAXAOOOAOOOXAOXXAOOOAAXAXXAAAAAAXAXAOAAAXXAXAAOOAOAOAAOOXOXXOOOOAAAOAAAOOAOXAAAAOAAAOOOOAAAAXAXAXAXAOOAAXAAAOXAAAXOAXAA
6986337
2028447
949592609
787377842
23446597
444005815
917714515
955604175
1018787156
335...

output:

309918720
3990192128
2993321984
0
2891860992
3601858560
1432551424
3605790720
0
2999713792
1596129280
0
2522185728
0
0
2617294848
0
0
2825748480
0
0
1602584576
0
0
4019388416
4155179008
0
2818048
0
29753344
4203659264
1560985600
0
1448184832
2321022976
1564880896
0
1824112640
548585472
600670208
599...

result:

ok 200 lines

Test #87:

score: 10
Accepted
time: 155ms
memory: 61300kb

input:

200 30 200
AXAAAAAAAAAAAAAAAAAAAXAAXAAAAAAAAAAAOAAAAAAAXAAAAAAXAAOXAAAAAAAAAAAAAAAAAAAAAAAAAAXAAAAXAAAAAAAAAAAAAOAAXAAAAAAAXAAOAAXAOAAAAAAAOXAAAAAAAAOAAAAXAAAAAAXAAAAOAAOAAAAAAAXAAAAAAAAXAAAAAAAAAAAAAAOXAAAAAAO
337953552
97088458
634769746
921554620
553718212
147192248
521091435
880031214
755460826
...

output:

0
0
0
0
0
0
178642813
0
0
2446409105
1444740853
0
2924542577
0
0
0
3866802357
0
2799054329
261379253
637203985
3766920821
0
0
0
1503562041
0
920283753
3095243625
0
2815829269
0
0
3471975969
491822993
0
2566353305
748618901
0
693221737
0
0
1587453589
3616095225
0
2715738065
0
0
2306452837
0
308453745...

result:

ok 200 lines

Test #88:

score: 10
Accepted
time: 141ms
memory: 61288kb

input:

200 30 200
XXOXXXOOOXOXXAAOXXAOOAAXAOOAXAOAAOOXXXXXXXXOXOAOAAXAXOOAOXOXOXOXOOXAOXXXOOOXXAOOXOAOXXAAXXXXXAOOOXOXOOXOAXXXXOXAXOXXOAOAOOAOOXOXOOAOOXXOXOOXOOXAXOXXOAOOOOXOOOXOXXXXOOOXOOOXAOOOAXXXOOXOXXAOXAOXXAOOOXO
844531253
1055412645
629024094
344633508
909973399
343892171
538955012
356340462
13274607...

output:

3959463936
625377280
0
0
322043904
266108928
0
0
0
0
3467247616
145358848
2066268160
1792737280
4011851776
0
1399586816
1065025536
3370647552
0
2196226048
770861568
0
0
732479488
0
0
2316435456
3396190208
2466291712
0
0
0
3304439808
277348352
590497792
0
0
2183135232
2486632448
2269249536
0
27918172...

result:

ok 200 lines

Test #89:

score: 10
Accepted
time: 211ms
memory: 62432kb

input:

200 30 200
AAOAOAAOAAAAAAAAXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAOAOAAAAAAAAAAAAAXXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAOAAAAAXAAAAAAAAAAAAAXAAAAAAAAAAAAAAAAA
637404975
584605446
88563568
56818310
405679981
634937497
750941277
425408931
701816573
1...

output:

720633856
0
0
0
3484647424
3710070784
2934063104
4160749568
4017618944
195084288
3916496896
0
3850240000
0
2833055744
755105792
0
137363456
572391424
0
0
0
1334837248
1294204928
0
4177002496
0
2182742016
1475608576
2124677120
297009152
2354167808
1109393408
3268214784
0
3971317760
0
1228406784
19089...

result:

ok 200 lines

Test #90:

score: 10
Accepted
time: 141ms
memory: 62136kb

input:

200 30 200
OOOOOOXOXOOXXOXXOXXOOXOOXXOXOAOXXOOOXOOOXOXOXOXOXXXAXOXXXXOAXXOOOXXOOOOOOOXAAOXXOOOOXOOOXOXOOOXOOXXAXOOAXOOXXOXOXXXOXOXOOXAOOAOXOXOXOOAXXXAOXOXOOOOXXOOXOOOXOOOXOOOOXOXOOXXXOAXXOXOOOXOXXAXXOOOXXXOXOXX
423639978
634042673
428181135
190021046
138548647
986152282
371522044
1054317336
35728918...

output:

0
2688122089
676268523
0
717291705
0
0
0
1107254323
921745339
1616309185
0
572634995
0
3718636049
3282037617
0
15913187
3617373905
4281627025
0
349163347
3186535939
0
0
890388243
0
282150057
849647475
194464115
0
4111993851
2674901113
0
0
0
0
2422681969
328003305
5050089
794971393
0
2166490083
10024...

result:

ok 200 lines

Subtask #10:

score: 10
Accepted

Dependency #6:

100%
Accepted

Dependency #8:

100%
Accepted

Dependency #9:

100%
Accepted

Test #91:

score: 10
Accepted
time: 284ms
memory: 62072kb

input:

1000 30 1000
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

1
0
3552074529
0
3882755681
0
432069569
0
2246081089
0
1362851297
0
2915497889
0
2240769409
0
4174047873
0
2222085793
0
3853643489
0
3549238593
0
253554881
0
2132598113
0
2990746657
0
3866112769
0
3360238849
0
4137675297
0
3226718049
0
3479447233
0
1945583425
0
2573556961
0
992082081
0
1625903233
0
...

result:

ok 1000 lines

Test #92:

score: 10
Accepted
time: 228ms
memory: 61080kb

input:

1000 30 1000
XOXOXOOOOOXOOOOXOXOXOXXXXOXXXOOXXOOXXOXXOXXOXOOXOOXXOOXXXXXOXOOXOOOXXOOXOOOOXXXOOOOOXOOXXOXXXOOXOXOOXXOOOOXXXOOOXOXOOXXXXOOOXXXXXOOOXOXXOOOXOOXOOXOXOOOOOXXXXXXXOOOXXXXXOOXOXXXOOOXXXOXOXXOXXOOXOOOOXXOXXXXXXXXXXOOOXXOOXOXXOOOXXOOOOXXXOOOXXXOOOOXOXOOOOOXOXOXOXOOOXXXXXXOXXOXXXXOOXXXXXXXXOOO...

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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 1000 lines

Test #93:

score: 10
Accepted
time: 764ms
memory: 62408kb

input:

1000 30 1000
AXAOAOAOAXAOAXAXAXAOAXAXAOAXAXAXAXAOAXAOAOAXAOAOAOAOAXAOAXAOAXAXAOAXAXAOAXAXAXAXAOAOAXAOAOAXAOAXAXAXAXAOAOAOAOAXAOAXAOAOAOAOAXAOAXAXAOAOAOAOAOAXAOAXAXAXAOAOAXAOAXAXAOAXAXAXAXAXAXAOAXAXAOAOAXAOAOAOAOAOAOAOAXAOAXAOAOAXAOAOAOAXAOAOAOAOAXAOAOAXAXAXAOAOAOAOAOAXAXAOAOAXAXAXAXAXAXAOAXAXAXAOAOA...

output:

3858759680
2147483648
0
0
1073741824
956301312
2403336192
2415919104
0
2147483648
0
0
0
2147483648
3087007744
0
0
2147483648
0
0
2147483648
0
0
0
0
0
0
1073741824
0
2147483648
0
2013265920
0
0
3003121664
0
2147483648
0
0
0
0
2147483648
0
2147483648
4160749568
0
0
0
1283457024
0
0
0
0
0
0
0
0
2684354...

result:

ok 1000 lines

Test #94:

score: 10
Accepted
time: 400ms
memory: 62104kb

input:

1000 30 1000
AAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAAAAAOAAAAAAOAAAAAAXAAAAAAXAAAAAAOAAAAAAXAAAAAAO...

output:

1154274967
4131303149
3051793767
0
2730817243
0
0
1496030695
0
0
0
3597271915
4141127559
3652005169
3888321827
3746841979
2551227453
0
1301470651
1004181405
0
210123235
1369654409
1116404509
3845686437
0
534296377
39078771
0
0
0
0
948756041
0
249767565
62022055
798562203
0
0
2002797853
1579196561
0
...

result:

ok 1000 lines

Test #95:

score: 10
Accepted
time: 318ms
memory: 62152kb

input:

1000 30 1000
XOOXXXAXXOOOOAOXXXOXAOXXXOOAXOXXOOAXXXXOXAXOOXXXAXXXXOXAOXOOOXAOXOOOOAOXXOXXAXXXOOOAOOXOXXAOXOXXOAXOXOXOAXOXOXXAXXOOOOAOOXOXXAXOXOXXAXXOOOOAOOOXOXAOXXOXXAXOXOOOAOXXOOOAXOXOOOAOXOOOOAOOXXOXAOOXXOXAXXOOOXAXXXXXXAXOXXXOAOXXXXXAOXOXOXAXOXOOOAOXXOXXAOOXXXOAXOOXOOAXXOXOOAXXOOXXAXXOOOOAXOXXXOA...

output:

0
0
3275726848
1225388032
1692555264
3244064768
0
4074356736
0
0
3872669696
1747517440
85721088
0
0
0
1898446848
3893792768
81526784
3733270272
3943254016
281100288
0
496762880
0
0
0
3542614016
997556224
0
0
0
194020864
0
141918208
4076175360
0
2212560896
0
0
0
3159687168
2105147392
535953408
143543...

result:

ok 1000 lines

Test #96:

score: 10
Accepted
time: 453ms
memory: 62212kb

input:

1000 30 1000
XXXAAXAXXAAXAXXXOAXXOOXXAOXXXAAAAXOXXAAAAXAXAOOAAOAAOXXAOOAAXAAAOOOOXXOXAXXAOXAAXXAOAAOAAAAXAOXOAAAAXXAAAAAOXXOAOAXAAOAAAXAAAAAAOAAAOXOXAAAOAAAAOXOAOOAAAXXAOOOOAAOOAXXAXXOXAAAAAOOAOXAAXXAAAAAOXAAOOOAXAAOAOAAXAXAAAAAOAAOXAAAXAAAAOOAXAXAAOAOAAOOAAXAAAAXAXAAXXOAAAAOAOXXAOAAAAOOAAAXXAXXAAAO...

output:

2165975183
0
3105563879
0
339728911
3911815021
2584822065
0
2136424919
1839745351
885281853
0
3281625753
0
2032562291
224314717
0
3558443145
198725449
0
0
0
0
0
2771249661
1233710693
3802941099
1944572653
1553515117
3295154677
343122421
2160577615
0
0
3498721123
0
0
728650839
3931648193
1474927401
0...

result:

ok 1000 lines

Test #97:

score: 10
Accepted
time: 569ms
memory: 61580kb

input:

1000 30 1000
AAXAAAAOAAOXAAAAAOAXAAAAAAAAAAAAAAAAAXXAAAOOAAXAAAAAAXAAAAAAAAAAAAAAAAOAAAAAXAAAOXAOAAXOOOAAAAAXAAOAAAAAAAAOAAAAAXAAAAOAAAAAAOAAAAAOAXXAAAAAAAAAAOAOAAOAAAAAAAOAAAAAAAAAAAAAAAOXXAAAAXAAAAAXAAAAAAAAAAAAAAAXAAAAAAAAAAXAAAAAAAAAAAXAAAAAAAAAAAAAAAAAAAAAAAXAAAAAAAAAAOXAAAAAAAOAAAXAAOAAAAAAAAA...

output:

0
4104602689
0
0
1664464583
2326366601
2989352265
0
0
0
0
0
0
3111000431
0
3911716993
0
3838743313
0
1124157415
0
0
0
0
0
1008203465
2548730471
2522676047
0
0
4212250177
0
0
590884121
1962816097
0
3608482647
0
0
4257494409
0
89350977
14026025
536715551
0
0
3981276161
1544055423
2310224297
3799520025...

result:

ok 1000 lines

Test #98:

score: 10
Accepted
time: 329ms
memory: 61400kb

input:

1000 30 1000
OXOXXXOAOOXXAOXXOOXXXXAOAOXOOOOXXXXOXOOOXOAAOAXOXXOAOXXOXAXOOOXOOAXOXOXXOXOAAXOOXXOXXXOOOAOXOAXOXAOXOAAAXXXAAAOXXXXXOOXOXAOOAAAXOXAXXXOOOOXXAOOOOXOOOOXOXXOOAAAXOOXXOXXXXOAXAXOXOOXXAOOXAOAOOXOOOAXAAOXOOOXXXXXOXXXXXXXXXXOXOOXXXOAXXOOOOOXOOOXAAOOXXOOXOXOAOXOAAAXOOAOXOAOXXXOXOOXXAOXOOXXAXOX...

output:

0
2584084480
3415695360
2037972992
0
0
0
4587520
1648803840
2088108032
608960512
3835297792
0
0
276234240
1927675904
1036779520
0
612368384
0
0
2324928000
0
0
0
509345792
1157627904
0
0
0
0
0
0
0
0
657195008
0
3935666176
0
0
4068343808
0
0
3421306880
0
926121984
2132869120
3263430656
3952541696
0
0
...

result:

ok 1000 lines

Test #99:

score: 10
Accepted
time: 289ms
memory: 62152kb

input:

1000 30 1000
AAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAOAAOAAAAAAAAAAAAXAAAAAAAAAAAAAAAAAOAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAXAOAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAX...

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
738197504
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
813301760
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2147483648
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 1000 lines

Test #100:

score: 10
Accepted
time: 417ms
memory: 61804kb

input:

1000 30 1000
XAOOXXXOXXXXXOXXXOOOOXOXXXOXOXXOOXOXXOXOOXAXXXOXOOXOOXOXOXXOXOOOXOXOXOXOOXOOOOXXXXOOXXXOAOAOOAOXXOOXXXOXXOXXOXOXXAOXOXXXXXAOXXXOXXOOXOXOXOXOXOOOXXOXOOOOXXXOOXXOXOXXOOOOOOXOXAOXOXOOXOXOOOXOAXOXXXXXXOXOXOOOXAOAOAXOOXOXOXAAOXOOXXOOOXXOXOOOXAOXXOOOOXXOXOXXXOXOAXXOXOXOXXOXXOOOOOXXXOOXXXXXXOO...

output:

0
0
1391812695
0
0
3555437111
3096717649
2879965405
3713107211
427803905
2310679837
0
0
0
0
0
1096513089
0
2899160493
4005770775
1046843287
0
0
3222792247
3390469895
0
0
0
0
0
521433415
1054708343
0
1289686781
0
1788281921
0
0
1977045453
1410785451
1250558427
761090695
1960054525
401530555
0
2887679...

result:

ok 1000 lines