#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> L, P;
map<long long, set<pair<int, int> > > D;
int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long dist2(int x, int y) { return x * 1LL * x + y * 1LL * y; }
pair<int, int> make_gcd_pair(int x, int y) {
  int g = gcd(x, y);
  return make_pair(x / g, y / g);
}
int main() {
  int q;
  scanf("%d", &q);
  int n = 0;
  while (q--) {
    int t, x, y;
    scanf("%d %d %d", &t, &x, &y);
    if (t == 1) {
      n++;
      long long d = dist2(x, y);
      L[make_gcd_pair(x, y)]++;
      for (const auto &p : D[d]) {
        int ox = p.first, oy = p.second;
        P[make_gcd_pair(x + ox, y + oy)]++;
      }
      D[d].insert(make_pair(x, y));
    } else if (t == 2) {
      n--;
      long long d = dist2(x, y);
      D[d].erase(make_pair(x, y));
      L[make_gcd_pair(x, y)]--;
      for (const auto &p : D[d]) {
        int ox = p.first, oy = p.second;
        P[make_gcd_pair(x + ox, y + oy)]--;
      }
    } else if (t == 3) {
      int ans = n - L[make_gcd_pair(x, y)] - 2 * P[make_gcd_pair(x, y)];
      printf("%d\n", ans);
    }
  }
  return 0;
}
