QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#359254#3039. CleaningFlamireAC ✓103ms148868kbC++174.5kb2024-03-20 15:21:132024-03-20 15:21:14

Judging History

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

  • [2024-03-20 15:21:14]
  • 评测
  • 测评结果:AC
  • 用时:103ms
  • 内存:148868kb
  • [2024-03-20 15:21:13]
  • 提交

answer

#pragma gcc optimize(2,3,"Ofast")
#include <bits/stdc++.h>
#define id(i,j) (((i)-1)*m+(j))
#define N 1000011
#define TIME chrono::steady_clock::now().time_since_epoch().count()
using namespace std;
namespace IO
{
	char Is[(1<<21)+10],Os[(1<<21)+10];
	int Ipt,Opt;
	char gc()
	{
		if(Ipt==1<<21)Ipt=0;
		if(!Ipt){Is[fread(Is,1,1<<21,stdin)]=0;}
		return Is[Ipt++];
	}
	void flush(){fwrite(Os,1,Opt,stdout);Opt=0;}
	void pc(char x)
	{
		if(Opt==1<<21)flush();
		Os[Opt++]=x;
	}
	int read()
	{
		int x=0;char ch=gc();while(ch<'0'||ch>'9')ch=gc();while(ch<='9'&&ch>='0')x=x*10+ch-'0',ch=gc();return x;
	}
	void write(int x){if(x<10)pc(x+'0');else write(x/10),pc(x%10+'0');}
	char readc(){char ch=gc();while(ch<'A'||ch>'Z')ch=gc();return ch;}
}
using namespace IO;
int n,m,q,ans[N];char s[1011][1011];
struct edge{int v,next;edge(){}edge(int _v,int _next){v=_v;next=_next;}}e[N*3];int head[N],sz;
void init(){memset(head,-1,sizeof(head));sz=0;}void insert(int u,int v){e[++sz]=edge(v,head[u]);head[u]=sz;}
int dfn[N],low[N],stk[N],scc[N],nscc=0,w[N],clk;bool vis[N];
void tarjan(int u)
{
	dfn[u]=low[u]=++clk;vis[u]=1;stk[++stk[0]]=u;
	for(int i=head[u];~i;i=e[i].next)
	{
		if(!dfn[e[i].v])tarjan(e[i].v),low[u]=min(low[u],low[e[i].v]);
		else if(vis[e[i].v])low[u]=min(low[u],dfn[e[i].v]);
	}
	if(dfn[u]==low[u])
	{
		scc[u]=nscc;++w[nscc];vis[u]=0;
		while(stk[stk[0]]!=u)scc[stk[stk[0]]]=nscc,++w[nscc],vis[stk[stk[0]--]]=0;
		--stk[0];++nscc;
	}
}
long long SS,CNT,S1,CNT1;
namespace sol_1
{
	int id[N],rk[N],in[N],nid[N],gg[N][4],tg[N][4];bool vis[N],ok[N];vector<int> G[N];
	int Q[N],ql,qr;
	struct kueri{int S,T,id;};vector<kueri> vq[N];
	void bfs(int s)
	{
		ql=qr=0;Q[qr++]=s;vis[s]=1;id[++id[0]]=s;rk[s]=id[0];vis[nscc+1]=1;
		while(ql^qr)
		{
			int p=Q[ql++];
			++in[gg[p][0]];
			if(!vis[gg[p][0]])
			{
				vis[gg[p][0]]=1;
				id[++id[0]]=gg[p][0];
				Q[qr++]=gg[p][0];
			}
			++in[gg[p][1]];
			if(!vis[gg[p][1]])
			{
				vis[gg[p][1]]=1;
				id[++id[0]]=gg[p][1];
				Q[qr++]=gg[p][1];
			}
			++in[gg[p][2]];
			if(!vis[gg[p][2]])
			{
				vis[gg[p][2]]=1;
				id[++id[0]]=gg[p][2];
				Q[qr++]=gg[p][2];
			}
			++in[gg[p][3]];
			if(!vis[gg[p][3]])
			{
				vis[gg[p][3]]=1;
				id[++id[0]]=gg[p][3];
				Q[qr++]=gg[p][3];
			}
		}
	}
	void Solve(int x)
	{
		bfs(x);
		ql=qr=0;
		for(int i=1;i<=id[0];++i)if(!in[id[i]])Q[qr++]=id[i];vis[nscc+1]=0;
		while(ql!=qr)
		{
			int p=Q[ql];
			nid[++nid[0]]=p;++ql;
			if(vis[gg[p][0]]&&!--in[gg[p][0]])Q[qr++]=gg[p][0];
			if(vis[gg[p][1]]&&!--in[gg[p][1]])Q[qr++]=gg[p][1];
			if(vis[gg[p][2]]&&!--in[gg[p][2]])Q[qr++]=gg[p][2];
			if(vis[gg[p][3]]&&!--in[gg[p][3]])Q[qr++]=gg[p][3];
		}
		for(int i=1;i<=id[0];++i)id[i]=nid[i];
		nid[0]=0;
		for(int i=1;i<=id[0];++i)rk[id[i]]=i;
		for(int i=1;i<=id[0];++i)tg[i][0]=rk[gg[id[i]][0]],tg[i][1]=rk[gg[id[i]][1]],tg[i][2]=rk[gg[id[i]][2]],tg[i][3]=rk[gg[id[i]][3]];
		for(kueri k:vq[x])
		{
			if(!vis[k.T])continue;
			ok[rk[k.T]]=1;
			for(int i=rk[k.T]-1;i;--i)
			{
				ok[i]=id[i]==k.T;
				ok[i]|=ok[tg[i][0]];
				ok[i]|=ok[tg[i][1]];
				ok[i]|=ok[tg[i][2]];
				ok[i]|=ok[tg[i][3]];
			}
			for(int i=1;i<=rk[k.T];++i)ans[k.id]+=w[id[i]]*ok[i];
			for(int i=1;i<=rk[k.T];++i)ok[i]=0;
		}
		for(int i=1;i<=id[0];++i)rk[id[i]]=vis[id[i]]=0;id[0]=0;
	}
	void main()
	{
		for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)if(!dfn[id(i,j)])tarjan(id(i,j));
		for(int i=1;i<=n*m;++i)for(int j=head[i];~j;j=e[j].next)if(scc[i]!=scc[e[j].v])G[scc[i]].push_back(scc[e[j].v]);
		for(int i=0;i<nscc;++i)sort(G[i].begin(),G[i].end()),G[i].resize(unique(G[i].begin(),G[i].end())-G[i].begin());
		for(int i=0;i<nscc;++i){for(int j=0;j<G[i].size();++j)gg[i][j]=G[i][j];for(int j=G[i].size();j<4;++j)gg[i][j]=nscc+1;}
		for(int _=1;_<=q;++_)
		{
			int a,b,c,d,x,y;
			a=read();b=read();c=read();d=read();
			kueri k;k.S=scc[id(a,b)];k.T=scc[id(c,d)];k.id=_;
			vq[k.S].push_back(k);
		}
		for(int i=0;i<nscc;++i)if(vq[i].size())Solve(i);
		for(int i=1;i<=q;++i)
		{
			if(!ans[i])pc(48),pc(10);
			else write(ans[i]),pc(10);
		}
		flush();
	}
}
int main()
{
n=read();m=read();q=read();init();
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)s[i][j]=readc();
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
			if(i>1&&s[i][j]!='U')insert(id(i,j),id(i-1,j));
			if(i<n&&s[i][j]!='D')insert(id(i,j),id(i+1,j));
			if(j>1&&s[i][j]!='L')insert(id(i,j),id(i,j-1));
			if(j<m&&s[i][j]!='R')insert(id(i,j),id(i,j+1));
		}
	}
	sol_1::main();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 75224kb

input:

1 1 1
L
1 1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

5 5 5
DDDDD
RDDDL
RRDLL
RUUUL
UUUUU
1 1 5 5
2 2 5 5
3 3 5 5
4 4 5 5
5 5 5 5

output:

0
14
20
14
5

result:

ok 5 number(s): "0 14 20 14 5"

Test #3:

score: 0
Accepted
time: 3ms
memory: 77424kb

input:

10 10 15
DDDDDDDDLU
LRDLRRDLLU
DDDLRRDLLD
RRLLDUULLD
RRLLURLRLD
RRLLRRLDLU
RRLLURLULU
UULLURLULU
DRULUUUULD
RRRLDRLRLD
7 4 2 5
4 7 6 8
6 6 5 6
5 6 9 6
9 10 5 5
2 5 4 3
7 9 4 4
10 9 1 5
9 9 8 9
1 4 7 8
10 2 5 10
7 9 1 3
7 6 7 7
5 6 10 2
2 6 4 2

output:

41
41
41
41
0
0
0
0
20
0
88
0
41
0
0

result:

ok 15 numbers

Test #4:

score: 0
Accepted
time: 59ms
memory: 108308kb

input:

1000 1000 300000
RLLLURUDLURULUURLUDDLDDDRDDRUUDLLURRDDLLDRDLLRRRULUULLRRLRURRLLUUUUDUDDLUURDULDUDRRRUDLULRLDRDDUDULUUURLDUDDDUULLURUDRLRDLRULDUDUDDDLDUULRUUDLRLDURURLDDLLRRUURLULLRULLDURUDDDRUUUURUULRRRLLDLLUURUULDDLDRDLLDURLRDURLRLLDLUDLRULDUUDLDLULLULDDLUDLLLRURRRUUDLRLDLDLRDULRUDDURDRRLDRLRULDUL...

output:

0
0
0
0
0
0
245868
0
0
0
0
0
0
0
0
0
0
0
0
98541
0
0
0
89575
0
361225
0
262684
0
0
0
0
0
0
0
0
0
0
0
0
311462
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
361225
0
0
0
0
0
0
0
0
0
62676
0
0
136413
0
0
0
0
246844
0
178165
0
62676
361225
136413
0
0
361225
0
361225
0
0
0
199089
0
0
0
311462
0
0
262684
0
199...

result:

ok 300000 numbers

Test #5:

score: 0
Accepted
time: 67ms
memory: 116264kb

input:

