QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#423459#7518. GCD of Pattern MatchingpandapythonerTL 1999ms3880kbC++172.3kb2024-05-28 02:51:232024-05-28 02:51:23

Judging History

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

  • [2024-05-28 02:51:23]
  • 评测
  • 测评结果:TL
  • 用时:1999ms
  • 内存:3880kb
  • [2024-05-28 02:51:23]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops,fast-math")
// #pragma GCC target("avx,avx2")


#include <bits/stdc++.h>


using namespace std;


#define ll long long
#define flt double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()


const ll inf = 1e18;
mt19937 rnd(234);
const ll mod = 1e9 + 7;
typedef complex<flt> base;
const flt pi = atan2(1, 0) * 2;





int32_t main() {
    if (1) {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }
    int t;
    cin >> t;
    for (int itr = 0; itr < t; itr += 1) {
        int m;
        string s;
        cin >> m >> s;
        string f = s;
        sort(all(f));
        f.resize(unique(all(f)) - f.begin());
        assert((int)f.size() <= m);
        int n = (int)s.size();
        vector<int> a(n);
        for (int i = 0; i < n; i += 1) {
            a[i] = lower_bound(all(f), s[i]) - f.begin();
        }
        vector<int> p(m);
        for (int i = 0; i < m; i += 1) {
            p[i] = i;
        }
        unsigned ll rs = 0;
        unsigned ll x = 0;
        shuffle(all(p), rnd);
        for (int i = 0; i < n; i += 1) {
            x = x * m + p[a[i]];
        }
        vector<unsigned ll> vals(m);
        unsigned ll pwr = 1;
        for (int i = n - 1; i >= 0; i -= 1) {
            vals[a[i]] += pwr;
            pwr *= m;
        }
        for (ll r = 0; r < 300; r += 1) {
            for (int aboba = 0; aboba < 1; aboba += 1) {
                int i = rnd() % m;
                int j = rnd() % m;
                x -= vals[i] * p[i] + vals[j] * p[j];
                swap(p[i], p[j]);
                x += vals[i] * p[i] + vals[j] * p[j];
            }
            if(p[a[0]] == 0){
                continue;
            }
            /*
            shuffle(all(p), rnd);
            if (p[a[0]] == 0) {
                continue;
            }
            unsigned ll x = 0;
            for (int i = 0; i < m; i += 1) {
                x += vals[i] * p[i];
            }
            */
            if (rs == 0) {
                rs = x;
            } else if (x % rs != 0) {
                rs = gcd(rs, x);
            }
        }
        cout << rs << "\n";
    }
    return 0;
}

