QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#67807#5166. 回文匹配xiaoyaowudi100 ✓1021ms532328kbC++145.8kb2022-12-12 11:07:032022-12-12 11:07:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-12 11:07:06]
  • 评测
  • 测评结果:100
  • 用时:1021ms
  • 内存:532328kb
  • [2022-12-12 11:07:03]
  • 提交

answer

#include <algorithm>
#include <iostream>
#include <cstring>
#include <queue>
#include <assert.h>
constexpr int N(500010);
namespace trie
{
	int sz(1),pos[N];
	struct _z
	{
		int ch[26],p,dep,ptpos,es[26],pampos;
	}z[N];
	struct pam
	{
		struct _z
		{
			int fail,len,trans[26],ch[26],fa,ft[20],dep,rs[26];
		}z[N];
		int pos[N],sz,cnt;bool nc[N];char s[N];
		pam()
		{
			sz=1;z[1].fail=0;z[0].fail=1;z[1].len=-1;z[0].len=0;
			for(int i(0);i<26;++i) z[0].trans[i]=z[1].trans[i]=1,z[0].ch[i]=z[1].ch[i]=-1,z[0].rs[i]=1;
		}
		void pop()
		{
			if(nc[cnt])
			{
				z[z[pos[cnt]].fa].ch[s[cnt]-'a']=-1;
			}
			--cnt;
		}
		std::pair<int,int> push(char c,int (&es)[26])
		{
			int fa(pos[cnt++]);
			if(!(z[fa].len<cnt-1 && s[cnt-1-z[fa].len]==c)) fa=z[fa].trans[c-'a'];s[cnt]=c;
			if(!(~z[fa].ch[c-'a']))
			{
				nc[cnt]=true;++sz;pos[cnt]=sz;z[sz].fa=fa;z[sz].len=z[fa].len+2;
				int t(z[fa].trans[c-'a']);if(~z[t].ch[c-'a']) t=z[t].ch[c-'a'];else t=0;z[sz].fail=t;
				z[fa].ch[c-'a']=sz;z[sz].dep=z[t].dep+1;z[sz].ft[0]=t;
				for(int i(1);(1<<i)<=z[sz].dep;++i) z[sz].ft[i]=z[z[sz].ft[i-1]].ft[i-1];
				std::memset(z[sz].ch,0xff,sizeof(z[sz].ch));
				std::memcpy(z[sz].trans,z[t].trans,sizeof(z[sz].trans));
				z[sz].trans[s[cnt-z[t].len]-'a']=t;
			}else
			{
				nc[cnt]=false;pos[cnt]=z[fa].ch[c-'a'];
			}
			for(int i(0);i<26;++i) z[pos[cnt]].rs[i]=es[i]=z[z[pos[cnt]].trans[i]].len+2;
			int l(z[pos[cnt]].len);if(l<cnt) es[s[cnt-l]-'a']=l+2;
			return {z[pos[cnt]].len,pos[cnt]};
		}
	}T;
	void dfs(int u)
	{
		for(int i(0),v;i<26;++i) if((v=z[u].ch[i]))
		{
			auto [p,pampos]=T.push(char(i+'a'),z[v].es);
			z[v].p=p;z[v].pampos=pampos;
			dfs(v);T.pop();
		}
	}
	void build()
	{
		for(int i(0);i<26;++i) z[1].es[i]=1;
		dfs(1);
	}
}
struct bit
{
	int b[N];
	void add(int x,int v){for(;x<N;x+=(x&(-x))) b[x]+=v;}
	int _qry(int x){int ans(0);for(;x;x-=(x&(-x))) ans+=b[x];return ans;}
	int qry(int l,int r){return _qry(r)-_qry(l-1);}
}TB;
int qid[N],ans[N];
namespace pt
{
	struct _z
	{
		int dc,ps[26],id,fail,len,nd[26],dfn,ed;
		bool initialized;
		int get_id(int p){return std::lower_bound(ps,ps+dc,p)-ps;}
	}z[N];
	std::vector<int> qs[N],ts[N];
	int sz(1),dcnt;
	void build()
	{
		std::queue<std::pair<int,int>> qq;qq.push({1,1});trie::z[1].ptpos=1;z[1].id=1;
		while(!qq.empty())
		{
			auto [pn,tn]=qq.front();qq.pop();
			if(!z[pn].initialized)
			{
				z[pn].initialized=true;
				std::memcpy(z[pn].ps,trie::z[tn].es,sizeof(z[pn].ps));
				std::sort(z[pn].ps,z[pn].ps+26);z[pn].dc=std::unique(z[pn].ps,z[pn].ps+26)-z[pn].ps;
				if(pn==1)
				{
					for(int i(0);i<z[pn].dc;++i) z[pn].nd[i]=1;
				}
				else
				{
					int fl(z[z[pn].fail].len),v(trie::z[tn].pampos),f(z[pn].fail);
					for(int i(19);i>=0;--i) if((1<<i)<=trie::T.z[v].dep && trie::T.z[trie::T.z[v].ft[i]].len>=fl) v=trie::T.z[v].ft[i];
					for(int i(0);i<26;++i)
					{
						int p;
						if(trie::T.z[v].len<fl){p=trie::z[tn].es[i];}
						else{p=trie::T.z[v].rs[i];}
						int j(z[f].get_id(p));
						int w(z[f].nd[j]);
						int q(trie::z[tn].es[i]);
						z[pn].nd[z[pn].get_id(q)]=w;
					}
				}
			}
			for(int i(0);i<26;++i) if(trie::z[tn].ch[i])
			{
				int k(z[pn].get_id(trie::z[tn].es[i]));
				if(z[z[pn].nd[k]].len<=z[pn].len)
				{
					int c(++sz);
					z[c].id=trie::z[tn].ch[i];
					z[c].fail=z[pn].nd[k];
					z[c].len=z[pn].len+1;
					z[pn].nd[k]=c;
				}
				trie::z[trie::z[tn].ch[i]].ptpos=z[pn].nd[k];
				qq.emplace(z[pn].nd[k],trie::z[tn].ch[i]);
			}
		}
	}
	void dfs_d(int u){z[u].dfn=++dcnt;for(int v:ts[u]) dfs_d(v);z[u].ed=dcnt;}
	void dfs(int u)
	{
		TB.add(z[u].dfn,1);
		for(int q:qs[u])
		{
			int v(qid[q]);
			ans[q]=TB.qry(z[v].dfn,z[v].ed);
		}
		for(int i(0);i<z[u].dc;++i) if(z[z[u].nd[i]].len>z[u].len) dfs(z[u].nd[i]);
		TB.add(z[u].dfn,-1);
	}
	void calc()
	{
		for(int i(2);i<=sz;++i)
		{
			ts[z[i].fail].emplace_back(i);
		}
		dfs_d(1);
		dfs(1);
	}
}
namespace fr{
	#include <ctype.h>
	char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
	#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
	#define putchar(c) (((O==obuf+(1<<23))?(fwrite(obuf,1,O-obuf,stdout),O=obuf):O),*O++=(c))
	void rd(char *x){char c=getchar();while(isspace(c)) c=getchar();while(!isspace(c) && c!=EOF) *(x++)=c,c=getchar();*(x++)='\0';}
	void rd(char &x){x=getchar();while(isspace(x)) x=getchar();}
	template<class T> void rd(T &x){T ret=0;bool flg=false;char c=getchar();while(!isdigit(c) && c!='-') c=getchar();
		if(c=='-') c=getchar(),flg=true;while(isdigit(c)) ret=(ret<<1)+(ret<<3)+(c-'0'),c=getchar();if(flg) x=-ret;else x=ret;}
	void pc(char c){putchar(c);}void flush(){fwrite(obuf,1,O-obuf,stdout),O=obuf;}
	template<class T> void wr(T x){if(x<0) putchar('-'),x=-x;if(x==0) putchar('0');static int cnt,stk[110];cnt=0;while(x) stk[++cnt]=x%10,x/=10;
	for(int i=cnt;i;--i) putchar(stk[i]+'0');}
}
using fr::rd;using fr::pc;using fr::wr;using fr::flush;
int main()
{
	int T,n,q;rd(T);rd(n);rd(q);
	if(T==0)
	{
		static char s[N];
		for(int i(1);i<=n;++i)
		{
			rd(s+1);int l(std::strlen(s+1)),u(1);
			for(int j(1);j<=l;++j)
			{
				if(!trie::z[u].ch[s[j]-'a']) trie::z[u].ch[s[j]-'a']=(++trie::sz);
				u=trie::z[u].ch[s[j]-'a'];
			}
			trie::pos[i]=u;
		}
	}
	else
	{
		trie::pos[0]=1;
		for(int i(1);i<=n;++i)
		{
			int fa;char sc;rd(fa);rd(sc);int id(sc-'a');
			if(!trie::z[trie::pos[fa]].ch[id]) trie::z[trie::pos[fa]].ch[id]=(++trie::sz);
			trie::pos[i]=trie::z[trie::pos[fa]].ch[id];
		}
	}
	trie::build();
	pt::build();
	static int pos[N];
	for(int i(1);i<=n;++i) pos[i]=trie::z[trie::pos[i]].ptpos;
	for(int i(1);i<=q;++i)
	{
		int u,v;rd(u);rd(v);
		qid[i]=pos[u];
		pt::qs[pos[v]].emplace_back(i);
	}
	pt::calc();
	for(int i(1);i<=q;++i) wr(ans[i]),pc('\n');flush();
	return 0;
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 27ms
memory: 38392kb

input:

0 2 500000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

1
1
1
487
1
0
1
487
0
1
0
0
1
1
1
0
487
0
0
1
487
1
1
1
1
487
1
0
0
0
487
487
1
1
487
487
1
0
1
0
1
0
0
487
1
0
1
0
1
1
487
1
1
1
1
1
1
0
1
0
0
0
0
0
0
487
0
1
1
0
1
0
0
1
0
487
487
487
1
1
487
487
1
1
1
1
1
487
0
487
0
0
0
487
0
1
487
487
1
1
1
0
0
1
1
487
1
1
0
1
1
1
1
1
1
487
1
1
0
1
1
0
0
1
0
1
...

result:

ok 500000 tokens

Test #2:

score: 0
Accepted
time: 28ms
memory: 40380kb

input:

0 2 500000
bbbbaaabbabababbbabaaaabaaabbaababbababaababbaabbaabbaaabbabaaabbbabbabaaaaabbbabbbaabbabbbaabaaaaabbbbabaaabbbbbbbabaaaabaaabbbbabbbababaaaababaaababbbbbababbbbbababbbaababbabbabaaaabbbaaabaabbbbaabaabaabbaaabbaabaaabbaaaabbaabbaabbbbaaabbbbabababaaabbbbaaaaababaaaababbbbbababababaaaabba...

output:

1
999
1
999
1
999
1
0
1
1
0
1
0
999
0
1
1
0
999
0
1
1
1
1
999
999
999
1
1
1
1
1
1
1
1
999
0
999
999
999
1
0
1
999
0
999
1
999
1
0
999
1
0
1
1
999
0
1
0
999
999
1
999
999
1
0
1
999
1
1
1
1
1
1
1
999
0
0
1
999
1
1
1
1
1
1
1
999
0
999
1
0
1
1
1
1
999
1
999
1
1
1
0
1
0
999
0
999
0
0
0
0
1
1
999
999
1
0
...

result:

ok 500000 tokens

Test #3:

score: 0
Accepted
time: 25ms
memory: 40552kb

input:

0 10 500000
baaaaabbaabbabbbbbbaabbbbaaabaaaaabbaaaaabaabaabaaaaaabababbaabababbaabaaaaaaabbbbaabbaaaabbbbaaaaaaaaaaaaabbaabbababaababbababbaaaabaaabaabbaaaabbaaabababbabbbaabbabbaaaabbaaaababbabaabbaabbbabbbbababaabbbaaabaaaabbbaabbabbaaababbbaababaabbbbbbaabaabbbabbabbbabaaabaaabbabbaabbabaaabaaaa...

output:

1
0
0
0
0
225
0
0
0
0
0
0
0
0
0
0
1
35
0
0
1
1
30
0
0
0
0
0
18
0
0
0
0
0
0
0
0
0
16
0
0
3
0
0
1
0
0
0
1
0
1
0
0
0
0
54
50
0
1
0
0
0
1
5
0
0
0
63
0
50
175
109
0
0
0
0
0
0
0
0
0
0
1
175
3
109
0
0
0
35
0
0
0
0
0
0
0
0
0
0
50
0
4
0
0
0
0
0
3
0
18
0
0
0
35
301
0
0
0
0
0
0
35
0
0
175
0
0
1
1
0
0
0
0
1
0
0...

result:

ok 500000 tokens

Test #4:

score: 0
Accepted
time: 39ms
memory: 39200kb

input:

0 30 500000
ababbababaabaababaaabbaaabbabaabababaaaababbaaababba
abaababaaababaabaabbb
baba
aaabbaaabbaaabbaa
ab
bbbbbaabbababbaabaaba
bbbbbbabbbbaaaaabaabbaabbabbbaaaaaaaaaabaabb
bbb
bba
baaaaaaabbbababbbaaaabbbba
aaabaaaaaaabbbabaaabaaaabbbbabbaabbbaabbbaabaaaaabbabbbabbbabbaaabbbbbbbbabaabbbaabbb...

output:

26
0
0
0
0
0
33
0
0
16
0
1
0
14
0
0
1
0
0
6
4
26
1
0
6
0
14
0
0
50
0
1
0
1
11
0
0
0
0
0
3
0
0
1
0
0
0
0
0
0
0
10
0
3
0
0
2
1
0
0
16
0
0
3
0
0
0
0
0
0
0
0
0
0
0
0
3
0
6
0
0
0
165
2
0
0
0
0
0
0
0
0
0
13
0
0
0
36
0
2
10
0
0
1
0
0
0
0
0
36
0
0
14
0
0
0
0
0
2
2
0
0
0
6
1
2
0
1
0
0
13
0
0
1
18
0
0
0
0
0
0...

result:

ok 500000 tokens

Test #5:

score: 0
Accepted
time: 36ms
memory: 40616kb

input:

0 100 500000
a
aba
aaa
aababbbaaaabbabba
abaaabb
babbabbabbaa
bbbb
baaabb
aaaababbbabbaababaa
babaabbab
ababbabab
aaaba
baaabbaabaabb
abbababbaababbabaabbbaaaaabababaabab
ba
bb
aaabbbbbbb
a
bbabaaabababbaa
aab
bba
aaa
abb
b
bbbbab
abab
bbaab
bbbabbbabbbabaabbabb
ababa
bb
babaaaaaaaaaaaabaabaaaaaa
ba...

output:

1
0
0
0
0
0
0
37
13
0
0
0
0
2
0
1
0
0
5
0
0
0
0
0
2
10
0
0
7
0
0
3
0
0
3
0
3
0
0
3
13
0
0
2
0
0
0
0
8
5
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
27
0
5
3
0
0
1
0
0
0
6
0
0
3
0
0
0
0
0
0
0
2
2
0
0
5
0
9
0
0
0
6
0
0
0
0
0
0
0
0
6
0
0
0
1
5
21
0
8
0
0
0
0
0
0
0
0
0
0
0
2
2
0
0
0
1
0
0
1
2
0
0
3
0
0
0
0
1
0
25
8
1...

result:

ok 500000 tokens

Test #6:

score: 0
Accepted
time: 19ms
memory: 38056kb

input:

0 10 500000
dwufssiqlihcwjeunletiposagglzrtaebzfwarrgxpffcgdfjlkyaiaprxqtlnmdweczqpbcqppbaeghojhodqyicl
dskgaujjtcaaiobkallyeoyddhqgfsrpyghyqnpxihmlyg
qwpqdmsygfqpyotyqayhprdccctiunclkqeguxmlvplrxauwxwdccmfepmrivspacjlkncuylibvguvqvncoykwtjuxorgiiqpmotlhmkmqdaxtiiqamskzledzucczsygneqrmzrikhffuqbclgf...

output:

0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
1
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 500000 tokens

Test #7:

score: 0
Accepted
time: 34ms
memory: 41308kb

input:

0 30 500000
zfypsxangtebfdztifwcdgdzo
qtxczqnulhrscugzkghnmwzviuwlpwjvqdrqdectpvnpyjzxgzlkainkoekbmn
ilec
joqqzftazpykqlhnvualkp
bfhpanqhkctymdmwutvzrmvanfwippyqaowidnqzzbrvyhdahjayzkvwbohilzbwshkvmjsxrxyrzodwdk
mwcnzm
wyoujkavpsopsxkgdhqxrvdj
nruhek
jaannpkquuayfyhagnjydj
bcfdanjogbtyhexqqahovggcli...

output:

0
0
4
0
16
0
0
0
0
1
0
3
0
1
0
22
0
0
3
0
0
0
0
67
169
22
0
39
0
0
14
0
22
69
0
0
0
0
0
0
0
0
0
0
0
8
51
0
0
0
0
0
0
0
0
0
6
3
0
0
15
0
15
0
0
0
0
0
0
0
18
0
0
0
15
1
0
0
0
1
69
0
0
0
1
0
0
59
0
0
0
0
0
0
0
0
0
18
16
0
0
0
0
0
33
0
11
0
0
2
16
60
0
56
0
0
0
0
0
5
0
1
0
0
0
0
18
0
0
1
0
46
0
2
0
0
0
...

result:

ok 500000 tokens

Test #8:

score: 0
Accepted
time: 31ms
memory: 38616kb

input:

0 100 500000
f
vctmhqmlcvwadkbtiptgiynjdrv
klnurfsks
mdtew
w
dobxagftzyiep
aigx
ku
vgx
hlmmtvh
gf
vm
inbaj
hlugbhc
xkmdikabexzvkhkvjl
tiglgdhvmzeibfnt
deofjsoxepazkrbmthsebbnylmcptldzvqyfqpolfimoiux
brh
rc
mvvwq
jjzhgrmoxxlrkm
uawxorf
bixvlsfqjnufva
oq
fiemitnd
ezybml
nmckgblttqyq
lldyiyulzinj
sdvog...

output:

0
4
17
0
0
0
0
0
41
4
0
11
0
1
0
0
8
0
2
0
21
2
0
4
2
3
0
0
0
0
0
0
0
0
0
15
9
13
22
0
0
0
0
0
1
0
0
6
6
1
0
0
0
0
1
0
1
5
6
0
1
0
0
10
0
0
17
0
13
0
0
3
0
0
0
1
0
9
21
0
0
0
1
6
0
1
0
10
0
0
0
0
0
2
53
0
7
0
0
5
2
13
19
2
0
0
4
7
0
0
32
0
0
0
0
6
0
8
0
5
0
5
0
0
0
0
0
0
0
7
0
0
1
26
32
0
1
8
0
0
6
...

result:

ok 500000 tokens

Test #9:

score: 0
Accepted
time: 9ms
memory: 39628kb

input:

0 1000 500000
o
i
k
p
e
o
h
v
g
p
v
h
f
v
r
j
j
u
b
x
s
s
l
v
e
x
o
i
b
r
b
k
z
a
v
k
j
i
o
g
r
c
n
x
j
t
p
r
c
r
i
u
k
n
s
s
o
f
c
y
x
i
a
o
p
g
q
n
d
j
t
c
h
s
w
e
q
z
w
e
k
p
q
c
z
d
c
j
w
f
p
w
e
i
v
i
r
p
f
s
a
v
u
v
n
l
y
s
n
v
r
c
h
k
n
m
e
m
t
g
t
f
x
g
q
l
v
f
g
l
i
y
w
t
h
x
y
j
q
o
b
b
o
...

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 tokens

Subtask #2:

score: 15
Accepted

Test #10:

score: 15
Accepted
time: 31ms
memory: 43600kb

input:

0 500000 500000
v
s
o
w
f
c
z
u
d
b
z
h
b
e
w
p
n
l
e
i
e
h
g
h
o
q
u
x
n
k
t
z
i
f
e
t
q
b
s
h
o
q
k
n
k
t
d
x
t
u
p
w
l
h
g
j
c
q
n
i
s
o
v
s
u
e
n
c
j
f
u
w
q
g
u
p
v
w
z
w
p
r
d
n
m
v
d
z
n
j
l
o
n
v
y
u
j
x
j
v
a
e
x
r
l
s
x
g
u
a
h
u
c
b
z
k
b
t
g
h
o
g
k
t
l
u
i
c
q
p
v
c
s
s
s
l
i
c
h
t
o
s
...

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 tokens

Test #11:

score: 0
Accepted
time: 21ms
memory: 41832kb

input:

0 250000 500000
di
ne
pk
cw
la
bt
cx
hs
ku
ga
rq
zq
jo
zr
at
ue
og
sl
su
ju
gy
oo
om
ev
df
bm
jh
um
vw
ts
qs
we
pn
pe
zc
zb
nl
ld
kl
pl
tk
uh
cm
hn
qb
xi
wb
lu
kq
gf
vc
eq
xe
ni
se
ng
kn
rt
zd
bv
vb
vn
ui
dz
kn
do
cg
nn
ct
mz
op
od
lu
cb
ra
ib
dk
lh
xh
wh
ny
ws
jw
lh
vk
bl
ak
an
rz
xv
sm
zt
mp
yr
an...

output:

1
1
1
0
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 tokens

Test #12:

score: 0
Accepted
time: 173ms
memory: 246988kb

input:

0 50000 500000
qkubvtpdzm
soafdgztoz
dzihbjgzlv
qzmgwddcum
edjlwzdesz
uzdcradqvu
keljvoztlv
rwibigjyiq
txgwbogpxx
hpkzemjevp
zgygtmqivo
vmhpsomqgj
icjqyepuzv
lgxnfnvmnk
wgetijbyql
qsglhyjkee
enfkhyfory
hwzrhlcqfj
bhifrgvfly
bpuphqsvau
yvdgurwpeo
vxyypvbpfh
ghgrliyqyb
vaunorfwvl
xzisdbfkbu
vpxuecgonr...

output:

0
0
0
1
1
1
0
1
1
0
0
0
0
0
1
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
1
0
0
1
0
0
0
0
1
0
1
1
0
0
0
1
0
0
1
1
1
1
0
0
0
1
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
...

result:

ok 500000 tokens

Test #13:

score: 0
Accepted
time: 595ms
memory: 294984kb

input:

0 5000 500000
wgnhspqfqmsglvytlzswiyhhryunyqtbwgrybapsfazarmqfzeyaqheruzccfiwvosvttasxklvfyiyutasgnqzielbmzfwzneea
ksqsaughjpdpmrxyqrnkenvuhhbnxjlgaxoebfgosierjxuhbxxnnupigxqjcmknzuomavqyafbwippqznniqixbbutybznxxlcg
jqhxhvoknjktzdegmtdvxapbfobchmgvxavvbksiqekqtjkvvgwkfxsuqueklxlyqlanorcambowdgzvdovf...

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 500000 tokens

Test #14:

score: 0
Accepted
time: 564ms
memory: 279772kb

input:

0 200 500000
ztvrelbmgkwawltubkecueenrrxoafbslwjaeqvzzppfzxvgycgliaiwhfeyvodpsapqeyjirgclwrdflcqispbtbivlkaiecakocarlmhpdowzwjhxgpjbcccepmpceyyrwwrnmlyyioslgqbppnutbqcxhiyfntvxwslcpqnvmonyevbadqpkhlddixawynfoztkjmfsafyoolgspflnixalfeulgtuymhzpeutrquxqnkhwhezovdksbthwzirpdnhinlvnjijtytwzggcoptflsjhbl...

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
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
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 500000 tokens

Test #15:

score: 0
Accepted
time: 511ms
memory: 274340kb

input:

0 20 500000
tzfbewglzikwxyjkkathrpoidnvdudkwosfrlcnmhvoyjniwveiypahkpychzwseqsvssdqbzxkixatwwsuigjygtoxehabbsioeberecmqzmagaancqugaaxqblwleoglexgeobzhidsqydsgyhtncuhdyavcknynbeisqebyagzpengdavedutrwejzcrfpacgvohrjshpsiubwqufuaqrwzcyothsesstsjyldiddejmgpcefjbshtbojbbkytitfibgiabeonnysfswnqwkwqmaurtbe...

output:

0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
...

result:

ok 500000 tokens

Test #16:

score: 0
Accepted
time: 363ms
memory: 308108kb

input:

0 1 500000
xbfaqwhxainvubbxblsgiyhxchubsocqkdjomtvxiwrxiytdshewrcfjjxelnrdsmrjphysgoiugosyghdtmjzrzrzjkzbuyxjicfeaggqfhwleuekeldzxamxdhpfgxtlwdehoarxjxshtqyhtwehgirhdqvkxoxstpiltckqaliambfrrnighbdireuuddwgidywbazdfrclivpynyjmtwmedhowwigqcslfadgqwzqxlxhumfkbnutalszwrofjlhhfxkcazgxzpooxlgyoalhqpnmklgc...

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 tokens

Test #17:

score: 0
Accepted
time: 38ms
memory: 58504kb

input:

0 100000 500000
thjjy
hhhhp
nnnnn
ssssz
ttttx
xxxxx
yyyyy
yyyyy
sssss
qqqqn
ooooo
uuuuu
yyyyo
eeeee
ttttt
wwwww
bbbbb
ttttt
zzzzz
lllll
vvvvv
wwwww
xxxxx
hhhhh
lllll
nnnnn
ccccc
nexxj
yyyyq
iiiii
mmmmm
qqqqq
kkkkk
wwwww
ooooo
yyyyy
uuuuu
kkkkk
iiiih
ggggg
qqqqq
eeeee
ooooo
wmuuz
ooooo
sasss
gkffo
eu...

output:

1
0
1
1
0
0
1
1
1
0
1
0
1
1
0
1
0
1
1
1
1
1
1
0
1
0
1
0
1
1
0
0
1
0
1
1
1
0
1
1
1
1
1
0
1
1
1
1
1
0
1
1
0
1
1
1
0
0
0
0
1
0
1
1
1
0
0
0
1
1
1
0
0
1
1
1
0
0
1
1
1
0
0
0
1
1
0
0
0
1
0
1
1
1
0
1
0
1
0
1
1
1
0
1
1
0
0
1
1
1
0
1
1
1
1
1
0
1
0
0
0
0
0
0
0
1
0
1
1
0
0
0
0
0
0
1
1
0
0
1
1
0
1
1
1
1
0
1
1
0
...

result:

ok 500000 tokens

Test #18:

score: 0
Accepted
time: 42ms
memory: 64912kb

input:

0 50000 500000
uuuuuuueeu
yyyyyyyyqq
oooooooooo
qqqqqqqqqq
nnnnnnnnnn
nnnnnnnnnn
pppppppepp
lldldmjmmm
qqqqqqqqqq
sssssssuus
ppkzkrjrrr
ggvgvsdsss
ffffffffff
mmmmmmmmmm
oooooooooo
aaaaaaaaaa
aaaaaaaahh
fffffffvff
dddddddddd
cccccccccc
xxxxxxxexx
eeeeeeesse
wwwwwwwwww
bbbbbbbbbb
uuuuuuuuuu
eeeeueeeee...

output:

0
1
0
0
0
0
1
0
0
1
1
0
0
0
1
0
0
1
1
1
1
0
0
0
1
1
0
0
1
0
0
1
0
0
1
0
1
1
1
1
0
0
1
1
1
1
0
0
1
0
0
1
0
0
0
0
0
1
0
1
1
1
1
1
0
0
1
1
0
0
0
1
1
0
0
0
0
0
1
1
0
0
1
0
0
0
0
1
0
0
0
1
1
0
0
0
0
1
0
1
0
0
1
0
0
1
0
0
0
0
0
0
1
0
0
1
1
0
0
0
1
0
1
0
0
1
0
1
0
1
0
1
1
0
0
0
0
1
0
0
0
0
1
0
0
1
0
0
0
1
...

result:

ok 500000 tokens

Test #19:

score: 0
Accepted
time: 86ms
memory: 158400kb

input:

0 5000 500000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadaaaaadaaaaadaaaaaaaaaaaaaaaaaaddaaaaaaaaadaaaaaaaaaddaaddaaaaaaaaad
rrwwwwwqnhnhhhuhhuppppuhuuwuuuuwuduzzuuuzzmxmtmmoaaojrneenneeeeeyqyeyvkkilhyyybzzzbiiibmbsvfvvfvlvvj
uukkkkkwfcfcccgccgaaaagcggdggggdgrgmmgggmmwlwkwwgzzgtvjbbjjbbbbbtqtbtriiwyadddcooocy...

output:

1
0
0
0
1
0
1
0
0
1
0
0
0
0
1
1
0
0
0
0
0
0
0
1
1
0
0
0
1
0
0
0
0
0
0
1
1
0
0
0
0
0
1
1
0
0
1
1
1
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
1
1
0
0
0
1
1
1
1
0
1
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
1
0
1
1
0
0
0
0
0
0
0
0
1
...

result:

ok 500000 tokens

Test #20:

score: 0
Accepted
time: 187ms
memory: 265632kb

input:

0 500 500000
llllllllllllllllnmnnnnmnnnnmnlllllllnnllnnbnnlllnnbbnnbnnbbnnnbbnnbnnbbbnnbbbnynbnbbnbnbbtbbtbbnbbtbbttbttbbtbbttbttbxxbtttbxkxkkxkxkkxkkxkxkxxkkxaxaaakkakkakkaakkkaakkkaaaakkkkaaaakkkaakkkakkkaakaaaaaakkakkaaakkakkaakkakkaakaakkakakakakkaakakakaiiakkkakalakakkkakalakkalaalhlallaalllaal...

output:

0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
...

result:

ok 500000 tokens

Test #21:

score: 0
Accepted
time: 207ms
memory: 269468kb

input:

0 20 500000
hhzhhhhzhhhhxhhggpgggpgollooooomrmmrbrmjjiijjijijijijjjhhhjjhjwwjhhbbhhhhbpswswswswadadaaddlddaqqaooooarajzjzjajzjzjjzzjzjzjjjzzjaaoahfmqmihhhhimmihhiiooiihhghvhhvvevevevvkkkvvdiddpdejjggsshsbssszszszvpkykkkbbkkhvhhhvhvkkmccccccjjcjyjjyyfynyfxxfxffxffbjnnzlzznnllnlnprddlzfzlzzzzzkkkklalq...

output:

0
0
1
1
0
0
0
0
0
1
0
0
0
1
0
1
1
1
0
1
0
0
1
0
0
0
0
1
0
0
0
1
1
1
0
0
0
0
1
1
0
0
1
1
1
0
1
0
0
0
1
1
1
1
0
0
1
0
1
1
1
1
0
0
1
0
1
0
1
1
0
0
1
0
1
1
0
1
0
0
1
1
1
1
0
1
1
0
0
0
0
0
0
1
1
1
0
0
0
0
1
1
0
1
0
1
0
0
1
0
1
0
1
0
1
0
1
1
1
1
0
0
1
1
1
0
1
1
0
1
1
0
1
1
0
1
0
0
0
0
1
0
1
1
1
1
0
0
0
1
...

result:

ok 500000 tokens

Test #22:

score: 0
Accepted
time: 271ms
memory: 364472kb

input:

0 5 500000
ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt...

output:

0
0
1
1
1
1
1
0
1
1
1
1
0
1
0
1
1
0
0
0
1
1
1
1
0
0
0
1
0
0
1
1
0
0
1
0
0
1
0
1
0
1
1
1
0
0
0
1
1
1
0
1
1
1
0
1
1
1
1
0
1
1
0
1
1
1
1
1
0
1
1
1
0
1
0
1
1
1
0
0
0
1
0
1
0
0
1
1
0
0
0
0
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
0
1
1
1
0
1
1
1
0
1
1
1
0
0
1
1
1
0
0
0
1
1
1
0
1
1
0
1
0
0
0
0
0
1
0
0
1
0
1
1
1
0
...

result:

ok 500000 tokens

Test #23:

score: 0
Accepted
time: 260ms
memory: 369768kb

input:

0 5 500000
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzpzzzzz...

output:

0
0
1
1
1
1
1
1
1
0
1
0
1
0
1
0
0
1
1
0
1
0
0
0
0
1
1
1
0
0
1
1
0
1
1
0
1
1
1
1
1
0
0
1
0
1
1
1
1
1
0
1
1
1
1
0
1
0
1
1
0
1
1
0
1
1
1
0
0
0
1
1
0
1
0
0
1
1
1
0
1
1
1
0
0
0
1
1
0
0
0
0
0
1
0
1
0
1
1
1
1
0
0
1
1
1
0
1
1
0
0
0
0
0
0
1
1
1
0
1
1
0
0
1
1
0
0
0
0
0
1
1
0
0
1
0
0
0
0
1
1
1
0
0
0
0
0
0
1
1
...

result:

ok 500000 tokens

Test #24:

score: 0
Accepted
time: 247ms
memory: 379484kb

input:

0 5 500000
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww...

output:

1
1
1
1
0
1
0
1
0
1
0
1
1
0
0
1
0
0
1
1
0
0
0
1
0
1
0
0
1
1
0
1
1
0
0
1
0
1
0
1
0
0
1
0
1
0
1
0
0
1
1
0
0
0
1
1
0
1
0
0
1
1
0
1
0
1
0
1
0
1
1
1
1
0
0
0
0
0
0
1
0
1
1
0
1
1
0
0
1
1
1
1
1
0
1
0
0
0
1
1
1
1
1
0
1
1
1
0
1
1
1
1
0
1
1
1
1
1
1
0
0
1
1
1
1
0
1
1
1
1
0
1
1
1
1
1
1
1
0
1
1
0
0
0
0
1
1
1
0
0
...

result:

ok 500000 tokens

Test #25:

score: 0
Accepted
time: 295ms
memory: 422140kb

input:

0 2 500000
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv...

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 tokens

Test #26:

score: 0
Accepted
time: 270ms
memory: 408224kb

input:

0 2 500000
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww...

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 tokens

Test #27:

score: 0
Accepted
time: 496ms
memory: 433132kb

input:

0 2 500000
sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...

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 tokens

Test #28:

score: 0
Accepted
time: 519ms
memory: 433872kb

input:

0 2 500000
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo...

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 tokens

Test #29:

score: 0
Accepted
time: 462ms
memory: 433316kb

input:

0 2 500000
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww...

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 tokens

Test #30:

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

input:

0 2 500000
uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu...

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 tokens

Test #31:

score: 0
Accepted
time: 753ms
memory: 519380kb

input:

0 1 500000
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...

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 tokens

Subtask #3:

score: 20
Accepted

Test #32:

score: 20
Accepted
time: 795ms
memory: 511356kb

input:

0 1 1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

1

result:

ok "1"

Test #33:

score: 0
Accepted
time: 354ms
memory: 271432kb

input:

0 2 1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

1

result:

ok "1"

Test #34:

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

input:

0 2 1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

300001

result:

ok "300001"

Test #35:

score: 0
Accepted
time: 425ms
memory: 318524kb

input:

0 2 1
bccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaa...

output:

33334

result:

ok "33334"

Test #36:

score: 0
Accepted
time: 584ms
memory: 415332kb

input:

0 2 1
bccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaabccbaa...

output:

100001

result:

ok "100001"

Test #37:

score: 0
Accepted
time: 453ms
memory: 319248kb

input:

0 2 1
bcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcdeedcbaabcde...

output:

20001

result:

ok "20001"

Test #38:

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

input:

0 100 1
a
j
w
z
m
h
d
n
f
c
k
z
f
c
m
d
v
o
e
w
t
r
j
j
e
l
q
q
m
y
a
a
q
g
i
e
y
p
k
x
c
q
t
b
c
r
l
n
e
t
x
d
x
w
a
a
p
g
e
v
x
o
r
v
e
n
t
s
t
x
u
y
l
x
bcddcbaabcddcbaabcddcbaabcddcbaabcddcbaabcddcbaabcddcbaabcddcbaabcddcbaabcddcbaabcddcbaabcddcbaabcddcbaabcddcbaabcddcbaabcddcbaabcddcbaabcddcbaa...

output:

74976

result:

ok "74976"

Test #39:

score: 0
Accepted
time: 368ms
memory: 300172kb

input:

0 2 1
epppipfhwh
wnybdiecccdcqdrdyrrrzrxizicvvvrvoxpxnpppspbnknmuuupuykckegggqgwctclhhhihvonooxxxrxwujuussswsxltlujjjpjxysyudddydrqeqozzzgznsislcccjcqlilyjgfxccctchvlvqfffhfvcpcyrrrqrstntomxvvvmvgprpawwwpwnjmjyjjjdjpbnbevvvovadmdrzzzpzothtekfffaflnwngkkkxkycncczzzgzsgvgldddjdnqmqyzzzbzwmhmmaaahawrvr...

output:

47042

result:

ok "47042"

Test #40:

score: 0
Accepted
time: 357ms
memory: 315884kb

input:

0 2 1
eoaxlzjsyyyysyyyysysyysyssysyysyssyysyyssysyssyyssysyssyysyyssyyssyysyyssyysssyyssyysyysssyysssysyysysssyyssavvhuqyhpetbpcplkobyavffffnffffnfnffnfnnfnffnfnnffnffnnfnfnnffnnfnfnnffnffnnffnnffnffnnffnnnffnnffnffnnnffnnnfnffnfnnnffnnbbbbsbbbbsbsbbsbssbsbbsbssbbsbbssbsbssbbssbsbssbbsbbssbbssbbsbbs...

output:

4748

result:

ok "4748"

Test #41:

score: 0
Accepted
time: 347ms
memory: 316416kb

input:

0 2 1
llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll...

output:

13476

result:

ok "13476"

Test #42:

score: 0
Accepted
time: 413ms
memory: 461452kb

input:

0 2 1
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...

output:

47

result:

ok "47"

Test #43:

score: 0
Accepted
time: 550ms
memory: 470800kb

input:

0 2 1
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

4

result:

ok "4"

Test #44:

score: 0
Accepted
time: 437ms
memory: 310892kb

input:

0 3 1
bbbbabaaabbaaaaabbbbabbabaabbbaaabaababbbabbaababbaaaababbaabbbaabbbababbbbbbababaaababbbbaabaabbaaaabaaabaabaabbbabaabaabbbaaaabaabbabababbaabbaaaaaababbbbabbabbaabaaabaabbbbaababbaabababbaabaaabbaabababbaabaaaababababababbaaaababbbabbababbbabaaaabababbaaabbaaabababbaaaabaaababbbaabaabbababba...

output:

0

result:

ok "0"

Subtask #4:

score: 20
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #45:

score: 20
Accepted
time: 250ms
memory: 134552kb

input:

0 50000 500000
bbbaa
a
abbaabbba
bbbbbaababbbbaabbbbbaaabababbbbbbabbbba
b
a
abaabb
bbbaba
ababbab
abbbba
bbabab
b
aabb
bab
ab
abaabaaabaabababbbaaabaabbbaabbbbaaaaa
babba
babaaabbabbb
bbaab
abb
babbbbaaabbbbbbbab
aaabbababbbbbbbabbbba
bbaabbabababaa
bbbbaaaaababbabaa
bbbaaababbbb
ababbababbababaaaa...

output:

6
14
5
0
0
0
0
0
0
16
0
0
0
0
0
0
0
1
5
0
3
2
3
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
6
0
0
1
0
4
0
0
0
0
2
1
0
1
0
2
0
0
0
0
22
0
0
28
0
0
2
0
0
3
5
0
0
0
0
0
0
0
0
0
0
21
0
0
0
0
1
0
1
18
3
0
1
0
0
2
9
0
0
4
0
0
0
25
1
5
1
0
0
8
0
0
2
6
0
0
0
0
6
0
0
0
0
0
0
0
0
0
0
0
10
0
0
1
0
1
1
2
0
0
2
2
0
0
0
...

result:

ok 500000 tokens

Test #46:

score: 0
Accepted
time: 611ms
memory: 295480kb

input:

0 10000 500000
abaabbbbbbaabbabaaaaababbbbaaaabbbabaaaabaaabaaaabaaaaa
abbbabaaabaa
aabababbbabababbaaaaabababbababbababaabababbabaabbaaabbabbaaabbbaaababab
bbbbbbbbbbaaaabbbaaabbaaababbabbaabbabaaaaaaabaabaabaaaaaaaaaabbaabbbaaaabbabaaaaa
abbaaabbaabbaaababbaaaabaaababababaabbaabaaaababbbbbbabaabbb...

output:

0
0
0
0
5
3
0
0
0
0
0
0
0
0
0
0
16
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
0
0
0
0
0
0
0
0
7
0
0
0
0
0
0
0
0
8
0
21
0
3
0
0
0
0
20
0
0
0
0
0
1
0
0
0
0
2
18
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7
0
0
0
0
0
0
0
0
12
0
0
0
8
0
9
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
36
0
0
0
0
0
0
0
0
0
0
0
0
0
11
0
0
0
0
0
0
0
0
0
0
9...

result:

ok 500000 tokens

Test #47:

score: 0
Accepted
time: 156ms
memory: 193424kb

input:

0 100000 500000
esiot
s
grmaqr
im
ixwnxky
oi
grcbnl
b
ca
xob
dypwxgpefk
ghlxscoq
xv
uumjttkubpe
j
g
mt
vr
dn
guf
y
yslq
epnbrwbddoprbhs
d
myh
gdfevmw
noqptzbjsdpfqi
zjpjftajy
h
ibbx
hlmbldu
e
rbvqxtpzpe
shlmt
l
hgxvfmtc
umbjmzrvzhwnb
vfeer
hgzuid
la
q
u
lkzny
lkaeyrj
cf
fdk
cqfsfsuuo
o
qabrwhl
ca
dg...

output:

0
0
1
4
2
13
0
0
0
2
3
0
1
0
2
0
4
0
8
2
0
2
0
15
0
0
0
0
1
14
0
0
0
15
0
0
3
0
0
3
9
4
2
3
2
1
0
0
9
0
3
0
0
0
0
1
0
4
5
0
0
0
4
0
1
0
8
0
9
3
8
0
7
0
1
6
4
1
0
8
4
0
0
0
0
2
0
0
2
0
2
0
2
0
0
1
1
2
1
1
1
0
0
0
0
0
1
0
0
1
1
0
4
0
4
2
1
2
3
2
1
0
2
0
2
4
14
0
21
0
0
2
3
2
0
1
0
2
7
0
3
3
0
5
1
0
4
...

result:

ok 500000 tokens

Test #48:

score: 0
Accepted
time: 445ms
memory: 405620kb

input:

0 10 500000
pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp...

output:

0
0
1
1
1
0
0
0
1471
2829
0
31520
4
0
4
83857
1
1
0
83857
0
0
0
3
136935
0
1471
0
168454
0
1
0
0
0
0
4
1793
0
1
0
0
1
0
0
0
31520
0
0
0
0
83857
0
0
0
0
0
1
0
0
1092
0
0
0
0
0
0
0
1
0
0
0
1
0
31520
0
0
0
1
4
1471
0
31520
0
0
1471
1471
0
1793
0
1
0
0
1
0
0
0
0
0
31520
1793
0
0
3
0
0
0
0
4
0
0
1
1
0
28...

result:

ok 500000 tokens

Test #49:

score: 0
Accepted
time: 545ms
memory: 380624kb

input:

0 10 500000
yyhwfjbfbzfdfddffcrciiaaiqgltihhhoyfefccauauufddfqqnnmmjjjmbbbyyypkhkhahaacccgywswhpsppwvvwwwwvvaaaavgoimmhhihshhhmkhsqqqwzdeddoodshhhmixxxxzdjjppfyykifbbbbxfxxpvkvwwhbekkbnncjnnnotrqqwwhhttttthttthmhvrkoozzzzzozkvzzzczzllljuafmmmfekqweddjltljllfffwwwqqkzmmmvuevaiiaomiixqjkzkuudzsseefffh...

output:

0
1
0
0
1
0
0
0
1
0
1
0
0
1
0
1
8
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
1
4
0
0
0
4
0
8
0
0
0
0
0
1
0
0
0
0
1
0
1
0
0
1
1
0
4
0
0
0
0
1
0
0
0
4
1
0
0
9
9
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
1
0
0
0
45384
0
0
0
0
9
0
0
0
0
0
0
0
0
0
0
0
0
0
4
1
2
0
0
2
0
0
1
1
0
1
1
1
0
0
8
0
0
0
0
0
0
0
0
2
0
0
45384
0
...

result:

ok 500000 tokens

Test #50:

score: 0
Accepted
time: 497ms
memory: 376252kb

input:

0 100 500000
ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...

output:

0
0
1
0
0
0
0
0
0
0
8910
0
0
0
0
8910
0
0
0
0
0
0
0
1
0
1
0
0
2926
0
0
0
0
3068
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7586
0
0
2359
0
0
0
0
79
0
0
0
0
0
0
0
0
0
0
0
0
0
7182
0
0
7014
0
0
0
0
0
0
80
0
484
0
0
1559
0
0
0
0
0
0
0
0
0
0
3387
0
9164
9839
7785
0
0
0
2926
0
2613
0
0
0
0
338
0
0
107...

result:

ok 500000 tokens

Test #51:

score: 0
Accepted
time: 557ms
memory: 398588kb

input:

0 100 500000
gggggggggggggggggggggggggggggggggggggggggxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxypyyyppyyuyycycyctctccttjtjtjttcccttjtjvjnggnjjjjnjjjjngignjngiignjnggggvbbbvgggigggvvggggggvvfffvvvfffvvvffffvvvvffvvfffvvffgffvuuuvcvvvnvnvnvnnvnvvnnnnvvnnpxpppxxppopplplplululluuxuxuxuullluuxuxaxhqqhxxx...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3539
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2507
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
9
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
67
0
0
0
0
0
0
0
0
0
0
0
0
0
8182
0
0
0
0
71
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0...

result:

ok 500000 tokens

Test #52:

score: 0
Accepted
time: 503ms
memory: 349412kb

input:

0 500 500000
jjjjjjjjjjjjuuuuuuuuuuuudddddrdddddrdddddrdrdddrdrxxxxxsxxxxxsxxxxxsxsxxxsxszzzzzzzzzzzzzzzjjzjzjzjjzjjzxzxzjjzjjzjzjjzjjzxzxzjjzxzxzzxzzxzxxzxzzxznzxzzzzxzxzzzzxznzxxoxoxxznnzxxooxxxxxooxxznnnttnntntnntntnttntntnntntnnnjqqmmddddddddddddddddddddddddddddddgiiiiiiiiiiiiuuuuuuuuuuuuvpotttt...

output:

0
0
0
0
838
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
57
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0...

result:

ok 500000 tokens

Test #53:

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

input:

0 1000 500000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaavvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv...

output:

0
0
0
3
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
158
36
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
89
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 500000 tokens

Test #54:

score: 0
Accepted
time: 460ms
memory: 308560kb

input:

0 10000 500000
lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllluuuuuuuvvvvvvvvvvvvvvggggggggggggggmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmsltjqgljlliv
mkkkkkkkkkkkkkkkjhhhhvvvvoo
ffffffffffffffffffffffgfffffffff
dddddddddddmmmmmmmmmmmiiiiiiiiiiilllllllllllzzzzzzzzzzzxsuhvkwg
lllmll...

output:

0
20
0
0
0
0
1
0
0
0
1
0
0
0
0
0
46
0
1
7
2
0
0
0
24
0
0
0
0
0
0
0
0
0
0
0
0
9
0
0
0
0
1
0
0
0
5
0
0
40
1
7
0
7
0
0
0
9
0
0
0
0
0
0
0
0
0
8
15
12
0
0
0
0
0
0
7
2
31
20
0
0
0
0
0
0
0
0
2
0
0
0
0
37
40
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
11
0
0
2
0
0
0
0
0
8
5
0
0
0
0
0
0
0
0
0
0
0
5
1
0...

result:

ok 500000 tokens

Test #55:

score: 0
Accepted
time: 146ms
memory: 157960kb

input:

0 100000 500000
jfjqtqeh
o
qqq
nnnnndddd
ffppp
xxx
ddcddbiii
iiibb
eeeo
r
muuuu
nxhx
qc
g
xx
pppppccvvxxx
tt
hh
kkkkbyk
uoj
w
fffffffv
voorrr
lll
ccccccccccc
m
ed
jr
f
ddddxv
xxxppprrrlkmp
gfeeee
kkkkqqkpl
v
aaa
juuuuucccccqqqnnnzzzblxa
ecn
xcrnn
u
ppppppbbc
rr
iiiiibbbbbcu
q
bbban
p
ffn
etggwwwwnyz...

output:

0
2
0
0
0
0
0
3
0
1
0
1
2
11
5
0
9
2
1
3
1
1
0
5
0
6
0
5
0
7
10
1
0
4
5
0
2
1
1
1
0
0
11
0
2
7
0
0
1
4
3
1
8
4
1
0
1
4
2
4
4
0
1
0
0
0
0
1
0
4
3
2
11
10
0
4
9
4
1
5
5
0
0
2
14
1
3
0
6
2
4
0
3
0
2
0
3
1
12
5
0
6
0
0
0
0
0
0
8
0
5
0
3
4
5
3
1
0
0
3
5
0
13
11
2
6
7
3
7
0
4
0
2
0
3
4
18
12
7
20
2
0
1
5
...

result:

ok 500000 tokens

Test #56:

score: 0
Accepted
time: 239ms
memory: 221076kb

input:

0 100000 500000
a
kk
t
wv
f
rfpo
tfs
r
ej
nqhl
y
nn
iivo
ur
dn
jjjtttl
o
x
qn
ts
eypr
y
xw
c
f
e
yxyyyyjdf
x
w
e
a
sj
f
j
n
h
a
oa
r
akz
w
jjq
x
o
p
k
l
wt
j
xtq
vc
c
h
u
p
u
ta
ww
w
j
sg
o
fwe
agwq
hz
t
olrn
g
p
r
d
sy
snv
jj
j
rz
t
v
ncu
uuo
d
a
w
x
tttfh
ww
f
oxh
nkee
o
rjatwwyyhhh
f
r
a
kl
k
llz...

output:

19
19
13
7
13
19
13
0
13
3
13
12
15
15
6
12
19
19
19
0
7
19
13
8
13
0
19
6
280059
13
280059
19
15
13
6
19
14225
13
12
15
10495
10495
15
0
0
3
5
5
13
3
10495
19
0
3
4
149254
19
280059
15
8
14
19941
15
2
15
7
14
14
16
9445
19
14
13
13
0
0
12
12
13
3
280059
14
19
19
3
9445
19
15
13
16
10
19
19
19
13
13...

result:

ok 500000 tokens

Test #57:

score: 0
Accepted
time: 280ms
memory: 213572kb

input:

0 100000 500000
hyqnn
w
gsbgfm
ur
cwwp
utos
t
p
vd
f
f
zcs
e
a
k
wg
uwnmg
z
fud
i
o
slbo
u
jg
pp
yi
mhpt
baqkcp
pv
l
wh
w
jex
oil
d
ujhw
ynq
y
htu
vk
v
ll
iiii
rrrlc
zcz
mc
ci
u
q
t
mc
h
b
dl
v
he
hn
ltc
tu
e
k
r
c
aw
g
g
j
i
k
w
i
r
dm
qj
q
f
o
tt
upt
l
k
hl
ffffl
z
kki
f
p
yb
r
ex
h
v
vl
i
j
ccc
y...

output:

5
12272
14
16
44260
62720
2450
44260
1
14
12
12272
5
80969
18
14
0
17
9
45455
4
7
1
14
35954
15
12
15
3
111986
80969
10
16
18
62720
18
2
15
14
2450
14
84070
9
14
2450
3
6
84070
111986
16
14
41874
12
9
68107
80969
111986
1463
1382
10
12
14
16
5
8
2
0
16
12
17
153861
14
15
2450
1
3
10
18
16
3
1
6
14
6...

result:

ok 500000 tokens

Test #58:

score: 0
Accepted
time: 295ms
memory: 209848kb

input:

0 100000 500000
yfii
gl
l
pmw
al
n
kx
e
h
he
te
wkoobbb
rgww
s
iw
ss
nn
ac
upq
dt
co
z
gp
z
bbbo
s
ezy
tt
ug
j
e
g
ggzw
e
o
k
tw
exs
z
d
vv
ct
ms
co
r
x
pzdc
yonnn
kl
g
bd
h
b
r
j
m
ca
alk
vv
jxv
pl
y
xcl
kp
p
dd
al
g
ky
eec
j
efapkn
gj
r
h
b
he
megwwg
q
sw
mq
f
xxm
vka
u
l
y
v
w
w
y
qpxx
dddd
w
v
o...

output:

62952
62952
0
1559
11965
17055
106665
13
4595
62952
75627
14
14
80980
3
12588
106665
14
25684
1215
101032
17055
4466
3
14
80980
14
5118
10
0
5
14
2165
14
13
6
50986
25684
12
9
8
0
4
106665
14
13
0
80980
19
1308
4595
10
3379
106665
7
208
12
80980
50986
62952
63670
106665
0
12588
5118
182
17055
2583
0...

result:

ok 500000 tokens

Test #59:

score: 0
Accepted
time: 444ms
memory: 307672kb

input:

0 10000 500000
kkgs
suji
hhhmhhdrrqd
eyxxxxxxxjjjjjjjggggggggggggggsssbbbpqvm
hhhhhhhhhhhgji
lllllllll
uuu
bbbbbkap
hh
tttttxxxoooccccccccctttg
fffrre
kkx
ssssssssssssssssssssssssssszyzyzyzyzyzyzyzzyyzzys
mmmmmuuuuuuuuuuueeeeueuuhaaaaaaaaaaaaaaaaaaaaaaaaaaaaavdiaidqqgglg
eeeeeeeeddddddddzcccccccew
q...

output:

82
36
0
0
31
0
1
0
0
0
0
206277
0
0
3729
0
0
0
0
0
0
8
8
0
0
0
0
0
80
0
0
1
1
0
132
0
47
0
0
0
0
0
0
0
2
0
0
0
131
5
0
0
126
2
0
0
0
41
0
16656
0
9
45554
2688
0
64
0
149
0
0
9
4
6
0
0
52
153
0
158856
0
0
0
13
0
0
5
6
0
0
0
0
43
2
0
0
0
0
0
3
0
109
1
3729
0
0
0
0
116
24
0
3
0
0
5
149
0
0
17
0
1
3
519...

result:

ok 500000 tokens

Subtask #5:

score: 40
Accepted

Dependency #4:

100%
Accepted

Test #60:

score: 40
Accepted
time: 320ms
memory: 279364kb

input:

1 500000 500000
0 a
1 u
1 m
2 l
2 b
4 h
1 v
3 r
2 a
8 w
3 t
8 u
9 q
1 r
6 b
11 d
10 t
13 h
9 p
19 p
6 o
18 j
11 y
19 t
16 c
17 y
17 n
26 n
7 g
28 q
2 d
27 m
12 i
18 w
8 b
34 d
31 r
17 r
20 h
35 o
23 i
19 t
36 e
21 b
36 c
42 x
44 c
43 u
15 c
27 y
39 r
32 x
25 u
52 d
5 g
20 z
7 r
14 y
47 n
35 w
28 c
5...

output:

1
0
1
0
0
0
0
0
0
0
3
2
8
0
0
0
0
4
0
7
5
0
0
5
0
9
0
0
0
0
3
0
0
0
0
0
0
0
1
0
5
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
1
2
0
0
0
0
0
3
0
0
12
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
7
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
9
0
0
0
0
1
1
0
1...

result:

ok 500000 tokens

Test #61:

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

input:

1 500000 500000
0 i
1 i
0 e
3 b
0 f
3 b
2 a
7 f
5 d
0 e
2 c
9 f
1 h
1 e
6 f
8 b
5 a
11 d
17 c
4 b
8 j
3 h
7 f
23 g
7 j
4 d
7 c
16 b
11 j
8 j
0 e
27 e
22 g
15 a
12 c
6 i
32 d
14 h
17 j
20 f
32 c
4 d
18 d
17 g
27 b
10 f
42 a
35 d
34 b
8 i
15 h
25 b
18 c
49 j
28 h
23 a
29 i
2 f
58 b
30 a
60 i
53 h
27 h...

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

result:

ok 500000 tokens

Test #62:

score: 0
Accepted
time: 443ms
memory: 182364kb

input:

1 500000 500000
0 c
0 c
0 c
1 c
3 b
2 a
1 c
2 a
1 a
2 a
9 c
10 c
11 b
10 b
3 a
5 c
6 a
13 c
1 b
9 b
19 c
8 c
7 b
2 a
16 b
16 a
4 a
9 a
9 b
20 c
19 a
23 c
20 b
19 c
27 c
17 a
26 a
21 b
4 c
29 b
2 c
15 b
4 b
11 a
13 a
27 c
46 c
28 c
0 a
32 a
24 c
2 a
45 a
43 a
42 c
5 b
46 b
49 c
8 b
26 b
39 a
3 a
25 c...

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 500000 tokens

Test #63:

score: 0
Accepted
time: 177ms
memory: 89584kb

input:

1 500000 500000
0 a
1 a
1 a
1 b
3 a
5 b
6 b
7 a
1 b
4 b
0 a
5 a
3 a
5 a
9 b
11 a
6 b
2 a
11 b
11 a
14 b
1 b
1 b
6 b
23 a
12 a
21 b
20 a
15 a
25 a
10 b
0 b
7 a
28 b
28 a
8 b
12 b
36 b
36 b
24 a
23 a
12 a
19 a
35 b
21 a
35 a
10 a
31 b
11 b
40 a
40 b
13 a
34 a
48 b
23 b
5 b
17 a
52 b
19 a
41 b
20 a
15 ...

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

result:

ok 500000 tokens

Test #64:

score: 0
Accepted
time: 33ms
memory: 43784kb

input:

1 500000 500000
0 a
1 a
1 a
2 a
3 a
3 a
0 a
4 a
6 a
8 a
7 a
4 a
8 a
10 a
7 a
1 a
14 a
11 a
15 a
14 a
0 a
20 a
14 a
3 a
1 a
5 a
16 a
20 a
4 a
0 a
6 a
8 a
23 a
13 a
29 a
32 a
35 a
30 a
19 a
11 a
12 a
10 a
18 a
7 a
38 a
43 a
26 a
34 a
33 a
5 a
3 a
24 a
11 a
27 a
11 a
22 a
45 a
38 a
55 a
37 a
59 a
31 a
...

output:

3
4
0
9
0
6
0
3
2
4
0
6
0
0
0
0
0
0
0
0
0
0
0
0
0
2
2
0
7
0
0
7
0
0
0
6
3
0
0
7
0
6
1
0
0
0
0
9
0
4
0
12
9
0
1
12
0
0
0
4
2
2
9
5
4
0
0
0
5
0
1
2
1
0
4
2
6
0
0
0
0
0
0
0
0
0
4
0
0
0
0
11
3
0
2
3
0
3
4
6
4
5
0
0
3
6
9
0
2
0
7
0
2
0
3
3
0
7
4
0
0
0
0
1
0
1
0
0
8
0
4
4
0
7
0
5
2
0
6
8
0
3
0
0
0
1
0
0
1...

result:

ok 500000 tokens

Test #65:

score: 0
Accepted
time: 763ms
memory: 405156kb

input:

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

output:

52259
53392
0
0
58084
58993
0
38845
0
0
54640
0
0
152386
69134
50392
0
0
0
114729
0
0
19817
161773
0
125908
0
47935
0
54872
123185
38633
81688
0
159068
0
54906
0
58834
74130
80575
1258
39757
0
47137
75140
124433
61082
1
99668
44916
45747
118176
76995
0
45226
77131
0
139155
6836
89397
0
13765
0
0
1
4...

result:

ok 500000 tokens

Test #66:

score: 0
Accepted
time: 763ms
memory: 406740kb

input:

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

output:

11108
0
3404
14609
21446
14257
11535
94119
53681
0
118138
50517
1
0
0
130225
0
0
0
0
0
18177
1
133326
70147
60228
0
25631
0
0
1
0
37803
124244
1
32034
35576
0
46679
0
1
40292
84383
0
25765
116167
946
88892
0
49845
3369
71321
57143
0
0
52824
0
0
0
16033
0
29335
20161
0
22377
1
14430
0
0
1
11154
0
0
0...

result:

ok 500000 tokens

Test #67:

score: 0
Accepted
time: 719ms
memory: 439936kb

input:

1 500000 500000
0 s
1 a
1 f
2 g
1 v
5 n
2 e
3 o
3 o
5 m
10 v
4 f
7 z
5 y
1 s
13 l
7 o
12 h
6 h
11 h
10 o
13 q
12 h
3 f
0 s
10 o
22 p
27 d
9 g
1 p
6 b
22 k
8 r
15 n
7 s
27 j
20 x
6 b
19 k
22 k
27 c
12 t
15 m
5 m
19 a
14 l
29 o
19 w
34 z
22 p
26 f
27 r
19 d
33 c
53 b
29 f
32 z
12 z
5 f
14 k
26 n
2 s
2...

output:

0
0
1
1
111450
118061
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
38405
148134
1
0
0
2
104742
99981
0
0
87181
0
0
0
0
0
0
1
0
0
1
57745
0
0
77712
0
0
0
0
0
90284
0
140109
0
0
21261
0
5466
1895
40905
0
0
0
0
140156
0
0
0
0
0
23709
0
0
0
0
0
0
62560
0
0
0
0
0
155552
0
0
0
105812
0
0
0
0
0
0
0
0
0
0
16372
0
0
...

result:

ok 500000 tokens

Test #68:

score: 0
Accepted
time: 715ms
memory: 440824kb

input:

1 500000 500000
0 k
1 p
0 h
2 g
2 v
1 a
1 w
2 q
1 p
4 l
8 z
11 v
12 o
8 b
14 d
8 j
12 h
3 o
0 i
4 r
3 t
19 t
20 a
14 k
6 c
7 n
2 x
22 m
2 l
15 h
12 z
12 w
10 p
12 b
26 h
15 b
0 r
8 c
9 v
10 y
37 k
24 l
14 v
12 k
40 t
10 s
46 d
17 w
5 y
30 e
7 g
26 k
5 q
46 w
36 g
23 a
9 w
25 z
47 h
15 n
5 j
5 u
13 n...

output:

0
0
0
0
131078
0
101874
0
0
0
1
0
0
0
0
78838
0
0
0
0
0
16393
0
0
0
0
0
1
0
0
1
1
0
0
62847
0
0
0
0
0
0
40237
0
0
0
0
0
0
0
0
0
1
0
112602
0
0
0
1
0
1
0
0
0
72930
0
0
0
0
76639
0
0
135996
0
48975
23583
70132
0
0
1
0
0
0
0
0
0
0
0
0
0
0
3
0
0
85965
0
0
0
0
0
0
0
51527
36602
0
0
0
0
0
1
0
0
0
0
0
0
0
...

result:

ok 500000 tokens

Test #69:

score: 0
Accepted
time: 738ms
memory: 440960kb

input:

1 500000 500000
0 y
0 f
0 j
2 k
0 e
2 e
1 h
0 n
1 m
3 v
3 g
2 e
10 l
1 m
12 t
3 m
8 e
13 z
5 t
6 n
8 m
0 a
16 u
9 g
19 q
8 m
8 i
20 v
6 z
29 o
5 f
2 j
16 w
2 o
0 e
6 s
24 i
29 l
31 o
23 l
18 p
40 h
25 v
16 j
15 y
38 d
15 r
31 j
16 g
41 l
40 d
16 w
43 g
27 i
28 v
10 n
19 y
39 w
38 n
24 j
36 a
17 t
47...

output:

0
0
0
45696
1
0
0
0
0
0
0
5
0
0
0
0
0
0
0
0
0
0
13274
0
0
0
0
0
0
0
0
0
0
32052
0
0
0
0
83699
0
55174
0
0
0
0
0
0
0
0
59627
0
0
0
0
6803
79599
0
0
0
0
1
0
35639
0
0
40231
0
0
7126
0
0
0
0
0
0
8171
0
0
36292
479
0
34047
68086
0
59010
0
0
0
0
7036
0
0
0
52114
0
0
0
45061
75830
0
0
0
0
0
0
0
7
0
0
0
56...

result:

ok 500000 tokens

Test #70:

score: 0
Accepted
time: 858ms
memory: 474160kb

input:

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

output:

124375
25348
3720
40597
233147
1
132741
20961
96222
89206
143461
121529
76753
30192
187329
205491
127655
45560
69110
0
47530
56186
55350
0
1
163161
243891
248418
173276
2567
21827
182766
135720
67026
141912
82246
1
159360
1
71364
253654
231136
38881
45510
1
182983
73106
0
188020
1
1
55571
168274
524...

result:

ok 500000 tokens

Test #71:

score: 0
Accepted
time: 814ms
memory: 475296kb

input:

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

output:

195100
0
254859
111111
170786
28053
0
88678
48783
43215
106232
235108
61321
132299
1
9820
148904
134800
159791
56251
142885
1
71655
115925
1
197866
216160
85571
103284
247303
28558
87036
0
208379
31076
59961
7095
251513
40055
188739
212478
3737
77504
210199
1
0
197615
63079
0
1
126713
220243
22113
1...

result:

ok 500000 tokens

Test #72:

score: 0
Accepted
time: 873ms
memory: 475044kb

input:

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

output:

31722
30258
9770
84138
0
50712
0
92856
119668
0
13312
72729
70956
104868
71857
91183
0
47506
42199
1
71619
0
9226
1
121936
83988
99382
85542
107679
126471
84186
58085
121542
0
75103
37441
105362
0
0
55031
61993
78290
127771
136138
101950
101504
18678
62507
0
90066
1
61156
51120
110368
77470
37729
26...

result:

ok 500000 tokens

Test #73:

score: 0
Accepted
time: 973ms
memory: 532328kb

input:

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

output:

257724
152126
51825
72241
136487
91466
68700
180850
247249
29142
108978
197289
80927
317557
18470
15496
421784
402443
428843
391255
126002
218912
32959
330606
15194
229113
197824
59953
37164
317128
137023
206586
92065
179448
166827
17149
28056
154300
326624
97422
42837
307965
32814
97665
11599
14378...

result:

ok 500000 tokens

Test #74:

score: 0
Accepted
time: 1021ms
memory: 532068kb

input:

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

output:

6855
137803
46117
28625
34092
102207
39264
75141
14211
31334
160005
17039
120409
189125
58677
6258
168837
84960
48536
63949
20636
64444
1090
109564
97197
9577
87847
75246
19981
3966
91963
138142
134939
113380
111899
15157
13687
29666
159846
67837
125140
103147
52846
60286
153536
131110
120360
79807
...

result:

ok 500000 tokens

Test #75:

score: 0
Accepted
time: 855ms
memory: 461992kb

input:

1 500000 500000
0 z
1 w
2 f
2 d
0 e
4 v
0 n
6 u
0 c
7 x
3 l
3 a
0 b
1 g
8 k
12 d
3 v
8 q
13 j
12 d
14 d
16 n
12 e
9 m
1 b
20 c
23 a
23 m
15 d
9 z
20 y
13 y
32 s
17 z
1 l
26 c
15 c
30 o
15 v
32 s
12 z
38 b
17 d
28 a
40 v
2 s
16 y
10 r
23 e
33 l
11 a
4 l
26 r
14 i
54 e
35 e
32 z
19 d
6 v
0 r
16 i
26 z...

output:

0
1
17568
0
2
0
0
0
34
0
0
17213
0
0
0
0
9
0
4
0
0
0
48942
2
0
15
5
0
16
0
0
6026
0
0
1
0
0
0
0
49184
0
31845
0
0
1
0
0
1
0
0
0
0
20912
0
1730
0
12
0
0
0
0
0
0
1
7
0
3
2
1
0
0
0
19132
35124
0
0
0
29
0
0
1
0
0
1
0
5
1
0
0
8
0
26756
1
0
0
7713
10
0
31310
0
2
3
0
0
0
0
0
0
0
0
0
0
5
0
12
0
0
0
0
0
1
0
...

result:

ok 500000 tokens

Test #76:

score: 0
Accepted
time: 865ms
memory: 459484kb

input:

1 500000 500000
0 p
0 r
0 d
3 u
1 m
1 k
2 x
0 g
1 m
0 j
5 h
1 f
0 c
12 q
12 y
7 b
4 g
8 a
15 r
8 i
1 k
7 n
1 x
16 y
3 p
21 b
19 i
8 g
4 z
5 p
3 b
26 s
32 w
28 c
14 r
2 e
19 n
16 z
14 i
29 m
13 w
34 h
18 x
21 j
14 b
44 f
41 b
34 y
25 l
7 o
35 m
1 k
45 x
28 c
39 x
48 u
40 l
37 y
12 s
31 u
17 p
41 e
28...

output:

37539
1
48262
0
1
8
0
5231
2
5
2
0
0
0
0
0
0
0
0
33997
4
0
0
45520
49321
3
0
0
0
1
0
0
0
22891
2
2
7
0
3
0
0
2
1
0
11
4
3
0
1
2
4
41055
0
42552
0
0
0
49113
21765
0
24850
0
0
0
0
0
0
48801
8905
30050
43719
2
4
36411
0
0
1
36490
0
13427
1
1
2
0
0
0
0
0
49053
6
0
36597
0
0
0
13
18363
49907
2
0
31
0
9
0...

result:

ok 500000 tokens

Test #77:

score: 0
Accepted
time: 834ms
memory: 463420kb

input:

1 500000 500000
0 j
0 q
0 s
1 q
3 d
0 d
5 m
2 b
1 b
3 j
8 q
3 k
10 o
11 x
9 d
3 d
14 d
16 k
18 z
4 i
18 v
20 b
22 y
15 g
9 u
18 f
16 u
9 b
22 d
22 j
9 i
7 m
4 w
4 c
30 n
18 h
22 l
2 f
5 y
18 k
6 b
38 g
35 n
18 w
18 d
43 s
31 e
25 f
17 k
35 n
31 v
2 o
41 o
42 s
21 v
4 g
25 b
51 y
52 p
9 t
35 e
2 i
26...

output:

46837
0
21324
0
0
0
0
6
0
1
0
0
1
21717
36716
7377
0
2
35880
1
0
0
0
41031
1
0
12336
1
12579
9271
0
21839
0
13889
0
0
0
3
22386
0
6538
0
0
0
15617
0
10520
0
0
0
0
0
44747
0
0
0
0
20870
6684
1
46651
1
0
0
49492
0
0
0
2
48645
2
0
5785
1946
22510
0
0
3846
0
912
0
0
0
7262
0
1
0
0
1
575
3168
0
15430
0
1...

result:

ok 500000 tokens

Test #78:

score: 0
Accepted
time: 832ms
memory: 463960kb

input:

1 500000 500000
0 d
0 w
1 a
0 f
3 q
3 a
6 y
0 u
8 l
6 j
4 q
1 p
6 j
8 k
7 s
12 s
9 c
16 o
13 f
17 k
15 p
7 o
21 l
1 b
18 l
3 e
12 n
3 d
5 h
19 y
0 a
9 r
22 c
17 g
14 s
31 j
27 l
21 s
18 d
4 n
1 n
23 o
27 f
33 i
16 g
13 x
6 u
0 d
9 n
34 u
12 j
30 g
20 m
10 v
9 d
7 v
41 x
24 v
35 q
13 i
8 j
55 l
19 l
...

output:

0
0
43730
0
0
0
0
1704
1
1
2
43018
0
0
0
0
0
0
48013
1
0
0
0
0
0
0
0
2
1
0
4
2
0
0
0
0
0
0
1
0
8271
0
2
27498
0
0
1
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
11394
0
0
0
0
0
0
4
0
1
0
1
0
8
0
0
0
2
0
0
0
0
0
0
7
0
1
0
0
0
0
1
0
2
0
0
0
2
0
0
0
0
0
0
3
0
0
0
0
2
1
0
1
0
1
0
0
47687
0
2
0
0
0
0
0
0
...

result:

ok 500000 tokens

Test #79:

score: 0
Accepted
time: 892ms
memory: 468548kb

input:

1 500000 500000
0 x
0 r
1 u
1 x
0 z
2 p
3 n
2 k
4 v
5 r
3 v
7 q
7 v
3 q
11 f
7 u
1 v
2 b
3 w
9 w
18 a
20 d
21 q
9 f
20 y
4 l
8 r
11 t
23 l
28 s
6 h
22 l
23 g
20 g
27 k
7 m
24 j
7 y
25 u
33 t
35 s
19 u
28 v
30 v
43 w
32 w
31 y
24 f
1 u
8 p
9 s
39 s
28 d
24 k
49 b
44 k
56 o
54 v
40 n
52 d
22 q
12 u
16...

output:

17077
0
0
0
0
0
0
0
0
0
0
0
1
34613
0
2
0
0
2
40481
1
0
1
2860
1
0
0
0
0
2
2
0
0
41769
44540
0
1
41374
0
0
3
0
0
0
7331
0
0
0
1
2
0
0
0
0
0
0
0
0
0
0
0
1
0
47729
0
3870
0
0
0
0
0
0
0
2931
48076
0
0
0
2
29909
0
0
0
0
0
0
0
0
0
11
0
0
0
0
11475
0
0
0
0
0
33841
0
0
0
1
27
0
0
1
0
0
0
0
0
0
4
0
48503
0
...

result:

ok 500000 tokens

Test #80:

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

input:

1 500000 500000
0 u
1 o
0 e
0 m
0 y
2 a
6 m
3 j
6 d
4 p
1 i
10 r
7 h
1 e
11 e
14 a
16 w
10 k
4 k
0 o
20 n
3 q
22 r
17 h
10 d
22 j
8 i
26 l
11 e
5 w
4 h
4 t
7 l
8 a
10 e
27 x
23 o
3 g
21 o
22 a
30 f
13 v
36 j
32 y
2 l
36 f
40 a
7 y
34 z
16 q
5 s
5 c
46 i
12 z
28 u
17 p
34 q
36 j
26 b
45 j
47 f
14 t
1...

output:

0
0
31257
0
0
0
0
0
0
1
0
0
2
21353
0
16055
31344
0
13565
5
0
44073
31931
0
0
15869
0
480
0
22186
5
0
46725
1
1
0
5
3086
0
0
24657
41972
1
47302
21291
24170
40895
18497
0
46812
15857
10886
0
0
0
2
0
0
0
0
0
0
0
7
5104
8
0
0
21790
13569
0
17960
2
0
24208
32538
22578
0
0
23486
2
24381
0
40998
42932
33...

result:

ok 500000 tokens

Test #81:

score: 0
Accepted
time: 832ms
memory: 451172kb

input:

1 500000 500000
0 z
0 o
0 j
0 g
4 g
3 n
6 v
0 q
3 z
3 x
9 n
5 o
0 w
5 e
3 a
1 e
9 s
1 g
9 d
8 a
4 i
1 z
7 j
23 v
11 n
19 x
6 g
20 n
24 y
8 l
3 d
19 z
12 p
13 n
29 x
33 f
33 z
34 v
22 a
27 k
31 s
4 g
15 b
11 s
44 l
10 l
26 r
25 z
8 f
8 v
42 z
26 t
0 f
32 j
45 p
35 u
51 e
37 a
31 t
58 j
34 u
20 a
27 r...

output:

0
0
0
0
11
0
26
0
0
0
10
1
6
30852
3
42427
0
1
40399
13
0
0
0
0
7525
0
1019
0
8
0
0
1
1
0
0
0
0
0
0
0
0
0
24
0
0
0
0
0
1303
0
6834
285
0
12
0
0
0
8692
73
0
6
0
0
1
0
0
35764
0
2744
0
48106
0
0
0
41
0
20
0
0
42338
0
40693
0
21
0
0
0
0
1
0
0
0
12
0
0
0
1
1
0
174
0
7726
20677
0
0
0
0
0
25052
49341
0
0
...

result:

ok 500000 tokens

Test #82:

score: 0
Accepted
time: 820ms
memory: 457124kb

input:

1 500000 500000
0 t
0 k
0 t
0 s
3 c
0 d
3 b
6 z
7 k
0 i
1 j
4 t
10 o
8 i
14 j
0 r
12 n
3 b
4 m
18 w
4 o
20 x
9 u
12 m
8 g
19 j
4 h
11 x
12 o
3 c
8 z
11 w
28 l
15 r
14 y
26 d
10 w
0 q
11 y
20 u
29 h
7 z
18 d
3 o
27 r
23 v
9 f
16 t
26 e
33 r
24 q
7 b
2 h
22 a
26 l
14 t
2 k
8 q
13 g
21 w
10 w
46 t
45 x...

output:

0
0
49733
2
0
15103
125
0
38532
0
0
0
34685
1
0
0
0
0
2
0
25586
0
6632
0
1
0
38615
0
53
0
1
0
0
0
0
0
0
35334
0
0
4
0
1
5
0
3946
41392
1
39589
1
8
0
0
1
0
0
171
0
1
0
0
3446
0
13372
596
0
25391
0
44924
45386
0
1
0
28698
0
0
47315
8
0
1
23
40135
0
0
0
6
1
35682
0
0
0
0
0
0
27682
40665
49399
0
0
7
2
0...

result:

ok 500000 tokens

Test #83:

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

input:

1 500000 500000
0 e
1 n
0 g
1 d
1 r
3 q
0 r
6 v
0 q
6 w
4 l
4 e
11 n
11 v
5 v
10 m
10 v
11 f
5 d
14 s
7 s
21 s
2 t
5 a
23 e
15 g
23 s
16 b
28 v
8 y
2 d
1 h
7 e
1 w
4 x
23 v
0 c
17 r
1 p
20 d
39 m
20 a
25 r
13 m
10 n
27 l
4 h
39 q
3 w
47 i
33 a
18 u
21 q
30 e
10 j
25 f
27 e
22 a
3 h
20 n
58 x
0 e
45 ...

output:

0
0
0
0
0
0
0
0
0
0
23788
20366
0
1
795
21873
0
15073
0
0
17818
0
0
0
1
19339
0
0
0
0
0
27217
0
24667
0
1
0
0
1
2993
1
0
1
41280
35913
0
18802
0
0
0
9918
1
0
0
10110
40148
0
0
18679
0
0
0
1
0
0
1306
0
1
0
9081
0
0
23323
0
1
0
15896
0
0
0
0
0
0
0
0
0
0
2463
0
0
7
0
23884
0
0
0
24986
0
0
0
0
20839
0
6...

result:

ok 500000 tokens

Extra Test:

score: 0
Extra Test Passed