1000 1000 300000
RRUDRRRRRDUULRUDLLULDRUDLDUDUDRUUUDURDDDRLURUURDURLDRDUUDUDLLUDDLRUDULUDDULDUULRRLUUDLLURLLRLDRLLDRDLUUDRDDUDRLLRDDDRURLRRDUDRRURRUDRRURRLLDULULRUDLLURDDULURDUULLUUUULLRURLLUURRUDLDUDRLLUDLDUDRLUUUUURLDRUDLRRLLLRRDLLDLRDUULDUDDULRURRDLRUDDRDLDLDDRLDRLRUDUURDURUURRDRRDLDLDDLRDRDLDDLL...

output:

0
0
321495
0
0
321495
0
321495
321495
0
0
505626
0
0
0
79631
0
0
0
0
0
0
0
0
371285
79628
0
321495
155278
0
0
0
0
0
0
469795
0
72655
0
0
0
0
0
0
0
0
71676
469795
0
321495
0
0
371285
54713
0
321495
0
0
0
0
0
0
589228
505626
321495
321495
0
0
0
321495
425998
0
589228
0
0
0
0
0
0
100484
0
0
321495
0
0
...

result:

ok 300000 numbers

Test #6:

score: 0
Accepted
time: 81ms
memory: 109964kb

input:

1000 1000 300000
RDLURLRUDLRRLRDULRLRLULDDLRRLDLRRRLLDDUDULDLLRLURUURUUDRRRURDURLRULRRUDDLLUDRDLDLULDLDLULRDRDDLDRURLDRDRLLURRDLRDRRRUURRRURDRUDLRDDDLRULULDLDLRDDRRLDURLLLURRLLLULRLLRRDDDLRDDDLRDRDDUDDDUDRDRURDRRULDURLRLDDLURLUURUUURLRUDRRURDLDLUDDLLDRRULLULULRRLLDLLLUDRRDUULUDRRRRUUDDDUULRURLUDLULD...

output:

0
0
142351
0
366329
0
0
0
0
0
0
0
0
0
0
154199
0
154199
0
0
0
0
0
119290
0
54685
0
0
0
0
366329
0
142351
0
0
0
0
0
0
280656
212130
0
0
0
0
0
0
0
0
0
0
0
366329
0
69779
0
0
0
280656
0
139334
0
0
0
0
223978
0
0
366329
0
0
0
0
157316
0
0
223978
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
119450
227095
0
...

result:

ok 300000 numbers

Test #7:

score: 0
Accepted
time: 81ms
memory: 109740kb

input:

1000 1000 300000
LLLUDDULLDLRDLUURDUDURLDDURRLLRLRDDLURLDLRLLDLDLUDDRRLRLLDRRRLUULRLLLLDULDUDURURDURRURLDLRULUULURRLRLULUUUUDRURRUULRUUUDDURULUDLUUUULUUURUDLRRDURULLURLDUDUDUUDLDRLDDRRUURDRRRURLURDRRURRRLDLURURRRUDRUDLLLUDDRRDULDLUDUDDRRLRRLDULLLURULDDLDDLDULRDLULLDUUDUULRURULULRLRUDLLLURRRDLRUULURD...

output:

0
0
202971
223079
0
0
0
0
0
0
0
142349
0
0
0
223079
0
223079
0
0
0
0
0
142349
0
197961
90544
47763
0
0
0
223079
0
0
0
241901
0
0
0
0
0
241901
223079
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
223079
0
0
0
223079
90544
0
0
0
0
0
0
0
0
0
0
90544
0
0
215933
0
0
0
0
99552
0
367428
0
0
0
0
0
99552
0
0
0
0
0
223079
...

result:

ok 300000 numbers

Test #8:

score: 0
Accepted
time: 55ms
memory: 108508kb

input:

1000 1000 300000
URRLURLRLRDDDULLDDLDLLRRUDLRLRDDDRLURRDRDULLUDUDUDRDUUDUDUURRRDDRDLDURLURDLRRLRURLLDUDUDDLRUDDLDDRDLUULRRULUDUDUDUURDUDDLDRDLRDLDRRRDDDUUDLRURULLLUDLRDUULRRDUDLLDDRURLDDLRLUDRUDRDRRDLLUDULDUDLDLDLLURRRLDRRDLLDURLLRLDDLRULDUURLRLDRLULDLRRULUURULRULDLUDLLUDULRDULRDLLDLDRLLRLRLLLDLUDLU...

output:

0
0
190077
0
0
298685
0
0
229985
0
0
94594
0
0
0
72683
0
0
0
0
0
0
0
0
229985
0
0
0
0
0
0
72683
0
0
229985
0
0
229985
0
0
0
0
0
0
65663
190077
0
229985
0
0
0
229985
0
0
148298
0
0
0
298685
0
0
159235
0
0
0
0
0
0
0
0
0
0
0
0
0
0
229985
0
94594
0
0
0
0
0
0
0
0
0
0
0
0
229985
0
0
0
0
0
0
0
0
54726
0
72...

result:

ok 300000 numbers

Test #9:

score: 0
Accepted
time: 103ms
memory: 114468kb

input:

1000 1000 300000
LULDDDLUULDUDLRURDURLDRDLLURLRRRURLRLURDUULDUDLULLLDLUUURURLRLDRDUDLLLUULURURLRRDURDDDDDDRUDRDDRLDDULDDULRURULUUDLDRRRUUDLUUUUDULLUDDDRULLLLRUDDRRDDLDRULLUUDLLDDURUDULLRUDUURLLRUDRRUUDDURDURDDRRRUDUUDRDLULDLRLDDUURRURURLDDLLUDLUULRRLLRLUDDRUDDLDDLURULDRLRRLURUDRDDRLDURDRDUULRUURUURR...

output:

0
0
0
174103
209015
0
0
0
0
0
0
0
0
0
0
88503
0
0
0
0
125408
0
0
0
0
0
0
0
33830
0
0
0
0
0
0
0
0
301590
0
0
0
0
0
0
0
0
301590
0
0
0
0
0
209015
0
0
0
0
0
0
0
0
0
0
0
161244
0
0
125408
0
0
0
0
0
0
0
0
0
0
0
0
0
252895
0
0
125408
0
62707
0
0
252895
90581
0
0
0
0
0
0
0
0
0
301590
237813
85600
0
57768
0...

result:

ok 300000 numbers

Test #10:

score: 0
Accepted
time: 70ms
memory: 119904kb

input:

1000 1000 300000
LRDRULDLURLUDRLRUULUURRDRUURLRLLLDRRDRDUDUUDDRDDLLUDLDRDDRDLUURRDDDDLDULDLRRDDUUDUDDUDRDRDRRULDURLLDRRUDDDLULRDLRRDUDLDULUURDDUUUULURRLDLUDLDULLRULDDLDRRRLRULLRULRRULUURUUDDDLDLRURRUUURURLDDULURURLDUDDURDRRDRLRLUDULLLDLDDULDDDRDDDUUDRUDUDURLDURRLDURDRLLLRUDLRDDRLDDLDRLLRLRDLLDRUULUU...

output:

189161
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
313577
313577
0
189161
0
313578
0
0
0
0
0
414142
0
0
0
0
0
0
0
0
0
0
0
0
0
0
527591
0
313577
313577
181089
0
0
0
0
0
0
0
0
181089
0
0
0
80635
181090
502738
0
0
80635
0
189161
313577
0
0
0
502738
527591
0
0
0
0
0
0
0
0
0
0
0
0
133381
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 300000 numbers

Test #11:

score: 0
Accepted
time: 68ms
memory: 120276kb

input:

1000 1000 300000
DUDDRRLDLURDURULDRDLDLLLRURUDRDDLULLLUDDLRRDRLULDRLDURULURLURDDDRLUURUDLRDDRRRDDUURDDRULLDUURUDURRDRRLDRDURLLDRUULLRRLDRURRUULUURDRULDRRLRULRLULUUUDLUDRRRRLUDLULDRRLLLURRDRRLURURLDLLUDLDDUDURDRLUDUURLDRLLUDUDLLDDLRUULLURLRLDRLUDDDLLLUDURLLLDUUDULRULDDUDLRURRURUURUDULLRRDUDRDLDLRRUUR...

output:

0
0
0
0
0
0
0
166267
152266
152266
160281
160281
0
0
0
0
0
0
0
0
0
0
160281
335415
22868
43787
0
561433
0
0
562410
0
166267
0
166267
0
0
0
0
318533
0
0
318533
318533
0
0
0
0
0
0
0
160281
0
160281
27835
0
0
118463
0
0
0
0
0
0
114452
0
0
90628
0
114453
0
0
312547
0
0
152266
0
0
0
478814
478814
0
0
0
0...

result:

ok 300000 numbers

Test #12:

score: 0
Accepted
time: 68ms
memory: 119176kb

input:

1000 1000 300000
DRLDLRLLUDRRDURLLRRURDLURDULULRRDRRDURRRLRDLLLLDLDUDDDLUDDULRRLDURUURDDURDULUULRDDDRDRLUURDURDDLLDDURDUDLLUURUUUDDLLUURRDUULRRLRUDURULURRRULRURLRUDRLLDRLRLRDUDRLRRLLLUURUDLUURLDRDULDLUULULDULDLRLURLRRRLUDRRUUDRDLLLLRULDRDRUULLDLRULLUUDUDLLURDRUUUUUDLURRLLLLLRRUURURLDRRULDDUDDDLRULLR...

output:

0
0
0
0
0
0
0
95604
0
0
75639
0
102531
0
216065
89502
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
81641
239793
0
0
0
239793
0
0
0
0
148364
0
0
0
0
0
0
0
0
0
0
116469
0
0
0
0
0
0
0
0
0
0
0
0
0
0
113499
0
0
0
0
0
0
0
0
0
0
266649
0
0
0
0
216065
0
0
0
0
0
0
0
0
0
0
113499
0
102531
0
0
0
0
95604
0
0
0
0
0
0...

result:

ok 300000 numbers

Test #13:

score: 0
Accepted
time: 70ms
memory: 119872kb

input:

1000 1000 300000
LULDRUUUUDLRDRRURLDRURRLUDRLDRLLRUULRRRDLDULRDDDLDUDRRURLDUDDLRDRDDLURRDURDRULLDDLDDDUUUDDRUUULUDUDLURRDULLUDDUDULUDURRRLULDLRRDRUURDLLDRLDUUURDDLLLLURUURULRRLLUDDLRDRRDLLLURULDURDRRDUDURDDUDUUULLUDUUUDDLRLLLLLDURDDLURDDRRLRULDLRDUDLDUDLRULDUDLDDURRRLLLRRLDDRLURUULLULRDDRDDULLULLRRU...

output:

0
0
0
94537
0
0
0
0
207008
0
0
0
0
0
0
0
138343
0
272749
0
0
0
0
0
0
0
0
0
0
0
0
0
0
138343
195091
0
0
57674
0
0
0
0
122445
0
109498
0
0
0
0
182144
70638
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
94537
0
0
0
86607
0
0
0
0
0
0
0
0
239818
0
0
0
0
136370
0
136370
0
122445
0
0
0
0
0
0
0
0
0
0
272749
0
0
0
0
0
18114...

result:

ok 300000 numbers

Test #14:

score: 0
Accepted
time: 58ms
memory: 121132kb

input:

1000 1000 300000
LUULDLLDURULUUUDRLRUDLLLRLDUDLDRRRRDLDDDLUDDULDULURDUDRDLDDLRRUURULDDUURULLRDDDURDDRRULRLRDLLRLLDLUUURUDRRLRDUULRLDDRRDLRLULDUDRULDLLLLRLDLRURULRDDLRLUDRDRLDLRDRDURUURDUDDLLRUUDRDLUDDLURURULUDUDDRRLUDDDDURLDRRLDULRDDRLLRULUDULDRDDRULULRDDULUULRRDDDDURUURLRULRLLLUUUUUULDUUULUDRDRURRU...

output:

0
0
0
0
218951
132405
0
429984
0
0
218951
211033
0
0
201044
429984
0
412077
0
0
0
0
0
0
0
412077
0
0
0
0
0
68649
412077
0
429984
0
0
0
0
0
333363
412077
218951
429984
412077
218951
201044
0
0
63756
412077
0
0
544396
218951
218951
201044
0
0
0
0
0
0
201044
0
429984
0
218951
0
117448
429984
0
0
0
0
0
...

result:

ok 300000 numbers

Test #15:

score: 0
Accepted
time: 61ms
memory: 118640kb

input:

1000 1000 300000
LLUDDULUUUURRRRUDLLUURULLLUULDDLRUDDRRLDRUUURUULDLULDLUULLUDRDURUURULLUDUDDULRLRDDURLDDRRDLUUDURDUDUDRRRUDRRULDDRUULRUDLLLLULDLURLUURDULRLDLDUUDLRLUDDDRUUUUDLDDDDURDULLUDLUUDRLDRLDDDUDRDDDDDULURRRLDRULRLULRRULDLLLRLDRURUUDDRUDDDLRRDLRDDLDLUDUUUDUUDDRLURLRLLUURRDRLRULRLLDDDLRDURURDUR...

output:

116440
0
137326
0
0
0
0
172193
0
0
0
0
0
0
0
172193
0
0
0
0
56716
116440
0
0
0
0
0
0
0
245819
0
0
163205
361188
0
0
104496
0
0
0
0
0
0
178126
405970
0
0
304472
0
0
0
0
0
0
0
0
0
0
172193
0
0
0
0
0
0
0
0
0
0
238861
0
304472
0
0
163205
0
0
0
0
0
0
175165
99473
0
222965
163205
0
0
0
0
0
0
141267
219921...

result:

ok 300000 numbers

Test #16:

score: 0
Accepted
time: 78ms
memory: 118688kb

input:

1000 1000 300000
LDDDURLRUULLRUUUURLDRDRLDDLLUDRLDLDDRLLDUUDUDRRDDLLDUUDLUDDRDDDRULUDDDLURLDUDUDDUULRRDRDDUULLRRURULUUDDURULRUUULDLLLRLDRUDLDRDRDRRLDDRDDRUDDLLLRRLLDDURLDRRLRRLUDUURLDRUULDRURULDDRRLLDURURUDURULRLLLDRRRRLRLUUURUDRLDLRDRDUUUURLULURRLDDLUDDDLURDDRDUULRDUDDDDUDLLURDDRDLUDDLLUULDLULRRDLU...

output:

0
0
202010
0
278655
171249
0
0
0
0
0
121419
0
140299
0
0
0
0
0
353337
0
0
0
0
415019
0
0
0
415019
0
0
0
0
138351
0
0
0
0
0
0
0
395115
0
0
0
138351
0
0
0
0
0
0
0
0
0
77615
0
0
0
140299
0
0
0
0
0
0
0
0
0
198042
0
0
0
0
0
0
0
0
0
0
493641
0
0
214986
0
140299
0
338374
0
57743
0
0
0
0
0
0
0
64613
0
0
138...

result:

ok 300000 numbers

Test #17:

score: 0
Accepted
time: 71ms
memory: 142492kb

input:

1000 1000 300000
DUULULRDLLRDLLULRDLULRDUURRDDDDURRRLLRLRULDLUURLDDULDRLLURRDLRUDURURUDLDDRRLLLLRRRLUURDDDUDLRLDDRDLUDRLDLUUDDUDDUULLLDDRDLUULLRUDRDRDLURLLDLDRDLUUUDURRDDLLRUDRULULURLRRRDRRDULUURRURDLRDDULULLDULDRUDURRULRDULULRRRDLDURRURLDLLRLLRRDDUDDDDUURURLUUUUDRUDRLUDRRRDRRULLDDLDDDDRDRDDUDLRDULR...

output:

995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108
995108...

result:

ok 300000 numbers

Test #18:

score: 0
Accepted
time: 72ms
memory: 141352kb

input:

1000 1000 300000
UDURLRDULUDRRLDUUUUDRUDDRDRDDLLDRUURRLLLDDDDLUULDRDDLLDURDDLLDDULDULLRRDDURLLDRUULRRRLLDURDRLRDULRUULLRLLLLURLDUUULDDDLDDRUDDLLDLDDLLRLUDURUUURDDUDULUURDDUULULULDLUULDRLLUDDUDRLRRRRRRLDDDDURLLLDRURDRRLULDDDDLLDURRDURURRLUDLDDUDRDLLLDURDUDDDUULLRLDLUULRRDULLUDUDLUDUDRDDRRULULDUUDUDDL...

output:

995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238...

result:

ok 300000 numbers

Test #19:

score: 0
Accepted
time: 70ms
memory: 146084kb

input:

1000 1000 300000
LRLRURRURRRLLLLUURULDLURLURDULRDDDRUDDRURULRRURDLRLDLDDLUULULUURRRDDURLDDDLDURRUUUDUULRRUULDRDDURDDRDUULLRUULDDRRUULRUDLRUUUDDULDLRRUURRDLDLDRDLLDRUURDLLRRDRDDDLLLRRLLRRDURRLLLDURRUUDDULRDUULUDULLUULDDUDULLRDDRUDDDLLURDLULULRRURRRRRRUUULRLRRRDDULLDRRRLULLRDUDDRDLURLUDDRRUDLUDLRDRURR...

output:

995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285
995285...

result:

ok 300000 numbers

Test #20:

score: 0
Accepted
time: 61ms
memory: 144940kb

input:

1000 1000 300000
LRRLDUUURRDLUDDLUUDRDRURRULDLDRDDLRLDUDDRULRULLDULRDRDUDUDDDRDLLULURLUUDDDLUUULRUURULLDDDURLULLRLDUURDRRLLURULRRURLULRRDLDULDLRLULLRDDURURDRULDUDRLDDRLRURLRLUDRULDUUURRRRRDRUDDRLDUUDRDUDLUUDLDLLLDULULDRLUDLUULLULRDUUULDUDDDLRUUDUDRRULURDULRUDUUDDDRRDLLDULUDDUUURRULDLDRRUDRDULULDRULL...

output:

995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080
995080...

result:

ok 300000 numbers

Test #21:

score: 0
Accepted
time: 77ms
memory: 146636kb

input:

1000 1000 300000
DDRLURULRULLDRLLLLDDULRRRRLLDRUDLUULLLDDLRLRLRUUDLRDRLRRLDURRLRDRURUURRDDLRURURRLLLLUDRDUURRLRRLULRULLRDDLUDLUUUURDUUULLRLLLDDRDRLRRURUUDLLUULLRDRDULLDRDDLURUDDLDLLDLDURDRLUDUDRDRLDDURRLULURLDRUUUUURLLUUDURULDLRRRLLLRLRDLUDLDLLDDURLLURLDDDDLRUULRLRDURURDLLLURLUURURLLDLLUDLDUULDLRRDD...

output:

995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161
995161...

result:

ok 300000 numbers

Test #22:

score: 0
Accepted
time: 57ms
memory: 145412kb

input:

1000 1000 300000
URDLDRLLLDDURDLLLULLDDLRULLURURUDLDUDURUURLDDLURRUDUDDDUURURLDUDDLRDLRLULDLUURUUUULLRLDDRUDRLLRULUULLUUDDUUDLRUDRDULLRLDRDLULLLURULUDDDRRUDLDLLDRDLULRURLDLRLRRRDUDUDDDDUDDLLDRDLUDRDURLLLRLRDULRUULULDLRULDRLDDUDLLLUDRLDDULULDUDLULLULDRDRULDURRULDLRDUUURRUDRUDDURUUUUUUDRULRLLRDLDULDUD...

output:

995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208
995208...

result:

ok 300000 numbers

Test #23:

score: 0
Accepted
time: 82ms
memory: 144088kb

input:

1000 1000 300000
UUDRLLDLLULRRLRRUDLDDLUDDUUULURRRLRUDUDRRRDUURRDLUURRURDLLURRURLUUULUURDDLURDLUURRUDLRRLDLULULDDRLUDLLDDURRLUULLDUDDDUDRRRLLLRRDLDUDDLRRUDUDDLDURUDLDURRUDUDDRUUDURRDDLRRURRRLRDURRRULURLLRUURLUUUUDRRLLLULURLRDLLLRUDURLURUDLLURUUDLLLRDDURDDLLURRUUUDRRDDLRUDUDRDDRLUUDDRDULDRDLULDULULUU...

output:

995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260
995260...

result:

ok 300000 numbers