/*
1
16 abcdefghijklmnop

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
10 ccpcccpc
10 cpcpcp
10 cpc
4 cpccpc
4 dhcp

output:

10001
10101
1
65
3

result:

ok 5 number(s): "10001 10101 1 65 3"

Test #2:

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

input:

30
2 ab
3 abc
4 abcd
5 abcde
6 abcdef
7 abcdefg
8 abcdefgh
9 abcdefghi
10 abcdefghij
11 abcdefghijk
12 abcdefghijkl
13 abcdefghijklm
14 abcdefghijklmn
15 abcdefghijklmno
16 abcdefghijklmnop
16 a
16 ab
16 abc
16 abcd
16 abcde
16 abcdef
16 abcdefg
16 abcdefgh
16 abcdefghi
16 abcdefghij
16 abcdefghijk
...

output:

2
1
3
2
5
3
7
4
9
5
11
6
13
7
15
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok 30 numbers

Test #3:

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

input:

12
10 abccbaabc
10 abcdeedcba
10 abccbaabccba
3 abccbaabccba
4 abcddcba
4 abcddcbaabcddcba
5 online
5 onlie
6 online
3 ccc
10 ccc
16 aaaaaaaaaaaaaaaa

output:

3
11
11000011
2920
15
983055
1
2
1
13
111
1229782938247303441

result:

ok 12 numbers

Test #4:

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

input:

21
13 abcccbbaccca
11 abcdcdeebdcdca
15 abcdcdeebdcdca
11 abcdcdeebdcacd
15 abcdcdeebdcacd
12 abcdcdeebbae
14 abcbadcbabcd
14 abcbaccbacbb
14 aaaaaabaabbab
10 aaaaabaababbb
9 aaaaabaababb
14 aaaaabaabbaba
10 aaaaabbaabaab
11 aaaaabbabbaabb
14 aaaababbbbbaba
12 aaaabbababbb
12 aaabaabbabab
13 aabaaab...

output:

183
4
4
4
4
1
38221
183
1
1
820
1
1
12
24326193
145
133
157
1064
1
145

result:

ok 21 numbers

Test #5:

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

input:

21
13 acccabbcccba
11 acdcdbeedcdcba
15 acdcdbeedcdcba
11 dcacdbeedcdcba
15 dcacdbeedcdcba
12 eabbeedcdcba
14 dcbabcdabcba
14 bbcabccabcba
14 babbaabaaaaaa
10 bbbabaabaaaaa
9 bbabaabaaaaa
14 ababbaabaaaaa
10 baabaabbaaaaa
11 bbaabbabbaaaaa
14 ababbbbbabaaaa
12 bbbababbaaaa
12 bababbaabaaa
13 bbababa...

output:

915
4
4
4
4
5
38221
183
157
79
5740
157
79
516
24326193
1015
665
785
1064
11
1015

result:

ok 21 numbers

Test #6:

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

input:

96
15 abbbcaacccba
16 cabacaabbccba
16 bcbbaaccabcba
16 bbccaacbabcba
16 bcbabbccaacba
16 abcacbcaccbba
16 accabcbabcbba
15 ccaaabccbbba
15 bbaaabbbbbba
16 abababbbbba
11 abbaabaabbbbba
16 ababbaaabbbbba
16 abbbaaaabbbbba
11 bababaababbbba
11 bababaabbbba
12 aababaabbbba
15 bbaaabbbba
16 aaaabbaaabb...

output:

416
157
157
157
157
157
157
416
416
89
516
1921
731
86
117
1015
176
731
187
665
2011170
516
785
2989355
40543655
63
67
731
731
86
1921
176
1357265
416
1015
416
416
176
785
731
1357265
516
86
63
1015
117
86
516
731
67
665
187
1921
86
516
516
86
665
63
785
187
2011170
1921
89
117
665
2989355
40543655
...

result:

ok 96 numbers

Test #7:

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

input:

96
15 abcccaacbbba
16 abccbbaacabac
16 abcbaccaabbcb
16 abcbabcaaccbb
16 abcaaccbbabcb
16 abbccacbcacba
16 abbcbabcbacca
15 abbbccbaaacc
15 abbbbbbaaabb
16 abbbbbababa
11 abbbbbaabaabba
16 abbbbbaaabbaba
16 abbbbbaaaabbba
11 abbbbabaababab
11 abbbbaababab
12 abbbbaababaa
15 abbbbaaabb
16 abbbbaaabba...

output:

32
1
1
1
1
1
1
32
32
1
12
17
17
2
3
145
16
17
17
133
402234
12
157
2989355
40543655
3
1
17
17
2
17
16
271453
32
145
32
32
16
157
17
271453
12
2
3
145
3
2
12
17
1
133
17
17
2
12
12
2
133
3
157
17
402234
17
1
3
133
2989355
40543655
1
3
145
1
3
157
1
17
3
133
1
2989355
40543655
157
1
3
3
1
157
145
1
3
...

result:

ok 96 numbers

Test #8:

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

input:

100000
15 abbbcaacccba
16 cabacaabbccba
16 bcbbaaccabcba
16 bbccaacbabcba
16 bcbabbccaacba
16 abcacbcaccbba
16 accabcbabcbba
15 ccaaabccbbba
15 bbaaabbbbbba
16 abababbbbba
11 abbaabaabbbbba
16 ababbaaabbbbba
16 abbbaaaabbbbba
11 bababaababbbba
11 bababaabbbba
12 aababaabbbba
15 bbaaabbbba
16 aaaabba...

output:

416
157
157
157
157
157
157
416
416
89
516
1921
731
86
117
1015
176
731
187
665
2011170
516
785
2989355
40543655
63
67
731
731
86
1921
176
1357265
416
1015
416
416
176
785
731
1357265
516
86
63
1015
117
86
516
731
67
665
187
1921
86
516
516
86
665
63
785
187
2011170
1921
89
117
665
2989355
40543655
...

result:

ok 100000 numbers

Test #9:

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

input:

22
15 dacbcbdddaddcba
15 bacdcdddbaddcba
15 bdedacaebecdcba
15 bdddacadbdcdcba
15 baaadcaabdcdcba
15 bdcdacacbccdcba
16 acccacddbbcdcba
16 acaccaddbbcdcba
15 bdbdacabbbcdcba
15 badddcddbacdcba
15 bdadacaabacdcba
15 abcddadddbcbcad
15 abcddabdddcdcab
15 abcdcebeacadedb
15 abcdcdbdacadddb
15 abcdcdbaa...

output:

2651
2651
2651
2651
2651
2651
3003
77
2651
2651
2651
241
241
241
241
241
241
273
1
241
241
241

result:

ok 22 numbers

Test #10:

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

input:

237
12 aaaaaaaa
12 aaaaaaaaa
4 aaaaaaaaaa
13 aaaaaaaaaaa
16 aaaaaaaaaaaa
6 aaaaaaaaaaaaa
6 aaaaaaaaaaaaaa
14 aaaababbbbbaba
14 aaaabbabba
8 aaabaabbbaa
4 aaabaabbbaabba
11 aaabababaaaa
7 aaabababbabbaa
16 aaabbabaabbbaa
3 aaabbbaaba
7 aaabbbaabaaa
11 aaabbbbabbaa
5 aaabbbbbbaaa
8 aabaabbababa
7 aaba...

output:

39089245
469070941
349525
149346699503
18764998447377
2612138803
15672832819
24326193
75
89
145
14763
58
1921
44
208
156
3906
285
312
13
30583
70
16
29
468799645
58593
55
113
65
13
29
43
203
665
46873
1460
232
21
2343
65
516
73015558161
2380
51
32
1555
187245
53
35
116
1015
52
2121
285212689
78
4156...

result:

ok 237 numbers

Test #11:

score: 0
Accepted
time: 122ms
memory: 3632kb

input:

30580
14 aaababbbbbaa
14 bccaaccccbaa
6 ccaacbabbbbbbcba
11 bedadacba
8 dgfceaedabcbaa
13 ebdeeabcdcba
15 aabacacaacccccba
3 aababaaaaababaaa
16 acbbabbbbccba
16 accbacbcccba
15 feddcbafeddcba
13 baaaacacabcbaa
9 dcbaaaaadcbdcba
7 bbbbabbbba
15 acdddbbaccba
5 cacbaabcaaabacba
16 dabadcbcdcba
7 babab...

output:

197
45
9079
1
1
5
17
65620
53
3
170859376
29
31
16808
241
204
65793
2
117650
2651
1
7568149
248833
1
513
3
1285
3003
19136585
11
1
1
17
1
77
2
3
2
58
1111
82
22049
62
328
13
20
32045
244
33
1
65
1
1000001
1
3003
1
3003
290730444229
1
1
1885
1
7
823544
50401
93
1
116
14065
532171
1475827473
183
78
1
...

result:

ok 30580 numbers

Test #12:

score: 0
Accepted
time: 75ms
memory: 3636kb

input:

19914
9 abaccacbbcba
5 abcdebadcbed
12 hgfedcba
14 abacdbefgfhgib
13 abcdefdabcdefd
9 abbaabba
11 abcddbbcacad
5 aaaaaaabaaba
6 badcfefedcba
13 faedabcfcedcba
12 eabbecdccaaba
7 abcdefdefabc
5 abcdcdddddab
7 abcccdbddcbadb
9 cbbabcbaccba
16 abaaabababbbab
16 abcacccabcbbba
11 abcaddeddebc
6 aaaaaaaa...

output:

5740
601
1
1
62748518
65620
133
126
185
29
1
344
26
8
73
17895697
1
1332
15672832819
273
1
4161
11111
1
69810262081
1085
4
2
1
31
257
8
1
1
3
121
65793
1
1
1
2
1
1
273
10
10
2
7529537
105413505
452
1
37
1
730
164
85
252
1
1
8
11
1
1001
1
156
1
3
2
11390626
3
4
89
1
17
10
67
2
3
3
8
17
30941
13
49155...

result:

ok 19914 numbers

Test #13:

score: 0
Accepted
time: 392ms
memory: 3632kb

input:

100000
7 mkjpmkjppkjm
13 ybyzybyzzbbz
14 ifvnvifvnv
6 gpgggkkkkppkgk
10 werrrrrerewe
4 ssbsbbssbsbb
8 oinyydinnodn
14 qtttqqtttqqq
5 mpmmpmpmpppmpm
16 cymwll
9 cwmwmfwfwycy
13 tqqttqqt
7 qqrrzqqrrqzr
4 utuugtyutyygtu
6 gkbzkb
6 ifypccpyfill
11 bhyhsssshbyshs
9 mxmxmxmxmxmx
4 eexemmmxxxem
4 ejeedjddj...

output:

57
20
537825
29
101
12291
9
3165
3
1
82
399868
2353
29
1
35
2
3530369206
85
1
1
1
5
364
105
241
2
1001
665
1
43053283
28
1
366
157
4097
806
1333
16
2380
4
1
730
54466
170859376
1
5
20593
7
65
597871
9901
28393
4
14
13
197
268435457
26
1
197
1
1
182
3
2
391251
1885
1000001
1
3
17
3
1
1
49
16
1
32
274...

result:

ok 100000 numbers

Test #14:

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

input:

100000
11 fnffffxxxfnnnxff
4 tvo
5 zuuy
8 dzazddzdddzddzaz
9 xxsxxssxssxs
9 oiuooiuo
9 cycycc
11 eueuueeseususues
13 gtjvwuyvwuyvgtjv
9 sqssqqaqqaasaas
11 rrrrrr
13 vlvlvvvlvvll
10 tsttpptwwsspttw
14 ninmnininimimmni
10 hyoyqhoiobzywqh
9 sxjgibgeojixl
5 lylwlwlw
7 yyrsvsatvaasvyrt
14 wqqqqwqwwqqwwww...

output:

1464
1
1
4097
730
6562
2
16
28562
7381
177156
785
3
591
1
1
1
1
697
16
257
73
6481
77
1
14521
1
15
1
1
145
785
1
1
15
2
257
1
137858863143
164025000064
1
183
2
11
1
1
1
1
13
1
1
24888
1
6
3003
288240100
45
3
391251
16
128
1
91
1
64
4369
15
2
3
113
3
7
16
1
1
1
13
1
16385
40
1
65537
820
1
8
14
1
17
1...

result:

ok 100000 numbers

Test #15:

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

input:

100000
13 irqnk
13 hfknacfcqcncqn
12 pasppdsdcwt
14 jdceaecccejade
13 ppjppfmttjttfm
13 ndedewndedew
13 axpbbjpba
15 ytsfxaseeae
14 hfoppnhhbf
13 npxdxdnp
14 ztvnqluxzmoucz
13 ggfxfxsssfxg
14 lslmsqquszqml
14 attfgtfa
16 uglmtlmtdugd
13 lazualviuzibbv
15 easvosovoeav
12 zmrjoomrjz
14 usufqmqsmfmm
13...

output:

1
1
1
1
98
4826810
1
1
1
170
1
183
1
1
4097
14
211
13
197
53
4
1
16
15
1
1
38613
15
35831809
1
1
211
28393
226
4097
2745
43
157
1729
1
2
14
16777217
1
16
38221
1
1
1
2985985
1
1
2
157
16
53
273
1
4826810
1
2
273
157
38221
1
211
1
13
170859376
7
1
1
371294
50851
53
1
1
1
1
1
3
98
1
13
537825
1
28393
...

result:

ok 100000 numbers

Test #16:

score: 0
Accepted
time: 377ms
memory: 3576kb

input:

100000
15 cococcciccio
14 tqskqskqssqkkt
12 vfbvbwfbwbiiff
12 waaawwawaaaw
14 hwwwwwhhhh
15 aaaaaxxbxbax
16 otpddvhothvp
15 hhsdihddhkoxs
16 faourogfggff
15 jottjtttjtot
14 vhwuwwwvhwhwuh
14 jjqqqqjj
13 giiigiiiigig
15 hhhsssshshhhhs
13 orraoobaarbb
12 xrjbrjrbrxrb
12 kkqqkkkqqkkq
13 gfttgffgggtg
14...

output:

211
15
13
1
41371
226
17
1
1
211
15
2955
28
16
183
133
20593
183
540765
1
14
4829007
15
2745
183
1
373660
5
1048577
38613
98
1
183
1048577
1052929
7
1
98
2
2
7
50626
1015
170859376
187
35831809
4369
11
1
30583
8
2
13
250705
1
3
4826810
13
50401
15
11
4826810
65
30583
762976
1921
183
273
41371
1
2432...

result:

ok 100000 numbers

Test #17:

score: 0
Accepted
time: 399ms
memory: 3868kb

input:

100000
16 xbwbpxbwbpxbwbp
14 xdeeeexdxdxddxxx
15 ftngoxoxngft
13 ooooow
12 kotkbyktykotyobt
16 lugfwllugfwl
16 izfkfzzkkfifffi
12 iyaveivbbc
15 jeoyootteoyj
13 xkmmmrmmhxxxkmhr
15 gshgghhwbhsssgwb
14 joqdwkqwokdq
16 whdwhwhdwhwhddd
16 dsencgesdecsnpg
16 ccddccccdddcdc
13 ynyfvnnynyfv
14 jlezlwleeezj...

output:

1099512676353
3
226
1
5
16777217
273
1
16
2
16
1
5
1
113
14
15
3
1
2
815759283
371294
1
2745
157
1
1
1
2
1
1
4369
17
1
3003
1
157
23298900881764
38221
1
3
50626
32
1
1
3
77
1475789057
1
1
170
28562
65281
1885
1
1
35831809
883306230
1
11441476
1
1
3006865
2
1
1
53
1
1
1
241
62748518
65537
1
1
1
14
20...

result:

ok 100000 numbers

Test #18:

score: 0
Accepted
time: 393ms
memory: 3576kb

input:

100000
16 pssssspssssssps
12 rsssrc
12 llaaflfaffff
14 pgivzqqqqgivzpqp
14 pnpnpppnpnnnnppp
13 qqqqqqqqqqq
15 jjgjjjgjjjjjjgjg
16 qcccccqcqqqcqcc
13 haahahhhah
16 pgpggzzzppzpzgz
14 jjljlllljljljjj
16 rrorrooorrorrooo
16 hezhhezhhezh
12 tnccrcn
14 lrrrrlrrrrll
12 beojbeojbeoj
13 uzxtmyglmzgy
12 qqnn...

output:

3
1
157
1
123
149346699503
64
3
22
1
1
73014444049
4295032833
1
8865
430002433
1
1261
3003
273
399868
1
2745
665
183
1
24326193
226
187
157
1
3
273
20
7568149
157
1
1
145
85
2
1
915
2562890626
2
429981697
1
7568149
1
1
2198
273
1
1
197
1
1
197
1
13
1
10
1
2
228496
17
799736
1
255
3376
16
3
16
1
1
21...

result:

ok 100000 numbers

Test #19:

score: 0
Accepted
time: 1955ms
memory: 3644kb

input:

500000
16 rbrbrbbrrbbrrrr
13 sassssaasaasaas
3 zz
10 zzzzz
6 bibbibbiibiiibbi
10 ppppppppppppppp
2 xxmxmmxmmxxxm
12 rrrrrrrrrrrr
4 ccoc
12 pppppppppp
2 kkkkkkkkkk
10 bbbbbbbbb
8 vdd
5 ooooooooooo
15 xuxx
14 saassasaa
15 n
3 ddddddddd
7 hhh
10 yyyyyyyyyyy
2 l
5 eeeeeeeeeeeeee
10 kkktttttkktk
15 sssss...

output:

3
1
4
11111
119
111111111111111
6734
810554586205
1
5628851293
1023
111111111
1
12207031
1
1
1
9841
57
11111111111
1
1525878906
33
54241
1
1093
43
1
7
3
11
31
6
1
29524
1
1
111
1
1
273
1
469172025408063616
299593
13
4265491084507563
1
883708281
47989
1
1
14
8
31
116719860413533
597871
1
1
960800
610...

result:

ok 500000 numbers

Test #20:

score: 0
Accepted
time: 1957ms
memory: 3876kb

input:

500000
11 llbbbbblbbbllbbl
13 lbl
14 oeoeeeeoeeeooo
5 phhpphpphh
11 dtttt
5 oooooqqqooq
8 jf
8 aaaff
14 ubbubuuuububbub
15 ssssssssfffs
3 zzqzqqzq
3 nnsnnnnsn
9 kokookkok
4 ccscscccccsss
7 iimm
7 caccacaacaaa
6 xffxfxxfxffxfxxf
15 qn
10 qr
4 tftftftftfftfft
16 iffiiififiiii
6 sssbssbbb
6 ajaaaaj
5 y...

output:

2
1
15
781
1
1
1
1
1
241
40
1
1
1
8
1
435020803
1
1
1
1
1
1
6
1
1
1
1
1
1
1
1
17008
7
1
1
1
1
47909
1
1
1
1
1
1
1
1
1
1
1
5
15
1
1
2
1
1
1
1
1
1
1
1
1
1
1
7
1
1
1
1
1
1
10609328380
1
1
1
1
5
1
51
1
1
1
1
11
12291
1
1
1
1
1
1
1
1
183
1
1
197
1
1
126
1
1
1
1
1
1
1
175
1440
1
1
1
1
23
1
3595
1
22
1
266...

result:

ok 500000 numbers

Test #21:

score: 0
Accepted
time: 1944ms
memory: 3628kb

input:

500000
13 qqrqdddqdd
13 fnnfffnfccffcfc
15 dddd
4 ppppppppppppppp
12 okkkokkkkkkkoko
10 g
16 oooooooooooooooo
9 sjssjjs
7 zzzzzzzzzzzzz
15 eeew
15 qwjjjw
14 yyiyyiiyyiiyiyyi
3 nhhhhnnnhhhn
14 eneeneneeneen
9 qr
8 hh
16 uufulufullul
3 jjj
15 x
16 hhhhhh
7 m
10 jjjjjjjjjjj
14 zzpppzj
10 bbbbbbbbbbbb
1...

output:

1
1
3616
357913941
1
1
1229782938247303441
1
16148168401
1
1
17
1
1
1
9
1
13
1
1118481
1
11111111111
1
111111111111
1
22621
1
1
1
1
4594972986357216
113037178808
62748518
1
2745
1
231627523606480
183063616
1
6
1
2859599056870
4
1
10001
1
1
1
156
1
15
1
564221981491
1
2
1
13
1
15672832819
6725601
17
...

result:

ok 500000 numbers

Test #22:

score: 0
Accepted
time: 1926ms
memory: 3576kb

input:

500000
16 clbbb
16 ilil
10 ojjv
8 pplplwpwppww
14 ehhchccece
9 bbbobbboo
11 cdddc
10 pk
14 avaavvvavava
8 eeeemmmmem
7 hzrz
5 ssosos
10 umjmmjujuju
7 wbwibwbbbiiibbiw
12 vfvvffvvvvff
3 eeggee
12 brlrbllbllrblll
15 lmnln
8 rgrggrgrrrr
5 zzqzxzzxxqzxxqqx
3 pkkkkkkppkkkkkkk
12 uuouxxoo
4 tvtvmv
16 tbtb...

output:

1
257
1
1
1
91
1
1
1
1
1
2
1
5
7
4
1
1
1
6
5
1
1
1
1
1
5
13
1
1
1
1
1
1
10
1
1
241
1
1
1
1
12
1
1
1
1
1
1
1
3
1
1
3
3
1
1
1
1
1
1
1
2
1
1
1
4
1
4
1
1
1
1
1
1
1
1
1
10
1
1
1
1
10
1
1
1
11
1
1
12
1
12
1
1
1
1
1
1
8
1
2
1
1
1
1
3
1
1
1
1
1
51
1
1
1
1
6
1
1
211
1
2
1
1
2
1
1
1
1
1
1
17
2
1
1
1
1
3
1
1
1...

result:

ok 500000 numbers

Test #23:

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

input:

500000
6 iwciwwcw
7 gsgssslgllggss
3 txtatxxattaxt
7 mwx
15 pjppccpj
4 gybybbbbb
13 mxmxtxmm
15 ccaccffaaf
8 jdjw
4 zzzzzuquzuzqzzzu
5 ycooo
15 byebebye
14 jaamjmmajajaja
12 thtuht
10 qqjjqjqjpqp
14 drwww
7 nzfznfnzff
12 gcz
16 kns
3 xoxxpo
10 hhmwmmmhhwwh
5 ndvvvnvnd
4 wkrw
13 gzyyyzzzygzy
8 auucuu...

output:

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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
11
1
1
1
1
1
1
1
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
1
1
1
1
1
1
1
1
1
1
1
5
1
1
1
13
2
2
1
1
1
12
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
15
1
1
1
1
1
1
1
1
1
4
1
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #24:

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

input:

500000
14 ff
14 feifyyifffyi
11 ppppppppppppp
8 iyiigggigiyyygy
12 hhvhvmmhhfvmhh
10 kkii
14 llflloofflffofol
13 iygiggiyiyyigyyi
16 chcococohco
15 xdddxxdxddxdxxx
16 vvvvvvvvvvvvvvvv
14 ffff
7 ookt
16 zazzzfff
5 la
16 rppppprrprr
10 ccccccc
16 ucuuyjjyjcujcyju
6 v
5 xtgdt
8 agadadaddagdaga
5 rjraar...

output:

15
1
3452271214393
1
1
11
1
2
1
1
1229782938247303441
2955
1
1
1
1
1111111
1
1
1
1
4
94036996915
1
1
19173961
400
1
1
1
1
15
1
1
1
1
1
1
72559411
328114698808274
1
1
1
1
1
1
17
1
10
94036996915
11
1
1
1
1
67546215517
72559411
1
820
628292358729
1
1
16
1
1
1
1
1
177156
1
22369621
2
3
1
1
1
1
76861433...

result:

ok 500000 numbers

Test #25:

score: 0
Accepted
time: 1969ms
memory: 3692kb

input:

500000
7 fypiyfyiifpypyff
16 cccccczczzc
10 vh
5 rcd
8 xvvkxvvvvvkxdk
12 tutumo
15 rrrilr
10 bdh
10 tgtwtwggwtwwg
4 btbqqgtgggqgtt
12 fziiiizfiffzzz
16 dndnddeemmnmd
13 hahhaahahaaahahh
9 dydyyy
12 wjajjrjwr
15 ssspzvzpzv
13 cbbcbcbbbbccp
10 vdho
14 lffololofffql
13 wmbbwbkbmmbmkkw
5 tuuuuttuututuut...

output:

1
1
1
1
1
1
1
1
1
1
1
1
8
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
11
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
15
1
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
12
1
1
1
1
1
1
1
1
1
4
1
1
1
2
1
1
1
1
1
1
14
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
9
1
1
1
1
1
1
1
1
1
1
1
513
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #26:

score: 0
Accepted
time: 1926ms
memory: 3580kb

input:

500000
16 dddgggdjgdjd
7 kbzmbbbkkbz
16 lyq
6 zmzzuzzummuuzm
8 eheedhpehpepphp
10 oaeooeaooaoeaa
5 wkip
9 jbss
15 dhfr
13 kffmffrrrfrkmff
4 cffafaf
14 ybq
15 ececeoeeoo
8 uquiq
10 rruluurrlluur
6 vxjjjj
6 eeexxnxsee
9 xqoxcxqoc
11 kckglgllklgkg
9 rqjqqprp
8 jcp
5 cinccen
9 qbqqqjtjqjt
15 ejererll
4 ...

output:

17
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
20
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
6
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
2
2
1
1
1
1
1
5
2
1
1
1
1
1
1
2
1
1
1
1
1
6
...

result:

ok 500000 numbers

Test #27:

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

input:

500000
13 oizfz
10 lnenelnlkkkkenk
13 gxrgxrpppp
8 ilcipl
4 lwlgwlgeee
12 httthttxxeht
15 lskksclc
14 qmqqmmbzb
15 nnqqhnzqz
12 cogchg
10 dgzzgggqzzqzqgdg
4 immmmwwwmiiiilm
6 haalelhl
12 ccpwppctwcp
13 lkqkklkhkkl
6 ryhfyyryfhrfrhfr
12 ddcenn
12 oojttotoff
13 ustsssspttp
10 ssfpspfspccfpf
4 uuvfvfuu...

output:

1
1
14
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
11
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
10
1
1
1
1
1
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 500000 numbers

Test #28:

score: 0
Accepted
time: 1880ms
memory: 3580kb

input:

500000
14 pvvvpppp
16 tctmmymtcyssysy
12 pqqztbq
11 somvvmvvvmgvvs
15 iiiiiiiiiii
11 vggtvgln
14 ihiisxxhhi
15 bbb
16 rrrrrrrr
11 llllllllllll
14 jjjjqjqqjjq
7 ggievvyy
7 sssssssssss
8 xuoxux
7 wbbew
16 wxwwxxxxxxx
10 ooooooo
12 wbwbwwwb
7 eaaea
6 ofooffofoooo
9 fjujuuuffjuj
14 tttt
10 mhlbh
14 mee
...

output:

1
1
1
1
617839704241
1
1
241
286331153
313842837672
1
1
329554457
1
1
1
1111111
1
1
1
1
2955
1
1
1
50
1
9726655034461
1
1
2
12
1
1
1
781
37974983358324
111
1
72559411
1
1
1
1
67546215517
1
1
1
1
3
1
1
13
6
1
435356467
1
1
1
1
1
1
25239592216021
1
1
1
1
1
1
1
1
1
1
11
1
1
1
1
1
1
1
5026338869833
1111...

result:

ok 500000 numbers

Test #29:

score: 0
Accepted
time: 1903ms
memory: 3828kb

input:

500000
11 yh
7 fqeqqfefeefeffe
13 esycl
11 qbkqkkkqbbbkk
14 vvwvvww
8 lnzlccczlc
16 jcjjkju
9 yhwh
14 lllq
13 kgbb
7 mmiimmiiimmmmimi
6 wyq
11 ztzttzzzzt
14 mppmnmm
12 ppppzz
6 eeeeeg
15 rl
13 oeueumoumooemoo
11 ldyppppdlddyl
10 ioeoxf
15 cm
5 xwpa
16 fifiifi
12 gxbg
5 qqqqttqtttt
11 rrhrj
7 xxxhhxa...

output:

1
3
1
1
1
1
1
1
1
1
1
1
2
1
13
1
1
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4369
3376
1
1
1
1
1
1
1
1
1
157
1
1
1
1
1
1
1
1
1
1
17
1
1
1
1
1
1
1
1
1
1
1
1
4
1
1
3
1
1
1
1
1
1
1
1
2
1
1
1
24
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
12
1
1
1
3
1
1
12
1
1
1
1
1
1
1
8
1
1
1
1
1
73
1
1
1
1
1
1
6
1
1
1
1
...

result:

ok 500000 numbers

Test #30:

score: 0
Accepted
time: 1914ms
memory: 3512kb

input:

500000
7 yycctctyc
8 vnxn
11 cbl
8 dndnnygygng
7 ggndngddgvnvvvn
14 vvettttg
7 nzjj
15 cphpchwwkk
15 lyklkyaytaktt
13 ybxbw
7 jljdjrrljdd
9 ghkhkghkkkhkhh
5 abgj
15 vvdvoddvo
10 yqwwqoy
11 xoxkyu
11 lleefoorffofl
5 coycdybb
11 bxzphzb
12 qop
16 rggtgrgtrgr
5 gegeeegle
8 qqxxlqxllqqxlqx
15 httxxhnx
5...

output:

1
1
1
1
1
1
1
2
1
1
1
10
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
8
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
14
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #31:

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

input:

500000
12 llhmllflhfjml
5 gpor
13 fllghhhgfl
14 sdddqchhsq
10 szsziixz
7 iyfmflyyfy
7 gtrgtgrk
13 uzjzjjgggzuggjgu
16 yoiird
7 ttthhotgghfothfh
16 eygyglelxllx
14 zfvzzqvavqaz
16 ohfhhovfvh
6 pxfxxnixnfxiipx
8 ppacdbddpccbbpp
8 jjjfffwor
14 zaaet
12 ycinn
10 cebbgbgceceebcgb
13 rlqlqouuurrouou
5 blg...

output:

1
1
1
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
9
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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
1
1
1
1
...

result:

ok 500000 numbers

Test #32:

score: 0
Accepted
time: 1937ms
memory: 3640kb

input:

500000
13 pukuqnnpp
11 yqtsqysvtyvvys
5 njpiw
16 xvyxxsyzy
9 sffrzfsszrccss
9 bjuuugjubgguduub
6 rrbbrrjwjbxrjwxj
11 mmjxjbimjjxbiij
5 gagcattgtarrcac
9 phjpjfjjjfhpvfvp
11 stwzswwmzsz
11 ftplss
5 tvjveeecv
14 yeyfhehk
15 gaanwbawwb
9 ucumomcmmyyo
16 xyacooxxya
14 eelnngngzeennl
15 umummiey
11 wwssg...

output:

1
1
2
1
1
1
1
1
1
1
1
1
2
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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
1
1
1
...

result:

ok 500000 numbers

Test #33:

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

input:

500000
13 lxqxll
16 aacfaawcxwwwwc
8 mhfakjfj
12 fffffffffff
9 tgftggkg
16 sdxkd
15 ccccccccccc
15 htttojdjbjoj
13 ggrqqr
10 rrcrekell
7 jyjjjyjyjyjjj
12 tvvveffe
7 bbb
7 llll
11 cccccccccccccc
12 wwwrkwkrwrw
10 z
11 pmmg
16 kdnkndnwd
13 iiiiiii
14 hfheb
11 eayul
10 cioii
8 ttt
7 g
10 nnnnnnnnnnnn
1...

output:

1
1
1
67546215517
1
1
617839704241
1
14
1
1
1
57
400
37974983358324
1
1
1
1
5229043
1
1
1
73
1
111111111111
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
7
4594972986357216
50
1
1
1
1
1
11488207654
1
1
1
1
1
1
259
1
1
41371
19173961
1
1
1
1
1
1
1
1
1
25736391511831
1
1
31278135027204241
1
14
1
37449
78536544841
1
1...

result:

ok 500000 numbers

Test #34:

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

input:

500000
6 il
15 qjn
8 zkdm
13 imbmfrriqfbrrmqb
10 ozomsomosszsomm
6 swxu
14 hohocho
7 xxjjjjxppjxpx
14 xpzjlzdx
15 nnnllnnn
10 zzzzzzzzuuuuu
11 bbbcbxcccbxbx
12 dptxpjjpdxxnjnn
14 ououuouuuouooo
12 jcfpm
13 ssyy
11 jhajadjaid
8 ddbdbbddd
6 liuruirmmrxulxiu
8 iiuuuf
13 kj
7 jzvy
16 rtrrstrstttsstrt
6 ...

output:

1
1
1
1
1
1
1
1
1
16
1
1
1
1
1
14
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
5
1
1
1
1
1
1
1
1
1
1
1
585
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
15
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
1
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
11
1
1
2
3
1
1
1
1
1
1
1
3
1
1
...

result:

ok 500000 numbers

Test #35:

score: 0
Accepted
time: 1920ms
memory: 3632kb

input:

500000
10 miimjipijyi
14 beaebeeage
7 sghsshgmnh
12 jerletrjtrle
6 fkkqfvkzkvfqz
15 qhqhzyzzqqjy
11 vygwybvwbgr
6 aqtatatt
13 mieiinnezmeixie
11 wokww
14 gmzmvgzvgmm
14 rwcccepceru
9 mhmhwwbccmtttw
13 ygiy
10 rraikkdazzkiddak
12 wfkxxwzxwwkxw
6 hqhtnt
12 lxnpnxlnn
10 dduduuuuudt
15 tozddnncd
16 zfee...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
10
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
12
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
11
1
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
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
1
1
14
...

result:

ok 500000 numbers

Test #36:

score: 0
Accepted
time: 1934ms
memory: 3632kb

input:

500000
9 xtxtmswmxdst
7 qezv
9 raardeccrsdscrr
10 lhdhhdhvyy
7 vvebhcheebbvefev
7 lwwglatblwlb
6 bbopf
8 onroknqqnkyq
11 amlc
11 wfrqjrfqj
7 drqdz
14 glzltwlwdlg
13 yzozzqzyyoz
13 woowxwwr
6 fecqy
11 vvvtvtcammatccvv
14 pzcczpam
14 mmkigpbg
7 suaqafeq
11 fcszg
6 xxoouomm
10 ksklllswclclk
12 ggwuswkg...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #37:

score: 0
Accepted
time: 1935ms
memory: 3576kb

input:

500000
11 ilmtwvtw
11 gvbvgallllaoaoo
6 eckaammm
8 dhwdnko
9 lbouyu
11 kbgrdo
7 bxaxvoapbpvop
14 zqzeggeqzpggeggp
12 kblukkuruqr
16 pooloonnlddloln
8 gkkpxpooxxp
16 lkcrlrchkklr
9 jqpcpbcjbjlcppbq
16 ryvdhdvvhryyy
9 ilvltjrl
6 lllwwiwjjjblil
9 oxjstk
16 rkckkzkrkiizrr
8 fygddiifdynfnffy
6 ayixqqqiqq...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #38:

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

input:

500000
15 vfdnvdffpvddft
13 ttpvpmnj
8 nullszuvlsn
8 iixxaoexxq
15 dajmitmmi
10 wclcnolwoala
16 harhfazfzfaorrr
8 wqcxcgwt
16 sgasmtmgfs
6 eofvovtc
13 xnmkxnukw
13 owwbovht
6 izqazjjqamjamjmm
15 kkgakfjajd
16 rfntjl
6 nsfsmgfimgsi
10 jdmxgyx
6 lwxcxcywllck
12 vqnyknwqk
14 mpfano
13 mjranbmramrrmrjr
...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
5
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #39:

score: 0
Accepted
time: 1872ms
memory: 3568kb

input:

500000
11 ycqkyiuy
13 nqqlnvqinqlqn
7 qp
13 y
15 tbkvo
8 mhgmmhmggmgg
15 looooooll
7 aonpwft
14 fvpfpfppfpv
9 wpoprpwppowrrowr
14 fqkkkqfx
11 ppqqqpqpqqp
7 xvxxxxxvvvvxv
11 tt
14 yyo
12 lllllll
8 ocfdeh
11 h
7 pqfsfspqspff
15 xzoz
16 anapnpnp
11 gemk
12 ooblofflbolfof
14 xssnpyysspyjxns
16 hqllrlllr...

output:

1
1
1
1
1
1
241
3
1
1
1
1
1
12
1
3257437
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
883708281
1
3
1
1
1
1
64
10
1
2380
91
1
1
1
1
1
1
183
597871
1
1
1
1
1
1
17
226
1
1
1
1
9817068105
1
10
1
1
1
1
1
1
1
1
1
1
1
1
2955
1
1
1
12
1
1
1
13
1
1
1
1
40210710958665
1
1
1
1
1
1
1
1
2306881200
19608
1
1
1111
1
1
1
1
1
1
2...

result:

ok 500000 numbers

Test #40:

score: 0
Accepted
time: 1901ms
memory: 3640kb

input:

500000
14 ldlklwkkdddd
12 tbtheepwhx
11 yhehcmdvd
7 yrddyyyrdyrd
16 ayyssywaayyyrwa
13 qqqqeeqeeeeqee
11 imzimzmzizzm
16 pwfwfpppfppfff
12 wllwwww
16 yyw
14 ufuuufuufffffff
8 bolhhbobl
9 st
15 bcmcbcccmm
16 lngxl
11 cguicbgbcttg
9 uuqquququuuuqu
14 eve
7 usnus
7 wwwsvyssynsn
10 cqgsqc
10 ffmmmfmfmfm...

output:

1
1
1
1
1
98
1
1
1
1
31
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
13
1
1
1
1
1
273
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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
1
1
1
1
1
1
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
101
1...

result:

ok 500000 numbers

Test #41:

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

input:

500000
10 kaudbwaeuw
8 wewjwjejwwje
8 ucrctrkrk
10 xlyiniltddl
10 munmjucmnjjjumju
8 xwu
15 yfu
10 jare
13 whu
8 yyyybtkbybyrftky
15 mbwmiweiwwm
7 pxkdjo
14 zpxxz
8 ndlxlldadl
16 iivjgjjvjgiijg
11 tatattaatiaooiia
7 sxzzix
15 ywlywkjywylljn
12 cvgds
16 rrrrrreeqqer
15 tstlltpru
11 iifrir
7 gdbxkun
7...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
9
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #42:

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

input:

500000
13 hfippf
11 awfnxf
11 xztxzuzxttuuzxux
10 fxdwgh
15 lnghghtmhttlht
15 jlilrroaiajjcrr
15 prrwrnzooyo
16 yylxhkxdxklb
8 ynbmnz
11 bbcnvcojcj
14 oguysplolp
16 nnzzntnxtxvxv
9 vrhrnvkhk
12 ewpzzzie
9 njjrrrcjjnjrjrr
14 bccwbcmcm
15 exdrz
11 yqztgyt
15 nwwxnxhnaxw
14 omvk
16 wwkkbafnznfwkf
11 rz...

output:

1
1
1
1
1
1
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
14
1
1
1
1...

result:

ok 500000 numbers

Test #43:

score: 0
Accepted
time: 1944ms
memory: 3640kb

input:

500000
11 eogamjav
10 ttvggglct
7 hiiaahjist
10 avebeoeaevvvoeo
13 eyseyjqsqjnp
16 isyxssiyiwsos
9 ylgyhjpgm
10 kexdxrrdqlkkxqxx
10 kxjtgs
15 jrippgpj
14 jbfiijaoa
11 ggttxiwh
8 fwjqvvqdwjkqwjwf
16 kenykpbk
13 ffvhduhttd
8 jlasp
7 xgmsmllsz
13 yyppsygggzzp
9 kxstkstlrrxg
11 vvbhcwt
15 xnmvgdnbn
16 e...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #44:

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

input:

500000
9 azirveez
15 omojsvvkf
7 ayjhuufjhffsusf
8 ocaorclohccrah
9 ccgcgoyzyzyhoohh
15 opffooxyzsoxpoo
15 fafxyflzfyzo
16 dqejtttfjfejf
11 tnccadx
8 jlcvlbfl
13 eazsaeesjzsjsnjs
14 fntrfererfcknrr
10 uohikhq
15 cscezzcrfr
7 enslbylysmlse
16 hnfrbanafas
9 bxzembmxzesssa
11 rbtxborjooj
10 hnjicujmnn
...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
...

result:

ok 500000 numbers

Test #45:

score: 0
Accepted
time: 1966ms
memory: 3576kb

input:

500000
11 nqjqsunjwjqwscuj
10 jzzwsgajl
12 zgpzcvvgpccoobbo
7 llqqyeclbfqcb
8 brenllalevrvn
16 adoqdaqdouemeaoq
14 hfekmhjdj
13 xxrrhzqaaal
7 fsczmoox
16 wcxcbkwutt
13 hbdcptvc
8 csmkmxpr
7 ozylubk
13 vxvzxvvpqxrkp
9 etpbqppgy
10 sarfuiz
8 wfmxsrqrr
12 aaqowhjqg
9 smjumtutsay
13 pfywcvvty
13 fedeotc...

output:

1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #46:

score: 0
Accepted
time: 1873ms
memory: 3632kb

input:

500000
16 ppppppp
13 aimiaiammi
12 jnwaenhhhpa
11 eweeeeweaaewa
9 mmmh
15 bobvfvzbeplf
13 r
8 iiiiiiiii
16 yrxrddrd
15 ddhbciicihdbdbi
10 odgdgdmdomddo
16 pwwhiihuupbnpu
10 zcczc
16 xx
12 llhiihhi
11 erricirrlcris
15 wowppupwpu
10 shwhhwhhwh
13 etltl
11 ejeejeejjejejjee
10 lllllllll
14 cnccnnnnnncnn...

output:

17895697
1
1
1
1
1
1
19173961
1
1
1
1
1
17
1
1
1
1
1
1
111111111
1
1
73
1
1
1
1
1
1
1
1
1
17
1
1
1
82
1
1
9
1
1
1
1
16
1
1
1
1
1
2859599056870
1
1172812402961
13
1
1
2955
1
1
1
1
1
1
1
1
1
1
1
17
3
1
1
1
1
1
1
1
1
8108731
1
139013933454241
1
10
11111
1
1
2
1
1
183
1
585
1
1
1
2
1
1
3616
1
1
1
585
1
...

result:

ok 500000 numbers

Test #47:

score: 0
Accepted
time: 1898ms
memory: 3880kb

input:

500000
13 gq
12 aaallavvvv
11 izerciu
10 bs
12 hkzsu
8 xt
14 mbmjmmzqjbmj
15 peiujr
14 klmzhrehm
11 jcuyuhpyu
10 duemxmx
11 ssw
10 pqxldlxfqfl
16 qcqf
8 nvxxvm
10 wvotbosbooo
10 nssdnsdd
12 ccyrzbyrbnwbnw
12 kittywqwe
9 ngcffgfgcggng
11 fjquqfqjqjfyjyqu
10 azb
13 gkvkgassvuvkg
12 sr
14 oiddior
16 cz...

output:

1
13
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
16
1
1
1
1
1
1
1
17
1
1
1
3
759376
1
1
1
1
1
1
1
1
17
1
1
1
1
1
122
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
7
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
7
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
366
1
1
1
1
1
1
1
1
1
10
1
1
1
1
1
...

result:

ok 500000 numbers

Test #48:

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

input:

500000
11 usl
9 vovvttvvvvvottov
10 jnxdmkkxmxx
16 yjdxkrdyyq
11 qrqyrl
11 zysmcycscczyttms
11 errpg
14 zxlhvoggpzg
12 joorardoj
11 ted
16 ggwfuwwpp
9 prpxrx
13 mva
11 nxbs
15 nnxnmqmlxhhfx
14 wpgno
16 eyurucrc
14 laakgkfuflglhah
9 ffxfqmmiqfq
8 oihtfv
9 opofopmpcff
14 htmszzs
14 vene
12 rlurfhg
8 a...

output:

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

result:

ok 500000 numbers

Test #49:

score: 0
Accepted
time: 1926ms
memory: 3580kb

input:

500000
9 dtqkkmr
10 lzzltlttkkk
14 rnerddaeryvonvyr
10 mwmmwmmmzn
13 ogrugrbprbqmqp
12 jaajsyiislljnjs
15 rlsstsr
11 qqlqgrr
13 lmmorssramvj
16 nxjrw
12 hhzvzihqvhqivz
11 cblkgklanoack
8 junjcnncncnun
9 pkciccjjck
13 nbkgnbeckcebn
13 asmaogxexxa
12 dcvo
10 ttwwlio
16 bqfxpxht
15 nrfllyfyrlrnlnn
8 ba...

output:

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

result:

ok 500000 numbers

Test #50:

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

input:

500000
10 enwndwmqqdqemmm
15 ncsumsbnt
13 cbxybav
8 cpahhikddkhicnip
11 rkobkvezvzl
15 iavbgbexavexig
14 ifibddbdbiffx
9 xhfrxrxbwhafew
8 rvhdxkhx
8 lfflxxbbxhxh
16 meejvum
11 kjxuuxw
11 hxyijjyaajpy
16 ulclxuxccg
12 qwgiwtiqqgiqttw
11 jjhjchjnqhcucucu
14 ejyiifhh
14 kpnifwrj
10 wwwwlujwlf
11 sjfae
...

output:

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

result:

ok 500000 numbers

Test #51:

score: 0
Accepted
time: 1952ms
memory: 3640kb

input:

500000
14 ehspvmsseibeib
10 artroiq
9 plmczpvkkvfvc
8 oroqneoraqe
11 sdwndnhdhg
16 xfxxbzkjfmzjmx
14 gchsyjagayjgcac
11 jvvgvfhwlfphj
16 ieeicwwssnemwzc
10 lmodwociiiym
8 xbdgkl
12 fhgncgcccnmm
13 shlpwwhqtqdl
11 rsznznuhrr
8 vledhmlmjmhhzdme
15 lhxgdnju
13 enbhbhneemvtvp
11 xykdkqxdc
16 qlljalbhuc
...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #52:

score: 0
Accepted
time: 1970ms
memory: 3796kb

input:

500000
8 qsooopuusuuuprsd
9 xpqooplookpllkh
13 rphqbsnub
15 rsgtrlrbrlzwr
8 vueduffftutviiep
14 afbbkfxaery
10 ypszsjyxcje
8 dgadedkaddhv
14 dmeuyzyluf
10 jwvwwjjrrzjzohvw
9 veyyqphqpdhdq
13 rqydvdtpg
16 juxuivvrjjz
15 zzixhlikj
10 rbrqqhlnmlqm
11 xbzvyeazbexabby
12 jgzleblgtjegbe
13 nrcywqi
10 cddg...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
7
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
7
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #53:

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

input:

500000
14 bzfgszssgfxxsfqc
8 jdqagorggajn
13 xtnllftqkfzz
11 mmyxbjour
12 hchzbmdtl
9 pgqunwzqquyp
16 zxsxvcxbbzmvxsd
9 yteqxdqwodqewdye
14 ptsgtkktocoj
10 weatawifwifdyitw
11 zragobglm
16 lhugjmea
10 jmnjntzvrnxt
9 htzmnftfhmofwh
9 ksaoplzn
12 zcpkmvbzkg
8 joohgyahsr
9 chlysifnh
10 tppcnufcauub
9 k...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
7
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
7
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
7
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #54:

score: 0
Accepted
time: 1875ms
memory: 3880kb

input:

500000
11 jb
13 ulg
13 ovpzrqtifzi
12 qcgximmjtict
13 plppvl
13 u
10 eu
10 tftvfvddtofvovt
11 leldjvbwlveed
16 ub
9 beabdadbbud
14 ohoohhhohh
14 qq
16 ccccccccccccc
13 kezoa
15 bc
11 ikwgixzdgpwp
16 fttwaftt
14 ubtkau
15 ofoeooefooo
11 hjdjdjjdhh
13 jvyyyy
15 cmemommocc
11 dgnzu
11 haahtfi
12 xmbxbm...

output:

1
1
1
1
1
1
1
1
1
1
1
15
15
300239975158033
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
183
1
1
1
1
1
1
1
1
1
1
69905
1
1
1
1
1
1
1
1
11
2
1
1
1
579195
4
1
1
1
1
257
91
1
1
1
1
1
1
1
14
1
1
1
1
1
1
1
1
1
3452271214393
1
1
1
1
300239975158033
177156
1
1
1
1
1
1
1
1
1
11
1
1
1
1
11
1
1
1
1
1
1
1
1
1
1
1
1
4
40223...

result:

ok 500000 numbers

Test #55:

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

input:

500000
10 xztcztxttzcztctc
16 ftafrrfatfaaft
16 kb
13 nqjdjm
12 jwjjw
13 fafff
10 mguhydtqv
12 mmmmzmmzzmzzm
9 avndvdvav
14 bbbbjjbb
9 uulklnluhlhhunn
15 pc
15 xrgy
14 vk
14 dcbccdbdbbdbddd
11 oxjwqzqla
13 mavmkyeyyem
9 ymmyyy
16 acabjjbjj
14 zolznlozzlono
16 fjjj
11 fffwwwwfff
10 mjzmrmmm
11 midaib...

output:

1
1
1
1
1
1
1
1
1
15
1
1
1
1
1
1
1
10
1
1
1
12
1
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
1
73
820
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
11
2
1
16
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #56:

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

input:

500000
12 nuv
9 urxfzsxbbwd
15 pbubkjdmtop
11 naantjnctgxxdl
10 aiaadadiaadiiadd
11 wzwzwzvez
12 nqzdvwzqwindz
12 cvt
13 itosdpbtgpsbtdpg
13 jhfyiryiftqyajyq
14 pjm
14 blm
10 gpupgnupnxn
11 bbbbttttwwb
9 mzmozmzgmm
15 amjmxacvnxaanx
9 kkhvvkvccckhh
16 swssh
12 tdldtcccllcttlj
10 erfajerbjaar
15 byu
...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
14
2
1
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
1
1
1
1
1
13
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #57:

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

input:

500000
10 qqpkczzkpqzpzpcz
14 iuutx
10 crmy
15 umkubuudummmmdu
10 rrhjjljsrsrhoo
15 wsayn
9 dbvdqkx
13 mpxlkcra
9 lblzblbzlwwbzbl
16 wakxxkmmmx
13 kwwwnwigiinvpuuu
11 usjsjjpsjpspp
10 dadfef
15 odnngzrogzrgg
9 blqlblqhblullbq
9 pufvo
16 zjnc
14 lnerwreen
12 xbrcxuuzzvrzrxbx
9 wqfgwpsauqrfuqrf
16 jju...

output:

1
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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
10
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 500000 numbers

Test #58:

score: 0
Accepted
time: 1955ms
memory: 3800kb

input:

500000
10 hntbzjqsi
16 xzomtm
10 xdmmvmlmvdvxmvlx
11 jccxuyxcyurx
9 jdbbor
10 ylvelayazs
11 dalicqte
15 ikihrkkynynfkrh
12 odvcma
11 ovjuc
14 uunuaquqaneaqn
13 hzofcohuho
13 clyglhwlqgyhw
16 gygiuatq
14 fyrhbrpphqt
13 kfmflyemyk
15 tfgkgztzfq
10 rcessj
15 kccowhcwzphzph
12 comycxcyxbx
15 qbvqgve
13 ...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #59:

score: 0
Accepted
time: 1955ms
memory: 3872kb

input:

500000
11 ixknrp
9 xinvtlbwitbs
12 ywfnuvnoiyv
13 sazgut
10 vzledbyyk
11 qdpzjbfkkt
11 xxtezkzyjexzrvj
12 nzgddftntngztgj
12 bqkasjk
9 rixnxwibbwib
9 ikkpniyrgay
15 qbkvavqxuakub
16 ieligeycvy
10 oadbhchobhloa
13 kctvettjeqqe
16 pccvievvdcidpic
14 xoirnq
14 lncgij
11 vvuaymuoztufuy
13 wzyxsjxj
10 rj...

output:

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

result:

ok 500000 numbers

Test #60:

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

input:

500000
15 szgpassgybszbaa
10 ngbxnghjl
15 njsjjrnsayipz
10 xzkcfeacaizefp
12 kzhxmvla
13 puprujffjcpikupi
11 gztzcvprgrgpzg
12 msjxsmaqhhxr
15 qsnwkwojz
15 rizuavc
12 zgjdbmtd
16 auvlwibuhoua
15 olzvomjw
12 pbswputzd
13 fulmzblaazfplfj
15 eenpookhhnat
9 robmlwlrwfowwzoo
11 lulveebrkjld
14 ddgbnvwreu...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #61:

score: 0
Accepted
time: 1977ms
memory: 3636kb

input:

500000
16 ogaijmovwmx
9 mnowpiaxa
13 gtmmgnajjnnjbij
11 jylifjabfbljql
12 qitqnifdqiithhhe
14 yvhgukds
10 lgvuxivggdeg
9 kudjiikkgcr
16 waugcoihgcct
10 ihulrfllkb
13 lnytcwbu
13 pwdhrnxa
12 tqsusipqmlk
13 rgaukbws
15 liijubtgy
10 ctfcoffidytefci
13 cirtvnepw
11 ypzfaptjyttzw
16 slxeergjcek
15 dotymm...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #62:

score: 0
Accepted
time: 1980ms
memory: 3628kb

input:

500000
13 kkqzzzmqgueth
14 yfjmdsoshtd
15 frxfxyupixbyc
14 gikglvbhcpb
10 ijgcozvap
15 xkaqeuadqxxsi
11 tddtdisuwgcl
15 xchhxmuidfgu
13 vqvvipfffsqsxoh
11 ykilwoydetl
9 bgwszqishwciiqh
16 akckjeiqeincyaa
16 lrgrrlpruvepsavg
9 cpkhrdlfj
9 zlcdpafzgv
10 ygivwsvvdjee
11 dtoptxxddedekbzt
9 johbnsbaiimhm...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #63:

score: 0
Accepted
time: 1875ms
memory: 3876kb

input:

500000
14 pi
14 ygyryyxwcsr
10 ddddddd
15 ogadbjogwobawao
16 vkz
14 dodmctdibtfbeo
14 xxxxxxxxxx
12 giwwiwwwcgi
13 lliun
13 rodod
12 wmmmmmwwmwwmwmmm
10 yccy
11 lllll
16 yxvt
11 bomviwld
13 tgtgnmgnuwwtll
16 jjjjjjj
15 rrrrrrrrrrrrrr
13 lll
15 ezzeeee
11 bbltfjzrkj
13 nunnnunnnu
12 oobodooodbd
13 gn...

output:

1
1
1111111
1
1
1
22250358075
1
1
1
145
11
16105
1
1
1
17895697
2085209001813616
183
1
1
1
1
1
1
1
1
8108731
1
1
14
1
579195
2085209001813616
1
1
1
1
1
1
1
1
1
1
2593742460
1
1
1
1
1
1
241
4361070182715
1
1
1
1
1
1
1
1
1
1
1
15
1
1
1
1
1
1
1
1
21435888
1
1
14
1
1
16105
1
1
1
1
15
1
1
177156
11
1
1
1...

result:

ok 500000 numbers

Test #64:

score: 0
Accepted
time: 1903ms
memory: 3860kb

input:

500000
14 asualfauwuwwhlu
10 ccckk
10 rrrrllrrlrrr
12 qjqjq
13 ellaeallaalae
13 llfjppoogkgeu
15 mspqjspmgwj
15 rrnmxgx
15 ercuxvjsh
10 eqaueqeaeuubaq
11 vynlc
14 lwatvlc
14 saghhbhgasta
15 uk
11 pnyptwtcucupr
13 fmrkkruvrfg
10 ahmayypmapya
16 ojuqtuorqrnzhnh
10 qirokkgpt
10 qjsavtewwvai
10 zozozzoz...

output:

1
1
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
1
15
1
1
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
2
1
1
1
1
1
157
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
101
1
1048577
3
1
1
1
1
1
1
1
12
1
1
1
340
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
273
1
1
1
1
1
1
1
12...

result:

ok 500000 numbers

Test #65:

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

input:

500000
13 sdujva
16 ccffdccdcf
15 vwjhxp
12 ujuvevghtphqv
13 xccxffcxcx
12 lppcpsoocoqcqes
12 joimbktjsoibi
14 amdetavkw
15 ljcp
10 tgao
16 tjrqlyioi
14 mmjjn
15 bwzvjg
11 ffbrefek
14 ftdppdptdpfffdtd
15 ftdy
16 hjzdsvfkw
14 haeyttehyhihia
10 rhjuftlkr
16 czoyuvxzg
11 qxnfsyyynssvxqnx
10 kxfvqksrxrq...

output:

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

result:

ok 500000 numbers

Test #66:

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

input:

500000
14 fclm
15 sbsklbg
16 esescsnnsnceecee
16 mmgpegemmemeg
12 qvsa
15 kfhtcckhtjftcj
14 usiwgby
16 rvmyx
12 ejfwecgvffgdvp
11 brbbbbreerzzeee
15 pblqlyysdbp
14 rwwejajqphwmhe
13 wwceceull
11 cyycchpc
13 cvcrgr
11 vpyvmiejkii
11 kopvbttsk
16 chsllsc
15 kcbhocp
12 daavwtvdaty
10 exdmm
13 gnojlkkfb...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
9
1
1
1
1
1
1
1
1
1
1
1
1
16
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 500000 numbers

Test #67:

score: 0
Accepted
time: 1945ms
memory: 3800kb

input:

500000
16 yecgk
13 dorgjtdd
13 quxmzcw
15 rkebkzr
15 gjpqc
11 rqzbg
12 delhkekkakatdqkl
12 svshmft
13 lbsdddvvbvsblvl
13 hqenjxnfcjqxlfet
16 lutdmld
14 juujpuwpypulyjl
16 sexkmtuknctusg
10 mrzwesvlc
12 qqcxxxmzbmql
13 aqmgw
14 ouhmavxuekp
13 zooqwzwyoqq
12 truwitu
14 ndlwlrylcscldrm
12 ovyakd
13 svh...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #68:

score: 0
Accepted
time: 1949ms
memory: 3868kb

input:

500000
15 qbwgnk
15 ivlzrbflbivir
16 htctlwbclcblyhy
13 tvststsavabotaaa
14 yudjrxg
11 umkykqhrul
13 csqtexzfmrcqme
16 aqjcajbcjdxq
12 yhhchgphusgcysep
14 rwvwcqjsaffnsn
11 tkawdgm
11 lzkmgascza
15 fzuklo
13 vynirt
11 sdgwiuhbp
15 mybhpvyvphfvbsh
14 uutctqiicfjuq
12 wbfktnyyywnfbw
12 dludlqurynddg
1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #69:

score: 0
Accepted
time: 1969ms
memory: 3628kb

input:

500000
10 qftsrwigis
13 wxkuhmhmuozpoz
12 eclwgth
13 nzxpuypgujayni
10 vylliiydlrwowpil
14 uqldroprpkyv
13 ranqneaxnixteee
14 atqddmwbwa
14 jcsqvftwa
10 anagoaosnaskanuo
16 rgjmqxt
14 uulcuwlmelfmquf
15 tkdcuvx
14 lhastmejarz
11 kvwltsp
12 vgdpkcpvzzygam
13 dequwatxj
16 xrttoxgtockzokxk
10 dmpbldbom...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #70:

score: 0
Accepted
time: 1978ms
memory: 3576kb

input:

500000
11 qpfvphvvhpfybbia
13 zbdjuvws
16 mypttpwjtripptq
14 agislsujh
15 tptlapjdnjponno
15 jpfdlpkpfkathqhj
10 hswypfysoyqq
14 okkvaojqhvqhm
16 fdhbcjpa
15 jnvofuwe
12 inhcwwnznbwr
16 azrcfbislt
13 ghaldjuen
13 rlwhauwrqnzqrmhz
11 lhmmfxmptpxqj
11 szuhrfqbdt
13 ifowdwgqjwxdjxww
13 zjtbvtqfwo
16 fd...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
9
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Test #71:

score: -100
Time Limit Exceeded

input:

500000
10 tihhyzdwhxiostww
10 zrczzpsjapabwz
15 vmumrwkikktp
16 jcjforwdufofren
16 svyupnfbw
14 romtkduxh
10 rcdzcvxddddujvir
15 flyqsxuanl
13 kzijnpkejdqp
14 uvjzwbubpqvpyjz
14 pzdchjpnjpaavclv
16 pmjzbtrrhwy
16 zkzorvswrqkfu
12 vohkmyfemovuccem
12 nqyroqpznbe
16 auekldwbof
16 bcgjrqgbnchuupp
11 nh...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
9
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
9
1
1
1
1
1
1
1
1
1
...

result: