Here is a coding problem:
<PROBLEM>

Here are several easier subproblems for solving this problem.
<HINT>

Your should first review these subproblems and follow their logic the solve the original problem.
Generate the code in the following format:
```<LANGUAGE>
your code here
```