Test #24:

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

input:

1000 1000 300000
RRDDLULLDDLRLUURDRDDDRLLRDURDRRUDDUDRDULURURRDDLDULDURLLUUDDRURRRDLRURLUDUUDUDDDULULURRLRLLLDUULDLRDURLDRLRURUDURLDRLURRLLRRDLRRLUUULDUDUUDUULDDLULLDLDUDDUDURDLLDDDRDDLUURDUDLRDLRDRRUDLLRDLUURDLDDDDLDDULRLDUURDRRUUDLUDLDULLRURURRLDDDRULDDRLDURDRDRLURUUDUULLULRRRRDLRRRDLULRRUDLLUDURL...

output:

995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
0
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995202
995203
995202
995202
995202
995202
995202
9952...

result:

ok 300000 numbers

Test #25:

score: 0
Accepted
time: 64ms
memory: 143792kb

input:

1000 1000 300000
RRLRRULULDRUDRUDLDRDDLDULURLDRULLRULRUDDUDDLLUDULDLUDURULLLUDDDURDULLDRRDDLLUDUURURRURUURLRDUDDRLULDDLURRRURLDDDDDLLDRDLLDDRDRRLRDULULUDDDRDUDDULRDURLRUUDDLUDDURLRDLRDUULDUDDLLRRULUDDDDUDRUUDUUDDDDUUUDRUDRDLDDLRRULRLDDDDUDRDDLRDRLULLLURLLDRLDDDURDLURURRDLRLDDUULRLDULRDUDLLUDURLRRURR...

output:

995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182...

result:

ok 300000 numbers

Test #26:

score: 0
Accepted
time: 66ms
memory: 144552kb

input:

1000 1000 300000
LDLUDDRUULRDDURUUDUDDDULLLDLDLUDDDDUUDUURLDDLUUDRLLRLDDRLDULRRRRRRURDULDULURUDRRLUDRURRDULDLDLDRUDUUULDDRDRUDDDDLLLURDDRURRRDRUDRUDUULUDRDDRDRUUUDRLUUULLRDLLULLRDRLRLLRUUUDLLLUUUDLULDRULDDRRDDUDUDLLDRDLDULDRLDRLRDDULLLUUDRRRLDLULLRRDRUULLRDURRRLULLDDLLDULRURDRUDLLUURLLRURUDURURRUUDD...

output:

995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241
995241...

result:

ok 300000 numbers

Test #27:

score: 0
Accepted
time: 96ms
memory: 145972kb

input:

1000 1000 300000
UURLRRURLLULLLURDLURUDDRDLDRLRURDRRURDUDDDDDLLLUDLRDDRDRUUDURUDDRRULDULDLDUUDDRLRRULUDLDLUUURDRLURUUULLUUDUUDLUDUUUDURULUUULLRDUDDULLLURLURURLUULRLUULRUDRURLDLLDDURLLRULLDUURUUDDDULLUURUURDUDDLLUURRLULDLUDDDUDLRDRRLRUUUDUURDURUDLDRLULUUULRDLLDDRRDDRRURULLURDUDUDDURLRUDDRLLRLURLUDRUL...

output:

995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090
995090...

result:

ok 300000 numbers

Test #28:

score: 0
Accepted
time: 67ms
memory: 143868kb

input:

1000 1000 300000
RDURUDLRURLLLDDLDRULRRDRRLLDLDLLRRDDDDRRULULDDLRRLULUURLDRRDDUUURLUUULRDRRLRLUUDULRDRRDURDRURLRLLRUULDULUURLDDURUDRLDURDUULLDRURRDRLRRULUULLLLLRLLDRLULDDLLDDLRUDDDRDDDUUUULLLRULRLLDDDLRDURLLUURLLULLLLULRLRLRLLDRDDLDRRURRLUDDLDLLLDURRURDRRRLDDLLULLRLLUUURDLUUDRULRRUURDLUDDUDDDDULRDLD...

output:

995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
0
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
9951...

result:

ok 300000 numbers

Test #29:

score: 0
Accepted
time: 94ms
memory: 147040kb

input:

1000 1000 300000
UUDLRRDLLLDLRULRRLLDUUUDLRRDDLLURRLRLDRDDLDURLUDULRURDLULLLRDLRRURRLUURRLRRURRLRUUDDDLLLRDUDRURLLLUDDLDLRDLDDDLLDLDRDDRRLRRULRLRLUDRLRDRRRLULLRLLLURLDDRLDLRLLRRRDDLRRULRUULULUDUDDLDURURLDLLRDULDRLUURUDDDRUULLLULULLRRDUDLDULLLDLLLRURRDRLRUURRLULLRLLLLLLUDRURUUDLRDLULURDUDRLURLDLDURDR...

output:

995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052
995052...

result:

ok 300000 numbers

Test #30:

score: 0
Accepted
time: 64ms
memory: 145532kb

input:

1000 1000 300000
DULDUDLLURDURLURDUDULRDUULLLRUDDLRUUDLDLDULLLRDRRDLURRRDDDDLDLRRDLLULRDULRULLRRRDRRRLLLURLRRDUDDRUUULLLRLUUUUDDLLDULLLRRDLDRUDUDLLULRLRLDURRRRDLLLRDUDUDLDLLRDLLURDLUURLDULDDDDLDDLLRLLUDRRUURUDDRDDURUDLURLLULLULLRUDLUDULLUUULUDLUUDLUDUDLDRUULULUULLLULDUDDRDUDDLLRUUURLRUDDDLDURULLDUDU...

output:

995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
995073
0
995073
995073
9950...

result:

ok 300000 numbers

Test #31:

score: 0
Accepted
time: 69ms
memory: 146100kb

input:

1000 1000 300000
DUURUDLUULUULUUDLLULRLLDRRUULRLRLDUURLUUDRDUDLULRUDRULURLUUUDUURDDDLRURURLURUDURLLUULLURUDLRDLLUDRUDLRLDRLDRRDDUDURUUDRDULRULRRULLDLLDDDRULLRLLRLDRLDLRDRURDDUDLUURLLLRRLDDUUDRLRDRULDULLDUDLDUDLLRULURRLLDDLRDRDULULURDUURLDURUDUDLULUDRDUURDULLRRDUDDDLDDLDUUDUULDUURUDRRLLRLDRLURUUURURU...

output:

995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182
995182...

result:

ok 300000 numbers

Test #32:

score: 0
Accepted
time: 67ms
memory: 144140kb

input:

1000 1000 300000
LUURUDLULLRLDURUUDLLLULRLULUULDDDRUDRULDLDLRRLULDRDRURDRRLUDDDRURDLLRDLUDDDLRURDLUDURRDRDLURRDUULLLRULRDLRRLDULRDDDUDDDRURDUUDLRDURLLRRURRLULDRLURLUUDDDDULRLDDLRDRLUDULRDDUDULLLDLDLLLLLRLUUURRLRDDUDUURDURDLLURLURURDLURLRDLLLDRDDLDDRULDRUULDRRUDUUDLDURDURLDUDDURLRLUDRRLDLRLULLDDDRDLL...

output:

995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232
995232...

result:

ok 300000 numbers

Test #33:

score: 0
Accepted
time: 69ms
memory: 144320kb

input:

1000 1000 300000
RRURLLDDUULDULLRLRRRDRLUUUUDDLULDUDDDRDLURDDLDLLUDRRRLUDRDRRDUDUUDRDUUDRULUUUDLUURLLRDDULDLRLDUDDURLRLRULRDUDLDDDRRULDLRLDDUUUDLRLRDDLLRDURRRLLLDDUDRUUDLDLLUUUURLURDLUUUUUUURLULLURLDDULRLRDUUURRLRDLRDDRRUUUUDDURDLULLDURLDLLLRLRUDDDRRUDLDUDDRDDRLUUULRRDUDDDDLRUURRLURRRULRDDRRLRUDRDUR...

output:

995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995164
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995163
995164
995163
995163
995163...

result:

ok 300000 numbers

Test #34:

score: 0
Accepted
time: 82ms
memory: 144212kb

input:

1000 1000 300000
DUURRDDDDRLLDDLDDRRDLRLURLDURLDLLRURDUUURULDLLLRDUDDUUDRRURLDLDLDLRDDRLLLDUUDLRDUURDLRDDDRLLDULDDRDUUDUURLUDULLLLLDRLUDDUULDLRDDRRDDLUULRDRUDRDDRDUUUURDDLLLLULLULLDDUUDRUUUURLLULDRLLDUDLDLUURLDLLLRRLDLLULLDRRRUDLRULRDLUDULRDUDDUURUDRURRRRDRLDRUDLLRURURDLURDRLUULLDRLURURDRLDDLRLURRUU...

output:

995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212...

result:

ok 300000 numbers

Test #35:

score: 0
Accepted
time: 74ms
memory: 145316kb

input:

1000 1000 300000
DRUUURRDRLLDULRUURRRRDUDUULUUDRUDLLDLDDURDDLULRLRLURUDULDLDRLRDUDRLLRRURDDURURLRUURLRLRUUDDDULRLDULRULDRLDLDRULRRLRUDDLRULLULLRULDULDURUUDUUDUULULLUDULURRLULDRDUDLUUURRLLLURUUUULUDLDRUDUUDLDURRLLUDUDUURDRURDRDRURUUDLRDRLRULDLLLLULLRRURRUDRRRLRUDRLUURLURDLULDULDDDRUDDRULDDDDULRDRRRDU...

output:

995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
0
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
995200
9952...

result:

ok 300000 numbers

Test #36:

score: 0
Accepted
time: 87ms
memory: 143128kb

input:

1000 1000 300000
LRLLLLLDRRDRLRDDLLULRUDUUDURRDDLDURRUULLUULUDDUDRDLUDDRDLRLLLUDRURLRLUDLLRRDRUDUURRDUURUDRLRUUUULLLURURUDUDUURRRRULURUDURLDRDDDUULUURRDDLLRLLLDDLRLDUUUUURRRULDRLRDDULDURDDRRDUDDLUUDRUULURRDLULLRURULLDURULURDURRDUDRRLDDLURURDRDUDLDDDUDLURUDLULRRUULRULDDLURDLRLDLLRRLLLDRLRLRUDUDRURRRL...

output:

