You have built a moving sculpture containing several devices that move marbles around on a grid. Each device occupies a single square on the grid and repeatedly executes a sequence of actions. The possible actions are:
Each device has its own sequence of actions, and different devices may have sequences of different lengths. At time 0, each device executes its first action, at time 1, each device executes its second action, etc. When a device reaches the end of its sequence, it starts again at the beginning of the sequence.
During each unit of time, all actions happen simultaneously and only operate on marbles on the squares at the beginning of that time unit. For example, suppose there is one marble on square (0, 0) and one on square (1, 0). Now suppose the first square's action is 'E' and the second square's action is 'D'. At the end of this time unit, the first square will have 0 marbles and the second will have 1. The second square drops the marble that it had at the beginning of the time unit, but it does not drop the marble that arrives from the first square during that time unit.
You are given a String actions, the i-th element of which is the action sequence for a device of type i (where i is a 0-based index). You are also given a String layout, where the j-th character of the i-th element is a digit representing the type of device located in row i, column j of the grid. Rows are numbered in increasing order from North to South, and columns are numbered in increasing order from West to East. Return the maximum number of marbles that exist on a single square after t time units have passed.
|-||layout will contain between 1 and 8 elements, inclusive.|
|-||Each element of layout will contain between 1 and 8 characters, inclusive.|
|-||Each element of layout will contain the same number of characters.|
|-||Each element of layout will contain only digits between 0 and n-1, inclusive, where n is the number of elements in actions.|
|-||actions will contain between 1 and 10 elements, inclusive.|
|-||Each element of actions will contain between 1 and 6 characters, inclusive.|
|-||Each element of actions will contain only digits ('0'-'9') and the characters 'N', 'E', 'S', 'W' and 'D'.|
|-||t will be between 1 and 100,000,000, inclusive.|