#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
const int MAXQ = 200000;
int nq;
int qkind[MAXQ], qx[MAXQ], qy[MAXQ], qans[MAXQ];
int n;
map<pair<int, int>, int> mp;
int px[MAXN], py[MAXN], pl[MAXN], pr[MAXN];
map<long long, vector<int>> byrad;
map<pair<int, int>, vector<pair<int, int>>> matches;
map<pair<int, int>, vector<pair<int, int>>> singles;
map<pair<int, int>, vector<int>> queries;
void run() {
  scanf("%d", &nq);
  for (int i = (0); i < (nq); ++i) scanf("%d%d%d", &qkind[i], &qx[i], &qy[i]);
  n = 0;
  mp.clear();
  for (int i = (0); i < (nq); ++i) {
    if (qkind[i] == 1) {
      int id = n++;
      pair<int, int> key = make_pair(qx[i], qy[i]);
      assert(!mp.count(key));
      mp[key] = id;
      px[id] = qx[i], py[id] = qy[i], pl[id] = i, pr[id] = -1;
    }
    if (qkind[i] == 2) {
      pair<int, int> key = make_pair(qx[i], qy[i]);
      assert(mp.count(key));
      int id = mp[key];
      mp.erase(key);
      pr[id] = i;
    }
    if (qkind[i] == 3) {
      qans[i] = ((int)(mp).size());
    }
  }
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    int id = it->second;
    pr[id] = nq;
  }
  mp.clear();
  for (int i = (0); i < (n); ++i)
    byrad[(long long)px[i] * px[i] + (long long)py[i] * py[i]].push_back(i);
  for (auto it = byrad.begin(); it != byrad.end(); ++it) {
    vector<int> lst = it->second;
    for (int ii = (0); ii < (((int)(lst).size())); ++ii)
      for (int jj = (ii + 1); jj < (((int)(lst).size())); ++jj) {
        int i = lst[ii], j = lst[jj];
        int l = max(pl[i], pl[j]), r = min(pr[i], pr[j]);
        if (l > r) continue;
        assert(px[i] != px[j] || py[i] != py[j]);
        int cx = px[i] + px[j], cy = py[i] + py[j], g = gcd(cx, cy);
        cx /= g, cy /= g;
        matches[make_pair(cx, cy)].push_back(make_pair(l, r));
      }
  }
  for (int i = (0); i < (n); ++i) {
    int cx = px[i], cy = py[i], g = gcd(cx, cy);
    cx /= g, cy /= g;
    singles[make_pair(cx, cy)].push_back(make_pair(pl[i], pr[i]));
  }
  for (int i = (0); i < (nq); ++i)
    if (qkind[i] == 3) {
      int cx = qx[i], cy = qy[i], g = gcd(cx, cy);
      cx /= g, cy /= g;
      queries[make_pair(cx, cy)].push_back(i);
    }
  for (auto it = queries.begin(); it != queries.end(); ++it) {
    vector<int> cqueries = it->second;
    vector<pair<int, int>> cmatches = matches[it->first];
    vector<pair<int, int>> csingles = singles[it->first];
    vector<pair<int, int>> evt;
    for (int i = (0); i < (((int)(cmatches).size())); ++i)
      evt.push_back(make_pair(cmatches[i].first, -2)),
          evt.push_back(make_pair(cmatches[i].second + 1, +2));
    for (int i = (0); i < (((int)(csingles).size())); ++i)
      evt.push_back(make_pair(csingles[i].first, -1)),
          evt.push_back(make_pair(csingles[i].second + 1, +1));
    sort(cqueries.begin(), cqueries.end());
    sort(evt.begin(), evt.end());
    int at = 0, sum = 0;
    for (int i = (0); i < (((int)(cqueries).size())); ++i) {
      int id = cqueries[i];
      while (at < ((int)(evt).size()) && id >= evt[at].first)
        sum += evt[at++].second;
      qans[id] += sum;
    }
  }
  for (int i = (0); i < (nq); ++i)
    if (qkind[i] == 3) printf("%d\n", qans[i]);
}
int main() {
  run();
  return 0;
}
