QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#217036#3039. CleaningCrysflyAC ✓294ms354224kbC++177.5kb2023-10-16 11:55:592023-10-16 11:56:00

Judging History

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

  • [2023-10-16 11:56:00]
  • 评测
  • 测评结果:AC
  • 用时:294ms
  • 内存:354224kb
  • [2023-10-16 11:55:59]
  • 提交

answer

// what is matter? never mind. 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define ull unsigned long long
//#define int __int128
//#define int long long
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 2000005
#define inf 0x3f3f3f3f

int n,m,Q,cnt;
int a[1005][1005];
vi g[maxn];
vi g2[maxn];
char str[maxn];

// L D R U.
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
char opt[4]={'R','D','L','U'};

int getx(char c){
	For(i,0,3) if(opt[i]==c) return i;
	assert(0);
}
int P(int i,int j){
	return (i-1)*m+j;
}
int X(int i){
	return (i-1)/m+1;
}
int Y(int i){
	return (i-1)%m+1;
}
int px[maxn],py[maxn],op[maxn];

int dfn[maxn],low[maxn],idx,scc,st[maxn],tp,bel[maxn];
vi p[maxn];
int lx[maxn],rx[maxn],ly[maxn],ry[maxn];

void tar(int u){
	dfn[u]=low[u]=++idx;
	st[++tp]=u;
	for(int v:g[u]){
		if(!dfn[v])tar(v),low[u]=min(low[u],low[v]);
		else if(!bel[v])low[u]=min(low[u],dfn[v]);
	}
	if(dfn[u]!=low[u])return;
	int v; ++scc; do{
		v=st[tp--];
		bel[v]=scc;
		p[scc].pb(v);
	} while(u!=v);
}

bool vis[maxn];
int par[maxn];

int dsu[maxn];
int gf(int x){
	while(x!=dsu[x])x=dsu[x]=dsu[dsu[x]];
	return x;
}

int rt;
vi e[maxn];

int deg[maxn],out[maxn];

int pos[maxn],eto[maxn];

int fa[maxn][21],dep[maxn],sum[maxn],val[maxn],L[maxn],R[maxn];

int Sum(int l,int r){
	return sum[r]-sum[l]+p[l].size();
}
void dfs(int u){
//	cout<<"dfs u: "<<u<<" "<<par[u]<<"\n";
	dep[u]=dep[par[u]]+1;
	fa[u][0]=par[u];
	For(i,1,20)fa[u][i]=fa[fa[u][i-1]][i-1];
	int sz=e[u].size();
	
	int now=0;
	for(int v:e[u])now+=p[v].size(),sum[v]=now;
	int lst=-1;
	for(int v:e[u]){
		if(lst==-1 || eto[lst]!=-1) L[v]=v;
		else L[v]=L[lst];
		lst=v;
	}
	lst=-1;
	Rep(i,sz-1,0){
		int v=e[u][i];
		if(eto[v]!=1) R[v]=v;
		else assert(lst!=-1),R[v]=R[lst];
		lst=v;
	}
	for(int v:e[u])val[v]=Sum(L[v],R[v]);
	for(int v:e[u])val[v]+=val[u],dfs(v);
}

int ask(int u,int v){
//	cout<<"ask "<<u<<" "<<v<<"\n";
	if(dep[u]<dep[v])return 0;
	int res=val[u];
	Rep(i,20,0)
		if(dep[fa[u][i]]>=dep[v]) u=fa[u][i];
	res-=val[u];
	if(fa[u][0]!=fa[v][0])return 0;
//	cout<<"u: "<<u<<" "<<L[u]<<" "<<R[u]<<"\n";
//	cout<<"fa "<<fa[u][0]<<" "<<fa[v][0]<<"\n";
	if(pos[u]<pos[v]){
		if(pos[R[u]]>=pos[v])return Sum(u,v)+res;
		return 0;
	}
	else{
		if(pos[L[u]]<=pos[v])return Sum(v,u)+res;
		return 0;
	}
}

