A diagnostics unit tracks a multiset of fault codes (integers). Starting empty, it processes q operations, each one of:
ADD x— add one occurrence of codex.REMOVE x— remove one occurrence of codex. It is guaranteed at least one occurrence exists.MODE— report the code with the highest current occurrence count. If several codes tie for the highest count, report the smallest such code. It is guaranteed the multiset is non-empty.
Input format
Line 1: an integer q.
Next q lines: ADD x, REMOVE x, or MODE.
Output format
For every MODE operation, in order, print the reported code on its own line.
Constraints
- 1 <= q <= 40
- -1000000 <= x <= 1000000
- Every
REMOVEtargets a present code; everyMODEsees a non-empty multiset.