#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
struct pt {
  int x, y;
  long long int sqlen() { return x * (long long int)x + y * (long long int)y; }
  void norm() {
    int g = gcd(x, y);
    x /= g;
    y /= g;
  }
};
pt operator+(const pt &a, const pt &b) { return {a.x + b.x, a.y + b.y}; }
bool operator<(const pt &a, const pt &b) {
  return a.x == b.x ? a.y < b.y : a.x < b.x;
}
map<pt, int> onLine, sym;
map<long long int, set<pt>> circ;
int main() {
  int q;
  scanf("%d", &q);
  int ct = 0;
  for (int i = 0; i < q; i++) {
    pt a;
    int t;
    scanf("%d%d%d", &t, &a.x, &a.y);
    if (t == 1) {
      ct++;
      long long int len = a.sqlen();
      for (auto &p : circ[len]) {
        auto s = a + p;
        s.norm();
        sym[s]++;
      }
      circ[len].insert(a);
      a.norm();
      onLine[a]++;
    } else if (t == 2) {
      ct--;
      long long int len = a.sqlen();
      circ[len].erase(a);
      for (auto &p : circ[len]) {
        auto s = a + p;
        s.norm();
        sym[s]--;
      }
      a.norm();
      onLine[a]--;
    } else {
      a.norm();
      printf("%d\n", ct - sym[a] * 2 - onLine[a]);
    }
  }
  return 0;
}
