## Editorial for Gấp tiền

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Lưu ý: Các code mẫu dưới đây chỉ mang tính tham khảo và có thể không AC được bài tập này

#### Code mẫu của flashmt

const t:array[1..3] of byte=(0,0,1);
r:array[0..1] of char=('D','U');
var n:byte;
m:longint;
a:array[1..31] of qword;
procedure init;
var i:byte;
begin
a[1]:=2;
for i:=2 to 31 do a[i]:=a[i-1]*2;
end;
function calc(n:byte;m:longint):byte;
var kt:boolean;
begin
if m=a[n] div 2 then exit(0);
if n=2 then exit(t[m]);
kt:=(m>a[n] div 2);
if kt then calc:=1-calc(n-1,a[n]-m)
else calc:=calc(n-1,m);
end;
begin
init;
repeat
if n+m=0 then break;
m:=a[n]-m;
if n=2 then writeln(r[t[m]])
else writeln(r[calc(n,m)]);
until false;
end.


#### Code mẫu của happyboy99x

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define sz(a) int((a).size())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(), _e = (c).end(); it != _e; ++it)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i,n) for(int i = 0, _n = (n); i < _n; ++i)
#define repd(i,n) for(int i = (n)-1; i >= 0; --i )
#define fo(i,a,b) for(int i = (a), _b = (b); i <= _b; ++i)
#define fod(i,a,b) for(int i = (a), _b = (b); i >= _b; --i)

#define INF 1000000000
#define N

bool Down( int f, int p ) { //True: pos is D, False otherwise
int mid = 1 << (f-1);
return p == mid ? 1 : p < mid ? !Down(f-1, mid-p) : Down(f-1,p-mid);
}

int main() {
//freopen( "input.txt", "r", stdin );
//freopen( "output.txt", "w", stdout );
int f, p;
for(;scanf("%d%d",&f,&p)==2&&(f||p);printf("%c\n", Down(f,p) ? 'D' : 'U'));
return 0;
}


#### Code mẫu của RR

var
n,p:longint;

function get(n,p:longint; rev:boolean):longint;
var
mid:longint;
begin
if not rev then
begin
if n=1 then exit(1);
mid:=1 shl (n-1);
if p=mid then exit(1);
if p<mid then exit(get(n-1,p,not rev));
if p>mid then exit(get(n-1,p-mid,rev));
end
else
begin
if n=1 then exit(0);
mid:=1 shl (n-1);
if p=mid then exit(0);
if p>mid then exit(get(n-1,p-mid,not rev));
if p<mid then exit(get(n-1,p,rev));
end;
end;

begin
while (n>0) or (p>0) do
begin
if get(n,p,false)=1 then writeln('D')
else writeln('U');
end;
end.


#### Code mẫu của ll931110

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int calc(int k,int n)
{
if (k == 1) return 0;
if (n % 4 == 1) return 1;
if (n % 4 == 3) return 0;
return calc(k - 1,n/2);
};

int main()
{
//    freopen("note.in","r",stdin);
//    freopen("note.ou","w",stdout);
while (1)
{
int k,n;
scanf("%d %d", &k, &n);
if (!k && !n) break;
if (calc(k,n)) printf("U\n"); else printf("D\n");
};
};


#### Code mẫu của khuc_tuan

#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

#define Rep(i,n) for(int i=0;i<(n);++i)
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Ford(i,a,b) for(int i=(a);i>=(b);--i)
#define Fit(i,v) for(__typeof(v.begin()) i=v.begin();i!=v.end();++i)
#define Fill(a,b) memset((a), (b), sizeof(a))
#define pb push_back
#define MP make_pair

typedef long long LL;

char find( int n, LL p) {
if(n==1) return 'D';
if(p==(1LL<<(n-1))) return 'D';
else if(p<(1LL<<(n-1))) return 'U'+'D' - find(n-1,(1LL<<(n-1))-p);
else return find(n-1, p-(1LL<<(n-1)));
}

int main() {
int n;
LL p;
while( cin >> n >> p) {
if(n==0 && p==0) break;
cout << find( n, p) << endl;
}
return 0;
}