995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
0
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
995192
9951...

result:

ok 300000 numbers

Test #37:

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

input:

1000 1000 300000
DRDRLDLLLURUDLDLDRDUURDUULUDRLURDUDDRLLDDRRRUULLURURULDUUUDDLRDLLLUDLDULDURURDLDLRLLDDULRDLLUUDRUDLULULDDULURUDRDRLLURRUULULURDLRUUDLULULLRDUUUURRLDDUULRDULRDULURRRLRDLLDRLUUDRDULULRUDURUULLDDURLLRDUDUUUDRLRLRLRUDDULLLRURLDRULRULUUDDDDDURRULRUDLRLLDLDDRRDUDRRUULULDDDDURLDULRLUUDLDDR...

output:

995169
995169
995169
995169
995169
995169
995169
995169
0
995169
995169
995169
995169
995169
995169
995169
995169
995169
0
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
995169
99...

result:

ok 300000 numbers

Test #38:

score: 0
Accepted
time: 92ms
memory: 145380kb

input:

1000 1000 300000
LDDDUDLRLUUUULRDLRDRRRLLRRUDLUULURUULRRDDDLULDUURDRLDRRRULURRDDDLLDDDLRLDLLLULRRLURDDRDLUDDRLLRDRULUDDDRLDDDDLUDDRRDURULLRURRULRUUULLURDUDLDDUULDLUUDUUURLDDRRDDUUUURRDUUDLRDRDUDLDLLUDDRDDRLUDLLRUUDLDRDLDURLRURRLLDDLLRRUULLUUURDDLDDRUDLUUUUDRUDDLDURDRDDDRURRULLRURRDUDURLRDLRRLUULRRLU...

output:

995162
995162
995162
995162
995162
995162
995162
995162
995162
0
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
995162
9951...

result:

ok 300000 numbers

Test #39:

score: 0
Accepted
time: 64ms
memory: 148868kb

input:

1000 1000 300000
UDRRLDDRLULDRLLLRUURLDRUDLLRUURRLRLDUDRLRUDUDURUUUDDRLDULLDRDURLUDUDLULLRLDRLDURRRDUDLURRUULULLURRUULLUDUUDRDDRULLRDRDURDRRDLURRRLUURULRUDUUDDDULRLDURDDDLDUDLRRRLDLUURURUULRUUURDDULDDUDRULRRURRLLRLLLRDLUDLULUDURRDLUURLDLLRDLRUDRRDRURRRDLLUUDLUDLLLRLLRLLRLLRURURLDRLULUDDDRDRRULLRLDDR...

output:

995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087
995087...

result:

ok 300000 numbers

Test #40:

score: 0
Accepted
time: 65ms
memory: 146572kb

input:

1000 1000 300000
DRURLURUDURDUDUDULDUUDULUDRLDDRULULUDUUUUDUULLDRLRURLDDRUDLDLUULDULURUULUDURLURRLDLUDLUDRRULRLRLDUUDRRRULDDRDLRLRLDRDUUDDLRRRDLLRRULULLDUDRDDLRDLRURLLLUDLDDRLLDURLLDRDDRRLRRRRLDRUDDDRURDLUUURLUDRLDULLUULDUDUULUDDRUURDDRRUUULDUDULDLLULURDDURDLRLDRLLULUDUDRULLUDRRDLDUUDLUDURUULLDDLLRL...

output:

995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085
995085...

result:

ok 300000 numbers

Test #41:

score: 0
Accepted
time: 72ms
memory: 145580kb

input:

1000 1000 300000
ULULLRLRRDUDLRRUDLRDRUUUDUDRLLRLLUDUDULLDULRUUDLRLRDDRLRDRLLLULUDRRRLDRUDLLLRUDLLULRUURRRDDLLLLUDLDRRRUURDLURDDLRDDULLLDLDLUUULRDDLRLRRLULULDULRLDUDLRULUDDLDULDDLDLDDDRDDLLDUDDDRRRLDDDRDLLDDURLRDLURDRLDULDDRURRULDUULDDULRDRUUURRURRUDRLUUUUDRDLRDULRDDDLRLDRLUDLULLURULLLDDUUDLURURURRR...

output:

995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
995101
0
995101
995101
995101
995101
995101
995101
995101
995101
995101
9951...

result:

ok 300000 numbers

Test #42:

score: 0
Accepted
time: 84ms
memory: 147436kb

input:

1000 1000 300000
URDDUULLDLRLRLLRRULDURULLDRRUDDLURUULDURDUDDLLURRUULLRDLRDULLLDRLURURLRULRLUDRRRDDUDDURLLLRRRDLRLUUDRDULRRULLDDDULLURDDRRDURDUDLDLRDLURDDURDURUDDDLLDURURRRRLULRURUURUURDLDRLDDLRRLRUDURDDDUDDLULDRRDULDDLDULLLULRLURLRRUDDDULRULLDRRRLDLURRLUULDUUDRLLRLURRURLLUDRUULULURDRRUULDLUDLRDURLD...

output:

995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004
995004...

result:

ok 300000 numbers

Test #43:

score: 0
Accepted
time: 68ms
memory: 145988kb

input:

1000 1000 300000
RURLLDRUURDLLLUDRDDUDDURLULDRURLRLULRRURURUULDDRRDDDRLRDRULLLRLDRUDUDLDULUDDLRULLDUDLDRRRDRUURDLLLLDUDULLRRLLURUDLLRLLLRUDDURDLUURULUUUDUDDRRURRLLLLRUDLLUURURRLDDRULDDDURLUUDLUDDRUULRLRLDRLLLUDDURULDDRLLRULDURDRDLLUUURLLRDRLURURRURUDUDULDDDURRLUULULUDRULDRDLLDDDDURRLRLUDDLRRULUDLURD...

output:

995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063
995063...

result:

ok 300000 numbers

Test #44:

score: 0
Accepted
time: 72ms
memory: 142928kb

input:

1000 1000 300000
UULDRDRDDUDLDLRDRDRLUULDLRRLDDDLDLDLDUDUULUULRDURUDRDRUULLRLLDDUUDLLULLLUULRUDRUDDDURLDDULUDDRLRUULRRRDUULRULURURURLRDDLDLRRRURULRURUDDLURDDDUUDDRLUULRUUULLUUDRUDRLLRLRRLRRLRLRDRDUURURLUDULRULRLRLRDRULUULLDRLDUURDUURULDDRRRLRLLLULDLLLRLLLUUDDDLLURLLRRLUDRLULDLULLDDDDRRRRDRDRDULURRLL...

output:

995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199
995199...

result:

ok 300000 numbers

Test #45:

score: 0
Accepted
time: 80ms
memory: 145784kb

input:

1000 1000 300000
ULURULLLRULDULDLRDLRRLLDULRLDDURRURRLLUDRUDLDULUDDLLRDDDURULUDULDRRLRLDDLLRRLLRDRURURUUULDRDUDDDURLLRULLULLUDLLRLUULULRDDUURLLLDLDLLDRULDRUDUULRDLDRULDDURRLULLUUDUDDURLLLLRUDRDLLLUULLDDRLDLDDDLLDLDURRLRDUURLULDULRDRUDRUULURRDUURLULDUULDURDRDRRRURRRURUURUDLLULUDRUUULLDRDUULLLLUUDDURD...

output:

994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
0
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
994992
9949...

result:

ok 300000 numbers

Test #46:

score: 0
Accepted
time: 72ms
memory: 142848kb

input:

1000 1000 300000
LUULULRLLRURUDDLURURDLDRLRULRRDRDDRLLURLULDDLDULDRURUUUULDDLLDLULRUDLLLLLUDURLLUUDURLDDRULUDLRUURLRURDDLUURDLDDDRLUDLDLRLRURUULUDURDDUURDDLRUULLDDDULLLUURLLRDDUUDDURURULLRURULDRDRDLDDRRRDUUDRDLLRLRDLDRRDLDLDUDURDRUDLLDUDRLRUDLDLLDUULUDUDUDRRRURDLURRLURDUDULUDLRUDRRULDLLRDLDUDLRRLRLL...

output:

995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224
995224...

result:

ok 300000 numbers

Test #47:

score: 0
Accepted
time: 65ms
memory: 144616kb

input:

1000 1000 300000
LRLRRUUURLLUULDUUURLRULUUDDUDLRDDRDULDLRLLLRUDDUDRLRDDULDRRLLUUUULRLDLDUUDDLUUUDRULLRURDRLDRURDRUDRDULRULDLURDDLLLRUDRDDRDUDULLUDLUURURRUUDRURURURLUDDLULRRDDDRLURLLLUDULLRDRRLRLDLDUURDULLDURDRDDDDLDLRDLLDURDUULDDUDDDRUUULLULUUDLUUURLLULDRDDRRDURLULLDRRLRDURUUDDRLDLURDDLDRDLULUDDUUDR...

output:

995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212
995212...

result:

ok 300000 numbers

Test #48:

score: 0
Accepted
time: 82ms
memory: 143552kb

input:

1000 1000 300000
UULLRRDRRURDULUUUUDUULLLDRDLLLDDLLURULDDRRDDURLRRLUDURLURDUUDUDRRLUULRDLLLLLLRUURRDURULDUURUUDUDRLLLRULDUDDRURRDDDLRLRUUURDRRDDDLRDRLLLDLLLURRLURULRUUULLLDRDDRDURULULRLLURDRRLULRDLRRLUUUUDULUULRRULLLRLURULLUDLLDUURLDLULDDURLURRRDLLRDRRRDURDULRDLRDRULURUUDDLRDLURRURULLULRDLLRUUUDUURR...

output:

995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995128
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127...

result:

ok 300000 numbers

Test #49:

score: 0
Accepted
time: 72ms
memory: 144916kb

input:

1000 1000 300000
LDRUDDRUUDRRUUDURRDUUURURURDULRUURRDUUDLLRUURDRUULURRLUULULDLLUULDDDDLUDLUDDLRUULRUUULURDDRRLRRRRLUURUURLLUURLLDULRDDURRUDULULLRRLUULDUURUUUULURRDRURDULLUDLDRRRRRUDURULDLRLLULRDRRUULURRRDUUULLLLUUULLDLDDDDDRRRLDRRDUUDRLRURDUULRLLLRULLRRLURDLDUDURRUULULDURLUURLDURLLUDRDRULLLDLLRRDDUU...

