Problem: Monocarp has numbers and a set (initially empty). He adds his numbers to this set times in some order. During each step, he adds a new number (which has not been present in the set before). In other words, the sequence of added numbers is a permutation of length .
Every time Monocarp adds an element into the set except for the first time, he writes out a character:
- if the element Monocarp is trying to insert becomes the maximum element in the set, Monocarp writes out the character >;
- if the element Monocarp is trying to insert becomes the minimum element in the set, Monocarp writes out the character <;
- if none of the above, Monocarp writes out the character ?.
You are given a string of characters, which represents the characters written out by Monocarp (in the order he wrote them out). You have to process queries to the string. Each query has the following format:
- — replace with the character .
Both before processing the queries and after each query, you have to calculate the number of different ways to order the integers such that, if Monocarp inserts the integers into the set in that order, he gets the string . Since the answers might be large, print them modulo .
Input Format: The first line contains two integers and (; ).
The second line contains the string , consisting of exactly characters <, > and/or ?.
Then lines follow. Each of them represents a query. Each line contains an integer and a character (; is either <, >, or ?).
Output Format: Both before processing the queries and after each query, print one integer — the number of ways to order the integers such that, if Monocarp inserts the integers into the set in that order, he gets the string . Since the answers might be large, print them modulo .
Note: In the first example, there are three possible orderings before all queries:
- ;
- ;
- .
After the last query, there is only one possible ordering:
- .