#P1732D1. Balance (Easy version)

    ID: 8035 Type: RemoteJudge 3000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>brute forcedata structuresimplementation*1500

Balance (Easy version)

No submission language available for this problem.

Description

This is the easy version of the problem. The only difference is that in this version there are no "remove" queries.

Initially you have a set containing one element — 00. You need to handle qq queries of the following types:

  • + xx — add the integer xx to the set. It is guaranteed that this integer is not contained in the set;
  • ? kk — find the k-mexk\text{-mex} of the set.

In our problem, we define the k-mexk\text{-mex} of a set of integers as the smallest non-negative integer xx that is divisible by kk and which is not contained in the set.

The first line contains an integer qq (1q21051 \leq q \leq 2 \cdot 10^5) — the number of queries.

The following qq lines describe the queries.

An addition query of integer xx is given in the format + xx (1x10181 \leq x \leq 10^{18}). It is guaranteed that xx was not contained in the set.

A search query of k-mexk\text{-mex} is given in the format ? kk (1k10181 \leq k \leq 10^{18}).

It is guaranteed that there will be at least one query of type ?.

For each query of type ? output a single integer — the k-mexk\text{-mex} of the set.

Input

The first line contains an integer qq (1q21051 \leq q \leq 2 \cdot 10^5) — the number of queries.

The following qq lines describe the queries.

An addition query of integer xx is given in the format + xx (1x10181 \leq x \leq 10^{18}). It is guaranteed that xx was not contained in the set.

A search query of k-mexk\text{-mex} is given in the format ? kk (1k10181 \leq k \leq 10^{18}).

It is guaranteed that there will be at least one query of type ?.

Output

For each query of type ? output a single integer — the k-mexk\text{-mex} of the set.

Sample Input 1

15
+ 1
+ 2
? 1
+ 4
? 2
+ 6
? 3
+ 7
+ 8
? 1
? 2
+ 5
? 1
+ 1000000000000000000
? 1000000000000000000

Sample Output 1

3
6
3
3
10
3
2000000000000000000

Sample Input 2

6
+ 100
? 100
+ 200
? 100
+ 50
? 50

Sample Output 2

200
300
150

Note

In the first example:

After the first and second queries, the set will contain elements {0,1,2}\{0, 1, 2\}. The smallest non-negative number that is divisible by 11 and is not contained in the set is 33.

After the fourth query, the set will contain the elements {0,1,2,4}\{0, 1, 2, 4\}. The smallest non-negative number that is divisible by 22 and is not contained in the set is 66.

In the second example:

  • Initially, the set contains only the element {0}\{0\}.
  • After adding an integer 100100 the set contains elements {0,100}\{0, 100\}.
  • 100-mex100\text{-mex} of the set is 200200.
  • After adding an integer 200200 the set contains elements {0,100,200}\{0, 100, 200\}.
  • 100-mex100\text{-mex} of the set is 300300.
  • After adding an integer 5050 the set contains elements {0,50,100,200}\{0, 50, 100, 200\}.
  • 50-mex50\text{-mex} of the set is 150150.