output:

994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962
994962...

result:

ok 300000 numbers

Test #50:

score: 0
Accepted
time: 74ms
memory: 145144kb

input:

1000 1000 300000
DDDLLDRURLULDURRDLULLDRLDLLLURURUDLRDDUDUDRUDDRDRLRURULLLDURRLRULDDLLURURUDLDULDUDUDRLURRRUDLURULDRDUULLRULRRURULULDLDLDURUDDDULLLDRDLRUURDUDUDURRULDLRULRUURDUULULRRDRUUDRLRRRLRDRRULRLRRRLLULDDDLURURLDDLLURDUULRDDULRURDDLLRDUDLULRURLUDLUUDRUDDRLLDRRRLULDULRUDRUULLRUDURLDLLLRRURRURRU...

output:

995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
0
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
995110
9951...

result:

ok 300000 numbers

Test #51:

score: 0
Accepted
time: 57ms
memory: 145268kb

input:

1000 1000 300000
RUULUULLRUDRDUULDLURLLRLUURDURDLLURUULLLRUULDUDUURRLDULRRDDRDUURDLULRURLLLDDLDRUUDUULLLULDDLUUUUDLUDLDDLDRDDLLRLRRDRDLLUDDLRRLDDDUULDDLDUDLDURRDLLULDRUDRURUURUURRLLRRDLUDRDRLLULDULLULRRURLDDRRRDURDRURLDUURUUDULDDDULRRRLUDDDURDRDUULULLUULDULRLLLUUUDDLLUUDLLDLLLLURUDLUDDLLRUUDDRRURDRL...

output:

995149
995149
995149
995149
0
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995149
995150
995149
995149
995149
995149
9951...

result:

ok 300000 numbers

Test #52:

score: 0
Accepted
time: 79ms
memory: 147524kb

input:

1000 1000 300000
LDURURRLDLURDLLDDURDDLLUDUDULDRDUDUDRRUURRLULRRLUURRRRRUURDLRDRDLLUDLUDLRURRDDDDRURDLRRRURLRRLULURURUUDULDLUDDDLLULURRLRLLRLRDULLRRRUDDRDRLDLRRDLUURDLULDDURLRUULLRUUDLRDLRURRUDURULLUULLLLLLUDDUUUDRLLLRDRRLLDUURDUDRDDULUDLRRRLRUDLRDLRRLRLLULDRRRDURRDUDDRDDRDRRUUUULDURDUUURLURRLLRDRRR...

output:

995206
995206
995206
995206
995206
995207
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995207
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206
995206...

result:

ok 300000 numbers

Test #53:

score: 0
Accepted
time: 76ms
memory: 143688kb

input:

1000 1000 300000
DLRLULDDDDURUUULURLDRUULULUUUDRLLRLULURRLULRURDRDDRUDLUURDULRUDDDURLDDRURUULURLRURRRLDDUDRUDDURURRDULDUDDUUUDURDRLDUURRRUDDUUURLLLLRLURRRULRRLUDRRLDRULLRDUULLDRRRDRRDLRLLLDRRLULULULUDRLRUUDDDDDDDDDRULURDDDLUDLLDDDURRRLRRLRDRULDLLRRULDRDDLLURLRRLDRLDLUUUDRURUUURLLLLUULDLRLLLURLDURUUR...

output:

995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211
995211...

result:

ok 300000 numbers

Test #54:

score: 0
Accepted
time: 56ms
memory: 143604kb

input:

1000 1000 300000
LLDDLRUDULDUDDRURRRULDRRUUDDRRDDRRUUUDDDRUUDLLLUURDURLLLDLLDLUULLURRUUDDRDLDDDLDRDRLDRRDULRRRUURLUDLRUULDURLDRRLLRUUUUDLDUDURLDDLDRDRUDULRRLRLUUUDDLRLLDRLLUUULRRRULRRLLULLUUDUDDDDDRUDURLULRURDRLDRLDDDRRRUDRULRURUURRURRDDRLULLLLULUUUURLRRUDLRDLDDLUUDRDULDUDLUUULUUURRDRRUURUUUUDDDLULU...

output:

995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166
995166...

result:

ok 300000 numbers

Test #55:

score: 0
Accepted
time: 76ms
memory: 144048kb

input:

1000 1000 300000
DLULRURURUDRLDRRRLRLLLDRDUDLDULDRUDDRDDLDDDDDLRDUDRLDDULRLULRRLRRUDLDURULRDUUDRDLRLUDRUUDRDDDRLUDRRDRUDRRRUUUULURRLUDDUUDLRLURDDUUDULUULRLRRLLUURRLRDRDDLDLRDDURDURRUDUULRUURRUUDDDLLDRDURRLDDRRLDLRUDDLDRLRUDRLDULDLLDLUULLDDLLLRLLDRUDDLLUDLDRUUUUUURUDDURLRLLDULLLLUDRRUDUDLLLURDRDDLDLU...

output:

995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127
995127...

result:

ok 300000 numbers

Test #56:

score: 0
Accepted
time: 71ms
memory: 125384kb

input:

1000 1000 300000
DDRULLDULLUURRULRRRDLLDRDUDDDUUULRUUDLDUDLRRURRDDLULLDUDDDLDULDLULDURLDRLRDLRURLLDDRRRDDURULLUDRURUDLRDDLDDUUDURULURRRLDLDRDRDULDDDRDRULLURUURLLLDLRRRUDUULDDDDRDUUULDRRDDLRDRDLUURRLDRRDRDRDUUDLLUDUDRRRDURLRDDDDDUDRURDDUDURRLDUUDRLRRRDLDLRULRUDLRLLLDDLLURLRULLUDLLDDRDUDRRURLURRDLDLRR...

output:

0
417921
273585
498479
0
417921
417921
0
273585
0
0
0
417921
0
0
417921
0
498479
0
273585
0
0
0
417921
417921
498480
0
273585
0
0
0
0
577131
0
417921
0
417921
0
498479
417921
417921
0
0
417921
0
417921
224894
0
224894
273585
0
417921
0
0
0
417921
273585
417921
267682
0
0
498479
577131
267682
0
0
417...

result:

ok 300000 numbers

Test #57:

score: 0
Accepted
time: 69ms
memory: 136484kb

input:

1000 1000 300000
DDLRLULLULRRLUUULRLLRDDLDRDUDDDURULRDDUULDLDRRDLRDRLRRLUURRUDUDRLLULLLDRULLLDLDDDDUULURLDRULRDLLRLURRLRUDRRLUDLDULRUUULDURLRDLRDULURRRDLLDDRLLDULLLRLUUDLLRLDDUULLRDDUDDRLDDRLUURDDURLUDLDLLULLLDDUUULLRLDDLRRLDDUDUUDLRRRRLLDLDURUUDUDRLRLULULURDULRUULDDDDLRLRLRRURLRURRLLURUULLRLLLRURRL...

output:

0
0
892790
558339
558339
0
0
558339
558339
334451
579191
0
0
0
334451
558339
0
558339
974359
558339
558339
0
892790
0
558339
334451
0
334451
558339
0
558339
558339
0
558339
334451
0
0
892790
0
0
974359
334451
558339
334451
558339
558339
892790
558339
892790
558339
0
558339
0
334451
334451
0
558339
8...

result:

ok 300000 numbers

Test #58:

score: 0
Accepted
time: 67ms
memory: 138072kb

input:

1000 1000 300000
DUDLUULDLDULUDLRUDRDLUUUUDDLULLUULRUUULRUUDDDURDDDULRUDUDRUUUULUURUDDURRDDDDDUDLLURRLRURUUDUDLDUUDRRLUULUULLDRDUDDRDDRDRUDUURLLRDRULUDRDRLDUUULRUUUUDLDRRLLRLLULRULRRLLLDUDLLULDUUURUDLLRUDRDDDDLRULLURRLRLLURLRLRUURLLDRDURLLDUULDLDUULLLLDRULLURDDRLUDULUDURDUUDLLUDLRUULUUURDDRDLUUUDRUU...

output:

0
545320
545320
0
545320
545320
545320
0
545320
0
0
0
0
545320
545320
0
545320
0
0
545320
0
0
545320
0
0
0
0
545320
545320
0
0
545320
0
0
0
0
545320
0
0
0
265766
545320
0
545320
0
0
545320
545320
0
0
545320
545320
545320
265766
545320
0
0
435959
545320
265766
545320
0
545320
545320
0
0
545320
0
0
0
...

result:

ok 300000 numbers

Test #59:

score: 0
Accepted
time: 56ms
memory: 144572kb

input:

1000 1000 300000
RUDULDDULLRRURRDUUDDRDDURDLLLDLLLDLDRRURDULDDURLDURLLURUDURLUUUDURDRDDDLDRRLDLDLDDRDUUUDRUULULUUDRDLDLDUDDLLDDURRULDRUDLURLUULLLDDDRDUDRUURURLULULRUUDURLLDRDLRUULDDRULDULLURRLLDRRRULULRRRLDURDUDDURLRUULULLLDUDLDRLLRDRULDULURDUUDDDRRURDLRRURLUUULDRULLDUDDLRRRDLUURRURULURDDLLRDLLLUDRR...

output:

995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995146
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145
995145...

result:

ok 300000 numbers

Test #60:

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

input:

1000 1000 300000
LDRURURLLDLLLDURLDDRRLDDDRLLLDRULLDDULRUDRLUULRRUDRULDDRLRUDURLLUDDRRUURURRURRDUDDURDRRUDDRLRUURLRDDLDDRRDRURRRULUURDDRDDRUUURDLULDDDRUDRUDDDRULRRLRDRRDLUDDRLRULDRRRUDLDRRDULURLDDDDULRUUUDRLLDLRDDUURLUULRDDRDDUDLUDDDURLULRUDUULRRLUDDLURRDUUDRLLLUDULLRDDLLLULRRURURRUULRDLLLLDRUDDDRLU...

output:

995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198...

result:

ok 300000 numbers

Test #61:

score: 0
Accepted
time: 73ms
memory: 145144kb

input:

