You are given an integer , a string of length consisting only of the characters < and >, and an array .
Count the number of arrays such that for every , and all of the following conditions are satisfied:
For each from to :
<, then .>, then .Print the answer modulo .
The first value can be 1 or 2. The second value must be 3 or 4 to make the second prefix maximum greater than 2. The third value can be any value from 1 to 4, so there are 16 arrays.
The first condition asks the first prefix maximum to be less than 1. This is impossible because every chosen value is at least 1.
Every chosen value is positive, so the only condition is always satisfied. There are 3 choices.
The last condition forces the maximum of all three chosen values to be less than 2. Therefore all chosen values must be 1.
Among the first two values, at least one must be 2, and the first three values cannot exceed 2. Then the third value has 2 choices and the last value has 3 choices, so the answer is 18.