Under construction

Still being built. Things may change

Best Friends

Interview

Time limit2sMemory limit1024 MB

Summary
Process queries that toggle base stations on the plane and count the stations forming an acute triangle with (-x,0) and (x,0) for a given x.
Level

Medium6 of 10

Topics
Geometry, Hash map, Binary search
Solved
No attempts yet

Problem

Beomsu and Yunseong are the best of friends. Their village is drawn on a two-dimensional coordinate plane. Beomsu lives in the positive direction of the x-axis and Yunseong lives in the negative direction, so they cannot meet in person. They mostly bond by playing games together.

Games need a communication link through a base station located on the coordinate plane. For smooth play, the link must be fast enough. A player can use the high-speed link only when Beomsu's position, Yunseong's position, and the base station's position form an acute triangle. The village changes every day, so the positions of the two friends and the base stations change constantly. You must process the following QQ queries.

  • 1 xx: Beomsu is at (x,0)(x,0) and Yunseong is at (−x,0)(-x,0). Print the number of base stations where the high-speed link is available.
  • 2 xx yy: If there is no base station at (x,y)(x,y), install one. If there is one, remove it. No base station is located on the x-axis.

Initially, no base stations are installed. Write a program that processes the queries correctly.

Input

The first line contains the number of queries QQ. (1≤Q≤300 000)(1 \le Q \le 300\,000)

Each of the next QQ lines contains one query in one of the following forms.

  • 1 xx: (1≤x≤109)(1 \le x \le 10^9)
  • 2 xx yy: (−109≤x,y≤109;y≠0)(-10^9 \le x,y \le 10^9; y \ne 0)

All given numbers are integers. At least one query of type 1 is given.

Output

For each query of type 1, print the answer on its own line, in the order the queries are given.

Examples1

  1. Example 1

    Input
    7
    2 0 1
    2 0 2
    2 0 3
    1 2
    1 1
    2 0 3
    1 1
    
    Expected output
    1
    2
    1