#include <stdio.h>
#define W (1920)
#define H (1080)
char board[H][W];
const char * actions = "UULLLDULDRRDDLDULDURLDDRUDLUDRUDLDRRRDLDUDDDLLDURLLUURUDLLUDDDULRRDRLULLLDDRDLUDRRRRUDLRDURLLDDDLLRULURDLLLLDLRRUDLRRLULUUUDULULLLRLLLUDLRDLDLUUUDRUULURURDLLRLDDDDDURDDULURUDDDULLLDRDLULURLUURLRUDLLUULUDLLDUUURLLDLDUURRRUURRRUDLUDURLLLLDRULLLRULRURLUDDLDUL";
void do_action(char action) {
switch (action) {
case 'U':
{
for (int x = 0; x < W; ++x) {
int dst_y = 0;
for (int y = 0; y < H; ++y) {
if (board[y][x] != '.') {
board[dst_y++][x] = board[y][x];
}
}
for (; dst_y < H; ++dst_y) {
board[dst_y][x] = '.';
}
}
break;
}
case 'D':
{
for (int x = 0; x < W; ++x) {
int dst_y = H-1;
for (int y = H-1; y >= 0; --y) {
if (board[y][x] != '.') {
board[dst_y--][x] = board[y][x];
}
}
for (; dst_y >= 0; --dst_y) {
board[dst_y][x] = '.';
}
}
break;
}
case 'L':
{
for (int y = 0; y < H; ++y) {
int dst_x = 0;
for (int x = 0; x < W; ++x) {
if (board[y][x] != '.') {
board[y][dst_x++] = board[y][x];
}
}
for (; dst_x < W; ++dst_x) {
board[y][dst_x] = '.';
}
}
break;
}
case 'R':
{
for (int y = 0; y < H; ++y) {
int dst_x = W-1;
for (int x = W-1; x >= 0; --x) {
if (board[y][x] != '.') {
board[y][dst_x--] = board[y][x];
}
}
for (; dst_x >= 0; --dst_x) {
board[y][dst_x] = '.';
}
}
break;
}
}
}
int main(int argc, const char* argv[]) {
const char *ac = actions;
#if 1
/* reduce qctions */
char opt[512];
char attr[256] = {0};
attr['U'] = attr['D'] = 1;
attr['L'] = attr['R'] = 2;
while (1) {
char last[3] = {0};
int dst = 0, count = 0;
for (int i = 0; ac[i]; ++i) {
count++;
int a = attr[ac[i]];
if (ac[i+1] == 0 || a != attr[ac[i+1]]) {
if (last[a] != ac[i]) {
opt[dst++] = ac[i];
last[a] = ac[i];
}
}
}
opt[dst] = 0;
ac = opt;
if (dst == count)
break;
}
#else
ac = actions;
#endif
/* read initial board */
fread(board
, W
* H
, 1, stdin
);
/* doit */
for (int i = 0; ac[i]; ++i) {
do_action(ac[i]);
}
/* write result */
fwrite(board
, W
* H
, 1, stdout
); }