#P1913C. Game with Multiset

    ID: 8963 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 4 Uploaded By: Tags>binary searchbitmasksbrute forcegreedy*1300

Game with Multiset

No submission language available for this problem.

Description

In this problem, you are initially given an empty multiset. You have to process two types of queries:

  1. ADD xx — add an element equal to 2x2^{x} to the multiset;
  2. GET ww — say whether it is possible to take the sum of some subset of the current multiset and get a value equal to ww.

The first line contains one integer mm (1m1051 \le m \le 10^5) — the number of queries.

Then mm lines follow, each of which contains two integers tit_i, viv_i, denoting the ii-th query. If ti=1t_i = 1, then the ii-th query is ADD viv_i (0vi290 \le v_i \le 29). If ti=2t_i = 2, then the ii-th query is GET viv_i (0vi1090 \le v_i \le 10^9).

For each GET query, print YES if it is possible to choose a subset with sum equal to ww, or NO if it is impossible.

Input

The first line contains one integer mm (1m1051 \le m \le 10^5) — the number of queries.

Then mm lines follow, each of which contains two integers tit_i, viv_i, denoting the ii-th query. If ti=1t_i = 1, then the ii-th query is ADD viv_i (0vi290 \le v_i \le 29). If ti=2t_i = 2, then the ii-th query is GET viv_i (0vi1090 \le v_i \le 10^9).

Output

For each GET query, print YES if it is possible to choose a subset with sum equal to ww, or NO if it is impossible.

Sample Input 1

5
1 0
1 0
1 0
2 3
2 4

Sample Output 1

YES
NO

Sample Input 2

7
1 0
1 1
1 2
1 10
2 4
2 6
2 7

Sample Output 2

YES
YES
YES