#include <bits/stdc++.h>
using namespace std;
int q, op, u, v, sz, *h, lst[200010], nxt[200010], tmp, pos, num;
map<pair<int, int>, int> il, dl;
map<long long, int> hd;
pair<int, int> p[200010], tp;
int gcd(const int& first, const int& second) {
  return second ? gcd(second, first % second) : first;
}
pair<int, int> Calc(const int& first, const int& second) {
  return tmp = gcd(first, second), (pair<int, int>){first / tmp, second / tmp};
}
int main() {
  scanf("%d", &q);
  for (int fr = 1; fr <= q; ++fr) {
    scanf("%d%d%d", &op, &u, &v);
    if (op == 1) {
      ++il[Calc(u << 1, v << 1)], ++num;
      h = (&hd[1ll * u * u + 1ll * v * v]);
      if (!(*h)) (*h) = q + 1;
      p[++sz] = (pair<int, int>){u, v};
      for (int i = (*h); i != q + 1; i = nxt[i])
        ++dl[Calc(u + p[i].first, v + p[i].second)];
      nxt[sz] = (*h), lst[(*h)] = sz, (*h) = sz;
    } else if (op == 2) {
      --il[Calc(u << 1, v << 1)], --num;
      h = (&hd[1ll * u * u + 1ll * v * v]);
      for (int i = (*h); i != q + 1; i = nxt[i])
        u != p[i].first || v != p[i].second
            ? --dl[Calc(u + p[i].first, v + p[i].second)]
            : pos = i;
      pos == (*h) ? (*h) = nxt[pos] : 0, nxt[lst[pos]] = nxt[pos],
                    lst[nxt[pos]] = lst[pos];
    } else
      tp = Calc(u << 1, v << 1), printf("%d\n", num - il[tp] - (dl[tp] << 1));
  }
  return 0;
}