signed main()
{
//	freopen("maze.in","r",stdin);
//	freopen("maze.out","w",stdout);
//	read();
	n=read(),m=read(),Q=read();
	For(i,1,n){
		scanf("%s",str);
		For(j,1,m)a[i][j]=getx(str[j-1]);
	}
	
	For(i,1,n)
		For(j,1,m){
			For(d,0,3)
				if(d!=a[i][j]){
					int ii=i+dx[d],jj=j+dy[d];
					if(ii>0&&jj>0&&ii<=n&&jj<=m)
						g[P(i,j)].pb(P(ii,jj));
				}
		}
	For(i,1,n*m)if(!dfn[i])tar(i);
	
//	For(i,1,n)
//		For(j,1,m) cout<<bel[P(i,j)]<<" \n"[j==m];
	
	For(i,1,n*m*2+1) dsu[i]=i;
	For(u,1,n*m)
		for(int v:g[u]) if(bel[u]!=bel[v]) g2[bel[v]].pb(bel[u]);
	cnt=scc;
	vector<pii>E;
	For(i,1,scc){
		px[i]=X(p[i][0]);
		py[i]=Y(p[i][0]);
	}
	Rep(i,scc,1){
	//	cout<<"work "<<i<<"\n";
		lx[i]=ly[i]=inf,rx[i]=ry[i]=0;
		for(auto u:p[i]){
			int x=(u-1)/m+1;
			int y=(u-1)%m+1;
			lx[i]=min(lx[i],x);
			rx[i]=max(rx[i],x);
			ly[i]=min(ly[i],y);
			ry[i]=max(ry[i],y);
		}
		for(int j:g2[i]){
			// j->i
			j=gf(j);
			if(j==i)continue;
			if(lx[j]>=lx[i] && rx[j]<=rx[i] && ly[j]>=ly[i] && ry[j]<=ry[i]){
			//	cout<<"i: "<<lx[i]<<" "<<ly[i]<<" "<<rx[i]<<" "<<ry[i]<<"\n";
			//	cout<<"j: "<<lx[j]<<" "<<ly[j]<<" "<<rx[j]<<" "<<ry[j]<<"\n";
				par[j]=i;
				dsu[j]=i;
			//	cout<<"merge "<<j<<" "<<i<<"\n";
			}
		}
		for(int u:p[i]){
			int x=(u-1)/m+1;
			int y=(u-1)%m+1;
			For(d,0,3){
				int xx=x+dx[d],yy=y+dy[d];
				if(xx>=lx[i] && yy>=ly[i] && xx<=rx[i] && yy<=ry[i]){
					int j=gf(bel[P(xx,yy)]);
					if(j!=i) par[j]=dsu[j]=i;
				}
			}
		}
		for(int x:{lx[i]-1,rx[i]+1}){
			if(x<=0||x>n)continue;
			if(bel[P(x,ly[i])]<i) continue;
			int u=gf(bel[P(x,ly[i])]),lst=u;
			bool hav=0;
			vi o; o.pb(u);
			For(y,ly[i],ry[i]){
				int v=gf(bel[P(x,y)]);
				if(x==lx[i]-1 && x+dx[a[x][y]]!=lx[i]) hav=1;
				if(x==rx[i]+1 && x+dx[a[x][y]]!=rx[i]) hav=1;
				if(v!=lst) o.pb(v),lst=v;
			}
			if(o.size()>1){
			//	puts("qaq");
			//	for(int v:o)cout<<v<<" "; puts("");
				px[cnt+1]=px[u];
				py[cnt+1]=py[u];
				op[cnt+1]=1;//0.
				u=++cnt;
		//		cout<<"Create New: "<<cnt<<"\n";
		//		for(int v:o)cout<<v<<" ";puts("");
				lx[u]=ly[u]=inf;
				// create new.
				for(int v:o){
					par[v]=dsu[v]=u;
					lx[u]=min(lx[u],lx[v]);
					ly[u]=min(ly[u],ly[v]);
					rx[u]=max(rx[u],rx[v]);
					ry[u]=max(ry[u],ry[v]);
				}
			}
			if(hav){
				// adde (u,i).
			//	cout<<"add "<<u<<" "<<i<<"\n";
				E.pb(mkp(u,i));
				++deg[u],++deg[i],out[u]^=i,out[i]^=u;
			}
		}
		for(int y:{ly[i]-1,ry[i]+1}){
			if(y<=0||y>m)continue;
			if(bel[P(lx[i],y)]<i)continue;
			int u=gf(bel[P(lx[i],y)]),lst=u;
			bool hav=0;
			vi o; o.pb(u);
			For(x,lx[i],rx[i]){
				int v=gf(bel[P(x,y)]);
				if(y==ly[i]-1 && y+dy[a[x][y]]!=ly[i]) hav=1;
				if(y==ry[i]+1 && y+dy[a[x][y]]!=ry[i]) hav=1;
				if(v!=lst) o.pb(v),lst=v;
			}
			if(o.size()>1){
			//	puts("qaq");
			//	for(int v:o)cout<<v<<" "; puts("");
				px[cnt+1]=px[u];
				py[cnt+1]=py[u];
				op[cnt+1]=2;//y.
				u=++cnt;
		//		cout<<"Create New: "<<cnt<<"\n";
		//		for(int v:o)cout<<v<<" ";puts("");
				lx[u]=ly[u]=inf;
				// create new.
				for(int v:o){
					par[v]=dsu[v]=u;
					lx[u]=min(lx[u],lx[v]);
					ly[u]=min(ly[u],ly[v]);
					rx[u]=max(rx[u],rx[v]);
					ry[u]=max(ry[u],ry[v]);
				}
			}
			if(hav){
				// adde (u,i).
				E.pb(mkp(u,i));
				++deg[u],++deg[i],out[u]^=i,out[i]^=u;
			}
		}
	//	cout<<"cnt "<<cnt<<"\n";
	}
	
//	cout<<"edges:\n";
//	for(auto [u,v]:E) cout<<u<<" "<<v<<"\n";
//	cout<<"L&&R:\n";
	//For(i,1,cnt){
//		cout<<lx[i]<<" "<<ly[i]<<" "<<rx[i]<<" "<<ry[i]<<"\n";
//	}
	
	rt=++cnt;
	For(i,1,cnt-1){
		if(gf(i)==i) par[i]=dsu[i]=rt;
		e[par[i]].pb(i);
	}
//	For(i,1,cnt) cout<<par[i]<<" ";cout<<"  par\n";
	For(i,1,cnt){
//		sort(e[i].begin(),e[i].end(),[&](int u,int v){
//			return mkp(lx[u],ly[u])<mkp(lx[v],ly[v]);
//		});
	//	cout<<"child:\n";
	//	for(int v:e[i]) cout<<v<<" "; cout<<"\n";
		vi o;
		for(int u:e[i]){
			if(vis[u])continue;
			if(deg[u]==0)o.pb(u);
			if(deg[u]==1 && !vis[u]){
				int x=u;
				o.pb(x); vis[x]=1; x=out[x];
				while(deg[x]!=1) o.pb(x),vis[x]=1,x=out[x]^(o[o.size()-2]);
				o.pb(x); vis[x]=1;
			}
		}
		e[i]=o;
		For(j,0,(int)e[i].size()-1) pos[e[i][j]]=j;
	}
	for(auto [u,v]:E){
		if(par[u]!=par[v]) exit(233);
		if(abs(pos[u]-pos[v])!=1){
			int x=par[u];
			cout<<"par "<<x<<"\n";
			for(int y:e[x]){
				cout<<lx[y]<<" "<<ly[y]<<" "<<rx[y]<<" "<<ry[y]<<"\n";
			}
			exit(0);
		}
		if(pos[u]<pos[v]) eto[u]=1;
		else eto[v]=-1;
	}
	dfs(rt);
	For(_,1,Q){
		int a=read(),b=read(),c=read(),d=read();
		int u=bel[P(a,b)],v=bel[P(c,d)];
		cout<<ask(u,v)<<"\n";
	}
	return 0;
}
/*
4 2
18 14 4
*/

