The Lemon Tree is a complete binary tree with an infinite number of vertices. Node is the root, and the child vertices of any vertex numbered are numbered and . There is a set whose elements are vertices of this tree. Initially, the set is empty. queries are given as follows.
- : Among the descendants of vertex , including , add all vertices whose distance to is less than or equal to into . Here, it is guaranteed that the sets of vertices added by each query do not overlap.
After each query, you must output the remainder of divided by . For two vertices and in the tree, means the distance between vertex and .
Input
is given on the first line. From the second line, the queries and are given separated by a space, one per line over lines.
Output
Print immediately after each query, one per line.
Constraints
- , ,
Subtasks
Samples
After the first query, . Therefore, the answer to the query is .
After the second query, . Therefore, the answer to the query is .