#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
struct A {
  int x, y;
  bool vv;
};
vector<A> t[N];
map<long long, int> r;
map<pair<int, int>, int> g0, g1;
int cr, tot;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
int main() {
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int ty, x, y;
    scanf("%d%d%d", &ty, &x, &y);
    if (ty == 1) {
      long long tl = 1ll * x * x + 1ll * y * y;
      if (!r[tl]) r[tl] = ++cr;
      int tmp = r[tl];
      if (t[tmp].size())
        for (int j = 0; j <= t[tmp].size() - 1; j++)
          if (t[tmp][j].vv) {
            int tx = x + t[tmp][j].x, ty = y + t[tmp][j].y, gg = gcd(tx, ty);
            g1[make_pair(tx / gg, ty / gg)]++;
          }
      t[tmp].push_back((A){x, y, true});
      int gg = gcd(x, y);
      g0[make_pair(x / gg, y / gg)]++, tot++;
    } else if (ty == 2) {
      int tmp = r[1ll * x * x + 1ll * y * y];
      for (int j = 0; j <= t[tmp].size() - 1; j++)
        if (t[tmp][j].x == x && t[tmp][j].y == y) t[tmp][j].vv = false;
      if (t[tmp].size())
        for (int j = 0; j <= t[tmp].size() - 1; j++)
          if (t[tmp][j].vv) {
            int tx = x + t[tmp][j].x, ty = y + t[tmp][j].y, gg = gcd(tx, ty);
            g1[make_pair(tx / gg, ty / gg)]--;
          }
      int gg = gcd(x, y);
      g0[make_pair(x / gg, y / gg)]--, tot--;
    } else {
      int gg = gcd(x, y);
      printf("%d\n", tot - g0[make_pair(x / gg, y / gg)] -
                         g1[make_pair(x / gg, y / gg)] * 2);
    }
  }
  return 0;
}
