#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse2,sse3,sse4")
using namespace std;
inline int gcd(int a, int b) {
  while (b != 0) {
    int c = a;
    a = b;
    b = c % b;
  }
  return a;
}
inline void normalize(int& x, int& y) {
  int g = gcd(x, y);
  x /= g;
  y /= g;
}
const int MAXN = 1e6 + 42;
unordered_map<int, int> lines[MAXN];
inline void update_(vector<pair<int, int>>& bucket) {
  int sx = bucket.back().first, sy = bucket.back().second;
  for (auto u : bucket) {
    int x = u.first, y = u.second;
    int mx = sx + x, my = sy + y;
    normalize(mx, my);
    lines[mx][my] += 2;
  }
  normalize(sx, sy);
  --lines[sx][sy];
}
inline void delete_(vector<pair<int, int>>& bucket, int x, int y) {
  for (auto u : bucket) {
    int sx = u.first, sy = u.second;
    int mx = sx + x, my = sy + y;
    normalize(mx, my);
    lines[mx][my] -= 2;
  }
  for (int i = 0; i < bucket.size(); ++i) {
    if (bucket[i] == make_pair(x, y)) {
      swap(bucket[i], bucket.back());
      bucket.pop_back();
      break;
    }
  }
  normalize(x, y);
  ++lines[x][y];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int ctr = 0;
  unordered_map<long long, vector<pair<int, int>>> bucket;
  int q;
  scanf("%d", &q);
  while (q--) {
    int type, x, y;
    scanf("%d%d%d", &type, &x, &y);
    long long gg = 1LL * x * x + 1LL * y * y;
    if (type == 1) {
      bucket[gg].push_back({x, y});
      update_(bucket[gg]);
      ++ctr;
    } else if (type == 2) {
      delete_(bucket[gg], x, y);
      --ctr;
    } else {
      normalize(x, y);
      printf("%d\n", ctr - lines[x][y]);
    }
  }
}