詳細信息

Test #1:

score: 100
Accepted
time: 11ms
memory: 222636kb

input:

1 1 1
L
1 1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 20ms
memory: 230908kb

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: 11ms
memory: 230924kb

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: 225ms
memory: 305924kb

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: 232ms
memory: 308580kb

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: 237ms
memory: 298804kb

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: 214ms
memory: 303488kb

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: 247ms
memory: 295036kb

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: 237ms
memory: 296992kb

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: 241ms
memory: 308532kb

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: 245ms
memory: 299724kb

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: 216ms
memory: 299368kb

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: 221ms
memory: 299908kb

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: 241ms
memory: 304864kb

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: 241ms
memory: 298216kb

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: 230ms
memory: 300088kb

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: 250ms
memory: 350552kb

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: 258ms
memory: 349732kb

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: 270ms
memory: 349800kb

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: 257ms
memory: 351220kb

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: 269ms
memory: 349672kb

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: 246ms
memory: 350316kb

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: 255ms
memory: 348412kb

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: 248ms
memory: 349540kb

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: 244ms
memory: 346992kb

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: 228ms
memory: 351140kb

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: 228ms
memory: 349712kb

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: 281ms
memory: 352120kb

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: 261ms
memory: 349248kb

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: 240ms
memory: 350304kb

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: 246ms
memory: 352148kb

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: 241ms
memory: 348468kb

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: 242ms
memory: 350336kb

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: 267ms
memory: 348136kb

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: 263ms
memory: 348300kb

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: 275ms
memory: 347412kb

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: 276ms
memory: 348600kb

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: 242ms
memory: 351932kb

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: 277ms
memory: 349816kb

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: 236ms
memory: 351324kb

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: 243ms
memory: 346720kb

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: 266ms
memory: 350412kb

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: 240ms
memory: 348568kb

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: 267ms
memory: 346304kb

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: 247ms
memory: 349956kb

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: 259ms
memory: 348716kb

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: 233ms
memory: 349840kb

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: 260ms
memory: 347988kb

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: 258ms
memory: 349244kb

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: 239ms
memory: 354224kb

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: 294ms
memory: 346724kb

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: 265ms
memory: 349132kb

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: 245ms
memory: 349616kb

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: 249ms
memory: 350348kb

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: 275ms
memory: 347940kb

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: 246ms
memory: 309868kb

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: 251ms
memory: 333684kb

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: 212ms
memory: 327668kb

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: 257ms
memory: 348892kb

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: 251ms
memory: 351516kb

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: 254ms
memory: 347572kb

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: 230ms
memory: 353364kb

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: 290ms
memory: 347476kb

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: 279ms
memory: 348932kb

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: 259ms
memory: 349496kb

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: 283ms
memory: 348708kb

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: 266ms
memory: 351524kb

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: 263ms
memory: 349216kb

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: 271ms
memory: 350408kb

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: 253ms
memory: 350696kb

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: 256ms
memory: 350556kb

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: 245ms
memory: 350004kb

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: 240ms
memory: 304324kb

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: 243ms
memory: 312740kb

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: 233ms
memory: 302428kb

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: 256ms
memory: 302088kb

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: 244ms
memory: 309244kb

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: 243ms
memory: 307652kb

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: 238ms
memory: 306428kb

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: 240ms
memory: 301292kb

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: 248ms
memory: 304124kb

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