QOJ.ac

QOJ

시간 제한: 2 s 메모리 제한: 256 MB 총점: 100

#18796. 수열과 쿼리 38

통계

Initially, there is an array $A$ containing a single 0. Then, the following queries need to be executed:

  • 1 x: Append x to the end of $A$.
  • 2 x: Remove x from $A$. If $A$ contains two or more x's, remove only the first occurrence. It is guaranteed that $x$ is present in $A$ at the time of the query.
  • 3: Output the sum of all elements in $A$.
  • 4: Output the XOR of all elements in $A$.

Input

The first line contains an integer $M$, the number of queries. The next $M$ lines each contain one query.

Output

Whenever a query of type 3 or type 4 appears, output the answer, each on its own line.

Examples

Input 1

12
1 3
1 1
1 4
3
4
1 1
3
4
2 1
2 4
3
4

Output 1

8
6
9
7
4
2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.