The tests for this problem consist of five groups. Points for each group are awarded only if all tests of the group and all tests of some of the previous groups are passed. Note that passing the tests from the statement is not required for some groups.

\begin{center}
\begingroup
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Group
& Points
& Constraints
& \parbox{3cm}{\centering Required}
& Comments
\\
\hline 
0 & 0 & -- & -- & Samples \\
\hline
1 & 17 & $n, m \le 50$ & 0 & \\
\hline
2 & 14 & $s_i = \texttt{R}$ & -- & \\
\hline
3 & 19 & $s_i \in  \{\texttt{D}, \texttt{U}\}$ & -- & \\
\hline
4 & 23 & $s_i \in  \{\texttt{R}, \texttt{D}\}$ & 2 & \\
\hline
5 & 27 & -- & 0 -- 4 & \\
\hline
\end{tabular}
\endgroup
\end{center}