1000 1000 300000
RUULRRUULRRLULLDDDDRURDDDRLDUDRURURRDLUDUDDRLURUDUDRDUUDDRUUDLDURRUDUURURUULDRUDUDUDURLLRLRRRUDUUUURLDURDDLDRURLRLRRDUDURDRDUUURRUDLDDURUUURDULDRDDURDLUUULUDDLDULLRLDULLRDRRLUUURURDDDUDDRRUULRDLLLDDDDRRLULRUUDUDLURLDRRUUDRRUDRUURULUULULDURDLRURDDDURRLRDDUUULRUDDDRLDLLLULLRURDURDURLL...

output:

995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017
995017...

result:

ok 300000 numbers

Test #62:

score: 0
Accepted
time: 77ms
memory: 142532kb

input:

1000 1000 300000
DDDRLULLLDRRUULLRRDDDRRDRUUDRULLUUULDLDRDLLUDDLRLLRRRLDLUURURUURDURRDDUUUDDLUDUDURRDLUUURULLRULURDRDDURLLLLUULUUDRLLRRUDLLULRDUULLLLRLRRDRRDULUURDLRLLDRLRRLRUDLUUDLRDDRLRDDDRDRDDDDUUDRLLDDDLLRRRLDRUDDULRLDLLRDULLRULULLDRLUDUDDDDLUDLLRURULRLRDDUDLDLUURDLDDRRRLRURDDRULRLDLUUULUDURDLDL...

output:

995238
995238
995239
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238
995238...

result:

ok 300000 numbers

Test #63:

score: 0
Accepted
time: 74ms
memory: 144260kb

input:

1000 1000 300000
URLDDUURURDLLUUUDULLRURLDLLDLDUULRRRRLLLRUDDDRLLDDRDUDDULULDURRRLLDRUUURLDDDLLDLRLUDDUDUUDLUDDDRLLDLRULLLDRRLDRDRRRLRULULDDLLDULDURURDDLURRULULUUDRDLDDDUDUUDDLLRUUDURRLDUURDRUURLULLULDLLRLLDRRLRRLRDLDLRLRDRRUULRLLDUULLRLULRULUUULLDRUDLRDULRRDLUURLRRRRURDRUDDDLURRRDULLRRDULLDULDRDLRU...

output:

995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147
995147...

result:

ok 300000 numbers

Test #64:

score: 0
Accepted
time: 81ms
memory: 145752kb

input:

1000 1000 300000
LUDDLUUDRUDDRUUDDRDDRLRUUDLDRRUDRDRULULRLRDUURLRULRUDUUDULLDLLDDUDULLDUDLRLUULLRRDDUDDDDLRLUDDLLRRDRULDLRLDLURLRRLULULLRUDDUULURDRUDDDLDURRDLRRRRUDLLDURDDLLDDLRULDUDDUDDRDDRDRLLLULULLLULURRLLDDULLRULDDULDDURDRRDURRRRLURLLDULRUDUDDLULRRDDRRDUUDDLUULRRRLDLLLRRDURDUDDLDULRLLRUDRRLDRUUR...

output:

995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250
995250...

result:

ok 300000 numbers

Test #65:

score: 0
Accepted
time: 63ms
memory: 147464kb

input:

1000 1000 300000
DUUURRLUDLRULURRRDRLUUULRDUDDLLUULUDULDRDRULRLULRLUUDRRURLUDRLULRRLUUULLDDRDRULDDRLURLLLURRURUULRRDRRDLUDURRLLLULDRRDUDURDLDUULDUURLUULULDLLDDUURUDLDRDLLLDURDRRULLLLULDDRLRULLDLURDDLRURDURLDDUURRDURLLUDLLDLLUDRLLURUURDLDDRRDLDRLULLDRLRDLLRRUDRDLRRRLDRLRLRLLDDRDURLRUUUDURRULULURURDUU...

output:

995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995137
995136
0
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
995136
9951...

result:

ok 300000 numbers

Test #66:

score: 0
Accepted
time: 79ms
memory: 148856kb

input:

1000 1000 300000
URULRLDUDUURRLDLUDUDLRULLUUDDLURRUUDUUURLDLLLRDUUUURRDULLLDURDRDRLDRULDRLRLLRURUURLRDDRDULLUDLDURDDDLDRDRDLDLUURRULLDULUUUDLDLUDDLLULLUURDUURDRDDUULLLDRLUULRUUDRDDRDRUDDLRRUULUURUDDDULLULRUDRUULRURULLLLUUDULDLLDRULLLLRDUURUDULDULUDURUDULRRLLUDUULLUDLULDDDDRDULDRDRLLURRLUDURLUDLDRDDR...

output:

995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107
995107...

result:

ok 300000 numbers

Test #67:

score: 0
Accepted
time: 70ms
memory: 143996kb

input:

1000 1000 300000
URDRLLLDRUDLDLURRLRRRLRULRRUDDUUDLLRDLDULUDDLLLLULLULLDLUUUDRUULDLDLDURRURRUUDRRULUURLLLLLDRULRDDDLUDULDULLDLRLDLULLURLLLRDUUDDUDUUURRDUUDRDUDURRUDUDLDDRRDUDDURLURLURDDRUUDLUULRLLDDLURRURRURDDRLDDLDLLULDRRRRRDUDRLLUUULUURLDLLUDDRLRLDDUUDLDLRDLLLDULUDDRURLDDLDRRUDDRLLRDRDRDRRDRUUULUR...

output:

995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203
995203...

result:

ok 300000 numbers

Test #68:

score: 0
Accepted
time: 73ms
memory: 144272kb

input:

1000 1000 300000
RDDLLUDULDDRRUUURLDRULRDDLLRRLLRLDRLLRULRRULUUDRUULUULUUDLRLLRURLURULRLRDDDRURDDLRRLDRUDDDRRLRLLULDLRDLLULLLDUDULURRUDURLURURLDLULDURRDULURDUDLRLURRDRDDDLULLRRRRRULRRURURDURUULLDRRUULUULDDDRDULRRLRLDUUUURUURURURRDDULURLLRURRDUUUDDRRLDUDUDLLUDLRRRDLLDRDUDULUULDULLLUUURRDURLDDDRDLDUDU...

output:

995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
0
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
995198
9951...

result:

ok 300000 numbers

Test #69:

score: 0
Accepted
time: 84ms
memory: 147620kb

input:

1000 1000 300000
UDRRRRULRLRUDLUURRDRULDDRRDRDRLURDLDLLDULLLULULLLULURLLURLLRUUUDLLUDURLDRDUDRLUURRRDLDRLDLLLDRDRURLLRUDRRRLLRURDDRUDLUDDURDLLDRDUDULLUDRRUDLLRLRLURLURRDLULUURURUDRDRULLLDULUUDUUDDRULDDRLLLRDLRRLRLULUUULRDURRLUDRLLRLDUDDRRDLRRLRLUDLRRDUUDRDRDURURRUUULUDLDULDRDDLURDLUUUDULLDLDULLDRDLD...

output:

995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084
995084...

result:

ok 300000 numbers

Test #70:

score: 0
Accepted
time: 62ms
memory: 145976kb

input:

1000 1000 300000
LRLRRUULUDULRDLDLRUUDDULDDULLLRRRDLDRLDLURLUUULDLLDLDRULULDRUUDDDURLRRULRDLDULUDUDDUURUUDLUDDDUULULRDDRRRLLLRULRDRRLDLDLUDDUUULLRDRRRDDRRDRRRDDLDRUDDDLRRRDLLLRRDDUDDURUDURDDRDDDDUDRLLDRRRDULUULRURUUDRRLUURDLRUDRRLURDDDULUUUURRLDRLLURLUDRLDLDLUDRUUDLUUDLRULUDRULUDLDUDRDRLULUURRDLURUR...

output:

995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118
995118...

result:

ok 300000 numbers

Test #71:

score: 0
Accepted
time: 80ms
memory: 147440kb

input:

1000 1000 300000
UDDLDULRRLULRLRRRUDRDRRLDULRDURRRRRDRULURLURLLDLDRDDRDRRURRDRULUURRURULLLRRUDDRRLLURLDDRRLUDLRDULLUULDDRUULLURLRUULRRLDDULLDUDDDUUULURLLDUDRDLLLLDRLURURLDDLRLDULLRUUDLULURRULRULRUULDDULRDLDRRUDLLUULLRURRDRRRDUULLURDULLRRLDDULRULLLLULULURDLURLUUULLRLRLRRDRDULUULLURURRLLLDRDLRLUUDRDDR...

output:

995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178
995178...

result:

ok 300000 numbers

Test #72:

score: 0
Accepted
time: 85ms
memory: 143460kb

input:

1000 1000 300000
RURURUUDLLDURRLLURRRRURRRDDLDLRDLRURRLDDDRUDRLURRULULDDDRRDLRDDDRDDLULRULURUURRRURURDLLDRUDDLUDDDLRRLRRLLRLDDLURDDLRRRLDDULDLLRLDLRDLDRDDDDLLDURRUDLDLUUUDLRDDLLRLLRDURRURDLRUULDUURUDURRRRURRURLRDDDUUDRDURRLURLDDUUDUDLDRDLDDDRUULLULRURLRRULLRDDDDRRDDRUUUULLDDUDUULULLDDRUULUDDDRUURURD...

output:

994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994978
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976
994976...

result:

ok 300000 numbers

Test #73:

score: 0
Accepted
time: 54ms
memory: 125412kb

input:

1000 1000 300000
LDRRDLRDDLRUDULUDRULRUDRUURDURURDULDLLRDRULUUDLRRUDDDLUUDLDRUDUUUUDRULLULRUDRULLDRLLDLLLRULDLRLRUDULUDULRDRDLRRDDRULRLLDUDDURRUDRURUUULLDLURDRUDUULUURLUULUULULDRLUDRRULULRLLLRLLLRRRUULLRRUDRDDRULLRUDULRDRDDUULLDLLLLUUUDULURRDRLLDLLLLUDRULDDDDULDDRDLRLURULLULLLDULDUUDRLUDRRRUUURLLDDR...

output:

0
658918
148289
329421
0
329421
279692
0
0
314475
0
83633
0
0
0
680784
0
680784
0
329421
574279
0
609113
0
329421
0
0
680784
0
0
0
96569
0
0
680784
329421
0
793191
0
695706
0
0
0
0
0
0
0
695706
562349
562349
0
338435
0
574279
876824
329421
574279
425990
0
0
329421
0
0
0
0
148289
574279
0
108499
0
54...

