And again the sum... (Easy)#5284

And again the sum... (Easy)

1 second
64 megabytes
Very easy

Implement a data structure that manages a set of integers, supporting the following operations:

Input

Initially, the set is empty. The first line of the input contains , the number of operations (1 \leq n \leq 100). The following lines describe the operations. Each operation is either "+ i" or "? l r". The operation "? l r" corresponds to the query sum(l, r).

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

All parameters in the queries and addition operations range from to 10^9.

Output

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

Examples

Example 1

Loading
Loading