#include <bits/stdc++.h>
using namespace std;
long long int mcd(long long int a, long long int b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return mcd(a % b, b);
}
struct point {
  long long int x, y;
  point() {}
  point(long long int x, long long int y) : x(x), y(y) {}
};
bool operator<(point p1, point p2) {
  if (p1.x != p2.x) return p1.x < p2.x;
  return p1.y < p2.y;
}
long long int sq(long long int x) { return x * x; }
long long int sq(point p) { return sq(p.x) + sq(p.y); }
point operator+(point p1, point p2) { return point(p1.x + p2.x, p1.y + p2.y); }
point normalize(point p) {
  long long int mc = mcd(p.x, p.y);
  return point(p.x / mc, p.y / mc);
}
map<long long int, vector<point> > mapa;
map<point, int> mapap;
int cases;
int main() {
  ios::sync_with_stdio(false);
  cin >> cases;
  int amount = 0;
  for (int cas = 0; cas < cases; cas++) {
    int t, x, y;
    cin >> t >> x >> y;
    point p(x, y);
    long long int s = sq(p);
    vector<point> &v = mapa[s];
    if (t == 1) {
      for (int i = 0; i < int(v.size()); i++) {
        point dir = normalize(p + v[i]);
        mapap[dir] += 2;
      }
      v.push_back(p);
      mapap[normalize(p)]++;
      amount++;
    } else if (t == 2) {
      vector<point> nextv;
      for (int i = 0; i < int(v.size()); i++)
        if (v[i].x != p.x or v[i].y != p.y) nextv.push_back(v[i]);
      v = nextv;
      for (int i = 0; i < int(v.size()); i++) {
        point dir = normalize(p + v[i]);
        mapap[dir] -= 2;
      }
      mapap[normalize(p)]--;
      amount--;
    } else {
      point dir = normalize(p);
      cout << amount - mapap[dir] << endl;
    }
  }
}