result:

ok 300000 numbers

Test #74:

score: 0
Accepted
time: 57ms
memory: 121852kb

input:

1000 1000 300000
RLLRLUUDDLUUUDDRUDDULLLLDLUDUUUDDULLDUDLRDULURULUDRRRLRLURURUDLUULLDLLLUDLLLRRRULDDLDRDDRRURDLDLURLLUUULLLLRUUDRULDDLRULLDLDLLDLLRDDDRDRULURUULURRURDDURLUDURLLUUUDUURLRUULLLDURRRLLLUDRLRRDRDDLLRUDDLLUDDDDLRULDDRLDLULDRDUDDRRRRDUDUDDLUURUURULLURUUDRLDUDRDRDRDURLDRRDLRRDRLLUUUURDRUUDR...

output:

0
0
0
0
0
0
0
0
0
0
351389
0
0
0
0
238865
0
0
90550
0
0
0
368245
351389
0
112524
0
368245
203074
294665
0
0
0
0
0
0
294665
137397
0
0
0
0
0
256807
0
294665
0
0
112524
0
294665
294665
0
294665
0
294665
0
0
0
0
0
294665
0
294665
0
0
0
294665
0
0
0
0
294665
294665
0
0
351389
0
294665
191131
0
351389
0
...

result:

ok 300000 numbers

Test #75:

score: 0
Accepted
time: 73ms
memory: 122828kb

input:

1000 1000 300000
LRDUUULUDRLULLRRLUDLDDRULDLURLLUDDLLRDRLLRRRRRRUDRDRLDRDDRRRULURLLUUUDULDRLUDUUUURUDRDLLDRDDDLURDURDDUDLRUDDRDLDLRDULRRRRDLLDUDDLUDULUUULRRDRUDRURRRURRLURLUURDLDDRURLRDURDLDLULRLRUDULUUDDUUUUUUULUUDLDURRLLDURLUURRLDRRLUDDRRUDLDRLRDRLRRLURUUUDRRRLDURDLULLRURURDRUDURURRLDRDDDLRUDRLLUD...

output:

0
509533
0
0
0
0
332513
131411
0
0
201102
0
0
0
0
401188
187052
0
187052
509533
0
0
332513
0
0
0
0
0
0
509533
0
100495
0
112443
0
0
0
0
0
0
100495
332513
0
239756
0
0
0
267691
0
0
0
0
0
0
640944
308431
0
640944
0
0
0
201102
509533
0
0
0
0
187052
0
0
0
640944
0
267691
0
0
0
231906
0
0
0
380134
0
0
0
...

result:

ok 300000 numbers

Test #76:

score: 0
Accepted
time: 68ms
memory: 121528kb

input:

1000 1000 300000
RLLDDDDRLLDULLDUUDLLRRDRUURUULDRLLUUDULDLRDRRLURRDLDURULURURRDULRDDLUDDRUUULRDDRURDRLRDRRDLDLDLRRURRUDDDRDLLLDRDULLRLURRLUULLURDDDRDLULURLLLRRDUUDLUULRLRRDUURUDDDDURRUUDRLDRDUUUDRDRRUUDDLUDDUULRDDLLDLRDLDLRDURRULRLLDRRURDDDLLURLUUURLRLURLULRUURRDUDDLRDDUULLDUDLUDLLRRUUULLRDDDDUURLRU...

output:

0
0
562105
0
0
0
0
65708
379035
0
168194
0
379035
0
168151
0
0
0
148220
0
0
413885
0
0
148220
0
0
0
0
413885
94572
0
148220
0
0
117407
562105
329337
0
0
0
0
168151
0
0
0
562105
0
146267
0
0
0
0
0
168151
168151
0
0
0
0
0
0
148220
232768
0
0
183070
14919
0
148220
315528
324418
0
0
0
0
413885
0
0
0
0
3...

result:

ok 300000 numbers

Test #77:

score: 0
Accepted
time: 71ms
memory: 125720kb

input:

1000 1000 300000
ULDRRRUDUUDRRLRRRRURDDDUDDDRLDLUDLLLULUDRDRULDRLLUULUURLDLDLRDLULUDUUDUDDUDLDURLLRRLDURUUDDDRULRDLRLDDDDDDLRRURRLDRRLDLUDDDDRULDRLURUUDLRRRRULLRDDDLLLLUULLLLLDDDUURLRUDULLDRRLURDDLDRULUDDURDUURDURULRUUUDDDULRUDRDUDRRDRURURRDRULRRRUULLDLULDDDLLUULULLULDDUDLRURRLULDLDUURUDDDLRDUULRRDL...

output:

0
0
0
0
0
124424
0
268684
153254
0
0
0
153254
416927
0
0
0
0
268684
320419
0
153254
121376
0
268684
93519
0
0
0
148243
0
138366
0
0
0
416927
468662
0
0
0
0
0
352256
0
0
0
352256
0
268684
0
0
0
0
0
0
0
0
268684
0
0
0
0
0
0
124424
0
0
0
0
0
0
230880
416929
268684
0
0
0
0
0
0
117409
0
0
0
0
0
268684
15...

result:

ok 300000 numbers

Test #78:

score: 0
Accepted
time: 67ms
memory: 124680kb

input:

1000 1000 300000
DRLRRRRRLURRRLRLRULULUUUDUURDRUUULDURURURRURULRUDDDLLDRDLURLDLLDRLDDRDRLRURURULUURRUULRLDULUDDULRULULDLLRURURDURLLLDLURLDDDULRUULRLDUDDLLLLURUDLRLLLLLUDRRRDLLDDLDDULLRLLRRRRURDDDLDUDURRLRRLULDRURDLRURULULLLLUURUUDDRLRLDUDLUDRDRURLLLUURUULLURUURLRDURDRDDDLRURLLULUDURDLULUDLDUDULLUULL...

output:

0
0
0
0
0
201013
753433
0
0
387193
256843
0
0
448774
0
0
0
0
0
0
0
0
201013
544477
0
448774
0
0
0
0
239815
0
0
0
0
0
544477
256843
753433
544477
0
0
0
0
0
0
0
0
0
448774
256843
201013
239818
448774
0
0
552420
0
239818
0
0
0
0
0
0
544477
753434
239818
0
387193
201013
0
0
239818
0
239818
448774
0
2568...

result:

ok 300000 numbers

Test #79:

score: 0
Accepted
time: 68ms
memory: 125224kb

input:

1000 1000 300000
URULLRDURURLDDLDULRULUDDUUDUDLRDLRULLULDDURRDULULLLURURRDRURLRUURLDRURUURDULRDULLLDDDLLRUUULDRLLDRDULDRLLRRLDDDLDRRRUULULRUDLRUDULURLDRRRULDDDLRDRLRRULRULRDDDDLLRLURRLDRLRULULDDDDUUDDRULLUUDDUULLUDRUDLDDRULRRLRDDUDLLLURLRRDURRDDLLRDLLRDLRLULRULLURDLRRDLRDURDRDUDULUDULRRRDLURDLLLDRUR...

output:

0
202060
141304
0
0
217973
0
141304
0
0
0
0
296595
0
141304
0
478686
296595
0
0
0
0
257722
0
281639
420033
0
459782
0
0
160208
0
420033
0
0
0
0
0
0
0
0
63666
94535
0
0
0
0
0
0
0
0
0
420033
0
141304
0
0
0
0
0
0
0
0
0
0
63666
420033
217973
202060
232892
296595
0
0
217973
217973
221950
0
0
459782
0
0
2...

result:

ok 300000 numbers

Test #80:

score: 0
Accepted
time: 68ms
memory: 122556kb

input:

1000 1000 300000
DULUDDLLRLDLLUDULUDLLLUULLDRLLUDRULRURLUUDDLRDUUULULURRDLRUUDLDRLRUULUURDRUDRDLUURDLRLDRUDULRDDDRRRDRRUURDLDDULULURDDDUUUUULDUULLRUULUULDRRURULDRUULRLULDUUUULURDLDDLUDLDDULRDULDDULRRULRRLLURRULDUULLDDDLUDDLULDDRLRDDRRLLDDLRRULRRRLRDUDLLRRLRLRLLDLRDDURDLUURULUDDUULLRRURURDDLUUDRUUDDD...

output:

0
0
0
187081
0
189164
0
0
189164
0
189164
0
0
0
0
0
0
111476
0
0
0
111476
0
0
0
37777
0
346370
0
0
0
0
130370
0
0
0
0
0
0
0
0
298557
457846
0
0
0
0
0
0
0
0
0
0
0
187081
0
0
187081
0
258860
229941
457846
0
0
0
0
0
0
0
0
0
0
0
0
159289
0
0
0
0
0
0
0
0
0
258860
346370
258860
0
0
0
130370
0
219998
25886...

result:

ok 300000 numbers

Test #81:

score: 0
Accepted
time: 73ms
memory: 122276kb

input:

1000 1000 300000
DULRDLDLRULRUULLDLUUDLULUULLLULRLLDLDLDURLULDLULLDLULLDDDLLURLDDDDDRDURRDDRLLULLRLDRLDURURDRUDDURUDLLLLRLUULRDDDRLRDDDUDULUUDDUULUURDDRUURRLLUDUDLRURULDDRDULUURLRUDLURLRLUUDURDLLULRULRRRLUDLDDRDDURLDLLDULUDDDUURLRUURRRLLUULDRLDRRDLLLLLRLUDLRUUDUULDDRLUUURLDLLURDDRLLUDDULLRLLRLURLDDL...

output:

0
89609
281641
0
89609
0
0
0
0
0
121468
0
0
0
0
0
0
488659
0
0
0
423963
281641
0
0
0
0
0
281641
0
0
0
0
0
203966
0
0
0
251701
0
0
134420
0
0
281641
0
0
0
0
114333
0
0
0
281641
0
0
281641
0
0
134420
89609
114333
0
0
0
0
0
165183
263790
0
114333
488659
0
0
0
0
0
0
0
0
0
203966
0
263790
0
0
0
281641
26...

result:

ok 300000 numbers