And again the sum...#2310

And again the sum...

3 seconds
128 megabytes
Very easy

Implement a data structure to manage a set of integers, supporting the following operations:

Input

Initially, the set is empty. The first line contains the integer (1 \leq n \leq 300\ 000), representing the number of operations. The following lines each contain an operation in one of the following forms:

  • "+ i"

  • "? l r"

The operation "? l r" corresponds to the query \text{sum}(l, r).

If a "+ i" operation is the first operation or follows another "+" operation, it corresponds to . However, if it follows a "?" query, and the result of that query was , then the operation becomes \text{add}((i + y) \bmod 10^9).

All parameters in the queries and add operations are within and 10^9 inclusive.

Output

For each query operation, output a single number, which is the result of the query.

Examples

Example 1

Loading
Loading