CF1416F Showing Off

Description

Another dull quarantine day was going by when BThero decided to start researching matrices of size $ n \times m $ . The rows are numerated $ 1 $ through $ n $ from top to bottom, and the columns are numerated $ 1 $ through $ m $ from left to right. The cell in the $ i $ -th row and $ j $ -th column is denoted as $ (i, j) $ . For each cell $ (i, j) $ BThero had two values: 1. The cost of the cell, which is a single positive integer. 2. The direction of the cell, which is one of characters L, R, D, U. Those characters correspond to transitions to adjacent cells $ (i, j - 1) $ , $ (i, j + 1) $ , $ (i + 1, j) $ or $ (i - 1, j) $ , respectively. No transition pointed outside of the matrix. Let us call a cell $ (i_2, j_2) $ reachable from $ (i_1, j_1) $ , if, starting from $ (i_1, j_1) $ and repeatedly moving to the adjacent cell according to our current direction, we will, sooner or later, visit $ (i_2, j_2) $ . BThero decided to create another matrix from the existing two. For a cell $ (i, j) $ , let us denote $ S_{i, j} $ as a set of all reachable cells from it (including $ (i, j) $ itself). Then, the value at the cell $ (i, j) $ in the new matrix will be equal to the sum of costs of all cells in $ S_{i, j} $ . After quickly computing the new matrix, BThero immediately sent it to his friends. However, he did not save any of the initial matrices! Help him to restore any two valid matrices, which produce the current one.

Input Format

N/A

Output Format

N/A