QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#417585#3039. CleaningxlwangAC ✓1476ms160848kbC++143.8kb2024-05-22 19:54:092024-05-22 19:54:10

Judging History

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

  • [2024-05-22 19:54:10]
  • 评测
  • 测评结果:AC
  • 用时:1476ms
  • 内存:160848kb
  • [2024-05-22 19:54:09]
  • 提交

answer

#include<bits/stdc++.h>
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define foredge(i,j) for(register int i=head[j];i;i=e[i].nxt)
#define pb push_back
#define Times printf("Time:%.3lf\n",clock()/CLOCKS_PER_SEC)
#define pii pair<int,int>
#define mk make_pair
using namespace std;
inline int read(){
	int x=0;
	bool f=0;
	char c=getchar();
	while(!isdigit(c)) f|=(c=='-'),c=getchar();
	while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f?-x:x;
}
inline void write(int x){
    if(x<0){putchar('-');x=-x;}
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline int randfind(int l,int r){return rnd()%(r-l+1)+l;}
//inline void init(){
//	int t=read();
//	while(t--) work();
//}
const int Maxn=1e3+10,Maxm=1e4+10;
int col[Maxn][Maxn];
int n,m;
int vis[Maxn][Maxn];
vector<pii> to[Maxn][Maxn];
int dfn[Maxn][Maxn],low[Maxn][Maxn];
int idx;
char c[Maxn];
inline bool check(int x,int y){return x>=1 && x<=n && y>=1 && y<=m;}
int q;
inline void init(){
    n=read();m=read();q=read();
    fr(i,1,n){
        scanf("%s",c+1);
        fr(j,1,m){
            if(check(i,j-1) && c[j]!='L') to[i][j].pb(mk(i,j-1));
            if(check(i,j+1) && c[j]!='R') to[i][j].pb(mk(i,j+1));
            if(check(i-1,j) && c[j]!='U') to[i][j].pb(mk(i-1,j));
            if(check(i+1,j) && c[j]!='D') to[i][j].pb(mk(i+1,j));
        }
    }
}
stack<pii> st;
int color;
inline void chkmin(int &x,int y){if(x>y) x=y;}
inline void dfs(int x,int y){
    // cerr<<x<<' '<<y<<endl;
    dfn[x][y]=low[x][y]=++idx;vis[x][y]=1;st.push(mk(x,y));
    for(auto p:to[x][y]){
        int nx,ny;nx=p.first,ny=p.second;
        if(!dfn[nx][ny]){dfs(nx,ny);chkmin(low[x][y],low[nx][ny]);}
        else if(vis[nx][ny]) chkmin(low[x][y],dfn[nx][ny]);
    }
    if(dfn[x][y]==low[x][y]){
        ++color;
        int nx,ny;
        do{
            nx=st.top().first;ny=st.top().second;
            col[nx][ny]=color;vis[nx][ny]=0;
            st.pop();
        }while(!(nx==x && ny==y));
    }
}
int siz[Maxm];
vector<int> vc[Maxm];
bitset<Maxm> bt[Maxm];
int in[Maxm];
inline void work(){
    fr(i,1,n) fr(j,1,m) if(!dfn[i][j]) dfs(i,j);
    // fr(i,1,n){
    //     fr(j,1,m) writepl(col[i][j]);puts("");
    // }
    fr(i,1,n) fr(j,1,m) siz[col[i][j]]++;
    fr(x,1,n) fr(y,1,m) for(auto p:to[x][y]){
        int nx,ny;nx=p.first;ny=p.second;
        if(col[x][y]!=col[nx][ny]){
            // cout<<col[x][y]<<' '<<col[nx][ny]<<endl;
            vc[col[x][y]].pb(col[nx][ny]);
        }
    }
    fr(i,1,color){
        vector<int> now;sort(vc[i].begin(),vc[i].end());
        for(int j=0;j<vc[i].size();++j) if(j==0 || vc[i][j]!=vc[i][j-1]) now.pb(vc[i][j]);
        swap(now,vc[i]);
        for(auto x:vc[i]) in[x]++;
    }
    queue<int> que;
    fr(i,1,color) bt[i][i]=1;
    fr(i,1,color) if(!in[i]) que.push(i);
    // fr(i,1,color){
    //     cout<<"id="<<i<<":\n";
    //     for(auto x:vc[i]) cout<<x<<' ';cout<<endl;
    // }
    while(!que.empty()){
        int x=que.front();que.pop();
        for(auto y:vc[x]){
            bt[y]|=bt[x];--in[y];
            if(!in[y]) que.push(y);
        }
    }
    while(q--){
        int sx,sy,tx,ty;
        sx=read();sy=read();tx=read();ty=read();
        int ans=0,col1=col[sx][sy],col2=col[tx][ty];
        fr(i,1,color) if(bt[i][col1] && bt[col2][i]) ans+=siz[i];
        writeln(ans);
    }
}
signed main(){
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
    init();work();
    // printf("\nTIME:%.3lf",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 30964kb

input:

1 1 1
L
1 1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

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: 28032kb

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: 1249ms
memory: 108424kb

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: 1408ms
memory: 113340kb

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: 1071ms
memory: 106400kb

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: 1157ms
memory: 106240kb

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: 1319ms
memory: 103368kb

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: 1476ms
memory: 103328kb

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: 1402ms
memory: 105236kb

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: 1007ms
memory: 113000kb

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: 1396ms
memory: 104296kb

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: 1172ms
memory: 106744kb

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: 1205ms
memory: 110948kb

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: 1201ms
memory: 105604kb

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: 1148ms
memory: 107360kb

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: 1015ms
memory: 160592kb

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: 1010ms
memory: 160592kb

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: 1050ms
memory: 160020kb

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: 1003ms
memory: 160704kb

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: 1032ms
memory: 160600kb

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: 1026ms
memory: 160832kb

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: 976ms
memory: 160408kb

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: 981ms
memory: 160456kb

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: 998ms
memory: 160524kb

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: 979ms
memory: 160312kb

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: 1035ms
memory: 160536kb

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: 1036ms
memory: 160804kb

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: 1046ms
memory: 160456kb

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: 1048ms
memory: 160432kb

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: 1029ms
memory: 160636kb

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: 995ms
memory: 160624kb

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: 1009ms
memory: 160324kb

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: 1014ms
memory: 160548kb

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: 1006ms
memory: 160612kb

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: 1012ms
memory: 160520kb

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: 1011ms
memory: 160848kb

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: 1020ms
memory: 160724kb

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: 1011ms
memory: 160316kb

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: 1036ms
memory: 160520kb

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: 1029ms
memory: 160572kb

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: 1019ms
memory: 160464kb

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: 1040ms
memory: 160596kb

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: 1030ms
memory: 160660kb

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: 1022ms
memory: 160644kb

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: 1003ms
memory: 160360kb

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: 1002ms
memory: 160088kb

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: 1019ms
memory: 160540kb

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: 1021ms
memory: 160684kb

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: 1010ms
memory: 160440kb

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: 1115ms
memory: 160712kb

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: 1017ms
memory: 160220kb

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: 1048ms
memory: 160804kb

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: 1004ms
memory: 160520kb

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: 1024ms
memory: 160408kb

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: 1065ms
memory: 121860kb

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: 993ms
memory: 132400kb

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: 1000ms
memory: 127220kb

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: 979ms
memory: 160464kb

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: 1030ms
memory: 160484kb

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: 1051ms
memory: 160460kb

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: 1014ms
memory: 160416kb

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: 1013ms
memory: 160520kb

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: 993ms
memory: 160656kb

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: 1002ms
memory: 160300kb

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: 1013ms
memory: 160288kb

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: 1013ms
memory: 160332kb

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: 1019ms
memory: 160296kb

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: 1011ms
memory: 160280kb

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: 1032ms
memory: 160396kb

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: 1024ms
memory: 160356kb

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: 1050ms
memory: 160552kb

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: 1393ms
memory: 108316kb

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: 1019ms
memory: 109324kb

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: 1047ms
memory: 116600kb

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: 1035ms
memory: 114864kb

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: 1079ms
memory: 111212kb

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: 1041ms
memory: 110652kb

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: 1012ms
memory: 109368kb

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: 980ms
memory: 110860kb

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: 1137ms
memory: 108884kb

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